@camstack/addon-admin-ui 1.2.511 → 1.2.512
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/dist/assets/{AddonAssetIcon-BhmFaWF6.js → AddonAssetIcon-DCKCRhEh.js} +1 -1
- package/dist/assets/{Addons-DaNcypAW.js → Addons-DPAqJ5aW.js} +1 -1
- package/dist/assets/{AdminPage-Cywt1sv5.js → AdminPage-CVSTxsAk.js} +1 -1
- package/dist/assets/{AdminSectionedPage-D8XbpLmz.js → AdminSectionedPage-BG6w5-w1.js} +1 -1
- package/dist/assets/{AiProfiles-qBccFu5d.js → AiProfiles-DR_I4RIr.js} +1 -1
- package/dist/assets/{BrokerEditorDialog-C2p0P4ye.js → BrokerEditorDialog-Dd6KEwRN.js} +1 -1
- package/dist/assets/Build-C8Iyyb5o.js +40 -0
- package/dist/assets/{Calendars-74ckkFP0.js → Calendars-BHqwUpG9.js} +1 -1
- package/dist/assets/{Cluster-1JwXjjed.js → Cluster-DDjN53AW.js} +1 -1
- package/dist/assets/CompositionBlockEditor-B81aTqq3.js +1 -0
- package/dist/assets/{CompositionEditorPage-DE9Rccl2.js → CompositionEditorPage-CbLv15x4.js} +1 -1
- package/dist/assets/{Data-DWYM-kxy.js → Data-CJqiuGjd.js} +1 -1
- package/dist/assets/{DeviceDetail-CVMOCWi5.js → DeviceDetail-DvtPS7Er.js} +1 -1
- package/dist/assets/{DeviceDoActionFields-BDdQwLvn.js → DeviceDoActionFields-DnA_DSYw.js} +1 -1
- package/dist/assets/{Devices-DdCovTvt.js → Devices-B9SE3Rwm.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-BeuVN1QD.js → EmbedPlayerPage-D63WF3oV.js} +1 -1
- package/dist/assets/HelperWizard-BigkVmsB.js +2 -0
- package/dist/assets/{History-DVdEMBYJ.js → History-D0syoHcx.js} +1 -1
- package/dist/assets/{Identity-DNSkhe9x.js → Identity-CElkwZnz.js} +1 -1
- package/dist/assets/{IntegrationDetail-DZttjxiw.js → IntegrationDetail-DZ8ztuOE.js} +1 -1
- package/dist/assets/{IntegrationHub-DqbKVh4N.js → IntegrationHub-DiscqOsj.js} +1 -1
- package/dist/assets/{Integrations-BfgfABQl.js → Integrations-BfCE8MnT.js} +1 -1
- package/dist/assets/{Integrations-BmU9vQlf.js → Integrations-CHguUclI.js} +1 -1
- package/dist/assets/{Library-D268sj-L.js → Library-C2NTg1uA.js} +1 -1
- package/dist/assets/{Locations-D7E3SmAX.js → Locations-DWad73x-.js} +1 -1
- package/dist/assets/{Logs-IXGaCSMo.js → Logs-kEWkWloD.js} +1 -1
- package/dist/assets/{MyAccess-Bred4wkj.js → MyAccess-CS5GrN5k.js} +1 -1
- package/dist/assets/{Network-sb7soD7f.js → Network-DtfAuiol.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BswQpSzM.js → NodeAddonsSettingsPanel-lczGJdHs.js} +1 -1
- package/dist/assets/{Notifications-CjXAcavg.js → Notifications-DchKpNOg.js} +1 -1
- package/dist/assets/{Pipeline-DURRCrIJ.js → Pipeline-vgUZsFFP.js} +1 -1
- package/dist/assets/{Recordings-D1a7Ipp3.js → Recordings-CyPYQ20P.js} +1 -1
- package/dist/assets/{ScanNetworkModal-9eawQeIJ.js → ScanNetworkModal-Bg22q8vm.js} +1 -1
- package/dist/assets/{SessionsList-BtpHp2KM.js → SessionsList-CfuTFr66.js} +1 -1
- package/dist/assets/{Showroom-C0KMMGgI.js → Showroom-R3reqgpn.js} +1 -1
- package/dist/assets/{System-Ca9giuGu.js → System-r9rg9iWn.js} +1 -1
- package/dist/assets/{Terminal-Ct5pxKeO.js → Terminal-B5qyGLn1.js} +1 -1
- package/dist/assets/{Viewer-D_HQWvCc.js → Viewer-CLvHpMj8.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BTJLKrn5.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-GbWwXkZ2.js} +1 -1
- package/dist/assets/{addon-icons-context-7pMoFmo9.js → addon-icons-context-ClSTx0Nd.js} +1 -1
- package/dist/assets/{assignment-candidates-DctD4-Kk.js → assignment-candidates-B0B3pJGN.js} +1 -1
- package/dist/assets/{authed-media-DyWWajaJ.js → authed-media-Ba0gOxiM.js} +1 -1
- package/dist/assets/{board-model-DKqEIHLh.js → board-model-DcpPhztF.js} +1 -1
- package/dist/assets/{device-integration-icon-Bh0Znsav.js → device-integration-icon-Nwyo5V5H.js} +1 -1
- package/dist/assets/device-picker-model-C44QyL85.js +1 -0
- package/dist/assets/{format-D360_J0N.js → format-u0sqgb1J.js} +1 -1
- package/dist/assets/{hostInit-B2k6yhyi.js → hostInit-VFHoBRCk.js} +1 -1
- package/dist/assets/{i18n-B5uU8u6u.js → i18n-CXGP1uaw.js} +1 -1
- package/dist/assets/{index-DUl9HFmr.css → index-Dep3DVAz.css} +1 -1
- package/dist/assets/{index-CuvJet67.js → index-lH9UKmhf.js} +3 -3
- package/dist/assets/{linked-devices-model-B8JwCaUn.js → linked-devices-model-COUfIEod.js} +1 -1
- package/dist/assets/{location-owned-usage-CVWBPy28.js → location-owned-usage-BmtVONF0.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-56c74718.js → mf-entry-bootstrap-0-556ccfd0.js} +2 -2
- package/dist/assets/mount-C44QyL85.js +1 -0
- package/dist/assets/remoteEntry-De9zVsA0.js +1 -0
- package/dist/assets/{src-vYMgzn3X.js → src-IQsaq5W-.js} +2 -2
- package/dist/assets/{step-inspector-model-BZFtfupM.js → step-inspector-model-CW9NPxgI.js} +1 -1
- package/dist/assets/{use-scenes-feed-CGtWB1L7.js → use-scenes-feed-CQOhXjvP.js} +1 -1
- package/dist/assets/{use-stationary-objects-Cp1KGKmU.js → use-stationary-objects-D9KV1ze2.js} +1 -1
- package/dist/assets/useEventInvalidation-C44QyL85.js +1 -0
- package/dist/assets/{useNodeUrlSelection-BsZGUghh.js → useNodeUrlSelection-CAyN93HW.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BQEGoWCP.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dyo8T61H.js} +2 -2
- package/dist/index.html +7 -7
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Build-DRh7B9_e.js +0 -40
- package/dist/assets/CompositionBlockEditor-CV4xvSqS.js +0 -1
- package/dist/assets/HelperWizard-TPowwspC.js +0 -2
- package/dist/assets/device-picker-model-CreVFMrD.js +0 -1
- package/dist/assets/mount-CreVFMrD.js +0 -1
- package/dist/assets/remoteEntry-BlJC9q2U.js +0 -1
- package/dist/assets/useEventInvalidation-CreVFMrD.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./icons-BJz9Yj7E.js","./player-overlays-B5FSaids.js","./client-JLEP7nv7.js","./__vite-browser-external-BlMfPwfH.js","./archive-P7vGIXBL.js","./user-x-DKorc3CR.js","./scan-eye-gmpggdW4.js","./scissors-CCgXntCX.js","./bell-off-B4S4Brhx.js","./sigma-Bzh2qqL3.js","./key-drN5OJov.js","./boxes-Cc83jXU7.js","./variable-BXBhuk59.js","./cloud-upload-BNAApVPM.js","./video-2nOnVl_R.js","./speaker-CmGzkRdE.js","./circle-slash-fwUwJ3r8.js","./usb-CdZusF7Y.js","./crop-j4n-xPUF.js","./eraser-CfQsg9Ve.js","./timer-reset-ceaN5uh6.js","./send-B8FKrOyC.js","./hard-drive-download-PwUdP9sZ.js","./mic-off-Dyo6dwK_.js","./list-ordered-A3gv0vJA.js","./key-round-CBhTR29b.js","./layers-C5Yl1IY5.js","./log-in-ChqbFBLh.js","./memory-stick-B__TSEyk.js","./message-square-plus-BERx-QaF.js","./monitor-off-Czfm61g6.js","./monitor-smartphone-tJnvQ6Wt.js","./recycle-droAKct3.js","./search-x-D1xSmXhu.js","./settings-2-BdhYf7UQ.js","./table-2-DaQYtXJ7.js","./unlink-CZPQIK73.js","./user-round-yFN2hAUV.js","./MotionZonesSettings-BXHdXw3X.js","./MaskShapeCanvas-D6XVNdwA.js","./PrivacyMaskSettings-BXiuTmLQ.js","./SceneMonitorEditor-ChgZnP_I.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t,i as n,o as r,r as i}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BQEGoWCP.js";import{t as a}from"./vite-preload-helper-kNaey6uv.js";import{$ as o,A as s,C as c,E as l,G as u,H as d,J as f,K as p,N as m,O as h,Q as g,R as _,S as v,U as y,V as b,W as x,X as S,Y as C,a as w,d as T,et as E,j as D,k as O,o as k,q as A,t as j,u as M,w as N,x as P,y as F,z as I}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$ as L,$i as R,$n as z,$r as B,$t as V,A as H,Ai as U,An as ee,Ar as W,At as G,B as te,Bi as ne,Bn as re,Br as K,Bt as ie,C as ae,Ci as oe,Cn as se,Cr as ce,Ct as le,D as ue,Di as de,Dn as fe,Dr as pe,Dt as me,E as he,Ei as ge,En as _e,Er as ve,Et as ye,F as be,Fi as xe,Fn as Se,Fr as Ce,Ft as we,G as Te,Gi as Ee,Gn as De,Gr as Oe,Gt as ke,H as Ae,Hi as je,Hn as Me,Hr as Ne,Ht as Pe,I as Fe,Ii as Ie,In as Le,Ir as Re,It as ze,J as Be,Ji as Ve,Jn as He,Jr as Ue,Jt as We,K as Ge,Ki as Ke,Kn as qe,Kr as Je,Kt as Ye,L as Xe,Li as Ze,Ln as Qe,Lr as $e,Lt as et,Mi as tt,Mn as nt,Mr as rt,Mt as it,N as at,Ni as ot,Nn as st,Nr as ct,Nt as lt,O as ut,Oi as dt,On as ft,Or as pt,Ot as mt,P as ht,Pi as gt,Pn as _t,Pr as vt,Pt as yt,Q as bt,Qi as xt,Qn as St,Qr as Ct,Qt as wt,R as Tt,Ri as Et,Rn as Dt,Rr as Ot,Rt as kt,S as At,Si as jt,Sn as Mt,Sr as Nt,St as Pt,T as Ft,Ti as It,Tn as Lt,Tr as eee,Tt as Rt,U as zt,Ui as Bt,Un as Vt,Ur as Ht,Ut as tee,V as Ut,Vi as Wt,Vn as Gt,Vr as Kt,Vt as qt,W as Jt,Wi as Yt,Wn as Xt,Wr as Zt,Wt as Qt,X as $t,Xi as en,Xn as tn,Xr as nn,Xt as rn,Y as an,Yi as on,Yn as sn,Yr as cn,Yt as ln,Z as un,Zi as dn,Zn as fn,Zr as pn,Zt as mn,_ as hn,_i as gn,_n,_r as vn,_t as yn,a as bn,aa as xn,ai as Sn,an as Cn,ar as wn,at as Tn,b as En,bi as Dn,bn as On,br as kn,bt as An,c as jn,ci as Mn,cn as nee,cr as Nn,ct as Pn,d as ree,da as Fn,di as In,dn as Ln,dr as iee,dt as Rn,ea as aee,ei as oee,en as see,er as zn,et as Bn,f as Vn,fa as Hn,fi as Un,fn as Wn,fr as Gn,ft as Kn,g as qn,gi as Jn,gn as Yn,gr as Xn,gt as Zn,h as Qn,hi as $n,hn as er,hr as tr,ht as nr,i as rr,ia as ir,ii as ar,in as or,ir as sr,it as cr,j as lr,ji as ur,jn as dr,jr as fr,jt as pr,k as mr,ki as hr,kn as gr,kr as _r,kt as vr,l as yr,la as br,li as xr,ln as Sr,lr as Cr,lt as wr,m as Tr,mi as Er,mn as Dr,mr as Or,mt as kr,n as Ar,na as jr,ni as Mr,nn as Nr,nr as Pr,nt as Fr,o as Ir,oa as Lr,oi as Rr,on as zr,or as Br,ot as Vr,p as Hr,pa as q,pi as Ur,pn as Wr,pr as Gr,pt as Kr,q as qr,qi as Jr,qn as Yr,qr as Xr,qt as Zr,r as Qr,ra as $r,ri as ei,rn as ti,rr as ni,rt as ri,s as ii,sa as ai,si as oi,sn as si,sr as ci,st as li,t as ui,ta as di,ti as fi,tn as pi,tr as mi,tt as hi,u as cee,ua as gi,ui as _i,un as vi,ur as yi,ut as bi,v as xi,vi as Si,vn as Ci,vr as wi,vt as Ti,w as lee,wi as Ei,wn as Di,wr as Oi,wt as uee,x as ki,xi as Ai,xn as ji,xr as dee,xt as fee,y as Mi,yi as Ni,yn as Pi,yr as pee,yt as Fi,z as Ii,zi as Li,zn as mee,zr as Ri,zt as zi}from"./player-overlays-B5FSaids.js";import{$ as hee,$a as Bi,Aa as Vi,Ca as gee,Ea as _ee,Fa as vee,Fr as Hi,Ga as yee,Ia as Ui,Jn as Wi,Ka as Gi,La as bee,Na as xee,Nr as Ki,Pa as See,Qa as qi,Ra as Cee,Sa as wee,Sr as Ji,Ta as Yi,Ua as Xi,Va as Tee,Wa as Eee,Wt as Zi,Xa as Dee,Xn as Oee,Xr as kee,Zr as Aee,_ as Qi,_a as $i,_n as ea,ai as ta,an as na,ao as ra,ar as ia,at as aa,b as oa,ba as sa,bi as ca,bn as la,ci as ua,co as da,cr as fa,da as J,dr as pa,ei as ma,eo as ha,et as ga,f as _a,g as va,ga as ya,gn as ba,h as xa,ha as Sa,ii as Ca,in as wa,ir as Ta,it as Ea,ja as Da,la as Oa,m as ka,ma as Aa,ni as ja,nn as Ma,no as Na,nt as Pa,o as Fa,oa as Ia,oi as La,ot as Ra,p as za,qn as Ba,r as Va,ri as Ha,rt as Ua,si as Wa,so as Ga,ti as Ka,tn as qa,to as Ja,u as Ya,ua as Y,ur as Xa,v as Za,va as Qa,vn as $a,vr as eo,wa as to,x as no,xa as ro,xn as io,y as ao,ya as oo,zr as so}from"./client-JLEP7nv7.js";import{D as co,M as lo,O as uo,S as fo,T as po,j as mo,p as ho,v as go,y as _o}from"./__vite-browser-external-BlMfPwfH.js";import{T as vo,b as yo,g as bo,k as xo,o as So,x as Co}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js";import{r as wo,t as To}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{n as Eo,r as Do,t as Oo}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{n as ko,t as Ao}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";E();var jo=typeof globalThis<`u`?globalThis.__camstackTrpcReact:void 0,X=jo??To();typeof globalThis<`u`&&!jo&&(globalThis.__camstackTrpcReact=X);function Mo(e,t){let n=Rn(),r=f(t);r.current=t;let[i,a]=C(n.connectionVersion);b(()=>n.subscribeConnectionEvents((e,t)=>{e===`connected`&&a(t)}),[n]),b(()=>n.subscribeEvent(e,e=>{r.current(e)}),[n,e,i])}E();function No(e){let t=f(e);return t.current=e,t}function Po(e,t){let[n,r]=C(null),i=No(t);return Mo(e,e=>{let t=e.data,n=i.current;n&&!n(t)||r(t)}),n}function Fo(e,t,n){let[r,i]=C(()=>new Map),a=No(t),o=No(n);return Mo(e,e=>{let t=e.data,n=o.current;if(n&&!n(t))return;let r=a.current(t);i(e=>{let n=new Map(e);return n.set(r,t),n})}),{map:r,values:p(()=>Array.from(r.values()),[r])}}E();function Io(){let{data:e,isLoading:t,isError:n}=X.nodes.topology.useQuery(void 0,{staleTime:1/0});return{nodes:Po(`cluster.topology-snapshot`)?.nodes??e,isLoading:t,isError:n}}function Lo(){let{nodes:e,isLoading:t,isError:n}=Io();return{nodes:p(()=>{let t=[];for(let n of e??[])t.push({id:String(n.id??``),name:String(n.name??n.id??``),shortName:n.isHub?`HUB`:String(n.name??n.id??``),isHub:!!n.isHub,isOnline:!!n.isOnline,localIps:n.localIps??[],addons:(n.addons??[]).map(e=>({addonId:e.id,capabilities:e.capabilities}))});return t.sort((e,t)=>e.isHub===t.isHub?e.name.localeCompare(t.name):e.isHub?-1:1),t},[e]),isLoading:t,isError:n}}function Ro(e,t){return{icon:e.icon,label:t(e.labelKey,e.labelFallback)}}var zo={[J.Camera]:{icon:ot,labelKey:`uiLibrary.deviceMeta.type.camera`,labelFallback:`Camera`},[J.Hub]:{icon:De,labelKey:`uiLibrary.deviceMeta.type.hub`,labelFallback:`Hub`},[J.Light]:{icon:Xn,labelKey:`uiLibrary.deviceMeta.type.light`,labelFallback:`Light`},[J.Siren]:{icon:Sr,labelKey:`uiLibrary.deviceMeta.type.siren`,labelFallback:`Siren`},[J.Switch]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.type.switch`,labelFallback:`Switch`},[J.Sensor]:{icon:ai,labelKey:`uiLibrary.deviceMeta.type.sensor`,labelFallback:`Sensor`},[J.Thermostat]:{icon:We,labelKey:`uiLibrary.deviceMeta.type.thermostat`,labelFallback:`Thermostat`},[J.Climate]:{icon:Lr,labelKey:`uiLibrary.deviceMeta.type.climate`,labelFallback:`Air conditioner`},[J.Button]:{icon:Si,labelKey:`uiLibrary.deviceMeta.type.button`,labelFallback:`Button`},[J.EventEmitter]:{icon:nr,labelKey:`uiLibrary.deviceMeta.type.eventEmitter`,labelFallback:`Event Emitter`},[J.Update]:{icon:_e,labelKey:`uiLibrary.deviceMeta.type.update`,labelFallback:`Update`},[J.Generic]:{icon:Ze,labelKey:`uiLibrary.deviceMeta.type.generic`,labelFallback:`Generic`},[J.Notifier]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.type.notifier`,labelFallback:`Notifier`},[J.Script]:{icon:Pi,labelKey:`uiLibrary.deviceMeta.type.script`,labelFallback:`Script`},[J.Automation]:{icon:Ti,labelKey:`uiLibrary.deviceMeta.type.automation`,labelFallback:`Automation`},[J.Lock]:{icon:Cr,labelKey:`uiLibrary.deviceMeta.type.lock`,labelFallback:`Lock`},[J.Cover]:{icon:ne,labelKey:`uiLibrary.deviceMeta.type.cover`,labelFallback:`Cover`},[J.Valve]:{icon:Dt,labelKey:`uiLibrary.deviceMeta.type.valve`,labelFallback:`Valve`},[J.Humidifier]:{icon:Rt,labelKey:`uiLibrary.deviceMeta.type.humidifier`,labelFallback:`Humidifier`},[J.WaterHeater]:{icon:en,labelKey:`uiLibrary.deviceMeta.type.waterHeater`,labelFallback:`Water heater`},[J.Fan]:{icon:Ht,labelKey:`uiLibrary.deviceMeta.type.fan`,labelFallback:`Fan`},[J.MediaPlayer]:{icon:z,labelKey:`uiLibrary.deviceMeta.type.mediaPlayer`,labelFallback:`Media player`},[J.AlarmPanel]:{icon:Dr,labelKey:`uiLibrary.deviceMeta.type.alarmPanel`,labelFallback:`Alarm panel`},[J.Control]:{icon:zr,labelKey:`uiLibrary.deviceMeta.type.control`,labelFallback:`Control`},[J.Presence]:{icon:ci,labelKey:`uiLibrary.deviceMeta.type.presence`,labelFallback:`Presence`},[J.Weather]:{icon:Rr,labelKey:`uiLibrary.deviceMeta.type.weather`,labelFallback:`Weather`},[J.Vacuum]:{icon:Et,labelKey:`uiLibrary.deviceMeta.type.vacuum`,labelFallback:`Vacuum`},[J.LawnMower]:{icon:Qt,labelKey:`uiLibrary.deviceMeta.type.lawnMower`,labelFallback:`Lawn mower`},[J.Container]:{icon:Ze,labelKey:`uiLibrary.deviceMeta.type.container`,labelFallback:`Container`},[J.Image]:{icon:Nt,labelKey:`uiLibrary.deviceMeta.type.image`,labelFallback:`Image`},[J.PetFeeder]:{icon:Li,labelKey:`uiLibrary.deviceMeta.type.petFeeder`,labelFallback:`Pet feeder`},[J.Dishwasher]:{icon:Rt,labelKey:`uiLibrary.deviceMeta.type.dishwasher`,labelFallback:`Dishwasher`},[J.Washer]:{icon:ye,labelKey:`uiLibrary.deviceMeta.type.washer`,labelFallback:`Washing machine`},[J.Dryer]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.type.dryer`,labelFallback:`Dryer`}},Bo={[Y.Siren]:{icon:Sr,labelKey:`uiLibrary.deviceMeta.role.siren`,labelFallback:`Siren`},[Y.Floodlight]:{icon:Xn,labelKey:`uiLibrary.deviceMeta.role.floodlight`,labelFallback:`Floodlight`},[Y.Spotlight]:{icon:Ot,labelKey:`uiLibrary.deviceMeta.role.spotlight`,labelFallback:`Spotlight`},[Y.PirSensor]:{icon:gr,labelKey:`uiLibrary.deviceMeta.role.pirSensor`,labelFallback:`PIR sensor`},[Y.Chime]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.role.chime`,labelFallback:`Chime`},[Y.Autotrack]:{icon:fi,labelKey:`uiLibrary.deviceMeta.role.autotrack`,labelFallback:`Auto-track`},[Y.Nightvision]:{icon:St,labelKey:`uiLibrary.deviceMeta.role.nightvision`,labelFallback:`Night vision`},[Y.PrivacyMask]:{icon:Oe,labelKey:`uiLibrary.deviceMeta.role.privacyMask`,labelFallback:`Privacy mask`},[Y.Doorbell]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.doorbell`,labelFallback:`Doorbell`},[Y.CoverBlind]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverBlind`,labelFallback:`Blind`},[Y.CoverShutter]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverShutter`,labelFallback:`Shutter`},[Y.CoverAwning]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverAwning`,labelFallback:`Awning`},[Y.CoverCurtain]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverCurtain`,labelFallback:`Curtain`},[Y.CoverGarage]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.coverGarage`,labelFallback:`Garage door`},[Y.CoverGate]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.coverGate`,labelFallback:`Gate`},[Y.CoverDoor]:{icon:pn,labelKey:`uiLibrary.deviceMeta.role.coverDoor`,labelFallback:`Door`},[Y.CoverWindow]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverWindow`,labelFallback:`Window`},[Y.BinaryHelper]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.role.binaryHelper`,labelFallback:`Binary helper`},[Y.Outlet]:{icon:_t,labelKey:`uiLibrary.deviceMeta.role.outlet`,labelFallback:`Outlet`},[Y.MotionSensor]:{icon:$e,labelKey:`uiLibrary.deviceMeta.role.motionSensor`,labelFallback:`Motion sensor`},[Y.ContactSensor]:{icon:pn,labelKey:`uiLibrary.deviceMeta.role.contactSensor`,labelFallback:`Contact sensor`},[Y.LeakSensor]:{icon:cn,labelKey:`uiLibrary.deviceMeta.role.leakSensor`,labelFallback:`Leak sensor`},[Y.SmokeSensor]:{icon:xn,labelKey:`uiLibrary.deviceMeta.role.smokeSensor`,labelFallback:`Smoke sensor`},[Y.COSensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.cOSensor`,labelFallback:`CO sensor`},[Y.GasSensor]:{icon:K,labelKey:`uiLibrary.deviceMeta.role.gasSensor`,labelFallback:`Gas sensor`},[Y.TamperSensor]:{icon:Dr,labelKey:`uiLibrary.deviceMeta.role.tamperSensor`,labelFallback:`Tamper sensor`},[Y.VibrationSensor]:{icon:vr,labelKey:`uiLibrary.deviceMeta.role.vibrationSensor`,labelFallback:`Vibration sensor`},[Y.ConnectivitySensor]:{icon:An,labelKey:`uiLibrary.deviceMeta.role.connectivitySensor`,labelFallback:`Connectivity`},[Y.SoundSensor]:{icon:mt,labelKey:`uiLibrary.deviceMeta.role.soundSensor`,labelFallback:`Sound sensor`},[Y.BinarySensor]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.role.binarySensor`,labelFallback:`Binary sensor`},[Y.TemperatureSensor]:{icon:We,labelKey:`uiLibrary.deviceMeta.role.temperatureSensor`,labelFallback:`Temperature`},[Y.HumiditySensor]:{icon:Ue,labelKey:`uiLibrary.deviceMeta.role.humiditySensor`,labelFallback:`Humidity`},[Y.AmbientLightSensor]:{icon:wt,labelKey:`uiLibrary.deviceMeta.role.ambientLightSensor`,labelFallback:`Ambient light`},[Y.PressureSensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.pressureSensor`,labelFallback:`Pressure`},[Y.WindSensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.windSensor`,labelFallback:`Wind`},[Y.RainSensor]:{icon:Mn,labelKey:`uiLibrary.deviceMeta.role.rainSensor`,labelFallback:`Rain`},[Y.UvSensor]:{icon:V,labelKey:`uiLibrary.deviceMeta.role.uvSensor`,labelFallback:`UV index`},[Y.SolarRadiationSensor]:{icon:mn,labelKey:`uiLibrary.deviceMeta.role.solarRadiationSensor`,labelFallback:`Solar radiation`},[Y.SoilMoistureSensor]:{icon:Nr,labelKey:`uiLibrary.deviceMeta.role.soilMoistureSensor`,labelFallback:`Soil moisture`},[Y.PowerSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.powerSensor`,labelFallback:`Power`},[Y.EnergySensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.energySensor`,labelFallback:`Energy`},[Y.VoltageSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.voltageSensor`,labelFallback:`Voltage`},[Y.CurrentSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.currentSensor`,labelFallback:`Current`},[Y.AirQualitySensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.airQualitySensor`,labelFallback:`Air quality`},[Y.BatterySensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.batterySensor`,labelFallback:`Battery`},[Y.NumericSensor]:{icon:pe,labelKey:`uiLibrary.deviceMeta.role.numericSensor`,labelFallback:`Numeric sensor`},[Y.EnumSensor]:{icon:Gr,labelKey:`uiLibrary.deviceMeta.role.enumSensor`,labelFallback:`Enum sensor`},[Y.DateTimeSensor]:{icon:In,labelKey:`uiLibrary.deviceMeta.role.dateTimeSensor`,labelFallback:`Date / time`},[Y.GenericSensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.genericSensor`,labelFallback:`Sensor`},[Y.NumericControl]:{icon:zr,labelKey:`uiLibrary.deviceMeta.role.numericControl`,labelFallback:`Numeric control`},[Y.SelectControl]:{icon:Or,labelKey:`uiLibrary.deviceMeta.role.selectControl`,labelFallback:`Select control`},[Y.TextControl]:{icon:et,labelKey:`uiLibrary.deviceMeta.role.textControl`,labelFallback:`Text control`},[Y.DateTimeControl]:{icon:In,labelKey:`uiLibrary.deviceMeta.role.dateTimeControl`,labelFallback:`Date / time control`},[Y.MobilePushNotifier]:{icon:Cn,labelKey:`uiLibrary.deviceMeta.role.mobilePushNotifier`,labelFallback:`Mobile push`},[Y.MessagingNotifier]:{icon:ni,labelKey:`uiLibrary.deviceMeta.role.messagingNotifier`,labelFallback:`Messaging`},[Y.EmailNotifier]:{icon:Nn,labelKey:`uiLibrary.deviceMeta.role.emailNotifier`,labelFallback:`Email`},[Y.GenericNotifier]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.role.genericNotifier`,labelFallback:`Notifier`},[Y.IrTransmitter]:{icon:ft,labelKey:`uiLibrary.deviceMeta.role.irTransmitter`,labelFallback:`IR/RF transmitter`}},Vo=new Set(Object.values(J)),Ho=new Set(Object.values(Y));function Uo(e){return Vo.has(e)}function Wo(e){return Ho.has(e)}function Go(e,t=Fn){return Ro(zo[e],t)}function Ko(e,t=Fn){return Ro(Bo[e],t)}var qo=zo[J.Generic],Jo=Bo[Y.GenericSensor];function Yo(e,t=Fn){return Uo(e)?Ro(zo[e]??qo,t):Ro(qo,t)}function Xo(e,t=Fn){return Wo(e)?Ro(Bo[e]??Jo,t):Ro(Jo,t)}var Zo={camera:ot,network:De,"toggle-left":Ye,"circle-dot":Si,"refresh-cw":_e,box:Ze,"scroll-text":Pi,workflow:Ti,lock:Cr,blinds:ne,"air-vent":Lr,"monitor-play":z,"sliders-horizontal":zr,"map-pin":ci,bot:Et,tractor:Qt,image:Nt,bone:Li,"door-closed":Ct,"door-open":pn,crosshair:fi,"eye-off":Oe,smartphone:Cn,power:nt,battery:Ee,lightbulb:Xn,flashlight:Ot,thermometer:We,droplets:Ue,droplet:cn,gauge:vt,sun:wt,"sun-medium":V,sunrise:mn,moon:St,wind:Fi,"cloud-rain":Mn,"cloud-sun":Rr,waves:Rt,sprout:Nr,zap:nr,flame:K,bell:Bt,siren:Sr,radar:gr,activity:ai,hash:pe,clock:In,pipette:Dt,fan:Ht,bath:en,footprints:$e,"alarm-smoke":xn,"shield-alert":Dr,vibrate:vr,wifi:An,"volume-2":mt,list:Gr,"list-checks":Or,mail:Nn,"message-square":ni,type:et};function Qo(e){return Object.values(J).map(t=>{let n=Yo(t,e);return{id:t,label:n.label,icon:n.icon}})}var $o=Qo(Fn);function es(e=Fn){return e===Fn?$o:Qo(e)}E();var ts,ns,rs,is=0,as=new Set;function os(){is+=1;for(let e of as)e()}function ss(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function cs(){return ts===void 0?rs===void 0?(ns??=a(()=>import(`./icons-BJz9Yj7E.js`).then(e=>{ts=e,os()},e=>{throw rs=e,os(),e}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url),ns):Promise.reject(rs):Promise.resolve()}function ls(){return rs!==void 0}function us(){return ts!==void 0}function ds(e){let t=Ka(e);if(t===void 0)return;let n=Zo[t];if(n!==void 0)return n;if(ts!==void 0)return ts[ss(t)];rs===void 0&&cs().catch(()=>void 0)}function fs(e){return as.add(e),()=>{as.delete(e)}}var ps=()=>is;function ms(){return S(fs,ps,ps)}function hs(){return p(()=>e=>ds(e),[ms()])}function gs(e){let t=e.split(`+`),n=t[t.length-1]??``,r=t.slice(0,-1);return{mod:r.includes(`mod`),shift:r.includes(`shift`),alt:r.includes(`alt`),key:n}}function _s(){return typeof navigator>`u`?`other`:/mac|iphone|ipad/i.test(navigator.platform)?`mac`:`other`}function vs(e,t,n){let r=gs(t),i=n===`mac`?e.metaKey:e.ctrlKey,a=n===`mac`?e.ctrlKey:e.metaKey;return e.key.toLowerCase()===r.key&&i===r.mod&&!a&&e.shiftKey===r.shift&&e.altKey===r.alt}E();var ys=`page`,bs=`fallback`,xs=O(null),Ss=O(ys);function Cs(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`:!1}function ws(e,t,n){if(t.isComposing||t.keyCode===229)return;let r=Cs(t.target),i=[...[...e.scopes].reverse().map(e=>e.id),ys,bs];for(let a of i){let i=e.bindings.filter(e=>e.scope===a&&vs(t,e.combo,n)).reverse();for(let e of i)if(!(r&&!e.allowInInput)&&e.handlerRef.current(t)!==!1){e.preventDefault&&t.preventDefault();return}if(e.scopes.find(e=>e.id===a)?.modal)return}}function Ts({children:e,platform:t}){let n=f({bindings:[],scopes:[]}),r=t??_s(),i=p(()=>({addBinding:e=>(n.current={...n.current,bindings:[...n.current.bindings,e]},()=>{n.current={...n.current,bindings:n.current.bindings.filter(t=>t.id!==e.id)}}),addScope:e=>(n.current={...n.current,scopes:[...n.current.scopes,e]},()=>{n.current={...n.current,scopes:n.current.scopes.filter(t=>t!==e)}})}),[]);return b(()=>{let e=e=>ws(n.current,e,r);return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r]),v(xs.Provider,{value:i,children:e})}var Es=0;function Ds(e,t,n={}){let r=I(xs),i=I(Ss),a=f(t);a.current=t;let o=n.scope??i,s=n.enabled??!0,c=n.preventDefault??!0,l=n.allowInInput??gs(e).mod;b(()=>{if(!(!r||!s))return Es+=1,r.addBinding({id:Es,combo:e,scope:o,handlerRef:a,preventDefault:c,allowInInput:l})},[r,s,e,o,c,l])}function Os({id:e,children:t,enabled:n=!0,modal:r=!1}){let i=I(xs);return b(()=>{if(!(!i||!n))return i.addScope({id:e,modal:r})},[i,n,e,r]),v(Ss.Provider,{value:e,children:t})}function ks(e){return e.isConnected&&!e.disabled&&e.getClientRects().length>0}function As(e,t={}){let n=t.enabled??!0,r=t.scope,i=()=>{let t=e.current;return!t||!ks(t)?!1:(t.focus(),t.select(),!0)};Ds(`mod+f`,i,{enabled:n,scope:r}),Ds(`mod+k`,i,{enabled:n,scope:r})}Do();function js(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=js(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Ms(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=js(e))&&(r&&(r+=` `),r+=t);return r}var Ns=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Ps=(e,t)=>({classGroupId:e,validator:t}),Fs=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Is=`-`,Ls=[],Rs=`arbitrary..`,zs=e=>{let t=Hs(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Vs(e);let n=e.split(Is);return Bs(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Ns(i,t):t:i||Ls}return n[e]||Ls}}},Bs=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Bs(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Is):e.slice(t).join(Is),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Vs=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Rs+r:void 0})(),Hs=e=>{let{theme:t,classGroups:n}=e;return Us(n,t)},Us=(e,t)=>{let n=Fs();for(let r in e){let i=e[r];Ws(i,n,r,t)}return n},Ws=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Gs(i,t,n,r)}},Gs=(e,t,n,r)=>{if(typeof e==`string`){Ks(e,t,n);return}if(typeof e==`function`){qs(e,t,n,r);return}Js(e,t,n,r)},Ks=(e,t,n)=>{let r=e===``?t:Ys(t,e);r.classGroupId=n},qs=(e,t,n,r)=>{if(Xs(e)){Ws(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ps(n,e))},Js=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ws(o,Ys(t,a),n,r)}},Ys=(e,t)=>{let n=e,r=t.split(Is),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Fs(),n.nextPart.set(t,i)),n=i}return n},Xs=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Zs=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Qs=`!`,$s=`:`,ec=[],tc=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),nc=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===$s){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Qs)?(c=s.slice(0,-1),l=!0):s.startsWith(Qs)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return tc(t,l,c,u)};if(t){let e=t+$s,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):tc(ec,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},rc=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},ic=e=>({cache:Zs(e.cacheSize),parseClassName:nc(e),sortModifiers:rc(e),postfixLookupClassGroupIds:ac(e),...zs(e)}),ac=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},oc=/\s+/,sc=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(oc),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Qs:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},cc=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=lc(n))&&(i&&(i+=` `),i+=r);return i},lc=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=lc(e[r]))&&(n&&(n+=` `),n+=t);return n},uc=(e,...t)=>{let n,r,i,a,o=o=>(n=ic(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=sc(e,n);return i(e,a),a};return a=o,(...e)=>a(cc(...e))},dc=[],fc=e=>{let t=t=>t[e]||dc;return t.isThemeGetter=!0,t},pc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,mc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_c=/\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$/,vc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,yc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xc=e=>hc.test(e),Sc=e=>!!e&&!Number.isNaN(Number(e)),Cc=e=>!!e&&Number.isInteger(Number(e)),wc=e=>e.endsWith(`%`)&&Sc(e.slice(0,-1)),Tc=e=>gc.test(e),Ec=()=>!0,Dc=e=>_c.test(e)&&!vc.test(e),Oc=()=>!1,kc=e=>yc.test(e),Ac=e=>bc.test(e),jc=e=>!Z(e)&&!Q(e),Mc=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Nc=e=>Jc(e,Qc,Oc),Z=e=>pc.test(e),Pc=e=>Jc(e,$c,Dc),Fc=e=>Jc(e,el,Sc),Ic=e=>Jc(e,nl,Ec),Lc=e=>Jc(e,tl,Oc),Rc=e=>Jc(e,Xc,Oc),zc=e=>Jc(e,Zc,Ac),Bc=e=>Jc(e,rl,kc),Q=e=>mc.test(e),Vc=e=>Yc(e,$c),Hc=e=>Yc(e,tl),Uc=e=>Yc(e,Xc),Wc=e=>Yc(e,Qc),Gc=e=>Yc(e,Zc),Kc=e=>Yc(e,rl,!0),qc=e=>Yc(e,nl,!0),Jc=(e,t,n)=>{let r=pc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Yc=(e,t,n=!1)=>{let r=mc.exec(e);return r?r[1]?t(r[1]):n:!1},Xc=e=>e===`position`||e===`percentage`,Zc=e=>e===`image`||e===`url`,Qc=e=>e===`length`||e===`size`||e===`bg-size`,$c=e=>e===`length`,el=e=>e===`number`,tl=e=>e===`family-name`,nl=e=>e===`number`||e===`weight`,rl=e=>e===`shadow`,il=uc(()=>{let e=fc(`color`),t=fc(`font`),n=fc(`text`),r=fc(`font-weight`),i=fc(`tracking`),a=fc(`leading`),o=fc(`breakpoint`),s=fc(`container`),c=fc(`spacing`),l=fc(`radius`),u=fc(`shadow`),d=fc(`inset-shadow`),f=fc(`text-shadow`),p=fc(`drop-shadow`),m=fc(`blur`),h=fc(`perspective`),g=fc(`aspect`),_=fc(`ease`),v=fc(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Q,Z],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Q,Z,c],T=()=>[xc,`full`,`auto`,...w()],E=()=>[Cc,`none`,`subgrid`,Q,Z],D=()=>[`auto`,{span:[`full`,Cc,Q,Z]},Cc,Q,Z],O=()=>[Cc,`auto`,Q,Z],k=()=>[`auto`,`min`,`max`,`fr`,Q,Z],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[xc,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[xc,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[xc,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,Q,Z],L=()=>[...b(),Uc,Rc,{position:[Q,Z]}],R=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],z=()=>[`auto`,`cover`,`contain`,Wc,Nc,{size:[Q,Z]}],B=()=>[wc,Vc,Pc],V=()=>[``,`none`,`full`,l,Q,Z],H=()=>[``,Sc,Vc,Pc],U=()=>[`solid`,`dashed`,`dotted`,`double`],ee=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],W=()=>[Sc,wc,Uc,Rc],G=()=>[``,`none`,m,Q,Z],te=()=>[`none`,Sc,Q,Z],ne=()=>[`none`,Sc,Q,Z],re=()=>[Sc,Q,Z],K=()=>[xc,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Tc],breakpoint:[Tc],color:[Ec],container:[Tc],"drop-shadow":[Tc],ease:[`in`,`out`,`in-out`],font:[jc],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Tc],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Tc],shadow:[Tc],spacing:[`px`,Sc],text:[Tc],"text-shadow":[Tc],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,xc,Z,Q,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Q,Z]}],"container-named":[Mc],columns:[{columns:[Sc,Z,Q,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Cc,`auto`,Q,Z]}],basis:[{basis:[xc,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Sc,xc,`auto`,`initial`,`none`,Z]}],grow:[{grow:[``,Sc,Q,Z]}],shrink:[{shrink:[``,Sc,Q,Z]}],order:[{order:[Cc,`first`,`last`,`none`,Q,Z]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"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":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Vc,Pc]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,qc,Ic]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,wc,Z]}],"font-family":[{font:[Hc,Lc,t]}],"font-features":[{"font-features":[Z]}],"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:[i,Q,Z]}],"line-clamp":[{"line-clamp":[Sc,`none`,Q,Fc]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,Q,Z]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Q,Z]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...U(),`wavy`]}],"text-decoration-thickness":[{decoration:[Sc,`from-font`,`auto`,Q,Pc]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[Sc,`auto`,Q,Z]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[Cc,Q,Z]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Q,Z]}],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`,Q,Z]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:z()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Cc,Q,Z],radial:[``,Q,Z],conic:[Cc,Q,Z]},Gc,zc]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":H()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...U(),`hidden`,`none`]}],"divide-style":[{divide:[...U(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Sc,Q,Z]}],"outline-w":[{outline:[``,Sc,Vc,Pc]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`none`,u,Kc,Bc]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,Kc,Bc]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:H()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[Sc,Pc]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,Kc,Bc]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[Sc,Q,Z]}],"mix-blend":[{"mix-blend":[...ee(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ee()}],"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":[Sc]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[Q,Z]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":b()}],"mask-image-conic-pos":[{"mask-conic":[Sc]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Q,Z]}],filter:[{filter:[``,`none`,Q,Z]}],blur:[{blur:G()}],brightness:[{brightness:[Sc,Q,Z]}],contrast:[{contrast:[Sc,Q,Z]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Kc,Bc]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,Sc,Q,Z]}],"hue-rotate":[{"hue-rotate":[Sc,Q,Z]}],invert:[{invert:[``,Sc,Q,Z]}],saturate:[{saturate:[Sc,Q,Z]}],sepia:[{sepia:[``,Sc,Q,Z]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Q,Z]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[Sc,Q,Z]}],"backdrop-contrast":[{"backdrop-contrast":[Sc,Q,Z]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Sc,Q,Z]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sc,Q,Z]}],"backdrop-invert":[{"backdrop-invert":[``,Sc,Q,Z]}],"backdrop-opacity":[{"backdrop-opacity":[Sc,Q,Z]}],"backdrop-saturate":[{"backdrop-saturate":[Sc,Q,Z]}],"backdrop-sepia":[{"backdrop-sepia":[``,Sc,Q,Z]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Q,Z]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Sc,`initial`,Q,Z]}],ease:[{ease:[`linear`,`initial`,_,Q,Z]}],delay:[{delay:[Sc,Q,Z]}],animate:[{animate:[`none`,v,Q,Z]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Q,Z]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":[`scale-3d`],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[Q,Z,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:K()}],"translate-x":[{"translate-x":K()}],"translate-y":[{"translate-y":K()}],"translate-z":[{"translate-z":K()}],"translate-none":[`translate-none`],zoom:[{zoom:[Cc,Q,Z]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"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`,Q,Z]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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`,Q,Z]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[Sc,Vc,Pc,Fc]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],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`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function $(...e){return il(Ms(e))}E();var al=`(max-width: 767px)`,ol=`(min-width: 768px) and (max-width: 1023px)`;function sl(e){return typeof window.matchMedia==`function`?window.matchMedia(e):null}function cl(e){return t=>{let n=sl(e);return n===null?()=>{}:(n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t))}}function ll(e){return()=>sl(e)?.matches??!1}function ul(){return!1}function dl(){return S(cl(al),ll(al),ul)}function fl(){return S(cl(ol),ll(ol),ul)}E();function pl({open:e,onClose:t,title:n,children:r,className:i}){return b(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=``}},[e,t]),c(P,{children:[v(`div`,{className:$(`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`}),c(`div`,{role:`dialog`,"aria-modal":`true`,className:$(`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 pb-[env(safe-area-inset-bottom)]`,`max-h-[80dvh]`,e?`translate-y-0`:`translate-y-full`,i),children:[v(`div`,{className:`flex justify-center pt-2 pb-1`,children:v(`div`,{className:`h-1 w-8 rounded-full bg-foreground-subtle/30`})}),n&&c(`div`,{className:`flex items-center justify-between px-4 pb-2`,children:[v(`span`,{className:`text-sm font-medium text-foreground`,children:n}),v(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,children:v(Zn,{className:`h-4 w-4`})})]}),v(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:r})]})]})}E();var ml=O(null);function hl(){let e=I(ml);if(!e)throw Error(`Popover compound components must be used within <Popover>`);return e}function gl({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t??r,o=y(),s=y(),c=f(null),l=_(e=>{n?.(e),t===void 0&&i(e)},[t,n]);return v(ml.Provider,{value:{open:a,setOpen:l,triggerId:o,contentId:s,triggerRef:c},children:v(`div`,{className:`relative inline-block`,children:e})})}function _l({children:e,...t}){let{open:n,setOpen:r,triggerId:i,contentId:a,triggerRef:o}=hl();return v(`button`,{type:`button`,ref:o,id:i,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}var vl=8;function yl(e){let t=e.viewportHeight-e.triggerBottom-e.offset-vl,n=e.triggerTop-e.offset-vl,r=e.contentHeight>t&&n>t?`above`:`below`;return{side:r,maxHeight:Math.max(0,r===`above`?n:t)}}function bl({className:e,children:t,align:n=`start`,offset:r=4,...i}){let{open:a,setOpen:o,contentId:s,triggerId:c,triggerRef:l}=hl(),d=dl(),p=f(null),[m,h]=C(null),[g,_]=C(null);return u(()=>{if(!a||d){h(null);return}let e=()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),i=n===`end`?t.right:t.left;h({top:t.bottom+r,left:i,minWidth:t.width,triggerTop:t.top,triggerBottom:t.bottom})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a,d,n,r,l]),u(()=>{let e=p.current;if(!m||!e){_(null);return}_(yl({triggerTop:m.triggerTop,triggerBottom:m.triggerBottom,contentHeight:e.scrollHeight,viewportHeight:window.innerHeight,offset:r}))},[m,r]),b(()=>{if(!a||d)return;let e=e=>{let t=p.current,n=l.current;t&&!t.contains(e.target)&&!n?.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a,o,l,d]),a?d?v(pl,{open:a,onClose:()=>o(!1),children:t}):!m||typeof document>`u`?null:Oo(v(`div`,{ref:p,id:s,role:`dialog`,"aria-labelledby":c,style:{position:`fixed`,...g?.side===`above`?{bottom:window.innerHeight-m.triggerTop+r}:{top:m.top},...g?{maxHeight:g.maxHeight}:{},...n===`end`?{right:window.innerWidth-m.left}:{left:m.left},minWidth:m.minWidth},className:$(`z-50 overflow-y-auto bg-background-elevated border border-border rounded-lg shadow-lg p-3`,e),...i,children:t}),document.body):null}E();var xl=7,Sl=24,Cl=32,wl=288,Tl=96;function El(e){let t=[];for(let n=0;n<e.length;n+=xl)t.push(e.slice(n,n+xl));return t}function Dl(e){return e.kind===`header`?Sl:Cl}function Ol(e,t){return e.trim().length>0?El(ta(e,t).map(e=>e.entry.key)).map((e,t)=>({kind:`tiles`,id:`r${t}`,keys:e})):ma.flatMap(e=>{let t=Ha(e).map(e=>e.key);return[{kind:`header`,id:`h-${e}`,category:e},...El(t).map((t,n)=>({kind:`tiles`,id:`${e}-${n}`,keys:t}))]})}function kl(e,t,n,r){let i=Math.max(0,r-Tl),a=r+wl+Tl,o=0;for(;o<e.length-1&&(t[o+1]??n)<=i;)o+=1;let s=o;for(;s<e.length&&(t[s]??n)<a;)s+=1;return{rows:e.slice(o,s),padTop:t[o]??0,padBottom:Math.max(0,n-(t[s]??n))}}function Al({value:e,onPick:t,fallbackGlyph:n,labels:r,extraWords:i,clearGlyph:a,labelFor:o,categoryLabel:s=ja,disabled:l=!1}){let u=f(null);As(u);let[d,m]=C(!1),[h,g]=C(``),[_,y]=C(0),x=f(null),S=hs();b(()=>{d&&cs().catch(()=>void 0)},[d]);let w=Ka(e),T=p(()=>Ol(h,i),[h,i]),{offsets:E,total:D}=p(()=>{let e=[],t=0;for(let n of T)e.push(t),t+=Dl(n);return{offsets:e,total:t}},[T]),O=p(()=>kl(T,E,D,_),[T,E,D,_]),k=(e===null?void 0:S(e))??n,A=a??n,j=e=>{g(e),y(0),x.current!==null&&(x.current.scrollTop=0)},M=async e=>{N(!1),await t(e)},N=e=>{m(e),e||j(``)};return c(gl,{open:d,onOpenChange:N,children:[v(_l,{disabled:l,"aria-label":r.trigger,title:r.trigger,className:`rounded border border-border p-1 text-foreground-muted hover:bg-surface-hover disabled:opacity-50`,children:v(k,{className:`h-4 w-4`})}),v(bl,{"aria-label":r.panel,"aria-labelledby":void 0,className:`w-72 p-2`,children:c(`div`,{className:`w-full`,children:[v(`input`,{ref:u,type:`search`,value:h,autoFocus:!0,onChange:e=>j(e.target.value),placeholder:r.searchPlaceholder,"aria-label":r.searchPlaceholder,className:`mb-2 w-full rounded border border-border bg-surface-raised px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`}),c(`button`,{type:`button`,onClick:()=>void M(null),"aria-pressed":e===null,className:`mb-2 flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[v(A,{className:`h-3.5 w-3.5`}),r.clear]}),T.length===0?v(`p`,{className:`px-1.5 py-2 text-[11px] text-foreground-subtle`,children:r.noMatches}):v(`div`,{ref:x,onScroll:e=>y(e.currentTarget.scrollTop),className:`max-h-72 overflow-y-auto`,children:v(`div`,{style:{paddingTop:O.padTop,paddingBottom:O.padBottom},children:O.rows.map(e=>e.kind===`header`?v(`h4`,{className:`flex h-6 items-center px-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(e.category)},e.id):v(`div`,{className:`grid h-8 grid-cols-7 gap-1 pb-1`,children:e.keys.map(e=>{let t=S(e);if(t===void 0)return v(`span`,{"aria-hidden":`true`},e);let n=w===e;return v(`button`,{type:`button`,onClick:()=>void M(e),"aria-pressed":n,"aria-label":o?.(e)??e,title:o?.(e)??e,className:n?`flex items-center justify-center rounded border border-primary bg-primary/10 text-foreground`:`flex items-center justify-center rounded border border-transparent text-foreground-muted hover:bg-surface-hover`,children:v(t,{className:`h-4 w-4`})},e)})},e.id))})})]})})]})}function jl(e){return{trigger:`Choose an icon for ${e}`,panel:`${e} icon`,searchPlaceholder:`Search icons`,clear:`Default icon`,noMatches:`No icon matches`}}function Ml({label:e,value:t,defaultKey:n,disabled:r,onChange:i}){let a=hs(),o=Ca(t,n),s=a(n)??Wr;return c(`div`,{className:`flex items-center gap-2`,children:[v(Al,{value:o===``?null:o,onPick:e=>i(e??n),fallbackGlyph:s,labels:jl(e),disabled:r}),v(`span`,{className:`text-[11px] text-foreground-subtle font-mono`,children:o})]})}function Nl(e){if(typeof window>`u`||typeof DOMParser>`u`)return``;let t=new Set([`A`,`UL`,`OL`,`LI`,`STRONG`,`EM`,`CODE`,`BR`,`P`,`SPAN`,`B`]),n=new DOMParser().parseFromString(`<div>${e}</div>`,`text/html`),r=n.body.firstElementChild;if(!r)return``;let i=e=>{let r=Array.from(e.children);for(let e of r){if(!t.has(e.tagName)){let t=n.createTextNode(e.textContent??``);e.replaceWith(t);continue}let r=e.tagName===`A`?new Set([`href`]):new Set;for(let t of Array.from(e.attributes))r.has(t.name)||e.removeAttribute(t.name);if(e.tagName===`A`){let t=e.getAttribute(`href`)??``,n=/^https?:\/\//i.test(t),r=t.startsWith(`mailto:`),i=t.startsWith(`/`)&&!t.startsWith(`//`);!n&&!r&&!i?e.removeAttribute(`href`):n&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}i(e)}};return i(r),r.innerHTML}var Pl=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Fl=Ms,Il=(e,t)=>n=>{if(t?.variants==null)return Fl(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Pl(t)||Pl(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Fl(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)};E();var Ll=Il(`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`}}),Rl=D(({className:e,variant:t,size:n,icon:r,...i},a)=>v(`button`,{ref:a,className:$(Ll({variant:t,size:n}),e),...i,children:v(r,{className:`h-4 w-4`,"aria-hidden":`true`})}));Rl.displayName=`IconButton`,E();var zl=Il(`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-inset focus:ring-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,{variants:{state:{default:`border-border`,error:`border-danger`}},defaultVariants:{state:`default`}}),Bl=D(({className:e,state:t,leftSlot:n,rightSlot:r,searchHotkey:i,...a},o)=>{let s=f(null),l=_(e=>{s.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);return As(s,{enabled:i??a.type===`search`}),n||r?c(`div`,{className:$(`relative flex items-center`,e),children:[n&&v(`div`,{className:`absolute left-2.5 flex items-center text-foreground-subtle pointer-events-none`,children:n}),v(`input`,{ref:l,className:$(zl({state:t}),n&&`pl-8`,r&&`pr-8`,e),...a}),r&&v(`div`,{className:`absolute right-2.5 flex items-center text-foreground-subtle`,children:r})]}):v(`input`,{ref:l,className:$(zl({state:t}),e),...a})});Bl.displayName=`Input`,E();var Vl=O(null);function Hl(){let e=I(Vl);if(!e)throw Error(`Tooltip compound components must be used within <Tooltip>`);return e}function Ul({children:e,className:t,open:n}){let[r,i]=C(!1),a=n??r,o=f(null),s=y();return v(Vl.Provider,{value:{open:a,show:()=>{o.current=setTimeout(()=>i(!0),300)},hide:()=>{o.current&&clearTimeout(o.current),i(!1)},tooltipId:s},children:v(`div`,{className:$(`relative`,t??`inline-block`),children:e})})}function Wl({children:e,...t}){let{show:n,hide:r,tooltipId:i,open:a}=Hl();return v(`div`,{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?i:void 0,...t,children:e})}function Gl({className:e,children:t,...n}){let{open:r,tooltipId:i}=Hl();return v(`div`,{id:i,role:`tooltip`,className:$(`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})}E();var Kl=`w-full min-h-[60px] rounded-md border border-border bg-background px-2.5 py-1.5 pr-9 font-mono text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`,ql={WebkitTextSecurity:`disc`},Jl=D(({value:e,onValueChange:t,shown:n,onToggleShown:r,busy:i=!1,error:a=null,toggleBlockedReason:o=null,hideToggle:s=!1,multiline:l=!1,className:u,disabled:d,...f},p)=>{let m=n?`Hide password`:`Show password`;return c(`div`,{className:`relative w-full`,children:[l?v(`textarea`,{className:$(Kl,u),style:n?void 0:ql,value:e,disabled:d,spellCheck:!1,autoComplete:`off`,"aria-label":f[`aria-label`],placeholder:f.placeholder,onChange:e=>t(e.target.value)}):v(Bl,{ref:p,...f,type:n?`text`:`password`,className:$(`h-auto bg-background py-1.5`,!s&&`pr-9`,u),value:e,disabled:d,spellCheck:!1,autoComplete:`new-password`,onChange:e=>t(e.target.value)}),!s&&c(Ul,{open:a!==null,className:`absolute right-0.5 top-0.5`,children:[v(`span`,{className:`inline-flex`,title:o??void 0,children:v(Rl,{type:`button`,variant:`ghost`,icon:i?Gn:n?Oe:Zt,"aria-label":m,"aria-pressed":n,"aria-busy":i||void 0,disabled:d||i||o!==null,className:$(`h-6 w-6 text-foreground-subtle`,i&&`[&>svg]:animate-spin`),onClick:r})}),a!==null&&v(Gl,{role:`alert`,className:`left-auto right-0 w-max max-w-[16rem] translate-x-0 whitespace-normal bg-danger text-white`,children:a})]})]})});Jl.displayName=`PasswordInput`,E();var Yl=D(({className:e,options:t,disabled:n,...r},i)=>c(`div`,{className:`relative w-full`,children:[v(`select`,{ref:i,disabled:n,className:$(`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`,`disabled:opacity-50 disabled:cursor-not-allowed`,e),...r,children:t.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(`div`,{className:$(`absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted`,n===!0?`opacity-50`:``),children:v(de,{className:`h-3.5 w-3.5`})})]}));Yl.displayName=`Select`,E();var Xl=1e4,Zl=`••••••••`,Ql=5e3,$l=Kn(`camstack:secret-reveal`,null);function eu({reveal:e,children:t}){return v($l.Provider,{value:e,children:t})}function tu(e){return e===null||ha(e)||Bi(e)}function nu(e,t,n){return e.kind===`untouched`?t:e.text.length===0?n?qi:t:e.text===e.revealed?t:e.text}function ru(e){return typeof e==`string`&&e.length>0?{kind:`visible`,text:e,revealed:null}:Bi(e)?{kind:`visible`,text:``,revealed:null}:{kind:`untouched`}}function iu(e,t,n,r){return e.kind===`untouched`?t?Zl:n:e.text.length===0&&t?r(`uiLibrary.configSecretField.removedOnSave`,`Removed on save`):n}function au({field:e,value:t,onChange:n,disabled:r,multiline:i}){let a=q(),o=I($l),[s]=C(()=>ha(t)?t:null),[c]=C(()=>ha(t)||Bi(t)),[l,u]=C(()=>ru(t)),[d,f]=C(!1),[p,m]=C(!1),[h,g]=C(null);b(()=>{if(h===null)return;let e=setTimeout(()=>g(null),Ql);return()=>clearTimeout(e)},[h]);let _=s?.$secret??null,y=l.kind===`untouched`&&c,x=y&&!(_!==null&&o!==null)?a(`uiLibrary.configSecretField.cannotReveal`,`This stored value cannot be revealed here — type to replace it`):null,S=e=>{let t={kind:`visible`,text:e,revealed:l.kind===`visible`?l.revealed:null};g(null),u(t),n(nu(t,s,c))},w=()=>{if(!y){f(e=>!e);return}_===null||o===null||(g(null),m(!0),o(_).then(e=>{m(!1),u({kind:`visible`,text:e,revealed:e}),f(!0)},e=>{m(!1),g(e instanceof Error?e.message:String(e))}))},T=`label`in e?e.label:``,E=`placeholder`in e&&typeof e.placeholder==`string`?e.placeholder:``;return v(`div`,{"data-secret-field":`key`in e?e.key:void 0,children:v(Jl,{"aria-label":T,value:l.kind===`visible`?l.text:``,onValueChange:S,placeholder:iu(l,c,E,a),shown:d,onToggleShown:w,busy:p,error:h,toggleBlockedReason:x,disabled:r,multiline:i})})}var ou=X.accessories.setChildHidden.useMutation,su=X.accessories.getStatus.useQuery,cu=X.actions.list.useQuery,lu=X.actions.get.useQuery,uu=X.actions.run.useMutation,du=X.actions.stop.useMutation,fu=X.actions.getTraces.useQuery,pu=X.actions.create.useMutation,mu=X.actions.update.useMutation,hu=X.actions.delete.useMutation,gu=X.actions.listForCamera.useQuery,_u=X.actions.getLinks.useQuery,vu=X.actions.setLinks.useMutation,yu=X.actionSource.listActions.useQuery,bu=X.actionSource.runAction.useMutation,xu=X.actionSource.stopAction.useMutation,Su=X.addonPages.listPages.useQuery,Cu=X.addons.list.useQuery,wu=X.addons.getLogs.useQuery,Tu=X.addons.listPackages.useQuery,Eu=X.addons.installPackage.useMutation,Du=X.addons.installFromWorkspace.useMutation,Ou=X.addons.isWorkspaceAvailable.useQuery,ku=X.addons.listWorkspacePackages.useQuery,Au=X.addons.uninstallPackage.useMutation,ju=X.addons.listInstallations.useQuery,Mu=X.addons.reloadPackages.useMutation,Nu=X.addons.searchAvailable.useQuery,Pu=X.addons.listUpdates.useQuery,Fu=X.addons.updatePackage.useMutation,Iu=X.addons.rollbackPackage.useMutation,Lu=X.addons.forceRefresh.useMutation,Ru=X.addons.restartServer.useMutation,zu=X.addons.getLastRestart.useQuery,Bu=X.addons.listFrameworkPackages.useQuery,Vu=X.addons.listCapabilityProviders.useQuery,Hu=X.addons.setCapabilityProviderEnabled.useMutation,Uu=X.addons.getVersions.useQuery,Wu=X.addons.getPackageDocs.useQuery,Gu=X.addons.restartAddon.useMutation,Ku=X.addons.retryLoad.useMutation,qu=X.addons.getAutoUpdateSettings.useQuery,Ju=X.addons.setAutoUpdateSettings.useMutation,Yu=X.addons.getAddonAutoUpdate.useQuery,Xu=X.addons.setAddonAutoUpdate.useMutation,Zu=X.addons.applyAutoUpdateToAll.useMutation,Qu=X.addons.custom.useMutation,$u=X.addons.startJob.useMutation,ed=X.addons.getJob.useQuery,td=X.addons.listJobs.useQuery,nd=X.addons.cancelJob.useMutation,rd=X.addons.onAddonLogs.useSubscription,id=X.addonSettings.getGlobalSettings.useQuery,ad=X.addonSettings.updateGlobalSettings.useMutation,od=X.addonSettings.getIntegrationSettings.useQuery,sd=X.addonSettings.getDeviceSettings.useQuery,cd=X.addonSettings.updateDeviceSettings.useMutation,ld=X.addonWidgets.listWidgets.useQuery,ud=X.airQualitySensor.getStatus.useQuery,dd=X.alarmPanel.arm.useMutation,fd=X.alarmPanel.disarm.useMutation,pd=X.alarmPanel.trigger.useMutation,md=X.alarmPanel.getStatus.useQuery,hd=X.alerts.emit.useMutation,gd=X.alerts.update.useMutation,_d=X.alerts.list.useQuery,vd=X.alerts.getUnreadCount.useQuery,yd=X.alerts.markRead.useMutation,bd=X.alerts.markAllRead.useMutation,xd=X.alerts.dismiss.useMutation,Sd=X.ambientLightSensor.getStatus.useQuery,Cd=X.audioAnalysis.resolveDeviceSettings.useQuery,wd=X.audioAnalysis.getDeviceSettingsContribution.useQuery,Td=X.audioAnalysis.getDeviceLiveContribution.useQuery,Ed=X.audioAnalysis.applyDeviceSettingsPatch.useMutation,jee=X.audioAnalyzer.analyseChunk.useMutation,Mee=X.audioAnalyzer.classify.useQuery,Nee=X.audioAnalyzer.attachDevice.useMutation,Pee=X.audioAnalyzer.detachDevice.useMutation,Fee=X.audioAnalyzer.isReady.useQuery,Iee=X.audioAnalyzer.dispose.useMutation,Dd=X.audioAnalyzer.reprobeAudioEngine.useMutation,Lee=X.audioCodec.listSupportedCodecs.useQuery,Ree=X.audioCodec.canHandle.useQuery,zee=X.audioCodec.createDecodeSession.useMutation,Bee=X.audioCodec.createEncodeSession.useMutation,Vee=X.audioCodec.closeSession.useMutation,Hee=X.audioCodec.pushEncodedFrame.useMutation,Uee=X.audioCodec.pullPcm.useQuery,Wee=X.audioCodec.pushPcm.useMutation,Gee=X.audioCodec.pullEncoded.useQuery,Kee=X.audioCodec.flushEncode.useMutation,qee=X.audioCodec.listActiveSessions.useQuery,Od=X.audioMetrics.getCurrentSnapshot.useQuery,Jee=X.audioMetrics.getHistory.useQuery,Yee=X.automationControl.enable.useMutation,Xee=X.automationControl.disable.useMutation,Zee=X.automationControl.trigger.useMutation,Qee=X.automationControl.getStatus.useQuery,kd=X.backup.listDestinations.useQuery,Ad=X.backup.trigger.useMutation,jd=X.backup.listRuns.useQuery,Md=X.backup.cancel.useMutation,$ee=X.backup.list.useQuery,ete=X.backup.listLocations.useQuery,Nd=X.backup.getEntries.useQuery,Pd=X.backup.restore.useMutation,Fd=X.backup.getEncryption.useQuery,Id=X.backup.setupEncryption.useMutation,Ld=X.backup.disableEncryption.useMutation,tte=X.backup.checkBackupKey.useMutation,Rd=X.backup.delete.useMutation,zd=X.backup.listArchives.useQuery,nte=X.backup.upsertDestinationPolicy.useMutation,Bd=X.backup.previewSchedule.useQuery,Vd=X.backup.listSchedules.useQuery,Hd=X.backup.listAvailableDatabases.useQuery,Ud=X.backup.upsertSchedule.useMutation,Wd=X.backup.deleteSchedule.useMutation,rte=X.battery.wakeForStream.useMutation,ite=X.battery.getStatus.useQuery,ate=X.binary.getStatus.useQuery,ote=X.brightness.setBrightness.useMutation,ste=X.brightness.getStatus.useQuery,Gd=X.broker.list.useQuery,cte=X.broker.get.useQuery,Kd=X.broker.listProviders.useQuery,qd=X.broker.add.useMutation,Jd=X.broker.remove.useMutation,Yd=X.broker.testConnection.useMutation,Xd=X.broker.getSettings.useQuery,Zd=X.broker.setSettings.useMutation,lte=X.broker.getBrokerConfig.useQuery,Qd=X.broker.getSettingsSchema.useQuery,$d=X.broker.testSettings.useMutation,ef=X.broker.publish.useMutation,ute=X.broker.subscribe.useMutation,dte=X.broker.unsubscribe.useMutation,tf=X.broker.getState.useQuery,nf=X.broker.getStatus.useQuery,fte=X.button.press.useMutation,rf=X.calendars.listCalendars.useQuery,af=X.calendars.listEvents.useQuery,of=X.calendars.getPreferences.useQuery,sf=X.calendars.setCalendarPreference.useMutation,pte=X.cameraCredentials.getCredentials.useQuery,mte=X.cameraCredentials.getStatus.useQuery,hte=X.cameraGridLayout.getLayout.useQuery,gte=X.cameraGridLayout.saveLayout.useMutation,_te=X.cameraGridLayout.getDeviceSettingsContribution.useQuery,vte=X.cameraGridLayout.getDeviceLiveContribution.useQuery,yte=X.cameraGridLayout.applyDeviceSettingsPatch.useMutation,bte=X.cameraPipelineConfig.getDeviceSettingsContribution.useQuery,xte=X.cameraPipelineConfig.getDeviceLiveContribution.useQuery,Ste=X.cameraPipelineConfig.applyDeviceSettingsPatch.useMutation,Cte=X.cameraStreams.getCameraStreams.useQuery,wte=X.cameraStreams.getBrokerStreams.useQuery,cf=X.cameraStreams.getRtspEntries.useQuery,Tte=X.cameraStreams.getProfileRtspEntries.useQuery,Ete=X.cameraStreams.pickStream.useQuery,Dte=X.carbonMonoxide.getStatus.useQuery,Ote=X.climateControl.setMode.useMutation,kte=X.climateControl.setFanMode.useMutation,Ate=X.climateControl.setPreset.useMutation,jte=X.climateControl.setTarget.useMutation,Mte=X.climateControl.setTargetRange.useMutation,Nte=X.climateControl.setTargetHumidity.useMutation,Pte=X.climateControl.setSwingVertical.useMutation,Fte=X.climateControl.setSwingHorizontal.useMutation,Ite=X.climateControl.getStatus.useQuery,Lte=X.color.setColor.useMutation,Rte=X.color.getStatus.useQuery,zte=X.connectionTest.testSettings.useMutation,Bte=X.connectionTest.describeTest.useQuery,Vte=X.connectivity.getStatus.useQuery,lf=X.consumables.reset.useMutation,uf=X.consumables.getStatus.useQuery,df=X.contact.getStatus.useQuery,ff=X.control.setValue.useMutation,pf=X.control.getStatus.useQuery,mf=X.coreBlocks.list.useQuery,hf=X.coreBlocks.get.useQuery,gf=X.coreBlocks.create.useMutation,_f=X.coreBlocks.update.useMutation,vf=X.coreBlocks.delete.useMutation,yf=X.coreBlocks.setEnabled.useMutation,bf=X.coreBlocks.restart.useMutation,xf=X.coreBlocks.compile.useMutation,Sf=X.coreBlocks.getBlockSettings.useQuery,Cf=X.coreBlocks.updateBlockSettings.useMutation,wf=X.coreBlocks.migrateRawSecrets.useMutation,Tf=X.coreBlocks.getTypeDefs.useQuery,Ef=X.coreBlocks.createComposition.useMutation,Df=X.coreBlocks.updateComposition.useMutation,Of=X.coreBlocks.getComposition.useQuery,kf=X.coreBlocks.listCompositions.useQuery,Af=X.coreBlocks.getCustomization.useQuery,jf=X.coreBlocks.listComposableCaps.useQuery,Mf=X.coreBlocks.validateComposition.useMutation,Nf=X.coreBlocks.reportAutomationRun.useMutation,Pf=X.coreBlocks.getAutomationRunState.useQuery,Ff=X.coreBlocks.getTraces.useQuery,If=X.cover.open.useMutation,Lf=X.cover.close.useMutation,Rf=X.cover.stop.useMutation,zf=X.cover.setPosition.useMutation,Bf=X.cover.setTiltPosition.useMutation,Vf=X.cover.getStatus.useQuery,Hf=X.dayNight.getOptions.useQuery,Uf=X.dayNight.setSettings.useMutation,Wf=X.dayNight.getStatus.useQuery,Gf=X.decoder.getInfo.useQuery,Kf=X.decoder.reprobeHwaccel.useMutation,Hte=X.detectionPipeline.getDeviceSettingsContribution.useQuery,Ute=X.detectionPipeline.getDeviceLiveContribution.useQuery,Wte=X.detectionPipeline.applyDeviceSettingsPatch.useMutation,Gte=X.deviceAdminLink.getAdminLink.useQuery,Kte=X.deviceAdoption.listCandidateFilters.useQuery,qte=X.deviceAdoption.listCandidates.useQuery,Jte=X.deviceAdoption.getCandidate.useQuery,Yte=X.deviceAdoption.refresh.useMutation,Xte=X.deviceAdoption.adopt.useMutation,Zte=X.deviceAdoption.release.useMutation,Qte=X.deviceAdoption.resync.useMutation,$te=X.deviceAdoption.getStatus.useQuery,ene=X.deviceCredentials.listDeviceCredentials.useQuery,tne=X.deviceCredentials.startEnrollment.useMutation,qf=X.deviceCredentials.revokeDeviceCredential.useMutation,Jf=X.deviceCredentials.getDeviceCertificateSettings.useQuery,Yf=X.deviceCredentials.setDeviceCertificateSettings.useMutation,Xf=X.deviceCredentials.deleteDeviceCredential.useMutation,Zf=X.deviceCredentials.getDeviceCaStatus.useQuery,Qf=X.deviceCredentials.renameDeviceCredential.useMutation,$f=X.deviceDiscovery.listDiscovered.useQuery,ep=X.deviceDiscovery.refreshDiscovery.useMutation,tp=X.deviceDiscovery.adoptDevice.useMutation,np=X.deviceDiscovery.releaseDevice.useMutation,rp=X.deviceDiscovery.getStatus.useQuery,ip=X.deviceExport.getStatus.useQuery,ap=X.deviceExport.listSupportedDeviceKinds.useQuery,op=X.deviceExport.listExposedDevices.useQuery,sp=X.deviceExport.exposeDevice.useMutation,cp=X.deviceExport.unexposeDevice.useMutation,lp=X.deviceExport.getDeviceSettingsContribution.useQuery,up=X.deviceExport.getDeviceLiveContribution.useQuery,dp=X.deviceExport.applyDeviceSettingsPatch.useMutation,fp=X.deviceExtension.listSources.useQuery,pp=X.deviceExtension.listSlots.useQuery,mp=X.deviceExtension.listCandidates.useQuery,hp=X.deviceExtension.setSlot.useMutation,gp=X.deviceHistory.listSeries.useQuery,_p=X.deviceHistory.listNodeSeries.useQuery,vp=X.deviceHistory.query.useQuery,yp=X.deviceHistory.queryNode.useQuery,bp=X.deviceHistory.queryMany.useQuery,xp=X.deviceHistory.declareSeries.useMutation,Sp=X.deviceHistory.record.useMutation,Cp=X.deviceHistory.recordBuckets.useMutation,wp=X.deviceHistory.getDeviceEnabled.useQuery,Tp=X.deviceHistory.setDeviceEnabled.useMutation,Ep=X.deviceHistory.getStatus.useQuery,Dp=X.deviceHistory.listOrphanSeries.useQuery,Op=X.deviceHistory.deleteOrphanSeries.useMutation,kp=X.deviceManager.allocateDeviceId.useMutation,Ap=X.deviceManager.migrateDevice.useMutation,jp=X.deviceManager.registerDevice.useMutation,Mp=X.deviceManager.removeDevice.useMutation,Np=X.deviceManager.persistConfig.useMutation,Pp=X.deviceManager.loadConfig.useQuery,Fp=X.deviceManager.loadRuntimeState.useQuery,Ip=X.deviceManager.loadMeta.useQuery,Lp=X.deviceManager.setName.useMutation,Rp=X.deviceManager.setLocation.useMutation,zp=X.deviceManager.setType.useMutation,Bp=X.deviceManager.setIntegrationId.useMutation,Vp=X.deviceManager.setLinkDeviceId.useMutation,Hp=X.deviceManager.setPrimaryChildEntityId.useMutation,Up=X.deviceManager.setChildLayout.useMutation,Wp=X.deviceManager.setDisplay.useMutation,Gp=X.deviceManager.getRoleDisplayDefaults.useQuery,Kp=X.deviceManager.setRoleDisplayDefaults.useMutation,qp=X.deviceManager.getWireableFields.useQuery,Jp=X.deviceManager.setRole.useMutation,Yp=X.deviceManager.applyInitialMeta.useMutation,Xp=X.deviceManager.setMetadata.useMutation,Zp=X.deviceManager.listLocations.useQuery,Qp=X.deviceManager.addLocation.useMutation,$p=X.deviceManager.removeLocation.useMutation,em=X.deviceManager.renameLocation.useMutation,tm=X.deviceManager.listLocationIcons.useQuery,nm=X.deviceManager.setLocationIcon.useMutation,rm=X.deviceManager.listLocationDescriptions.useQuery,im=X.deviceManager.setLocationDescription.useMutation,am=X.deviceManager.listSiteZones.useQuery,om=X.deviceManager.setSiteZone.useMutation,sm=X.deviceManager.removeSiteZone.useMutation,cm=X.deviceManager.renameSiteZone.useMutation,lm=X.deviceManager.setLocationZone.useMutation,nne=X.deviceManager.setDisabled.useMutation,um=X.deviceManager.listPersistedByAddon.useQuery,dm=X.deviceManager.listAll.useQuery,fm=X.deviceManager.getDevice.useQuery,pm=X.deviceManager.getChildren.useQuery,rne=X.deviceManager.getChildrenBatch.useQuery,ine=X.deviceManager.getLinkedDevices.useQuery,ane=X.deviceManager.getLinkedDevicesBatch.useQuery,one=X.deviceManager.getStreamSources.useQuery,sne=X.deviceManager.getConfigSchema.useQuery,cne=X.deviceManager.getSettingsSchema.useQuery,lne=X.deviceManager.updateConfig.useMutation,mm=X.deviceManager.enable.useMutation,hm=X.deviceManager.disable.useMutation,gm=X.deviceManager.remove.useMutation,_m=X.deviceManager.listDeletedSince.useQuery,vm=X.deviceManager.cleanupDeletedDevicesData.useMutation,ym=X.deviceManager.removeByIntegration.useMutation,bm=X.deviceManager.getStreamProfileMap.useQuery,xm=X.deviceManager.setStreamProfileMap.useMutation,Sm=X.deviceManager.probeStreams.useMutation,Cm=X.deviceManager.getBindings.useQuery,wm=X.deviceManager.getBindingsBatch.useQuery,Tm=X.deviceManager.getAllBindings.useQuery,Em=X.deviceManager.listDeviceIdsByCaps.useQuery,Dm=X.deviceManager.setWrapperActive.useMutation,Om=X.deviceManager.getWrapperActivation.useQuery,km=X.deviceManager.listWrappersForCap.useQuery,Am=X.deviceManager.listBindableCapsForDeviceType.useQuery,jm=X.deviceManager.getDeviceSettingsAggregate.useQuery,Mm=X.deviceManager.getDeviceLiveInfoAggregate.useQuery,Nm=X.deviceManager.getDeviceAggregate.useQuery,Pm=X.deviceManager.runDeviceAction.useMutation,Fm=X.deviceManager.updateDeviceField.useMutation,Im=X.deviceManager.updateDeviceFieldsBatch.useMutation,Lm=X.deviceManager.discoverDevices.useMutation,Rm=X.deviceManager.adoptDevice.useMutation,zm=X.deviceManager.getCreationSchema.useQuery,Bm=X.deviceManager.createDevice.useMutation,Vm=X.deviceManager.testCreationField.useMutation,Hm=X.deviceManager.adoptionListCandidateFilters.useQuery,Um=X.deviceManager.adoptionListCandidates.useQuery,Wm=X.deviceManager.adoptionRefresh.useMutation,Gm=X.deviceManager.adoptionAdopt.useMutation,Km=X.deviceManager.adoptionRelease.useMutation,qm=X.deviceManager.adoptionStartJob.useMutation,Jm=X.deviceManager.adoptionListJobs.useQuery,Ym=X.deviceManager.adoptionCancelJob.useMutation,Xm=X.deviceManager.adoptionResync.useMutation,Zm=X.deviceManager.discoveryProviders.useQuery,Qm=X.deviceManager.discoverAllProviders.useMutation,$m=X.deviceManager.discoverProvider.useMutation,eh=X.deviceManager.providerCreationType.useQuery,th=X.deviceManager.providerDiscoveryParamsSchema.useQuery,nh=X.deviceManager.testField.useMutation,rh=X.deviceManager.getDeviceStatusAggregate.useQuery,ih=X.deviceManager.getDeviceStatusAggregateBatch.useQuery,ah=X.deviceOps.getStreamSources.useQuery,oh=X.deviceOps.getConfigEntries.useQuery,sh=X.deviceOps.setConfig.useMutation,ch=X.deviceOps.runAction.useMutation,lh=X.deviceOps.removeDevice.useMutation,uh=X.deviceOps.getSettingsSchema.useQuery,dh=X.deviceOps.getRawState.useQuery,fh=X.deviceProvider.start.useMutation,ph=X.deviceProvider.stop.useMutation,mh=X.deviceProvider.getStatus.useQuery,hh=X.deviceProvider.getDevices.useQuery,gh=X.deviceProvider.reloadDevice.useMutation,_h=X.deviceProvider.supportsDiscovery.useQuery,vh=X.deviceProvider.discoverDevices.useMutation,yh=X.deviceProvider.getDiscoveryParamsSchema.useQuery,bh=X.deviceProvider.getManualCreationType.useQuery,xh=X.deviceProvider.adoptDiscoveredDevice.useMutation,Sh=X.deviceProvider.supportsManualCreation.useQuery,Ch=X.deviceProvider.getChildCreationSchema.useQuery,wh=X.deviceProvider.createDevice.useMutation,Th=X.deviceProvider.testCreationField.useMutation,Eh=X.deviceState.getSnapshot.useQuery,Dh=X.deviceState.getCapSlice.useQuery,Oh=X.deviceState.getAllSnapshots.useQuery,kh=X.deviceState.setCapSlice.useMutation,Ah=X.deviceState.claimFields.useMutation,jh=X.deviceState.patchOwnedFields.useMutation,Mh=X.deviceState.releaseClaim.useMutation,Nh=X.deviceState.listClaims.useQuery,Ph=X.deviceState.getNativeCapSlice.useQuery,Fh=X.deviceStatus.getStatus.useQuery,Ih=X.dishwasher.start.useMutation,Lh=X.dishwasher.pause.useMutation,Rh=X.dishwasher.resume.useMutation,zh=X.dishwasher.stop.useMutation,Bh=X.dishwasher.setProgram.useMutation,Vh=X.dishwasher.setPower.useMutation,Hh=X.dishwasher.setHalfLoad.useMutation,Uh=X.dishwasher.setHygienePlus.useMutation,Wh=X.dishwasher.setExtraDry.useMutation,Gh=X.dishwasher.setIntensiveZone.useMutation,Kh=X.dishwasher.setVarioSpeedPlus.useMutation,qh=X.dishwasher.setChildLock.useMutation,Jh=X.dishwasher.setOption.useMutation,Yh=X.dishwasher.getOptions.useQuery,Xh=X.dishwasher.getStatus.useQuery,Zh=X.displayPalette.getPalette.useQuery,Qh=X.displayPalette.listPresets.useQuery,$h=X.displayPalette.setPalette.useMutation,eg=X.doorbell.getStatus.useQuery,tg=X.enumSensor.getStatus.useQuery,ng=X.eventEmitter.getStatus.useQuery,rg=X.faceGallery.listIdentities.useQuery,ig=X.faceGallery.createIdentity.useMutation,ag=X.faceGallery.renameIdentity.useMutation,og=X.faceGallery.deleteIdentity.useMutation,sg=X.faceGallery.listIdentitySamples.useQuery,cg=X.faceGallery.auditIdentitySamples.useQuery,lg=X.faceGallery.removeSample.useMutation,ug=X.faceGallery.listRecentFaces.useQuery,dg=X.faceGallery.getFaceByTrack.useQuery,fg=X.faceGallery.getFaceMedia.useQuery,pg=X.faceGallery.assignFace.useMutation,mg=X.faceGallery.unassignFace.useMutation,hg=X.faceGallery.deleteFace.useMutation,gg=X.faceGallery.assignFaces.useMutation,_g=X.faceGallery.unassignFaces.useMutation,vg=X.faceGallery.suggestFaceClusters.useQuery,yg=X.fanControl.setPercentage.useMutation,bg=X.fanControl.setPreset.useMutation,xg=X.fanControl.setDirection.useMutation,Sg=X.fanControl.setOscillating.useMutation,Cg=X.fanControl.getStatus.useQuery,wg=X.featureProbe.getStatus.useQuery,Tg=X.flood.getStatus.useQuery,Eg=X.gas.getStatus.useQuery,Dg=X.groupActive.getStatus.useQuery,Og=X.groupCommands.getStatus.useQuery,kg=X.groupStatus.getStatus.useQuery,Ag=X.heatingValve.getStatus.useQuery,jg=X.humidifier.setOn.useMutation,Mg=X.humidifier.setTargetHumidity.useMutation,Ng=X.humidifier.setMode.useMutation,Pg=X.humidifier.getStatus.useQuery,Fg=X.humiditySensor.getStatus.useQuery,Ig=X.image.getStatus.useQuery,Lg=X.imageSettings.getOptions.useQuery,Rg=X.imageSettings.setSettings.useMutation,zg=X.imageSettings.getStatus.useQuery,Bg=X.integrations.list.useQuery,Vg=X.integrations.get.useQuery,Hg=X.integrations.getByAddonId.useQuery,Ug=X.integrations.create.useMutation,Wg=X.integrations.update.useMutation,Gg=X.integrations.delete.useMutation,Kg=X.integrations.getSettings.useQuery,qg=X.integrations.setSettings.useMutation,Jg=X.integrations.getAvailableTypes.useQuery,Yg=X.integrations.testConnection.useMutation,Xg=X.intercom.startSession.useMutation,Zg=X.intercom.handleAnswer.useMutation,Qg=X.intercom.stopSession.useMutation,$g=X.intercom.startTalkSession.useMutation,e_=X.intercom.pushTalkAudio.useMutation,t_=X.intercom.endTalkSession.useMutation,n_=X.intercom.getStatus.useQuery,r_=X.irTransmitter.send.useMutation,i_=X.irTransmitter.getInfo.useQuery,a_=X.keychainAdmin.status.useQuery,o_=X.keychainAdmin.listSecrets.useQuery,s_=X.keychainAdmin.listAudit.useQuery,c_=X.keychainAdmin.reveal.useMutation,l_=X.keychainAdmin.setSystemSecret.useMutation,u_=X.keychainAdmin.importSecret.useMutation,d_=X.keychainAdmin.deleteOrphans.useMutation,f_=X.keychainAdmin.rotateMasterKey.useMutation,p_=X.keychainAdmin.purgeRetiredKeys.useMutation,m_=X.keychainAdmin.downloadRecoveryKey.useMutation,h_=X.keychainAdmin.resetKeychain.useMutation,g_=X.keychainAdmin.resetReport.useQuery,__=X.keychainAdmin.acknowledgeReset.useMutation,v_=X.lawnMowerControl.startMowing.useMutation,y_=X.lawnMowerControl.pause.useMutation,b_=X.lawnMowerControl.dock.useMutation,x_=X.lawnMowerControl.getStatus.useQuery,une=X.llm.generate.useMutation,dne=X.llm.generateVision.useMutation,fne=X.llm.cancel.useMutation,pne=X.llm.listProfileKinds.useQuery,mne=X.llm.listProfiles.useQuery,hne=X.llm.upsertProfile.useMutation,gne=X.llm.migrateRawSecrets.useMutation,_ne=X.llm.deleteProfile.useMutation,vne=X.llm.testProfile.useMutation,yne=X.llm.listModels.useMutation,bne=X.llm.getDefaults.useQuery,xne=X.llm.setDefault.useMutation,Sne=X.llm.getUsage.useQuery,Cne=X.llm.listModelCatalog.useQuery,wne=X.llm.listRuntimeNodes.useQuery,Tne=X.llm.listNodeModels.useQuery,Ene=X.llm.resolveModelRef.useMutation,Dne=X.llm.installModel.useMutation,One=X.llm.deleteModel.useMutation,kne=X.llm.getRuntimeStatus.useQuery,Ane=X.llm.startRuntime.useMutation,jne=X.llm.stopRuntime.useMutation,S_=X.localNetwork.list.useQuery,Mne=X.localNetwork.getPreferred.useQuery,C_=X.localNetwork.getConnectionEndpoints.useQuery,Nne=X.localNetwork.getNotificationEndpoint.useQuery,Pne=X.localNetwork.setNotificationEndpoint.useMutation,Fne=X.localNetwork.getViewerEndpoints.useQuery,Ine=X.localNetwork.setViewerEndpoints.useMutation,w_=X.localNetwork.getAddresses.useQuery,T_=X.localNetwork.addCustomAddress.useMutation,E_=X.localNetwork.removeCustomAddress.useMutation,D_=X.localNetwork.setAddressRole.useMutation,Lne=X.localNetwork.getHubAddresses.useQuery,O_=X.localNetwork.getAllowedAddresses.useQuery,k_=X.localNetwork.setAllowedAddresses.useMutation,A_=X.localNetwork.resetAllowlistToBestMatch.useMutation,j_=X.localNetwork.getTlsStatus.useQuery,M_=X.localNetwork.regenerateCertificate.useMutation,N_=X.localNetwork.uploadCertificate.useMutation,Rne=X.localNetwork.downloadCa.useQuery,P_=X.localNetwork.useStoredUploadedCertificate.useMutation,F_=X.localNetwork.revertToGeneratedCertificate.useMutation,I_=X.lockControl.lock.useMutation,L_=X.lockControl.unlock.useMutation,zne=X.lockControl.open.useMutation,Bne=X.lockControl.getStatus.useQuery,Vne=X.mediaPlayer.play.useMutation,Hne=X.mediaPlayer.pause.useMutation,Une=X.mediaPlayer.stop.useMutation,Wne=X.mediaPlayer.next.useMutation,Gne=X.mediaPlayer.previous.useMutation,Kne=X.mediaPlayer.seek.useMutation,qne=X.mediaPlayer.setVolume.useMutation,Jne=X.mediaPlayer.setMute.useMutation,Yne=X.mediaPlayer.setShuffle.useMutation,Xne=X.mediaPlayer.setRepeat.useMutation,Zne=X.mediaPlayer.selectSource.useMutation,Qne=X.mediaPlayer.playMedia.useMutation,$ne=X.mediaPlayer.getStatus.useQuery,R_=X.meshNetwork.getStatus.useQuery,ere=X.meshNetwork.join.useMutation,z_=X.meshNetwork.startLogin.useMutation,B_=X.meshNetwork.leave.useMutation,V_=X.meshNetwork.logout.useMutation,H_=X.meshNetwork.listPeers.useQuery,tre=X.meshNetwork.testConnection.useMutation,nre=X.meter.getStatus.useQuery,rre=X.metricsProvider.collectSnapshot.useQuery,ire=X.metricsProvider.getCached.useQuery,are=X.metricsProvider.getCurrent.useQuery,ore=X.metricsProvider.getDiskSpace.useQuery,sre=X.metricsProvider.getGpuInfo.useQuery,cre=X.metricsProvider.getCpuTemperature.useQuery,lre=X.metricsProvider.getProcessStats.useQuery,ure=X.metricsProvider.listAddonInstances.useQuery,dre=X.metricsProvider.getAddonStats.useQuery,U_=X.metricsProvider.listNodeProcesses.useQuery,W_=X.metricsProvider.getLoadSeries.useQuery,fre=X.motion.isDetected.useQuery,pre=X.motion.getStatus.useQuery,mre=X.motionDetection.analyze.useMutation,hre=X.motionDetection.removeCamera.useMutation,G_=X.motionDetection.reset.useMutation,K_=X.motionDetection.getDeviceSettingsContribution.useQuery,q_=X.motionDetection.getDeviceLiveContribution.useQuery,J_=X.motionDetection.applyDeviceSettingsPatch.useMutation,Y_=X.motionTrigger.setMotionTrigger.useMutation,X_=X.motionTrigger.getStatus.useQuery,Z_=X.motionZones.getOptions.useQuery,Q_=X.motionZones.setZone.useMutation,$_=X.motionZones.getStatus.useQuery,ev=X.mqttBroker.listBrokers.useQuery,tv=X.mqttBroker.getBrokerConfig.useQuery,nv=X.mqttBroker.addBroker.useMutation,rv=X.mqttBroker.removeBroker.useMutation,iv=X.mqttBroker.testConnection.useMutation,av=X.mqttBroker.startEmbeddedBroker.useMutation,ov=X.mqttBroker.stopEmbeddedBroker.useMutation,sv=X.mqttBroker.getStatus.useQuery,cv=X.nativeObjectDetection.getOptions.useQuery,lv=X.nativeObjectDetection.setSettings.useMutation,uv=X.nativeObjectDetection.setEnabled.useMutation,dv=X.nativeObjectDetection.getStatus.useQuery,fv=X.navigation.move.useMutation,pv=X.navigation.stop.useMutation,mv=X.navigation.goToPoint.useMutation,hv=X.navigation.listActions.useQuery,gv=X.navigation.runAction.useMutation,_v=X.navigation.playSound.useMutation,vv=X.navigation.setLightOn.useMutation,yv=X.navigation.setLightMode.useMutation,bv=X.navigation.setLightLevel.useMutation,xv=X.navigation.getFeatures.useQuery,Sv=X.navigation.getStatus.useQuery,Cv=X.networkAccess.start.useMutation,wv=X.networkAccess.stop.useMutation,Tv=X.networkAccess.getEndpoint.useQuery,Ev=X.networkAccess.getStatus.useQuery,Dv=X.networkAccess.listEndpoints.useQuery,Ov=X.networkLink.getStatus.useQuery,kv=X.networkQuality.getDeviceStats.useQuery,Av=X.networkQuality.getAllStats.useQuery,jv=X.networkQuality.reportClientStats.useMutation,Mv=X.nodes.topology.useQuery,Nv=X.nodes.directory.useQuery,Pv=X.nodes.deployAddon.useMutation,Fv=X.nodes.undeployAddon.useMutation,Iv=X.nodes.restartAddon.useMutation,Lv=X.nodes.restartProcess.useMutation,Rv=X.nodes.restartNode.useMutation,zv=X.nodes.shutdownNode.useMutation,Bv=X.nodes.renameNode.useMutation,Vv=X.nodes.clusterAddonStatus.useQuery,Hv=X.nodes.getCapUsageGraph.useQuery,Uv=X.nodes.getNodeAddons.useQuery,Wv=X.nodes.setProcessLogLevel.useMutation,Gv=X.nodes.executeQuery.useMutation,Kv=X.notificationOutput.listTargetKinds.useQuery,qv=X.notificationOutput.listTargets.useQuery,Jv=X.notificationOutput.getTarget.useQuery,Yv=X.notificationOutput.discoverTargets.useQuery,Xv=X.notificationOutput.probeTargetConfig.useMutation,Zv=X.notificationOutput.send.useMutation,Qv=X.notificationOutput.testTarget.useMutation,$v=X.notificationOutput.upsertTarget.useMutation,ey=X.notificationOutput.deleteTarget.useMutation,ty=X.notificationOutput.setTargetEnabled.useMutation,ny=X.notificationRules.listRules.useQuery,ry=X.notificationRules.getRule.useQuery,iy=X.notificationRules.createRule.useMutation,ay=X.notificationRules.updateRule.useMutation,oy=X.notificationRules.deleteRule.useMutation,sy=X.notificationRules.setRuleEnabled.useMutation,cy=X.notificationRules.listSequences.useQuery,ly=X.notificationRules.getSequence.useQuery,uy=X.notificationRules.createSequence.useMutation,dy=X.notificationRules.updateSequence.useMutation,fy=X.notificationRules.deleteSequence.useMutation,py=X.notificationRules.getClipRetentionAsks.useQuery,my=X.notificationRules.listDeviceMutes.useQuery,hy=X.notificationRules.setDeviceMuted.useMutation,gy=X.notificationRules.testRule.useMutation,_y=X.notificationRules.previewStateSummary.useMutation,vy=X.notificationRules.getConditionCatalog.useQuery,yy=X.notificationRules.getTemplateCatalog.useQuery,by=X.notificationRules.previewTemplate.useMutation,xy=X.notificationRules.getHistory.useQuery,Sy=X.notificationRules.getRuleLastRuns.useQuery,Cy=X.notificationRules.resolveArtifactUrl.useQuery,wy=X.notificationRules.listSnoozes.useQuery,Ty=X.notificationRules.createSnooze.useMutation,Ey=X.notificationRules.cancelSnooze.useMutation,Dy=X.notificationRules.getAlarmConfig.useQuery,Oy=X.notificationRules.setAlarmConfig.useMutation,ky=X.notificationRules.createAlarmProfile.useMutation,Ay=X.notificationRules.renameAlarmProfile.useMutation,jy=X.notificationRules.deleteAlarmProfile.useMutation,My=X.notificationRules.activateAlarmProfile.useMutation,Ny=X.notificationRules.getAlarmSensors.useQuery,Py=X.notifier.send.useMutation,Fy=X.notifier.cancel.useMutation,Iy=X.notifier.getStatus.useQuery,Ly=X.numericSensor.getStatus.useQuery,Ry=X.oidcConnections.connectionFormSchema.useQuery,zy=X.oidcConnections.listConnections.useQuery,By=X.oidcConnections.createConnection.useMutation,Vy=X.oidcConnections.updateConnection.useMutation,Hy=X.oidcConnections.deleteConnection.useMutation,Uy=X.osd.setOverlay.useMutation,Wy=X.osd.getStatus.useQuery,Gy=X.osdManager.getDeviceOsd.useQuery,Ky=X.osdManager.getSourceCatalog.useQuery,qy=X.osdManager.getConditionSupport.useQuery,Jy=X.osdManager.setSlotBinding.useMutation,Yy=X.osdManager.clearSlotBinding.useMutation,Xy=X.osdManager.setSlotCameraEnabled.useMutation,Zy=X.osdManager.copyDeviceConfiguration.useMutation,Qy=X.osdManager.previewSlot.useMutation,$y=X.osdManager.renderDevice.useMutation,eb=X.osdManager.listTemplates.useQuery,tb=X.osdManager.upsertTemplate.useMutation,nb=X.osdManager.deleteTemplate.useMutation,rb=X.petFeeder.feed.useMutation,ib=X.petFeeder.cancelFeed.useMutation,ab=X.petFeeder.resetDesiccant.useMutation,ob=X.petFeeder.markFoodReplenished.useMutation,sb=X.petFeeder.callPet.useMutation,cb=X.petFeeder.playSound.useMutation,lb=X.petFeeder.setChildLock.useMutation,ub=X.petFeeder.setIndicatorLight.useMutation,db=X.petFeeder.setFeedSound.useMutation,fb=X.petFeeder.setVolume.useMutation,pb=X.petFeeder.getStatus.useQuery,mb=X.pipelineAnalytics.getActiveTracks.useQuery,hb=X.pipelineAnalytics.getTrack.useQuery,gb=X.pipelineAnalytics.listTracks.useQuery,_b=X.pipelineAnalytics.listRecentTracks.useQuery,vb=X.pipelineAnalytics.clearTracks.useMutation,yb=X.pipelineAnalytics.getMotionEvents.useQuery,bb=X.pipelineAnalytics.getObjectEvents.useQuery,xb=X.pipelineAnalytics.getAudioEvents.useQuery,Sb=X.pipelineAnalytics.listEventKinds.useQuery,Cb=X.pipelineAnalytics.listEventKindsBatch.useQuery,wb=X.pipelineAnalytics.getSensorEvents.useQuery,Tb=X.pipelineAnalytics.getKeyEvents.useQuery,Eb=X.pipelineAnalytics.getKeyEventsBatch.useQuery,Db=X.pipelineAnalytics.readLongTermSeries.useQuery,Ob=X.pipelineAnalytics.getEventDensity.useQuery,kb=X.pipelineAnalytics.getEventDensityBatch.useQuery,Ab=X.pipelineAnalytics.pruneEventsBefore.useMutation,jb=X.pipelineAnalytics.pruneTracksBefore.useMutation,Mb=X.pipelineAnalytics.wipeAllAnalytics.useMutation,Nb=X.pipelineAnalytics.reconcileFromDisk.useMutation,Pb=X.pipelineAnalytics.deleteTracks.useMutation,Fb=X.pipelineAnalytics.setTrackFlags.useMutation,Ib=X.pipelineAnalytics.listArchivedDebugNotes.useQuery,Lb=X.pipelineAnalytics.setTrackRelation.useMutation,Rb=X.pipelineAnalytics.clearTrackRelation.useMutation,zb=X.pipelineAnalytics.setTrackPurity.useMutation,Bb=X.pipelineAnalytics.listTrackRelations.useQuery,Vb=X.pipelineAnalytics.listBirthDecisions.useQuery,Hb=X.pipelineAnalytics.getEventStoreFootprint.useQuery,Ub=X.pipelineAnalytics.getEventMediaFootprintByKind.useQuery,Wb=X.pipelineAnalytics.pruneEvents.useMutation,Gb=X.pipelineAnalytics.deleteDeviceEvents.useMutation,Kb=X.pipelineAnalytics.pauseForStorageMigration.useMutation,qb=X.pipelineAnalytics.resumeForStorageMigration.useMutation,Jb=X.pipelineAnalytics.refreshStorageLocationsForMigration.useMutation,Yb=X.pipelineAnalytics.startStorageMigrationMove.useMutation,Xb=X.pipelineAnalytics.getStorageMigrationMoveStatus.useQuery,Zb=X.pipelineAnalytics.cancelStorageMigrationMove.useMutation,Qb=X.pipelineAnalytics.relocateMedia.useMutation,$b=X.pipelineAnalytics.countUnstampedEventMedia.useQuery,ex=X.pipelineAnalytics.countRelocatableMedia.useQuery,tx=X.pipelineAnalytics.listRelocateMediaJobs.useQuery,nx=X.pipelineAnalytics.cancelRelocateMedia.useMutation,rx=X.pipelineAnalytics.listOpsLog.useQuery,ix=X.pipelineAnalytics.reclaimDebugMedia.useMutation,ax=X.pipelineAnalytics.getMediaReclaimStatus.useQuery,ox=X.pipelineAnalytics.getTrainingExportSummary.useQuery,sx=X.pipelineAnalytics.getTrainingExportUrl.useQuery,cx=X.pipelineAnalytics.listRetrainStaging.useQuery,lx=X.pipelineAnalytics.listRetrainCorpusPage.useQuery,ux=X.pipelineAnalytics.getRetrainCorpusKpi.useQuery,dx=X.pipelineAnalytics.listRetrainFrames.useQuery,fx=X.pipelineAnalytics.selectRetrainFrames.useMutation,px=X.pipelineAnalytics.deselectRetrainFrame.useMutation,mx=X.pipelineAnalytics.getRetrainFrameImage.useQuery,hx=X.pipelineAnalytics.proposeRetrainAnnotations.useMutation,gx=X.pipelineAnalytics.listRetrainAnnotations.useQuery,_x=X.pipelineAnalytics.saveRetrainAnnotations.useMutation,vx=X.pipelineAnalytics.backfillRetrainOrigins.useMutation,yx=X.pipelineAnalytics.completeRetrainTrack.useMutation,bx=X.pipelineAnalytics.restageRetrainTrack.useMutation,xx=X.pipelineAnalytics.getRetrainExportUrl.useQuery,Sx=X.pipelineAnalytics.setRetrainFrameComplete.useMutation,Cx=X.pipelineAnalytics.writeRetrainArchive.useMutation,wx=X.pipelineAnalytics.offerRetrainArchive.useMutation,Tx=X.pipelineAnalytics.listRetrainAssistProfiles.useQuery,Ex=X.pipelineAnalytics.proposeRetrainAnnotationsWithLlm.useMutation,Dx=X.pipelineAnalytics.createRetrainCollection.useMutation,Ox=X.pipelineAnalytics.listRetrainCollections.useQuery,kx=X.pipelineAnalytics.resolveRetrainTrainingCorpus.useQuery,Ax=X.pipelineAnalytics.renameRetrainCollection.useMutation,jx=X.pipelineAnalytics.deleteRetrainCollection.useMutation,Mx=X.pipelineAnalytics.addRetrainFrameFromRecording.useMutation,Nx=X.pipelineAnalytics.addRetrainFramesToCollection.useMutation,Px=X.pipelineAnalytics.removeRetrainFrameFromCollection.useMutation,Fx=X.pipelineAnalytics.listRetrainCollectionFrames.useQuery,Ix=X.pipelineAnalytics.getEventMedia.useQuery,Lx=X.pipelineAnalytics.getTrackMedia.useQuery,Rx=X.pipelineAnalytics.listTrackMedia.useQuery,zx=X.pipelineAnalytics.listEventMedia.useQuery,Bx=X.pipelineAnalytics.ownersWithMedia.useQuery,Vx=X.pipelineAnalytics.searchObjectEvents.useQuery,Hx=X.pipelineAnalytics.wipeObjectEmbeddings.useMutation,Ux=X.pipelineAnalytics.rebuildObjectEmbeddings.useMutation,Wx=X.pipelineAnalytics.getObjectEmbeddingRebuildStatus.useQuery,Gx=X.pipelineAnalytics.getDeviceSettingsContribution.useQuery,Kx=X.pipelineAnalytics.getDeviceLiveContribution.useQuery,qx=X.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Jx=X.pipelineExecutor.getAvailableEngines.useQuery,Yx=X.pipelineExecutor.getSelectedEngine.useQuery,Xx=X.pipelineExecutor.getEngineProvisioning.useQuery,Zx=X.pipelineExecutor.getVideoPipelineSteps.useQuery,Qx=X.pipelineExecutor.setVideoPipelineSteps.useMutation,$x=X.pipelineExecutor.getInferenceDeviceHealth.useQuery,eS=X.pipelineExecutor.rearmInferenceDevice.useMutation,tS=X.pipelineExecutor.getSchema.useQuery,nS=X.pipelineExecutor.getOrchestratorConfigSchema.useQuery,rS=X.pipelineExecutor.validatePipeline.useQuery,iS=X.pipelineExecutor.getCapabilities.useQuery,aS=X.pipelineExecutor.getAddonModels.useQuery,oS=X.pipelineExecutor.downloadModel.useMutation,sS=X.pipelineExecutor.deleteModel.useMutation,cS=X.pipelineExecutor.runPipeline.useMutation,lS=X.pipelineExecutor.runPipelineBatch.useMutation,uS=X.pipelineExecutor.cacheFrameInPool.useMutation,dS=X.pipelineExecutor.inferCached.useMutation,fS=X.pipelineExecutor.uncacheFrame.useMutation,pS=X.pipelineExecutor.getEffectiveTuning.useQuery,mS=X.pipelineExecutor.listLoadedEngines.useQuery,hS=X.pipelineExecutor.spinEngine.useMutation,gS=X.pipelineExecutor.killEngine.useMutation,_S=X.pipelineExecutor.listReferenceImages.useQuery,vS=X.pipelineExecutor.getReferenceImage.useQuery,yS=X.pipelineExecutor.getReferenceAudioFiles.useQuery,bS=X.pipelineExecutor.getReferenceAudio.useQuery,xS=X.pipelineExecutor.getAudioCapabilities.useQuery,SS=X.pipelineExecutor.runAudioTest.useMutation,CS=X.pipelineExecutor.getDetectionConfigSchema.useQuery,wS=X.pipelineOrchestrator.requestOccupancyLook.useMutation,TS=X.pipelineOrchestrator.pauseForStorageMigration.useMutation,ES=X.pipelineOrchestrator.resumeForStorageMigration.useMutation,DS=X.pipelineOrchestrator.assignPipeline.useMutation,OS=X.pipelineOrchestrator.unassignPipeline.useMutation,kS=X.pipelineOrchestrator.setPipelineDevicePin.useMutation,AS=X.pipelineOrchestrator.getPipelineDevicePin.useQuery,jS=X.pipelineOrchestrator.rebalance.useMutation,MS=X.pipelineOrchestrator.getPipelineAssignments.useQuery,NS=X.pipelineOrchestrator.getPipelineAssignment.useQuery,PS=X.pipelineOrchestrator.getAgentLoad.useQuery,FS=X.pipelineOrchestrator.getClusterModelChoice.useQuery,IS=X.pipelineOrchestrator.getGlobalMetrics.useQuery,LS=X.pipelineOrchestrator.getCameraMetrics.useQuery,RS=X.pipelineOrchestrator.getCapabilityBindings.useQuery,zS=X.pipelineOrchestrator.setCapabilityBinding.useMutation,BS=X.pipelineOrchestrator.getIngestOwner.useQuery,VS=X.pipelineOrchestrator.assignAudio.useMutation,HS=X.pipelineOrchestrator.unassignAudio.useMutation,US=X.pipelineOrchestrator.getAudioAssignment.useQuery,WS=X.pipelineOrchestrator.getAudioNodeLoad.useQuery,GS=X.pipelineOrchestrator.getAudioAssignments.useQuery,KS=X.pipelineOrchestrator.getAgentSettings.useQuery,qS=X.pipelineOrchestrator.listAgentSettings.useQuery,JS=X.pipelineOrchestrator.removeAgentSettings.useMutation,YS=X.pipelineOrchestrator.setAgentMaxCameras.useMutation,XS=X.pipelineOrchestrator.setAgentCapabilities.useMutation,ZS=X.pipelineOrchestrator.setAgentDecodeLimits.useMutation,QS=X.pipelineOrchestrator.setAgentReachableHost.useMutation,$S=X.pipelineOrchestrator.setAgentInferenceDevices.useMutation,eC=X.pipelineOrchestrator.setNodeStepSettings.useMutation,tC=X.pipelineOrchestrator.getNodeInferenceDevices.useQuery,nC=X.pipelineOrchestrator.forgetInferenceDevice.useMutation,rC=X.pipelineOrchestrator.resetNodePipelineDefaults.useMutation,iC=X.pipelineOrchestrator.planAutoTune.useQuery,aC=X.pipelineOrchestrator.applyAutoTune.useMutation,oC=X.pipelineOrchestrator.setLoadBalancingShares.useMutation,sC=X.pipelineOrchestrator.getPlacementStats.useQuery,cC=X.pipelineOrchestrator.suggestShares.useQuery,lC=X.pipelineOrchestrator.getEffectiveShares.useQuery,uC=X.pipelineOrchestrator.setShareSource.useMutation,dC=X.pipelineOrchestrator.getNodeBenchmarkPreflight.useQuery,fC=X.pipelineOrchestrator.startNodeBenchmark.useMutation,pC=X.pipelineOrchestrator.getNodeBenchmarkStatus.useQuery,mC=X.pipelineOrchestrator.abortNodeBenchmark.useMutation,hC=X.pipelineOrchestrator.getNodeBenchmarkCandidates.useQuery,gC=X.pipelineOrchestrator.listNodeBenchmarkResults.useQuery,_C=X.pipelineOrchestrator.deleteNodeBenchmarkResult.useMutation,vC=X.pipelineOrchestrator.getCameraSettings.useQuery,yC=X.pipelineOrchestrator.setCameraStepToggle.useMutation,bC=X.pipelineOrchestrator.getCameraDetectionSource.useQuery,xC=X.pipelineOrchestrator.setCameraDetectionSource.useMutation,SC=X.pipelineOrchestrator.setCameraStepSettings.useMutation,CC=X.pipelineOrchestrator.resolvePipeline.useQuery,wC=X.pipelineOrchestrator.getCameraSwitches.useQuery,TC=X.pipelineOrchestrator.setCameraSwitch.useMutation,EC=X.pipelineOrchestrator.getCameraStatus.useQuery,DC=X.pipelineOrchestrator.getCameraStatuses.useQuery,OC=X.pipelineOrchestrator.setCameraSensors.useMutation,kC=X.pipelineOrchestrator.reconcileFromDisk.useMutation,AC=X.pipelineOrchestrator.getReconcileFromDiskStatus.useQuery,jC=X.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,MC=X.pipelineOrchestrator.getDeviceLiveContribution.useQuery,NC=X.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,PC=X.pipelineRunner.attachCamera.useMutation,FC=X.pipelineRunner.detachCamera.useMutation,IC=X.pipelineRunner.reportMotion.useMutation,LC=X.pipelineRunner.getLocalLoad.useQuery,RC=X.pipelineRunner.getLocalMetrics.useQuery,zC=X.pipelineRunner.getCameraMetrics.useQuery,BC=X.pipelineRunner.getAllCameraMetrics.useQuery,VC=X.pipelineRunner.getLocalCameras.useQuery,HC=X.pipelineRunner.requestOccupancyBurst.useMutation,UC=X.pipelineRunner.getNativeCrop.useQuery,WC=X.pipelineRunner.runDetailSubtree.useMutation,GC=X.pipelineRunner.runStatelessStep.useMutation,KC=X.pipelineRunner.parkTrackFrame.useMutation,qC=X.pipelineRunner.getParkedTrackFrame.useQuery,JC=X.pipelineRunner.releaseParkedTrackFrames.useMutation,YC=X.pipelineRunner.startNodeBench.useMutation,XC=X.pipelineRunner.getNodeBenchStatus.useQuery,ZC=X.pipelineRunner.abortNodeBench.useMutation,QC=X.plateGallery.listPlates.useQuery,$C=X.plateGallery.getPlateByTrack.useQuery,ew=X.plateGallery.getPlateMedia.useQuery,tw=X.plateGallery.searchPlates.useQuery,nw=X.plateGallery.suggestPlateClusters.useQuery,rw=X.plateGallery.correctPlateText.useMutation,iw=X.plateGallery.deletePlate.useMutation,aw=X.plateGallery.listVehicles.useQuery,ow=X.plateGallery.createVehicle.useMutation,sw=X.plateGallery.renameVehicle.useMutation,cw=X.plateGallery.deleteVehicle.useMutation,lw=X.plateGallery.listVehicleSamples.useQuery,uw=X.plateGallery.removeVehicleSample.useMutation,dw=X.plateGallery.assignPlate.useMutation,fw=X.plateGallery.unassignPlate.useMutation,pw=X.plateGallery.assignPlates.useMutation,mw=X.plateGallery.unassignPlates.useMutation,hw=X.powerMeter.getStatus.useQuery,gw=X.presence.getStatus.useQuery,_w=X.pressureSensor.getStatus.useQuery,vw=X.privacyMask.getOptions.useQuery,yw=X.privacyMask.setMask.useMutation,bw=X.privacyMask.setAudioEnabled.useMutation,xw=X.privacyMask.getStatus.useQuery,Sw=X.ptz.move.useMutation,Cw=X.ptz.continuousMove.useMutation,ww=X.ptz.stop.useMutation,Tw=X.ptz.getPresets.useQuery,Ew=X.ptz.goToPreset.useMutation,Dw=X.ptz.savePreset.useMutation,Ow=X.ptz.deletePreset.useMutation,kw=X.ptz.getOptions.useQuery,Aw=X.ptz.goHome.useMutation,jw=X.ptz.getHomePreset.useQuery,Mw=X.ptz.setHomePreset.useMutation,Nw=X.ptz.captureHomeHere.useMutation,Pw=X.ptz.getHomeReturn.useQuery,Fw=X.ptz.setHomeReturn.useMutation,Iw=X.ptz.getPosition.useQuery,Lw=X.ptz.setAutofocus.useMutation,Rw=X.ptz.getStatus.useQuery,zw=X.ptzAutotrack.getStatus.useQuery,Bw=X.ptzAutotrack.setEnabled.useMutation,Vw=X.ptzAutotrack.getSettings.useQuery,Hw=X.ptzAutotrack.setSettings.useMutation,Uw=X.reboot.reboot.useMutation,Ww=X.recordEntries.listEntryKinds.useQuery,Gw=X.recordEntries.listEntries.useQuery,Kw=X.recordEntries.putEntry.useMutation,qw=X.recordEntries.deleteEntry.useMutation,Jw=X.recording.listSources.useQuery,Yw=X.recording.getAvailability.useQuery,Xw=X.recording.getDaysWithRecordings.useQuery,Zw=X.recording.getPlayback.useQuery,Qw=X.recording.getPlaybackOptions.useQuery,$w=X.recordingArchive.getAvailabilityBatch.useQuery,eT=X.recordingArchive.getDaysWithRecordingsBatch.useQuery,tT=X.recordingArchive.getStorageUsage.useQuery,nT=X.recordingArchive.getDeviceConfig.useQuery,rT=X.recordingArchive.locateSegment.useQuery,iT=X.recordingArchive.readSegmentBytes.useQuery,aT=X.recordingArchive.readGopBytes.useQuery,oT=X.recordingArchive.readWindowBytes.useQuery,sT=X.recordingArchive.setDeviceConfig.useMutation,cT=X.recordingArchive.rescanStorage.useMutation,lT=X.recordingArchive.pruneFootage.useMutation,uT=X.recordingArchive.deleteFootprint.useMutation,dT=X.recordingArchive.listOpsLog.useQuery,fT=X.recordingArchive.renderGif.useMutation,pT=X.recordingArchive.renderClip.useMutation,mT=X.recordingArchive.pauseForStorageMigration.useMutation,hT=X.recordingArchive.resumeForStorageMigration.useMutation,gT=X.recordingArchive.refreshStorageLocationsForMigration.useMutation,_T=X.recordingArchive.startStorageMigrationMove.useMutation,vT=X.recordingArchive.getStorageMigrationMoveStatus.useQuery,yT=X.recordingArchive.cancelStorageMigrationMove.useMutation,bT=X.recordingArchive.relocateFootage.useMutation,xT=X.recordingArchive.listRelocateJobs.useQuery,ST=X.recordingArchive.getRelocateResidue.useQuery,CT=X.recordingArchive.reconcileLedgerAgainstDisk.useMutation,wT=X.recordingArchive.cancelRelocateJob.useMutation,TT=X.recordingArchive.planStorageRebalance.useQuery,ET=X.recordingArchive.startStorageRebalance.useMutation,DT=X.recordingArchive.getPlacement.useQuery,OT=X.recordingArchive.setDevicePlacement.useMutation,kT=X.recordingArchive.getStatus.useQuery,AT=X.recordingArchive.getDeviceSettingsContribution.useQuery,jT=X.recordingArchive.getDeviceLiveContribution.useQuery,MT=X.recordingArchive.applyDeviceSettingsPatch.useMutation,NT=X.recordingExport.createExport.useMutation,PT=X.recordingExport.listExports.useQuery,FT=X.recordingExport.getExport.useQuery,IT=X.recordingExport.cancelExport.useMutation,LT=X.recordingExport.deleteExport.useMutation,RT=X.recordingExport.getDownloadUrl.useQuery,zT=X.recordingExport.readExportBytes.useQuery,BT=X.recordingOnboard.getOptions.useQuery,VT=X.recordingOnboard.setSettings.useMutation,HT=X.recordingOnboard.getStatus.useQuery,UT=X.recordingSignal.getStatus.useQuery,WT=X.runningState.getStatus.useQuery,GT=X.sceneMonitor.listScenes.useQuery,KT=X.sceneMonitor.listScenesBatch.useQuery,qT=X.sceneMonitor.createScene.useMutation,JT=X.sceneMonitor.updateScene.useMutation,YT=X.sceneMonitor.deleteScene.useMutation,XT=X.sceneMonitor.captureReference.useMutation,ZT=X.sceneMonitor.deleteReference.useMutation,QT=X.sceneMonitor.recheckNow.useMutation,$T=X.sceneMonitor.resetScene.useMutation,eE=X.sceneMonitor.getStatus.useQuery,tE=X.scriptRunner.run.useMutation,nE=X.scriptRunner.stop.useMutation,rE=X.scriptRunner.getStatus.useQuery,iE=X.serverManagement.getServerPackageStatus.useQuery,aE=X.serverManagement.checkServerUpdate.useMutation,oE=X.serverManagement.applyServerUpdate.useMutation,sE=X.serverManagement.rollbackServerUpdate.useMutation,cE=X.serverManagement.restartServer.useMutation,lE=X.settingsStore.get.useQuery,uE=X.settingsStore.set.useMutation,dE=X.settingsStore.query.useQuery,fE=X.settingsStore.upsert.useMutation,pE=X.settingsStore.upsertMany.useMutation,mE=X.settingsStore.insert.useMutation,hE=X.settingsStore.insertMany.useMutation,gE=X.settingsStore.transact.useMutation,_E=X.settingsStore.update.useMutation,vE=X.settingsStore.delete.useMutation,yE=X.settingsStore.deleteWhere.useMutation,bE=X.settingsStore.updateWhere.useMutation,xE=X.settingsStore.count.useQuery,SE=X.settingsStore.aggregate.useQuery,CE=X.settingsStore.histogram.useQuery,wE=X.settingsStore.isEmpty.useQuery,TE=X.settingsStore.declareCollection.useMutation,EE=X.smoke.getStatus.useQuery,DE=X.snapshot.getSnapshot.useQuery,OE=X.snapshot.invalidateCache.useMutation,kE=X.snapshot.getSnapshotOverview.useQuery,AE=X.snapshot.getDebugState.useQuery,jE=X.snapshot.getSnapshotLinks.useQuery,ME=X.snapshot.getStatus.useQuery,NE=X.snapshot.getDeviceSettingsContribution.useQuery,PE=X.snapshot.getDeviceLiveContribution.useQuery,FE=X.snapshot.applyDeviceSettingsPatch.useMutation,IE=X.storage.resolve.useQuery,LE=X.storage.write.useMutation,RE=X.storage.read.useQuery,zE=X.storage.exists.useQuery,BE=X.storage.list.useQuery,VE=X.storage.delete.useMutation,HE=X.storage.getAvailableSpace.useQuery,UE=X.storage.beginUpload.useMutation,WE=X.storage.writeChunk.useMutation,GE=X.storage.finalizeUpload.useMutation,KE=X.storage.abortUpload.useMutation,qE=X.storage.beginDownload.useMutation,JE=X.storage.readChunk.useQuery,YE=X.storage.endDownload.useMutation,XE=X.storage.listLocations.useQuery,ZE=X.storage.listLocationDeclarations.useQuery,QE=X.storage.upsertLocation.useMutation,$E=X.storage.deleteLocation.useMutation,eD=X.storage.listDrainProgress.useQuery,tD=X.storage.testLocation.useQuery,nD=X.storage.listProviders.useQuery,rD=X.storage.testConfig.useQuery,iD=X.storageMigration.plan.useQuery,aD=X.storageMigration.start.useMutation,oD=X.storageMigration.status.useQuery,sD=X.storageMigration.cancel.useMutation,cD=X.storageMigration.movers.useQuery,lD=X.storageMigration.moverClearance.useQuery,uD=X.storageMigration.residue.useQuery,dD=X.storageMigration.drain.useMutation,fD=X.storageMigration.cleanupStart.useMutation,pD=X.storageMigration.cleanupStatus.useQuery,mD=X.storageMigration.cleanupCancel.useMutation,hD=X.storageMigration.history.useQuery,gD=X.streamBroker.reportStreamSignal.useMutation,_D=X.streamBroker.publishCameraStream.useMutation,vD=X.streamBroker.retractCameraStream.useMutation,yD=X.streamBroker.assignProfile.useMutation,bD=X.streamBroker.unassignProfile.useMutation,xD=X.streamBroker.forgetDeviceHardware.useMutation,SD=X.streamBroker.renderPreBufferClip.useMutation,CD=X.streamBroker.produceEventMedia.useMutation,wD=X.streamBroker.fetchEventMedia.useMutation,TD=X.streamBroker.listAllCameraStreams.useQuery,ED=X.streamBroker.listAllProfileSlots.useQuery,DD=X.streamBroker.getBrokerStats.useQuery,OD=X.streamBroker.probeStream.useMutation,kD=X.streamBroker.listClients.useQuery,AD=X.streamBroker.getLiveViewerCounts.useQuery,jD=X.streamBroker.killClient.useMutation,MD=X.streamBroker.restartProfile.useMutation,ND=X.streamBroker.getStreamUrl.useQuery,PD=X.streamBroker.getStreamWithCodec.useMutation,FD=X.streamBroker.releaseStreamWithCodec.useMutation,ID=X.streamBroker.acquireEgressTranscode.useMutation,LD=X.streamBroker.releaseEgressTranscode.useMutation,RD=X.streamBroker.subscribeAudioChunks.useMutation,zD=X.streamBroker.pullAudioChunks.useQuery,BD=X.streamBroker.unsubscribeAudioChunks.useMutation,VD=X.streamBroker.setPreBufferDuration.useMutation,HD=X.streamBroker.getPreBufferInfo.useQuery,UD=X.streamBroker.getRtspPort.useQuery,WD=X.streamBroker.getAllRtspEntries.useQuery,GD=X.streamBroker.getRtspEntry.useQuery,KD=X.streamBroker.regenerateRtspToken.useMutation,qD=X.streamBroker.setRtspEnabled.useMutation,JD=X.streamBroker.isRtspEnabled.useQuery,YD=X.streamBroker.getDeviceAudioMute.useQuery,XD=X.streamBroker.setDeviceAudioMute.useMutation,ZD=X.streamBroker.getDeviceSettingsContribution.useQuery,QD=X.streamBroker.getDeviceLiveContribution.useQuery,$D=X.streamBroker.applyDeviceSettingsPatch.useMutation,eO=X.streamCatalog.getCatalog.useQuery,tO=X.streamParams.getOptions.useQuery,nO=X.streamParams.setProfile.useMutation,rO=X.streamParams.getConfigSchema.useQuery,iO=X.streamParams.getStatus.useQuery,aO=X.streamSignals.listSignals.useQuery,oO=X.switch.setState.useMutation,sO=X.switch.getStatus.useQuery,cO=X.system.info.useQuery,lO=X.system.health.useQuery,uO=X.system.featureFlags.useQuery,dO=X.system.networkAddresses.useQuery,fO=X.system.getRetentionConfig.useQuery,pO=X.system.setRetentionConfig.useMutation,mO=X.system.forceRetentionCleanup.useMutation,hO=X.system.getSiteLocation.useQuery,gO=X.system.setSiteLocation.useMutation,_O=X.system.detectSiteLocation.useMutation,vO=X.system.getRequestCensus.useQuery,yO=X.system.getLoadContributions.useQuery,bO=X.system.getFailureContributions.useQuery,xO=X.system.getLoggingSettings.useQuery,SO=X.system.setLoggingSettings.useMutation,CO=X.tamper.getStatus.useQuery,wO=X.temperatureSensor.getStatus.useQuery,TO=X.terminalSession.listProfiles.useQuery,EO=X.terminalSession.listInstances.useQuery,DO=X.terminalSession.createInstance.useMutation,OO=X.terminalSession.updateInstance.useMutation,kO=X.terminalSession.deleteInstance.useMutation,AO=X.terminalSession.setInstanceEnabled.useMutation,jO=X.terminalSession.listLegacyCameras.useQuery,MO=X.terminalSession.adoptLegacyMonitor.useMutation,NO=X.terminalSession.listSessions.useQuery,PO=X.terminalSession.openSession.useMutation,FO=X.terminalSession.resize.useMutation,IO=X.terminalSession.pullOutput.useMutation,LO=X.terminalSession.writeInput.useMutation,RO=X.terminalSession.close.useMutation,zO=X.toast.onToast.useSubscription,BO=X.training.listBaseModels.useQuery,VO=X.training.planJob.useQuery,HO=X.training.startJob.useMutation,UO=X.training.startJobBatch.useMutation,WO=X.training.listJobs.useQuery,GO=X.training.getJob.useQuery,KO=X.training.cancelJob.useMutation,qO=X.training.getJobResult.useQuery,JO=X.training.listCanaryTargets.useQuery,YO=X.training.registerResult.useMutation,XO=X.training.canaryResult.useMutation,ZO=X.training.rollbackCanary.useMutation,QO=X.training.discardResult.useMutation,$O=X.turnProvider.getTurnServers.useQuery,ek=X.update.installUpdate.useMutation,tk=X.update.getStatus.useQuery,nk=X.userManagement.listUsers.useQuery,rk=X.userManagement.createUser.useMutation,ik=X.userManagement.updateUser.useMutation,ak=X.userManagement.deleteUser.useMutation,ok=X.userManagement.resetPassword.useMutation,sk=X.userManagement.setUserScopes.useMutation,gre=X.userManagement.validateCredentials.useMutation,_re=X.userManagement.setupTotp.useMutation,vre=X.userManagement.confirmTotp.useMutation,ck=X.userManagement.disableTotp.useMutation,lk=X.userManagement.getTotpStatus.useQuery,yre=X.userManagement.migrateRawSecrets.useMutation,bre=X.userManagement.verifyTotp.useMutation,xre=X.userManagement.oauthIssueCode.useMutation,Sre=X.userManagement.oauthExchangeCode.useMutation,Cre=X.userManagement.oauthRefresh.useMutation,wre=X.userManagement.oauthVerifyAccessToken.useQuery,uk=X.userManagement.listExternalIdentities.useQuery,Tre=X.userManagement.findUserByExternalIdentity.useQuery,dk=X.userManagement.unlinkExternalIdentity.useMutation,fk=X.userManagement.listOauthSessions.useQuery,pk=X.userManagement.revokeOauthSession.useMutation,Ere=X.vacuumControl.start.useMutation,Dre=X.vacuumControl.pause.useMutation,Ore=X.vacuumControl.stop.useMutation,kre=X.vacuumControl.returnToBase.useMutation,Are=X.vacuumControl.locate.useMutation,jre=X.vacuumControl.setFanSpeed.useMutation,Mre=X.vacuumControl.getStatus.useQuery,Nre=X.valve.open.useMutation,Pre=X.valve.close.useMutation,Fre=X.valve.stop.useMutation,Ire=X.valve.setPosition.useMutation,Lre=X.valve.getStatus.useQuery,Rre=X.vibration.getStatus.useQuery,mk=X.videoclips.listClips.useQuery,hk=X.videoclips.listSources.useQuery,gk=X.videoclips.getClipPlayback.useQuery,zre=X.videoclips.readClipBytes.useQuery,Bre=X.videoclips.offerClipBytes.useQuery,Vre=X.videoclips.dialClipStream.useQuery,Hre=X.videoclips.getPlaybackOptions.useQuery,Ure=X.waterHeater.setTargetTemp.useMutation,Wre=X.waterHeater.setOperationMode.useMutation,Gre=X.waterHeater.setAway.useMutation,Kre=X.waterHeater.getStatus.useQuery,qre=X.weather.getStatus.useQuery,Jre=X.webrtcSession.listStreams.useQuery,Yre=X.webrtcSession.createSession.useMutation,Xre=X.webrtcSession.handleOffer.useMutation,Zre=X.webrtcSession.handleAnswer.useMutation,Qre=X.webrtcSession.addIceCandidate.useMutation,$re=X.webrtcSession.getIceCandidates.useQuery,eie=X.webrtcSession.closeSession.useMutation,tie=X.webrtcSession.hasAdaptiveBitrate.useQuery,nie=X.webrtcSession.getSessionState.useQuery,rie=X.webrtcSession.applyDownlinkProbe.useMutation,iie=X.webrtcSession.getSessionDebug.useQuery,aie=X.zoneAnalytics.getCurrentSnapshot.useQuery,oie=X.zoneAnalytics.getCurrentSnapshotBatch.useQuery,sie=X.zoneAnalytics.getZoneHistory.useQuery,cie=X.zoneAnalytics.getCameraHistory.useQuery,lie=X.zoneAnalytics.getUnzonedHistory.useQuery,uie=X.zoneRules.listRules.useQuery,die=X.zoneRules.setRules.useMutation,_k=X.zones.listZones.useQuery,fie=X.zones.addZone.useMutation,pie=X.zones.removeZone.useMutation,mie=X.zones.updateZone.useMutation;E(),Do();var vk=O(null);function yk(){let e=I(vk);if(!e)throw Error(`Dropdown compound components must be used within <Dropdown>`);return e}function bk({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t!==void 0&&n!==void 0,o=a?t:r,s=_(e=>{a?n(e):i(e)},[a,n]),c=y(),l=y(),u=f(null);return v(vk.Provider,{value:{open:o,setOpen:s,triggerId:c,contentId:l,triggerRef:u},children:v(`div`,{className:`relative inline-block`,children:e})})}function xk({children:e,...t}){let{open:n,setOpen:r,triggerId:i,contentId:a,triggerRef:o}=yk();return v(`button`,{type:`button`,ref:o,id:i,"aria-haspopup":`menu`,"aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function Sk({className:e,children:t,align:n=`start`,offset:r=4,...i}){let{open:a,setOpen:o,contentId:s,triggerId:c,triggerRef:l}=yk(),d=f(null),[p,m]=C(null);return u(()=>{if(!a){m(null);return}let e=()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),i=n===`end`?t.right:t.left;m({top:t.bottom+r,left:i,minWidth:t.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a,n,r,l]),b(()=>{if(!a)return;let e=e=>{let t=d.current,n=l.current;t&&!t.contains(e.target)&&!n?.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a,o,l]),!a||!p||typeof document>`u`?null:Oo(v(`div`,{ref:d,id:s,role:`menu`,"aria-labelledby":c,style:{position:`fixed`,top:p.top,...n===`end`?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth},className:$(`z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]`,e),...i,children:t}),document.body)}function Ck({className:e,icon:t,variant:n=`default`,children:r,onClick:i,...a}){let{setOpen:o}=yk(),s=_(e=>{i?.(e),o(!1)},[i,o]);return c(`button`,{type:`button`,role:`menuitem`,className:$(`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:s,...a,children:[t&&v(t,{size:14}),r]})}function hie(e,t){if(e.length===0||t.length===0)return!1;let n=new Set(e);return t.some(e=>n.has(e))}function wk(e,t){if(t?.excludeDeviceId!==void 0&&e.id===t.excludeDeviceId||t?.excludeTypes!==void 0&&t.excludeTypes.includes(e.type))return!1;let n=t?.caps!==void 0&&t.caps.length>0,r=t?.types!==void 0&&t.types.length>0;return!!(!n&&!r||n&&hie(e.features??[],t.caps)||r&&t.types.includes(e.type))}function Tk(e){return typeof e.location==`string`&&e.location.length>0?`${e.name} (${e.location})`:e.name}function gie(e){let t=[];return typeof e.location==`string`&&e.location.length>0&&t.push(e.location),t.push(e.type),typeof e.parentName==`string`&&e.parentName.length>0&&t.push(`in ${e.parentName}`),t.join(` · `)}function Ek(e,t){return e.filter(e=>wk(e,t)).map(e=>({value:String(e.id),label:Tk(e),description:gie(e),location:typeof e.location==`string`&&e.location.length>0?e.location:null})).toSorted((e,t)=>e.label.localeCompare(t.label))}function _ie(e){let t=new Set,n=new Set;for(let r of e)typeof r.location==`string`&&r.location.length>0&&t.add(r.location),n.add(r.type);return{locations:[...t].toSorted((e,t)=>e.localeCompare(t)),types:[...n].toSorted((e,t)=>e.localeCompare(t))}}var vie={locations:[],types:[]};function yie(e,t){return!(t.locations.length>0&&(typeof e.location!=`string`||!t.locations.includes(e.location))||t.types.length>0&&!t.types.includes(e.type))}function Dk(e,t,n){return{suggested:e.filter(e=>t.has(n(e))),others:e.filter(e=>!t.has(n(e)))}}function Ok(e,t){return e.location===t}function bie(e,t){let n=io(t.map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name})),e.primaryChildEntityId,e.name);return n===null?null:n.id}function kk(e,t){if(t==null||t.length===0)return new Set;let n=new Map(e.map(e=>[e.id,e])),r=new Map;for(let t of e)t.parentDeviceId===null||t.parentDeviceId===void 0||r.set(t.parentDeviceId,[...r.get(t.parentDeviceId)??[],t]);let i=e=>e!==void 0&&e.type===J.Container,a=new Set,o=new Set;for(let r of e){if(i(r)){Ok(r,t)&&a.add(r.id);continue}if(!Ok(r,t))continue;let e=r.parentDeviceId===null||r.parentDeviceId===void 0?void 0:n.get(r.parentDeviceId);e!==void 0&&i(e)?a.add(e.id):o.add(r.id)}for(let e of a){let t=n.get(e);if(t===void 0)continue;let a=bie(t,r.get(e)??[]);a!==null&&!i(n.get(a))&&o.add(a)}return o}function Ak(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.value} ${e.label} ${e.description??``}`.toLowerCase();return n.every(e=>t.includes(e))})}function jk(e,t){let n=new Map(e.map(e=>[e.value,e]));return t.map(e=>n.get(e)??{value:e,label:e})}E();var xie=`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`,Sie=`flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30`,Mk=`block text-[11px] font-medium text-foreground mb-1 break-words`,Nk=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function Pk(e){return typeof e==`string`?e:null}function Fk(e){if(!Array.isArray(e))return[];let t=new Map;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;typeof e.id==`number`&&typeof e.name==`string`&&t.set(e.id,e.name)}let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r;if(typeof e.id!=`number`||typeof e.type!=`string`||typeof e.name!=`string`)continue;let i=typeof e.parentDeviceId==`number`?t.get(e.parentDeviceId)??null:null;n.push({id:e.id,type:e.type,name:e.name,location:typeof e.location==`string`?e.location:null,features:Array.isArray(e.features)?e.features.filter(e=>typeof e==`string`):[],parentName:i,stableId:typeof e.stableId==`string`?e.stableId:``,parentDeviceId:typeof e.parentDeviceId==`number`?e.parentDeviceId:null,primaryChildEntityId:Pk(e.primaryChildEntityId),role:Pk(e.role)})}return n}var Cie=`px-2.5 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,wie=`inline-flex max-w-full items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,Ik=`flex h-7 w-full items-center gap-2 px-2 text-left text-xs text-foreground hover:bg-surface-hover`;function Lk({label:e,values:t,chosen:n,onChange:r}){let i=q();if(t.length<2)return null;let a=n.length===0?i(`uiLibrary.deviceSelectField.all`,`All`):n.join(`, `),o=e=>{r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return c(bk,{children:[c(xk,{className:wie,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),v(`span`,{"aria-hidden":`true`,children:`·`}),v(`span`,{className:`truncate`,children:a}),v(de,{className:`h-3 w-3 shrink-0 text-foreground-subtle`})]}),c(Sk,{className:`max-h-56 overflow-y-auto`,children:[c(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n.length===0,className:Ik,onClick:()=>r([]),children:[v(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center rounded border border-border`,children:n.length===0&&v(dt,{className:`h-2.5 w-2.5`})}),i(`uiLibrary.deviceSelectField.all`,`All`)]}),t.map(e=>{let t=n.includes(e);return c(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":t,className:Ik,onClick:()=>o(e),children:[v(`span`,{className:[`inline-flex h-3.5 w-3.5 items-center justify-center rounded border`,t?`border-primary bg-primary text-white`:`border-border`].join(` `),children:t&&v(dt,{className:`h-2.5 w-2.5`})}),e]},e)})]})]})}function Tie({label:e,description:t,required:n,translationFn:r,children:i}){let a=Az(e,r),o=Az(t,r);return c(`div`,{className:`min-w-0`,children:[a!==void 0&&a!==``&&c(`label`,{className:Mk,children:[a,n&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),i,o&&v(`p`,{className:Nk,children:o})]})}function Rk({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{data:o}=dm({}),s=p(()=>Ek(Fk(o),e.deviceFilter),[o,e.deviceFilter]),l=t==null?``:String(t);return v(Tie,{label:e.label,description:e.description,required:e.required,translationFn:i,children:c(`select`,{className:xie,value:l,disabled:r||e.disabled,onChange:e=>n(e.target.value),children:[!e.required&&v(`option`,{value:``,children:a(`uiLibrary.deviceSelectField.select`,`— Select device —`)}),s.map(e=>v(`option`,{value:e.value,children:e.label},e.value))]})})}function zk({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{data:o}=dm({}),s=e.suggestLocation!==void 0,[l,u]=C(vie),d=p(()=>Fk(o),[o]),m=p(()=>_ie(d.filter(t=>t.id!==e.deviceFilter?.excludeDeviceId)),[d,e.deviceFilter?.excludeDeviceId]),h=p(()=>s?d.filter(e=>yie(e,l)):d,[d,l,s]),g=p(()=>Ek(h,e.deviceFilter),[h,e.deviceFilter]),_=Array.isArray(t)?t.map(String):[],y=r===!0||e.disabled===!0,b=e.maxItems!==void 0&&_.length>=e.maxItems,[x,S]=C(``),[w,T]=C(!1),[E,D]=C(0),O=f(null),k=f(null),A=p(()=>jk(g,_),[g,_]),j=p(()=>Ak(g,x),[g,x]),M=p(()=>kk(d,s?e.suggestLocation:null),[d,s,e.suggestLocation]),N=p(()=>Dk(j,M,e=>Number(e.value)),[j,M]),P=p(()=>[...N.suggested,...N.others],[N]),F=t=>{if(!y)if(_.includes(t))n(_.filter(e=>e!==t));else{if(e.maxItems!==void 0&&_.length>=e.maxItems)return;n([..._,t])}},I=e=>{if(e.key===`ArrowDown`)e.preventDefault(),T(!0),D(e=>P.length===0?0:(e+1)%P.length);else if(e.key===`ArrowUp`)e.preventDefault(),T(!0),D(e=>P.length===0?0:(e-1+P.length)%P.length);else if(e.key===`Enter`){e.preventDefault();let t=P[E];t&&F(t.value)}else e.key===`Escape`?T(!1):e.key===`Backspace`&&x===``&&_.length>0&&n(_.slice(0,-1))},L=Az(e.label,i),R=Az(e.description,i);return c(`div`,{className:`min-w-0`,children:[L!==void 0&&L!==``&&v(`label`,{className:Mk,children:L}),A.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:A.map(e=>c(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary max-w-full`,children:[v(`span`,{className:`truncate`,children:e.label}),!y&&v(`button`,{type:`button`,className:`shrink-0 hover:text-danger`,"aria-label":a(`uiLibrary.deviceSelectField.remove`,`Remove {{label}}`,{label:e.label}),onClick:()=>F(e.value),children:v(Zn,{className:`h-2.5 w-2.5`})})]},e.value))}),s&&c(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:[v(Lk,{label:a(`uiLibrary.deviceSelectField.location`,`Location`),values:m.locations,chosen:l.locations,onChange:e=>u(t=>({...t,locations:e}))}),v(Lk,{label:a(`uiLibrary.deviceSelectField.type`,`Type`),values:m.types,chosen:l.types,onChange:e=>u(t=>({...t,types:e}))})]}),c(`div`,{className:Sie+(y?` opacity-50`:``),children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:O,type:`text`,role:`combobox`,"aria-label":e.label,"aria-expanded":w,"aria-controls":`dsel-${e.key}`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,value:x,placeholder:b?a(`uiLibrary.deviceSelectField.max`,`Max {{count}} selected`,{count:e.maxItems}):e.placeholder??a(`uiLibrary.deviceSelectField.search`,`Search devices…`),disabled:y,onChange:e=>{S(e.target.value),T(!0),D(0)},onFocus:()=>T(!0),onBlur:()=>{k.current=setTimeout(()=>T(!1),120)},onKeyDown:I}),v(de,{className:`h-3.5 w-3.5 shrink-0 cursor-pointer text-foreground-subtle`,onMouseDown:e=>{e.preventDefault(),k.current&&clearTimeout(k.current),T(e=>!e),O.current?.focus()}})]}),w&&!y&&v(`div`,{id:`dsel-${e.key}`,role:`listbox`,className:`mt-1 max-h-56 overflow-y-auto rounded-md border border-border bg-surface shadow-lg`,onMouseDown:e=>{e.preventDefault()},children:P.length===0?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle italic`,children:g.length===0?a(`uiLibrary.deviceSelectField.noDevices`,`No matching devices`):a(`uiLibrary.deviceSelectField.noMatches`,`No matches for “{{query}}”`,{query:x})}):P.map((t,n)=>{let r=_.includes(t.value),i=!r&&b,a=N.suggested.length,o=s?n===0&&a>0?`Suggested · ${e.suggestLocation??``}`:n===a&&a>0?`Other devices`:null:null;return c(`div`,{children:[o!==null&&v(`div`,{className:Cie,children:o}),c(`button`,{type:`button`,role:`option`,"aria-selected":r,disabled:i,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,n===E?`bg-primary/10`:`hover:bg-surface-hover`,i?`opacity-40 cursor-not-allowed`:`cursor-pointer`].join(` `),onMouseEnter:()=>D(n),onClick:()=>F(t.value),children:[v(`span`,{className:[`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,r?`border-primary bg-primary text-white`:`border-border`].join(` `),children:r&&v(dt,{className:`h-2.5 w-2.5`})}),c(`span`,{className:`min-w-0 flex-1`,children:[v(`span`,{className:`block truncate text-foreground`,children:t.label}),t.description!==void 0&&v(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:t.description})]})]})]},t.value)})}),R&&v(`p`,{className:Nk,children:R})]})}E();var Eie=Il(`inline-flex items-center rounded-full font-medium [&>svg]:shrink-0 [&>svg]:size-3`,{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`,primary:`bg-primary/15 text-primary`,neutral:`bg-surface-hover text-foreground-muted`},styleVariant:{solid:``,fill:``,outline:`border bg-transparent`},size:{sm:`text-[10px] leading-4 px-1.5 py-0`,md:`text-xs px-2 py-0.5`},hasIcon:{true:`gap-1`,false:``},dashed:{true:`border-dashed`,false:``}},compoundVariants:[{variant:`default`,styleVariant:`fill`,class:`bg-neutral-fill text-neutral-on`},{variant:`neutral`,styleVariant:`fill`,class:`bg-neutral-fill text-neutral-on`},{variant:`success`,styleVariant:`fill`,class:`bg-success-fill text-success-on`},{variant:`warning`,styleVariant:`fill`,class:`bg-warning-fill text-warning-on`},{variant:`danger`,styleVariant:`fill`,class:`bg-danger-fill text-danger-on`},{variant:`info`,styleVariant:`fill`,class:`bg-info-fill text-info-on`},{variant:`primary`,styleVariant:`fill`,class:`bg-primary-fill text-primary-on`}],defaultVariants:{variant:`default`,styleVariant:`solid`,size:`md`,hasIcon:!1,dashed:!1}}),Bk=D(({className:e,variant:t,style:n,size:r,icon:i,dashed:a,children:o,...s},l)=>c(`span`,{ref:l,className:$(Eie({variant:t,styleVariant:n,size:r,hasIcon:i!=null,dashed:a===!0&&n===`outline`}),e),...s,children:[i,o]}));Bk.displayName=`Badge`,E();var Vk={motion:ai,audio:mt,person:it,vehicle:tt,animal:Me,package:Xt,sensor:fe,control:zr,car:tt,truck:kt,bus:xe,motorcycle:je,bicycle:je,airplane:Qe,boat:Mt,train:tee,bird:Wt,cat:U,dog:B,horse:Me,sheep:Me,cow:Me,elephant:Me,bear:Me,zebra:Me,giraffe:Me,door:pn,pir:gr,smoke:K,water:cn,gas:Fi,vibration:vr,tamper:Dr,presence:lt,generic:rn,lock:Cr,siren:Sr,switch:ke,doorbell:Yt,button:Si,"audio-speech":ni,"audio-scream":wn,"audio-crying":xt,"audio-laughter":pee,"audio-music":Yr,"audio-dog":B,"audio-cat":U,"audio-bird":Wt,"audio-animal":Me,"audio-alarm":Yt,"audio-doorbell":Yt,"audio-glass_breaking":zi,"audio-gunshot":fi,"audio-vehicle":tt,"audio-siren":Sr,"audio-fire":K,"audio-water":Ue,"audio-wind":Fi,"audio-door":pn,"audio-footsteps":$e,"audio-crowd":pr,"audio-telephone":re,"audio-engine":ar,"audio-tools":W,"audio-silence":me};function Hk(e){return Object.hasOwn(Vk,e)?Vk[e]:e.startsWith(`audio-`)?mt:rn}function Uk(e,t){if(t===void 0)return e.label;let n=t(e.labelKey);return n===e.labelKey||n.length===0?e.label:n}function Wk({iconId:e,size:t=16,color:n,className:r}){return s(Hk(e),{size:t,color:n,className:r})}var Gk=`flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30`;function Kk({label:e,onRemove:t,warning:n=!1,iconId:r,iconUrl:i,testId:a}){let o=q();return c(`span`,{"data-testid":a,className:n?`inline-flex items-center gap-1 rounded-md bg-warning/10 px-1.5 py-0.5 text-[11px] text-warning max-w-full`:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary max-w-full`,children:[i===void 0?r===void 0?null:v(Wk,{iconId:r,size:12}):v(`img`,{src:i,alt:``,className:`h-3 w-3 shrink-0 rounded-sm object-contain`}),v(`span`,{className:`truncate`,children:e}),t!==void 0&&v(`button`,{type:`button`,className:`shrink-0 hover:text-danger`,"aria-label":o(`uiLibrary.selectedChip.remove`,`Remove {{label}}`,{label:e}),onClick:t,children:v(Zn,{className:`h-2.5 w-2.5`})})]})}function qk(e){return[e.value,e.label,e.description].filter(e=>typeof e==`string`&&e.length>0).join(` `).toLowerCase()}function Jk(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>{let t=qk(e);return n.every(e=>t.includes(e))})}function Yk(e,t){let n=new Map(e.map(e=>[e.value,e])),r=new Set(t);return{selectedOptions:t.map(e=>n.get(e)??{value:e,label:e}),unselected:e.filter(e=>!r.has(e.value))}}function Xk(e,t,n){return n===void 0?e>=8||t:n}function Zk(e){let t=e.trim();return t.length>0?t:null}function Qk(e,t){let n=t.toLowerCase();return e.some(e=>e.value.toLowerCase()===n||e.label.toLowerCase()===n)}function $k(e,t){return e&&t}function eA(e,t,n){if(!e)return!1;let r=Zk(t);return r===null?!1:!Qk(n,r)}E(),Do();var tA=4,nA=224,rA=8,Die=`block text-[11px] font-medium text-foreground mb-1 break-words`,Oie=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function kie({opt:e}){return e.iconUrl===void 0?e.iconId===void 0?null:v(Wk,{iconId:e.iconId,size:13}):v(`img`,{src:e.iconUrl,alt:``,className:`h-3.5 w-3.5 shrink-0 rounded-sm object-contain`})}function iA(e){let t=q(),{mode:n,options:r,placeholder:i=`Select…`,disabled:a=!1,emptyMessage:o=`No options available.`,creatable:s=!1,createLabel:l=`Add new…`,onCreateRequest:m,label:h,description:g,testId:_,optionTestIdPrefix:y,listboxId:x}=e,S=a,w=Xk(r.length,s,e.searchable),T=x??_??`option-select-listbox`,E=n===`single`?e.value.length>0?[e.value]:[]:e.value,D=n===`multi`?e.maxItems:void 0,O=n===`multi`&&D!==void 0&&E.length>=D,[k,A]=C(``),[j,M]=C(!1),[N,F]=C(0),[I,L]=C(null),R=f(null),z=f(null),B=f(null),V=f(null),H=()=>{let e=z.current;if(e===null)return null;let t=e.getBoundingClientRect(),n=window.innerHeight-t.bottom-rA,r=t.top-rA,i=n>=Math.min(nA,r)||n>=120,a=Math.max(96,Math.min(nA,i?n:r)),o=Math.max(rA,Math.min(t.left,window.innerWidth-t.width-rA));return i?{top:t.bottom+tA,left:o,width:t.width,maxHeight:a,placement:`below`}:{top:Math.max(rA,t.top-tA-a),left:o,width:t.width,maxHeight:a,placement:`above`}},{selectedOptions:U}=p(()=>Yk(r,E),[r,E]),ee=p(()=>Jk(r,k),[r,k]),W=eA(s,k,r),G=$k(s,m!==void 0),te=p(()=>{let e=ee.map((e,t)=>({kind:`option`,opt:e,index:t}));if(W){let t=Zk(k);t!==null&&e.push({kind:`use-query`,draft:t})}return e},[ee,W,k]);u(()=>{if(!j||S){L(null);return}let e=()=>{L(H())};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[j,S,E.length,k,te.length]),b(()=>{if(!j)return;let e=e=>{let t=e.target;B.current?.contains(t)||z.current?.contains(t)||M(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[j]);let ne=t=>{let r=t.trim();if(r.length!==0){if(m!==void 0){m(r),A(``),M(!1);return}if(n===`single`){e.onChange(r),A(``),M(!1);return}e.value.includes(r)||D!==void 0&&e.value.length>=D||(e.onChange([...e.value,r]),A(``))}},re=t=>{if(!(n!==`multi`||S))if(e.value.includes(t))e.onChange(e.value.filter(e=>e!==t));else{if(D!==void 0&&e.value.length>=D)return;e.onChange([...e.value,t])}},K=t=>{n!==`single`||S||(e.onChange(t),A(``),M(!1))},ie=e=>{if(e.kind===`option`){if(e.opt.disabled===!0)return;n===`single`?K(e.opt.value):re(e.opt.value)}else e.kind===`use-query`&&ne(e.draft)},ae=te.length+(G&&!W?1:0),oe=t=>{if(t.key===`ArrowDown`)t.preventDefault(),M(!0),F(e=>ae===0?0:(e+1)%ae);else if(t.key===`ArrowUp`)t.preventDefault(),M(!0),F(e=>ae===0?0:(e-1+ae)%ae);else if(t.key===`Enter`){if(t.preventDefault(),W&&N===te.length){let e=Zk(k);e!==null&&ne(e);return}if(G&&!W&&N===te.length){R.current?.focus();return}let e=te[N];if(e)ie(e);else if(s){let e=Zk(k);e!==null&&ne(e)}}else t.key===`Escape`?M(!1):t.key===`Backspace`&&k===``&&n===`multi`&&e.value.length>0&&e.onChange(e.value.slice(0,-1))},se=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),M(e=>!e)):e.key===`Escape`&&M(!1)},ce=t=>{n===`single`?e.onChange(``):e.onChange(e.value.filter(e=>e!==t))},le=O===!0?`Max ${D} selected`:i,ue=r.length===0&&!W&&te.length===0&&j,fe;fe=ue?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle`,children:o}):te.length===0&&!s?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.optionSelect.noMatches`,`No matches for “{{query}}”`,{query:k})}):v(P,{children:te.map((r,i)=>{if(r.kind===`use-query`)return c(`button`,{type:`button`,role:`option`,"aria-selected":!1,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,i===N?`bg-primary/10`:`hover:bg-surface-hover`,`cursor-pointer`].join(` `),onMouseEnter:()=>F(i),onClick:()=>ne(r.draft),children:[v(Se,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),v(`span`,{className:`truncate text-foreground`,children:t(`uiLibrary.optionSelect.use`,`Use “{{value}}”`,{value:r.draft})})]},`__use-query__`);if(r.kind!==`option`)return null;let{opt:a}=r,o=n===`single`?e.value===a.value:e.value.includes(a.value),s=n===`multi`&&!o&&O===!0,l=a.disabled===!0||s,u=te[i-1],f=u!==void 0&&u.kind===`option`?u.opt.group:void 0;return c(d,{children:[a.group!==void 0&&a.group!==f?v(`div`,{role:`presentation`,className:`px-2.5 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:a.group}):null,c(`button`,{type:`button`,role:`option`,"aria-selected":o,disabled:l,"data-testid":y===void 0?void 0:`${y}-${a.value}`,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,i===N?`bg-primary/10`:`hover:bg-surface-hover`,l?`opacity-40 cursor-not-allowed`:`cursor-pointer`].join(` `),onMouseEnter:()=>F(i),onClick:()=>ie(r),children:[v(`span`,{className:[`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,o?`border-primary bg-primary text-white`:`border-border`].join(` `),children:o&&v(dt,{className:`h-2.5 w-2.5`})}),v(kie,{opt:a}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:a.label}),a.badge!==void 0&&a.badge.length>0?v(Bk,{variant:`default`,children:a.badge}):null]})]},a.value)})});let pe=te.length,me=n===`single`&&e.singleDisplay===`field`&&U.length>0;return c(`div`,{className:`min-w-0 space-y-1`,"data-testid":_,children:[h!==void 0&&h.length>0&&v(`label`,{className:Die,children:h}),n===`multi`&&U.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:U.map(e=>v(Kk,{label:e.label,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},...e.iconId===void 0?{}:{iconId:e.iconId},...S?{}:{onRemove:()=>ce(e.value)},...y===void 0?{}:{testId:`${y}-chip-${e.value}`}},e.value))}),n===`single`&&e.singleDisplay!==`field`&&U.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:U.map(e=>v(Kk,{label:e.label,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},...e.iconId===void 0?{}:{iconId:e.iconId},...S?{}:{onRemove:()=>ce(e.value)}},e.value))}),w?c(`div`,{ref:e=>{z.current=e},className:Gk+(S?` opacity-50`:``),children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:R,type:`text`,role:`combobox`,"aria-expanded":j,"aria-controls":T,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,value:me&&!j&&k===``?U[0]?.label??``:k,placeholder:me?U[0]?.label??``:le,disabled:S,onChange:e=>{A(e.target.value),M(!0),F(0)},onFocus:()=>M(!0),onBlur:()=>{V.current=setTimeout(()=>{let e=document.activeElement;B.current?.contains(e)||M(!1)},120)},onKeyDown:oe}),v(de,{className:`h-3.5 w-3.5 shrink-0 cursor-pointer text-foreground-subtle`,onMouseDown:e=>{e.preventDefault(),V.current&&clearTimeout(V.current),M(e=>!e),R.current?.focus()}})]}):c(`button`,{ref:e=>{z.current=e},type:`button`,role:`combobox`,"aria-expanded":j,"aria-controls":T,disabled:S,className:[Gk,`w-full justify-between text-xs text-foreground`,S?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),onClick:()=>!S&&M(e=>!e),onKeyDown:se,children:[v(`span`,{className:`truncate text-foreground-subtle`,children:U[0]?.label??le}),v(de,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})]}),j&&!S&&I!==null&&typeof document<`u`&&Oo(c(`div`,{ref:B,id:T,role:`listbox`,style:{position:`fixed`,top:I.top,left:I.left,width:I.width,maxHeight:I.maxHeight,zIndex:9999},className:`overflow-y-auto rounded-md border border-border bg-surface shadow-lg`,onMouseDown:e=>{e.preventDefault(),V.current&&clearTimeout(V.current)},children:[fe,G&&c(`button`,{type:`button`,className:[`flex w-full items-center gap-2 border-t border-border px-2.5 py-1.5 text-left text-xs transition-colors`,pe===N?`bg-primary/10`:`hover:bg-surface-hover`,`cursor-pointer text-primary`].join(` `),onMouseEnter:()=>F(pe),onClick:()=>{let e=Zk(k);if(e!==null){m?.(e),A(``),M(!1);return}R.current?.focus()},children:[v(Se,{className:`h-3.5 w-3.5 shrink-0`}),l]})]}),document.body),g!==void 0&&g.length>0&&v(`p`,{className:Oie,children:g})]})}function aA(e,t){return`${e}:${t}`}function oA(e,t,n,r){return e.map(e=>{let i=e.addonId!==void 0&&e.kind!==void 0?t.get(aA(e.addonId,e.kind)):void 0,a;return n?.has(e.id)===!0?a=r:e.enabled||(a=`disabled`),{value:e.id,label:e.name,...i===void 0?{}:{iconUrl:i},...a===void 0?{}:{badge:a}}})}function sA(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`kind`),r=Reflect.get(n,`addonId`),i=Reflect.get(n,`iconUrl`);typeof e!=`string`||typeof r!=`string`||typeof i==`string`&&i.length>0&&t.set(aA(r,e),i)}return t}function cA(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`name`),i=Reflect.get(n,`enabled`),a=Reflect.get(n,`kind`),o=Reflect.get(n,`addonId`);typeof e!=`string`||typeof r!=`string`||typeof a!=`string`||typeof o!=`string`||t.push({id:e,name:r,enabled:i===!0,kind:a,addonId:o})}return t}E();function lA({targets:e,value:t,onChange:n,disabled:r=!1,maxItems:i,testIdPrefix:a=`notification-target`,emptyMessage:o,noteIds:s,noteLabel:c,label:l,description:u,kindIconUrls:d}){let f=q(),m=Kv({}),h=p(()=>sA(m.data),[m.data]),g=d??h,_=o??f(`uiLibrary.notificationTargetsField.defaultEmpty`,`No delivery target is configured. Add one on the Targets tab first — without one the notification is rendered and thrown away.`),y=c??f(`uiLibrary.notificationTargetsField.note`,`note`);return v(iA,{mode:`multi`,options:p(()=>oA(e,g,s,y),[e,g,s,y]),value:t,onChange:n,disabled:r,searchable:!0,creatable:!1,...i===void 0?{}:{maxItems:i},emptyMessage:_,placeholder:f(`uiLibrary.notificationTargetsField.searchTargets`,`Search targets…`),label:l,description:u,testId:`${a}s`,optionTestIdPrefix:a,listboxId:`${a}-listbox`})}function uA({targets:e,value:t,onChange:n,disabled:r=!1,emptyMessage:i,placeholder:a,testId:o=`notification-target-select`,label:s,description:c,kindIconUrls:l}){let u=q(),d=Kv({}),f=p(()=>sA(d.data),[d.data]),m=l??f,h=i??u(`uiLibrary.notificationTargetsField.defaultEmpty`,`No delivery target is configured. Add one on the Targets tab first — without one the notification is rendered and thrown away.`),g=a??u(`uiLibrary.notificationTargetsField.select`,`Select…`),_=u(`uiLibrary.notificationTargetsField.note`,`note`);return v(iA,{mode:`single`,options:p(()=>oA(e,m,void 0,_),[e,m,_]),value:t,onChange:n,disabled:r,searchable:!0,creatable:!1,emptyMessage:h,placeholder:g,label:s,description:c,testId:o,optionTestIdPrefix:o,listboxId:`${o}-listbox`})}function dA({label:e,description:t,required:n,translationFn:r,children:i}){return c(`div`,{className:`space-y-1`,children:[c(`label`,{className:`block text-[11px] font-medium text-foreground mb-1 break-words`,children:[Az(e,r),n===!0?v(`span`,{className:`text-danger`,children:` *`}):null]}),i,t!==void 0&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 break-words`,children:Az(t,r)})]})}function fA({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=qv({}),s=Kv({}),c=p(()=>cA(o.data),[o.data]),l=p(()=>sA(s.data),[s.data]),u=Array.isArray(t)?t.filter(e=>typeof e==`string`):typeof t==`string`&&t.length>0?t.includes(`,`)?t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0):[t]:[],d=o.isPending||s.isPending,f=o.isError?o.error:s.isError?s.error:null;return d?v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.notificationTargetsField.loading`,`Loading targets…`)})}):f===null?v(lA,{targets:c,value:u,onChange:e=>n(e),disabled:r===!0||e.disabled===!0,...e.maxItems===void 0?{}:{maxItems:e.maxItems},kindIconUrls:l,label:Az(e.label,i),description:e.description===void 0?void 0:Az(e.description,i),emptyMessage:a(`uiLibrary.notificationTargetsField.noneConfigured`,`No delivery target is configured. Add one under Notification Center → Targets first.`),testIdPrefix:`config-target-${e.key}`}):v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-danger`,children:a(`uiLibrary.notificationTargetsField.loadError`,`Could not load targets: {{message}}`,{message:f instanceof Error?f.message:String(f)})})})}function pA({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=qv({}),s=Kv({}),c=p(()=>cA(o.data),[o.data]),l=p(()=>sA(s.data),[s.data]),u=typeof t==`string`?t:``,d=o.isPending||s.isPending,f=o.isError?o.error:s.isError?s.error:null;return d?v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.notificationTargetsField.loading`,`Loading targets…`)})}):f===null?v(uA,{targets:c,value:u,onChange:e=>n(e),disabled:r===!0||e.disabled===!0,kindIconUrls:l,label:Az(e.label,i),description:e.description===void 0?void 0:Az(e.description,i),emptyMessage:a(`uiLibrary.notificationTargetsField.noneConfigured`,`No delivery target is configured. Add one under Notification Center → Targets first.`),testId:`config-target-${e.key}`}):v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-danger`,children:a(`uiLibrary.notificationTargetsField.loadError`,`Could not load targets: {{message}}`,{message:f instanceof Error?f.message:String(f)})})})}E();var mA=Kn(`camstack:custom-field-renderers`,{});function hA({renderers:e,children:t}){return v(mA.Provider,{value:e,children:t})}function gA(e){return I(mA)[e]??null}E();var Aie=Il(`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 text-foreground 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`}}),_A=D(({className:e,variant:t,size:n,...r},i)=>v(`button`,{ref:i,className:$(Aie({variant:t,size:n}),e),...r}));_A.displayName=`Button`,E();var jie=`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`,Mie=2e3,Nie=/^[A-Za-z0-9._~-]{8,}$/;function vA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yA(e){return typeof e==`string`?e.trim().length>0:!!(ha(e)||Ja(e))}function Pie(e){return typeof e==`string`&&e.trim().length>0?e.trim():``}function bA(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return e.length;if(typeof e==`string`&&e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.length}catch{return null}return null}function Fie(e,t){return e===1?t:`${t}s`}function Iie(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)!vA(n)||typeof n.value!=`string`||typeof n.label!=`string`||t.push({value:n.value,label:n.label,...typeof n.brand==`string`?{brand:n.brand}:{},...typeof n.region==`string`?{region:n.region}:{}});return t}function Lie(e){return typeof e==`string`?e:``}function Rie(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function zie(e){let t=e.trim();return t.length===0?!1:t.includes(`code=`)||t.includes(`://`)||t.includes(`error=`)?!0:Nie.test(t)}function Bie({field:e,values:t,disabled:n,onAction:r,onChangeMany:i}){let a=q(),[o,s]=C(`idle`),[l,u]=C(null),[d,p]=C(null),[m,h]=C(``),[g,_]=C(null),[y,x]=C(!1),[S,w]=C([]),T=f(!1),E=Pie(t[e.accountKey]),D=e.secretKeys.some(e=>yA(t[e])),O=E.length>0||D,k=(e.countKey===void 0?null:bA(t[e.countKey]))??(e.countFromKey===void 0?null:bA(t[e.countFromKey])),A=o===`pasting`||!O&&l!==null,j=t=>{let n={};for(let[r,i]of Object.entries(e.assignResult??{})){let e=t[i];(typeof e==`string`||typeof e==`number`)&&(n[r]=e)}Object.keys(n).length>0&&i?.(n);let r=Iie(t.choices);w(r.length>1?r:[]);let a=typeof t.gatewayId==`string`&&t.gatewayId.length>0,o=typeof t.summary==`string`?t.summary:null;o!==null&&!a&&r.length<2&&_(o),s(`idle`),h(``),u(null),p(null)},M=e.claimAction;b(()=>{if(M===void 0||l===null||o!==`pasting`||!r)return;let t=!1,n=setInterval(()=>{T.current||r(M,e.key,{attemptId:l}).then(e=>{t||!vA(e)||e.pending===!0||(t=!0,j(e))}).catch(e=>{t||(t=!0,_(e instanceof Error?e.message:String(e)))})},Mie);return()=>{t=!0,clearInterval(n)}},[M,l,o,r,e.key]);let N=async()=>{if(!(!r||y)){x(!0),_(null);try{let t=await r(e.beginAction,e.key,{});if(!vA(t)||typeof t.authorizeUrl!=`string`||typeof t.attemptId!=`string`){_(a(`uiLibrary.accountSignIn.noLink`,`The sign-in page could not be opened. Try again.`));return}if(`verifier`in t||`state`in t){_(a(`uiLibrary.accountSignIn.noLink`,`The sign-in page could not be opened. Try again.`));return}u(t.attemptId),p(t.authorizeUrl),s(`pasting`),window.open(Rie(t.authorizeUrl),`_blank`,`noopener,noreferrer`)}catch(e){_(e instanceof Error?e.message:String(e))}finally{x(!1)}}},P=async t=>{if(!(!r||l===null||T.current)){T.current=!0,x(!0),_(null);try{let n=await r(e.completeAction,e.key,{attemptId:l,callback:t});if(!vA(n)){_(a(`uiLibrary.accountSignIn.rejected`,`The sign-in was not accepted. Start again.`));return}j(n)}catch(e){_(e instanceof Error?e.message:String(e))}finally{T.current=!1,x(!1)}}},F=async()=>{if(!(!r||y)){x(!0),_(null);try{await r(e.signOutAction,e.key,{});let t={[e.accountKey]:``};e.countKey!==void 0&&(t[e.countKey]=0),e.choiceKey!==void 0&&(t[e.choiceKey]=``),e.countFromKey!==void 0&&(t[e.countFromKey]=[]);for(let n of e.secretKeys)t[n]=qi;i?.(t),w([]),s(`idle`),u(null),h(``)}catch(e){_(e instanceof Error?e.message:String(e))}finally{x(!1)}}},I=t=>{let n=S.find(e=>e.value===t);if(n===void 0||e.choiceKey===void 0)return;let r={[e.choiceKey]:n.value};n.brand!==void 0&&(r.brand=n.brand),n.region!==void 0&&(r.region=n.region),i?.(r)},L=E.length>0?E:a(`uiLibrary.accountSignIn.yourAccount`,`your account`),R=k===null?a(`uiLibrary.accountSignIn.signedIn`,`Signed in as {{account}}`,{account:L}):a(`uiLibrary.accountSignIn.signedInCount`,`Signed in as {{account}} · {{detail}}`,{account:L,detail:e.countNoun===void 0?String(k):`${k} ${Fie(k,e.countNoun)}`});return c(`div`,{className:`col-span-1 flex min-w-0 flex-col gap-2`,children:[O&&o===`idle`?c(`div`,{className:`flex flex-col gap-2`,children:[v(`p`,{className:`text-xs text-foreground`,children:R}),S.length>1&&e.choiceKey!==void 0&&v(Yl,{"aria-label":e.choiceLabel??a(`uiLibrary.accountSignIn.choose`,`Choose`),options:S.map(e=>({value:e.value,label:e.label})),value:Lie(t[e.choiceKey]),onChange:e=>I(e.target.value),disabled:n||y}),c(`div`,{className:`flex flex-wrap gap-2`,children:[v(_A,{type:`button`,variant:`outline`,size:`sm`,disabled:n||y,onClick:()=>void N(),children:a(`uiLibrary.accountSignIn.again`,`Sign in again`)}),v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:n||y,onClick:()=>void F(),children:a(`uiLibrary.accountSignIn.signOut`,`Sign out`)})]})]}):v(_A,{type:`button`,variant:`primary`,size:`sm`,disabled:n||y,onClick:()=>void N(),children:y&&o!==`pasting`?a(`uiLibrary.accountSignIn.working`,`Working…`):a(`uiLibrary.accountSignIn.signInWith`,`Sign in with {{provider}}`,{provider:e.providerLabel})}),A&&c(`div`,{className:`flex flex-col gap-1.5`,children:[d!==null&&v(`a`,{className:`text-[11px] text-primary break-all`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:a(`uiLibrary.accountSignIn.open`,`Open the sign-in page`)}),M!==void 0&&v(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`uiLibrary.accountSignIn.pasteFallback`,`If the page does not finish, paste the address it stops on here.`)}),v(`textarea`,{className:`${jie} min-h-[60px] resize-y`,"aria-label":a(`uiLibrary.accountSignIn.paste`,`Redirect address or code`),placeholder:e.pastePlaceholder,value:m,disabled:n||y,onChange:e=>{let t=e.target.value;h(t),zie(t)&&P(t)}})]}),g!==null&&v(`p`,{className:`text-[11px] text-danger`,children:g})]})}function Vie({field:e,values:t}){return v(`p`,{className:`col-span-1 text-xs text-foreground`,children:yA(t[e.sourceKey])?e.yesLabel:e.noLabel})}E();var xA=Kn(`camstack:device-context`,null);function SA({deviceId:e,device:t,children:n}){let r={deviceId:e,device:t??null};return v(xA.Provider,{value:r,children:n})}function CA(){return I(xA)?.deviceId??null}function wA(){return I(xA)?.device??null}E(),Do();function TA(e){let t=(typeof globalThis<`u`?globalThis:void 0)?.[e];return t&&typeof t==`object`?t:{}}var EA={singleton:!0,requiredVersion:!1},DA=e=>({version:`0.0.0`,scope:`default`,lib:e,shareConfig:EA}),OA=`__mf_module_cache__`;function kA(){let e=globalThis,t=e[OA];if(t&&typeof t==`object`){let e=t;return e.share??={},e.remote??={},e}let n={share:{},remote:{}};return e[OA]=n,n}function Hie(){let e=kA();e.share.react??=o,e.share[`react-dom`]??=Eo,e.share[`react-dom/client`]??=ko,e.share[`react/jsx-runtime`]??=N,e.share[`@tanstack/react-query`]??=F,e.share[`@trpc/client`]??=xo,e.share[`@trpc/react-query`]??=wo,e.share[`@camstack/ui-library`]??=TA(`__camstackUiLibrary`),e.share[`@camstack/sdk`]??=TA(`__camstackSdk`),e.share[`@camstack/types`]??=TA(`__camstackTypes`)}var AA=e=>({version:`0.0.0`,scope:`default`,get:()=>e().then(e=>()=>e),shareConfig:EA});function Uie(){let e=kA();a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js`).then(e=>e.l).then(t=>{e.share[`react-konva`]??=t}),[],import.meta.url),a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__konva__loadShare__.js-B7XYY0cV.js`).then(e=>e.t).then(t=>{e.share.konva??=t}),[],import.meta.url)}function jA(){Hie(),i()===null&&(Uie(),n({name:`admin_ui_host`,remotes:[],shared:{react:DA(()=>o),"react-dom":DA(()=>Eo),"react-dom/client":DA(()=>ko),"react/jsx-runtime":DA(()=>N),"@tanstack/react-query":DA(()=>F),"@trpc/client":DA(()=>xo),"@trpc/react-query":DA(()=>wo),"react-konva":AA(()=>a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js`).then(e=>e.l),[],import.meta.url)),konva:AA(()=>a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__konva__loadShare__.js-B7XYY0cV.js`).then(e=>e.t),[],import.meta.url)),"@camstack/ui-library":DA(()=>TA(`__camstackUiLibrary`)),"@camstack/sdk":DA(()=>TA(`__camstackSdk`)),"@camstack/types":DA(()=>TA(`__camstackTypes`))}}))}E();var MA=Kn(`camstack:widget-registry`,null),NA=new Map,PA=new Map,FA=new Set;function IA(e,t){return`${e}::${t}`}function Wie(e){if(!e||typeof e!=`object`)return!1;let t=e.default;return typeof t==`object`&&!!t}function Gie(e){if(!e||typeof e!=`object`)return typeof e;let 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 LA(e,n,i){let a=IA(e,n),o=NA.get(a);if(o)return o;let s=PA.get(a);if(s)return s;FA.has(e)||(jA(),r([{name:e,entry:bt(i),type:`module`}],{force:!1}),FA.add(e));let c=t(`${e}/${n.startsWith(`./`)?n.slice(2):n}`).then(t=>{if(!Wie(t)){let r=Gie(t);throw Error(`Remote ${e} (${i}) does not expose a default record on '${n}'. Got: ${JSON.stringify(r)}`)}let r=t.default;return NA.set(a,r),PA.delete(a),r}).catch(e=>{throw PA.delete(a),e});return PA.set(a,c),c}function RA(e,t){return NA.get(IA(e,t))}var Kie=3e4,qie=2e3;function zA({children:e}){let t=k(),n=f(Date.now()),{data:r}=ld(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-n.current>=Kie?!1:qie}});Mo(`addon.widget-ready`,()=>{t.invalidateQueries({queryKey:[[`addonWidgets`,`listWidgets`]]})});let[i,a]=C(0),o=p(()=>r??[],[r]);b(()=>{if(o.length===0)return;let e=!1,t=new Set;for(let n of o){let r=IA(n.remote.remoteName,n.remote.exposedModule);if(t.has(r)||(t.add(r),NA.has(r)))continue;let i=n.bundleUrl;LA(n.remote.remoteName,n.remote.exposedModule,i).then(()=>{e||a(e=>e+1)}).catch(e=>{let t=e instanceof Error?e.message:String(e);(typeof globalThis<`u`?globalThis.console:void 0)?.error?.(`[WidgetRegistry] Failed to load widget remote`,{remoteName:n.remote.remoteName,exposedModule:n.remote.exposedModule,entryUrl:i,reason:t})})}return()=>{e=!0}},[o]);let s=p(()=>{let e=new Map,t=new Map;for(let n of o)e.set(`${n.addonId}/${n.stableId}`,n),t.set(n.remote.remoteName,n.bundleUrl);let n=(e,t)=>({widgetId:e,addonId:t.addonId,stableId:t.stableId,tab:t.tab,subTab:t.subTab,label:t.label,order:t.order,kind:t.kind,remote:t.remote,description:t.description,icon:t.icon,bundleUrl:t.bundleUrl,hosts:t.hosts,requires:t.requires,defaultSize:t.defaultSize,allowedSizes:t.allowedSizes,defaultColumns:t.defaultColumns,defaultRows:t.defaultRows});return{resolve:t=>{let n=e.get(t);if(!n)return;let r=RA(n.remote.remoteName,n.remote.exposedModule);if(!r)return null;let i=r[n.remote.componentKey??n.stableId];if(i)return i},metadata:t=>{let r=e.get(t);if(r)return n(t,r)},listAll:()=>{let t=[];for(let[r,i]of e)t.push(n(r,i));return t},entryUrlFor:e=>t.get(e)}},[o,i]);return v(MA.Provider,{value:s,children:e})}function Jie(e){return HA().resolve(e)}function BA(e){return HA().metadata(e)}function Yie(){return HA().listAll()}function VA(e,t){let n=UA(),r=t??n?.entryUrlFor(e.remoteName),[i,a]=C(0),[o,s]=C(!1);return b(()=>{if(!r||(s(!1),RA(e.remoteName,e.exposedModule)))return;let t=!1;return LA(e.remoteName,e.exposedModule,r).then(()=>{t||a(e=>e+1)}).catch(n=>{let i=n instanceof Error?n.message:String(n);(typeof globalThis<`u`?globalThis.console:void 0)?.error?.(`[WidgetRegistry] Failed to load remote component`,{remoteName:e.remoteName,exposedModule:e.exposedModule,entryUrl:r,reason:i}),t||s(!0)}),()=>{t=!0}},[e.remoteName,e.exposedModule,r]),p(()=>{if(!r||o)return;let t=RA(e.remoteName,e.exposedModule);if(!t)return null;let n=e.componentKey;return n===void 0?Object.values(t)[0]??void 0:t[n]??void 0},[e.remoteName,e.exposedModule,e.componentKey,r,i,o])}function HA(){let e=UA();if(!e)throw Error(`useWidgetRegistry(): no <WidgetRegistryProvider> in tree`);return e}function UA(){return Xie(MA)}function Xie(e){return I(e)}E();function WA(e){let t=k(),n=zw({deviceId:e??0},{enabled:e!==null&&Number.isFinite(e),refetchInterval:5e3,retry:1}),r=Bw({onSuccess:()=>{t.invalidateQueries({queryKey:[[`ptzAutotrack`]]})}}),i=Hw({onSuccess:()=>{t.invalidateQueries({queryKey:[[`ptzAutotrack`]]})}}),a=_(async t=>{e!==null&&await r.mutateAsync({deviceId:e,enabled:t})},[e,r]),o=_(async t=>{e!==null&&await i.mutateAsync({deviceId:e,settings:t})},[e,i]),s=n.error?n.error.message:r.error?r.error.message:i.error?i.error.message:null;return{status:n.data??null,isLoading:n.isLoading,isPending:r.isPending||i.isPending,error:s,setEnabled:a,setSettings:o}}E();function GA({deviceId:e}){let t=q(),{status:n,isLoading:r,isPending:i,error:a,setEnabled:o,setSettings:s}=WA(Number.isFinite(e)?e:null),[l,u]=C({targetType:``,stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=C(!1);b(()=>{if(d)return;let e=n?.currentSettings;e&&u({targetType:e.targetType,stopDelaySeconds:e.stopDelaySeconds,disappearDelaySeconds:e.disappearDelaySeconds})},[n,d]);let p=v(fi,{className:`h-3.5 w-3.5 text-foreground-subtle`});if(r&&!n)return v($t,{title:t(`uiLibrary.autotrack.title`,`Autotrack`),icon:p,children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),t(`uiLibrary.autotrack.loading`,`Loading autotrack…`)]})});let m=c(`button`,{type:`button`,onClick:()=>{o(!(n?.enabled??!1))},disabled:i,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${n?.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":n?.enabled??!1,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${n?.enabled?`bg-success`:`bg-foreground-subtle/40`}`}),n?.enabled?t(`uiLibrary.autotrack.enabled`,`Enabled`):t(`uiLibrary.autotrack.disabled`,`Disabled`)]});return c($t,{title:t(`uiLibrary.autotrack.title`,`Autotrack`),icon:p,headerRight:m,bodyClassName:`p-3 space-y-2`,children:[a&&c(`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:[v(Ai,{className:`h-3 w-3 flex-shrink-0 mt-0.5`}),v(`span`,{className:`leading-snug break-words`,children:a})]}),c(`div`,{className:`grid grid-cols-2 gap-2 px-2`,children:[(n?.supportedTargetTypes?.length??0)>0&&c(`label`,{className:`col-span-2 flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.targetType`,`Target type`)}),v(`select`,{value:l.targetType,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,targetType:e.target.value})),onBlur:()=>{f(!1);let e=n?.currentSettings?.targetType??``;l.targetType!==e&&s({targetType:l.targetType})},disabled:i,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:(n?.supportedTargetTypes??[]).map(e=>v(`option`,{value:e.value,children:e.label},e.value))})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.stopDelay`,`Stop delay (s)`)}),v(`input`,{type:`number`,min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,stopDelaySeconds:Number(e.target.value)||0})),onBlur:()=>{f(!1);let e=n?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==e&&s({stopDelaySeconds:l.stopDelaySeconds})},disabled:i,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`})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.disappearDelay`,`Disappear delay (s)`)}),v(`input`,{type:`number`,min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,disappearDelaySeconds:Number(e.target.value)||0})),onBlur:()=>{f(!1);let e=n?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==e&&s({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:i,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`})]})]}),v(`p`,{className:`px-2 text-[9.5px] text-foreground-subtle leading-snug italic`,children:t(`uiLibrary.autotrack.note`,`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).`)})]})}E();var KA=O(null);function qA(){return I(KA)}function Zie(e){let t=e.display?.label,n=t==null?``:t.trim();return{id:e.id,name:e.name,type:e.type,stableId:e.stableId,role:e.role??null,parentDeviceId:e.parentDeviceId??null,location:e.location??null,...n.length>0?{display:{label:n}}:{},...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.userNamed===void 0?{}:{userNamed:e.userNamed}}}function JA(e){let t=new Map,n=new Map;for(let r of e){let e=Zie(r);t.set(e.id,e);let i=e.parentDeviceId;if(i==null||i===e.id)continue;let a=n.get(i);a===void 0?n.set(i,[e.id]):a.push(e.id)}return{byId:t,childIds:n}}function YA({devices:e,children:t}){let n=p(()=>e===null?null:JA(e),[e]);return v(KA.Provider,{value:n,children:t})}function XA({children:e}){let t=dm({projection:`slim`});return v(YA,{devices:t.data===void 0?null:t.data,children:e})}var ZA=` · `,Qie=[`compact`,`full`,`nested`,`with-location`],$ie=[` — `,` `],eae=new Set([`battery-sensor`,`temperature-sensor`,`humidity-sensor`,`ambient-light-sensor`,`connectivity-sensor`,`datetime-sensor`,`numeric-sensor`,`enum-sensor`]);function QA(e){return e.toLowerCase().replace(/[-_\s]+/g,` `).trim()}function $A(e,t){return QA(e)===QA(t)}function ej(e,t){if(t.length===0)return e;let n=e.toLowerCase(),r=t.toLowerCase();for(let t of $ie){let i=`${r}${t}`;if(n.startsWith(i))return e.slice(i.length).trim()}return e}function tj(e){let t=e.role;return t==null||t.length===0?null:t}function tae(e){if(e.type===`update`)return!0;let t=tj(e);return t!==null&&eae.has(t)}function nj(e){let t=e.display?.label;return t==null?``:t.trim()}function rj(e,t,n){let r=nj(e);if(r.length>0)return r;let i=ej(e.name,t.name),a=i.length>0?i:e.name;return e.userNamed===!0?a:i.length===0||$A(i,t.name)||n.isStockPhrase(a,tj(e),e.type)?n.shortNoun(tj(e),e.type):a}function nae(e,t,n){return $A(n,t.name)?!0:nj(e).length>0||e.userNamed===!0?!1:$A(ej(e.name,t.name),t.name)}function rae(e){let t=0;for(let n of e)tae(n)||(t+=1);return t}function iae(e,t,n){let r=io(n.map(e=>{let t=tj(e);return{id:e.id,stableId:e.stableId,type:e.type,name:e.name,...t===null?{}:{role:t}}}),t.primaryChildEntityId,t.name);return r!==null&&r.id===e.id}function aae(e,t,n,r,i){let a=rj(e,t,r);return nae(e,t,a)||i===`compact`&&t.type===`container`&&iae(e,t,n)&&rae(n)===1?t.name:`${t.name}${ZA}${a}`}function ij(e,t){if(t==null)return e;let n=t.trim();return n.length===0||e.split(` · `).some(e=>$A(e,n))?e:`${e}${ZA}${n}`}function oae(e,t){return t===null?!1:e.parentDeviceId!=null}function aj(e,t,n,r){if(!oae(e,n.parent))return t===`with-location`?ij(e.name,e.location):e.name;if(t===`nested`)return rj(e,n.parent,r);let i=aae(e,n.parent,n.siblings,r,t===`full`?`full`:`compact`);return t===`with-location`?ij(i,e.location):i}var oj=[{id:`siren`,key:`uiLibrary.deviceMeta.noun.role.siren`,en:`Siren`,it:`Sirena`,shortEn:`Siren`,shortIt:`Sirena`,aliases:[]},{id:`floodlight`,key:`uiLibrary.deviceMeta.noun.role.floodlight`,en:`Floodlight`,it:`Faro`,shortEn:`Floodlight`,shortIt:`Faro`,aliases:[]},{id:`spotlight`,key:`uiLibrary.deviceMeta.noun.role.spotlight`,en:`Spotlight`,it:`Faretto`,shortEn:`Spotlight`,shortIt:`Faretto`,aliases:[]},{id:`pir-sensor`,key:`uiLibrary.deviceMeta.noun.role.pirSensor`,en:`PIR sensor`,it:`Sensore PIR`,shortEn:`PIR`,shortIt:`PIR`,aliases:[]},{id:`chime`,key:`uiLibrary.deviceMeta.noun.role.chime`,en:`Chime`,it:`Campanello`,shortEn:`Chime`,shortIt:`Campanello`,aliases:[]},{id:`autotrack`,key:`uiLibrary.deviceMeta.noun.role.autotrack`,en:`Auto-track`,it:`Auto-tracking`,shortEn:`Auto-track`,shortIt:`Auto-tracking`,aliases:[]},{id:`nightvision`,key:`uiLibrary.deviceMeta.noun.role.nightvision`,en:`Night vision`,it:`Visione notturna`,shortEn:`Night`,shortIt:`Notturna`,aliases:[]},{id:`privacy-mask`,key:`uiLibrary.deviceMeta.noun.role.privacyMask`,en:`Privacy mask`,it:`Maschera privacy`,shortEn:`Privacy`,shortIt:`Privacy`,aliases:[]},{id:`doorbell`,key:`uiLibrary.deviceMeta.noun.role.doorbell`,en:`Doorbell`,it:`Campanello video`,shortEn:`Doorbell`,shortIt:`Campanello video`,aliases:[]},{id:`cover-blind`,key:`uiLibrary.deviceMeta.noun.role.coverBlind`,en:`Blind`,it:`Tapparella`,shortEn:`Blind`,shortIt:`Tapparella`,aliases:[]},{id:`cover-shutter`,key:`uiLibrary.deviceMeta.noun.role.coverShutter`,en:`Shutter`,it:`Persiana`,shortEn:`Shutter`,shortIt:`Persiana`,aliases:[]},{id:`cover-awning`,key:`uiLibrary.deviceMeta.noun.role.coverAwning`,en:`Awning`,it:`Tenda da sole`,shortEn:`Awning`,shortIt:`Tenda da sole`,aliases:[]},{id:`cover-curtain`,key:`uiLibrary.deviceMeta.noun.role.coverCurtain`,en:`Curtain`,it:`Tenda`,shortEn:`Curtain`,shortIt:`Tenda`,aliases:[]},{id:`cover-garage`,key:`uiLibrary.deviceMeta.noun.role.coverGarage`,en:`Garage door`,it:`Porta del garage`,shortEn:`Garage`,shortIt:`Garage`,aliases:[]},{id:`cover-gate`,key:`uiLibrary.deviceMeta.noun.role.coverGate`,en:`Gate`,it:`Cancello`,shortEn:`Gate`,shortIt:`Cancello`,aliases:[]},{id:`cover-door`,key:`uiLibrary.deviceMeta.noun.role.coverDoor`,en:`Door`,it:`Porta`,shortEn:`Door`,shortIt:`Porta`,aliases:[]},{id:`cover-window`,key:`uiLibrary.deviceMeta.noun.role.coverWindow`,en:`Window`,it:`Finestra`,shortEn:`Window`,shortIt:`Finestra`,aliases:[]},{id:`binary-helper`,key:`uiLibrary.deviceMeta.noun.role.binaryHelper`,en:`Binary helper`,it:`Helper binario`,shortEn:`Helper`,shortIt:`Helper`,aliases:[]},{id:`outlet`,key:`uiLibrary.deviceMeta.noun.role.outlet`,en:`Outlet`,it:`Presa`,shortEn:`Outlet`,shortIt:`Presa`,aliases:[]},{id:`motion-sensor`,key:`uiLibrary.deviceMeta.noun.role.motionSensor`,en:`Motion sensor`,it:`Sensore di movimento`,shortEn:`Motion`,shortIt:`Movimento`,aliases:[]},{id:`contact-sensor`,key:`uiLibrary.deviceMeta.noun.role.contactSensor`,en:`Contact sensor`,it:`Sensore di contatto`,shortEn:`Contact`,shortIt:`Contatto`,aliases:[]},{id:`leak-sensor`,key:`uiLibrary.deviceMeta.noun.role.leakSensor`,en:`Leak sensor`,it:`Sensore di perdite`,shortEn:`Leak`,shortIt:`Perdita`,aliases:[]},{id:`smoke-sensor`,key:`uiLibrary.deviceMeta.noun.role.smokeSensor`,en:`Smoke sensor`,it:`Sensore di fumo`,shortEn:`Smoke`,shortIt:`Fumo`,aliases:[]},{id:`co-sensor`,key:`uiLibrary.deviceMeta.noun.role.cOSensor`,en:`CO sensor`,it:`Sensore di CO`,shortEn:`CO`,shortIt:`CO`,aliases:[]},{id:`gas-sensor`,key:`uiLibrary.deviceMeta.noun.role.gasSensor`,en:`Gas sensor`,it:`Sensore di gas`,shortEn:`Gas`,shortIt:`Gas`,aliases:[]},{id:`tamper-sensor`,key:`uiLibrary.deviceMeta.noun.role.tamperSensor`,en:`Tamper sensor`,it:`Sensore antimanomissione`,shortEn:`Tamper`,shortIt:`Manomissione`,aliases:[]},{id:`vibration-sensor`,key:`uiLibrary.deviceMeta.noun.role.vibrationSensor`,en:`Vibration sensor`,it:`Sensore di vibrazione`,shortEn:`Vibration`,shortIt:`Vibrazione`,aliases:[]},{id:`connectivity-sensor`,key:`uiLibrary.deviceMeta.noun.role.connectivitySensor`,en:`Connectivity`,it:`Connettività`,shortEn:`Connectivity`,shortIt:`Connettività`,aliases:[]},{id:`sound-sensor`,key:`uiLibrary.deviceMeta.noun.role.soundSensor`,en:`Sound sensor`,it:`Sensore acustico`,shortEn:`Sound`,shortIt:`Suono`,aliases:[]},{id:`binary-sensor`,key:`uiLibrary.deviceMeta.noun.role.binarySensor`,en:`Binary sensor`,it:`Sensore binario`,shortEn:`Binary`,shortIt:`Binario`,aliases:[]},{id:`temperature-sensor`,key:`uiLibrary.deviceMeta.noun.role.temperatureSensor`,en:`Temperature`,it:`Temperatura`,shortEn:`Temperature`,shortIt:`Temperatura`,aliases:[]},{id:`humidity-sensor`,key:`uiLibrary.deviceMeta.noun.role.humiditySensor`,en:`Humidity`,it:`Umidità`,shortEn:`Humidity`,shortIt:`Umidità`,aliases:[]},{id:`ambient-light-sensor`,key:`uiLibrary.deviceMeta.noun.role.ambientLightSensor`,en:`Ambient light`,it:`Luce ambientale`,shortEn:`Light`,shortIt:`Luce`,aliases:[`Illumination`]},{id:`pressure-sensor`,key:`uiLibrary.deviceMeta.noun.role.pressureSensor`,en:`Pressure`,it:`Pressione`,shortEn:`Pressure`,shortIt:`Pressione`,aliases:[]},{id:`wind-sensor`,key:`uiLibrary.deviceMeta.noun.role.windSensor`,en:`Wind`,it:`Vento`,shortEn:`Wind`,shortIt:`Vento`,aliases:[]},{id:`rain-sensor`,key:`uiLibrary.deviceMeta.noun.role.rainSensor`,en:`Rain`,it:`Pioggia`,shortEn:`Rain`,shortIt:`Pioggia`,aliases:[]},{id:`uv-sensor`,key:`uiLibrary.deviceMeta.noun.role.uvSensor`,en:`UV index`,it:`Indice UV`,shortEn:`UV index`,shortIt:`Indice UV`,aliases:[]},{id:`solar-radiation-sensor`,key:`uiLibrary.deviceMeta.noun.role.solarRadiationSensor`,en:`Solar radiation`,it:`Radiazione solare`,shortEn:`Solar radiation`,shortIt:`Radiazione solare`,aliases:[]},{id:`soil-moisture-sensor`,key:`uiLibrary.deviceMeta.noun.role.soilMoistureSensor`,en:`Soil moisture`,it:`Umidità del suolo`,shortEn:`Soil moisture`,shortIt:`Umidità del suolo`,aliases:[]},{id:`power-sensor`,key:`uiLibrary.deviceMeta.noun.role.powerSensor`,en:`Power`,it:`Potenza`,shortEn:`Power`,shortIt:`Potenza`,aliases:[]},{id:`energy-sensor`,key:`uiLibrary.deviceMeta.noun.role.energySensor`,en:`Energy`,it:`Energia`,shortEn:`Energy`,shortIt:`Energia`,aliases:[]},{id:`voltage-sensor`,key:`uiLibrary.deviceMeta.noun.role.voltageSensor`,en:`Voltage`,it:`Tensione`,shortEn:`Voltage`,shortIt:`Tensione`,aliases:[]},{id:`current-sensor`,key:`uiLibrary.deviceMeta.noun.role.currentSensor`,en:`Current`,it:`Corrente`,shortEn:`Current`,shortIt:`Corrente`,aliases:[]},{id:`air-quality-sensor`,key:`uiLibrary.deviceMeta.noun.role.airQualitySensor`,en:`Air quality`,it:`Qualità dell’aria`,shortEn:`Air quality`,shortIt:`Qualità dell’aria`,aliases:[]},{id:`battery-sensor`,key:`uiLibrary.deviceMeta.noun.role.batterySensor`,en:`Battery`,it:`Batteria`,shortEn:`Battery`,shortIt:`Batteria`,aliases:[]},{id:`numeric-sensor`,key:`uiLibrary.deviceMeta.noun.role.numericSensor`,en:`Numeric sensor`,it:`Sensore numerico`,shortEn:`Value`,shortIt:`Numerico`,aliases:[]},{id:`enum-sensor`,key:`uiLibrary.deviceMeta.noun.role.enumSensor`,en:`Enum sensor`,it:`Sensore a stati`,shortEn:`State`,shortIt:`Stato`,aliases:[]},{id:`datetime-sensor`,key:`uiLibrary.deviceMeta.noun.role.dateTimeSensor`,en:`Date / time`,it:`Data / ora`,shortEn:`Time`,shortIt:`Ora`,aliases:[`Last seen`]},{id:`generic-sensor`,key:`uiLibrary.deviceMeta.noun.role.genericSensor`,en:`Sensor`,it:`Sensore`,shortEn:`Sensor`,shortIt:`Sensore`,aliases:[]},{id:`numeric-control`,key:`uiLibrary.deviceMeta.noun.role.numericControl`,en:`Numeric control`,it:`Controllo numerico`,shortEn:`Number`,shortIt:`Numero`,aliases:[]},{id:`select-control`,key:`uiLibrary.deviceMeta.noun.role.selectControl`,en:`Select control`,it:`Controllo a selezione`,shortEn:`Select`,shortIt:`Selezione`,aliases:[]},{id:`text-control`,key:`uiLibrary.deviceMeta.noun.role.textControl`,en:`Text control`,it:`Controllo testo`,shortEn:`Text`,shortIt:`Testo`,aliases:[]},{id:`datetime-control`,key:`uiLibrary.deviceMeta.noun.role.dateTimeControl`,en:`Date / time control`,it:`Controllo data / ora`,shortEn:`Time`,shortIt:`Ora`,aliases:[]},{id:`mobile-push-notifier`,key:`uiLibrary.deviceMeta.noun.role.mobilePushNotifier`,en:`Mobile push`,it:`Push su mobile`,shortEn:`Push`,shortIt:`Push`,aliases:[]},{id:`messaging-notifier`,key:`uiLibrary.deviceMeta.noun.role.messagingNotifier`,en:`Messaging`,it:`Messaggistica`,shortEn:`Messaging`,shortIt:`Messaggistica`,aliases:[]},{id:`email-notifier`,key:`uiLibrary.deviceMeta.noun.role.emailNotifier`,en:`Email`,it:`Email`,shortEn:`Email`,shortIt:`Email`,aliases:[]},{id:`generic-notifier`,key:`uiLibrary.deviceMeta.noun.role.genericNotifier`,en:`Notifier`,it:`Notificatore`,shortEn:`Notifier`,shortIt:`Notificatore`,aliases:[]}],sj=[{id:`camera`,key:`uiLibrary.deviceMeta.noun.type.camera`,en:`Camera`,it:`Telecamera`,shortEn:`Camera`,shortIt:`Telecamera`,aliases:[]},{id:`hub`,key:`uiLibrary.deviceMeta.noun.type.hub`,en:`Hub`,it:`Hub`,shortEn:`Hub`,shortIt:`Hub`,aliases:[]},{id:`light`,key:`uiLibrary.deviceMeta.noun.type.light`,en:`Light`,it:`Luce`,shortEn:`Light`,shortIt:`Luce`,aliases:[]},{id:`siren`,key:`uiLibrary.deviceMeta.noun.type.siren`,en:`Siren`,it:`Sirena`,shortEn:`Siren`,shortIt:`Sirena`,aliases:[]},{id:`switch`,key:`uiLibrary.deviceMeta.noun.type.switch`,en:`Switch`,it:`Interruttore`,shortEn:`Switch`,shortIt:`Interruttore`,aliases:[]},{id:`sensor`,key:`uiLibrary.deviceMeta.noun.type.sensor`,en:`Sensor`,it:`Sensore`,shortEn:`Sensor`,shortIt:`Sensore`,aliases:[]},{id:`thermostat`,key:`uiLibrary.deviceMeta.noun.type.thermostat`,en:`Thermostat`,it:`Termostato`,shortEn:`Thermostat`,shortIt:`Termostato`,aliases:[]},{id:`climate`,key:`uiLibrary.deviceMeta.noun.type.climate`,en:`Air conditioner`,it:`Condizionatore`,shortEn:`Climate`,shortIt:`Condizionatore`,aliases:[]},{id:`button`,key:`uiLibrary.deviceMeta.noun.type.button`,en:`Button`,it:`Pulsante`,shortEn:`Button`,shortIt:`Pulsante`,aliases:[]},{id:`event-emitter`,key:`uiLibrary.deviceMeta.noun.type.eventEmitter`,en:`Event Emitter`,it:`Emettitore di eventi`,shortEn:`Event`,shortIt:`Evento`,aliases:[]},{id:`update`,key:`uiLibrary.deviceMeta.noun.type.update`,en:`Update`,it:`Aggiornamento`,shortEn:`Update`,shortIt:`Aggiornamento`,aliases:[]},{id:`generic`,key:`uiLibrary.deviceMeta.noun.type.generic`,en:`Generic`,it:`Generico`,shortEn:`Generic`,shortIt:`Generico`,aliases:[]},{id:`notifier`,key:`uiLibrary.deviceMeta.noun.type.notifier`,en:`Notifier`,it:`Notificatore`,shortEn:`Notifier`,shortIt:`Notificatore`,aliases:[]},{id:`script`,key:`uiLibrary.deviceMeta.noun.type.script`,en:`Script`,it:`Script`,shortEn:`Script`,shortIt:`Script`,aliases:[]},{id:`automation`,key:`uiLibrary.deviceMeta.noun.type.automation`,en:`Automation`,it:`Automazione`,shortEn:`Automation`,shortIt:`Automazione`,aliases:[]},{id:`lock`,key:`uiLibrary.deviceMeta.noun.type.lock`,en:`Lock`,it:`Serratura`,shortEn:`Lock`,shortIt:`Serratura`,aliases:[]},{id:`cover`,key:`uiLibrary.deviceMeta.noun.type.cover`,en:`Cover`,it:`Copertura`,shortEn:`Cover`,shortIt:`Copertura`,aliases:[]},{id:`valve`,key:`uiLibrary.deviceMeta.noun.type.valve`,en:`Valve`,it:`Valvola`,shortEn:`Valve`,shortIt:`Valvola`,aliases:[]},{id:`humidifier`,key:`uiLibrary.deviceMeta.noun.type.humidifier`,en:`Humidifier`,it:`Umidificatore`,shortEn:`Humidifier`,shortIt:`Umidificatore`,aliases:[]},{id:`water-heater`,key:`uiLibrary.deviceMeta.noun.type.waterHeater`,en:`Water heater`,it:`Scaldabagno`,shortEn:`Heater`,shortIt:`Scaldabagno`,aliases:[]},{id:`fan`,key:`uiLibrary.deviceMeta.noun.type.fan`,en:`Fan`,it:`Ventilatore`,shortEn:`Fan`,shortIt:`Ventilatore`,aliases:[]},{id:`media-player`,key:`uiLibrary.deviceMeta.noun.type.mediaPlayer`,en:`Media player`,it:`Lettore multimediale`,shortEn:`Player`,shortIt:`Lettore`,aliases:[]},{id:`alarm-panel`,key:`uiLibrary.deviceMeta.noun.type.alarmPanel`,en:`Alarm panel`,it:`Pannello allarme`,shortEn:`Alarm`,shortIt:`Allarme`,aliases:[]},{id:`control`,key:`uiLibrary.deviceMeta.noun.type.control`,en:`Control`,it:`Controllo`,shortEn:`Control`,shortIt:`Controllo`,aliases:[]},{id:`presence`,key:`uiLibrary.deviceMeta.noun.type.presence`,en:`Presence`,it:`Presenza`,shortEn:`Presence`,shortIt:`Presenza`,aliases:[]},{id:`weather`,key:`uiLibrary.deviceMeta.noun.type.weather`,en:`Weather`,it:`Meteo`,shortEn:`Weather`,shortIt:`Meteo`,aliases:[]},{id:`vacuum`,key:`uiLibrary.deviceMeta.noun.type.vacuum`,en:`Vacuum`,it:`Aspirapolvere`,shortEn:`Vacuum`,shortIt:`Aspirapolvere`,aliases:[]},{id:`lawn-mower`,key:`uiLibrary.deviceMeta.noun.type.lawnMower`,en:`Lawn mower`,it:`Tagliaerba`,shortEn:`Mower`,shortIt:`Tagliaerba`,aliases:[]},{id:`container`,key:`uiLibrary.deviceMeta.noun.type.container`,en:`Container`,it:`Contenitore`,shortEn:`Container`,shortIt:`Contenitore`,aliases:[]},{id:`image`,key:`uiLibrary.deviceMeta.noun.type.image`,en:`Image`,it:`Immagine`,shortEn:`Image`,shortIt:`Immagine`,aliases:[]},{id:`pet-feeder`,key:`uiLibrary.deviceMeta.noun.type.petFeeder`,en:`Pet feeder`,it:`Distributore di cibo per animali`,shortEn:`Feeder`,shortIt:`Distributore`,aliases:[]},{id:`dishwasher`,key:`uiLibrary.deviceMeta.noun.type.dishwasher`,en:`Dishwasher`,it:`Lavastoviglie`,shortEn:`Dishwasher`,shortIt:`Lavastoviglie`,aliases:[]}],sae={id:``,key:`uiLibrary.deviceMeta.noun.fallback`,en:`Device`,it:`Dispositivo`,shortEn:`Device`,shortIt:`Dispositivo`,aliases:[]};function cj(e,t){if(!(t===null||t.length===0))return e.find(e=>e.id===t)}function lj(e,t){if(e!==null){let t=cj(oj,e);if(t!==void 0)return t}return cj(sj,t)??sae}function uj(e,t){let n=[],r=[cj(oj,e),cj(sj,t)];for(let e of r)e!==void 0&&n.push(e.en,e.it,e.shortEn,e.shortIt,...e.aliases);return n}function dj(e,t,n){let r=QA(e);return r.length===0?!0:uj(t,n).some(e=>QA(e)===r)}function fj(e){return{shortNoun(t,n){let r=lj(t,n);return e===`it`?r.shortIt:r.shortEn},isStockPhrase(e,t,n){return dj(e,t,n)}}}function pj(){let e=q();return{shortNoun(t,n){let r=lj(t,n);return e(r.key,r.shortEn)},isStockPhrase(e,t,n){return dj(e,t,n)}}}function mj(e){return{id:e,name:`#${String(e)}`,type:`unknown`,stableId:``,role:null,parentDeviceId:null}}function hj(e,t){let n=e.parentDeviceId;return n==null?null:t.byId.get(n)??mj(n)}function gj(e,t){let n=e.parentDeviceId;if(n==null)return[];let r=t.childIds.get(n)??[],i=[];for(let e of r){let n=t.byId.get(e);n!==void 0&&i.push(n)}return i.some(t=>t.id===e.id)||i.push(e),i}function _j(e,t,n,r,i){let a=n?.byId.get(e.id)??e;return a.parentDeviceId!=null&&n===null&&i?.parent===void 0?a.name:aj(a,t,{parent:i?.parent===void 0?n===null?null:hj(a,n):i.parent,siblings:i?.siblings??(n===null?[]:gj(a,n))},r)}function vj(e,t,n){return _j(e,t,qA(),pj(),n)}function yj(e,t,n){let r=qA(),i=pj();if(r===null)return n??`#${String(e)}`;let a=r.byId.get(e);return a===void 0?`#${String(e)}`:_j(a,t,r,i)}function bj({device:e,form:t,parent:n,siblings:r,className:i,testId:a}){let o=vj(e,t,{...n===void 0?{}:{parent:n},...r===void 0?{}:{siblings:r}});return v(`span`,{className:i,title:o,"data-testid":a,children:o})}E();function xj(e){let t=Rn(),n=p(()=>e?JSON.stringify(e):``,[e]),[r,i]=C(()=>t.listDevices(e));return b(()=>{let n=()=>{i(t.listDevices(e))};n();let r=null,a=null;try{r=t.onDeviceAdded(n),a=t.onDeviceRemoved(n)}catch{}let o=t.subscribeConnectionEvents(e=>{e===`connected`&&n()});return()=>{r?.(),a?.(),o()}},[t,e,n]),r}function Sj(e){let t=Rn(),[n,r]=C(()=>e===null?null:t.getDevice(e));return b(()=>{if(e===null){r(null);return}let n=()=>{r(t.getDevice(e))};n();let i=null,a=null;try{i=t.onDeviceAdded(n),a=t.onDeviceRemoved(n)}catch{}let o=t.subscribeConnectionEvents(e=>{e===`connected`&&n()});return()=>{i?.(),a?.(),o()}},[t,e]),n}var Cj=.02;function wj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tj(e){if(!wj(e))return null;let{x:t,y:n,width:r,height:i}=e;return typeof t!=`number`||typeof n!=`number`||typeof r!=`number`||typeof i!=`number`||t<0||n<0||r<=0||i<=0||t+r>1||n+i>1?null:{x:t,y:n,width:r,height:i}}function Ej(e){if(!wj(e))return null;let t=e.deviceId;if(typeof t!=`number`||!Number.isInteger(t))return null;let n=Tj(e.source),r=Tj(e.cell);return n===null||r===null?null:{deviceId:t,source:n,cell:r}}function Dj(e){if(!wj(e))return null;let t=e.profile,n=e.offered,r=e.missingSources;if(t!==`high`&&t!==`mid`&&t!==`low`||typeof n!=`boolean`||!Array.isArray(r))return null;let i=[];for(let e of r){if(typeof e!=`number`||!Number.isInteger(e))return null;i.push(e)}return{profile:t,offered:n,missingSources:i,canvas:typeof e.canvas==`string`?e.canvas:``,published:typeof e.published==`boolean`?e.published:n}}function Oj(e){if(e===null)return null;if(!wj(e))return`unreadable`;let{instanceId:t,deviceId:n,name:r,fps:i,cells:a,profiles:o}=e;if(typeof t!=`string`||typeof n!=`number`||typeof r!=`string`||typeof i!=`number`||!Array.isArray(a)||!Array.isArray(o))return`unreadable`;let s=[];for(let e of a){let t=Ej(e);if(t===null)return`unreadable`;s.push(t)}let c=[];for(let e of o){let t=Dj(e);if(t===null)return`unreadable`;c.push(t)}return{instanceId:t,deviceId:n,name:r,fps:i,cells:s,profiles:c}}function kj(e){let t=Math.min(1,Math.max(Cj,e.width)),n=Math.min(1,Math.max(Cj,e.height));return{x:Math.min(1-t,Math.max(0,e.x)),y:Math.min(1-n,Math.max(0,e.y)),width:t,height:n}}function Aj(e,t,n){return kj({...e,x:e.x+t,y:e.y+n})}function jj(e,t,n,r){let i=t===`nw`||t===`w`||t===`sw`,a=t===`ne`||t===`e`||t===`se`,o=t===`nw`||t===`n`||t===`ne`,s=t===`sw`||t===`s`||t===`se`,c=e.x,l=e.x+e.width,u=e.y,d=e.y+e.height;return i&&(c=Math.min(l-Cj,Math.max(0,c+n))),a&&(l=Math.max(c+Cj,Math.min(1,l+n))),o&&(u=Math.min(d-Cj,Math.max(0,u+r))),s&&(d=Math.max(u+Cj,Math.min(1,d+r))),kj({x:c,y:u,width:l-c,height:d-u})}function Mj(e){if(!Number.isFinite(e)||e<=0)return[];let t=Math.floor(e),n=Math.ceil(Math.sqrt(t)),r=Math.ceil(t/n),i=[],a=0;for(let e=0;e<r;e++){let o=Math.min(n,t-a),s=1/r,c=1/o;for(let t=0;t<o;t++)i.push({x:t*c,y:e*s,width:c,height:s});a+=o}return i}E();var Nj={x:0,y:0,width:1,height:1},Pj=16,Fj={type:J.Camera},Ij={touchAction:`none`},Lj=`absolute flex h-6 w-6 items-center justify-center`,Rj=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],zj={nw:`-top-3 -left-3 cursor-nw-resize`,n:`-top-3 left-1/2 -translate-x-1/2 cursor-n-resize`,ne:`-top-3 -right-3 cursor-ne-resize`,e:`top-1/2 -right-3 -translate-y-1/2 cursor-e-resize`,se:`-bottom-3 -right-3 cursor-se-resize`,s:`-bottom-3 left-1/2 -translate-x-1/2 cursor-s-resize`,sw:`-bottom-3 -left-3 cursor-sw-resize`,w:`top-1/2 -left-3 -translate-y-1/2 cursor-w-resize`};function Bj(e){e.currentTarget.setPointerCapture(e.pointerId)}function Vj(e,t,n){return e.mode===`move`?Aj(e.origin,t,n):jj(e.origin,e.mode,t,n)}function Hj({deviceId:e}){let t=q(),n=Rn(),r=p(()=>n.listDeviceInfos(Fj),[n,xj(Fj)]),[i,a]=C(void 0),[o,s]=C(null),[l,u]=C(!1),[d,f]=C(null),[m,h]=C(0),[g,y]=C(null),x=Ge(n.trpcClient,e),S=_(async()=>{let e=x?.cameraGridLayout;if(!e)return;let t=Oj(await e.getLayout({}));a(t),s(t===null||t===`unreadable`?null:t)},[x]);b(()=>{if(x){if(!x.cameraGridLayout){a(null);return}S().catch(()=>{a(`unreadable`)})}},[x,S]);let w=_(async e=>{let t=x?.cameraGridLayout;if(!(o===null||!t)){u(!0),f(null);try{let n=Oj(await t.saveLayout({name:o.name,fps:o.fps,cells:o.cells.map(e=>({...e})),...e?.publishedProfiles===void 0?{}:{publishedProfiles:[...e.publishedProfiles]}}));n!==null&&n!==`unreadable`&&(a(n),s(n))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[x,o]),T=_((e,t)=>{s(n=>n===null?n:{...n,cells:n.cells.map((n,r)=>r===e?{...n,...t}:n)})},[]),E=p(()=>{let e=i==null||i===`unreadable`?[]:i.profiles;for(let t of e){if(!t.offered)continue;let[e,n]=t.canvas.split(`x`).map(Number);if(e!==void 0&&n!==void 0&&e>0&&n>0)return e/n}return 16/9},[i]);if(i===void 0)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),` `,t(`uiLibrary.cameraGridLayout.loading`,`Loading the layout…`)]})});if(i===`unreadable`)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-danger`,children:[v(Ai,{className:`h-3 w-3`}),t(`uiLibrary.cameraGridLayout.unreadable`,`The Camera Grids addon did not answer, so this layout is unknown — not empty.`)]})});if(i===null||o===null)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:v(`div`,{className:`text-[10.5px] text-foreground-subtle`,children:t(`uiLibrary.cameraGridLayout.notGrid`,`This camera is not a grid.`)})});let D=e=>{if(g===null)return;let t=e.currentTarget.getBoundingClientRect();if(t.width===0||t.height===0||g.target!==`cell`)return;let n=(e.clientX-g.startX)/t.width,r=(e.clientY-g.startY)/t.height;T(g.index,{cell:Vj(g,n,r)})};return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),headerRight:c(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,disabled:o.cells.length===0,title:t(`uiLibrary.cameraGridLayout.autofillTitle`,`Tile every cell over the whole canvas, leaving no gap`),onClick:()=>{let e=Mj(o.cells.length);s({...o,cells:o.cells.map((t,n)=>({...t,cell:e[n]??t.cell}))})},className:`flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[10px] uppercase`,children:[v(wi,{className:`h-3 w-3`}),` `,t(`uiLibrary.cameraGridLayout.autofill`,`Autofill`)]}),c(`button`,{type:`button`,disabled:l,onClick:()=>void w(),className:`flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[10px] uppercase`,children:[l?v(Gn,{className:`h-3 w-3 animate-spin`}):v(ji,{className:`h-3 w-3`}),t(`uiLibrary.cameraGridLayout.save`,`Save`)]})]}),children:c(`div`,{className:`flex flex-col gap-3`,children:[d!==null&&c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-danger`,children:[v(Ai,{className:`h-3 w-3`}),` `,d]}),c(`div`,{className:`relative w-full select-none overflow-hidden rounded border border-border bg-black`,style:{aspectRatio:String(E),...Ij},onPointerMove:D,onPointerUp:()=>{y(null)},onPointerCancel:()=>{y(null)},children:[o.cells.map((e,t)=>v(Wj,{cell:e,selected:t===m,onSelect:()=>{h(t)},onDragStart:(n,r)=>{h(t),y({index:t,target:`cell`,mode:n,startX:r.clientX,startY:r.clientY,origin:e.cell})}},`${String(e.deviceId)}-${String(t)}`)),o.cells.length===0&&v(`div`,{className:`absolute inset-0 flex items-center justify-center text-[10.5px] text-foreground-subtle`,children:t(`uiLibrary.cameraGridLayout.noCells`,`No cells yet — add one below.`)})]}),c(`div`,{className:`grid grid-cols-4 gap-2 text-[10.5px]`,children:[v(Xj,{label:`FPS`,value:o.fps,onChange:e=>{s({...o,fps:e})}}),c(`button`,{type:`button`,disabled:o.cells.length>=Pj,onClick:()=>{let t=r.find(t=>t.id!==e);t&&(s({...o,cells:[...o.cells,{deviceId:t.id,source:Nj,cell:kj({x:.1,y:.1,width:.4,height:.4})}]}),h(o.cells.length))},className:`flex items-center justify-center gap-1 self-end rounded border border-border px-2 py-1 uppercase`,children:[v(Se,{className:`h-3 w-3`}),` `,t(`uiLibrary.cameraGridLayout.addCell`,`Cell`)]})]}),v(Uj,{offers:i.profiles,cameras:r,onToggle:e=>{if(o===null)return;let t=i.profiles.filter(e=>e.published).map(e=>e.profile);w({publishedProfiles:t.includes(e)?t.filter(t=>t!==e):[...t,e]})}}),o.cells[m]!==void 0&&v(Kj,{cell:o.cells[m],index:m,cameras:r.filter(t=>t.id!==e),onChange:e=>{T(m,e)},onRemove:()=>{s({...o,cells:o.cells.filter((e,t)=>t!==m)}),h(0)}})]})})}function Uj({offers:e,cameras:t,onToggle:n}){let r=q(),i=e=>t.find(t=>t.id===e)?.name??`#${String(e)}`;return c(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2 text-[10.5px]`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.published`,`Published profiles`)}),e.map(e=>c(`div`,{className:`flex items-baseline gap-2`,children:[v(`input`,{type:`checkbox`,checked:e.published,disabled:!e.offered,"aria-label":r(`uiLibrary.cameraGridLayout.publish`,`publish {{profile}}`,{profile:e.profile}),onChange:()=>{n(e.profile)}}),v(`span`,{className:`w-10 uppercase`,children:e.profile}),e.offered?c(`span`,{className:`text-foreground-subtle`,children:[e.canvas,` —`,` `,e.published?r(`uiLibrary.cameraGridLayout.composed`,`composed from every source’s {{profile}}`,{profile:e.profile}):r(`uiLibrary.cameraGridLayout.serviceable`,`serviceable, not published`)]}):v(`span`,{className:`text-danger`,children:e.missingSources.length===0?r(`uiLibrary.cameraGridLayout.noCellsOffer`,`not offered — this grid has no cells yet`):r(`uiLibrary.cameraGridLayout.missing`,`not offered — no {{profile}} on {{sources}}`,{profile:e.profile,sources:e.missingSources.map(i).join(`, `)})})]},e.profile))]})}function Wj({cell:e,selected:t,onSelect:n,onDragStart:r}){let{src:i}=Te(e.deviceId,{width:640}),a=`${String(100/e.source.width)}% ${String(100/e.source.height)}%`,o=e.source.width>=1&&e.source.height>=1?`center`:`${String(e.source.x/Math.max(1e-6,1-e.source.width)*100)}% ${String(e.source.y/Math.max(1e-6,1-e.source.height)*100)}%`;return v(`div`,{role:`presentation`,onPointerDown:e=>{n(),Bj(e),r(`move`,e)},className:`absolute cursor-move border ${t?`border-accent`:`border-border/60`}`,style:{...Ij,left:`${String(e.cell.x*100)}%`,top:`${String(e.cell.y*100)}%`,width:`${String(e.cell.width*100)}%`,height:`${String(e.cell.height*100)}%`,backgroundImage:i===null?void 0:`url(${i})`,backgroundSize:a,backgroundPosition:o,backgroundRepeat:`no-repeat`},children:t&&Rj.map(e=>v(`div`,{role:`presentation`,onPointerDown:t=>{t.stopPropagation(),Bj(t),r(e,t)},className:`${Lj} ${zj[e]}`,style:Ij,children:v(`span`,{className:`h-2.5 w-2.5 bg-accent`})},e))})}function Gj({camera:e}){return vj(e,`compact`)}function Kj({cell:e,index:t,cameras:n,onChange:r,onRemove:i}){let a=q();return c(`div`,{className:`flex flex-col gap-2 rounded border border-border p-2 text-[10.5px]`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:a(`uiLibrary.cameraGridLayout.cellN`,`Cell {{index}}`,{index:t+1})}),v(`button`,{type:`button`,onClick:i,className:`text-danger`,children:v(Pe,{className:`h-3 w-3`})})]}),c(`label`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`w-16 text-foreground-subtle`,children:a(`uiLibrary.cameraGridLayout.source`,`Source`)}),v(`select`,{value:String(e.deviceId),onChange:e=>{r({deviceId:Number(e.target.value)})},className:`flex-1 rounded border border-border bg-transparent px-1 py-0.5`,children:n.map(e=>v(`option`,{value:String(e.id),children:v(Gj,{camera:e})},e.id))})]}),v(qj,{deviceId:e.deviceId,source:e.source,onChange:e=>{r({source:e})}}),v(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5`,children:[`x`,`y`,`width`,`height`].map(t=>v(Yj,{label:Jj(a,t),value:e.source[t],onChange:n=>{r({source:kj({...e.source,[t]:n})})}},t))})]})}function qj({deviceId:e,source:t,onChange:n}){let r=q(),{src:i}=Te(e,{width:640}),[a,o]=C(null),[s,l]=C(null),u=e=>{if(a===null)return;let t=e.currentTarget.getBoundingClientRect();t.width===0||t.height===0||n(Vj({...a,index:0,target:`source`},(e.clientX-a.startX)/t.width,(e.clientY-a.startY)/t.height))},d=t.x===0&&t.y===0&&t.width===1&&t.height===1;return c(`div`,{className:`flex flex-col gap-1`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.visiblePart`,`Visible part of the camera`)}),c(`button`,{type:`button`,disabled:d,onClick:()=>{n(Nj)},className:`flex items-center gap-1 rounded border border-border px-1.5 py-0.5 uppercase disabled:opacity-40`,children:[v(Br,{className:`h-3 w-3`}),` `,r(`uiLibrary.cameraGridLayout.wholeFrame`,`Whole frame`)]})]}),c(`div`,{className:`relative w-full select-none overflow-hidden rounded border border-border bg-black`,style:{aspectRatio:String(s??16/9),...Ij},onPointerMove:u,onPointerUp:()=>{o(null)},onPointerCancel:()=>{o(null)},children:[i===null?v(`div`,{className:`absolute inset-0 flex items-center justify-center text-[10px] text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.noSnapshot`,`No snapshot from this camera yet — the numbers below still apply.`)}):v(`img`,{src:i,alt:``,className:`absolute inset-0 h-full w-full`,onLoad:e=>{let{naturalWidth:t,naturalHeight:n}=e.currentTarget;t>0&&n>0&&l(t/n)}}),v(`div`,{className:`pointer-events-none absolute inset-0 bg-black/55`}),v(`div`,{role:`presentation`,onPointerDown:e=>{Bj(e),o({mode:`move`,startX:e.clientX,startY:e.clientY,origin:t})},className:`absolute cursor-move border border-accent`,style:{...Ij,left:`${String(t.x*100)}%`,top:`${String(t.y*100)}%`,width:`${String(t.width*100)}%`,height:`${String(t.height*100)}%`,backgroundImage:i===null?void 0:`url(${i})`,backgroundSize:`${String(100/t.width)}% ${String(100/t.height)}%`,backgroundPosition:t.width>=1&&t.height>=1?`center`:`${String(t.x/Math.max(1e-6,1-t.width)*100)}% ${String(t.y/Math.max(1e-6,1-t.height)*100)}%`},children:Rj.map(e=>v(`div`,{role:`presentation`,onPointerDown:n=>{n.stopPropagation(),Bj(n),o({mode:e,startX:n.clientX,startY:n.clientY,origin:t})},className:`${Lj} ${zj[e]}`,style:Ij,children:v(`span`,{className:`h-2.5 w-2.5 bg-accent`})},e))})]})]})}function Jj(e,t){switch(t){case`x`:return e(`uiLibrary.cameraGridLayout.cropX`,`Crop x`);case`y`:return e(`uiLibrary.cameraGridLayout.cropY`,`Crop y`);case`width`:return e(`uiLibrary.cameraGridLayout.cropWidth`,`Crop width`);case`height`:return e(`uiLibrary.cameraGridLayout.cropHeight`,`Crop height`)}}function Yj({label:e,value:t,onChange:n}){let r=Math.round(t*100)/100;return c(`label`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{className:`flex items-baseline justify-between text-foreground-subtle`,children:[v(`span`,{children:e}),v(`input`,{type:`number`,min:0,max:1,step:.01,value:r,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n(t)},className:`w-12 rounded border border-border bg-transparent px-1 py-0.5 text-right`})]}),v(`input`,{type:`range`,min:0,max:1,step:.005,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n(t)},style:Ij,className:`h-5 w-full accent-accent`})]})}function Xj({label:e,value:t,step:n=1,onChange:r}){return c(`label`,{className:`flex flex-col gap-0.5`,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),v(`input`,{type:`number`,step:n,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&r(t)},className:`rounded border border-border bg-transparent px-1 py-0.5`})]})}function Zj(e){let t=Ge(e.trpc,e.deviceId),n=Be(t===null?void 0:e.slice(t)),r=t===null?void 0:e.cap(t),i=Be(t===null?void 0:t.state.deviceStatus),a=i?.online??!0,o=a?null:i?.lastChangedAt??null;return{dev:t,cap:r,slice:n,available:(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&r!==void 0&&n!==void 0&&a,online:a,offlineSince:o}}E();var Qj=`open`,$j=`closed`;function eM(e){if(e===null||typeof window>`u`)return null;try{let t=window.localStorage.getItem(e);return t===Qj?!0:t===$j?!1:null}catch{return null}}function tM(e,t){if(!(e===null||typeof window>`u`))try{window.localStorage.setItem(e,t?Qj:$j)}catch{}}function nM(e){let[t,n]=C(()=>({key:e,open:eM(e)})),r=t.key===e?t:{key:e,open:eM(e)};r!==t&&n(r);let i=_(t=>{n({key:e,open:t}),tM(e,t)},[e]);return[r.open,i]}var rM={ok:{variant:`success`,barClass:`bg-success`,labelKey:`uiLibrary.consumableLevel.ok`,labelFallback:`OK`},low:{variant:`warning`,barClass:`bg-warning`,labelKey:`uiLibrary.consumableLevel.low`,labelFallback:`Low`},empty:{variant:`danger`,barClass:`bg-danger`,labelKey:`uiLibrary.consumableLevel.empty`,labelFallback:`Empty`},full:{variant:`warning`,barClass:`bg-warning`,labelKey:`uiLibrary.consumableLevel.full`,labelFallback:`Full`},unknown:{variant:`neutral`,barClass:`bg-foreground-subtle`,labelKey:`uiLibrary.consumableLevel.unknown`,labelFallback:`Unknown`}};function iM(e){return rM[e??`unknown`]}function aM(e){return iM(e).variant}function oM(e){return iM(e).barClass}function sM(e,t){let n=iM(e);return t(n.labelKey,n.labelFallback)}function cM(e){return e.status===`full`||e.status===`replace`?`full`:e.level===null?e.status===null?null:`ok`:e.level>=85?`full`:`ok`}function lM(e){if(e.level!==null)return e.level<=0||e.status===`empty`?`empty`:e.level<=15||e.status===`replace`||e.status===`low`?`low`:`ok`;switch(e.status){case`replace`:case`low`:return`low`;case`empty`:return`empty`;case`ok`:case`full`:return`ok`;case null:return null}}function uM(e){return pa(e)===`waste`?cM(e):lM(e)}var dM=fa.exclude([`full`]).options;function fM(e){if(e.kind!==`enum`||e.enumValues===void 0)return!1;let t=dM;return e.enumValues.length===t.length&&t.every(t=>e.enumValues?.includes(t))}function pM(e){let t=fa.safeParse(e);return t.success?t.data:null}function mM({level:e,name:t,label:n,size:r=`md`,className:i}){let a=q(),o=n??sM(e,a);return v(Bk,{variant:aM(e),size:r,className:i,"data-level":e??`unknown`,children:t===void 0?o:`${t} · ${o}`})}E();var hM=D(({className:e,...t},n)=>v(`div`,{ref:n,className:$(`animate-pulse bg-surface-hover rounded-md h-4 w-full`,e),...t}));hM.displayName=`Skeleton`;function gM(e,t){if(t.value===null)return`—`;if(t.kind===`count`)return e(`uiLibrary.consumablesPanel.cycles`,{one:`{{count}} cycle`,other:`{{count}} cycles`},{count:t.value});let n=Va({value:t.value,quantity:`duration`,precision:0});return n.unit.length===0?n.text:`${n.text} ${n.unit}`}function _M(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function vM(e){return e===`low`||e===`empty`||e===`full`}function yM(e){return Math.max(0,Math.min(100,e))}function bM({item:e,warn:t,children:n}){return v(`div`,{"data-form":Xa(e),className:`flex gap-2.5 rounded-md border p-3 ${t?`border-warning/40 bg-warning/5`:`border-border-subtle`}`,children:n})}function xM({item:e,warn:t}){return v(`span`,{className:`truncate text-xs font-semibold ${t?`text-warning`:`text-foreground`}`,children:e.label})}function SM({item:e,busy:t,canReset:n,onReset:r}){let i=q(),a=uM(e),o=vM(a);return v(bM,{item:e,warn:o,children:c(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[v(xM,{item:e,warn:o}),e.level===null?v(mM,{level:a,size:`sm`,className:`w-fit`,label:e.status===`replace`?i(`uiLibrary.consumablesPanel.replace`,`Replace`):void 0}):c(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-surface-hover`,children:v(`div`,{className:`h-full rounded-full ${oM(a)} transition-all`,style:{width:`${yM(e.level)}%`}})}),c(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:[Math.round(e.level),`%`]})]}),e.remaining&&v(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:gM(i,e.remaining)}),e.lastResetAt!==null&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.consumablesPanel.replacedOn`,`Replaced {{date}}`,{date:_M(e.lastResetAt)})}),e.resettable&&v(_A,{type:`button`,variant:`outline`,size:`sm`,className:`w-fit`,onClick:()=>r(e.key),disabled:t||!n,children:i(`uiLibrary.consumablesPanel.replaced`,`Replaced`)})]})})}function CM({item:e}){let t=uM(e),n=vM(t);return c(bM,{item:e,warn:n,children:[v(`div`,{className:`relative h-10 w-3 shrink-0 overflow-hidden rounded-sm border border-border bg-surface-hover`,"data-testid":`consumable-gauge`,children:e.level!==null&&v(`div`,{className:`absolute inset-x-0 bottom-0 ${oM(t)} transition-all`,style:{height:`${yM(e.level)}%`}})}),c(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1`,children:[v(xM,{item:e,warn:n}),c(`div`,{className:`flex items-center gap-2`,children:[v(mM,{level:t,size:`sm`,className:`w-fit`}),e.level!==null&&c(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:[Math.round(e.level),`%`]})]})]})]})}var wM={full:3,ok:3,low:1,empty:0,unknown:0},TM=[0,1,2];function EM(e,t){if(e===`low`)return t(`uiLibrary.consumablesPanel.refillSoon`,`Refill soon`);if(e===`empty`)return t(`uiLibrary.consumablesPanel.refillNow`,`Refill now`)}function DM({item:e}){let t=q(),n=uM(e),r=vM(n),i=wM[n??`unknown`];return c(bM,{item:e,warn:r,children:[v(Xt,{className:`mt-0.5 h-4 w-4 shrink-0 ${r?`text-warning`:`text-foreground-subtle`}`}),c(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[v(xM,{item:e,warn:r}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`div`,{className:`flex gap-0.5`,"data-testid":`consumable-steps`,"data-filled":i,children:TM.map(e=>v(`span`,{className:`h-1.5 w-3 rounded-full ${e<i?oM(n):`bg-surface-hover`}`},e))}),v(mM,{level:n,size:`sm`,className:`whitespace-nowrap`,label:EM(n,t)})]})]})]})}function OM(e){switch(Xa(e.item)){case`part`:return v(SM,{...e});case`tank`:case`bin`:return v(CM,{item:e.item});case`product`:return v(DM,{item:e.item})}}var kM={empty:3,full:2,low:1};function AM(e){return e===`low`||e===`empty`||e===`full`}function jM(e){if(e.length===0)return{kind:`none`,needsAttention:!1};let t=[],n=0,r=0;for(let i of e){let e=uM(i);AM(e)?t.push({label:i.label,level:e,replace:i.status===`replace`}):e===`ok`?n+=1:r+=1}let i=[...t].sort((e,t)=>kM[t.level]-kM[e.level])[0];return i===void 0?r===0?{kind:`ok`,needsAttention:!1,count:n}:{kind:`partial`,needsAttention:!1,ok:n,unknown:r}:{kind:`attention`,needsAttention:!0,count:t.length,worst:i}}E();function MM(e){return`camstack.device.${String(e)}.consumables.open`}function NM({summary:e,t}){switch(e.kind){case`none`:return v(Bk,{variant:`neutral`,size:`sm`,children:t(`uiLibrary.consumablesPanel.noneReported`,`None reported`)});case`ok`:return v(Bk,{variant:`success`,size:`sm`,children:t(`uiLibrary.consumablesPanel.allOk`,`All OK`)});case`partial`:return v(Bk,{variant:`neutral`,size:`sm`,children:t(`uiLibrary.consumablesPanel.okAndUnknown`,`{{ok}} OK · {{unknown}} unknown`,{ok:e.ok,unknown:e.unknown})});case`attention`:return e.count===1?v(mM,{level:e.worst.level,name:e.worst.label,size:`sm`,label:e.worst.replace?t(`uiLibrary.consumablesPanel.replace`,`Replace`):void 0}):v(Bk,{variant:aM(e.worst.level),size:`sm`,children:t(`uiLibrary.consumablesPanel.needAttention`,{one:`{{count}} needs attention`,other:`{{count}} need attention`},{count:e.count})})}}function PM({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),{cap:i,slice:a,available:o}=Zj({trpc:n.trpcClient,deviceId:r?e:null,cap:e=>e.consumables,slice:e=>e.state.consumables}),[s,c]=C(null),[l,u]=nM(r?MM(e):null),d=_(async e=>{if(i){c(e);try{await i.reset({key:e})}catch(e){console.error(`consumables.reset failed`,e)}finally{c(null)}}},[i]),f=a===void 0?null:jM(a.items),p=l??f?.needsAttention??!1,m=v(hM,{className:p?`h-10 w-full`:`h-4 w-16`,"data-testid":`consumables-loading`,"aria-label":t(`uiLibrary.consumablesPanel.loading`,`Reading consumables…`)});return v($t,{title:t(`uiLibrary.consumablesPanel.title`,`Consumables`),icon:v(vt,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 overflow-y-auto`,collapsible:!0,open:p,onOpenChange:u,headerRight:p?void 0:f===null?m:v(NM,{summary:f,t}),children:a===void 0?m:a.items.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle italic leading-relaxed`,children:t(`uiLibrary.consumablesPanel.empty`,`No consumables reported.`)}):v(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:a.items.map(e=>v(OM,{item:e,busy:s===e.key,canReset:o,onReset:e=>void d(e)},e.key))})})}function FM(e){return e===null?`absent`:e.providers.length>0?`present`:`absent`}function IM(e){let t=X.capabilities.getCapability.useQuery({name:e});return t.status===`pending`?`pending`:t.status===`error`?`unknown`:FM(t.data)}var LM=[`object`,`motion`,`audio`];function RM(e,t,n){let r=[];for(let i of e){let e={motion:i.motion,object:i.object,audio:i.audio},a=e.motion+e.object+e.audio;if(a===0)continue;let o=Math.floor((i.bucketStart-t)/n),s=null,c=-1;for(let t of LM)e[t]>c&&(c=e[t],s=t);r.push({index:o,startMs:i.bucketStart,endMs:i.bucketStart+n,counts:e,total:a,dominant:s})}return r.toSorted((e,t)=>e.index-t.index)}function zM(e,t){return e<t.startMs?t.startMs-e:e>t.endMs?e-t.endMs:0}function BM(e,t){if(t.length===0)return null;let n=t.find(t=>e>=t.startMs&&e<=t.endMs);if(n)return{fromMs:e,toMs:n.endMs};let r=null,i=1/0;for(let n of t){let t=zM(e,n);t<i&&(i=t,r=n)}return r?{fromMs:r.startMs,toMs:r.endMs}:null}function VM(e,t,n){let r=n-t;if(r<=0)return 0;let i=(e-t)/r*100;return i<0?0:i>100?100:i}function HM(e,t){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0).getTime(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,0,0,0,0).getTime();return{fromMs:n,toMs:Math.max(n,Math.min(r,t))}}var UM=[24*36e5,12*36e5,6*36e5,36e5,15*6e4];function WM(e,t,n){if(t>=e.toMs-e.fromMs)return e;let r=Math.min(Math.max(n,e.fromMs+t),e.toMs);return{fromMs:r-t,toMs:r}}function GM(e,t,n){let r=e.toMs-e.fromMs,i=e.fromMs+n,a=e.toMs+n;return i<t.fromMs&&(i=t.fromMs,a=i+r),a>t.toMs&&(a=t.toMs,i=a-r),{fromMs:i,toMs:a}}var KM=[15*6e4,5*6e4,6e4,3e4,15e3,5e3];function qM(e){let t=e/100;for(let e of KM)if(e<=t)return e;return KM[KM.length-1]??5e3}function JM(e,t,n){if(n<=1)return[{pct:0,label:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}];let r=[];for(let i=0;i<n;i++){let a=e+i/(n-1)*(t-e),o=VM(a,e,t),s=new Date(a).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});r.push({pct:o,label:s})}return r}var YM=2;function XM(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-YM),i=Math.min(t-1,e+YM);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function ZM({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,itemNoun:i}){let a=q();if(t<=n)return null;let o=Math.ceil(t/n),s=(e-1)*n+1,l=Math.min(e*n,t),u=XM(e,o);return c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.pagination.showing`,`Showing {{start}}–{{end}} of {{total}} {{noun}}`,{start:s,end:l,total:t,noun:i??a(`uiLibrary.pagination.devices`,`devices`)})}),c(`span`,{className:`inline-flex items-center gap-1`,children:[v(`button`,{type:`button`,"aria-label":a(`uiLibrary.pagination.previous`,`Previous page`),disabled:e===1,onClick:()=>r(e-1),className:$(`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:v(ge,{className:`h-3 w-3`})}),u.map((t,n)=>t.kind===`ellipsis`?v(`span`,{className:`px-1 text-foreground-subtle/60 select-none`,children:`…`},`e-${n}`):v(`button`,{type:`button`,onClick:()=>r(t.n),className:$(`inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors`,t.n===e?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),children:t.n},`p-${t.n}`)),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.pagination.next`,`Next page`),disabled:e===o,onClick:()=>r(e+1),className:$(`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:v(It,{className:`h-3 w-3`})})]})]})}function QM({icon:e,title:t,description:n,action:r,className:i}){return c(`div`,{className:$(`flex flex-col items-center justify-center gap-3 py-12`,i),children:[e&&v(e,{className:`h-12 w-12 text-foreground-subtle`,"aria-hidden":`true`}),c(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[v(`p`,{className:`text-foreground-muted text-sm font-medium`,children:t}),n&&v(`p`,{className:`text-foreground-subtle text-xs max-w-xs`,children:n})]}),r&&v(`div`,{className:`mt-1`,children:r})]})}var $M={danger:{box:`border-danger/40 bg-danger/10`,icon:`text-danger`,title:`text-danger`,message:`text-danger`},warning:{box:`border-amber-500/40 bg-amber-500/10`,icon:`text-amber-600 dark:text-amber-400`,title:`text-amber-700 dark:text-amber-300`,message:`text-amber-700 dark:text-amber-300`}};function eN({message:e,title:t,onRetry:n,action:r,variant:i=`danger`,className:a}){let o=q(),s=$M[i],l=i===`warning`?zi:Ai;return c(`div`,{role:`alert`,className:$(`flex items-start gap-2.5 rounded border px-3 py-2.5`,s.box,a),children:[v(l,{className:$(`h-4 w-4 mt-0.5 shrink-0`,s.icon),"aria-hidden":`true`}),c(`div`,{className:`flex-1 min-w-0`,children:[t&&v(`p`,{className:$(`text-xs font-semibold`,s.title),children:t}),v(`div`,{className:$(`text-xs break-words`,s.message,t?`mt-0.5`:``),children:e})]}),r??(n&&c(`button`,{type:`button`,onClick:n,className:$(`shrink-0 inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium`,`border border-current/30 hover:bg-current/10 transition-colors`,s.message),children:[v(_e,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`uiLibrary.errorBox.retry`,`Retry`)]}))]})}var tN=[`chart-series-a`,`chart-series-b`,`chart-series-c`,`chart-series-d`,`chart-series-e`,`chart-series-f`,`chart-series-g`,`chart-series-h`],nN=[[],[6,4],[2,3]];function rN(e){let t=Math.max(0,Math.floor(e));return{token:tN[t%tN.length]??`chart-series-a`,dash:nN[Math.floor(t/tN.length)%nN.length]??[]}}var iN={"chart-series-a":`bg-chart-series-a`,"chart-series-b":`bg-chart-series-b`,"chart-series-c":`bg-chart-series-c`,"chart-series-d":`bg-chart-series-d`,"chart-series-e":`bg-chart-series-e`,"chart-series-f":`bg-chart-series-f`,"chart-series-g":`bg-chart-series-g`,"chart-series-h":`bg-chart-series-h`,border:`bg-border`},aN={"chart-series-a":`border-chart-series-a`,"chart-series-b":`border-chart-series-b`,"chart-series-c":`border-chart-series-c`,"chart-series-d":`border-chart-series-d`,"chart-series-e":`border-chart-series-e`,"chart-series-f":`border-chart-series-f`,"chart-series-g":`border-chart-series-g`,"chart-series-h":`border-chart-series-h`,border:`border-border`};function oN(e){return iN[e]}function sN(e){return aN[e]}function cN(e,t){if(typeof window>`u`||typeof getComputedStyle!=`function`)return`transparent`;let n=t??document.documentElement,r=getComputedStyle(n).getPropertyValue(`--color-${e}`).trim();return r.length>0?r:`transparent`}var lN=/^#[0-9a-f]{6}$/i;function uN(e,t){let n=Math.min(1,Math.max(0,t));return lN.test(e)?`${e}${Math.round(n*255).toString(16).padStart(2,`0`)}`:`color-mix(in srgb, ${e} ${String(Math.round(n*100))}%, transparent)`}function dN({title:e,actions:t,readoutTime:n,legend:r,summary:i,footer:a,placeholder:o,controls:s,className:l,children:u}){let d=r.length===1?r[0]:void 0;return c(`figure`,{className:$(`min-w-0 m-0`,l),"data-chart-frame":``,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1 min-w-0`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate min-w-0`,children:e}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n&&v(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:n}),d?.value!==void 0&&o===void 0&&v(mN,{entry:d}),t]})]}),o??v(`div`,{role:`img`,"aria-label":i,className:`min-w-0`,children:u}),o===void 0&&s,v(`p`,{className:`sr-only`,children:i}),r.length>1&&o===void 0&&v(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5 mt-1 list-none p-0 m-0`,children:r.map(e=>v(`li`,{className:`min-w-0`,children:v(pN,{entry:e})},e.id))}),a&&v(`div`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:a})]})}function fN({token:e,dashed:t}){return t?v(`span`,{"aria-hidden":`true`,className:$(`inline-block h-0 w-3 border-t-2 border-dashed shrink-0`,sN(e))}):v(`span`,{"aria-hidden":`true`,className:$(`inline-block h-2 w-2 rounded-[2px] shrink-0`,oN(e))})}function pN({entry:e}){return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] min-w-0`,e.muted?`text-foreground-subtle`:`text-foreground-muted`),children:[v(fN,{token:e.token,dashed:e.dashed}),v(`span`,{className:`truncate`,children:e.label}),e.value!==void 0&&v(`span`,{className:`tabular-nums text-foreground`,children:e.value})]})}function mN({entry:e}){return c(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[v(fN,{token:e.token,dashed:e.dashed}),e.value]})}function hN({message:e,height:t}){return v(`div`,{className:$(t===`sm`?`h-8`:t===`md`?`h-24`:`h-40`,`flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`),children:e})}function gN(e){let t=e.map(e=>[...e.points].sort((e,t)=>e.t-t.t)),n=t.map((t,n)=>_N(t,e[n]?.gapMs)),r=new Set;for(let e of t)for(let t of e)r.add(t.t);for(let e of n)for(let t of e)r.add(t);let i=[...r].sort((e,t)=>e-t),a=new Map;i.forEach((e,t)=>a.set(e,t));let o=()=>i.map(()=>void 0),s=[],c=[],l=[];return t.forEach((e,t)=>{let r=o(),i=o(),u=o();for(let e of n[t]??[]){let t=a.get(e);t!==void 0&&(r[t]=null,i[t]=null,u[t]=null)}for(let t of e){let e=a.get(t.t);e!==void 0&&(r[e]=t.v,t.min!==void 0&&(i[e]=t.min),t.max!==void 0&&(u[e]=t.max))}s.push(r),c.push(i),l.push(u)}),{xs:i,ys:s,mins:c,maxs:l}}function _N(e,t){if(t===void 0||!(t>0))return[];let n=[];for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];i&&a&&a.t-i.t>t&&n.push(i.t+1)}return n}function vN(e){if(e.length===0)return[];let t=null;for(let n of e){let e=yN(n);if(t=t===null?e:bN(t,e),t.length===0)return[]}return t??[]}function yN(e){let t=e.gapMs;if(t===void 0||!(t>0))return[];let n=[...e.points].sort((e,t)=>e.t-t.t),r=[];for(let e=1;e<n.length;e++){let i=n[e-1],a=n[e];i&&a&&a.t-i.t>t&&r.push({from:i.t,to:a.t})}return r}function bN(e,t){let n=[];for(let r of e)for(let e of t){let t=Math.max(r.from,e.from),i=Math.min(r.to,e.to);i>t&&n.push({from:t,to:i})}return n}function xN(e){let t=[];return e.forEach((e,n)=>{let r=n===0?null:t[n-1];t.push(e.map((e,t)=>{if(e===void 0)return;if(e===null)return null;if(r==null)return e;let n=r[t];return n===null?null:n===void 0?e:n+e}))}),t}function SN(e,t,n){for(let r=Math.min(n,e.length-1);r>=0;r--){let e=t[r];if(e!==void 0)return e}return null}function CN(e,t,n,r=null){let i=[...e].filter(e=>e.t<n).sort((e,t)=>e.t-t.t),a=[],o=t,s=r;for(let e of i){if(e.t<=t){s=e.state;continue}e.state!==s&&(a.push({from:o,to:e.t,state:s}),o=e.t,s=e.state)}return n>o&&a.push({from:o,to:n,state:s}),a.filter(e=>e.to>e.from&&e.state!==null)}function wN(e){let t=new Map;for(let n of e)n.state!==null&&t.set(n.state,(t.get(n.state)??0)+Math.max(0,n.to-n.from));return t}function TN(e,t){for(let n of e)if(t>=n.from&&t<n.to)return n.state;return null}var EN=6e4,DN=60*EN,ON=24*DN;function kN(e){if(!(e>0))return`0s`;if(e<EN)return`${String(Math.round(e/1e3))}s`;if(e<DN)return`${String(Math.floor(e/EN))}m`;if(e<ON){let t=Math.floor(e/DN),n=Math.floor(e%DN/EN);return n>0?`${String(t)}h ${String(n)}m`:`${String(t)}h`}let t=Math.floor(e/ON),n=Math.floor(e%ON/DN);return n>0?`${String(t)}d ${String(n)}h`:`${String(t)}d`}var AN={hour:`2-digit`,minute:`2-digit`},jN={hour:`2-digit`,minute:`2-digit`,second:`2-digit`},MN={day:`2-digit`,month:`short`},NN={month:`short`,year:`2-digit`};function PN(e,t){let n=new Date(e);return t<10*EN?n.toLocaleTimeString(void 0,jN):t<=2*ON?n.toLocaleTimeString(void 0,AN):t<=120*ON?n.toLocaleDateString(void 0,MN):n.toLocaleDateString(void 0,NN)}function FN(e,t){let n=new Date(e);return t<=2*ON?n.toLocaleTimeString(void 0,t<10*EN?jN:AN):`${n.toLocaleDateString(void 0,MN)} ${n.toLocaleTimeString(void 0,AN)}`}var IN=[1,2,5,10],LN=[1,2,4,8,16,32,64,128,256,512,1024],RN=[1,1.5,2,2.5,3,4,5],zN=[4,3,5,2],BN=1e-9;function VN(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return RN.some(e=>Math.abs(t-e)<BN)}let n=e/10**Math.floor(Math.log10(e));return RN.some(e=>Math.abs(n-e)<BN)}function HN(e,t,n=`linear`){let r=0;for(let t of e)t!==null&&Number.isFinite(t)&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of LN){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of IN){let t=e*i;if(t>=r)return t}return 10*i}function UN(e,t=`linear`){if(!Number.isFinite(e)||e<=0)return[];let n=zN.find(n=>VN(e/n,t))??zN[zN.length-1]??2,r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}function WN(e){let t=1/0,n=-1/0;for(let r of e)r===null||!Number.isFinite(r)||(r<t&&(t=r),r>n&&(n=r));if(!Number.isFinite(t)||!Number.isFinite(n))return null;if(n-t<1e-9)return[t-1,n+1];let r=(n-t)*.1,i=n-t+2*r,a=10**Math.floor(Math.log10(i/4)),o=[1,2,2.5,5,10].map(e=>e*a).find(e=>i/e<=6)??a*10;return[Math.floor((t-r)/o)*o,Math.ceil((n+r)/o)*o]}var GN=2.5;function KN(e){return e*GN}var qN=10;function JN(){let e=typeof document<`u`&&document.body?getComputedStyle(document.body).fontFamily:`sans-serif`;return`${String(qN)}px ${e}`}function YN(e,t=!0){return{show:t,scale:`x`,side:2,size:t?22:0,gap:4,font:JN(),stroke:()=>cN(`foreground-subtle`),grid:{show:!1},ticks:{show:t,stroke:()=>cN(`border`),width:1,size:3},space:70,values:(t,n)=>n.map(t=>PN(t,e()))}}function XN(e,t){if(t.fixed)return t.fixed;let n=e.filter(e=>typeof e==`number`&&Number.isFinite(e));return(t.zeroBased??!0)&&n.every(e=>e>=0)?[0,HN(n,t.floor??0,t.scale??`linear`)||1]:WN(n)??[0,1]}var ZN=[1,2,2.5,5];function QN(e,t){let[n,r]=e;if(n===0&&r>0)return[...UN(r,t.scale??`linear`)];let i=r-n;if(!(i>0))return[n];let a=10**Math.floor(Math.log10(i/4)),o=[...ZN,10].map(e=>e*a).find(e=>i/e<=6)??i/4,s=[];for(let e=Math.ceil(n/o-1e-9)*o;e<=r+1e-9;e+=o)s.push(Math.round(e/o)*o);return s}function $N(e,t,n,r){return{scale:e,side:t,font:JN(),size:(e,t)=>{let n=(t??[]).reduce((e,t)=>Math.max(e,String(t).length),0);return Math.max(28,Math.min(72,n*6+10))},gap:4,stroke:()=>cN(`foreground-subtle`),grid:{show:r,stroke:()=>uN(cN(`foreground-subtle`),.18),width:1},ticks:{show:!1},values:(e,t)=>t.map(e=>n(e))}}function eP(e){return{y:!1,drag:{x:!1,y:!1,setScale:!1},points:{size:6,width:1.5},focus:{prox:16},...e===void 0?{}:{sync:{key:e,setSeries:!1}}}}function tP(e){return t=>{let n=e();if(n.length===0)return;let r=t.ctx;r.save(),r.fillStyle=uN(cN(`foreground-subtle`),.12);for(let e of n){let n=t.valToPos(e.from,`x`,!0),i=t.valToPos(e.to,`x`,!0);r.fillRect(n,t.bbox.top,Math.max(1,i-n),t.bbox.height)}r.restore()}}var nP=new Set([`B`,`bytes`,`byte`]);function rP(e){return e!=null&&nP.has(e)}var iP=new Set([`°C`,`°F`,`K`,`dBFS`,`dB`,`dBm`,`hPa`,`mbar`,`inHg`]);function aP(e){return rP(e)?{scale:`bytes`}:e===`%`?{floor:10}:e!=null&&iP.has(e)?{zeroBased:!1}:{}}function oP(e){if(!Number.isFinite(e))return`—`;if(Math.abs(e)<1024)return`${String(Math.round(e))} B`;let t=[`KB`,`MB`,`GB`,`TB`,`PB`],n=e/1024,r=`KB`;for(let e of t){if(r=e,Math.abs(n)<1024)break;n/=1024}return`${Math.abs(n)<100?n.toFixed(1):n.toFixed(0)} ${r}`}function sP(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e3?Math.round(e).toLocaleString():t>=100?e.toFixed(0):t>=10?cP(e.toFixed(1)):t>=1?cP(e.toFixed(2)):t===0?`0`:cP(e.toFixed(3))}function cP(e){return e.includes(`.`)?e.replace(/\.?0+$/,``):e}function lP(e,t){if(rP(t))return oP(e);let n=sP(e);return t==null||t===``||t===`count`?n:t===`%`?`${n}%`:`${n} ${t}`}function uP({options:e,value:t,onChange:n,ariaLabel:r,className:i}){return e.length<2?null:v(`div`,{role:`radiogroup`,"aria-label":r,className:$(`inline-flex items-center gap-0.5 border border-border rounded-md p-0.5 bg-background`,i),children:e.map(({id:e,label:r})=>{let i=t===e;return v(`button`,{type:`button`,role:`radio`,"aria-checked":i,onClick:()=>n(e),className:$(`px-2 py-0.5 rounded text-[10px] font-medium transition-colors`,i?`bg-primary/10 text-primary`:`text-foreground-subtle hover:text-foreground`),children:r},e)})})}function dP(e,t){let n=[];for(let r=0;r<t;r++)n.push(e.map(e=>{let t=null;for(let n=0;n<=r;n++){let r=e.values[n];r!=null&&(t=(t??0)+r)}return t}));return n}function fP(e,t){let n=Array.from({length:t},()=>0),r=!1;for(let i of e)for(let e=0;e<t;e++){let t=i.values[e];t!=null&&(r=!0,n[e]=(n[e]??0)+t)}return{perLayer:n,total:n.reduce((e,t)=>e+t,0),known:r}}function pP(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(i&&n>=i.t&&n<i.t+t)return r}return null}var mP=`—`,hP=new Set([`information`,`duration`,`duration-ms`,`none`,`device`,`count`,`index`,`ratio`,`humidity`,`percentage`]),gP={selection:{visible:!1,dataX:null,anchorX:0,anchorY:0,pinned:!1},gesture:null,lockHorizontalScroll:!1},_P=[{placed:`right`,vertical:`above`},{placed:`left`,vertical:`above`},{placed:`right`,vertical:`below`},{placed:`left`,vertical:`below`}];function vP(e,t){if(e.length===0||!Number.isFinite(t))return null;let n=0,r=e.length-1;for(;n<r;){let i=Math.floor((n+r)/2);(e[i]??0)<t?n=i+1:r=i}let i=n,a=Math.max(0,i-1);return Math.abs((e[a]??0)-t)<=Math.abs((e[i]??0)-t)?a:i}function yP(e){if(!(e.plotWidth>0)||!Number.isFinite(e.localX))return null;let t=e.localX-e.plotLeft;if(!e.clamp&&(t<0||t>e.plotWidth))return null;let n=Math.min(e.plotWidth,Math.max(0,t));return e.xMin+n/e.plotWidth*(e.xMax-e.xMin)}function bP(e,t,n){if(e.length===0||!Number.isFinite(n))return null;let r=0,i=1/0;for(let a=0;a<e.length;a++){let o=e[a]?.t;if(o===void 0)continue;let s=o+t;if(n>=o&&n<s)return a;let c=n<o?o-n:n-s;c<i&&(i=c,r=a)}return r}function xP(e,t,n){if(e.length===0)return null;let r=[...e].sort((e,t)=>e-t);if(t===null||!Number.isFinite(t))return n>0?r[0]??null:r[r.length-1]??null;let i=0,a=1/0;for(let e=0;e<r.length;e++){let n=Math.abs((r[e]??0)-t);n<a&&(a=n,i=e)}let o=i+n;return o<0||o>=r.length?r[i]??null:r[o]??null}function SP(e,t,n,r){return{visible:!0,dataX:e,anchorX:t,anchorY:n,pinned:r}}function CP(e,t,n){return{selection:e,gesture:t,lockHorizontalScroll:n}}function wP(e,t,n){if(e.axis!==`pending`)return e.axis;let r=Math.abs(t-e.originX),i=Math.abs(n-e.originY);return r<10&&i<10?`pending`:r>=i?`x`:`y`}function TP(e,t){return t.kind===`mouse`?e:CP(e.selection,{kind:t.kind,originX:t.x,originY:t.y,axis:`pending`},!1)}function EP(e,t){if(t.kind===`mouse`)return t.dataX===null?e.selection.pinned?e:gP:CP(SP(t.dataX,t.x,t.y,!1),null,!1);let n=e.gesture;if(n===null)return e;let r=wP(n,t.x,t.y),i={...n,axis:r};return r!==`x`||t.dataX===null?CP(e.selection,i,!1):CP(SP(t.dataX,t.x,t.y,!0),i,!0)}function DP(e,t){return t.kind===`mouse`||e.gesture===null?e:e.gesture.axis===`y`||e.gesture.axis===`x`?CP(e.selection,null,!1):e.selection.visible&&e.selection.pinned||t.dataX===null?gP:CP(SP(t.dataX,t.x,t.y,!0),null,!1)}function OP(e,t){switch(t.type){case`hide`:case`outside`:return gP;case`leave`:return e.selection.pinned?CP(e.selection,null,!1):gP;case`hover`:return CP(SP(t.dataX,t.anchorX,t.anchorY,!1),null,!1);case`key`:return CP(SP(t.dataX,t.anchorX,t.anchorY,!0),null,!1);case`down`:return TP(e,t);case`move`:return EP(e,t);case`up`:return DP(e,t);default:return t}}function kP(e){if(e==null||e.length===0)return;let t;for(let n of Object.keys(Xi))if(!(!Gi(n)||hP.has(n))&&Xi[n]===e){if(t!==void 0)return;t=n}return t}function AP(e,t,n){return e.length===0?n:t.length===0?e:t===`%`?`${e}%`:`${e} ${t}`}function jP(e){let t=e.unknownLabel??mP;if(e.value===null||!Number.isFinite(e.value))return t;let n=e.quantity===`device`?void 0:e.quantity??kP(e.unit);if(n===void 0)return lP(e.value,e.unit??null);let r=Va({value:e.value,quantity:n,preference:e.preference,precision:e.precision});return AP(r.text,r.unit,t)}function MP(e,t){return t.length===0?e:`${e}, ${t.map(e=>`${e.label} ${e.value}`).join(`, `)}`}function NP(e,t){return{heading:e,lines:t,liveText:MP(e,t)}}function PP(e){let t=e.series.filter(e=>e.visible!==!1).map(t=>({id:t.id,label:t.label,value:jP({value:t.value,quantity:t.quantity,unit:t.unit,precision:t.precision,preference:e.preference})}));return NP(e.timeLabel,t)}function FP(e,t){for(let n of e)if(t>=n.from&&t<n.to)return{state:n.state,spanMs:Math.max(0,n.to-n.from)};return null}function IP(e,t){return e===null||e.length===0?mP:t===null||!(t>0)?e:`${e} · ${kN(t)}`}function LP(e){let t=e.rows.map(e=>({id:e.id,label:e.label,value:IP(e.stateLabel,e.spanMs)}));return NP(e.timeLabel,t)}function RP(e,t,n){return`${FN(e,n)} – ${FN(e+t,n)}`}function zP(e){let t=e.layers.map(t=>({id:t.id,label:t.label,value:jP({value:t.value,quantity:t.quantity,unit:t.unit,precision:t.precision,preference:e.preference})}));return NP(e.rangeLabel,t)}function BP(e,t,n){return{left:e.placed===`right`?t.anchorX+n:t.anchorX-n-t.tooltipWidth,top:e.vertical===`above`?t.anchorY-n-t.tooltipHeight:t.anchorY+n}}function VP(e,t,n){return e>=4&&t>=4&&e+n.tooltipWidth<=n.boundsWidth-4&&t+n.tooltipHeight<=n.boundsHeight-4}function HP(e,t,n){return n.anchorX>=e&&n.anchorX<=e+n.tooltipWidth&&n.anchorY>=t&&n.anchorY<=t+n.tooltipHeight}function UP(e,t,n){let r=Math.max(4,n.boundsWidth-4-n.tooltipWidth),i=Math.max(4,n.boundsHeight-4-n.tooltipHeight);return{left:Math.min(Math.max(e,4),r),top:Math.min(Math.max(t,4),i)}}function WP(e){let t=e.gap??12,n=null;for(let r of _P){let i=BP(r,e,t),a=UP(i.left,i.top,e),o={...r,...a};if(n===null&&!HP(a.left,a.top,e)&&(n=o),VP(i.left,i.top,e)&&!HP(i.left,i.top,e))return{...r,...i}}if(n!==null)return n;let r=_P[0]??{placed:`right`,vertical:`above`},i=UP(BP(r,e,t).left,BP(r,e,t).top,e);return{...r,...i}}E(),Do();function GP(e){return e===`mouse`?`mouse`:`touch`}function KP(e,t,n,r,i,a){let o=n.getBoundingClientRect(),s=e-o.left,c=t-o.top;if(r!==null){let n=r.over.getBoundingClientRect(),i=e-n.left,o=t-n.top,l=r.bbox.left,u=r.bbox.left+r.bbox.width,d=i>=l&&i<=u&&o>=r.bbox.top&&o<=r.bbox.top+r.bbox.height;return!d&&!a?{dataX:null,anchorX:s,anchorY:c,inside:!1}:{dataX:r.posToVal(Math.min(u,Math.max(l,i)),`x`),anchorX:s,anchorY:c,inside:d}}let l=yP({localX:s,plotLeft:0,plotWidth:o.width,xMin:i.xMin,xMax:i.xMax,clamp:a});return{dataX:l,anchorX:s,anchorY:c,inside:l!==null}}function qP(e,t,n,r){if(n!==null&&t!==null){let r=n.over.getBoundingClientRect(),i=t.getBoundingClientRect();return{x:r.left-i.left+n.valToPos(e,`x`),y:r.top-i.top+n.bbox.top+n.bbox.height/2}}let i=t?.getBoundingClientRect().width??0,a=t?.getBoundingClientRect().height??0,o=r.xMax-r.xMin,s=o===0?0:(e-r.xMin)/o;return{x:Math.min(1,Math.max(0,s))*i,y:a/2}}function JP(e,t){if(e!==null){if(t===null){e.setCursor({left:-10,top:-10});return}e.setCursor({left:e.valToPos(t,`x`),top:e.bbox.top+e.bbox.height/2})}}function YP({view:e}){let t=f(null);return u(()=>{let n=t.current;if(n===null)return;let r=WP({anchorX:e.anchorX,anchorY:e.anchorY,tooltipWidth:n.offsetWidth,tooltipHeight:n.offsetHeight,boundsWidth:e.boundsWidth,boundsHeight:e.boundsHeight});n.style.left=`${String(r.left)}px`,n.style.top=`${String(r.top)}px`},[e]),c(`div`,{ref:t,role:`tooltip`,"data-chart-tooltip":``,className:`pointer-events-none absolute z-20 max-w-64 rounded-md border border-border bg-background-elevated px-2 py-1 text-foreground shadow-md`,children:[v(`p`,{className:`m-0 text-[10px] tabular-nums text-foreground-subtle`,children:e.body.heading}),v(`ul`,{className:`m-0 list-none p-0`,children:e.body.lines.map(e=>c(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[v(`span`,{className:`min-w-0 truncate text-foreground-muted`,children:e.label}),v(`span`,{className:`shrink-0 tabular-nums`,children:e.value})]},e.id))})]})}function XP({spec:e,plotRef:t,kind:n,label:r,inline:i=!1,children:a}){let o=f(null),s=f(e);s.current=e;let l=f(gP),u=f(null),[d,p]=C(null),m=d!==null&&l.current.selection.pinned,h=_(e=>{l.current=e;let t=s.current,n=o.current,r=e.selection.visible?e.selection.dataX:null,i=t!==null&&r!==null?t.resolve(r):null;if(i===null||r===null){p(null),u.current!==null&&(u.current=null,t?.onDataX?.(null));return}p({body:i,anchorX:e.selection.anchorX,anchorY:e.selection.anchorY,boundsWidth:n?.getBoundingClientRect().width??0,boundsHeight:n?.getBoundingClientRect().height??0}),u.current!==r&&(u.current=r,t?.onDataX?.(r))},[]);b(()=>{let e=o.current;if(e===null)return;let n=(n,r)=>{let i=s.current;return i===null?null:KP(n.clientX,n.clientY,e,t.current,i,r)},r=e=>{if(GP(e.pointerType)===`mouse`)return;let t=n(e,!1);t!==null&&h(OP(l.current,{type:`down`,kind:`touch`,x:t.anchorX,y:t.anchorY,dataX:t.dataX}))},i=r=>{let i=GP(r.pointerType),a=l.current.gesture?.axis===`x`,o=n(r,i!==`mouse`&&a);if(o===null)return;if(i===`mouse`){if(!o.inside||o.dataX===null){h(OP(l.current,{type:`leave`})),l.current.selection.visible||JP(t.current,null);return}h(OP(l.current,{type:`hover`,dataX:o.dataX,anchorX:o.anchorX,anchorY:o.anchorY})),JP(t.current,o.dataX);return}let s=OP(l.current,{type:`move`,kind:`touch`,x:o.anchorX,y:o.anchorY,dataX:o.dataX});s.lockHorizontalScroll&&(r.preventDefault(),r.pointerId!==0&&!e.hasPointerCapture(r.pointerId)&&e.setPointerCapture(r.pointerId)),h(s),s.selection.dataX!==null&&s.selection.visible&&JP(t.current,s.selection.dataX)},a=e=>{if(GP(e.pointerType)===`mouse`)return;let r=n(e,l.current.gesture?.axis===`x`);if(r===null)return;let i=OP(l.current,{type:`up`,kind:`touch`,x:r.anchorX,y:r.anchorY,dataX:r.dataX});h(i),JP(t.current,i.selection.visible?i.selection.dataX:null)},c=e=>{if(GP(e.pointerType)!==`mouse`)return;let n=OP(l.current,{type:`leave`});h(n),n.selection.visible||JP(t.current,null)};return e.addEventListener(`pointerdown`,r),e.addEventListener(`pointermove`,i),e.addEventListener(`pointerup`,a),e.addEventListener(`pointercancel`,a),e.addEventListener(`pointerleave`,c),()=>{e.removeEventListener(`pointerdown`,r),e.removeEventListener(`pointermove`,i),e.removeEventListener(`pointerup`,a),e.removeEventListener(`pointercancel`,a),e.removeEventListener(`pointerleave`,c)}},[h,t]),b(()=>{if(!m)return;let e=e=>{let n=o.current;n!==null&&e.target instanceof Node&&n.contains(e.target)||(h(OP(l.current,{type:`outside`})),JP(t.current,null))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[h,m,t]);let g=e=>{let n=s.current;if(n===null)return;if(e.key===`Escape`){e.preventDefault(),h(OP(l.current,{type:`hide`})),JP(t.current,null);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let r=l.current.selection.visible?l.current.selection.dataX:null,i=xP(n.stops,r,e.key===`ArrowRight`?1:-1);if(i===null)return;let a=qP(i,o.current,t.current,n);h(OP(l.current,{type:`key`,dataX:i,anchorX:a.x,anchorY:a.y})),JP(t.current,i)},y=e=>{o.current=e},x=$(`relative min-w-0 touch-pan-y outline-none focus-visible:ring-2 focus-visible:ring-primary`,i?`inline-block w-full`:`w-full`),S=d===null?null:v(YP,{view:d}),w=d!==null&&typeof document<`u`?Oo(v(`div`,{className:`sr-only`,"aria-live":`polite`,"data-chart-tooltip-live":``,children:d.body.liveText}),document.body):null;return c(i?`span`:`div`,{ref:y,className:x,"data-chart-shell":``,"data-chart-kind":n,tabIndex:e===null?void 0:0,"aria-label":r,onKeyDown:g,children:[a,S,w]})}E();var ZP=null;function QP(){if(typeof document>`u`||typeof window>`u`||typeof window.matchMedia!=`function`)return!1;try{return document.createElement(`canvas`).getContext(`2d`)!==null}catch{return!1}}function $P(){return ZP===null&&(ZP=QP()?a(()=>import(`./uPlot.esm-B6hGABOr.js`).then(e=>e.default),[],import.meta.url).catch(()=>null):Promise.resolve(null)),ZP}function eF({optionsKey:e,buildOptions:t,data:n,height:r,onInstance:i,className:a,inline:o=!1,tooltip:s=null,kind:c,label:l}){let u=f(null),d=f(null),[p,m]=C(null),h=f({buildOptions:t,data:n,onInstance:i});h.current={buildOptions:t,data:n,onInstance:i},b(()=>{let e=!0;return $P().then(t=>{e&&t!==null&&m(()=>t)}),()=>{e=!1}},[]),b(()=>{let e=u.current;if(p===null||e===null)return;let t=Math.max(1,Math.floor(e.clientWidth)),n=new p({...h.current.buildOptions(t,p),width:t,height:r},h.current.data,e);return n.over.style.touchAction=`pan-y`,n.root.style.touchAction=`pan-y`,d.current=n,h.current.onInstance?.(n),()=>{h.current.onInstance?.(null),n.destroy(),d.current=null}},[p,e,r]),b(()=>{d.current?.setData(n)},[n]),b(()=>{let e=u.current;if(e===null||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=Math.floor(e[0]?.contentRect.width??0),n=d.current;n!==null&&t>0&&t!==n.width&&n.setSize({width:t,height:r})});return t.observe(e),()=>t.disconnect()},[r]),b(()=>{if(typeof MutationObserver>`u`)return;let e=new MutationObserver(()=>d.current?.redraw(!1,!0));return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]);let g=e=>{u.current=e};return v(XP,{spec:s,plotRef:d,kind:c,label:l,inline:o,children:o?v(`span`,{ref:g,className:a??`block w-full min-w-0`,"data-chart-plot":``}):v(`div`,{ref:g,className:a??`w-full min-w-0`,"data-chart-plot":``})})}E();function tF({title:e,layers:t,buckets:n,bucketMs:r,range:i,unit:a=null,formatValue:o,displayPreference:s,height:l,stacked:u,showTotal:d=!1,syncKey:m,pending:h=!1,emptyMessage:g,actions:y,footer:b,windowToggle:x,compact:S=!1,minBarFraction:w=0,selectedIndex:T=null,onSelect:E,bucketLabel:D,bucketTestId:O,className:k}){let A=q(),j=l??(S?24:100),M=u??t.length>1,N=_(e=>(o??lP)(e,a),[o,a]),F=p(()=>M?dP(n,t.length):t.map((e,t)=>n.map(e=>e.values[t]??null)),[n,t,M]),I=p(()=>fP(n,t.length),[n,t.length]),[L,R]=C(null),z=p(()=>({xMin:i.from,xMax:i.to,stops:n.map(e=>e.t),resolve:e=>{let o=bP(n,r,e);if(o===null)return null;let c=n[o];return c===void 0?null:zP({rangeLabel:RP(c.t,r,i.to-i.from),preference:s,layers:t.map((e,t)=>({id:e.id,label:e.label,value:c.values[t]??null,unit:a}))})},onDataX:e=>{R(e===null?null:bP(n,r,e))}}),[n,r,i,t,a,s]),B=f({buckets:n,tops:F,range:i,selectedIndex:T,onSelect:E,bucketLabel:D,fmt:N});B.current={buckets:n,tops:F,range:i,selectedIndex:T,onSelect:E,bucketLabel:D,fmt:N};let V=`${t.map(e=>`${e.id}:${e.colorIndex}`).join(`,`)}#${S?`C`:``}#${M?`S`:``}#${m??``}#${String(r)}`,H=p(()=>{let e=F.at(-1)??[],t=M?e:n.map((e,t)=>Math.max(...F.map(e=>e[t]??0)));return[n.map(e=>e.t),t.map(e=>e??null)]},[n,F,M,T]),U=_(()=>{let e={floor:0};return{ms:1,legend:{show:!1},padding:S?[0,0,0,0]:[8,30,0,0],scales:{x:{time:!0,range:()=>[B.current.range.from,B.current.range.to]},y:{range:t=>{let n=XN([...t.data[1]??[]],e);return[n[0],n[1]]}}},axes:S?[{show:!1,scale:`x`},{show:!1,scale:`y`}]:[YN(()=>B.current.range.to-B.current.range.from),{...$N(`y`,3,e=>B.current.fmt(e),!0),splits:(t,n,r,i)=>QN([r,i],e)}],series:[{},{scale:`y`,stroke:()=>`transparent`,points:{show:!1},paths:()=>null}],cursor:{...eP(m),points:{show:!1}},hooks:{draw:[e=>{let{buckets:n,tops:i,selectedIndex:a}=B.current,o=e.ctx,s=e.valToPos(0,`y`,!0),c=w*e.bbox.height,l=Math.max(1,Math.round(devicePixelRatio));o.save(),n.forEach((n,u)=>{let d=e.valToPos(n.t,`x`,!0),f=e.valToPos(n.t+r,`x`,!0),p=Math.max(1,f-d-l),m=s;t.forEach((n,r)=>{let a=i[r]?.[u];if(a==null||!(a>(M&&r>0?i[r-1]?.[u]??0:0)))return;let f=e.valToPos(a,`y`,!0),h=M?m:s;r===t.length-1&&s-f<c&&(f=s-c),o.fillStyle=cN(rN(n.colorIndex).token);let g=Math.max(1,h-f-(M&&r>0?l:0));o.fillRect(d,f,p,g),m=f}),a===u&&(o.strokeStyle=cN(`primary`),o.lineWidth=l*1.5,o.strokeRect(d,e.bbox.top+l,p,e.bbox.height-2*l))}),o.restore()}],setCursor:[e=>{let t=e.cursor.left??-1,n=t<0?null:pP(B.current.buckets,r,e.posToVal(t,`x`));R(n);let i=n===null?void 0:B.current.buckets[n],a=i===void 0||n===null?``:B.current.bucketLabel?.(i,n)??``;e.over.title=a}],ready:[e=>{e.over.addEventListener(`click`,()=>{let t=e.cursor.left??-1;if(t<0)return;let n=pP(B.current.buckets,r,e.posToVal(t,`x`));n!==null&&B.current.onSelect?.(n)})}]}}},[V,w]),ee=i.to-i.from,W=L===null?void 0:n[L],G=t.map((e,t)=>{let n=W?W.values[t]:I.known?I.perLayer[t]:void 0;return{id:e.id,label:e.label,token:rN(e.colorIndex).token,value:n==null?W?`—`:void 0:N(n)}}),te=A(`uiLibrary.charts.barSummary`,`{{title}}, {{from}} to {{to}}: total {{total}}`,{title:e,from:PN(i.from,ee),to:PN(i.to,ee),total:I.known?N(I.total):A(`uiLibrary.charts.unknown`,`unknown`)}),ne=E===void 0?null:v(`div`,{className:`sr-only`,children:n.map((e,t)=>{let n=e.values.reduce((e,t)=>e+(t??0),0);return n<=0?null:v(`button`,{type:`button`,"data-testid":O,"aria-pressed":T===t,onClick:()=>E(t),children:D?.(e,t)??`${PN(e.t,ee)} ${N(n)}`},e.t)})}),re=v(eF,{optionsKey:V,buildOptions:U,data:H,height:j,tooltip:z,kind:`bars`,label:e});if(S)return c(`div`,{className:$(`relative min-w-0`,k),children:[v(`div`,{role:`img`,"aria-label":te,children:re}),ne]});let K=d&&I.known?A(`uiLibrary.charts.total`,`Total {{value}}`,{value:N(I.total)}):null,ie=!I.known,ae=j<=64?`sm`:j<=120?`md`:`lg`;return v(dN,{title:e,actions:c(P,{children:[K&&v(`span`,{className:`text-[11px] tabular-nums text-foreground`,children:K}),x&&v(uP,{...x}),y]}),readoutTime:W?FN(W.t,ee):null,legend:t.length>1||W?G:[],summary:te,footer:b,placeholder:h?v(hN,{message:A(`uiLibrary.charts.loading`,`Loading…`),height:ae}):ie?v(hN,{message:g??A(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`),height:ae}):void 0,controls:ne,className:k,children:re})}E();var nF=[`motion`,`object`,`audio`],rF={motion:6,object:5,audio:4},iF=.15;function aF({windowFrom:e,windowTo:t,buckets:n,selectedIndex:r,onSelectBucket:i}){let a=q(),o=p(()=>n.filter(e=>e.total>0&&e.dominant!==null),[n]),s=p(()=>o.map(e=>({t:e.startMs,values:nF.map(t=>e.counts[t])})),[o]),c=p(()=>nF.map(e=>({id:e,label:a(`uiLibrary.eventHeatmap.kind.${e}`,e),colorIndex:rF[e]})),[a]),l=n[0],u=l?Math.max(1,l.endMs-l.startMs):1,d=r===null?null:o.findIndex(e=>e.index===r);return v(`div`,{className:`rounded bg-background/40`,children:v(tF,{compact:!0,title:a(`uiLibrary.eventHeatmap.title`,`Event density`),layers:c,buckets:s,bucketMs:u,range:{from:e,to:t},stacked:!0,minBarFraction:iF,selectedIndex:d===null||d<0?null:d,onSelect:e=>{let t=o[e];t&&i(t.index)},bucketTestId:`heatmap-bar`,bucketLabel:(e,t)=>{let n=o[t];return n?a(`uiLibrary.eventHeatmap.bucketTitle`,`{{time}} · motion {{motion}} · object {{object}}`,{time:new Date(n.startMs).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),motion:n.counts.motion,object:n.counts.object}):``}})})}function oF(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function sF(e){let t=e.split(`-`),n=t[0]===void 0?NaN:parseInt(t[0],10),r=t[1]===void 0?NaN:parseInt(t[1],10),i=t[2]===void 0?NaN:parseInt(t[2],10);return isNaN(n)||isNaN(r)||isNaN(i)?null:new Date(n,r-1,i)}function cF({day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i}){let a=q(),o=e=>{let n=sF(e.target.value);n!==null&&t(n)},s=n.toMs-n.fromMs,l=(()=>{let e=0,t=1/0;for(let n=0;n<UM.length;n++){let r=UM[n];if(r===void 0)continue;let i=Math.abs(r-s);i<t&&(t=i,e=n)}return e})(),u=n.toMs,d=()=>{let e=UM[Math.min(l+1,UM.length-1)];e!==void 0&&i(WM(r,e,u))},f=()=>{let e=UM[Math.max(l-1,0)];e!==void 0&&i(WM(r,e,u))},p=l<UM.length-1,m=l>0,h=Math.max(1,Math.round(s*.9)),g=n.fromMs>r.fromMs,_=n.toMs<r.toMs;return c(`div`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`date`,value:oF(e),max:oF(new Date),onChange:o,className:`rounded border border-border bg-background px-2 py-0.5 text-[11px] text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":a(`uiLibrary.timelineControls.day`,`Select recording day`)}),c(`div`,{className:`ml-auto flex items-center gap-1`,children:[v(`button`,{type:`button`,onClick:()=>{i(GM(n,r,-h))},disabled:!g,title:a(`uiLibrary.timelineControls.earlierTitle`,`Earlier (pan back)`),"aria-label":a(`uiLibrary.timelineControls.earlier`,`Pan earlier`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(ge,{size:14})}),v(`button`,{type:`button`,onClick:()=>{i(GM(n,r,h))},disabled:!_,title:a(`uiLibrary.timelineControls.laterTitle`,`Later (pan forward)`),"aria-label":a(`uiLibrary.timelineControls.later`,`Pan later`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(It,{size:14})}),v(`span`,{className:`mx-0.5 h-3 w-px bg-border`,"aria-hidden":`true`}),v(`button`,{type:`button`,onClick:f,disabled:!m,title:a(`uiLibrary.timelineControls.zoomOut`,`Zoom out`),"aria-label":a(`uiLibrary.timelineControls.zoomOut`,`Zoom out`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(Kr,{size:13})}),v(`button`,{type:`button`,onClick:d,disabled:!p,title:a(`uiLibrary.timelineControls.zoomIn`,`Zoom in`),"aria-label":a(`uiLibrary.timelineControls.zoomIn`,`Zoom in`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(kr,{size:13})})]}),v(`span`,{className:`text-[9px] text-foreground-subtle`,children:lF(s)})]})}function lF(e){let t=e/36e5;if(t>=24)return`24h`;if(t>=1)return`${Math.round(t)}h`;let n=e/6e4;return`${Math.round(n)}m`}E();var uF=18e3/100;function dF({day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i,buckets:a,selectedBucketIndex:o,onSelectBucket:s,densityLoading:l}){let u=q(),d=f(null),p=_(e=>{let t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;t!==0&&(e.preventDefault(),i(GM(n,r,t*uF)))},[n,r,i]),m=JM(n.fromMs,n.toMs,5);return c(`div`,{className:`space-y-1`,children:[v(cF,{day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i}),c(`div`,{ref:d,onWheel:p,className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:u(`uiLibrary.clipBandBar.eventsDensity`,`Events · density`)}),l?v(`div`,{className:`h-6 animate-pulse rounded bg-background/40`}):v(aF,{windowFrom:n.fromMs,windowTo:n.toMs,buckets:a,selectedIndex:o,onSelectBucket:s}),v(`div`,{className:`relative h-3`,children:m.map(e=>v(`span`,{className:`absolute -translate-x-1/2 text-[9px] text-foreground-subtle`,style:{left:`${String(e.pct)}%`},children:e.label},e.pct))})]})]})}E();var fF=Kn(`camstack:vod-playback`,{request:null,play:()=>{},clear:()=>{}});function pF({children:e}){let[t,n]=C(null),r=p(()=>({request:t,play:e=>n(e),clear:()=>n(null)}),[t]);return v(fF.Provider,{value:r,children:e})}function mF(){return I(fF)}E();var hF=Il(`rounded-lg p-3`,{variants:{variant:{flat:`bg-surface`,bordered:`bg-surface border border-border`}},defaultVariants:{variant:`bordered`}}),gF=D(({className:e,variant:t,...n},r)=>v(`div`,{ref:r,className:$(hF({variant:t}),e),...n}));gF.displayName=`Card`,E();var _F=[`low`,`mid`,`high`];function vF({deviceId:e,clip:t,profile:n,onProfileChange:r}){let i=q(),a=mF(),o=gk({deviceId:e,clipId:t.id,profile:n}),s=o.data,l=`${new Date(t.timeRange.startMs).toLocaleString()} · ${t.source}`;return b(()=>{s!==void 0&&a.play({url:bt(s.playbackUrl),...s.format===void 0?{}:{format:s.format},label:l})},[s,l]),c(gF,{className:`space-y-2 text-sm`,children:[v(`div`,{className:`font-medium text-foreground`,children:l}),c(`div`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`mr-1 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`uiLibrary.clipPanel.quality`,`Quality`)}),_F.map(e=>v(_A,{variant:e===n?`primary`:`secondary`,"aria-pressed":e===n,onClick:()=>r(e),children:e},e))]}),o.status===`pending`?c(`div`,{className:`space-y-1`,children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:i(`uiLibrary.clipPanel.preparing`,`Preparing the clip — the file is fetched and muxed once…`)}),v(hM,{className:`h-4 w-48`})]}):o.status===`error`?v(eN,{title:i(`uiLibrary.clipPanel.prepareFailed`,`This clip could not be prepared`),message:o.error?.message??i(`uiLibrary.clipPanel.noReasonGiven`,`no reason given`)}):s===void 0?null:c(`div`,{className:`space-y-2`,children:[s.served===void 0||s.served===n?null:v(eN,{variant:`warning`,message:v(gi,{uiKey:`uiLibrary.clipPanel.servedFallback`,fallback:`Served the <0>{{served}}</0> stream — this clip has no {{profile}} twin.`,components:[v(`strong`,{},`served`)],values:{served:s.served,profile:n}})}),c(`a`,{href:bt(s.playbackUrl),download:!0,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline`,children:[v(nn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),i(`uiLibrary.clipPanel.download`,`Download this clip`)]})]})]})}function yF(e){let t=Math.round(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}var bF={sleeping:(e,t)=>t(`uiLibrary.clipTile.refusal.sleeping`,`The camera is asleep — a still would cost a wake`),"camera-refused":(e,t)=>t(`uiLibrary.clipTile.refusal.camera_refused`,`The camera refused — {{reason}}`,{reason:e}),"no-keyframe":(e,t)=>t(`uiLibrary.clipTile.refusal.no_keyframe`,`No decodable frame inside this window`),unsupported:(e,t)=>t(`uiLibrary.clipTile.refusal.unsupported`,`This source cannot produce stills`),"queue-full":(e,t)=>t(`uiLibrary.clipTile.refusal.queue_full`,`Waiting for the camera — its still queue is full`),"camera-backoff":(e,t)=>t(`uiLibrary.clipTile.refusal.camera_backoff`,`The camera is resting after refusing — trying again shortly`),"no-catalog-row":(e,t)=>t(`uiLibrary.clipTile.refusal.no_catalog_row`,`This clip is no longer in the catalog`),"unknown-device":(e,t)=>t(`uiLibrary.clipTile.refusal.unknown_device`,`This camera is not served here`),"uid-missing":(e,t)=>t(`uiLibrary.clipTile.refusal.uid_missing`,`The camera’s id is not known yet`)};function xF(e,t,n){let r=e===void 0?void 0:bF[e];return r===void 0?t:r(t,n)}function SF(e,t,n){return{kind:`unavailable`,reason:e,text:xF(n,e,t)}}function CF(e,t=Fn){return e.thumbnail===void 0?e.thumbnailUnavailable===void 0?e.thumbnailMint===void 0?{kind:`none`,text:t(`uiLibrary.clipTile.noStill`,`This clip carries no still and offered none`)}:{kind:`mint`,url:e.thumbnailMint}:SF(e.thumbnailUnavailable.reason,t,e.thumbnailUnavailable.reason):{kind:`vouched`,url:e.thumbnail}}function wF(e,t=Fn){return e.disposition===`deferred`?{kind:`deferred`,reason:e.reason,text:xF(e.code,e.reason,t),retryAfterMs:e.retryAfterMs??null}:SF(e.reason,t,e.code)}async function TF(e,t,n=Fn){let r;try{r=await t(e,{credentials:`same-origin`})}catch(e){return DF(e,n)}if(r.status===204)return wF(EF(r,n),n);if(!r.ok)return wF({code:void 0,reason:n(`uiLibrary.clipThumbnail.httpStatus`,`HTTP {{status}}`,{status:String(r.status)}),disposition:void 0},n);try{return{kind:`image`,blob:await r.blob()}}catch(e){return DF(e,n)}}function EF(e,t){let n=e.headers.get(`retry-after`),r=n===null?NaN:Number(n);return{code:e.headers.get(`x-camstack-reason-code`)??void 0,reason:e.headers.get(`x-camstack-reason`)??t(`uiLibrary.clipThumbnail.noReason`,`no reason given`),disposition:e.headers.get(`x-camstack-disposition`)??void 0,retryAfterMs:Number.isFinite(r)&&r>0?r*1e3:null}}function DF(e,t){return wF({code:void 0,reason:e instanceof Error?e.message:String(e),disposition:`deferred`},t)}var OF=4e3,kF=3e4,AF=.25;function jF(e){if(e.attempt>=4||e.attempt<0)return null;let t=OF*2**e.attempt,n=Math.max(t,e.serverHintMs??0),r=Math.min(n,kF),i=1+(e.random()*2-1)*AF;return{waitMs:Math.round(r*i)}}E();function MF(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function NF(e){let t=q(),n=f(t);n.current=t;let r=p(()=>CF(e,t),[e.thumbnail,e.thumbnailMint,e.thumbnailUnavailable?.reason,t]),[i,a]=C(null),o=r.kind===`mint`?r.url:null;return b(()=>{if(a(null),o===null||typeof fetch!=`function`)return;let e=null,t=!1,r,i=async s=>{let c=await TF(bt(o),fetch,n.current);if(t)return;if(c.kind===`image`){e=URL.createObjectURL(c.blob),a({kind:`vouched`,url:e});return}if(c.kind!==`deferred`){a(c);return}let l=jF({attempt:s,serverHintMs:c.retryAfterMs,random:Math.random});if(l===null){a({kind:`unavailable`,reason:c.reason,text:c.text});return}r=setTimeout(()=>{i(s+1)},l.waitMs)};return i(0),()=>{t=!0,r!==void 0&&clearTimeout(r),e!==null&&URL.revokeObjectURL(e)}},[o]),i??r}function PF({clip:e,selected:t,onSelect:n}){let r=q(),i=NF(e),a=e.playable!==!1,o=[...e.labels??[],...e.behaviours??[]];return v(`li`,{children:v(`button`,{type:`button`,onClick:()=>n(e),disabled:!a,"aria-current":t?`true`:void 0,className:`block w-full text-left disabled:cursor-not-allowed`,children:c(gF,{className:`flex gap-3 transition-colors ${t?`border-primary`:``} ${a?`hover:bg-surface-hover`:`opacity-70`}`,children:[v(`div`,{className:`flex h-16 w-28 shrink-0 items-center justify-center overflow-hidden rounded bg-surface-hover text-[10px] text-foreground-subtle`,children:i.kind===`vouched`?v(`img`,{src:i.url,alt:``,className:`h-full w-full object-cover`}):i.kind===`mint`||i.kind===`deferred`?v(`span`,{role:`status`,"aria-label":i.kind===`mint`?r(`uiLibrary.clipTile.loadingStill`,`Loading the still`):i.text,className:`h-full w-full`,children:v(hM,{className:`h-full w-full rounded-none`})}):v(`span`,{className:`px-1 text-center leading-tight`,children:i.text})}),c(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[c(`div`,{className:`flex items-baseline gap-2`,children:[v(`span`,{className:`text-sm font-medium text-foreground`,children:MF(e.timeRange.startMs)}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.inProgress===!0?r(`uiLibrary.clipTile.recording`,`Recording…`):yF(e.timeRange.endMs-e.timeRange.startMs)})]}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:e.source}),o.length===0&&e.nativeTypes===void 0?null:c(`div`,{className:`flex flex-wrap gap-1`,children:[o.map(e=>v(Bk,{variant:`info`,children:e},`label:${e}`)),(e.nativeTypes??[]).map(e=>v(Bk,{style:`outline`,children:e},`native:${e}`))]}),a?null:v(`div`,{className:`text-[11px] text-warning`,children:r(`uiLibrary.clipTile.notPlayable`,`Not playable — {{reason}}`,{reason:e.unplayableReason??r(`uiLibrary.clipTile.noReason`,`the source gave no reason`)})})]})]})})})}function FF(e){return e<10?`0${String(e)}`:String(e)}function IF(e){let[t,n,r]=e.split(`-`).map(e=>Number(e));return new Date(t??1970,(n??1)-1,r??1,0,0,0,0)}function LF(e){return`${String(e.getFullYear())}-${FF(e.getMonth()+1)}-${FF(e.getDate())}`}function RF(e,t){let n=IF(e);return n.setDate(n.getDate()+t),LF(n)}function zF(e){return IF(e).toLocaleDateString(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`})}var BF=366;function VF(e){let t=Math.max(e.fromMs,e.toMs-1),n=LF(new Date(t)),r=LF(new Date(e.fromMs)),i=0;for(;r<=n&&i<BF;)i+=1,r=RF(r,1);return i}function HF(e){let t=VF(e);return t>2?{kind:`too-wide`,band:e,localDays:t,maxLocalDays:2}:{kind:`askable`,band:e,localDays:t}}function UF(e,t){return t===null?{fromMs:e.fromMs,toMs:e.toMs}:{fromMs:Math.max(t.startMs,e.fromMs),toMs:Math.min(t.endMs,e.toMs)}}function WF(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function GF(e){let t=LF(new Date(e.fromMs)),n=LF(new Date(Math.max(e.fromMs,e.toMs-1)));return t===n?`${zF(t)}, ${WF(e.fromMs)} – ${WF(e.toMs)}`:`${zF(t)} ${WF(e.fromMs)} – ${zF(n)} ${WF(e.toMs)}`}var KF={ok:{headlineKey:`uiLibrary.clipSource.state.ok`,headlineFallback:`Answering`,tone:`ok`,answered:!0},sleeping:{headlineKey:`uiLibrary.clipSource.state.sleeping`,headlineFallback:`Asleep — showing the catalog read while it was awake`,tone:`warn`,answered:!0},unreachable:{headlineKey:`uiLibrary.clipSource.state.unreachable`,headlineFallback:`Could not be reached — its clips are missing from this list`,tone:`error`,answered:!1},"no-storage":{headlineKey:`uiLibrary.clipSource.state.no_storage`,headlineFallback:`No storage card — this camera keeps nothing of its own`,tone:`warn`,answered:!1},"index-empty":{headlineKey:`uiLibrary.clipSource.state.index_empty`,headlineFallback:`The camera's calendar marks these days, and its own index lists nothing`,tone:`warn`,answered:!1}};function qF(e,t=Fn){let n=KF[e.availability.state];return{source:e.source,label:e.label,headline:t(n.headlineKey,n.headlineFallback),detail:e.availability.reason??null,tone:n.tone,answered:n.answered}}function JF(e,t=Fn){if(e.plan.kind===`too-wide`)return{kind:`refused`,band:e.plan.band,localDays:e.plan.localDays,maxLocalDays:e.plan.maxLocalDays};if(e.clipsStatus===`error`)return{kind:`failed`,message:e.clipsError??t(`uiLibrary.clipView.clipsFailed`,`The clip list could not be read`)};if(e.sourcesStatus===`error`&&e.clips.length===0)return{kind:`failed`,message:e.sourcesError??t(`uiLibrary.clipView.sourcesFailed`,`The source list could not be read`)};let n=e.sources.map(e=>qF(e,t)),r=n.filter(e=>e.answered),i=n.filter(e=>!e.answered),a=e.clips;return e.provider===null&&e.sourcesStatus===`success`?{kind:`empty`,band:e.plan.band,answered:r,silent:i,nobodyAnswered:!0}:e.clipsStatus===`pending`||e.sourcesStatus===`pending`?{kind:`loading`}:a.length===0?{kind:`empty`,band:e.plan.band,answered:r,silent:i,nobodyAnswered:r.length===0}:{kind:`listed`,clips:a,answered:r,silent:i}}E();var YF=500,XF=60;function ZF({silent:e}){let t=q();return e.length===0?null:v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.silentSources`,{one:`One source contributed nothing to this list`,other:`{{count}} sources contributed nothing to this list`},{count:e.length}),message:v(`div`,{className:`space-y-1`,children:e.map(e=>c(`div`,{children:[v(`span`,{className:`font-medium`,children:e.label}),c(`span`,{className:`opacity-70`,children:[` (`,e.source,`)`]}),v(`div`,{children:e.headline}),e.detail===null?null:v(`div`,{className:`opacity-80 break-words`,children:e.detail})]},e.source))})})}function QF({deviceId:e}){let t=q(),[n,r]=C(()=>new Date),[i,a]=C(()=>HM(new Date,Date.now())),[o,s]=C(null),[l,u]=C(``),[d,f]=C(1),[m,h]=C(null),[g,_]=C(`low`),y=IM(`videoclips`),x=p(()=>HM(n,Date.now()),[n]),S=qM(i.toMs-i.fromMs),w=Ob({deviceId:e,since:i.fromMs,until:i.toMs,bucketMs:S}),T=p(()=>RM(w.data??[],i.fromMs,S),[w.data,i.fromMs,S]),E=o===null?void 0:T.find(e=>e.index===o),D=p(()=>UF(i,E===void 0?null:{startMs:E.startMs,endMs:E.endMs}),[i,E]),O=HF(D),k=hk({deviceId:e}),A=k.data??[],j=p(()=>l===``?A.find(e=>e.addonId!==void 0)?.addonId??``:l,[l,A]),M=mk({deviceId:e,since:D.fromMs,until:D.toMs,limit:YF,provider:j},{enabled:O.kind===`askable`&&j!==``}),N=JF({plan:O,provider:j===``?null:j,clipsStatus:M.status,clips:M.data??[],sourcesStatus:k.status,sources:A,...M.error?{clipsError:M.error.message}:{},...k.error?{sourcesError:k.error.message}:{}},t),F=p(()=>{let e=new Map;for(let t of A){let n=t.addonId;if(n===void 0)continue;let r=e.get(n);r===void 0?e.set(n,[t.label]):r.push(t.label)}return[...e].map(([e,t])=>({value:e,label:t.join(` · `)}))},[A]);b(()=>{f(1)},[D.fromMs,D.toMs]);let I=e=>{r(e),a(HM(e,Date.now())),s(null)},L=e=>{a(e),s(null)},R=e=>{s(t=>t===e?null:e)},z=e=>{u(e),f(1)};if(y===`pending`)return c(`div`,{className:`space-y-2`,children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`uiLibrary.clipsSection.asking`,`Asking the registry whether this cluster serves clips…`)}),v(hM,{className:`h-24 w-full`})]});if(y===`unknown`)return v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.unknownTitle`,`Clip sources unknown`),message:t(`uiLibrary.clipsSection.unknownMessage`,`The capability registry could not be reached, so whether this camera has clip sources is unknown — not absent.`)});if(y===`absent`)return v(`div`,{role:`status`,children:v(QM,{icon:Un,title:t(`uiLibrary.clipsSection.absentTitle`,`No provider of videoclips in this cluster`),description:t(`uiLibrary.clipsSection.absentDescription`,`Nothing is installed that could list a camera's stored clips.`)})});let B=N.kind===`listed`?N.clips:[],V=B.slice((d-1)*XF,d*XF);return c(`div`,{className:`space-y-3`,children:[c(`div`,{children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`uiLibrary.clipsSection.clips`,`Clips`)}),v(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.intro`,`Every source this camera has, side by side — CamStack's own recordings and whatever the camera or an export keeps of its own. A source is listed because it exists, not because it was switched on here; pick sources to narrow the view.`)}),v(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.periodHint`,`The list follows the period selected on the timebar below — the recording section's own control. Zoom out to widen it, pan or pick a day to move it, click a density bar to narrow it to that window.`)})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`label`,{htmlFor:`clips-provider`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t(`uiLibrary.clipsSection.source`,`Source`)}),v(`div`,{className:`w-60`,children:v(Yl,{id:`clips-provider`,options:F,value:j,disabled:F.length<2,onChange:e=>z(e.target.value)})}),F.length<2?v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.oneProvider`,`This camera is bound to one clip provider today.`)}):null,c(`div`,{className:`ml-auto flex items-center gap-1`,children:[v(`span`,{className:`px-1 text-xs font-medium text-foreground`,children:GF(D)}),o===null?null:v(_A,{variant:`outline`,onClick:()=>s(null),children:t(`uiLibrary.clipsSection.expand`,`Expand to the visible window`)})]})]}),v(dF,{day:n,onDayChange:I,view:i,dayBounds:x,onViewChange:L,buckets:T,selectedBucketIndex:o,onSelectBucket:R,densityLoading:w.status===`pending`}),v(`section`,{"aria-label":t(`uiLibrary.clipsSection.clips`,`Clips`),className:`space-y-2`,children:N.kind===`refused`?v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.tooWideTitle`,`That period is too wide to list`),message:t(`uiLibrary.clipsSection.tooWideMessage`,`{{band}} covers {{days}} local days, and a clip listing is asked one local day at a time — at most {{max}}. Nothing was asked for; narrow the band and the list follows it.`,{band:GF(N.band),days:N.localDays,max:N.maxLocalDays})}):N.kind===`loading`?c(P,{children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`uiLibrary.clipsSection.loadingFor`,`Loading clips for {{band}}…`,{band:GF(D)})}),v(hM,{className:`h-24 w-full`})]}):N.kind===`failed`?v(eN,{title:t(`uiLibrary.clipsSection.listFailed`,`The clip list could not be read`),message:N.message}):N.kind===`empty`?c(P,{children:[v(`div`,{role:`status`,children:v(QM,{icon:Kt,title:N.nobodyAnswered?t(`uiLibrary.clipsSection.noSourceAnswered`,`No source could answer for {{band}}`,{band:GF(N.band)}):t(`uiLibrary.clipsSection.noClips`,`No clips in {{band}}`,{band:GF(N.band)}),...N.nobodyAnswered?{}:{description:t(`uiLibrary.clipsSection.asked`,`Asked {{sources}}.`,{sources:N.answered.map(e=>e.label).join(`, `)})}})}),v(ZF,{silent:N.silent})]}):c(P,{children:[v(ZF,{silent:N.silent}),v(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:V.map(e=>v(PF,{clip:e,selected:m?.id===e.id,onSelect:h},`${e.source}:${e.id}`))}),v(ZM,{currentPage:d,totalItems:B.length,pageSize:XF,onPageChange:f,itemNoun:t(`uiLibrary.clipsSection.itemNoun`,`clips`)})]})}),m===null?null:v(vF,{deviceId:e,clip:m,profile:g,onProfileChange:_})]})}function $F(e,t){let n=e.slot;return t.some(e=>e===n)}function eI(e,t=Aee,n=Fn){let r=e=>t.indexOf(e);if(e.status===`pending`)return{kind:`pending`};if(e.status===`error`)return{kind:`unknown`,reason:e.error?.message??n(`uiLibrary.extensions.requestFailed`,`the request failed`)};let i=e.data??[];if(i.length===0)return{kind:`none`};let a=[],o=[],s=[];for(let e of i)e.state===`ok`?$F(e,t)?a.push(e):o.push({slot:e.slot,slotRef:e.slotRef}):s.push(e);return{kind:`rows`,slots:a.toSorted((e,t)=>r(e.slot)-r(t.slot)),unknownSlots:o,unreachable:s}}function tI(e,t,n){return e.includes(t)?e.filter(e=>e!==t):n===`one`?[t]:[...e,t]}function nI(e,t){return e.filter(e=>e.suggested&&!t.includes(e.deviceId))}function rI(e,t,n){let r=n.trim().toLowerCase();return r.length===0?[]:e.filter(e=>!t.includes(e.deviceId)&&[e.name,e.location??``,e.parentName??``,e.type].some(e=>e.toLowerCase().includes(r)))}function iI(e,t){return e.length!==t.length||e.some((e,n)=>t[n]!==e)}function aI(e){return e.slot===`linked-devices`?e.trackedDeviceIds:void 0}function oI(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function sI(e,t){return e.length!==t.length||e.some(e=>!t.includes(e))}function cI(e){let t=[],n=new Set,r=(e,r)=>{n.has(e)||(n.add(e),t.push({deviceId:e,origin:r}))};for(let t of e.picks)e.invalidPicks.includes(t)||r(t,`pick`);for(let t of e.implied)r(t,`implied`);for(let t of e.tracked)r(t,`not-linked`);return t}function lI(e,t,n){return n.includes(t)?e:e.filter(e=>e!==t)}function uI(e,t,n){return e.slot===`linked-devices`&&n!==void 0?{slot:`linked-devices`,deviceIds:[...t],trackedDeviceIds:[...n]}:{slot:e.slot,deviceIds:[...t]}}E();function dI(e,t){switch(e){case`ok`:return t(`uiLibrary.associationSlotCard.healthOk`,`OK`);case`missing`:return t(`uiLibrary.associationSlotCard.healthMissing`,`Missing`);case`foreign`:return t(`uiLibrary.associationSlotCard.healthForeign`,`Other owner`);case`unavailable`:return t(`uiLibrary.associationSlotCard.healthUnavailable`,`Not a valid source`)}}var fI={ok:`success`,missing:`danger`,foreign:`warning`,unavailable:`warning`};function pI({sources:e,tracked:t}){let n=q();return e.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:n(`uiLibrary.associationSlotCard.noDevicesPicked`,`No devices picked.`)}):v(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>c(`li`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[v(`span`,{className:`text-foreground`,children:e.name??n(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e.deviceId})}),v(Bk,{variant:fI[e.health],children:dI(e.health,n)}),t?.includes(e.deviceId)===!0&&v(Bk,{variant:`info`,children:n(`uiLibrary.associationSlotCard.trackedEvents`,`Tracked events`)}),e.detail!==void 0&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.detail})]},e.deviceId))})}function mI({row:e}){let t=q(),n=e.activation;return n===null?null:c(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px] text-foreground-subtle`,children:[v(Bk,{variant:n.state===`active`?`success`:n.state===`inactive`?`warning`:`default`,children:n.state===`active`?t(`uiLibrary.associationSlotCard.active`,`Active`):n.state===`inactive`?t(`uiLibrary.associationSlotCard.inactive`,`Inactive`):t(`uiLibrary.associationSlotCard.unknown`,`Unknown`)}),v(`span`,{children:t(`uiLibrary.associationSlotCard.setBy`,`set by {{authority}}`,{authority:n.authority})}),n.detail!==void 0&&v(`span`,{children:n.detail})]})}function hI({sources:e,tracked:t}){let n=q();return e.length===0?null:c(`div`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`uiLibrary.associationSlotCard.alwaysLinked`,`Always linked (device tree):`)}),v(`ul`,{"aria-label":n(`uiLibrary.associationSlotCard.alwaysLinkedAria`,`Always linked`),className:`flex flex-col gap-1`,children:e.map(e=>c(`li`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[v(`span`,{className:`text-foreground`,children:e.name??n(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e.deviceId})}),t?.includes(e.deviceId)===!0&&v(Bk,{variant:`info`,children:n(`uiLibrary.associationSlotCard.trackedEvents`,`Tracked events`)})]},e.deviceId))})]})}function gI(e,t){switch(e){case`pick`:return null;case`implied`:return t(`uiLibrary.associationSlotCard.originImplied`,`always linked`);case`not-linked`:return t(`uiLibrary.associationSlotCard.originNotLinked`,`not linked any more — untick to remove`)}}function _I({options:e,tracked:t,nameOf:n,onToggle:r}){let i=q();return e.length===0?null:c(`fieldset`,{className:`flex flex-col gap-1`,children:[v(`legend`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.associationSlotCard.produceTracked`,`Produce tracked events on this camera (opt-in):`)}),e.map(({deviceId:e,origin:a})=>c(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[v(`input`,{type:`checkbox`,"aria-label":i(`uiLibrary.associationSlotCard.trackedFrom`,`Tracked events from {{name}}`,{name:n(e)}),checked:t.includes(e),onChange:()=>r(e)}),n(e),gI(a,i)!==null&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,gI(a,i)]})]},e))]})}function vI({deviceId:e,row:t,onSaved:n,readOnly:r=!1}){let i=f(null);As(i);let a=q(),o=kee[t.slot].descriptor,s=t.value.deviceIds,l=aI(t.value),u=t.impliedSources??[],d=u.map(e=>e.deviceId),p=t.sources.filter(e=>e.health===`unavailable`).map(e=>e.deviceId),[m,h]=C(!1),[g,_]=C(s),[y,b]=C(l??[]),[x,S]=C(``),[w,T]=C(null),E=mp({deviceId:e,slotRef:t.slotRef},{enabled:m}),D=hp(),O=E.data?.candidates??[],k=e=>O.find(t=>t.deviceId===e)?.name??t.sources.find(t=>t.deviceId===e)?.name??u.find(t=>t.deviceId===e)?.name??a(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e}),A=e=>{_(tI(g,e,o.cardinality)),b(lI(y,e,d))},j=()=>{_(s),b(l??[]),T(null),h(!0)},M=async()=>{T(null);try{await D.mutateAsync({deviceId:e,slotRef:t.slotRef,value:uI(t.value,g,l===void 0?void 0:y)}),h(!1),n()}catch(e){T(e instanceof Error?e.message:String(e))}};return c(`div`,{role:`group`,"aria-label":o.label,className:`flex flex-col gap-2 rounded-md border border-border/40 bg-surface-elevated/30 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`div`,{className:`flex flex-col gap-0.5`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:o.label}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.description}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.storedIn`,`Stored in {{authority}}`,{authority:t.authority})})]}),!m&&!r&&v(_A,{variant:`outline`,size:`sm`,onClick:j,children:a(`uiLibrary.associationSlotCard.edit`,`Edit`)})]}),v(mI,{row:t}),!m&&v(pI,{sources:t.sources,tracked:l}),!m&&v(hI,{sources:u,tracked:l}),m&&c(`div`,{className:`flex flex-col gap-2`,children:[v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.pickedDevices`,`Picked devices`),className:`flex flex-wrap gap-1.5`,children:g.map(e=>v(`li`,{children:c(`button`,{type:`button`,"aria-label":a(`uiLibrary.associationSlotCard.removeN`,`Remove {{name}}`,{name:k(e)}),onClick:()=>A(e),className:`inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-[11px] text-foreground`,children:[k(e),v(Zn,{className:`h-3 w-3`})]})},e))}),E.status===`pending`&&v(`p`,{role:`status`,className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.loadingCandidates`,`Loading candidates…`)}),E.status===`error`&&v(`p`,{role:`alert`,className:`text-[10px] text-danger`,children:a(`uiLibrary.associationSlotCard.candidatesError`,`Candidates could not be read: {{message}}`,{message:E.error.message})}),nI(O,g).length>0&&c(`div`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.suggested`,`Suggested — added only if you click them:`)}),v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.suggestions`,`Suggestions`),className:`flex flex-wrap gap-1.5`,children:nI(O,g).map(e=>v(`li`,{children:c(`button`,{type:`button`,"aria-label":a(`uiLibrary.associationSlotCard.addN`,`Add {{name}}`,{name:e.name}),onClick:()=>_(tI(g,e.deviceId,o.cardinality)),className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[11px] text-foreground-muted`,children:[v(Se,{className:`h-3 w-3`}),e.name,e.reason!==null&&c(`span`,{className:`text-foreground-subtle`,children:[`· `,e.reason]})]})},e.deviceId))})]}),v(`input`,{ref:i,type:`search`,"aria-label":a(`uiLibrary.associationSlotCard.searchDevices`,`Search devices`),value:x,onChange:e=>S(e.target.value),placeholder:a(`uiLibrary.associationSlotCard.searchPlaceholder`,`Search devices by name, location or type`),className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground outline-none focus:border-primary`}),rI(O,g,x).length>0&&v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.searchResults`,`Search results`),className:`flex max-h-40 flex-col gap-0.5 overflow-y-auto`,children:rI(O,g,x).map(e=>v(`li`,{children:c(`button`,{type:`button`,onClick:()=>{_(tI(g,e.deviceId,o.cardinality)),S(``)},className:`w-full rounded px-2 py-1 text-left text-[11px] text-foreground hover:bg-surface-hover`,children:[e.name,e.parentName!==null&&v(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.inParent`,`in {{name}}`,{name:e.parentName})}),e.location!==null&&c(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,e.location]})]})},e.deviceId))}),l!==void 0&&v(_I,{options:cI({picks:g,invalidPicks:p,implied:d,tracked:y}),tracked:y,nameOf:k,onToggle:e=>b(oI(y,e))}),w!==null&&v(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:a(`uiLibrary.associationSlotCard.notSaved`,`Not saved: {{reason}}`,{reason:w})}),c(`div`,{className:`flex justify-end gap-2`,children:[v(_A,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:a(`uiLibrary.associationSlotCard.cancel`,`Cancel`)}),v(_A,{size:`sm`,disabled:!(iI(s,g)||l!==void 0&&sI(l,y))||D.isPending,onClick:()=>void M(),children:a(`uiLibrary.associationSlotCard.save`,`Save`)})]})]})]})}function yI({deviceId:e,slots:t,title:n,readOnly:r=!1}){let i=q(),a=pp({deviceId:e}),o=eI({status:a.status,data:a.data,error:a.error},void 0,i),s=e=>t===void 0||t.some(t=>t===e),l=o.kind===`rows`?o.slots.filter(e=>s(e.slot)):[],u=o.kind===`rows`?o.unknownSlots.filter(e=>s(e.slot)):[],d=n??i(`uiLibrary.extensionsPanel.title`,`Extensions`),f=o.kind===`rows`&&t!==void 0&&l.length===0&&u.length===0&&o.unreachable.length===0;return v($t,{title:d,icon:v(dr,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3`,children:c(`section`,{"aria-label":d,className:`flex flex-col gap-3`,children:[o.kind===`pending`&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.loading`,`Loading this device’s extensions…`)}),o.kind===`unknown`&&v(eN,{title:i(`uiLibrary.extensionsPanel.unknownTitle`,`Extensions could not be read`),message:i(`uiLibrary.extensionsPanel.unknownMessage`,`Nothing is known about this device’s extensions yet: {{reason}}`,{reason:o.reason}),onRetry:()=>void a.refetch()}),o.kind===`none`&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle italic`,children:i(`uiLibrary.extensionsPanel.none`,`No extensions are offered on this device.`)}),o.kind===`rows`&&c(P,{children:[f&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle italic`,children:i(`uiLibrary.extensionsPanel.filteredToNothing`,`None of these extensions is offered on this device.`)}),l.map(t=>v(vI,{deviceId:e,row:t,onSaved:()=>void a.refetch(),readOnly:r},t.slotRef)),u.map(e=>c(`div`,{role:`alert`,className:`flex flex-col gap-1 rounded-md border border-warning/40 bg-warning/5 p-3`,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(Bk,{variant:`warning`,children:i(`uiLibrary.extensionsPanel.unknownSlot`,`Unknown slot`)}),v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.slot})]}),v(`p`,{className:`text-[11px] text-foreground-muted break-words`,children:e.slotRef}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.disagree`,`The admin UI and the server disagree: the server offers a slot this admin UI does not know. Update the admin UI, or the server.`)})]},`unknown:${e.slotRef}`)),o.unreachable.map(e=>c(`div`,{role:`alert`,className:`flex flex-col gap-1 rounded-md border border-warning/40 bg-warning/5 p-3`,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(Bk,{variant:`warning`,children:i(`uiLibrary.extensionsPanel.unreachable`,`Unreachable`)}),v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.addonId})]}),v(`p`,{className:`text-[11px] text-foreground-muted break-words`,children:e.reason}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.unreachableHint`,`The extensions this component owns are unknown until it answers.`)})]},`unreachable:${e.addonId}`))]})]})})}E();var bI=1e3,xI={forward:{pan:0,tilt:1},left:{pan:-1,tilt:0},right:{pan:1,tilt:0},spin:{pan:0,tilt:-1}};function SI(e){let t=e instanceof Error?e.message:String(e);return/not available|no provider|NOT_FOUND|PRECONDITION/i.test(t)}function CI(e,t,n){let r=n?.enabled??!0,i=Ge(e,r?t:null)?.navigation,a=qr(e,r?t:null,e=>e.navigation),[o,s]=C(null),[c,l]=C([]),[u,d]=C(!1),[p,m]=C(null),[h,g]=C(null),v=f(null);b(()=>{if(!r||!i)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([i.getFeatures({}),i.listActions({})]);if(e)return;s(t),l(n)}catch(t){if(e||SI(t))return;m(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[i,r]);let y=_(async e=>{if(!(!r||!i)){m(null),d(!0);try{await e()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}}},[r,i]),x=_(()=>{v.current!==null&&(clearInterval(v.current),v.current=null)},[]),S=_(async()=>{x(),g(null),i&&await y(()=>i.stop({}))},[x,i,y]),w=_(e=>{if(!i)return;x(),g(e);let t=xI[e],n=()=>{i.move({pan:t.pan,tilt:t.tilt}).catch(e=>{m(e instanceof Error?e.message:String(e))})};n(),v.current=setInterval(n,bI)},[x,i]);b(()=>()=>{v.current!==null&&(clearInterval(v.current),v.current=null,i?.stop({}).catch(()=>void 0))},[i]);let T=_(e=>y(async()=>i?.runAction({actionId:e})),[i,y]),E=_(e=>y(async()=>i?.playSound({soundId:e})),[i,y]),D=_(e=>y(async()=>i?.setLightOn({on:e})),[i,y]),O=_((e,t)=>y(async()=>i?.setLightMode(t===void 0?{mode:e}:{mode:e,level:t})),[i,y]),k=_(e=>y(async()=>i?.setLightLevel({level:e})),[i,y]);return{features:o,actions:c,status:a??null,startDrive:w,stopDrive:S,runAction:T,playSound:E,setLightOn:D,setLightMode:O,setLightLevel:k,busy:u,error:p,driving:h}}var wI={play:Le,pause:Vt,hand:_r,home:Oi,bell:Bt,crosshair:fi,"paw-print":Me,footprints:$e,droplets:Ue,"trash-2":Pe,flashlight:Ot,"flashlight-off":Ri,cat:U,dog:B,clock:In};function TI(e){return wI[e]??ti}var EI=[{direction:`left`,labelKey:`uiLibrary.navigationPanel.turnLeft`,labelFallback:`Turn left`,Icon:Lt},{direction:`forward`,labelKey:`uiLibrary.navigationPanel.forward`,labelFallback:`Forward`,Icon:R},{direction:`right`,labelKey:`uiLibrary.navigationPanel.turnRight`,labelFallback:`Turn right`,Icon:Di},{direction:`spin`,labelKey:`uiLibrary.navigationPanel.turnAround`,labelFallback:`Turn around`,Icon:ze}],DI=`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,OI=`bg-success/15 text-success hover:bg-success/25`;function kI({entry:e,disabled:t,onRun:n}){let r=TI(e.icon);return c(`button`,{type:`button`,className:DI,disabled:t,onClick:()=>n(e),title:e.label,"aria-label":e.label,children:[v(r,{className:`h-3.5 w-3.5`}),v(`span`,{children:e.label})]})}function AI({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),i=CI(n.trpcClient,r?e:0,{enabled:r});if(!r)return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.navigationPanel.notLoaded`,`Device #{{deviceId}} not loaded.`,{deviceId:e})});let a=i.features,o=i.actions.filter(e=>e.enabled&&e.kind===`action`),s=i.actions.filter(e=>e.enabled&&e.kind===`sound`),l=i.status,u=l?.lightMode===`manual`,d=e=>{if(e.kind===`sound`){e.soundId!==void 0&&i.playSound(e.soundId);return}i.runAction(e.id)};return c($t,{title:t(`uiLibrary.navigationPanel.title`,`Navigation`),icon:v(qe,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 flex flex-col gap-3 overflow-y-auto`,children:[l&&c(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[v(`span`,{className:`rounded-full bg-surface-elevated/60 px-2 py-0.5 text-foreground`,children:l.mode}),l.following&&v(`span`,{className:`rounded-full bg-info/15 px-2 py-0.5 text-info`,children:t(`uiLibrary.navigationPanel.following`,`following`)}),l.flash&&v(`span`,{className:`rounded-full bg-warning/15 px-2 py-0.5 text-warning`,children:t(`uiLibrary.navigationPanel.lightOn`,`light on`)})]}),a?.move&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.driveHold`,`Drive (hold)`)}),v(`div`,{className:`grid grid-cols-4 gap-1.5`,children:EI.map(({direction:e,labelKey:n,labelFallback:r,Icon:a})=>v(`button`,{type:`button`,className:$(DI,`justify-center select-none`,i.driving===e&&OI),"aria-label":t(n,r),title:t(n,r),onPointerDown:()=>i.startDrive(e),onPointerUp:()=>void i.stopDrive(),onPointerLeave:()=>{i.driving===e&&i.stopDrive()},onPointerCancel:()=>void i.stopDrive(),children:v(a,{className:`h-4 w-4`})},e))}),a.stop&&c(`button`,{type:`button`,className:$(DI,`justify-center`),onClick:()=>void i.stopDrive(),children:[v(_r,{className:`h-3.5 w-3.5`}),v(`span`,{children:t(`uiLibrary.navigationPanel.stop`,`Stop`)})]})]}),a?.runAction&&o.length>0&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.actions`,`Actions`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>v(kI,{entry:e,disabled:i.busy,onRun:d},e.id))})]}),a?.playSound&&s.length>0&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.sounds`,`Sounds`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>v(kI,{entry:e,disabled:i.busy,onRun:d},e.id))})]}),a?.light&&c(`section`,{className:`flex flex-col gap-1.5 border-t border-border/40 pt-2`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.fillLight`,`Fill light`)}),c(`button`,{type:`button`,className:$(DI,l?.flash&&OI),"aria-pressed":l?.flash===!0,disabled:i.busy,onClick:()=>void i.setLightOn(l?.flash!==!0),children:[l?.flash?v(Ot,{className:`h-3.5 w-3.5`}):v(Ri,{className:`h-3.5 w-3.5`}),l?.flash?t(`uiLibrary.navigationPanel.on`,`On`):t(`uiLibrary.navigationPanel.off`,`Off`)]})]}),a.lightMode&&c(`div`,{className:`flex items-center gap-2`,children:[c(`select`,{"aria-label":t(`uiLibrary.navigationPanel.lightMode`,`Light mode`),className:`rounded-md bg-surface-elevated/40 px-2 py-1 text-[10px] text-foreground`,value:l?.lightMode??`auto`,disabled:i.busy,onChange:e=>{let t=e.target.value===`manual`?`manual`:`auto`;i.setLightMode(t,t===`manual`?l?.lightLevel:void 0)},children:[v(`option`,{value:`auto`,children:t(`uiLibrary.navigationPanel.auto`,`Auto`)}),v(`option`,{value:`manual`,children:t(`uiLibrary.navigationPanel.manual`,`Manual`)})]}),u&&v(`input`,{type:`range`,"aria-label":t(`uiLibrary.navigationPanel.lightLevel`,`Light level`),className:`flex-1`,min:40,max:100,step:1,value:l?.lightLevel??100,disabled:i.busy,onChange:e=>void i.setLightLevel(Number(e.target.value))}),u&&v(`span`,{className:`text-[10px] text-foreground-subtle w-8 text-right`,children:l?.lightLevel??100})]})]}),i.error&&v(`div`,{className:`text-[10px] text-danger`,children:i.error})]})}E();var jI={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 MI(e,t,n){let r=n?.defaultSpeed??.5,i=n?.pulseMs??250,a=n?.enabled??!0,o=Ge(e,a?t:null)?.ptz,[s,c]=C([]),[l,u]=C(null),[d,f]=C(null),[p,m]=C(null),[h,g]=C(!1),[v,y]=C(null),x=_(async()=>{if(!(!a||!o))try{c(await o.getPresets({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]),S=_(async()=>{if(!(!a||!o))try{u(await o.getHomePreset({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]),w=_(async()=>{if(!(!a||!o))try{f(await o.getHomeReturn({}))}catch(e){if(zt(e))return;f(null)}},[o,a]),T=_(async()=>{if(!(!a||!o))try{m(await o.getOptions({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]);b(()=>{x(),T(),S(),w()},[x,T,S,w]);let E=_(async e=>{if(!(!a||!o)){y(null),g(!0);try{return await e()}catch(e){y(e instanceof Error?e.message:String(e));return}finally{g(!1)}}},[a,o]);return{move:_(async(e,t)=>{if(!o)return;let n=jI[e],a=t??r;await E(async()=>{await o.move({pan:n.pan,tilt:n.tilt,speed:a}),await new Promise(e=>setTimeout(e,i)),await o.stop({})})},[o,r,i,E]),startContinuous:_(async(e,t)=>{if(!o)return;let n=jI[e],i=t??r;await E(()=>o.continuousMove({pan:n.pan,tilt:n.tilt,speed:i}))},[o,r,E]),stopContinuous:_(async()=>{o&&await E(()=>o.stop({}))},[o,E]),zoom:_(async(e,t)=>{if(!o)return;let n=e===`in`?1:-1,a=t??r;await E(async()=>{await o.move({zoom:n,speed:a}),await new Promise(e=>setTimeout(e,i)),await o.stop({})})},[o,r,i,E]),goHome:_(async()=>{o&&await E(()=>o.goHome({}))},[o,E]),homePreset:l,setHomePreset:_(async e=>{o&&(await E(()=>o.setHomePreset({presetId:e})),await S())},[o,E,S]),captureHomeHere:_(async()=>{o&&(await E(()=>o.captureHomeHere({})),await S())},[o,E,S]),homeReturn:d,setHomeReturn:_(async(e,t)=>{o&&(await E(()=>o.setHomeReturn({enabled:e,seconds:t})),await w())},[o,E,w]),goToPreset:_(async e=>{o&&await E(()=>o.goToPreset({presetId:e}))},[o,E]),savePreset:_(async e=>{if(o)return E(async()=>{let t=new Set(s.map(e=>Number(e.id)).filter(e=>Number.isInteger(e)&&e>=0)),n=0;for(;t.has(n);)n+=1;let r=String(n);return await o.savePreset({presetId:r,name:e}),await x(),r})},[o,s,x,E]),updatePreset:_(async e=>{o&&await E(async()=>{let t=s.find(t=>t.id===e);await o.savePreset({presetId:e,name:t?.name??``}),await x()})},[o,s,x,E]),deletePreset:_(async e=>{o&&await E(async()=>{await o.deletePreset({presetId:e}),await x()})},[o,x,E]),presets:s,refreshPresets:x,options:p,busy:h,error:v}}E();var NI=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`;function PI({controls:e}){let t=q(),{homePreset:n,presets:r,setHomePreset:i,captureHomeHere:a,homeReturn:o,setHomeReturn:s,busy:l}=e,[u,d]=C(!1);if(n===null)return null;let f=l||u,p=e=>{d(!0),e().finally(()=>d(!1))},m=n.source===`native`?`This camera stores its own home position. “Set home here” pins it to where the camera is pointing now.`:n.source===`firmware`?`Taken from the camera, which names this preset as its home.`:n.source===`none`?`Nothing is set, so Home refuses rather than moving to an arbitrary preset.`:`Pinned here. Clear it to fall back to the camera’s own home.`;return c(`div`,{className:`flex flex-col gap-2 px-2 pt-2`,children:[n.source!==`native`&&c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.label`,`Home preset`)}),c(`select`,{value:n.presetId??``,disabled:f,onChange:e=>{let t=e.target.value===``?null:e.target.value;p(()=>i(t))},className:NI,children:[v(`option`,{value:``,children:t(`uiLibrary.homePresetPicker.notSet`,`Not set — Home is refused`)}),r.map(e=>v(`option`,{value:e.id,children:e.fn===`home`?t(`uiLibrary.homePresetPicker.ownHome`,`{{name}} (camera’s own home)`,{name:e.name||e.id}):e.name||e.id},e.id))]})]}),v(`button`,{type:`button`,disabled:f,onClick:()=>p(()=>a()),className:`self-start rounded-md border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:t(`uiLibrary.homePresetPicker.setHere`,`Set home here`)}),o!==null&&c(`div`,{className:`flex flex-col gap-1`,children:[c(`label`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`checkbox`,checked:o.enabled,disabled:f,onChange:e=>p(()=>s(e.target.checked,o.seconds))}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.returnIdle`,`Return home when idle`)})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.after`,`After (s)`)}),v(`input`,{type:`number`,min:0,max:3600,defaultValue:o.seconds,disabled:f,onBlur:e=>{let t=Number(e.target.value);!Number.isFinite(t)||Math.round(t)===o.seconds||p(()=>s(o.enabled,Math.round(t)))},className:NI})]})]}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:m})]})}E(),Do();function FI({direction:e,icon:t,disabled:n,className:r,variant:i,onMove:a,onStart:o,onStop:s}){let[c,l]=C(null),[u,d]=C(!1),f=_(t=>{if(n)return;t.currentTarget.setPointerCapture(t.pointerId),l(Date.now()),d(!1);let r=setTimeout(()=>{d(!0),o(e)},250);t.currentTarget.dataset.timer=String(r)},[e,n,o]),p=_(t=>{let n=Number(t.currentTarget.dataset.timer);n&&clearTimeout(n),t.currentTarget.dataset.timer=``,u?s():c!==null&&a(e),l(null),d(!1)},[u,e,a,s,c]),m=_(e=>{let t=Number(e.currentTarget.dataset.timer);t&&clearTimeout(t),e.currentTarget.dataset.timer=``,u&&s(),l(null),d(!1)},[u,s]),h=i===`panel`?`h-9 w-9`:`h-7 w-7`,g=i===`panel`?`h-4 w-4`:`h-3.5 w-3.5`;return v(`button`,{type:`button`,disabled:n,onPointerDown:f,onPointerUp:p,onPointerCancel:m,className:$(`flex items-center justify-center rounded transition-colors disabled:opacity-40`,i===`panel`?`text-foreground hover:bg-surface-hover active:bg-surface-hover/80`:`text-white hover:bg-white/15 active:bg-white/25`,h,r),title:e,children:v(t,{className:g})})}function II({controls:e,mode:t=`overlay`,showPresets:n,showZoom:r=!0,showHome:i=!0,className:a}){let o=q(),{move:s,startContinuous:l,stopContinuous:d,zoom:p,goHome:m,homePreset:h,goToPreset:g,savePreset:y,updatePreset:x,deletePreset:S,presets:w,options:T,busy:E,error:D}=e,O=li(),[k,A]=C(!1),[j,M]=C(``),N=f(null),F=f(null),[I,L]=C(null),z=t===`panel`,B=r&&(T?.hasZoom??!0),V=T?.supportsPresets??w.length>0,H=(n??V)&&V,U=z&&(T?.supportsPresets??!1),ee=T?.maxPresets!==void 0&&w.length>=T.maxPresets,W=_(async()=>{let e=j.trim();!e||E||ee||await y(e)!==void 0&&M(``)},[j,E,ee,y]),G=_(async(e,t)=>{await O({title:o(`uiLibrary.ptzOverlay.deleteTitle`,`Delete preset`),message:o(`uiLibrary.ptzOverlay.deleteMessage`,`Delete PTZ preset "{{label}}"? This removes it from the camera.`,{label:t}),confirmLabel:o(`uiLibrary.ptzOverlay.delete`,`Delete`),variant:`danger`})&&await S(e)},[O,S,o]),te=_(async(e,t)=>{await O({title:o(`uiLibrary.ptzOverlay.updateTitle`,`Update preset`),message:o(`uiLibrary.ptzOverlay.updateMessage`,`Overwrite preset "{{label}}" with the camera's current position?`,{label:t}),confirmLabel:o(`uiLibrary.ptzOverlay.update`,`Update`)})&&await x(e)},[O,x,o]);u(()=>{if(!k){L(null);return}let e=()=>{let e=N.current?.getBoundingClientRect();e&&L({top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[k]),b(()=>{if(!k)return;let e=e=>{let t=e.target;F.current?.contains(t)||N.current?.contains(t)||A(!1)},t=e=>{e.key===`Escape`&&A(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[k]);let ne=z?`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`,re=$(z?`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`,E&&`ring-1 ring-primary/40`),K=z?`h-9 w-9`:`h-7 w-7`,ie=z?`h-4 w-4`:`h-3.5 w-3.5`,ae=z?`text-foreground hover:bg-surface-hover`:`text-white hover:bg-white/15`,oe=z?`h-12 w-px bg-border mx-1`:`h-12 w-px bg-white/15 mx-1`;return c(`div`,{className:$(ne,a),children:[D&&v(`div`,{className:`rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center`,children:o(`uiLibrary.ptzOverlay.error`,`PTZ: {{error}}`,{error:D})}),c(`div`,{className:$(re,z&&`justify-center`),children:[c(`div`,{className:`grid grid-cols-3 gap-0.5`,children:[v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`up`,icon:R,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`left`,icon:jr,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`right`,icon:di,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`down`,icon:$r,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`})]}),(B||i)&&v(`div`,{className:oe}),c(`div`,{className:`flex flex-col gap-0.5`,children:[B&&c(P,{children:[v(`button`,{type:`button`,onClick:()=>p(`in`),disabled:E,title:o(`uiLibrary.ptzOverlay.zoomIn`,`Zoom in`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(kr,{className:ie})}),v(`button`,{type:`button`,onClick:()=>p(`out`),disabled:E,title:o(`uiLibrary.ptzOverlay.zoomOut`,`Zoom out`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(Kr,{className:ie})})]}),i&&v(`button`,{type:`button`,onClick:()=>m(),disabled:E||h?.source===`none`,title:h?.source===`none`?o(`uiLibrary.ptzOverlay.noHome`,`No home preset set for this camera — pick one in PTZ settings`):o(`uiLibrary.ptzOverlay.goHome`,`Go home`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(Oi,{className:ie})})]}),H&&c(`div`,{className:`relative`,children:[c(`button`,{ref:N,type:`button`,onClick:()=>A(e=>!e),disabled:E,className:$(`flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40`,z?`h-9 text-foreground hover:bg-surface-hover`:`h-7 text-white hover:bg-white/15`),title:o(`uiLibrary.ptzOverlay.presets`,`Presets`),children:[o(`uiLibrary.ptzOverlay.presets`,`Presets`),v(de,{className:$(`h-3 w-3 transition-transform`,k&&`rotate-180`)})]}),k&&I&&Oo(c(`div`,{ref:F,style:{position:`fixed`,top:I.top,right:I.right,zIndex:60},className:$(`rounded-lg shadow-xl py-1`,U?`min-w-[220px]`:`min-w-[140px]`,z?`bg-surface border border-border`:`border border-white/30 bg-zinc-900/95 backdrop-blur-md`),children:[w.length===0&&v(`div`,{className:$(`px-3 py-1.5 text-[10px]`,z?`text-foreground-subtle`:`text-white/60`),children:o(`uiLibrary.ptzOverlay.noPresets`,`No presets yet`)}),w.map(e=>c(`div`,{className:$(`group flex items-center`,z?`hover:bg-surface-hover`:`hover:bg-white/15`),children:[v(`button`,{type:`button`,onClick:()=>{g(e.id),A(!1)},disabled:E,className:$(`flex-1 px-3 py-1.5 text-left text-[10px] disabled:opacity-40`,z?`text-foreground`:`text-white`),children:e.name||e.id}),U&&e.writable&&c(P,{children:[v(`button`,{type:`button`,onClick:()=>void te(e.id,e.name||e.id),disabled:E,title:o(`uiLibrary.ptzOverlay.overwriteTitle`,`Overwrite "{{name}}" with current position`,{name:e.name||e.id}),className:$(`flex h-5 w-5 shrink-0 items-center justify-center rounded`,`text-foreground-subtle hover:bg-primary/15 hover:text-primary disabled:opacity-40`),children:v(fi,{className:`h-3 w-3`})}),v(`button`,{type:`button`,onClick:()=>void G(e.id,e.name||e.id),disabled:E,title:o(`uiLibrary.ptzOverlay.deletePreset`,`Delete preset {{name}}`,{name:e.name||e.id}),className:$(`mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded`,`text-foreground-subtle hover:bg-danger/15 hover:text-danger disabled:opacity-40`),children:v(Zn,{className:`h-3 w-3`})})]})]},e.id)),U&&c(P,{children:[w.length>0&&v(`div`,{className:$(`my-1 h-px`,z?`bg-border`:`bg-white/15`)}),c(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[v(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&W()},disabled:E||ee,placeholder:o(`uiLibrary.ptzOverlay.newPreset`,`New preset name`),maxLength:64,className:$(`min-w-0 flex-1 rounded border px-2 py-1 text-[11px]`,`focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-40`,z?`border-border bg-surface text-foreground placeholder:text-foreground-subtle`:`border-white/30 bg-zinc-800 text-white placeholder:text-white/40`)}),v(`button`,{type:`button`,onClick:()=>void W(),disabled:E||ee||j.trim().length===0,title:ee?o(`uiLibrary.ptzOverlay.limitTitle`,`Camera preset limit reached ({{max}})`,{max:T?.maxPresets}):o(`uiLibrary.ptzOverlay.saveTitle`,`Save current position as a new preset`),className:$(`flex h-7 w-7 shrink-0 items-center justify-center rounded`,`bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-40`),children:v(Se,{className:`h-3.5 w-3.5`})})]}),ee&&v(`span`,{className:$(`block px-2 pb-1 text-[10px]`,z?`text-foreground-subtle`:`text-white/60`),children:o(`uiLibrary.ptzOverlay.limit`,`Preset limit reached ({{max}}).`,{max:T?.maxPresets})})]})]}),document.body)]})]})]})}E();function LI({deviceId:e}){let t=q(),n=Ge(Rn().trpcClient,e),[r,i]=C(null),[a,o]=C(!1);b(()=>{if(!n)return;let e=!1;return(async()=>{try{let t=await n.ptz?.getStatus({});if(e||!t)return;i(t.autofocus)}catch{}})(),()=>{e=!0}},[n]);let s=_(async()=>{if(!(!n?.ptz||r===null)){o(!0);try{let e=!r;await n.ptz.setAutofocus({enabled:e}),i(e)}catch(e){console.error(`ptz.setAutofocus failed`,e)}finally{o(!1)}}},[n,r]);return r===null?null:c(`div`,{className:`flex items-center justify-between border-t border-border/40 mt-2 pt-2`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.ptzPanel.autofocus`,`Autofocus`)}),c(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-pressed":r,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${r?`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`,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-success`:`bg-foreground-subtle/40`}`}),r?t(`uiLibrary.ptzPanel.on`,`On`):t(`uiLibrary.ptzPanel.off`,`Off`)]})]})}function RI({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),i=MI(n.trpcClient,r?e:0,{enabled:r});if(!r)return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.ptzPanel.notLoaded`,`Device #{{deviceId}} not loaded.`,{deviceId:e})});let a=i.options?.hasAutofocus===!0;return c($t,{title:`PTZ`,icon:v(He,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 flex flex-col overflow-y-auto`,children:[v(II,{controls:i,mode:`panel`}),v(PI,{controls:i}),a&&v(LI,{deviceId:e})]})}var zI=[0,1,2,3,4,5,6],BI=`00:00`,VI=`23:59`;function HI(e,t){return{days:[...zI],start:BI,end:VI,mode:e,...t}}function UI(){return{days:[...zI],start:`09:00`,end:`18:00`,mode:`continuous`}}function WI(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function GI(e,t){return e.filter((e,n)=>n!==t)}var KI=[1,2,3,4,5,6,0];function qI(e,t){switch(t){case 1:return e(`uiLibrary.recordingBands.mon`,`Mon`);case 2:return e(`uiLibrary.recordingBands.tue`,`Tue`);case 3:return e(`uiLibrary.recordingBands.wed`,`Wed`);case 4:return e(`uiLibrary.recordingBands.thu`,`Thu`);case 5:return e(`uiLibrary.recordingBands.fri`,`Fri`);case 6:return e(`uiLibrary.recordingBands.sat`,`Sat`);default:return e(`uiLibrary.recordingBands.sun`,`Sun`)}}var JI=[`continuous`,`events`];function YI(e,t){return t===`continuous`?e(`uiLibrary.recordingBands.continuous`,`Continuous`):e(`uiLibrary.recordingBands.events`,`Events`)}function XI({bands:e,onChange:t,sensorContext:n}){let r=q();return c(`div`,{className:`space-y-2`,children:[e.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.recordingBands.empty`,`No bands — nothing is recorded. Add one to start.`)}):e.map((r,i)=>v(eL,{band:r,onChange:n=>t(WI(e,i,n)),onRemove:()=>t(GI(e,i)),sensorContext:n},i)),c(`button`,{type:`button`,onClick:()=>t([...e,UI()]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[v(Se,{className:`h-3 w-3`}),` `,r(`uiLibrary.recordingBands.add`,`Add band`)]})]})}var ZI=Object.keys(Ia);function QI(e,t){return{type:`device-multiselect`,key:`sensorDeviceIds`,label:e(`uiLibrary.recordingBands.sensors`,`Sensors`),description:e(`uiLibrary.recordingBands.sensorsHint`,`Sensors whose ACTIVE edge starts a recording — a contact opening, a PIR firing. Same-location devices are suggested first.`),placeholder:e(`uiLibrary.recordingBands.addSensor`,`Add a sensor…`),maxItems:16,deviceFilter:{caps:ZI,types:[`sensor`],excludeDeviceId:t.cameraId},...t.location===null?{}:{suggestLocation:t.location}}}function $I(e){return e===``?void 0:Number(e)}function eL({band:e,onChange:t,onRemove:n,sensorContext:r}){let i=q(),a=n=>{let r=e.days.length===0?KI:e.days;t({days:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},o=n=>t({triggers:{...e.triggers,...n}});return c(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[v(`input`,{type:`time`,"aria-label":i(`uiLibrary.recordingBands.start`,`Band start`),value:e.start,onChange:e=>t({start:e.target.value}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),v(`span`,{className:`text-foreground-subtle`,children:`→`}),v(`input`,{type:`time`,"aria-label":i(`uiLibrary.recordingBands.end`,`Band end`),value:e.end,onChange:e=>t({end:e.target.value}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),v(`span`,{className:`flex gap-1`,children:JI.map(n=>v(`button`,{type:`button`,onClick:()=>t({mode:n}),className:`rounded px-2 py-0.5 ${e.mode===n?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:YI(i,n)},n))}),c(`button`,{type:`button`,"aria-label":i(`uiLibrary.recordingBands.audio`,`Band audio`),"aria-pressed":e.audio!==`muted`,title:e.audio===`muted`?i(`uiLibrary.recordingBands.silentTitle`,`Silent — this band records the video-only stream.`):i(`uiLibrary.recordingBands.soundTitle`,`With sound — this band records the camera’s audio.`),onClick:()=>t({audio:e.audio===`muted`?`on`:`muted`}),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 ${e.audio===`muted`?`bg-surface-hover text-foreground-subtle`:`bg-primary/10 text-primary`}`,children:[e.audio===`muted`?v(me,{className:`h-3.5 w-3.5`}):v(mt,{className:`h-3.5 w-3.5`}),e.audio===`muted`?i(`uiLibrary.recordingBands.silent`,`Silent`):i(`uiLibrary.recordingBands.sound`,`Sound`)]}),v(`span`,{className:`flex-1`}),v(`button`,{type:`button`,onClick:n,"aria-label":i(`uiLibrary.recordingBands.remove`,`Remove band`),className:`text-foreground-subtle hover:text-red-500`,children:v(Pe,{className:`h-3.5 w-3.5`})})]}),c(`div`,{className:`flex flex-wrap gap-1`,children:[KI.map(t=>v(`button`,{type:`button`,onClick:()=>a(t),className:`rounded px-1.5 py-0.5 text-[10px] ${e.days.length===0||e.days.includes(t)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:qI(i,t)},t)),e.days.length===0?v(`span`,{className:`self-center text-[10px] text-foreground-subtle`,children:i(`uiLibrary.recordingBands.everyDay`,`every day`)}):null]}),e.mode===`events`?c(`div`,{className:`space-y-1.5 border-t border-border pt-1.5`,children:[c(`label`,{className:`flex items-center gap-2 text-xs`,children:[v(`input`,{type:`checkbox`,checked:e.triggers?.motion??!1,onChange:e=>o({motion:e.target.checked?!0:void 0})}),i(`uiLibrary.recordingBands.motion`,`Motion`)]}),c(`label`,{className:`flex items-center gap-2 text-xs`,children:[v(`input`,{type:`checkbox`,checked:e.triggers?.audioThresholdDbfs!=null,onChange:e=>o({audioThresholdDbfs:e.target.checked?-30:void 0})}),i(`uiLibrary.recordingBands.audioAbove`,`Audio above threshold`),e.triggers?.audioThresholdDbfs==null?null:v(`input`,{type:`number`,"aria-label":i(`uiLibrary.recordingBands.threshold`,`Audio threshold dBFS`),value:e.triggers.audioThresholdDbfs,onChange:e=>o({audioThresholdDbfs:$I(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-0.5 text-xs`}),v(`span`,{className:`text-foreground-subtle`,children:`dBFS`})]}),c(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[v(`span`,{className:`text-foreground-subtle`,children:i(`uiLibrary.recordingBands.objects`,`Objects`)}),bee.map(t=>{let n=e.triggers?.objectClasses??[],r=n.includes(t);return v(`button`,{type:`button`,"aria-label":i(`uiLibrary.recordingBands.triggerOn`,`Trigger on {{class}}`,{class:t}),"aria-pressed":r,onClick:()=>{let e=r?n.filter(e=>e!==t):[...n,t];o({objectClasses:e.length>0?e:void 0})},className:`rounded px-1.5 py-0.5 text-[10px] ${r?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:t},t)})]}),r===void 0?null:v(zk,{field:QI(i,r),value:(e.triggers?.sensorDeviceIds??[]).map(String),onChange:e=>{let t=Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>0):[];o({sensorDeviceIds:t.length>0?t:void 0})}}),v(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:c(`label`,{className:`flex items-center gap-1`,children:[i(`uiLibrary.recordingBands.postBuffer`,`Post-buffer`),v(`input`,{type:`number`,min:0,value:e.postBufferSec??``,placeholder:String(xee.postBufferSec),onChange:e=>t({postBufferSec:$I(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`s`]})})]}):null]})}E();var tL=[{value:`off`,labelKey:`uiLibrary.recordingSettings.modeOff`,labelFallback:`Off`},{value:`events`,labelKey:`uiLibrary.recordingSettings.modeEvents`,labelFallback:`Events`},{value:`continuous`,labelKey:`uiLibrary.recordingSettings.modeContinuous`,labelFallback:`Continuous`},{value:`on-device-decision`,labelKey:`uiLibrary.recordingSettings.modeDeviceDecides`,labelFallback:`Device decides`}];function nL(e,t){return e===`present`?null:e===`pending`?t(`uiLibrary.recordingSettings.noteChecking`,`checking the camera…`):e===`absent`?t(`uiLibrary.recordingSettings.noteAbsent`,`this camera does not report when it needs recording`):t(`uiLibrary.recordingSettings.noteUnknown`,`could not check the camera`)}function rL({initial:e,availableProfiles:t,saving:n,onSave:r,sensorContext:i}){let a=q(),[o,s]=C([...e.bands]),[l,u]=C(e.deviceDecision===!0),[d,f]=C({profiles:e.profiles,segmentSeconds:e.segmentSeconds,retention:e.retention}),p=d.retention??{},m=e=>f({...d,retention:{...p,...e}}),h=e=>e===``?void 0:Number(e),g=vee({enabled:l||o.length>0,bands:o,deviceDecision:l}),_=i?.deviceSignal,y=_===`present`||l,b=Ui(t,d.profiles),x=e=>{let t=b.includes(e)?b.filter(t=>t!==e):[...b,e];f({...d,profiles:t.length?t:void 0})},S=e=>{if(e===`off`){s([]),u(!1);return}if(e===`on-device-decision`){s([]),u(!0);return}u(!1),e!==g&&s([HI(e)])},w=()=>{let e=t.length>0?Ui(t,d.profiles):d.profiles?[...d.profiles]:void 0;r({enabled:l||o.length>0,bands:l?[]:o,...l?{deviceDecision:!0}:{},...e===void 0?{}:{profiles:e},segmentSeconds:d.segmentSeconds,retention:d.retention})},T=Cee.filter(e=>t.includes(e));return c(`div`,{className:`space-y-4`,children:[c(`div`,{className:`flex items-center gap-2 text-xs`,children:[v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.mode`,`Mode:`)}),tL.map(e=>{let t=e.value===`on-device-decision`,n=t?nL(_,a):null;return v(`button`,{type:`button`,"aria-label":a(`uiLibrary.recordingSettings.modeAria`,`Mode {{label}}`,{label:a(e.labelKey,e.labelFallback)}),title:n??void 0,disabled:t&&!y,onClick:()=>S(e.value),className:`rounded px-2.5 py-1 ${g===e.value?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`} disabled:cursor-not-allowed disabled:opacity-50`,children:a(e.labelKey,e.labelFallback)},e.value)})]}),l?v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.deviceDecides`,`The DEVICE decides: this camera records for as long as it reports it is in function — a robot while it cleans — and one job is one clip. There is nothing to schedule, so this mode has no bands.`)}):c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.bands`,`Recording bands`)}),v(XI,{bands:o,onChange:s,sensorContext:i}),v(`p`,{className:`mt-1.5 text-[11px] text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.bandsHint`,`A band says WHEN to record and HOW. Nothing is recorded outside every band — an empty table means this camera is off.`)})]}),c(`div`,{className:`flex flex-wrap items-center gap-4 text-xs`,children:[T.length>0?c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.profiles`,`Profiles:`)}),T.map(e=>v(`button`,{type:`button`,onClick:()=>x(e),className:`rounded px-2 py-1 ${b.includes(e)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:e},e))]}):v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.noStreams`,`No assigned streams to record yet.`)}),c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.segment`,`Segment`),v(`input`,{type:`number`,min:1,value:d.segmentSeconds??``,placeholder:a(`uiLibrary.recordingSettings.default`,`default`),onChange:e=>f({...d,segmentSeconds:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`s`]})]}),c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.retention`,`Retention (empty = node default)`)}),c(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.maxAge`,`Max age`),v(`input`,{type:`number`,min:0,value:p.maxAgeDays??``,placeholder:`14`,onChange:e=>m({maxAgeDays:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),a(`uiLibrary.recordingSettings.days`,`days`)]}),c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.maxSize`,`Max size`),v(`input`,{type:`number`,min:0,value:p.maxSizeGb??``,placeholder:`∞`,onChange:e=>m({maxSizeGb:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`GB`]})]})]}),v(`div`,{className:`flex justify-end`,children:c(`button`,{type:`button`,disabled:n,onClick:w,className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-60`,children:[n?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(ji,{className:`h-3.5 w-3.5`}),a(`uiLibrary.recordingSettings.save`,`Save`)]})})]})}function iL(e){return JSON.stringify(e)}var aL=[`live`,`loading`,`playing`,`paused`,`gap`,`ended`,`error`];function oL(e){return typeof e==`string`&&aL.includes(e)}function sL(e){return e===`high`||e===`mid`||e===`low`}function cL(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n={...t};return n.t===`state`&&oL(n.state)?{kind:`state`,state:n.state}:n.t===`position`&&typeof n.epochMs==`number`?{kind:`position`,epochMs:n.epochMs}:n.t===`servedProfile`&&sL(n.profile)&&typeof n.requested==`string`?{kind:`servedProfile`,profile:n.profile,requested:n.requested}:null}E();var lL=Kn(`camstack:recorded-playback`,{bindControlChannel:null,channelOpen:!1,mode:`live`,positionMs:null,send:()=>!1});function uL({children:e}){let t=f(null),[n,r]=C(!1),[i,a]=C(`live`),[o,s]=C(null),c=_(e=>{t.current=e;let n=()=>{t.current===e&&(t.current=null,r(!1),a(`live`),s(null))};e.onopen=()=>{t.current===e&&r(!0)},e.onclose=n,e.onerror=n,e.onmessage=n=>{if(t.current!==e)return;let r=n.data;if(typeof r!=`string`)return;let i=cL(r);i&&(i.kind===`position`?s(i.epochMs):i.kind===`state`&&(a(i.state),i.state===`live`&&s(null)))},e.readyState===`open`?r(!0):e.readyState===`closed`||e.readyState===`closing`?n():r(!1)},[]),l=_(e=>{let n=t.current;return!n||n.readyState!==`open`?!1:(n.send(iL(e)),!0)},[]),u=p(()=>({bindControlChannel:c,channelOpen:n,mode:i,positionMs:o,send:l}),[c,n,i,o,l]);return v(lL.Provider,{value:u,children:e})}function dL(){return I(lL)}E();var fL={scrubbing:!1,scrubEpoch:null,playheadEpoch:null,lastSource:null};function pL(e,t){switch(t.type){case`begin`:return{...e,scrubbing:!0,scrubEpoch:null,lastSource:t.source};case`update`:return{...e,scrubbing:!0,scrubEpoch:t.epoch,lastSource:t.source};case`end`:return{...e,scrubbing:!1,scrubEpoch:null,playheadEpoch:t.epoch,lastSource:t.source};case`seek`:return{...e,scrubbing:!1,scrubEpoch:null,playheadEpoch:t.epoch,lastSource:t.source};case`playhead`:return e.scrubbing?e:{...e,playheadEpoch:t.epoch};case`reset`:return fL;default:return e}}function mL(e,t,n=70){return t-e>=n}var hL=2e3;function gL(e,t,n,r=750,i=hL){if(e===null)return!0;let a=Math.abs(t-e.epoch)<=r,o=n-e.at<=i;return!(a&&o)}function _L(e,t){let n=e.scrubbing?e.scrubEpoch:e.playheadEpoch;if(n===null)return null;let r=t.to-t.from;return r<=0?null:Math.min(1,Math.max(0,(n-t.from)/r))}function vL(e,t,n,r={current:null},i=()=>!1){let a=(e,t)=>{let n=Date.now();if(i()){r.current={epoch:e,at:n},t(e);return}gL(r.current,e,n)&&(r.current={epoch:e,at:n},t(e))};return{beginScrub:n=>{t({type:`begin`,source:n}),e.scrubStart()},updateScrub:(r,i)=>{t({type:`update`,epoch:r,source:i});let a=Date.now();mL(n.current,a)&&(n.current=a,e.scrubTo(r))},endScrub:(n,r)=>{t({type:`end`,epoch:n,source:r}),a(n,e.scrubCommit)},seek:(n,r)=>{t({type:`seek`,epoch:n,source:r}),a(n,e.seek)},setPlayhead:e=>t({type:`playhead`,epoch:e}),reset:()=>t({type:`reset`})}}function yL(e,t=()=>!1){let[n,r]=A(pL,fL),i=f(0),a=f(null),o=f(t);return o.current=t,{state:n,...p(()=>vL(e,r,i,a,()=>o.current()),[e])}}E();var bL=O(null);function xL(){let e=I(bL);if(!e)throw Error(`Dialog compound components must be used within <Dialog>`);return e}function SL({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t??r,o=y(),s=_(e=>{n?.(e),t===void 0&&i(e)},[t,n]);return v(bL.Provider,{value:{open:a,setOpen:s,contentId:o},children:e})}function CL({children:e,...t}){let{setOpen:n}=xL();return v(`button`,{type:`button`,onClick:()=>n(!0),...t,children:e})}var wL=Il(`relative fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 m-0 w-[calc(100vw-2rem)] bg-background-elevated text-foreground border border-border rounded-lg p-4 backdrop:bg-black/50 backdrop:backdrop-blur-sm max-h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] [&:not([open])]:hidden`,{variants:{width:{sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-4xl`},scroll:{content:`overflow-y-auto overscroll-contain`,body:`flex flex-col overflow-hidden overscroll-contain`},placement:{center:``,"sheet-on-mobile":`bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none max-h-[92dvh] pb-[calc(1rem+env(safe-area-inset-bottom))] md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:bottom-auto md:pb-4 md:max-h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))]`}},compoundVariants:[{placement:`sheet-on-mobile`,width:`sm`,class:`md:w-[calc(100vw-2rem)] md:max-w-sm`},{placement:`sheet-on-mobile`,width:`md`,class:`md:w-[calc(100vw-2rem)] md:max-w-md`},{placement:`sheet-on-mobile`,width:`lg`,class:`md:w-[calc(100vw-2rem)] md:max-w-lg`},{placement:`sheet-on-mobile`,width:`xl`,class:`md:w-[calc(100vw-2rem)] md:max-w-4xl`},{scroll:`body`,placement:`sheet-on-mobile`,class:`h-[92dvh] md:h-auto`},{scroll:`body`,placement:`center`,class:`h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] md:h-auto`}],defaultVariants:{width:`md`,placement:`center`,scroll:`content`}}),TL=D(({className:e,width:t,placement:n,scroll:r,children:i,...a},o)=>{let{open:s,setOpen:l,contentId:u}=xL(),d=q(),p=f(null),m=o??p;return b(()=>{let e=m.current;e&&(s&&!e.open&&e.showModal(),!s&&e.open&&e.close())},[s,m]),c(`dialog`,{ref:m,id:u,className:$(wL({width:t,placement:n,scroll:r}),e),onClose:()=>l(!1),...a,children:[v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:Zn,"aria-label":d(`uiLibrary.dialog.close`,`Close`),className:`absolute right-4 top-4 z-10 shrink-0`,onClick:()=>l(!1)}),v(Os,{id:u,modal:!0,enabled:s,children:i})]})});TL.displayName=`DialogContent`;function EL({className:e,...t}){return v(`div`,{className:$(`flex flex-col gap-1 mb-3 shrink-0 pr-10`,e),...t})}function DL({className:e,...t}){return v(`div`,{className:$(`flex-1 min-h-0 overflow-y-auto overscroll-contain`,e),...t})}function OL({className:e,...t}){return v(`div`,{className:$(`flex justify-end gap-2 mt-4 shrink-0`,e),...t})}function kL({className:e,...t}){return v(`h2`,{className:$(`text-sm font-semibold text-foreground`,e),...t})}function AL({className:e,...t}){return v(`p`,{className:$(`text-xs text-foreground-muted`,e),...t})}E();function jL({value:e,onChange:t}){let n=q(),r=Ox({}),i=Dx(),[a,o]=C(``),[s,l]=C(null),u=r.data??[],d=async()=>{l(null);let e=await i.mutateAsync({name:a});if(e.kind===`refused`){l(e.reason);return}o(``),await r.refetch(),t(e.collection.id)};return c(`div`,{className:`space-y-2`,"data-testid":`training-collection-picker`,children:[u.length>0?v(Yl,{"aria-label":n(`uiLibrary.trainingCollectionPicker.collection`,`Collection`),value:e??``,options:[{value:``,label:n(`uiLibrary.trainingCollectionPicker.choose`,`Choose a collection…`)},...u.map(e=>({value:e.id,label:`${e.name} (${String(e.frameCount)})`}))],onChange:e=>{e.target.value!==``&&t(e.target.value)}}):v(`p`,{className:`text-xs text-foreground-subtle`,children:r.isLoading?n(`uiLibrary.trainingCollectionPicker.reading`,`Reading the collections…`):n(`uiLibrary.trainingCollectionPicker.none`,`No collection yet — create one.`)}),c(`div`,{className:`flex items-center gap-2`,children:[v(Bl,{className:`flex-1`,"aria-label":n(`uiLibrary.trainingCollectionPicker.newName`,`New collection name`),placeholder:n(`uiLibrary.trainingCollectionPicker.newPlaceholder`,`New collection (e.g. missed at night)`),value:a,onChange:e=>{o(e.target.value)}}),c(_A,{type:`button`,variant:`secondary`,size:`sm`,disabled:i.isPending||a.trim()===``,onClick:()=>void d(),children:[v(Se,{className:`h-3 w-3`}),n(`uiLibrary.trainingCollectionPicker.create`,`Create`)]})]}),s!==null&&v(`p`,{className:`text-xs text-danger`,children:s===`empty-name`?n(`uiLibrary.trainingCollectionPicker.emptyName`,`Give the collection a name.`):n(`uiLibrary.trainingCollectionPicker.duplicateName`,`A collection with that name already exists.`)})]})}var ML={"unknown-collection":`That collection no longer exists — pick another one.`,"still-unavailable":`No frame could be taken from the recording at that moment.`,"still-busy":`The recorder is busy decoding other frames. Try again in a moment.`,"unreadable-image":`The recorder returned something that is not a picture.`,"write-failed":`The frame could not be stored. Check the artifacts storage.`};function NL(e,t){let n=ML[e];return t!==void 0&&t!==``?`${n} (${t})`:n}E();function PL({deviceId:e,epochMs:t}){let n=q(),r=Ox({},{retry:!1}),i=Mx(),[a,o]=C(!1),[s,l]=C(null),[u,d]=C(null),[f,p]=C(null);if(r.isError)return null;let m=async()=>{if(s===null||u===null)return;let t=await i.mutateAsync({collectionId:s,deviceId:e,epochMs:u}),a=r.data?.find(e=>e.id===s)?.name??n(`uiLibrary.sendFrameToTraining.theCollection`,`the collection`);p(t.kind===`added`?{kind:`added`,reused:t.reused,collection:a}:{kind:`refused`,text:NL(t.reason,t.detail)}),t.kind===`added`&&await r.refetch()};return c(P,{children:[c(_A,{type:`button`,variant:`secondary`,size:`sm`,"data-testid":`send-frame-to-training`,disabled:t===null,title:t===null?n(`uiLibrary.sendFrameToTraining.playFirst`,`Play back a recording first — the frame at the playhead is the one sent`):n(`uiLibrary.sendFrameToTraining.addFrame`,`Add the frame at the playhead to a training collection`),onClick:()=>{d(t),p(null),o(!0)},children:[v(ct,{className:`h-3.5 w-3.5`}),n(`uiLibrary.sendFrameToTraining.button`,`Send frame to training`)]}),v(SL,{open:a,onOpenChange:e=>!i.isPending&&o(e),children:c(TL,{children:[c(EL,{children:[v(kL,{children:n(`uiLibrary.sendFrameToTraining.title`,`Send this frame to training`)}),v(AL,{children:u===null?``:n(`uiLibrary.sendFrameToTraining.description`,`The camera's frame at {{time}} is taken from the recording at full resolution and added to the collection. Annotate it on the Retrain page — including what the model missed.`,{time:new Date(u).toLocaleString()})})]}),v(jL,{value:s,onChange:l}),f!==null&&v(`p`,{className:`mt-2 text-xs ${f.kind===`added`?`text-success`:`text-danger`}`,role:`status`,children:f.kind===`added`?f.reused?n(`uiLibrary.sendFrameToTraining.reused`,`That moment was already in the dataset; it is now in {{collection}}.`,{collection:f.collection}):n(`uiLibrary.sendFrameToTraining.added`,`Added to {{collection}}.`,{collection:f.collection}):f.text}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:i.isPending,onClick:()=>{o(!1)},children:f?.kind===`added`?n(`uiLibrary.sendFrameToTraining.done`,`Done`):n(`uiLibrary.sendFrameToTraining.cancel`,`Cancel`)}),c(_A,{type:`button`,size:`sm`,disabled:s===null||i.isPending||f?.kind===`added`,onClick:()=>void m(),children:[i.isPending&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),n(`uiLibrary.sendFrameToTraining.send`,`Send`)]})]})]})})]})}E();function FL({windowFrom:e,windowTo:t,spans:n,playheadMs:r,onSeek:i,onScrubStart:a,onScrubMove:o,onScrubEnd:s}){let l=q(),[u,d]=C(null),p=!!s,[m,h]=C(!1),g=f(null),_=n=>{let r=n.currentTarget.getBoundingClientRect();if(r.width<=0)return null;let i=(n.clientX-r.left)/r.width;return e+Math.min(1,Math.max(0,i))*(t-e)},y=e=>{if(p)return;let t=_(e);t!==null&&i(t)},b=e=>{if(!p)return;e.currentTarget.setPointerCapture(e.pointerId),h(!0),a?.();let t=_(e);t!==null&&(g.current=t,o?.(t))},x=e=>{if(!p||!m)return;let t=_(e);t!==null&&(g.current=t,o?.(t))},S=e=>{if(!p||!m)return;h(!1);let t=_(e)??g.current;g.current=null,t!==null&&s?.(t)},w=()=>{if(!m)return;h(!1);let e=g.current;g.current=null,e!==null&&s?.(e)},T=e=>{let t=_(e);if(t===null)return;let n=e.currentTarget.getBoundingClientRect();d({xPct:n.width>0?(e.clientX-n.left)/n.width*100:0,ms:t})},E=()=>{d(null)},D=u===null?null:new Date(u.ms).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return c(`div`,{className:`relative`,children:[c(`div`,{"data-testid":`coverage-track`,"data-scrubbing":m?`true`:`false`,onClick:y,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:w,onMouseMove:T,onMouseLeave:E,className:`relative h-5 overflow-hidden rounded bg-background/40 ${p?`cursor-ew-resize touch-none select-none`:`cursor-pointer`}`,role:`group`,"aria-label":l(`uiLibrary.coverageTrack.ariaLabel`,`Recorded coverage timeline`),children:[n.map(n=>{let r=VM(n.startMs,e,t),i=VM(n.endMs,e,t);return v(`div`,{"data-testid":`coverage-band`,className:`absolute inset-y-0 bg-gradient-to-b from-primary to-primary/80`,style:{left:`${r}%`,width:`${Math.max(.5,i-r)}%`}},`${n.startMs}-${n.endMs}`)}),r===null?null:v(`div`,{"data-testid":`coverage-playhead`,className:`absolute inset-y-[-2px] w-0.5 bg-amber-500 shadow-[0_0_6px] shadow-amber-500`,style:{left:`${VM(r,e,t)}%`}})]}),u!==null&&D!==null?v(`div`,{"data-testid":`coverage-hover-tooltip`,className:`pointer-events-none absolute top-full z-10 mt-0.5 -translate-x-1/2 rounded bg-popover px-1.5 py-0.5 text-[9px] text-popover-foreground shadow`,style:{left:`${u.xPct}%`},children:D}):null]})}E();function IL({mediaUrl:e,kind:t}){let[n,r]=C(!1);return e&&!n?v(`img`,{src:e,alt:``,className:`h-full w-full object-cover`,loading:`lazy`,onError:()=>r(!0)}):v(`div`,{className:`flex h-full w-full items-center justify-center text-white/30`,children:v(LL,{kind:t,large:!0})})}function LL({kind:e,large:t=!1}){return v(e===`object`?Ze:e===`audio`?mt:ai,{className:t?`h-7 w-7`:`h-3.5 w-3.5 text-foreground-subtle`})}var RL=[`motion`,`object`,`audio`];function zL(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function BL({clips:e,loading:t,busyKey:n,onPlay:r,enabledKinds:i,onToggleKind:a,hasMore:o,onLoadMore:s}){let l=q(),u=v(`div`,{className:`flex items-center gap-3 pb-1`,children:RL.map(e=>c(`label`,{className:`flex cursor-pointer items-center gap-1 text-xs text-foreground-subtle select-none`,children:[v(`input`,{type:`checkbox`,checked:i.has(e),onChange:()=>a(e),className:`h-3.5 w-3.5 accent-primary`}),e]},e))});return t&&e.length===0?c(`div`,{className:`space-y-2`,children:[u,v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.loading`,`Loading events…`)})]}):e.length===0?c(`div`,{className:`space-y-2`,children:[u,v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.empty`,`No events in this window.`)})]}):c(`div`,{className:`space-y-2`,children:[u,t?v(`div`,{className:`px-1 text-[10px] text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.loading`,`Loading events…`)}):null,v(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.map(e=>{let t=`${e.kind}:${e.id}`;return c(`button`,{type:`button`,disabled:n!==null,onClick:()=>r(e),className:`group overflow-hidden rounded-lg border border-border text-left transition-colors hover:border-primary disabled:opacity-60`,children:[c(`div`,{className:`relative aspect-video bg-black/90`,children:[v(IL,{mediaUrl:e.mediaUrl,kind:e.kind}),v(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/30`,children:n===t?v(Gn,{className:`h-6 w-6 animate-spin text-white`}):v(Le,{className:`h-6 w-6 text-white opacity-0 transition-opacity group-hover:opacity-100`})})]}),c(`div`,{className:`flex items-center gap-1.5 bg-surface px-2 py-1.5`,children:[v(LL,{kind:e.kind}),c(`div`,{className:`min-w-0 flex-1`,children:[v(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.label}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:zL(e.timestamp)})]})]})]},t)})}),e.length>0?c(`div`,{className:`flex items-center gap-2 pt-1 text-[11px] text-foreground-subtle`,children:[v(`span`,{children:l(`uiLibrary.eventBucketStrip.shown`,`({{count}} shown)`,{count:e.length})}),o?v(`button`,{type:`button`,onClick:s,className:`rounded px-2 py-0.5 text-[11px] font-medium text-primary hover:underline`,children:l(`uiLibrary.eventBucketStrip.loadMore`,`Load more`)}):null]}):null]})}function VL(e){let t=e.filter(e=>e.endMs>e.startMs).map(e=>({startMs:e.startMs,endMs:e.endMs})).toSorted((e,t)=>e.startMs-t.startMs),n=[];for(let e of t){let t=n[n.length-1];t&&e.startMs<=t.endMs?e.endMs>t.endMs&&(n[n.length-1]={startMs:t.startMs,endMs:e.endMs}):n.push(e)}return n}function HL(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1024)return`${Math.round(e)} B`;let t=[`KB`,`MB`,`GB`,`TB`,`PB`],n=e/1024,r=`KB`;for(let e of t){if(r=e,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${r}`}E();var UL=[`motion`,`object`,`audio`],WL=60,GL=18e3/100,KL=5e3,qL=1e4,JL=[];function YL(e,t){switch(t){case`live`:return e(`uiLibrary.recordingTimeline.modeLive`,`Live`);case`loading`:return e(`uiLibrary.recordingTimeline.modeLoading`,`Loading…`);case`playing`:return e(`uiLibrary.recordingTimeline.modePlaying`,`Playing`);case`paused`:return e(`uiLibrary.recordingTimeline.modePaused`,`Paused`);case`gap`:return e(`uiLibrary.recordingTimeline.modeGap`,`No footage`);case`ended`:return e(`uiLibrary.recordingTimeline.modeEnded`,`Ended`);case`error`:return e(`uiLibrary.recordingTimeline.modeError`,`Error`)}}function XL({deviceId:e}){let t=q(),n=Rn(),r=mF(),[i,a]=C(null),[o,s]=C(null),[l,u]=C(null),[d,m]=C(null),h=dL(),{send:g,mode:y,positionMs:x}=h,[S,w]=C(!1),T=h.channelOpen&&!S,E=f(T);E.current=T;let D=p(()=>({scrubStart:()=>{},scrubTo:()=>{},scrubCommit:e=>{g({t:`scrubCommit`,epoch:e})},seek:e=>{g({t:`seek`,epoch:e})}}),[g]),O=f(y);O.current=y;let{state:k,beginScrub:A,updateScrub:j,endScrub:M,seek:N,setPlayhead:P,reset:F}=yL(D,_(()=>O.current===`live`,[]));b(()=>{x!==null&&P(x)},[x,P]),b(()=>{(!h.channelOpen||y===`live`)&&F()},[h.channelOpen,y,F]);let I=_(()=>{g({t:`goLive`}),F()},[g,F]),L=_(()=>{g({t:`setRate`,rate:+(O.current===`paused`)})},[g]),[R,z]=C(()=>new Set(UL)),B=_(e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[V,H]=C(WL),U=_(()=>{H(e=>e+WL)},[]);b(()=>{H(WL)},[i]);let[ee,W]=C(()=>new Date),[G,te]=C(()=>HM(new Date,Date.now())),ne=p(()=>HM(ee,Date.now()),[ee]),re=_(e=>{W(e),te(HM(e,Date.now())),a(null)},[]),K=_(e=>{te(e),a(null)},[]),ie=f(null),ae=_(e=>{let t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;if(t===0)return;e.preventDefault();let n=t*GL;te(e=>GM(e,ne,n))},[ne]),oe=qM(G.toMs-G.fromMs),se=Yw({deviceId:e,provider:ia,fromMs:G.fromMs,toMs:G.toMs}),ce=Ob({deviceId:e,since:G.fromMs,until:G.toMs,bucketMs:oe}),le=se.data?.read===`unreadable`,ue=se.data?.read===`read`?se.data.ranges:JL,de=p(()=>VL(ue),[ue]),pe=p(()=>RM(ce.data??[],G.fromMs,oe),[ce.data,G.fromMs,oe]),me=i===null?void 0:pe.find(e=>e.index===i),he=me!==void 0,ge=me?.startMs??0,_e=me?Math.min(me.endMs,G.toMs):0,ve=bb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`object`)}),ye=yb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`motion`)}),be=xb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`audio`)}),xe=p(()=>{if(!me)return[];let e=[];if(R.has(`object`))for(let t of ve.data??[])e.push({id:String(t.id),timestamp:t.timestamp,kind:`object`,label:t.label??t.className,mediaUrl:t.mediaUrl});if(R.has(`motion`))for(let n of ye.data??[])e.push({id:String(n.id),timestamp:n.timestamp,kind:`motion`,label:t(`uiLibrary.recordingTimeline.motionClip`,`Motion ({{count}})`,{count:n.regionCount}),mediaUrl:n.mediaUrl});if(R.has(`audio`))for(let n of be.data??[])e.push({id:String(n.id),timestamp:n.timestamp,kind:`audio`,label:n.classification?.className??t(`uiLibrary.recordingTimeline.audioClip`,`Audio`),mediaUrl:n.mediaUrl});return e.toSorted((e,t)=>t.timestamp-e.timestamp)},[me,R,ve.data,ye.data,be.data,t]),Se=p(()=>!!(R.has(`object`)&&(ve.data?.length??0)===V||R.has(`motion`)&&(ye.data?.length??0)===V||R.has(`audio`)&&(be.data?.length??0)===V),[R,ve.data,ye.data,be.data,V]),Ce=_(async(t,i,a,o,c)=>{u(t),m(null);try{let t=await n.trpcClient.recording.getPlayback.query({deviceId:e,provider:ia,fromMs:i,toMs:a});t.kind===`hls`&&t.manifest.playbackUrl?(s(c),r.play({url:t.manifest.playbackUrl,label:o})):m(t.kind===`none`?`No playable footage for this selection — ${t.reason}`:`No playable footage for this selection.`)}catch{m(`Could not load this recording.`)}finally{u(null)}},[n,e,r]),we=_(e=>{let t=BM(e,de);if(!t)return;if(E.current){N(t.fromMs,`timeline`);return}let n=`Recording · ${new Date(t.fromMs).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}`;Ce(`seek:${t.fromMs}`,t.fromMs,t.toMs,n,t.fromMs)},[de,Ce,N]),Te=_(()=>{A(`timeline`)},[A]),Ee=_(e=>{j(e,`timeline`)},[j]),De=_(e=>{M(BM(e,de)?.fromMs??e,`timeline`)},[de,M]),Oe=_(e=>{if(E.current){N(e.timestamp-KL,`timeline`);return}let t=`${e.label} · ${new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`;Ce(`${e.kind}:${e.id}`,e.timestamp-KL,e.timestamp+qL,t,e.timestamp)},[Ce,N]),ke=_(e=>{a(t=>t===e?null:e)},[]),Ae=se.isLoading,je=ce.isLoading,Me=(ve.isLoading||ye.isLoading||be.isLoading)&&he,Ne=p(()=>JM(G.fromMs,G.toMs,5),[G.fromMs,G.toMs]),Pe=T?k.scrubbing?k.scrubEpoch:k.playheadEpoch:o,Fe=T&&(y===`playing`||y===`paused`);return c(`div`,{className:`space-y-3`,children:[se.isError?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingTimeline.recorderUnavailable`,`Recorder unavailable — the recording service may not be running for this node.`)}):null,le?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingTimeline.availabilityUnreadable`,`CamStack could not be asked about this camera's recordings — this bar shows nothing, which is not the same as no footage.`)}):null,d?v(eN,{variant:`warning`,message:d}):null,v(cF,{day:ee,onDayChange:re,view:G,dayBounds:ne,onViewChange:K}),v(`div`,{className:`flex justify-end`,children:v(PL,{deviceId:e,epochMs:Pe})}),h.channelOpen?c(`div`,{"data-testid":`frame-push-status-row`,className:`flex flex-wrap items-center gap-2 text-[10px]`,children:[v(`span`,{"data-testid":`frame-push-mode-chip`,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-semibold uppercase tracking-wider ${T&&y!==`live`?y===`error`?`bg-rose-500/15 text-rose-400`:`bg-primary/15 text-primary`:`bg-background/40 text-foreground-subtle`}`,children:T?YL(t,y):t(`uiLibrary.recordingTimeline.hlsMode`,`HLS mode`)}),T&&x!==null&&!k.scrubbing?v(`span`,{className:`tabular-nums text-foreground-subtle`,children:new Date(x).toLocaleTimeString()}):null,Fe?c(`button`,{type:`button`,"data-testid":`frame-push-rate-toggle`,onClick:L,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,title:y===`paused`?t(`uiLibrary.recordingTimeline.resumeTitle`,`Resume playback`):t(`uiLibrary.recordingTimeline.pauseTitle`,`Pause playback`),children:[v(y===`paused`?Le:Vt,{className:`h-3 w-3`}),y===`paused`?t(`uiLibrary.recordingTimeline.resume`,`Resume`):t(`uiLibrary.recordingTimeline.pause`,`Pause`)]}):null,T&&y!==`live`?c(`button`,{type:`button`,"data-testid":`frame-push-go-live`,onClick:I,className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 font-medium text-danger transition-colors hover:bg-danger/20`,title:t(`uiLibrary.recordingTimeline.liveTitle`,`Return to the live stream`),children:[v(fe,{className:`h-3 w-3`}),t(`uiLibrary.recordingTimeline.goLive`,`Go live`)]}):null,v(`button`,{type:`button`,"data-testid":`frame-push-hls-toggle`,onClick:()=>w(e=>!e),className:`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium transition-colors ${S?`bg-primary/15 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:t(`uiLibrary.recordingTimeline.hlsTitle`,`Play recordings through the HLS player instead of the live WebRTC session`),children:`HLS`})]}):null,c(`div`,{ref:ie,onWheel:ae,className:`space-y-1`,children:[c(`div`,{className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`uiLibrary.recordingTimeline.recorded`,`Recorded`)}),Ae?v(`div`,{className:`h-5 animate-pulse rounded bg-background/40`}):de.length===0?v(QM,{icon:Kt,title:t(`uiLibrary.recordingTimeline.noRecordings`,`No recordings for this window.`)}):v(FL,{windowFrom:G.fromMs,windowTo:G.toMs,spans:de,playheadMs:Pe,onSeek:we,...T?{onScrubStart:Te,onScrubMove:Ee,onScrubEnd:De}:{}})]}),c(`div`,{className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`uiLibrary.recordingTimeline.density`,`Events · density`)}),je?v(`div`,{className:`h-6 animate-pulse rounded bg-background/40`}):v(aF,{windowFrom:G.fromMs,windowTo:G.toMs,buckets:pe,selectedIndex:i,onSelectBucket:ke})]}),v(`div`,{className:`relative h-3`,children:Ne.map(e=>v(`span`,{className:`absolute -translate-x-1/2 text-[9px] text-foreground-subtle`,style:{left:`${e.pct}%`},children:e.label},e.pct))})]}),me?v(BL,{clips:xe,loading:Me,busyKey:l,onPlay:Oe,enabledKinds:R,onToggleKind:B,hasMore:Se,onLoadMore:U}):v(`p`,{className:`text-[11px] text-foreground-subtle`,children:T?t(`uiLibrary.recordingTimeline.helpFramePush`,`Click or drag the coverage bar to play from any point (frames play in the main player above), or click a density bar to browse that window’s events.`):t(`uiLibrary.recordingTimeline.helpHls`,`Click the coverage bar to play from any point, or a density bar to browse that window’s events.`)})]})}E();var ZL=1440*60*1e3;function QL({deviceId:e}){let t=q(),n=k(),r=kT({deviceId:e}),i=nT({deviceId:e}),a=fm({deviceId:e}).data?.location??null,o=Cm({deviceId:e}),s=o.status===`pending`?`pending`:o.status===`error`?`unknown`:o.data.entries.some(e=>e.capName===`recording-signal`)?`present`:`absent`,l=sT(),u=cT(),{data:d}=ED(void 0,{staleTime:3e4}),f=p(()=>Tee(d??[],e).map(e=>e.profile),[d,e]),m=t=>{l.mutate({deviceId:e,config:t},{onSuccess:()=>{i.refetch(),r.refetch()}})},h=_(()=>{u.mutate({deviceId:e},{onSuccess:()=>{n.invalidateQueries({queryKey:[[`recording`]]})}})},[e,n,u]),g=p(()=>Date.now(),[]),y=Yw({deviceId:e,provider:ia,fromMs:g-ZL,toMs:g}),b=r.data?Ta.safeParse(r.data):null,x=b?.success?b.data:null,S=i.data?See.safeParse(i.data):null,C=S?.success?S.data:null,w=y.data?.read===`unreadable`,T=y.data?.read===`read`?y.data.ranges:[],E=T.reduce((e,t)=>e+Math.max(0,t.endMs-t.startMs),0),D=x?.enabled===!0&&x.activeMode===`continuous`;return c(`div`,{className:`space-y-3`,children:[v($t,{title:t(`uiLibrary.recordingPanel.settings`,`Settings`),icon:v(Yn,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:C?v(rL,{initial:C,availableProfiles:f,saving:l.isPending,onSave:m,sensorContext:{cameraId:e,location:a,deviceSignal:s}},JSON.stringify(C)):v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:t(`uiLibrary.recordingPanel.loadingSettings`,`Loading settings…`)})}),v($t,{title:t(`uiLibrary.recordingPanel.recording`,`Recording`),icon:v(Kt,{className:`h-3.5 w-3.5 text-foreground-subtle`}),headerRight:c(`span`,{className:`flex items-center gap-2`,children:[D?c(`span`,{className:`flex items-center gap-1.5 text-[10px] text-emerald-500`,children:[v(fe,{className:`h-3 w-3`}),` `,t(`uiLibrary.recordingPanel.recording`,`Recording`)]}):null,v(`button`,{type:`button`,onClick:h,disabled:u.isPending,"aria-label":t(`uiLibrary.recordingPanel.rescanStorage`,`Rescan storage`),className:`flex items-center rounded p-0.5 text-foreground-subtle transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:v(_e,{className:`h-3.5 w-3.5 ${u.isPending?`animate-spin`:``}`})})]}),children:c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[v(an,{label:t(`uiLibrary.recordingPanel.status`,`Status`),icon:v(Si,{className:`h-3.5 w-3.5 ${D?`text-emerald-500`:``}`}),footer:x?.nodeId?t(`uiLibrary.recordingPanel.nodeFooter`,`node: {{nodeId}}`,{nodeId:x.nodeId}):void 0,children:r.isLoading?`…`:D?t(`uiLibrary.recordingPanel.recordingContinuous`,`Recording (continuous)`):t(`uiLibrary.recordingPanel.idle`,`Idle`)}),v(an,{label:t(`uiLibrary.recordingPanel.storage`,`Storage`),icon:v(pt,{className:`h-3.5 w-3.5`}),children:x?HL(x.storageBytes):`—`}),v(an,{label:t(`uiLibrary.recordingPanel.recorded24h`,`Recorded (24h)`),icon:v(In,{className:`h-3.5 w-3.5`}),footer:w?t(`uiLibrary.recordingPanel.nobodyCouldLook`,`nobody could look`):t(`uiLibrary.recordingPanel.segmentRange`,{one:`{{count}} segment range`,other:`{{count}} segment ranges`},{count:T.length}),children:y.isLoading?`…`:w?`—`:yF(E)})]}),r.isError?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingPanel.recorderUnavailable`,`Recorder unavailable — the recording service may not be running for this node.`)}):null,v(XL,{deviceId:e}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.recordingPanel.playbackHint`,`Recordings play in the main player above — switch back to live from there.`)})]})})]})}E();var $L={"host/motion-zones-grid":m(()=>a(()=>import(`./MotionZonesSettings-BXHdXw3X.js`).then(e=>({default:e.MotionZonesSettings})),__vite__mapDeps([38,1,2,3,39]),import.meta.url)),"host/privacy-mask-grid":m(()=>a(()=>import(`./PrivacyMaskSettings-BXiuTmLQ.js`).then(e=>({default:e.PrivacyMaskSettings})),__vite__mapDeps([40,1,2,3,23,39]),import.meta.url)),"host/ptz-panel":RI,"host/navigation-panel":AI,"host/consumables-panel":PM,"host/ptz-autotrack":GA,"host/recording-panel":QL,"host/camera-grid-layout":Hj,"host/clips-browser":QF,"host/extensions-panel":yI};E();function eR(e){let{widgetId:t,deviceId:n}=e,r=$L[t];return r===void 0?v(tR,{...e}):n===void 0?v(iR,{widgetId:t,reason:`missing-device-context`}):v(g,{fallback:v(rR,{}),children:v(r,{deviceId:n})})}function tR(e){let{widgetId:t}=e,n=BA(t);return n===void 0?v(iR,{widgetId:t,reason:`unknown`}):v(nR,{...e,metadata:n})}function nR(e){let{widgetId:t,host:n=`device-tab`,config:r,deviceId:i,integrationId:a,instanceId:o,size:s,columns:c,rows:l,metadata:u}=e,d=VA(u.remote,u.bundleUrl),f=p(()=>o??t,[o,t]);return d===null?v(rR,{}):d===void 0?v(iR,{widgetId:t,reason:`missing-export`}):u.requires.deviceContext&&i===void 0?v(iR,{widgetId:t,reason:`missing-device-context`}):u.requires.integrationContext&&a===void 0?v(iR,{widgetId:t,reason:`missing-integration-context`}):v(d,{instanceId:f,host:n,config:r,deviceId:i,integrationId:a,size:s,columns:c,rows:l})}function rR(){return c(`div`,{className:`rounded-lg border border-border bg-surface/40 p-4 animate-pulse`,children:[v(`div`,{className:`h-3 w-24 bg-foreground-subtle/20 rounded mb-2`}),v(`div`,{className:`h-2 w-full bg-foreground-subtle/10 rounded mb-1`}),v(`div`,{className:`h-2 w-3/4 bg-foreground-subtle/10 rounded`})]})}function iR({widgetId:e,reason:t}){return v(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children: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`})}E();var aR=Object.defineProperty,oR=Object.getOwnPropertySymbols,sR=Object.prototype.hasOwnProperty,cR=Object.prototype.propertyIsEnumerable,lR=(e,t,n)=>t in e?aR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uR=(e,t)=>{for(var n in t||={})sR.call(t,n)&&lR(e,n,t[n]);if(oR)for(var n of oR(t))cR.call(t,n)&&lR(e,n,t[n]);return e},dR=(e,t)=>{var n={};for(var r in e)sR.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oR)for(var r of oR(e))t.indexOf(r)<0&&cR.call(e,r)&&(n[r]=e[r]);return n},fR;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(fR||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(fR||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(fR||={});var pR=fR,mR={L:pR.QrCode.Ecc.LOW,M:pR.QrCode.Ecc.MEDIUM,Q:pR.QrCode.Ecc.QUARTILE,H:pR.QrCode.Ecc.HIGH},hR=128,gR=`L`,_R=`#FFFFFF`,vR=`#000000`,yR=!1,bR=1,xR=4,SR=0,CR=.1;function wR(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function TR(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ER(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*CR),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function DR(e,t){return t==null?e?xR:SR:Math.max(Math.floor(t),0)}function OR({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=l.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...pR.QrSegment.makeSegments(t)),e),[]);return pR.QrCode.encodeSegments(r,mR[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:u,margin:d,numCells:f,calculatedImageSettings:p}=l.useMemo(()=>{let e=c.getModules(),t=DR(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ER(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:u,numCells:f,calculatedImageSettings:p}}var kR=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),AR=l.forwardRef(function(e,t){let n=e,{value:r,size:i=hR,level:a=gR,bgColor:o=_R,fgColor:s=vR,includeMargin:c=yR,minVersion:u=bR,boostLevel:d,marginSize:f,imageSettings:p}=n,m=dR(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=dR(m,[`style`]),_=p?.src,v=l.useRef(null),y=l.useRef(null),b=l.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=l.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=OR({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});l.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=TR(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,kR?t.fill(new Path2D(wR(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),l.useEffect(()=>{S(!1)},[_]);let D=uR({height:i,width:i},h),O=null;return _!=null&&(O=l.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),l.createElement(l.Fragment,null,l.createElement(`canvas`,uR({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});AR.displayName=`QRCodeCanvas`;var jR=l.forwardRef(function(e,t){let n=e,{value:r,size:i=hR,level:a=gR,bgColor:o=_R,fgColor:s=vR,includeMargin:c=yR,minVersion:u=bR,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=dR(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=OR({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=TR(_,y.excavation)),x=l.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=wR(b,g);return l.createElement(`svg`,uR({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&l.createElement(`title`,null,f),l.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),l.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});jR.displayName=`QRCodeSVG`;var MR=192;function NR({value:e,size:t=MR,className:n,alt:r}){let i=q(),a=e.trim();return a.length===0?null:v(`div`,{className:$(`inline-flex rounded-md bg-white p-2`,n),children:v(jR,{value:a,size:t,marginSize:1,title:r??i(`uiLibrary.qrCode.alt`,`QR code`)})})}var PR=`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`;function FR({value:e,onChange:t,disabled:n}){let r=q(),i=[];for(let e of Vi)i.includes(e.region)||i.push(e.region);return c(`select`,{className:PR,value:e,disabled:n,onChange:e=>t(e.target.value),children:[!Da(e)&&v(`option`,{value:``,children:r(`uiLibrary.timezoneSelector.select`,`— Select timezone —`)}),i.map(e=>v(`optgroup`,{label:e,children:Vi.filter(t=>t.region===e).map(e=>v(`option`,{value:e.id,children:e.label},e.id))},e))]})}E();var IR=`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`,LR=`block text-[11px] font-medium text-foreground mb-1 break-words`,RR=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function zR({label:e,description:t,required:n,span:r,htmlFor:i,children:a,translationFn:o}){let s=r===2?`col-span-1 @[480px]:col-span-2`:r===3?`col-span-1 @[480px]:col-span-2 @[880px]:col-span-3`:r===4?`col-span-1 @[480px]:col-span-2 @[1140px]:col-span-4`:`col-span-1`,l=Az(e,o),u=Az(t,o),d=l!==void 0&&l!==``;return c(`div`,{className:`${s} min-w-0`,children:[d&&c(`label`,{className:LR,...i===void 0?{}:{htmlFor:i},children:[l,n&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),a,u&&v(`p`,{className:RR,children:u})]})}function BR({field:e,value:t,onChange:n,disabled:r,translationFn:i,multiline:a,children:o}){let s=ra(e),[c,l]=C(()=>s&&tu(t)),u=s&&ha(t);return u&&!c&&l(!0),!c&&!u?v(P,{children:o}):v(zR,{label:`label`in e?e.label:void 0,description:`description`in e?e.description:void 0,required:`required`in e?e.required:void 0,span:`span`in e?e.span:void 0,translationFn:i,children:v(au,{field:e,value:t,onChange:n,disabled:r,multiline:a})})}function VR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`input`,{type:e.inputType??`text`,className:IR,value:t==null?``:String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function HR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let[a,o]=C(t==null?``:String(t)),s=f(!1);b(()=>{s.current||o(t==null?``:String(t))},[t]);let l=e=>{if(o(e),e===``||e===`-`){n(void 0);return}let t=Number(e);Number.isNaN(t)||n(t)};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex items-center gap-1`,children:[v(`input`,{type:`number`,className:IR,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:r||e.disabled,onFocus:()=>{s.current=!0},onBlur:()=>{s.current=!1},onChange:e=>l(e.target.value)}),e.unit&&v(`span`,{className:`text-xs text-foreground-subtle whitespace-nowrap`,children:e.unit})]})})}function UR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=!!t,o=r||e.disabled;return e.style===`checkbox`?v(zR,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[v(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,checked:a,disabled:o,onChange:e=>n(e.target.checked)}),v(`span`,{className:`text-xs font-medium text-foreground`,children:Az(e.label,i)}),e.required&&v(`span`,{className:`text-danger`,children:`*`})]})}):v(zR,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex items-center justify-between`,children:[c(`span`,{className:`block text-[11px] font-medium text-foreground mb-1 break-words mb-0`,children:[Az(e.label,i),e.required&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),v(`button`,{type:`button`,role:`switch`,"aria-checked":a,disabled:o,onClick:()=>!o&&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`,o?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),children:v(`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 WR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=e.options.some(e=>e.value===``),s=[...!e.required&&!o?[{value:``,label:a(`uiLibrary.configFormField.select`,`— Select —`)}]:[],...e.options.map(e=>({value:e.value,label:e.label}))],c=`config-select-${e.key}`;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,htmlFor:c,translationFn:i,children:v(Yl,{id:c,options:s,value:t==null?``:String(t),disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function GR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(FR,{value:typeof t==`string`?t:``,onChange:n,disabled:r||e.disabled})})}function KR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`input`,{type:`datetime-local`,className:IR,value:typeof t==`string`?t:``,placeholder:e.placeholder,disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function qR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=Array.isArray(t)?t:[],o=t=>{if(a.includes(t))n(a.filter(e=>e!==t));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,t])}};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(t=>{let n=a.includes(t.value);return c(`label`,{className:[`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors`,n?`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:[v(`input`,{type:`checkbox`,className:`sr-only`,checked:n,disabled:r||e.disabled,onChange:()=>o(t.value)}),t.iconId!==void 0&&v(Wk,{iconId:t.iconId,size:13}),t.label]},t.value)})})})}function JR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let[a,o]=C(!1),s=t==null?``:String(t);return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(Jl,{"aria-label":e.label,value:s,onValueChange:e=>n(e),shown:a,onToggleShown:()=>o(e=>!e),hideToggle:e.showToggle===!1,placeholder:e.placeholder,disabled:r||e.disabled,onFocus:e=>{s.length>0&&/^[•●*]{4,}$/u.test(s)&&e.currentTarget.select()}})})}function YR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`textarea`,{className:`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 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:e=>n(e.target.value)})})}function XR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=t==null,s=e.nullable===!0,l=o?e.default??e.min:Number(t),u=e.showValue!==!1,d=e.nullLabel??a(`uiLibrary.configFormField.auto`,`Auto`),f=r||e.disabled,p=e.displayScale??1,m=e.min/p,h=e.max/p,g=l/p,_=(e.step??1)/p;if(s&&o)return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`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:a(`uiLibrary.configFormField.clickToSet`,`{{label}} — click to set manually`,{label:d})})});let y=e.showStepper===!0&&u,b=t=>{let r=l+t*(e.step??1),i=Math.min(e.max,Math.max(e.min,r));i!==l&&n(i)},x=`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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[c(`div`,{className:`flex min-w-0 flex-1 basis-[160px] items-center gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums shrink-0`,children:m}),v(`input`,{type:`range`,className:`min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50`,min:m,max:h,step:_,value:g,disabled:f,onChange:e=>n(Number(e.target.value)*p)}),v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums shrink-0`,children:h})]}),(u||s||e.unit)&&c(`div`,{className:`flex shrink-0 items-center gap-2`,children:[y&&v(`button`,{type:`button`,className:x,disabled:f||l<=e.min,onClick:()=>b(-1),title:a(`uiLibrary.configFormField.decreaseBy`,`Decrease by {{step}}`,{step:e.step??1}),"aria-label":a(`uiLibrary.configFormField.decrement`,`Decrement`),children:v(zn,{className:`h-3 w-3`})}),u&&v(`input`,{type:`number`,className:`w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary`,min:m,max:h,step:_,value:g,disabled:f,onChange:t=>{if(t.target.value===``){n(s?null:e.min);return}let r=Number(t.target.value)*p,i=e.step??1,a=r-e.min,o=e.min+Math.round(a/i)*i;n(Math.min(e.max,Math.max(e.min,o)))}}),y&&v(`button`,{type:`button`,className:x,disabled:f||l>=e.max,onClick:()=>b(1),title:a(`uiLibrary.configFormField.increaseBy`,`Increase by {{step}}`,{step:e.step??1}),"aria-label":a(`uiLibrary.configFormField.increment`,`Increment`),children:v(Se,{className:`h-3 w-3`})}),e.unit&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.unit}),s&&v(`button`,{className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors`,title:a(`uiLibrary.configFormField.resetTo`,`Reset to {{label}}`,{label:d}),disabled:f,onClick:()=>n(null),children:d})]})]})})}function ZR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=Array.isArray(t)?t.filter(e=>typeof e==`string`):[],s=e.creatable!==!1,c=(e.suggestions??[]).map(e=>({value:e,label:e})),l=r===!0||e.disabled===!0;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(iA,{mode:`multi`,options:c,value:o,onChange:e=>n(e),disabled:l,creatable:s,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxTags===void 0?{}:{maxItems:e.maxTags},placeholder:e.placeholder??a(`uiLibrary.configFormField.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})})}function QR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{nodes:o}=Lo(),s=typeof t==`string`?t:``,l=e.showOffline?o:o.filter(e=>e.isOnline);return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`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:s,onChange:e=>n(e.target.value),disabled:r,children:[v(`option`,{value:``,children:a(`uiLibrary.configFormField.selectNode`,`Select node…`)}),l.map(e=>v(`option`,{value:e.id,disabled:!e.isOnline,children:e.isOnline?e.shortName:a(`uiLibrary.configFormField.nodeOffline`,`{{name}} (offline)`,{name:e.shortName})},e.id))]})})}function $R({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let{nodes:a}=Lo(),o=new Set(Array.isArray(t)?t.map(String):[]),s=e.showOffline?a:a.filter(e=>e.isOnline),c=e=>{let t=new Set(o);t.has(e)?t.delete(e):t.add(e),n([...t])};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>{let t=o.has(e.id);return v(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`} ${e.isOnline?``:`opacity-50 cursor-not-allowed`}`,children:e.shortName},e.id)})})})}function ez({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=t==null?`#000000`:String(t);return c(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(`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:e=>n(e.target.value)}),v(`input`,{type:`text`,className:`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 flex-1 font-mono`,value:a,placeholder:`#000000`,disabled:r||e.disabled,onChange:e=>n(e.target.value)})]}),e.presets&&e.presets.length>0&&v(`div`,{className:`flex gap-1.5 mt-1.5`,children:e.presets.map(t=>v(`button`,{type:`button`,className:`h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50`,style:{backgroundColor:t},disabled:r||e.disabled,title:t,onClick:()=>n(t)},t))})]})}function tz({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=typeof e.default==`string`?e.default:``;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(Ml,{label:Az(e.label,i)??e.label,value:t,defaultKey:a,disabled:r||e.disabled,onChange:n})})}function nz({field:e,value:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o,externalProbe:s}){let l=q(),[u,d]=C(`idle`),[f,p]=C(null),m=s?.status??u,h=s?.result??f,g=!!a||!!o,y=_(async()=>{if(g){d(`probing`),p(null);try{let n=a?await a(e.key,t):await o(`test-probe`,e.key,t),r=n&&typeof n==`object`?n:{status:`error`,error:l(`uiLibrary.configFormField.probeNoResult`,`Probe handler returned no result`)};p(r),d(r.status===`ok`?`ok`:`error`)}catch(e){p({status:`error`,error:e instanceof Error?e.message:String(e)}),d(`error`)}}},[a,o,e.key,t,g]),b=m===`probing`?`border-primary/40 bg-primary/10 text-primary`:m===`ok`?`border-success/40 bg-success/10 text-success hover:bg-success/15`:m===`error`?`border-danger/40 bg-danger/10 text-danger hover:bg-danger/15`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,x=m===`probing`?v(Gn,{className:`h-3 w-3 animate-spin`}):v(m===`ok`?Dn:m===`error`?Ai:An,{className:`h-3 w-3`});return c(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:[c(`div`,{className:`@container flex items-center gap-2`,style:{containerType:`inline-size`},children:[c(`button`,{type:`button`,onClick:y,title:l(`uiLibrary.configFormField.test`,`Test`),disabled:e.disabled||m===`probing`||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${b}`,children:[x,v(`span`,{className:`hidden @[280px]:inline`,children:l(`uiLibrary.configFormField.test`,`Test`)})]}),v(`input`,{type:e.inputType??`url`,className:`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 flex-1 min-w-0`,value:t==null?``:String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:e=>{n(e.target.value),u!==`idle`&&(d(`idle`),p(null))}})]}),m===`ok`&&h?.labels&&h.labels.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:h.labels.map((e,t)=>v(`span`,{className:`text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono`,children:e},t))}),m===`error`&&h?.error&&v(`p`,{className:`text-xs text-danger mt-1 truncate`,title:h.error,children:h.error})]})}function rz({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:s}){let[l,u]=C(e.defaultCollapsed??!1),d=e.style===`accordion`;return v(`div`,{className:`${e.span===2?`col-span-2`:e.span===3?`col-span-3`:e.span===4?`col-span-4`:`col-span-1`} min-w-0`,children:c(`div`,{className:`@container rounded-lg border border-border bg-surface/50 overflow-hidden`,style:{containerType:`inline-size`},children:[c(`div`,{className:[`px-3 py-2 flex items-center justify-between min-w-0`,d?`cursor-pointer hover:bg-surface`:``].join(` `),onClick:d?()=>u(e=>!e):void 0,children:[v(`span`,{className:`text-xs font-semibold text-foreground min-w-0 break-words`,children:Az(e.label,a)}),d&&v(`span`,{className:`text-foreground-subtle text-xs shrink-0 ml-2`,children:l?`▸`:`▾`})]}),!l&&v(`div`,{className:`px-3 pb-3 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:s},e.key))})]})})}function iz({field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o}){let[s,l]=C(e.tabs[0]?.id??``),u=e.span===2?`col-span-2`:e.span===3?`col-span-3`:e.span===4?`col-span-4`:`col-span-1`;return e.tabs.length===0?null:c(`div`,{className:`${u} min-w-0`,children:[e.label&&v(`div`,{className:LR,children:Az(e.label,i)}),c(`div`,{className:`@container rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden`,style:{containerType:`inline-size`},children:[v(`div`,{className:`flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40`,role:`tablist`,children:e.tabs.map(e=>{let t=e.id===s;return c(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>l(e.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${t?`bg-primary text-primary-foreground font-medium shadow-sm`:`bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground`}`,children:[v(`span`,{children:Az(e.label,i)}),e.badge&&v(`span`,{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${t?`bg-primary-foreground/20 text-primary-foreground`:`bg-primary/10 text-primary`}`,children:e.badge})]},e.id)})}),e.tabs.map(e=>e.id===s?v(`div`,{role:`tabpanel`,className:`px-3 pb-3 pt-2 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3`,children:e.fields.map((s,c)=>{let l=`key`in s&&typeof s.key==`string`?s.key:`__${e.id}__${c}`;return v(Oz,{field:s,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o},l)})},e.id):null)]})]})}function az({span:e}){return v(`div`,{className:e===2?`col-span-2`:e===3?`col-span-3`:e===4?`col-span-4`:`col-span-full`,children:v(`hr`,{className:`border-border`})})}var oz={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 sz({field:e}){let t=oz[e.variant??`info`]??oz.info,n=e.format===`html`;return v(`div`,{className:`col-span-full`,children:c(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${t.border} ${t.bg}`,children:[e.label&&v(`p`,{className:e.content.length>0?`text-xs font-semibold mb-0.5 ${t.text}`:`text-xs text-foreground-subtle leading-relaxed whitespace-pre-line break-words`,children:e.label}),n?v(`div`,{className:`text-xs text-foreground-subtle leading-relaxed info-html-content`,dangerouslySetInnerHTML:{__html:Nl(e.content)}}):e.content.length>0&&v(`p`,{className:`text-xs text-foreground-subtle leading-relaxed whitespace-pre-line break-words`,children:e.content})]})})}function cz({field:e}){let t=e.value;if(!t||t.length===0)return null;let n=e.size??192,r=e.alt??e.label;return v(`div`,{className:`col-span-full`,children:c(`div`,{className:`rounded-md border border-foreground-subtle/20 px-3 py-3 bg-background-subtle/40 flex flex-col items-start gap-2`,children:[e.label&&v(`p`,{className:`text-xs font-semibold text-foreground`,children:e.label}),e.caption&&v(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:e.caption}),v(NR,{value:t,size:n,alt:r})]})})}var lz={ok:`bg-success`,warn:`bg-amber-500`,danger:`bg-danger`,idle:`bg-foreground-subtle/40`,unknown:`bg-foreground-subtle/40`};function uz(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function dz(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString()}function fz({kind:e,value:t}){return t==null||t===``?v(`span`,{className:`text-foreground-subtle/60`,children:`—`}):e===`monospace`?v(`span`,{className:`font-mono text-[11px]`,children:String(t)}):e===`status`?c(`span`,{className:`inline-flex items-center gap-1.5`,children:[v(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full ${lz[String(t).toLowerCase()]??lz.unknown}`}),v(`span`,{children:String(t)})]}):e===`duration`&&typeof t==`number`?v(`span`,{className:`font-mono text-[11px]`,children:uz(t)}):e===`timestamp`&&typeof t==`number`?v(`span`,{className:`font-mono text-[11px]`,children:dz(t)}):v(`span`,{children:String(t)})}function pz({field:e}){let t=q(),n=e.value??[],r=e.description;return c(`div`,{className:`col-span-full`,children:[e.label&&v(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1`,children:e.label}),r&&v(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:r}),n.length===0?v(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle`,children:e.emptyMessage??t(`uiLibrary.configFormField.noEntries`,`No entries`)}):v(`div`,{className:`rounded-md border border-border overflow-x-auto`,children:c(`table`,{className:`w-full min-w-[28rem] text-xs`,children:[v(`thead`,{className:`bg-surface-subtle border-b border-border`,children:v(`tr`,{children:e.columns.map(e=>v(`th`,{className:`px-3 py-1.5 text-left font-medium text-foreground-subtle`,style:e.width?{width:e.width}:void 0,children:e.label},e.key))})}),v(`tbody`,{className:`divide-y divide-border`,children:n.map((t,n)=>v(`tr`,{className:`hover:bg-surface-hover/40`,children:e.columns.map(e=>v(`td`,{className:`px-3 py-1.5 align-top text-foreground`,children:v(fz,{kind:e.kind,value:t[e.key]})},e.key))},n))})]})})]})}function mz({field:e,value:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o}){let s=q(),l=Array.isArray(t)?t:[],u=e.minRows??0,d=e.maxRows??1/0,f=(e,t,r)=>{let i=l.slice();i[e]={...i[e]??{},[t]:r},n(i)},p=e=>{l.length<=u||n(l.filter((t,n)=>n!==e))},m=()=>{if(l.length>=d)return;let t=e.defaultItem??{};n([...l,{...t}])},h=(t,n)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r==null||r===``?`—`:String(r)}):s(`uiLibrary.configFormField.row`,`Row {{n}}`,{n:n+1}),g=l.length>u,_=l.length<d,y=e.itemIdKey??`id`,b=(e,t)=>{let n=e[y];return typeof n==`string`&&n.length>0?n:typeof n==`number`&&Number.isFinite(n)?String(n):`row-${String(t)}`};return c(`div`,{className:`col-span-full space-y-2`,children:[c(`div`,{className:`space-y-0.5`,children:[e.label&&v(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:Az(e.label,i)}),e.description&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:Az(e.description,i)})]}),l.length===0?v(`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??s(`uiLibrary.configFormField.noEntries`,`No entries`)}):v(`div`,{className:`space-y-2`,children:l.map((t,n)=>c(`div`,{className:`rounded-md border border-border bg-background`,children:[c(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[v(`span`,{className:`text-xs font-medium text-foreground`,children:h(t,n)}),c(`button`,{type:`button`,onClick:()=>p(n),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?s(`uiLibrary.configFormField.removeRow`,`Remove this row`):s(`uiLibrary.configFormField.minRows`,{one:`At least {{count}} row required`,other:`At least {{count}} rows required`},{count:u}),children:[v(zn,{className:`h-3 w-3`}),s(`uiLibrary.configFormField.remove`,`Remove`)]})]}),v(`div`,{className:`grid grid-cols-1 @[480px]:grid-cols-2 gap-x-3 gap-y-2 p-3`,children:e.itemFields.map(s=>v(Oz,{field:s,values:t,onChange:(e,t)=>f(n,e,t),disabled:r,translationFn:i,onTestField:a,allFields:e.itemFields,onAction:o},s.key))})]},b(t,n)))}),c(`div`,{children:[c(`button`,{type:`button`,onClick:m,disabled:r||!_,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:[v(Se,{className:`h-3 w-3`}),e.addLabel??s(`uiLibrary.configFormField.add`,`Add`)]}),!_&&Number.isFinite(d)&&v(`span`,{className:`ml-2 text-[10px] text-foreground-subtle`,children:s(`uiLibrary.configFormField.limit`,`(limit: {{max}})`,{max:d})})]})]})}function hz({field:e,disabled:t,onAction:n}){let r=q(),[i,a]=C(!1),o=li(),s=async()=>{if(!(e.confirmMessage&&!await o({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`}))&&n){a(!0);try{await n(e.action,e.key)}finally{a(!1)}}},c={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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:v(`button`,{onClick:s,disabled:t||i,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${c[e.variant??`default`]??c.default}`,children:i?r(`uiLibrary.configFormField.processing`,`Processing...`):e.buttonLabel})})}function gz(e,t){let n={...e.paramsStatic};if(e.paramsFromForm)for(let[r,i]of Object.entries(e.paramsFromForm)){let e=t[i];e!=null&&e!==``&&!Bi(e)&&(n[r]=e)}return n}function _z({field:e,value:t,values:n,onChange:r,disabled:i,onAction:a}){let o=q(),[s,l]=C(!1),[u,d]=C(null),[p,m]=C(null),h=gz(e,n),g=Object.keys(e.paramsFromForm??{}).some(e=>h[e]===void 0),_=e.mapOption.value,y=e.mapOption.label,x=e.mapOption.description,S=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(e=>`${e}=${JSON.stringify(n[e])}`).join(`|`),w=f(a);w.current=a;let T=f(r);T.current=r;let E=f(h);E.current=h;let D=f(t);return D.current=t,b(()=>{let t=w.current;if(!t||g){m(null),d(null);return}let n=!1;l(!0),d(null);let r=E.current;return t(e.action,e.key,r).then(t=>{if(n)return;let r=t,i=[];if(Array.isArray(r))i=r;else if(r&&typeof r==`object`)for(let e of Object.keys(r)){let t=r[e];if(Array.isArray(t)){i=t;break}}m(i);let a=D.current;if(e.hideWhenFewerThan!==void 0&&i.length===1&&(typeof a!=`string`||a.length===0)){let e=i[0]?.[_];typeof e==`string`&&e.length>0&&T.current(e)}}).catch(e=>{n||(d(e instanceof Error?e.message:String(e)),m([]))}).finally(()=>{n||l(!1)}),()=>{n=!0}},[S,g,a!==void 0,e.action,e.key,e.hideWhenFewerThan,_]),!a&&e.hideWhenFewerThan!==void 0||e.hideWhenFewerThan!==void 0&&p!==null&&p.length<e.hideWhenFewerThan?null:v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:g?v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e.emptyParamsMessage??o(`uiLibrary.configFormField.fillPrerequisites`,`Fill the prerequisite fields above first.`)}):s?c(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),` `,o(`uiLibrary.configFormField.loadingOptions`,`Loading options…`)]}):u?v(`div`,{className:`text-[11px] text-danger`,children:u}):p&&p.length===0?v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e.emptyResultsMessage??o(`uiLibrary.configFormField.noOptions`,`No options returned.`)}):(()=>{let e=(p??[]).some(e=>{let t=e[_];return t===``||t===void 0});return c(`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:i,onChange:e=>r(e.target.value),children:[!e&&v(`option`,{value:``,children:o(`uiLibrary.configFormField.select`,`— Select —`)}),(p??[]).map((e,t)=>{let n=e[_],r=e[y],i=x?e[x]:void 0,a=typeof n==`string`&&n!==``?n:`row-${t}`;return c(`option`,{value:typeof n==`string`?n:String(n??``),children:[typeof r==`string`?r:String(r??a),i===void 0?``:` (${String(i)})`]},a)})]})})()})}function vz({field:e,values:t,disabled:n,onAction:r,onChange:i,onChangeMany:a}){let o=q(),[s,l]=C(!1),[u,d]=C(null),f=li(),p=Pn(),m=CA(),h=async()=>{let n=e.prompt?await p({title:e.prompt.title??e.label,...e.prompt.message===void 0?{}:{message:e.prompt.message},...e.prompt.placeholder===void 0?{}:{placeholder:e.prompt.placeholder},confirmLabel:e.buttonLabel}):null;if(e.prompt&&n===null||e.confirmMessage&&!await f({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`})||!r)return;let o=gz(e,t);e.prompt&&n!==null&&(o[e.prompt.param]=n),e.includeDeviceId===!0&&m!=null&&(o.deviceId=m),l(!0),d(null);try{let t=await r(e.action,e.key,o),n=typeof t==`object`&&t?t:null;if(n!==null&&e.assignResult&&(i||a)){let t={};for(let[r,i]of Object.entries(e.assignResult)){let e=n[i];typeof e==`string`&&(t[r]=e)}if(Object.keys(t).length>0){if(a)a(t);else if(i)for(let[e,n]of Object.entries(t))i(e,n)}}d({kind:`ok`,text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(e,t)=>{let r=n?.[t];return r===void 0?``:String(r)}):`Done.`})}catch(e){d({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}},g={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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:c(`div`,{className:`flex flex-col gap-1.5`,children:[v(`button`,{onClick:h,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 ${g[e.variant??`default`]??g.default}`,children:s?o(`uiLibrary.configFormField.working`,`Working…`):e.buttonLabel}),u&&v(`div`,{className:`text-[11px] ${u.kind===`ok`?`text-emerald-700 dark:text-emerald-300`:`text-danger`}`,children:u.text})]})})}function yz({field:e,values:t,disabled:n,onAction:r}){let i=q(),[a,o]=C(!1),[s,l]=C(null),u=li(),d=async()=>{if(e.confirmMessage&&!await u({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`})||!r)return;let n=gz(e,t);o(!0),l(null);try{let t=await r(`device-custom-action`,e.action,n),i=typeof t==`object`&&t?t:null;l({kind:`ok`,text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(e,t)=>{let n=i?.[t];return n===void 0?``:String(n)}):`Done.`})}catch(e){l({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{o(!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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:c(`div`,{className:`flex flex-col gap-1.5`,children:[v(`button`,{onClick:d,disabled:n||a,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:a?i(`uiLibrary.configFormField.working`,`Working…`):e.buttonLabel}),s&&v(`div`,{className:`text-[11px] ${s.kind===`ok`?`text-emerald-700 dark:text-emerald-300`:`text-danger`}`,children:s.text})]})})}function bz({field:e}){let t=CA();return v(zR,{label:void 0,description:void 0,span:e.span,children:v(eR,{widgetId:e.widgetId,host:`device-tab`,config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function xz(e,t){if(e==null)return`—`;if(typeof e==`boolean`)return e?`yes`:`no`;if(typeof e==`number`){let n=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${n} ${t}`:n}return typeof e==`string`?e:JSON.stringify(e)}function Sz({field:e,values:t,onAction:n,translationFn:r}){let i=`key`in e?e.key:void 0;if(!i)return null;let a=t[i],o=a===void 0?`default`in e?e.default:void 0:a,s=xz(o,`unit`in e?e.unit:void 0),l=`label`in e?e.label:void 0,u=`description`in e?e.description:void 0,d=`span`in e?e.span:void 0,f=`actions`in e?e.actions??[]:[];return v(zR,{label:l,description:u,span:d,translationFn:r,children:c(`div`,{className:`flex items-stretch gap-1`,children:[v(`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:s}),f.length>0&&v(`div`,{className:`flex items-center gap-1`,children:f.map(e=>v(wz,{action:e,fieldKey:i,value:o,onAction:n},e.action))})]})})}function Cz({name:e}){let t=`h-3.5 w-3.5`;switch(e){case`copy`:return v(ei,{className:t});case`refresh-cw`:return v(_e,{className:t});case`external-link`:return v(Je,{className:t});case`trash-2`:return v(Pe,{className:t});case`download`:return v(nn,{className:t});case`upload`:return v(yt,{className:t});default:return v(yn,{className:t})}}function wz({action:e,fieldKey:t,value:n,onAction:r}){let i=li(),[a,o]=C(!1),s=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 v(`button`,{type:`button`,onClick:async()=>{if(!(e.confirmMessage&&!await i({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){o(!0);try{await r(e.action,t)}finally{o(!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 ${s}`,children:v(Cz,{name:e.icon})})}function Tz(e){return`multiple`in e&&e.multiple!=null}function Ez({field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,externalProbe:o,allFields:s,onAction:l}){let u=q(),d=e.multiple,f=d.min,p=d.max,m=t[e.key],h=[...Array.isArray(m)?m:m==null?[]:[m]],g=d.itemDefault===void 0?`default`in e&&e.default!==void 0?e.default:``:d.itemDefault;for(;h.length<f;)h.push(g);let _=t=>n(e.key,[...t]),y=(e,t)=>{let n=[...h];n[e]=t,_(n)},b=()=>{h.length>=p||_([...h,g])},x=e=>{h.length<=f||_(h.filter((t,n)=>n!==e))},S=()=>{let{multiple:t,...n}=e,r={label:void 0,description:void 0,required:!1};return{...n,...r}};return v(zR,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:i,children:c(`div`,{className:`space-y-2`,children:[h.map((n,o)=>{let p=d.itemLabel?.replace("${n}",String(o+1));return c(`div`,{className:`space-y-1`,children:[p&&v(`div`,{className:LR,children:p}),c(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`flex-1 min-w-0`,children:v(Oz,{field:S(),values:{...t,[e.key]:n},onChange:(e,t)=>y(o,t),disabled:r,translationFn:i,onTestField:a,onAction:l,allFields:s})}),h.length>f&&v(`button`,{type:`button`,onClick:()=>x(o),disabled:r,title:u(`uiLibrary.configFormField.remove`,`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:v(Pe,{className:`h-3.5 w-3.5`})})]})]},o)}),c(`div`,{className:`flex items-center justify-between pt-1`,children:[h.length<p?c(`button`,{type:`button`,onClick:b,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:[v(Se,{className:`h-3 w-3`}),d.addLabel??u(`uiLibrary.configFormField.add`,`Add`)]}):v(`span`,{}),c(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[h.length,`/`,p]})]})]})})}function Dz(e,t,n){if(!(`showWhen`in e)||!e.showWhen)return!0;let r=e.showWhen,i=t[r.field],a=n?.find(e=>`key`in e&&e.key===r.field),o=a&&`default`in a?a.default:void 0,s=i===void 0?o:i;return r.equals===void 0?r.notEquals===void 0?r.in===void 0?r.notIn===void 0?r.includes===void 0?r.notIncludes===void 0?!0:!Array.isArray(s)||!s.includes(r.notIncludes):Array.isArray(s)&&s.includes(r.includes):!r.notIn.includes(s):r.in.includes(s):s!==r.notEquals:s===r.equals}function Oz({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:s,allFields:c,onAction:l}){if(Tz(e))return v(Ez,{field:e,values:t,onChange:n,disabled:i,translationFn:a,onTestField:o,externalProbe:s,allFields:c,onAction:l});if(`readonlyField`in e&&e.readonlyField===!0)return v(Sz,{field:e,values:t,onAction:l,translationFn:a});if(!Dz(e,t,c))return null;let u=t[e.key],d=u===void 0?`default`in e?e.default:void 0:u,f=t=>n(e.key,t),p=gA(e.type);switch(e.type){case`text`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,children:v(VR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`number`:return v(HR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`boolean`:return v(UR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`select`:return v(WR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`multiselect`:return v(qR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`timezone`:return v(GR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`datetime`:return v(KR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`password`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,children:v(JR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`textarea`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,multiline:!0,children:v(YR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`slider`:return v(XR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`tags`:return v(ZR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`color`:return v(ez,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`icon`:return v(tz,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`node-select`:return v(QR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`node-multiselect`:return v($R,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`device-select`:return v(Rk,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`device-multiselect`:return v(zk,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`notification-target-select`:return v(pA,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`notification-target-multiselect`:return v(fA,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`probe`:return v(nz,{field:e,value:d,onChange:f,disabled:i,translationFn:a,onTestField:o,onAction:l,externalProbe:s});case`group`:return v(rz,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:l});case`sub-tabs`:return v(iz,{field:e,values:t,onChange:n,disabled:i,translationFn:a,onTestField:o,onAction:l});case`separator`:return v(az,{});case`info`:return v(sz,{field:e});case`qr-code`:return v(cz,{field:e});case`object-array`:return v(pz,{field:e});case`editable-array`:return v(mz,{field:e,value:d,onChange:f,disabled:i,translationFn:a,onTestField:o,onAction:l});case`button`:return v(hz,{field:e,disabled:i,onAction:l});case`addon-action-select`:{let r=e.writesKey??e.key;return v(_z,{field:e,value:t[r],values:t,onChange:e=>n(r,e),disabled:i,onAction:l})}case`addon-action-button`:return v(vz,{field:e,values:t,disabled:i,onAction:l,onChange:n,onChangeMany:r});case`account-sign-in`:return v(Bie,{field:e,values:t,disabled:i,onAction:l,onChangeMany:r});case`secret-presence`:return v(Vie,{field:e,values:t});case`device-action-button`:return v(yz,{field:e,values:t,disabled:i,onAction:l});case`widget`:return v(bz,{field:e});default:return p?v(p,{field:e,value:d,onChange:f,disabled:i}):null}}E();function kz(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Az(e,t){if(e!==void 0)return t&&kz(e)?t(e):e}function jz(e){let t=e??2;return t===1?`grid-cols-1`:t===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:t===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`}function Mz({section:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o}){let[s,l]=C(e.defaultCollapsed??!1),u=e.style===`accordion`,d=jz(e.columns);return c(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},children:[c(`div`,{className:[`flex items-center justify-between mb-2`,u?`cursor-pointer`:``].join(` `),onClick:u?()=>l(e=>!e):void 0,children:[c(`div`,{children:[v(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:Az(e.title,i)}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Az(e.description,i)})]}),u&&v(`span`,{className:`text-foreground-subtle text-xs ml-2`,children:s?`▸`:`▾`})]}),!s&&v(`div`,{className:`grid ${d} gap-x-3 gap-y-2.5`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,externalProbe:o?.[e.key]},e.key))})]})}function Nz({schema:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o,onClearProbe:s,bare:c=!1}){let l=(e,r)=>{n({...t,[e]:r}),s?.(e)};return c?v(`div`,{className:`space-y-4`,children:e.sections.map(e=>v(`div`,{className:`@container`,style:{containerType:`inline-size`},children:v(`div`,{className:`grid ${jz(e.columns)} gap-x-3 gap-y-2.5`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:l,disabled:r,translationFn:i,onTestField:a,externalProbe:o?.[e.key]},e.key))})},e.id))}):v(`div`,{className:`space-y-4`,children:e.sections.map(e=>v(Mz,{section:e,values:t,onChange:l,disabled:r,translationFn:i,onTestField:a,probeResults:o},e.id))})}E();var Pz=({open:e})=>v(`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:v(`polyline`,{points:`9 18 15 12 9 6`})});function Fz(e){return e.type!==`separator`&&e.type!==`info`&&e.type!==`button`&&e.type!==`group`}function Iz(e){let t={};if(!e)return t;for(let n of e.sections)for(let e of n.fields){if(!Fz(e))continue;let n=e.key;t[n]=e.value}return t}function Lz(e,t){return{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(!Fz(e))return e;let n=e.key;return n in t?{...e,value:t[n]}:e})}))}}function Rz(e){return Dee(e)}function zz({trpc:e,addonId:t,nodeId:n,title:r,disabled:i,onAfterChange:a,refreshToken:o,sectionIds:s,bare:l=!1,collapsible:u,defaultOpen:d,mode:m,onOverrideChange:h}){let g=q(),_=m??`persist`,[y,x]=C(null),[S,w]=C(!0),[T,E]=C(null),[D,O]=C(!1),[k,A]=C(d??!1),[j,M]=C({}),[N,F]=C(null),I=f(0);b(()=>{F(null),M({})},[e,t,n,o,_]),b(()=>{let r=!1;w(!0),E(null);let i=_===`override`&&Object.keys(j).length>0?j:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...i?{overlay:i}:{}}).then(e=>{r||(x(t=>e??t),!i&&e&&F(Iz(e)),w(!1))}).catch(e=>{r||(E(e instanceof Error?e.message:String(e)),w(!1))}),()=>{r=!0}},[e,t,n,o,_,JSON.stringify(j)]);let L=p(()=>Iz(y),[y]),R=s?.join(`\0`),z=p(()=>{if(!y)return null;let e=Rz(y);if(s===void 0)return e;let t=new Set(s);return{...e,sections:e.sections.filter(e=>t.has(e.id))}},[y,R]),B=async r=>{if(_===`override`){let e=N??L,t={};for(let n of Object.keys(r))r[n]!==e[n]&&(t[n]=r[n]);let n={...e,...t};M(t),h?.(t,n);return}let i={};for(let e of Object.keys(r))r[e]!==L[e]&&(i[e]=r[e]);if(Object.keys(i).length===0)return;let o=++I.current;x(e=>e===null?e:Lz(e,r)),O(!0),E(null);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:i});let r=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});r&&o===I.current&&x(r),o===I.current&&a?.()}catch(e){o===I.current&&E(e instanceof Error?e.message:String(e))}finally{o===I.current&&O(!1)}};if(S)return v(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:g(`uiLibrary.addonGlobalSettings.loading`,`Loading {{name}}…`,{name:r??t})});if(T)return c(`div`,{className:`text-xs text-red-400`,children:[r??t,`: `,T]});if(!y||!z)return v(`div`,{className:`text-xs text-foreground-subtle`,children:g(`uiLibrary.addonGlobalSettings.unavailable`,`{{name}} not available on {{node}}.`,{name:r??t,node:n})});let V=_===`override`?{...L,...j}:L,H=c(P,{children:[_===`override`?v(`div`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:g(`uiLibrary.addonGlobalSettings.override`,`Benchmark override — applies to this run only. The addon's saved settings are not changed.`)}):null,D?v(`div`,{className:`mb-2 text-[11px] text-foreground-subtle`,"aria-live":`polite`,children:g(`uiLibrary.addonGlobalSettings.saving`,`Saving…`)}):null,v(Nz,{schema:z,values:V,onChange:B,disabled:i===!0,bare:l})]});return l?v(`div`,{children:H}):u===!0?c(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[c(`button`,{type:`button`,onClick:()=>A(e=>!e),className:`w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left`,"aria-expanded":k,children:[v(Pz,{open:k}),v(`h3`,{className:`text-xs font-semibold text-foreground uppercase tracking-wide flex-1`,children:r??t}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:k?g(`uiLibrary.addonGlobalSettingsForm.hide`,`hide`):g(`uiLibrary.addonGlobalSettingsForm.edit`,`edit`)})]}),k?v(`div`,{className:`border-t border-border px-4 py-3`,children:H}):null]}):r?c(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[v(`div`,{className:`border-b border-border px-4 py-2`,children:v(`h3`,{className:`text-xs font-semibold text-foreground uppercase tracking-wide`,children:r})}),v(`div`,{className:`px-4 py-3`,children:H})]}):v(`div`,{children:H})}var Bz=/^(usb|pci)(?::(\d+))?$/;function Vz(e){let t=Bz.exec(e);if(t===null||t[1]===`usb`&&t[2]===void 0)return{label:`Coral Edge TPU`,short:`Coral`};let n=t[1]===`pci`?`PCIe`:`USB`,r=t[2]===void 0?n:`${n} ${Number(t[2])+1}`;return{label:`Coral Edge TPU (${r})`,short:`Coral ${r}`}}function Hz(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();if(e.key===`cpu`||n===`cpu`||t===`cpu`)return{label:`CPU`,short:`CPU`};if(n===`npu`)return{label:`Intel NPU`,short:`NPU`};if(n===`gpu`||n===`igpu`)return{label:`Intel iGPU`,short:`iGPU`};if(t===`edgetpu`)return Vz(n);if(t===`coreml`)return{label:`Apple Neural Engine`,short:`ANE`};let r=`${e.backend} ${e.device}`.trim().replace(/\b\w/g,e=>e.toUpperCase());return{label:r.length>0?r:e.key,short:e.backend||e.key}}function Uz(e){return Hz(e).label}function Wz(e){return Hz(e).short}function Gz({active:e,onClick:t,disabled:n,children:r,title:i}){return v(`button`,{type:`button`,onClick:t,disabled:n,title:i,className:$(`rounded-full px-3 py-1 text-[11px] font-medium border transition-colors`,e?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:text-foreground hover:border-foreground-subtle/40`,n?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:r})}function Kz({catalog:e,value:t,onChange:n,disabled:r}){let i=q(),a=Qa(e),o=oo(e,t),s=a.find(e=>e.family===o?.family)?.family??a[0]?.family??``,l=a.find(e=>e.family===s)??a[0];if(!l)return null;let u=l.tiers.find(e=>e.tier===o?.tier)?.tier??l.tiers[0]?.tier??``,d=l.tiers.find(e=>e.tier===u)??l.tiers[0];if(!d)return null;let f=[...new Set(d.options.map(e=>e.resolution))].sort((e,t)=>(t??1/0)-(e??1/0)),p=f.includes(o?.resolution)?o?.resolution:f[0],m=d.options.filter(e=>e.resolution===p),h=e=>e===void 0?i(`uiLibrary.groupedModelSelector.native`,`native`):`${e}`,g=e=>{let t=l.tiers.find(t=>t.tier===e);t&&n((t.options.find(e=>e.precision===(o?.precision??`fp32`)&&e.optimization===(o?.optimization??`standard`)&&e.resolution===o?.resolution)??t.options[0]).modelId)},_=e=>{let t=d.options.filter(t=>t.resolution===e),r=t.find(e=>e.precision===(o?.precision??`fp32`)&&e.optimization===(o?.optimization??`standard`))??t[0];r&&n(r.modelId)},y=t=>{let r=sa(e,{family:l.family,tier:d.tier,precision:t.precision,optimization:t.optimization,resolution:t.resolution});r&&n(r)},b=d.options.find(e=>e.modelId===t)??null;return c(`div`,{className:`space-y-3`,children:[a.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.family`,`Family`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:a.map(e=>v(Gz,{active:e.family===l.family,disabled:r,...e.hint===void 0?{}:{title:e.hint},onClick:()=>n(e.tiers[0]?.baseModelId??``),children:e.label},e.family))}),l.hint!==void 0&&c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,"data-testid":`model-family-hint`,children:[l.label,`: `,l.hint]})]}),l.tiers.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.size`,`{{family}} — size`,{family:l.label})}),v(`div`,{className:`grid grid-cols-2 gap-1.5 sm:grid-cols-4`,children:l.tiers.map(e=>{let t=e.tier===d.tier,n=e.options.find(e=>e.resolution===p&&e.precision===`fp32`)??e.options.find(t=>t.modelId===e.baseModelId)??e.options[0];return c(`button`,{type:`button`,disabled:r,onClick:()=>g(e.tier),className:$(`rounded-lg border px-2 py-2 text-left transition-all`,t?`border-primary bg-primary/5 ring-1 ring-primary/30`:`border-border bg-background hover:border-foreground-subtle/40`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:[c(`div`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.label}),t&&v(dt,{className:`h-3 w-3 text-primary`})]}),n!==void 0&&n.sizeMB>0&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.groupedModelSelector.approxSize`,`~{{size}} MB`,{size:n.sizeMB})})]},e.tier)})})]}),f.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.resolution`,`Resolution`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>v(Gz,{active:e===p,disabled:r,title:e===void 0?i(`uiLibrary.groupedModelSelector.nativeTitle`,`native (best accuracy)`):i(`uiLibrary.groupedModelSelector.fasterTitle`,`{{size}}×{{size}} (faster)`,{size:e}),onClick:()=>_(e),children:h(e)},e??`native`))})]}),m.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.variant`,`Variant`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map(e=>v(Gz,{active:e.modelId===t,disabled:r,title:e.sizeMB>0?i(`uiLibrary.groupedModelSelector.formatsSize`,`{{formats}} · ~{{size}} MB`,{formats:e.formats.join(`, `),size:e.sizeMB}):e.formats.join(`, `),onClick:()=>y(e),children:c(`span`,{className:`inline-flex items-center gap-1`,children:[e.optimization===`test`&&v(nr,{className:`h-3 w-3`}),e.label]})},e.modelId))})]}),c(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle pt-0.5`,children:[v(Mr,{className:`h-3 w-3`}),v(`span`,{className:`font-mono`,children:t||`—`}),b&&c(`span`,{children:[`· `,b.formats.join(`, `),b.sizeMB>0?i(`uiLibrary.groupedModelSelector.sizeSuffix`,` · ~{{size}} MB`,{size:b.sizeMB}):``]})]})]})}E();var qz={camstack:`CamStack`,frigate:`plus catalog`,scrypted:`plugin catalog`,custom:`Custom`};function Jz(e){return e.provider??`camstack`}function Yz({models:e,value:t,onChange:n,disabled:r,defaultModelId:i}){let a=q(),o=p(()=>{let t=new Map;for(let n of e){let e=Jz(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return t},[e]),s=p(()=>Aa.filter(e=>(o.get(e)?.length??0)>0),[o]),l=p(()=>{let n=e.find(e=>e.id===t);return n?Jz(n):void 0},[e,t])??(s.includes(`camstack`)?`camstack`:s[0]??`camstack`),[u,d]=C(l);b(()=>{d(l)},[l]);let f=t!==``&&!e.some(e=>e.id===t),m=i!==void 0&&e.some(e=>e.id===i)?i:e[0]?.id,h=f&&c(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-300 space-y-1.5`,children:[v(`p`,{children:v(gi,{uiKey:`uiLibrary.modelPicker.unresolved`,fallback:`Current pin (<0>{{value}}</0>) is not offered for this device. The runtime tries it as a custom model and refuses it if it cannot serve it. Pick a replacement and Save.`,components:[v(`span`,{className:`font-mono`},`v`)],values:{value:t}})}),m!==void 0&&v(`button`,{type:`button`,disabled:r,onClick:()=>n(m),className:`rounded border border-amber-500/50 px-2 py-0.5 text-[10px] font-medium hover:bg-amber-500/20 disabled:opacity-50`,children:v(gi,{uiKey:`uiLibrary.modelPicker.useDefault`,fallback:`Use default (<0>{{id}}</0>) — then Save`,components:[v(`span`,{className:`font-mono`},`d`)],values:{id:m}})})]}),g=o.get(u)??[],_=g.filter(e=>e.group!==void 0),y=g.filter(e=>e.group===void 0);return c(`div`,{className:`space-y-3`,children:[h,s.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:a(`uiLibrary.modelPicker.provider`,`Provider`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>v(`button`,{type:`button`,disabled:r,onClick:()=>d(e),className:$(`rounded-full px-3 py-1 text-[11px] font-medium border transition-colors`,e===u?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:text-foreground hover:border-foreground-subtle/40`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:qz[e]},e))})]}),_.length>0&&v(Kz,{catalog:_,value:t,onChange:n,disabled:r}),y.length>0&&((e,i)=>c(`select`,{disabled:r,className:`w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50`,value:e.some(e=>e.id===t)?t:``,onChange:e=>n(e.target.value),children:[i!==void 0&&v(`option`,{value:``,disabled:!0,children:i}),e.map(e=>v(`option`,{value:e.id,children:e.name},e.id))]}))(y,_.length>0?`— other models —`:`— select a model —`),e.length===0&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.modelPicker.none`,`No model is published for this engine format.`)})]})}function Xz(e,t){let n=n=>e.models.find(e=>e.id===n)?.formats[t]!==void 0,r=e.defaultModelIdByFormat?.[t];if(r!==void 0&&n(r))return r;if(n(e.defaultModelId))return e.defaultModelId;let i=e.models.filter(e=>e.formats[t]!==void 0&&e.legacy!==!0);return i.length===0?e.defaultModelId:[...i].toSorted((e,n)=>(e.formats[t]?.sizeMB??1/0)-(n.formats[t]?.sizeMB??1/0))[0].id}function Zz(e,t){let n=t?.format;if(n===void 0)return;let r=t?.defaultModelId;return e.slot===`detector`&&r!==void 0&&e.models.some(e=>e.id===r)?r:Xz(e,n)}function Qz(e,t){return t===void 0?[]:e.filter(e=>e.formats[t]!==void 0)}function $z(e,t){return Qz(e,t).length>0}function eB(e){return e.base??Zz(e.catalog,e.device)}function tB(e,t,n){return ya(e)?$i(e,t,n?.supplies):null}function nB(e,t){return{...e,[Sa]:t}}function rB(e,t=Fn){if(e.kind===`label`){let n=e.uncovered.length>0?[t(`uiLibrary.rootModelSource.notProduced`,`Not produced by this model: {{classes}}.`,{classes:e.uncovered.join(`, `)})]:[];return e.stepId===`package-detection`?[...n,t(`uiLibrary.rootModelSource.packageNote`,`The root model's own package boxes become the package result at this step's threshold; this step's zone-crop view is not used, so small parcels the full-frame model misses stay missed.`)]:[...n,t(`uiLibrary.rootModelSource.labelNote`,`This step's class list decides which of the root's labels become the fine class; a switched-off class stays at its macro.`)]}return e.kind===`mask`?[t(`uiLibrary.rootModelSource.maskNote`,`Masks come from the root model: each detection carries the root's own instance mask, so this step's model does not run. A root mask follows the model's mask grid (a quarter of its input), coarser than this step's own per-crop mask.`)]:e.stepId===`face-detection`?[t(`uiLibrary.rootModelSource.faceNote`,`Face boxes come from the root model. Each is re-found by this step's face detector in a square around it before recognition, so only a face it finds is recognised; a box with no face in it is dropped.`)]:[t(`uiLibrary.rootModelSource.plateNote`,`Plate boxes come from the root model and the plate reader reads them. The crop margin around a root plate box has not been measured for this model yet.`)]}function iB(e,t,n){switch(e.inactiveReason){case`root-input-too-small`:return n(`uiLibrary.rootModelSource.inactiveTooSmall`,`the current root model ({{name}}) sees the frame too small to find faces reliably (it needs an input of 640 px or more).`,{name:t.name});case`root-does-not-declare`:case void 0:return n(`uiLibrary.rootModelSource.inactiveCannot`,`the current root model ({{name}}) cannot supply this.`,{name:t.name})}}function aB({stepId:e,settings:t,rootModel:n,disabled:r,onChange:i}){let a=q();if(n===void 0)return null;let o=tB(e,t,n);if(o===null)return null;let s=o.inactive?v(`div`,{className:`rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle`,"data-testid":`root-model-inactive`,children:a(`uiLibrary.rootModelSource.inactive`,`Use the root model: inactive — {{reason}} The step runs its own model.`,{reason:iB(o,n,a)})}):null;if(o.supply===void 0)return s;let l=o.intent;return c(`div`,{className:`space-y-1`,"data-testid":`root-model-source`,children:[c(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[v(`input`,{type:`checkbox`,checked:l,disabled:r,onChange:e=>i(e.target.checked)}),a(`uiLibrary.rootModelSource.use`,`Use the root model ({{name}})`,{name:n.name})]}),s,o.effective&&rB(o.supply,a).map(e=>v(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:e},e))]})}function oB(e,t){switch(e){case`override`:return t(`uiLibrary.modelBoundSlider.sourceOverride`,`Override for this model`);case`model-default`:return t(`uiLibrary.modelBoundSlider.sourceModelDefault`,`Model default`);case`global-default`:return t(`uiLibrary.modelBoundSlider.sourceGlobalDefault`,`Default — not tuned for this model`)}}function sB(e,t){return(t===void 0?e:e/t).toFixed(2).replace(/\.?0+$/,``)}function cB({field:e,modelId:t,settings:n,disabled:r,onChangeSettings:i,hideSourceRow:a=!1}){let o=q(),s=e.modelApplicability?.defaultByModel?.[t],l=oa(n,e.key,t.length>0?t:void 0,s,e.default),u=typeof e.default==`number`?e.default:e.min??0,d=typeof l.value==`number`?l.value:u,f=e.type===`slider`?e.displayScale:void 0,p=`unit`in e?e.unit:void 0,m=l.inapplicableOverride,h=n?.[e.key]!==void 0,g=r=>{i(t.length>0?no(n,e.key,r,t):{...n,[e.key]:r})};return c(`div`,{children:[c(`div`,{className:`flex items-center justify-between mb-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:e.label}),c(`span`,{className:`text-xs font-medium text-foreground tabular-nums`,children:[sB(d,f),p?` ${p}`:``]})]}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:e.description}),v(`input`,{type:`range`,min:e.min??0,max:e.max??1,step:e.step??.01,value:d,disabled:r||e.disabled,onChange:e=>g(Number(e.target.value)),className:`w-full accent-primary h-1.5`}),!a&&c(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[10px]`,children:[v(`span`,{"data-testid":`model-bound-source`,className:l.source===`override`?`text-primary font-medium`:`text-foreground-subtle`,children:oB(l.source,o)}),h&&v(`button`,{type:`button`,disabled:r,className:`text-foreground-subtle hover:text-foreground disabled:opacity-50`,onClick:()=>i(va(n,e.key)),children:o(`uiLibrary.modelBoundSlider.resetToDefault`,`Reset to model default`)})]}),m!==void 0&&typeof m.value==`number`&&v(`p`,{className:`mt-1 text-[10px] text-amber-400/90`,children:o(`uiLibrary.modelBoundSlider.staleOverride`,`The override {{value}} was set for {{modelId}} and does not apply to this model.`,{value:sB(m.value,f),modelId:m.modelId})})]})}function lB(e){return e.flatMap(e=>e.type===`group`?lB(e.fields):`key`in e&&`bindsToModel`in e&&e.bindsToModel===!0?[e.key]:[])}function uB({fields:e,modelId:t,settings:n,disabled:r,onReset:i}){let a=q(),o=lB(e),s=t.length>0?t:void 0;return o.length===0||!Za(n,o,s)?null:v(`button`,{type:`button`,disabled:r,className:`text-[10px] text-primary hover:underline disabled:opacity-50`,onClick:()=>i(xa(n,o,s)),children:a(`uiLibrary.modelBoundSlider.resetThresholds`,`Reset thresholds to model defaults`)})}function dB({expanded:e,onExpandedChange:t,header:n,children:r,dimmed:i=!1,hideChevron:a=!1,className:o}){return c(`div`,{className:$(`rounded-lg border border-border bg-surface overflow-hidden`,i&&`opacity-[0.45]`,o),children:[c(`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:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(!e))},children:[!a&&v(`span`,{className:`text-foreground-subtle shrink-0`,children:v(e?de:It,{className:`h-4 w-4`})}),n]}),e&&r&&v(`div`,{className:`border-t border-border px-3 py-3`,children:r})]})}E();function fB(e){return e?.models??[]}function pB({step:e,schema:t,allSchemas:n,depth:r=0,onChange:i,onDelete:a,readOnly:o=!1}){let s=q(),[l,u]=C(!1),d=fB(t);if(d.length>0&&!d.some(t=>t.id===e.modelId)&&!o){let n=(t?.defaultModelId?d.find(e=>e.id===t.defaultModelId):null)??d[0];n&&n.id!==e.modelId&&queueMicrotask(()=>i({...e,modelId:n.id}))}let f=c(P,{children:[c(`div`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none`,children:e.slot}),v(`span`,{className:`text-sm font-semibold text-foreground truncate block leading-tight`,children:e.addonName}),c(`div`,{className:`flex items-center gap-1 mt-0.5 flex-wrap`,children:[e.inputClasses.map(e=>v(`span`,{className:`text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400`,children:e},e)),e.inputClasses.length>0&&e.outputClasses.length>0&&v(`span`,{className:`text-foreground-subtle/40 text-[10px]`,children:`→`}),e.outputClasses.map(e=>v(`span`,{className:`text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400`,children:e},e))]})]}),!o&&v(`button`,{onClick:t=>{t.stopPropagation(),i({...e,enabled:!e.enabled})},className:$(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors`,e.enabled?`bg-success`:`bg-foreground-subtle/30`),children:v(`span`,{className:$(`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-6`:`translate-x-1`)})})]});return v(dB,{expanded:l,onExpandedChange:u,dimmed:!e.enabled,header:f,children:c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`space-y-2`,children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:s(`uiLibrary.pipelineStep.model`,`Model`)}),v(Yz,{models:d,value:e.modelId,disabled:o,onChange:t=>i({...e,modelId:t})})]}),t?.configSchema?.map(n=>v(_B,{field:n,allFields:t.configSchema??[],step:e,disabled:o,onChange:i},n.key))]})})}function mB({label:e,value:t,options:n,disabled:r,onChange:i}){let a=q();return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5`,children:e}),c(`select`,{value:t,onChange:e=>i(e.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&&v(`option`,{value:t,children:t||a(`uiLibrary.pipelineStep.default`,`default`)}),n.map(e=>v(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]})]})}function hB({label:e,description:t,value:n,options:r,disabled:i,onChange:a}){function o(e){i||a(n.includes(e)?n.filter(t=>t!==e):[...n,e])}return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1`,children:e}),t&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:t}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>c(`button`,{type:`button`,disabled:i,onClick:()=>o(e.value),className:$(`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded-md border transition-colors`,n.includes(e.value)?`bg-primary/20 text-primary border-primary/40`:`bg-surface text-foreground-subtle border-border hover:border-primary/30`,i&&`opacity-50 cursor-not-allowed`),children:[e.iconId!==void 0&&v(Wk,{iconId:e.iconId,size:12}),e.label]},e.value))})]})}function gB(e,t,n){let r=t.settings?.[e];if(r!==void 0)return r;let i=n.find(t=>`key`in t&&t.key===e);return i&&`default`in i?i.default:void 0}function _B({field:e,allFields:t,step:n,disabled:r,onChange:i,hideModelBoundSourceRow:a}){let o=q(),s=`modelApplicability`in e?e.modelApplicability:void 0,l=s?.inapplicable?.[n.modelId],u=v(vB,{field:e,allFields:t,step:n,disabled:r||l!==void 0,modelScopedOptions:s?.optionsByModel?.[n.modelId],onChange:i,hideModelBoundSourceRow:a===!0});return l===void 0?u:c(`div`,{className:`space-y-1`,children:[u,v(`div`,{className:`text-[10px] text-amber-400/90`,children:o(`uiLibrary.pipelineStep.noEffect`,`No effect with the selected model — {{reason}}`,{reason:l})})]})}function vB({field:e,allFields:t,step:n,disabled:r,modelScopedOptions:i,onChange:a,hideModelBoundSourceRow:o}){let s=e.type!==`separator`&&e.type!==`info`?e.showWhen:void 0;if(s){let{field:e,equals:r,notEquals:i,in:a,notIn:o}=s,c=gB(e,n,t);if(r!==void 0&&c!==r||i!==void 0&&c===i||a!==void 0&&!a.includes(c)||o!==void 0&&o.includes(c))return null}function l(t){a({...n,settings:{...n.settings,[e.key]:t}})}if(e.type===`select`){let t=n.settings?.[e.key],a=typeof t==`string`?t:e.default??``;return v(mB,{label:e.label,value:a,disabled:r||e.disabled,options:i??e.options,onChange:l})}if(e.type===`multiselect`){let t=n.settings?.[e.key],a=Array.isArray(t)?t:Array.isArray(e.default)?e.default:[];return v(hB,{label:e.label,description:e.description,value:a,options:i??e.options,disabled:r||e.disabled,onChange:l})}if((e.type===`slider`||e.type===`number`)&&e.bindsToModel===!0)return v(cB,{field:e,modelId:n.modelId,settings:n.settings,disabled:r,onChangeSettings:e=>a({...n,settings:e}),hideSourceRow:o});if(e.type===`slider`||e.type===`number`){let t=n.settings?.[e.key],i=typeof e.default==`number`?e.default:e.min??0,a=typeof t==`number`?t:i,o=e.min??0,s=e.max??1,u=e.step??.01,d=e.type===`slider`?e.showValue:!0,f=`unit`in e?e.unit:void 0,p=e.type===`slider`?e.displayScale:void 0,m=p?a/p:a;return c(`div`,{children:[c(`div`,{className:`flex items-center justify-between mb-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:e.label}),d&&c(`span`,{className:`text-xs font-medium text-foreground tabular-nums`,children:[typeof m==`number`?m.toFixed(2).replace(/\.?0+$/,``):m,f?` ${f}`:``]})]}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:e.description}),v(`input`,{type:`range`,min:o,max:s,step:u,value:a,disabled:r||e.disabled,onChange:e=>l(Number(e.target.value)),className:`w-full accent-primary h-1.5`})]})}if(e.type===`boolean`){let t=n.settings?.[e.key];return c(`label`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`checkbox`,checked:typeof t==`boolean`?t:e.default===!0,disabled:r||e.disabled,onChange:e=>l(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),v(`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`){let t=n.settings?.[e.key],i=typeof t==`string`?t:e.default??``,a=e.type===`password`?`password`:`text`;return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5`,children:e.label}),e.type===`textarea`?v(`textarea`,{value:i,disabled:r||e.disabled,placeholder:e.placeholder,onChange:e=>l(e.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`}):v(`input`,{type:a,value:i,disabled:r||e.disabled,placeholder:e.placeholder,onChange:e=>l(e.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`?v(`div`,{className:`border-t border-border my-2`}):e.type===`info`?v(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle`,children:e.content}):null}function yB(e){return e.type!==`separator`&&e.type!==`info`&&e.type!==`group`}function bB(e){return`bindsToModel`in e&&e.bindsToModel===!0?!0:`key`in e&&_ee(e.key)}function xB(e){return e.flatMap(e=>{if(e.type===`group`){let t=xB(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return bB(e)?[]:[e]})}function SB(e){return(e.type===`slider`||e.type===`number`)&&e.bindsToModel===!0}function CB(e,t){let n=`modelApplicability`in e?e.modelApplicability?.defaultByModel?.[t]:void 0;return n===void 0?{value:`default`in e?e.default:void 0,fromModel:!1}:{value:n,fromModel:!0}}function wB(e){return e.toFixed(2).replace(/\.?0+$/,``)}function TB(e,t){if(t==null)return`—`;if(typeof t==`boolean`)return t?`on`:`off`;if(typeof t==`number`){let n=e.type===`slider`?e.displayScale:void 0,r=`unit`in e&&typeof e.unit==`string`?` ${e.unit}`:``;return`${wB(n===void 0?t:t/n)}${r}`}let n=`options`in e&&Array.isArray(e.options)?e.options:[],r=e=>{let t=n.find(t=>t.value===e);return t?t.label:String(e)};return Array.isArray(t)?t.length===0?`none`:t.map(r).join(`, `):typeof t==`string`?r(t):JSON.stringify(t)}var EB={camera:`border-primary/40 bg-primary/10 text-primary`,node:`border-border bg-muted/40 text-foreground`,default:`border-border/60 text-foreground-subtle`};function DB(e){return`step-field-${e}`}function OB(e,t,n){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:t,children:[],settings:{...n}}}var kB=[`camera`,`node`];function AB({field:e,layers:t,target:n,labels:r,boundKeys:i,modelId:a,pinned:o,disabled:s,onReset:l,action:u}){let d=q(),f=Ya(t),p=CB(e,a),m=p.fromModel?d(`uiLibrary.layeredSettings.modelDefault`,`model default`):d(`uiLibrary.layeredSettings.default`,`default`),h=_a(t,e.key,i),g=SB(e),_=g?oa(f,e.key,a,p.value,p.value):null,y=_===null||_.source===`override`?h:`default`,b=y==="default"?m:r[y]??y,x=kB.filter(e=>e!==y&&r[e]!==void 0).filter(n=>t[n]?.[e.key]!==void 0).map(n=>{let i=g?t[n]?.[ao(e.key)]:void 0,o=typeof i==`string`&&i!==a?d(`uiLibrary.layeredSettings.forModel`,` (for {{model}})`,{model:i}):``;return`${r[n]} ${TB(e,t[n]?.[e.key])}${o}`}),S=y==="default"?x:[...x,`${m} ${TB(e,p.value)}`],C=_a({[n]:t[n]},e.key,i)!=="default",w=kB.slice(kB.indexOf(n)+1).find(n=>r[n]!==void 0&&t[n]?.[e.key]!==void 0),T=w===void 0?m:r[w]??w,E=h==="default"?`default`:_a({...t,[h]:void 0},e.key,i),D=E==="default"?m:r[E]??E;return c(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px]`,children:[v(`span`,{"data-testid":`setting-source`,className:$(`rounded border px-1.5 py-px font-medium`,EB[y]),children:b}),S.length>0&&v(`span`,{"data-testid":`setting-levels`,className:`text-foreground-subtle`,children:S.join(` · `)}),o&&v(`span`,{className:`rounded border border-warning/40 px-1.5 py-px text-warning`,title:d(`uiLibrary.layeredSettings.pinnedHint`,`Stored by an older editor as a copy of the value below. It changes nothing today, but it stops later changes below from reaching this camera.`),children:d(`uiLibrary.layeredSettings.pinned`,`pinned at the {{source}} value`,{source:D.toLowerCase()})}),c(`span`,{className:`ml-auto flex items-center gap-2`,children:[u,C&&v(`button`,{type:`button`,disabled:s,onClick:l,className:`rounded px-1 text-foreground-subtle hover:bg-muted hover:text-foreground disabled:opacity-50`,children:d(`uiLibrary.layeredSettings.resetTo`,`Reset to {{target}}`,{target:T.toLowerCase()})})]})]})}function jB({addon:e,fields:t,layers:n,target:r,labels:i,modelId:a,onChangeLayer:o,rootModel:s,pinnedKeys:l=[],fieldActions:u,headerActions:d,highlightKey:f=null,disabled:p=!1}){let m=q(),h=r===`camera`?xB(t):t,g=Qi(h),_=Ya(n),y=n[r],b=OB(e,a,_),x=tB(e.id,_,s);return c(`div`,{className:`space-y-2 text-xs`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`h3`,{className:Ut,children:m(`uiLibrary.layeredSettings.title`,`Settings`)}),v(`span`,{className:Ii,children:m(`uiLibrary.layeredSettings.editing`,`editing: {{target}}`,{target:i[r]??r})}),c(`span`,{className:`ml-auto flex flex-wrap items-center gap-3`,children:[d,v(uB,{fields:h,modelId:a,settings:y,disabled:p,onReset:e=>o(e)})]})]}),x!==null&&v(aB,{stepId:e.id,settings:_,rootModel:s,disabled:p,onChange:e=>o(za(y,`useRootModel`,nB(_,e),[]))}),h.map(e=>{if(!yB(e))return v(_B,{field:e,allFields:h,step:b,disabled:p,onChange:()=>{}},e.key);let t=f===e.key;return c(`div`,{id:DB(e.key),"data-field-key":e.key,className:$(`rounded-md border border-transparent px-2 py-1 -mx-2`,t&&`border-primary/50 bg-primary/5`),children:[v(_B,{field:e,allFields:h,step:b,disabled:p,hideModelBoundSourceRow:!0,onChange:t=>o(za(y,e.key,t.settings??{},g))}),v(AB,{field:e,layers:n,target:r,labels:i,boundKeys:g,modelId:a,pinned:l.includes(e.key),disabled:p,onReset:()=>o(ka(y,e.key,g)),action:u?.(e.key,_a(n,e.key,g))})]},e.key)})]})}E();function MB(e){let t=new Set(Ji(e.id).map(e=>e.key));return(e.configSchema??[]).filter(e=>!t.has(e.key))}function NB(e,t,n,r){return r!==void 0&&tB(e.id,n,r)?.effective?r.modelId:t??e.defaultModelId}function PB({addonId:e}){let t=q();return Ji(e).length===0?null:v(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:t(`uiLibrary.agentStepEditor.clusterHint`,`Admission knobs for this step live in Pipeline → Cluster → Settings → Enrichment models. They apply to every camera — a per-device copy would fill the shared index from two policies.`)})}function FB({rootModel:e,stepModelId:t}){return v(`div`,{className:`rounded bg-primary/10 px-3 py-2 text-[11px] text-foreground-subtle`,"data-testid":`root-supplied-model`,children:v(gi,{uiKey:`uiLibrary.agentStepEditor.rootSupplied`,fallback:`<0>Model: {{name}}</0> (the root model). This step's own model{{stepModel}} is kept and runs again whenever the root model cannot supply the step.`,components:[v(`span`,{className:`font-semibold text-foreground`},`m`)],values:{name:e.name,stepModel:t===void 0?``:` (${t})`}})})}function IB({addon:e,agentDefault:t,onChangeAgentConfig:n,engineFormat:r,effectiveModelId:i,rootModel:a}){let o=q(),s=p(()=>Qz(e.models,r),[e.models,r]),l=e=>{n?.({...t,...e})},u=MB(e),d=e.defaultModelIdByFormat?.[r]??e.defaultModelId,f=t.settings??{},m=tB(e.id,f,a)?.effective===!0,h=t.modelId??i;return c(`div`,{className:`space-y-4 text-xs`,children:[m&&a!==void 0?v(FB,{rootModel:a,stepModelId:h}):c(`div`,{children:[v(`div`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle mb-1`,children:o(`uiLibrary.agentStepEditor.model`,`Model`)}),v(Yz,{models:s,value:h??``,defaultModelId:d,onChange:e=>l({modelId:e})})]}),(u.length>0||tB(e.id,f,a))&&v(`div`,{className:`pt-2 border-t border-border/50`,children:v(jB,{addon:e,fields:u,layers:{node:f},target:`node`,labels:{node:`This node`},modelId:NB(e,h,f,a),...a===void 0?{}:{rootModel:a},onChangeLayer:e=>l({settings:e})})}),v(PB,{addonId:e.id})]})}E();var LB=D(({className:e,...t},n)=>v(`label`,{ref:n,className:$(`text-[10px] uppercase tracking-wider text-foreground-muted font-medium`,e),...t}));LB.displayName=`Label`,E();var RB=Il(``,{variants:{orientation:{horizontal:`h-px w-full bg-border-subtle`,vertical:`w-px h-full bg-border-subtle`}},defaultVariants:{orientation:`horizontal`}}),zB=D(({className:e,orientation:t,...n},r)=>v(`div`,{ref:r,role:`separator`,"aria-orientation":t??`horizontal`,className:$(RB({orientation:t}),e),...n}));zB.displayName=`Separator`,E();var BB=D(({className:e,...t},n)=>v(`input`,{ref:n,type:`checkbox`,className:$(`w-3.5 h-3.5 rounded-sm border border-border accent-primary`,e),...t}));BB.displayName=`Checkbox`,E();var VB=D(({className:e,checked:t,onCheckedChange:n,label:r,...i},a)=>c(`button`,{ref:a,role:`switch`,"aria-checked":t,type:`button`,onClick:()=>n(!t),className:$(`inline-flex items-center gap-2`,e),...i,children:[v(`span`,{className:$(`w-8 h-4 rounded-full transition-colors`,t?`bg-primary`:`bg-surface-hover`),children:v(`span`,{className:$(`block w-3.5 h-3.5 rounded-full bg-white transition-transform`,t?`translate-x-4`:`translate-x-0.5`)})}),r&&v(`span`,{className:`text-xs text-foreground`,children:r})]}));VB.displayName=`Switch`,E();function HB(e){let{scrollLeft:t,scrollWidth:n,clientWidth:r}=e,i=n>r+1;return{overflowLeft:i&&t>1,overflowRight:i&&t+r<n-1}}function UB(e){typeof e.scrollIntoView==`function`&&e.scrollIntoView({inline:`nearest`,block:`nearest`})}function WB(e,t){let n=e.querySelectorAll(`[role="tab"]`);if(n.length===0)return;let r=e.scrollLeft;if(t===`right`){for(let e of n)if(e.offsetLeft+e.offsetWidth>r+1){UB(e);return}return}for(let e=n.length-1;e>=0;e--){let t=n[e];if(t!==void 0&&t.offsetLeft<r-1){UB(t);return}}}function GB(e){let t=e.querySelector(`[role="tab"][aria-selected="true"]`);t!==null&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({inline:`nearest`,block:`nearest`})}function KB({activeTabKey:e,listClassName:t,className:n,children:r,...i}){let a=f(null),[o,s]=C({overflowLeft:!1,overflowRight:!1}),[l,u]=C(!1),d=_(()=>{let e=a.current;e!==null&&s(HB(e))},[]);b(()=>{d();let e=a.current;if(e===null)return;e.addEventListener(`scroll`,d,{passive:!0});let t=typeof ResizeObserver<`u`?new ResizeObserver(d):null;t?.observe(e);for(let n of e.children)t?.observe(n);return()=>{e.removeEventListener(`scroll`,d),t?.disconnect()}},[d,r]),b(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(hover: hover) and (pointer: fine)`),t=()=>{u(e.matches)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),b(()=>{let t=a.current;t===null||e===void 0||(GB(t),d())},[e,d]);let p=e=>{let t=a.current;t!==null&&WB(t,e)};return c(`div`,{className:$(`relative min-w-0`,n),"data-tab-strip-overflow-left":o.overflowLeft?``:void 0,"data-tab-strip-overflow-right":o.overflowRight?``:void 0,children:[o.overflowLeft&&v(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 z-[1] w-8 bg-gradient-to-r from-background to-transparent`}),o.overflowRight&&v(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 z-[1] w-8 bg-gradient-to-l from-background to-transparent`}),l&&o.overflowLeft&&v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:ge,"aria-label":`Scroll tabs left`,className:`absolute left-0 top-1/2 z-[2] -translate-y-1/2 bg-background/80 shadow-sm`,onClick:()=>p(`left`)}),l&&o.overflowRight&&v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:It,"aria-label":`Scroll tabs right`,className:`absolute right-0 top-1/2 z-[2] -translate-y-1/2 bg-background/80 shadow-sm`,onClick:()=>p(`right`)}),v(`div`,{ref:a,role:`tablist`,className:t,...i,children:r})]})}E();var qB=O(null);function JB(){let e=I(qB);if(!e)throw Error(`Tabs compound components must be used within <Tabs>`);return e}function YB({value:e,onValueChange:t,defaultValue:n=``,appearance:r=`underline`,className:i,...a}){let[o,s]=C(n),c=e??o,l=_(n=>{t?.(n),e===void 0&&s(n)},[e,t]);return v(qB.Provider,{value:{value:c,setValue:l,appearance:r},children:v(`div`,{className:i,...a})})}function XB({className:e,...t}){let{appearance:n,value:r}=JB();return v(KB,{activeTabKey:r,listClassName:$(`flex flex-row overflow-x-auto overflow-y-hidden`,n===`pills`?`gap-1 border-b border-border-subtle py-1`:`border-b border-border-subtle`,e),...t})}var ZB=D(function({value:e,className:t,...n},r){let{value:i,setValue:a,appearance:o}=JB(),s=e===i;return v(`button`,{ref:r,type:`button`,role:`tab`,"aria-selected":s,"aria-controls":`tabpanel-${e}`,tabIndex:s?0:-1,className:$(`inline-flex h-7 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap text-xs px-3 transition-colors`,o===`pills`?s?`rounded-md bg-primary/10 font-medium text-primary`:`rounded-md text-foreground-muted hover:bg-surface-hover hover:text-foreground`:s?`border-b-2 border-primary text-foreground font-medium`:`text-foreground-muted hover:text-foreground`,t),onClick:()=>a(e),...n})});function QB({value:e,className:t,...n}){let{value:r}=JB();return e===r?v(`div`,{role:`tabpanel`,id:`tabpanel-${e}`,className:$(`pt-3`,t),...n}):null}E();var $B=D(({className:e,...t},n)=>v(`div`,{ref:n,className:$(`overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full`,e),...t}));$B.displayName=`ScrollArea`,E();function eV({title:e,icon:t,position:n,onPositionChange:r,size:i,onSizeChange:a,onClose:o,children:s,defaultWidth:l=360,defaultHeight:u=280,minWidth:d=280,minHeight:p=160,offsetIndex:m=0,className:h}){let g=q(),[y,x]=C({x:80+m*30,y:80+m*30}),[S,w]=C({w:l,h:u}),T=n??y,E=i??S,D=f({size:E,onPositionChange:r,onSizeChange:a});D.current={size:E,onPositionChange:r,onSizeChange:a};let[O,k]=C(!1),A=f(!1),j=f(!1),M=f({x:0,y:0}),N=dl(),P=_(e=>{e.preventDefault(),A.current=!0,M.current={x:e.clientX-T.x,y:e.clientY-T.y}},[T]),F=_(e=>{e.preventDefault(),e.stopPropagation(),j.current=!0,M.current={x:e.clientX,y:e.clientY}},[]);return b(()=>{let e=e=>{if(A.current){let t={x:e.clientX-M.current.x,y:e.clientY-M.current.y};x(t),D.current.onPositionChange?.(t)}if(j.current){let t=e.clientX-M.current.x,n=e.clientY-M.current.y;M.current={x:e.clientX,y:e.clientY};let r=D.current.size,i={w:Math.max(d,r.w+t),h:Math.max(p,r.h+n)};D.current={...D.current,size:i},w(i),D.current.onSizeChange?.(i)}},t=()=>{A.current=!1,j.current=!1};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[d,p]),N?c(`div`,{className:$(`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 pb-[env(safe-area-inset-bottom)]`,h),style:{maxHeight:`60dvh`},children:[c(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t&&v(t,{size:12,className:`text-primary shrink-0`}),v(`span`,{className:`text-[11px] font-medium truncate`,children:e})]}),c(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v(`button`,{onClick:()=>k(!O),className:`p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors`,children:v(O?Br:mi,{size:12})}),v(`button`,{onClick:o,className:`p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors`,children:v(Zn,{size:12})})]})]}),!O&&v(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:s})]}):c(`div`,{className:$(`fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden`,h),style:{left:T.x,top:T.y,width:O?280:E.w,height:O?`auto`:E.h},children:[c(`div`,{onMouseDown:P,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:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(fr,{size:12,className:`text-foreground-subtle shrink-0`}),t&&v(t,{size:12,className:`text-primary shrink-0`}),v(`span`,{className:`text-[11px] font-medium truncate`,children:e})]}),c(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v(`button`,{onClick:()=>k(!O),className:`p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors`,title:O?g(`uiLibrary.floatingPanel.restore`,`Restore`):g(`uiLibrary.floatingPanel.minimize`,`Minimize`),children:v(O?Br:mi,{size:12})}),v(`button`,{onClick:o,className:`p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors`,title:g(`uiLibrary.floatingPanel.close`,`Close`),children:v(Zn,{size:12})})]})]}),!O&&c(`div`,{className:`flex-1 min-h-0 overflow-y-auto relative`,children:[s,v(`div`,{onMouseDown:F,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}})]})]})}E();function tV({open:e,onClose:t,children:n,className:r,width:i=`w-64`}){let a=f(null);return b(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=``}},[e,t]),c(P,{children:[v(`div`,{className:$(`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`}),v(`div`,{ref:a,role:`dialog`,"aria-modal":`true`,className:$(`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 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,i,e?`translate-x-0`:`-translate-x-full`,r),children:n})]})}function nV({label:e,icon:t,href:n,badge:r,active:i=!1,className:a}){return c(`a`,{href:n,className:$(`flex items-center gap-2 h-7 px-2 text-[11px] transition-colors`,i?`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:[v(t,{className:`h-3.5 w-3.5 shrink-0`}),v(`span`,{className:`truncate flex-1`,children:e}),r!==void 0&&v(Bk,{className:`ml-auto text-[10px] px-1.5 py-0`,children:r})]})}function rV({logo:e,sections:t,footer:n,onNavigate:r,className:i}){return c(`nav`,{className:$(`bg-surface border-r border-border h-full flex flex-col`,i),children:[e&&v(`div`,{className:`px-3 py-2 shrink-0`,children:e}),v(`div`,{className:`flex-1 overflow-auto px-1 py-1`,children:t.map((e,t)=>c(`div`,{className:$(t>0?`mt-3`:``),children:[e.label&&v(`span`,{className:`text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block`,children:e.label}),v(`div`,{className:`flex flex-col gap-0.5`,onClick:r,children:e.items.map(e=>v(nV,{...e},e.href))})]},t))}),n&&n.length>0&&c(`div`,{className:`shrink-0 px-1 pb-1`,children:[v(zB,{className:`mb-1`}),v(`div`,{className:`flex flex-col gap-0.5`,onClick:r,children:n.map(e=>v(nV,{...e},e.href))})]})]})}E();function iV({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:i,className:a}){let o=q(),s=dl(),[l,u]=C(!1);return c(`div`,{className:$(`flex h-screen`,a),children:[!s&&v(rV,{...e,className:$(`w-44`,e.className)}),s&&v(tV,{open:l,onClose:()=>u(!1),width:`w-64`,children:v(rV,{...e,onNavigate:()=>u(!1),className:`w-full border-r-0`})}),c(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[s&&c(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[v(`button`,{onClick:()=>u(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":o(`uiLibrary.appShell.openMenu`,`Open menu`),children:v(sr,{className:`h-5 w-5`})}),n&&v(`div`,{className:`flex-1 flex justify-center`,children:n}),r&&v(`div`,{className:`shrink-0`,children:r})]}),!s&&t&&c(`header`,{className:`flex items-center h-10 border-b border-border px-4 shrink-0`,children:[t.breadcrumbs&&t.breadcrumbs.length>0&&v(`nav`,{className:`flex items-center gap-1 text-xs flex-1 min-w-0`,children:t.breadcrumbs.map((e,n)=>{let r=n===t.breadcrumbs.length-1;return c(`span`,{className:`flex items-center gap-1`,children:[n>0&&v(It,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),e.href&&!r?v(`a`,{href:e.href,className:`text-foreground-subtle hover:text-foreground transition-colors truncate`,children:e.label}):v(`span`,{className:`text-foreground truncate`,children:e.label})]},n)})}),t.actions&&v(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:t.actions})]}),v(`main`,{className:`flex-1 overflow-auto p-4`,children:i})]})]})}function aV(e){return e>=.8?`bg-emerald-500`:e>=.5?`bg-amber-500`:e>=.3?`bg-orange-500`:`bg-zinc-500`}function oV(e){return e>=.8?`text-emerald-400`:e>=.5?`text-amber-400`:e>=.3?`text-orange-400`:`text-zinc-400`}function sV({classifications:e,processing:t=!1,inferenceMs:n,maxItems:r=10,className:i=``}){let a=q(),o=e.slice(0,r),s=o.length>0?o[0].score:1;return t?v(`div`,{className:`rounded-xl border border-border bg-surface p-4 text-center ${i}`,children:v(`div`,{className:`text-sm text-foreground-subtle animate-pulse`,children:a(`uiLibrary.audioClassificationList.processing`,`Classifying audio...`)})}):o.length===0?v(`div`,{className:`rounded-xl border border-border bg-surface p-4 text-center ${i}`,children:v(`div`,{className:`text-xs text-foreground-subtle`,children:a(`uiLibrary.audioClassificationList.empty`,`No classifications yet`)})}):c(`div`,{className:`rounded-xl border border-border bg-surface overflow-hidden ${i}`,children:[c(`div`,{className:`px-3 py-2 border-b border-border flex items-center justify-between`,children:[v(`h3`,{className:`text-xs font-medium text-foreground`,children:a(`uiLibrary.audioClassificationList.title`,`Audio Classifications`)}),c(`div`,{className:`flex items-center gap-3 text-[10px] text-foreground-subtle`,children:[o.length<e.length&&v(`span`,{children:a(`uiLibrary.audioClassificationList.showing`,`showing {{shown}} of {{total}}`,{shown:o.length,total:e.length})}),n!==void 0&&c(`span`,{className:`font-mono`,children:[n.toFixed(1),`ms`]})]})]}),v(`div`,{className:`divide-y divide-border/50`,children:o.map((e,t)=>{let n=s>0?e.score/s*100:0;return c(`div`,{className:`px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle w-5 text-right font-mono`,children:t+1}),v(`span`,{className:`text-xs font-medium text-foreground min-w-[120px]`,children:e.className}),v(`div`,{className:`flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden`,children:v(`div`,{className:`h-full rounded-full transition-all duration-300 ${aV(e.score)}`,style:{width:`${n}%`}})}),c(`span`,{className:`text-xs font-mono font-semibold w-14 text-right ${oV(e.score)}`,children:[(e.score*100).toFixed(1),`%`]})]},`${e.className}-${t}`)})})]})}E();function cV({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:r=64,className:i=``,color:a=`#10b981`,clipColor:o=`#ef4444`,clipThreshold:s=-6,minDbfs:l=-96}){let u=q(),d=f(null),p=f(null),[m,h]=C([]);b(()=>{e!==null&&h(t=>{let r=[...t,{dbfs:e,timestamp:Date.now()}];return r.length>n?r.slice(-n):r})},[e,n]);let g=_(()=>{let e=d.current,n=p.current;if(!e||!n)return;let i=n.clientWidth;if(i===0)return;let c=window.devicePixelRatio||1;e.width=i*c,e.height=r*c,e.style.width=`${i}px`,e.style.height=`${r}px`;let u=e.getContext(`2d`);if(!u||(u.scale(c,c),u.clearRect(0,0,i,r),m.length===0))return;let f=m[m.length-1].timestamp,h=t*1e3,g=f-h,_=m.filter(e=>e.timestamp>=g);if(_.length===0)return;let v=Math.max(1,Math.floor(i/(t*2))),y=Math.abs(l);for(let e of _){let t=e.timestamp-g,n=Math.floor(t/h*i),c=(Math.max(l,Math.min(0,e.dbfs))-l)/y,d=Math.max(1,c*r);u.fillStyle=e.dbfs>=s?o:a,u.globalAlpha=.8,u.fillRect(n,r-d,v,d)}u.globalAlpha=1;let b=r-(s-l)/y*r;u.strokeStyle=o,u.globalAlpha=.25,u.lineWidth=1,u.setLineDash([4,4]),u.beginPath(),u.moveTo(0,b),u.lineTo(i,b),u.stroke(),u.setLineDash([]),u.globalAlpha=1},[m,t,r,a,o,s,l]);b(()=>{g()},[g]),b(()=>{let e=new ResizeObserver(()=>g()),t=p.current;return t&&e.observe(t),()=>e.disconnect()},[g]);let y=m.length>0?m[m.length-1].dbfs:null;return c(`div`,{ref:p,className:`relative ${i}`,children:[v(`canvas`,{ref:d,className:`w-full rounded-md`}),c(`div`,{className:`absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono`,children:[t,`s`]}),y!==null&&v(`div`,{className:`absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono`,children:u(`uiLibrary.audioLevelWaveform.readout`,{one:`{{dbfs}} dBFS · {{count}} sample`,other:`{{dbfs}} dBFS · {{count}} samples`},{dbfs:y.toFixed(1),count:m.length})})]})}E();function lV({samples:e,sampleRate:t=16e3,height:n=96,className:r=``,color:i=`#3b82f6`,bgColor:a=`transparent`}){let o=q(),s=f(null),l=f(null),u=_(()=>{let t=s.current,r=l.current;if(!t||!r||!e||e.length===0)return;let o=r.clientWidth;if(o===0)return;let c=window.devicePixelRatio||1;t.width=o*c,t.height=n*c,t.style.width=`${o}px`,t.style.height=`${n}px`;let u=t.getContext(`2d`);if(!u)return;u.scale(c,c),a===`transparent`?u.clearRect(0,0,o,n):(u.fillStyle=a,u.fillRect(0,0,o,n));let d=e.length/o,f=n/2;u.fillStyle=i,u.globalAlpha=.7;for(let t=0;t<o;t++){let n=Math.floor(t*d),r=Math.min(Math.floor((t+1)*d),e.length),i=0,a=0;for(let t=n;t<r;t++){let n=e[t];n<i&&(i=n),n>a&&(a=n)}let o=f-a*f,s=f-i*f,c=Math.max(1,s-o);u.fillRect(t,o,1,c)}u.globalAlpha=1,u.strokeStyle=i,u.globalAlpha=.2,u.lineWidth=1,u.beginPath(),u.moveTo(0,f),u.lineTo(o,f),u.stroke(),u.globalAlpha=1},[e,n,i,a]);b(()=>{u()},[u]),b(()=>{let e=new ResizeObserver(()=>u()),t=l.current;return t&&e.observe(t),()=>e.disconnect()},[u]);let d=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return c(`div`,{ref:l,className:`relative ${r}`,children:[v(`canvas`,{ref:s,className:`w-full rounded-md`}),e&&e.length>0&&v(`div`,{className:`absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono`,children:o(`uiLibrary.audioWaveform.summary`,`{{duration}}s · {{rate}}kHz · {{samples}} samples`,{duration:d,rate:t/1e3,samples:e.length.toLocaleString()})})]})}var uV=`uiLibrary.batteryBadge.low`,dV=`uiLibrary.batteryBadge.normal`;function fV(e){return e<50}function pV(e){return e<=10?Ke:e<=30?Ve:e<=70?Jr:on}function mV(e){return e===`dc`||e===`solar`}function hV(e,t){return mV(t)?`text-emerald-400`:e<=10?`text-rose-400`:e<=30?`text-amber-400`:`text-foreground-subtle`}function gV({status:e,variant:t=`compact`,className:n}){let r=q();if(!e)return null;let{level:i,charging:a,sleeping:o,binary:s}=e;if(i===null)return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,n),title:r(`uiLibrary.batteryBadge.titleUnknown`,`Battery: unknown`),children:[v(Ee,{className:`h-3.5 w-3.5`}),v(`span`,{children:r(`uiLibrary.batteryBadge.unknown`,`Unknown`)})]});if(s===!0){let e=fV(i),t=e?Ke:on;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,e?`text-rose-400`:`text-foreground-subtle`,n),title:e?r(`uiLibrary.batteryBadge.titleLow`,`Battery: low`):r(`uiLibrary.batteryBadge.titleNormal`,`Battery: normal`),children:[v(t,{className:`h-3.5 w-3.5`}),v(`span`,{children:e?r(uV,`Low`):r(dV,`Normal`)})]})}let l=pV(i),u=hV(i,a),d=a===`solar`?wt:a===`dc`?_t:null,f=o;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,u,n),title:[r(`uiLibrary.batteryBadge.titlePercent`,`Battery: {{percent}}%`,{percent:Math.round(i)}),mV(a)?r(`uiLibrary.batteryBadge.charging`,`charging ({{source}})`,{source:a}):null,o?r(`uiLibrary.batteryBadge.sleeping`,`sleeping`):null].filter(e=>e!==null).join(` · `),children:[v(l,{className:`h-3.5 w-3.5`}),c(`span`,{children:[Math.round(i),`%`]}),d&&v(d,{className:`h-3 w-3`}),f&&v(St,{className:`h-3 w-3 text-blue-300`}),t===`full`&&mV(a)&&v(`span`,{className:`text-foreground-subtle`,children:a})]})}function _V(e){if(e===null)return;let t=e.trim();return t===``?void 0:t}function vV(e,t){if(e===null||!Number.isFinite(e)||e<=0)return null;let n=t-e;if(n<=0)return null;let r=Math.floor(n/6e4);return r<60?{minutes:Math.max(1,r)}:{hours:Math.floor(r/60)}}function yV(e,t,n,r){let i=_V(n);if(e===null)return{key:`unknown`};if(e===!1)return i===void 0?{key:`idle`}:{key:`idle`,phase:i};let a=vV(t,r);return a===null?i===void 0?{key:`running`}:{key:`running`,phase:i}:{key:`running`,duration:a,...i===void 0?{}:{phase:i}}}function bV({running:e,children:t,className:n}){let r=q();return e===null?v(`span`,{"data-running":`unknown`,className:$(`inline-flex shrink-0`,n),children:t}):e===!0?c(`span`,{"data-running":`running`,className:$(`relative inline-flex shrink-0 rounded-full p-0.5`,n),"aria-label":r(`uiLibrary.runningBadge.running`,`Running`),children:[v(`span`,{className:`pointer-events-none absolute inset-0 rounded-full border border-primary animate-pulse`,"aria-hidden":!0}),t]}):c(`span`,{"data-running":`idle`,className:$(`relative inline-flex shrink-0`,n),"aria-label":r(`uiLibrary.runningBadge.idle`,`Idle`),children:[t,v(`span`,{className:`pointer-events-none absolute -bottom-px -right-px h-1.5 w-1.5 rounded-full bg-foreground-subtle`,"aria-hidden":!0})]})}function xV({running:e,since:t,phase:n,className:r,now:i=Date.now()}){let a=q(),o=yV(e,t,n,i);if(o.key===`unknown`||e!==!0&&e!==!1)return null;if(o.key===`idle`){let e=a(`uiLibrary.runningStatus.idle`,`Idle`),t=o.phase===void 0?e:a(`uiLibrary.runningStatus.withPhase`,`{{state}} · {{phase}}`,{state:e,phase:o.phase});return v(`p`,{className:$(`text-[11px] text-foreground-muted`,r),children:t})}let s;s=o.duration===void 0?a(`uiLibrary.runningStatus.running`,`Running`):`minutes`in o.duration?a(`uiLibrary.runningStatus.runningForMinutes`,`Running for {{count}} min`,{count:o.duration.minutes}):a(`uiLibrary.runningStatus.runningForHours`,`Running for {{count}} h`,{count:o.duration.hours});let c=o.phase===void 0?s:a(`uiLibrary.runningStatus.withPhase`,`{{state}} · {{phase}}`,{state:s,phase:o.phase});return v(`p`,{className:$(`text-[11px] text-foreground-muted`,r),children:c})}function SV(e){return e===null?An:e<=20?fee:e<=50?le:e<=80?uee:An}function CV(e){return e===null?`text-foreground-subtle`:e<=20?`text-rose-400`:e<=50?`text-amber-400`:`text-foreground-subtle`}function wV({status:e,className:t}){let n=q();if(!e||e.type===`unknown`)return null;if(e.type===`ethernet`)return v(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,t),title:n(`uiLibrary.networkLinkBadge.ethernet`,`Network: ethernet`),children:v(gt,{className:`h-3.5 w-3.5`})});let r=e.type===`cellular`?ft:SV(e.signal),i=e.signal===null?null:Math.round(e.signal),a=e.ssid?n(`uiLibrary.networkLinkBadge.typeSsid`,`Network: {{type}} ({{ssid}})`,{type:e.type,ssid:e.ssid}):n(`uiLibrary.networkLinkBadge.type`,`Network: {{type}}`,{type:e.type}),o=i===null?a:`${a} · ${n(`uiLibrary.networkLinkBadge.signal`,`signal {{percent}}%`,{percent:i})}`;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,CV(e.signal),t),title:o,children:[v(r,{className:`h-3.5 w-3.5`}),i!==null&&c(`span`,{children:[i,`%`]})]})}var TV={"node-a":`bg-node-a`,"node-b":`bg-node-b`,"node-c":`bg-node-c`,"node-d":`bg-node-d`,"node-e":`bg-node-e`,"node-f":`bg-node-f`,"node-g":`bg-node-g`,"node-h":`bg-node-h`},EV={"node-a":`text-node-a`,"node-b":`text-node-b`,"node-c":`text-node-c`,"node-d":`text-node-d`,"node-e":`text-node-e`,"node-f":`text-node-f`,"node-g":`text-node-g`,"node-h":`text-node-h`},DV={"node-a":`bg-node-a/15`,"node-b":`bg-node-b/15`,"node-c":`bg-node-c/15`,"node-d":`bg-node-d/15`,"node-e":`bg-node-e/15`,"node-f":`bg-node-f/15`,"node-g":`bg-node-g/15`,"node-h":`bg-node-h/15`};function OV(e){return TV[e]}function kV(e){return EV[e]}function AV(e){return DV[e]}function jV(e){for(let[t,n]of Object.entries(e))if(t===`color`)return n}function MV(e){let t=new Map;for(let n of e??[]){let e=to.safeParse(jV(n.settings));t.set(n.nodeId,e.success?e.data:Yi(n.nodeId))}return t}function NV(e,t){return e.get(t)??Yi(t)}var PV={detection:`bg-info/12 text-info ring-info/35`,decode:`bg-warning/12 text-warning ring-warning/35`,audio:`bg-success/12 text-success ring-success/35`},FV={detection:`bg-info/22 text-info ring-info/55`,decode:`bg-warning/22 text-warning ring-warning/55`,audio:`bg-success/22 text-success ring-success/55`},IV={"node-a":`bg-node-a/12`,"node-b":`bg-node-b/12`,"node-c":`bg-node-c/12`,"node-d":`bg-node-d/12`,"node-e":`bg-node-e/12`,"node-f":`bg-node-f/12`,"node-g":`bg-node-g/12`,"node-h":`bg-node-h/12`},LV={"node-a":`bg-node-a/22`,"node-b":`bg-node-b/22`,"node-c":`bg-node-c/22`,"node-d":`bg-node-d/22`,"node-e":`bg-node-e/22`,"node-f":`bg-node-f/22`,"node-g":`bg-node-g/22`,"node-h":`bg-node-h/22`},RV={"node-a":`ring-node-a/45`,"node-b":`ring-node-b/45`,"node-c":`ring-node-c/45`,"node-d":`ring-node-d/45`,"node-e":`ring-node-e/45`,"node-f":`ring-node-f/45`,"node-g":`ring-node-g/45`,"node-h":`ring-node-h/45`};function zV({roleLabel:e,roleId:t,nodeName:n,colorId:r,emphasized:i=!1,pinned:a=!1,onSelect:o,disabled:s=!1,trailing:l}){let u=q(),d=e===void 0?n:a?`${e} pinned on ${n}`:`${e} on ${n}`,f=e!==void 0&&t!==void 0,p=$(`inline-flex max-w-full items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight ring-1 ring-inset`,f?i?$(`role-node-pill-emphasized font-semibold ring-2`,FV[t]):$(`font-medium`,PV[t]):i?$(`role-node-pill-emphasized font-semibold ring-2`,LV[r],RV[r],kV(r)):$(`font-medium text-foreground-muted ring-border/60`,IV[r]),o!==void 0&&!s&&`cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,s&&`cursor-not-allowed opacity-50`),m=v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,OV(r)),"aria-hidden":!0}),h=e===void 0?c(P,{children:[m,v(`span`,{className:$(`min-w-0 truncate font-medium`,i?kV(r):`text-foreground`),children:n}),l]}):c(P,{children:[a&&v(mee,{className:`h-2.5 w-2.5 shrink-0 opacity-80`,"aria-label":u(`uiLibrary.roleNodePill.pinned`,`pinned`)}),v(`span`,{className:`shrink-0`,children:e}),v(`span`,{className:$(`min-w-0 truncate`,f?`opacity-80`:i?kV(r):`text-foreground-subtle`),children:n}),m]});return o===void 0?v(`span`,{"data-testid":`role-node-pill`,"data-role":t,title:d,className:p,children:h}):v(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`role-node-pill`,"data-role":t,title:d,disabled:s,onClick:o,className:p,children:h})}E();function BV({items:e,className:t}){return v(`nav`,{className:`hidden md:flex items-center gap-1 text-[11px] text-foreground-subtle ${t??``}`,children:e.map((t,n)=>{let r=n===e.length-1,i=!r&&(t.onClick||t.href);return c(l.Fragment,{children:[n>0&&v(It,{className:`h-3 w-3 flex-shrink-0`}),i?t.onClick?v(`button`,{type:`button`,onClick:t.onClick,className:`hover:text-foreground transition-colors`,children:t.label}):v(`a`,{href:t.href,className:`hover:text-foreground transition-colors`,children:t.label}):v(`span`,{className:r?`text-foreground font-medium`:``,children:t.label})]},n)})})}var VV={baseDelayMs:1500,maxDelayMs:15e3,maxAttempts:40};function HV(e,t=Math.random){if(e>=VV.maxAttempts)return{kind:`exhausted`,attempts:e};let n=Math.min(VV.maxDelayMs,VV.baseDelayMs*2**e);return{kind:`retry`,delayMs:Math.round(n*(.8+t()*.4))}}var UV=`/adaptive-probe`,WV=2500,GV=15e3,KV=250,qV=2;function JV(e){return e>=8?`high`:e>=2.5?`mid`:`low`}function YV(e){let{downlinkMbps:t,...n}=e;return n}function XV(e){return JV(e)!==`low`}function ZV(e){if(e===void 0||e===``)return null;let t;try{t=new URL(e)}catch{return null}return t.protocol!==`http:`&&t.protocol!==`https:`?null:`${t.origin}${t.pathname.replace(/\/+$/,``)}`}function QV(e,t){return ZV(e)??ZV(t)}function $V(e){let t=e.downlinkMbps===void 0?`none`:JV(e.downlinkMbps);return[e.phase,e.viewportWidth??`-`,e.viewportHeight??`-`,e.devicePixelRatio??`-`,t,e.prefersTier??`-`,e.probeOrigin??`unreachable`,e.probeStatus??`-`,e.probeAnswer??`-`].join(`|`)}function eH(e,t){return e<65536||!(t>0)?null:e*8/t/1e3}async function tH(e,t){let n=null,r=0,i=0;try{for(;;){let a=await e.read();if(a.done)break;let o=a.value?.byteLength??0,s=t();n===null?n=s:i+=o,r=s}}catch{e.cancel().catch(()=>void 0)}return n===null?null:eH(i,r-n)}async function nH(e,t){let n=e.replace(/\/+$/,``),r=new AbortController,i=setTimeout(()=>r.abort(),WV);try{let e=await t.fetchImpl(`${n}${UV}`,{signal:r.signal});if(!e.ok)return e.status!==void 0&&t.onRefused?.(e.status),null;let i=e.body?.getReader()??null;if(i!==null)return await tH(i,t.now);let a=t.now();return eH((await e.arrayBuffer()).byteLength,t.now()-a)}catch{return null}finally{clearTimeout(i)}}async function rH(e,t=GV){let n=e.now()+t;for(;;){if(e.signal.aborted)return`aborted`;if((e.readyState()??0)>=qV)return`frame`;if(e.now()>=n)return`timeout`;await e.sleep(KV)}}async function iH(e){if(await e.waitFrame()===`frame`)return e.measure()}function aH(e){let t=new Map,n=new Map,r=new Set,i=n=>{let r=t.get(n);return r!==void 0&&e.now()-r.at<=e.ttlMs?r.mbps:void 0};return{cached:i,firstRefusal:(e,t)=>{let n=`${e}|${String(t)}`;return r.has(n)?!1:(r.add(n),!0)},latest:n=>{let r=t.get(n);return r===void 0?null:{mbps:r.mbps,ageMs:Math.max(0,e.now()-r.at)}},measured:(r,a)=>{let o=i(r);if(o!==void 0)return Promise.resolve(o);let s=n.get(r);if(s!==void 0)return s;let c=a().then(n=>{if(!(n===null||!Number.isFinite(n)))return t.set(r,{mbps:n,at:e.now()}),n}).catch(()=>void 0).finally(()=>{n.delete(r)});return n.set(r,c),c}}}async function oH(e,t,n){if(e===void 0)return{kind:`unsupported`,why:`no-wiring`};if(t===null)return{kind:`unsupported`,why:`no-session`};try{return{kind:`answered`,answer:await e(t,n)}}catch{return{kind:`unsupported`,why:`call-failed`}}}var sH=100;function cH(e,t,n){if(n.renegotiating)return{baseline:null,sample:null};if(e===null||e.pc!==t.pc||t.ts<=e.ts)return{baseline:t,sample:null};let r=Math.max(0,t.lost-e.lost),i=r+Math.max(0,t.recv-e.recv),a=i>0?Math.min(sH,r/i*100):0,o=Math.max(0,Math.round((t.bytes-e.bytes)*8/(t.ts-e.ts)));return{baseline:t,sample:{rttMs:Math.round(t.rttS*1e3),jitterMs:Math.round(t.jitterS*1e3),estimatedBandwidthKbps:o,packetLossPercent:a,...n.probe===null?{}:{downlinkMbps:n.probe.mbps,downlinkAgeMs:n.probe.ageMs}}}}var lH={urls:`stun:stun.l.google.com:19302`};function uH(e,t){let n=[...e??[],lH];return t===void 0?{iceServers:n}:{iceServers:n,iceTransportPolicy:t}}var dH=8;function fH(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function pH(e){return typeof e==`string`&&e.length>0?e:null}function mH(e,t){if(e===null||t===null)return null;let n=e-t;return n<0?null:n}function hH(e,t){if(e===null||t===null)return null;let n=e+t;return n<=0?null:e/n*100}function gH(e){return e===null?null:/profile-level-id=([0-9a-fA-F]+)/.exec(e)?.[1]??null}function _H(e){let t={inbound:null,codecs:new Map,candidates:new Map,pair:null,selectedPairId:null},n=[];e.forEach(e=>{let r=e,i=pH(r.id);switch(r.type){case`inbound-rtp`:(r.kind??r.mediaType)===`video`&&(t.inbound=r);break;case`codec`:i!==null&&t.codecs.set(i,r);break;case`local-candidate`:case`remote-candidate`:i!==null&&t.candidates.set(i,r);break;case`candidate-pair`:n.push(r);break;case`transport`:t.selectedPairId=pH(r.selectedCandidatePairId);break;default:break}});let r=t.selectedPairId;return t.pair=n.find(e=>pH(e.id)===r)??n.find(e=>e.selected===!0)??n.find(e=>e.nominated===!0&&e.state===`succeeded`)??n.find(e=>e.nominated===!0)??n.find(e=>e.state===`succeeded`)??null,t}function vH(e){return e===null?{timestamp:null,bytesReceived:null,packetsReceived:null,packetsLost:null,framesDecoded:null,framesDropped:null,freezeCount:null,totalFreezesDurationS:null,totalDecodeTimeS:null,nackCount:null,pliCount:null}:{timestamp:fH(e.timestamp),bytesReceived:fH(e.bytesReceived),packetsReceived:fH(e.packetsReceived),packetsLost:fH(e.packetsLost),framesDecoded:fH(e.framesDecoded),framesDropped:fH(e.framesDropped),freezeCount:fH(e.freezeCount),totalFreezesDurationS:fH(e.totalFreezesDuration),totalDecodeTimeS:fH(e.totalDecodeTime),nackCount:fH(e.nackCount),pliCount:fH(e.pliCount)}}var yH={spanMs:null,kbps:null,packetsReceived:null,packetsLost:null,lossPercent:null,framesDecoded:null,framesDropped:null,freezeCount:null,freezeMs:null,nackCount:null,pliCount:null,decodeMs:null};function bH(e,t){if(t===null)return yH;let n=mH(e.timestamp,t.timestamp);if(n===null||n<=0)return yH;let r=mH(e.bytesReceived,t.bytesReceived),i=mH(e.packetsLost,t.packetsLost),a=mH(e.packetsReceived,t.packetsReceived),o=mH(e.framesDecoded,t.framesDecoded),s=mH(e.totalDecodeTimeS,t.totalDecodeTimeS),c=mH(e.totalFreezesDurationS,t.totalFreezesDurationS);return{spanMs:n,kbps:r===null?null:Math.round(r*8/n),packetsReceived:a,packetsLost:i,lossPercent:hH(i,a),framesDecoded:o,framesDropped:mH(e.framesDropped,t.framesDropped),freezeCount:mH(e.freezeCount,t.freezeCount),freezeMs:c===null?null:Math.round(c*1e3),nackCount:mH(e.nackCount,t.nackCount),pliCount:mH(e.pliCount,t.pliCount),decodeMs:s===null||o===null||o<=0?null:s/o*1e3}}function xH(e,t,n,r){if(t===null||n===null)return e;let i=e.at(-1);if(i!==void 0&&i.width===t&&i.height===n)return e;let a=[...e,{width:t,height:n,at:r}];return a.length>dH?a.slice(a.length-dH):a}function SH(e){let{inbound:t,codecs:n,candidates:r,pair:i}=_H(e.report),a=vH(t),o=t===null?void 0:n.get(pH(t.codecId)??``),s=pH(o?.mimeType),c=pH(o?.sdpFmtpLine),l=i===null?void 0:r.get(pH(i.localCandidateId)??``),u=i===null?void 0:r.get(pH(i.remoteCandidateId)??``),d=pH(l?.candidateType),f=pH(u?.candidateType),p=fH(t?.frameWidth),m=fH(t?.frameHeight),h=a.totalFreezesDurationS,g=a.totalDecodeTimeS,_=a.framesDecoded;return{at:e.now,hasInboundVideo:t!==null,width:p,height:m,fps:fH(t?.framesPerSecond),codec:s===null?null:s.split(`/`)[1]??s,codecProfileLevelId:gH(c),jitterMs:CH(t),packetsReceived:a.packetsReceived,packetsLost:a.packetsLost,lossPercent:hH(a.packetsLost,a.packetsReceived),nackCount:a.nackCount,pliCount:a.pliCount,framesDecoded:_,framesDropped:a.framesDropped,freezeCount:a.freezeCount,totalFreezeMs:h===null?null:Math.round(h*1e3),avgDecodeMs:g===null||_===null||_<=0?null:g/_*1e3,rttMs:wH(i),availableIncomingKbps:TH(i),localCandidateType:d,remoteCandidateType:f,candidatePairType:d===null&&f===null?null:`${d??`?`}/${f??`?`}`,candidateProtocol:pH(l?.protocol),iceConnectionState:e.iceConnectionState,dtlsState:e.dtlsState,window:bH(a,e.prev?.raw??null),resolutionLog:xH(e.prev?.resolutionLog??[],p,m,e.now),raw:a}}function CH(e){let t=fH(e?.jitter);return t===null?null:t*1e3}function wH(e){let t=fH(e?.currentRoundTripTime);return t===null?null:t*1e3}function TH(e){let t=fH(e?.availableIncomingBitrate);return t===null?null:Math.round(t/1e3)}var EH={unknown:`no window yet`,decoding:`decoding`,"decoder-stall":`DECODER STALL — bytes arriving, no frames out`,"transport-stall":`TRANSPORT STALL — nothing arriving`,"frozen-unknown":`frames stopped — byte rate unknown`};function DH(e){let t=OH(e);return{kind:t,label:EH[t]}}function OH(e){if(e===null||!e.hasInboundVideo)return`unknown`;let t=e.window.framesDecoded;if(t===null)return`unknown`;if(t>0)return`decoding`;let n=e.window.kbps;return n===null?`frozen-unknown`:n>0?`decoder-stall`:`transport-stall`}E();var kH=`—`;function AH(e,t){if(e==null||!Number.isFinite(e))return kH;let n=t?.digits??0;return`${e.toFixed(n)}${t?.suffix??``}`}function jH(e){return e==null||e===``?kH:e}function MH(e,t){return e==null?kH:e?t(`uiLibrary.streamDebugOverlay.yes`,`yes`):t(`uiLibrary.streamDebugOverlay.no`,`no`)}function NH(e,t,n){if(e===null)return kH;let r=Math.max(0,t-e);return r<1e3?n(`uiLibrary.streamDebugOverlay.msAgo`,`{{value}}ms ago`,{value:r}):r<6e4?n(`uiLibrary.streamDebugOverlay.sAgo`,`{{value}}s ago`,{value:(r/1e3).toFixed(1)}):n(`uiLibrary.streamDebugOverlay.msAgoLong`,`{{minutes}}m{{seconds}}s ago`,{minutes:Math.floor(r/6e4),seconds:Math.floor(r%6e4/1e3)})}var PH=3e3,FH={unknown:`bg-white/15 text-white/70`,decoding:`bg-emerald-500/25 text-emerald-200`,"decoder-stall":`bg-amber-500/30 text-amber-100`,"transport-stall":`bg-rose-500/30 text-rose-100`,"frozen-unknown":`bg-white/15 text-white/70`};function IH({label:e,value:t,window:n,strong:r=!1}){return c(`div`,{className:`flex items-baseline justify-between gap-2 leading-[1.25]`,children:[v(`span`,{className:`text-white/55 shrink-0`,children:e}),c(`span`,{className:`flex items-baseline gap-1 text-right`,children:[v(`span`,{className:r?`text-white font-semibold tabular-nums`:`text-white/90 tabular-nums`,children:t}),n!==void 0&&v(`span`,{className:`text-sky-300/80 tabular-nums`,children:n})]})]})}function LH({title:e,measuredAt:t,now:n}){let r=q(),i=t!==null&&n-t>PH;return c(`div`,{className:`flex items-baseline justify-between gap-3 mt-2 first:mt-0 pb-0.5 border-b border-white/20`,children:[v(`span`,{className:`text-white/80 font-semibold tracking-wide uppercase text-[9px]`,children:e}),c(`span`,{className:i?`text-amber-300 text-[9px]`:`text-white/45 text-[9px]`,children:[i?`${r(`uiLibrary.streamDebugOverlay.staleUpper`,`STALE`)} · `:``,NH(t,n,r)]})]})}var RH={unknown:`bg-white/50`,decoding:`bg-emerald-400`,"decoder-stall":`bg-amber-400`,"transport-stall":`bg-rose-400`,"frozen-unknown":`bg-white/50`};function zH(e){let t=q(),{stats:n,server:r,serverError:i,serverWired:a,now:o,sessionId:s}=e,l=DH(n),u=n?.window,[d,f]=C(!1),p=n!==null&&o-n.at>PH;return d?c(`div`,{className:`absolute bottom-10 left-2 z-20 transform-gpu w-[13.5rem] max-h-[70%] overflow-y-auto rounded-md bg-neutral-950/95 ring-1 ring-white/25 shadow-lg px-1.5 py-1 text-[9px] font-mono text-white/90 select-text`,"data-testid":`stream-debug-overlay`,children:[v(`button`,{type:`button`,onClick:()=>f(!1),className:`w-full text-left rounded px-1.5 py-0.5 mb-1 text-[9px] font-semibold ${FH[l.kind]}`,children:l.label}),v(LH,{title:`decode`,measuredAt:n?.at??null,now:o}),v(IH,{label:`framesDecoded`,value:AH(n?.framesDecoded),window:u?.framesDecoded===null?void 0:`+${AH(u?.framesDecoded)}`,strong:!0}),v(IH,{label:`freezeCount`,value:AH(n?.freezeCount),strong:!0}),v(IH,{label:`frozen`,value:AH(n?.totalFreezeMs,{suffix:`ms`}),window:u?.freezeMs===null?void 0:`+${AH(u?.freezeMs)}ms`,strong:!0}),v(IH,{label:`pliCount`,value:AH(n?.pliCount),window:u?.pliCount===null?void 0:`+${AH(u?.pliCount)}`,strong:!0}),v(IH,{label:`framesDropped`,value:AH(n?.framesDropped)}),v(IH,{label:`decode`,value:AH(n?.avgDecodeMs,{digits:1,suffix:`ms`}),window:u?.decodeMs===null?void 0:`${AH(u?.decodeMs,{digits:1})}ms`}),v(LH,{title:`picture`,measuredAt:n?.at??null,now:o}),v(IH,{label:`resolution`,value:n?.width!==null&&n?.width!==void 0&&n.height!==null?`${n.width}×${n.height}`:kH}),v(IH,{label:`fps`,value:AH(n?.fps)}),v(IH,{label:`codec`,value:n?.codec===null||n?.codec===void 0?kH:`${n.codec}${n.codecProfileLevelId===null?``:` ${n.codecProfileLevelId}`}`}),(n?.resolutionLog.length??0)>1&&v(`div`,{className:`mt-0.5 text-white/60 leading-tight`,children:n?.resolutionLog.map(e=>c(`div`,{className:`flex justify-between`,children:[c(`span`,{children:[e.width,`×`,e.height]}),v(`span`,{className:`text-white/40`,children:NH(e.at,o,t)})]},`${e.at}-${e.width}x${e.height}`))}),v(LH,{title:`transport`,measuredAt:n?.at??null,now:o}),v(IH,{label:`bitrate`,value:AH(u?.kbps,{suffix:` kbps`})}),v(IH,{label:`rtt`,value:AH(n?.rttMs,{digits:0,suffix:`ms`})}),v(IH,{label:`jitter`,value:AH(n?.jitterMs,{digits:1,suffix:`ms`})}),v(IH,{label:`packetsLost`,value:AH(n?.packetsLost),window:u?.packetsLost===null?void 0:`+${AH(u?.packetsLost)}`}),v(IH,{label:`loss`,value:AH(n?.lossPercent,{digits:2,suffix:`%`}),window:u?.lossPercent===null?void 0:AH(u?.lossPercent,{digits:2,suffix:`%`})}),v(IH,{label:`nackCount`,value:AH(n?.nackCount),window:u?.nackCount===null?void 0:`+${AH(u?.nackCount)}`}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.candidatePair`,`candidate pair`),value:jH(n?.candidatePairType)}),v(IH,{label:`protocol`,value:jH(n?.candidateProtocol)}),v(IH,{label:`ice`,value:jH(n?.iceConnectionState)}),v(IH,{label:`dtls`,value:jH(n?.dtlsState)}),v(LH,{title:`server`,measuredAt:r?.observedAt??null,now:o}),a?i===null?r===null?v(`div`,{className:`text-white/50 leading-tight py-0.5`,children:t(`uiLibrary.streamDebugOverlay.waiting`,`waiting for the first answer…`)}):r.alive?c(P,{children:[v(IH,{label:t(`uiLibrary.streamDebugOverlay.servedRung`,`served rung`),value:jH(r.servedTier),strong:!0}),v(IH,{label:`adaptive`,value:MH(r.adaptive,t)}),v(IH,{label:`source`,value:jH(r.camStreamId)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.sourceKind`,`source kind`),value:r.sourceKind}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.ingestNode`,`ingest node`),value:jH(r.ingestNodeId)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.remote`,`· remote`),value:MH(r.ingestIsRemote,t)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.egressLeg`,`egress leg`),value:r.egressLeg,strong:!0}),v(IH,{label:`codec src→out`,value:`${jH(r.sourceCodec)}→${jH(r.negotiatedCodec)}`}),v(IH,{label:`broker`,value:jH(r.brokerStatus)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.bitrate`,`· bitrate`),value:AH(r.brokerBitrateKbps,{suffix:` kbps`})}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.inputFps`,`· input fps`),value:AH(r.brokerInputFps)}),v(IH,{label:`rtp sent`,value:AH(r.rtpPacketsSent)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.trackMode`,`track mode`),value:jH(r.trackMode)}),r.lastDecision===null?v(IH,{label:`ladder`,value:r.climbHold?t(`uiLibrary.streamDebugOverlay.held`,`held`):t(`uiLibrary.streamDebugOverlay.neverMoved`,`never moved`)}):c(P,{children:[v(IH,{label:t(`uiLibrary.streamDebugOverlay.ladderMove`,`ladder move`),value:`${r.lastDecision.causeDetail??r.lastDecision.cause}${r.lastDecision.tier===null?``:` → ${r.lastDecision.tier}`}`,strong:!0}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.when`,`· when`),value:NH(r.lastDecision.at,o,t)}),v(IH,{label:`· lossRatio`,value:AH(r.lastDecision.lossRatio,{digits:4})}),v(IH,{label:`· clientKbps`,value:AH(r.lastDecision.clientKbps,{suffix:` kbps`})}),v(IH,{label:`· stalledFor`,value:AH(r.lastDecision.stalledForMs,{suffix:`ms`})}),v(IH,{label:`· serverSending`,value:MH(r.lastDecision.serverSending,t)}),v(IH,{label:`· transcode-down`,value:MH(r.lastDecision.forcedTranscodeDown,t)})]}),r.climbHold?v(IH,{label:`climb`,value:r.climbHold.summary}):null,v(IH,{label:`promotions`,value:AH(r.upgradeCount)}),r.tierFailures.length>0&&v(IH,{label:t(`uiLibrary.streamDebugOverlay.tierFailures`,`tier failures`),value:r.tierFailures.map(e=>`${e.tier}:${e.failures}`).join(` `)})]}):v(`div`,{className:`text-amber-300 leading-tight py-0.5`,children:t(`uiLibrary.streamDebugOverlay.sessionNotFound`,`session not found on the server — it ended, or this node never had it`)}):v(`div`,{className:`text-rose-300 leading-tight py-0.5 break-words`,children:i}):v(`div`,{className:`text-amber-300/90 leading-tight py-0.5`,children:v(gi,{uiKey:`uiLibrary.streamDebugOverlay.notWired`,fallback:`not wired on this surface — this player was mounted without <0>getSessionDebug</0>, so the server half cannot be asked`,components:[v(`span`,{className:`text-white/80`},`fn`)]})}),s!==null&&v(`div`,{className:`mt-1 pt-0.5 border-t border-white/15 text-white/40 break-all leading-tight`,children:s})]}):c(`button`,{type:`button`,onClick:()=>f(!0),className:`absolute bottom-10 left-2 z-20 transform-gpu flex items-center gap-1.5 rounded bg-neutral-950/90 ring-1 ring-white/20 px-1.5 py-0.5 text-[9px] font-mono text-white/85 tabular-nums select-text`,"data-testid":`stream-debug-pill`,title:l.label,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${RH[l.kind]}`}),v(`span`,{children:n?.width!==null&&n?.width!==void 0?`${n.width}×${n.height}`:kH}),c(`span`,{children:[AH(n?.fps),`fps`]}),c(`span`,{children:[AH(u?.kbps),`k`]}),p&&v(`span`,{className:`text-amber-300`,children:t(`uiLibrary.streamDebugOverlay.stale`,`stale`)})]})}E();function BH(e,t){e.muted=t;let n=e.srcObject;if(n instanceof MediaStream)for(let e of n.getAudioTracks())e.enabled=!t}function VH(){return typeof window>`u`?!1:window.matchMedia(`(hover: none) and (pointer: coarse)`).matches||typeof navigator<`u`&&navigator.maxTouchPoints>0||`ontouchstart`in window}function HH(e,t,n){let r=0;for(let i=0;i<8;i++)for(let a=0;a<8;a++){let o=Math.min(t-1,Math.floor((a+.5)/8*t)),s=Math.min(n-1,Math.floor((i+.5)/8*n)),{data:c}=e.getImageData(o,s,1,1);.2126*(c[0]??0)+.7152*(c[1]??0)+.0722*(c[2]??0)>12&&r++}return r<=1}function UH(e){let t={};if(typeof window<`u`){let n=window.devicePixelRatio||1;if(e){let r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t.viewportWidth=Math.round(r.width*n),t.viewportHeight=Math.round(r.height*n))}t.viewportWidth===void 0&&(t.viewportWidth=Math.round(window.innerWidth*n),t.viewportHeight=Math.round(window.innerHeight*n)),t.devicePixelRatio=n}return t}var WH=aH({now:()=>Date.now(),ttlMs:3e4});function GH(e){return QV(e,typeof window<`u`?un():void 0)}function KH(e,t,n){let r=GH(e);return r===null?Promise.resolve(void 0):WH.measured(r,()=>nH(r,{onRefused:e=>{WH.firstRefusal(r,e)&&n(r,e)},fetchImpl:(e,n)=>fetch(e,{...n,...t===null?{}:{headers:{authorization:`Bearer ${t}`}}}),now:()=>Date.now()}))}function qH(e){let t=GH(e);return t===null?void 0:WH.cached(t)}function JH(e){let t=GH(e);return t===null?null:WH.latest(t)}function YH(e){return iH({waitFrame:()=>rH({readyState:()=>{let t=e.video();return t!==null&&t.srcObject===e.stream?t.readyState:null},signal:e.signal,sleep:e=>new Promise(t=>setTimeout(t,e)),now:()=>Date.now()}),measure:()=>KH(e.serverUrl,e.authToken,e.onRefused)})}function XH(e,t,n,r){let i={...e,...n===void 0?{}:{downlinkMbps:n},...t};return r?YV(i):i}var ZH=8e3;function QH({serverUrl:e,streamKey:t,label:n,autoPlay:r=!0,muted:i=!0,showControls:a=!0,showStats:o=!1,onDebugStats:s,onPlaybackStats:l,onClientNetworkSample:u,probeAuthToken:d,onConnectTiming:p,className:m=``,onStateChange:h,onError:g,onReconnectAttempt:y,overlay:x,createSession:S,sendAnswer:w,handleOffer:T,getIceServers:E,addIceCandidate:D,getIceCandidates:O,closeSession:k,getSessionState:A,getSessionDebug:j,applyDownlinkProbe:M,reoffer:N,posterUrl:P,hintsOverride:F,onAdaptiveHints:I,reconnectSignal:L,onControlChannel:R,onVideoElement:z,iceTransportPolicy:B,onPeerConnection:V}){let H=q(),U=f(null),ee=f(null),W=f(null),G=f(new Set),te=f(null),ne=f(null),re=f(0),K=f(!0),ie=f(R);ie.current=R;let ae=f(B);ae.current=B;let oe=f(V);oe.current=V;let se=f(z);se.current=z,b(()=>(se.current?.(U.current),()=>se.current?.(null)),[]);let ce=f(I);ce.current=I;let le=f(null),ue=_((e,t,n)=>{let r=ce.current;if(!r)return;let i={phase:e,probeOrigin:n,...t},a=$V(i);a!==le.current&&(le.current=a,r(i))},[]),de=f(M);de.current=M;let fe=_(async(t,n,r)=>{let i=await oH(de.current,t,n);if(!K.current)return;if(i.kind===`unsupported`){r();return}let{outcome:a,tier:o,reason:s}=i.answer;ce.current?.({phase:`probe-in-session`,probeOrigin:GH(e),downlinkMbps:n,probeAnswer:`${a}:${o??`-`}:${s}`})},[e]),pe=_((e,t)=>{ce.current?.({phase:`probe-refused`,probeOrigin:e,probeStatus:t})},[]),me=f(null),he=f(null),ge=f(0),_e=f(!1),ve=f(!1),ye=f(async()=>{}),[be,xe]=C(`idle`),[Se,Ce]=C(``),[we,Te]=C(i),Ee=f(we);Ee.current=we;let[De,Oe]=C(!1),[ke,Ae]=C(!1),je=VH(),[Me,Ne]=C(!0),Pe=f(null),Fe=f(!1);(w||S)&&(Fe.current=!0);let Ie=Fe.current,Le=f(!1);T&&(Le.current=!0);let Re=Le.current,[ze,Be]=C(!1),Ve=f(null),[He,Ue]=C(null),[We,Ge]=C(!1),Ke=_(()=>{let e=U.current;if(!(!e||e.readyState<2||!e.videoWidth||!e.videoHeight))try{let t=document.createElement(`canvas`);t.width=e.videoWidth,t.height=e.videoHeight;let n=t.getContext(`2d`);if(!n||(n.drawImage(e,0,0),HH(n,t.width,t.height)))return;Ve.current=t.toDataURL(`image/jpeg`,.6)}catch{}},[]),qe=_(e=>{xe(e),e===`playing`&&Be(!0),h?.(e)},[h]),Je=_(()=>{if(te.current?.abort(),te.current=null,ne.current&&=(clearTimeout(ne.current),null),he.current&&=(clearTimeout(he.current),null),me.current=null,ve.current=!1,ge.current=0,W.current&&=(W.current.close(),null),k&&G.current.size>0){for(let e of G.current)k(e).catch(()=>{});G.current.clear()}},[k]),Ye=_(()=>{te.current?.abort(),te.current=null,ne.current&&=(clearTimeout(ne.current),null),he.current&&=(clearTimeout(he.current),null),me.current=null,ve.current=!1,ge.current=0},[]),Xe=1e3,Ze=_(e=>{if(!A||!N)return;he.current&&=(clearTimeout(he.current),null);let t=async()=>{if(K.current&&me.current===e){if(!ve.current)try{let{pendingRenegotiation:t}=await A(e);if(K.current&&me.current===e&&t&&t.epoch>ge.current&&!ve.current){ge.current=t.epoch,await ye.current(e,t.target);return}}catch{}!K.current||me.current!==e||(he.current=setTimeout(()=>{t()},Xe))}};he.current=setTimeout(()=>{t()},Xe)},[A,N]),Qe=_(async(t=!1,n=t,r)=>{if(!K.current||!S||!w)return;let i=t?W.current:null,a=t?new Set(G.current):null;t?Ye():Je(),qe(`connecting`);let o=new AbortController;te.current=o;try{let s=XH(UH(ee.current),F,n?r??await KH(e,d??null,pe):void 0,!n);ue(n?`probe-climb`:`cold-start`,s,GH(e));let{sessionId:c,sdpOffer:l,iceServers:u}=await S(s);if(G.current.add(c),!K.current||o.signal.aborted){k?.(c).catch(()=>{}),G.current.delete(c);return}let f=new RTCPeerConnection(uH(u,ae.current));oe.current?.(f),t||(W.current=f);let p=new MediaStream;n||YH({video:()=>U.current,stream:p,signal:o.signal,serverUrl:e,authToken:d??null,onRefused:pe}).then(e=>{e===void 0||!XV(e)||!K.current||o.signal.aborted||_e.current||(_e.current=!0,fe(c,e,()=>{!K.current||o.signal.aborted||Qe(!0,!0,e)}))});let m=!1,h=()=>{if(!(m||!K.current)){if(m=!0,W.current=f,U.current&&(U.current.srcObject=p,BH(U.current,Ee.current),U.current.play().catch(()=>{})),i&&i!==f)try{i.close()}catch{}if(a)for(let e of a)G.current.delete(e),k?.(e).catch(()=>{})}};f.ontrack=e=>{if(console.debug(`[WebRTC] ontrack`,e.track.kind,e.track.readyState),p.addTrack(e.track),t){h();return}U.current&&(U.current.srcObject=p,BH(U.current,Ee.current),U.current.play().catch(()=>{}))},f.oniceconnectionstatechange=()=>{if(!K.current)return;let e=f.iceConnectionState;if(console.debug(`[WebRTC] ICE state:`,e),e===`connected`||e===`completed`)re.current=0,t&&h(),qe(`playing`),U.current?.paused&&(console.debug(`[WebRTC] video was paused at ICE connected — calling play()`),U.current.play().catch(()=>{}));else if(e===`failed`||e===`disconnected`||e===`closed`){if(t&&!m)try{f.close()}catch{}qe(`disconnected`),at()}},f.onicecandidateerror=e=>{console.debug(`[WebRTC] ICE candidate error:`,e)},console.debug(`[WebRTC] Setting remote description (server offer)...`),await f.setRemoteDescription({type:`offer`,sdp:l});let g=await f.createAnswer();if(await f.setLocalDescription(g),console.debug(`[WebRTC] Local description set, waiting for ICE gathering...`),await eU(f),!K.current)return;let _=(f.localDescription?.sdp??``).split(`
|
|
2
|
+
import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t,i as n,o as r,r as i}from"./virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dyo8T61H.js";import{t as a}from"./vite-preload-helper-kNaey6uv.js";import{$ as o,A as s,C as c,E as l,G as u,H as d,J as f,K as p,N as m,O as h,Q as g,R as _,S as v,U as y,V as b,W as x,X as S,Y as C,a as w,d as T,et as E,j as D,k as O,o as k,q as A,t as j,u as M,w as N,x as P,y as F,z as I}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{$ as L,$i as R,$n as z,$r as B,$t as V,A as H,Ai as U,An as ee,Ar as W,At as G,B as te,Bi as ne,Bn as re,Br as K,Bt as ie,C as ae,Ci as oe,Cn as se,Cr as ce,Ct as le,D as ue,Di as de,Dn as fe,Dr as pe,Dt as me,E as he,Ei as ge,En as _e,Er as ve,Et as ye,F as be,Fi as xe,Fn as Se,Fr as Ce,Ft as we,G as Te,Gi as Ee,Gn as De,Gr as Oe,Gt as ke,H as Ae,Hi as je,Hn as Me,Hr as Ne,Ht as Pe,I as Fe,Ii as Ie,In as Le,Ir as Re,It as ze,J as Be,Ji as Ve,Jn as He,Jr as Ue,Jt as We,K as Ge,Ki as Ke,Kn as qe,Kr as Je,Kt as Ye,L as Xe,Li as Ze,Ln as Qe,Lr as $e,Lt as et,Mi as tt,Mn as nt,Mr as rt,Mt as it,N as at,Ni as ot,Nn as st,Nr as ct,Nt as lt,O as ut,Oi as dt,On as ft,Or as pt,Ot as mt,P as ht,Pi as gt,Pn as _t,Pr as vt,Pt as yt,Q as bt,Qi as xt,Qn as St,Qr as Ct,Qt as wt,R as Tt,Ri as Et,Rn as Dt,Rr as Ot,Rt as kt,S as At,Si as jt,Sn as Mt,Sr as Nt,St as Pt,T as Ft,Ti as It,Tn as Lt,Tr as eee,Tt as Rt,U as zt,Ui as Bt,Un as Vt,Ur as Ht,Ut as tee,V as Ut,Vi as Wt,Vn as Gt,Vr as Kt,Vt as qt,W as Jt,Wi as Yt,Wn as Xt,Wr as Zt,Wt as Qt,X as $t,Xi as en,Xn as tn,Xr as nn,Xt as rn,Y as an,Yi as on,Yn as sn,Yr as cn,Yt as ln,Z as un,Zi as dn,Zn as fn,Zr as pn,Zt as mn,_ as hn,_i as gn,_n,_r as vn,_t as yn,a as bn,aa as xn,ai as Sn,an as Cn,ar as wn,at as Tn,b as En,bi as Dn,bn as On,br as kn,bt as An,c as jn,ci as Mn,cn as nee,cr as Nn,ct as Pn,d as ree,da as Fn,di as In,dn as Ln,dr as iee,dt as Rn,ea as aee,ei as oee,en as see,er as zn,et as Bn,f as Vn,fa as Hn,fi as Un,fn as Wn,fr as Gn,ft as Kn,g as qn,gi as Jn,gn as Yn,gr as Xn,gt as Zn,h as Qn,hi as $n,hn as er,hr as tr,ht as nr,i as rr,ia as ir,ii as ar,in as or,ir as sr,it as cr,j as lr,ji as ur,jn as dr,jr as fr,jt as pr,k as mr,ki as hr,kn as gr,kr as _r,kt as vr,l as yr,la as br,li as xr,ln as Sr,lr as Cr,lt as wr,m as Tr,mi as Er,mn as Dr,mr as Or,mt as kr,n as Ar,na as jr,ni as Mr,nn as Nr,nr as Pr,nt as Fr,o as Ir,oa as Lr,oi as Rr,on as zr,or as Br,ot as Vr,p as Hr,pa as q,pi as Ur,pn as Wr,pr as Gr,pt as Kr,q as qr,qi as Jr,qn as Yr,qr as Xr,qt as Zr,r as Qr,ra as $r,ri as ei,rn as ti,rr as ni,rt as ri,s as ii,sa as ai,si as oi,sn as si,sr as ci,st as li,t as ui,ta as di,ti as fi,tn as pi,tr as mi,tt as hi,u as cee,ua as gi,ui as _i,un as vi,ur as yi,ut as bi,v as xi,vi as Si,vn as Ci,vr as wi,vt as Ti,w as lee,wi as Ei,wn as Di,wr as Oi,wt as uee,x as ki,xi as Ai,xn as ji,xr as dee,xt as fee,y as Mi,yi as Ni,yn as Pi,yr as pee,yt as Fi,z as Ii,zi as Li,zn as mee,zr as Ri,zt as zi}from"./player-overlays-B5FSaids.js";import{$ as hee,$a as Bi,Aa as Vi,Ca as gee,Ea as _ee,Fa as vee,Fr as Hi,Ga as yee,Ia as Ui,Jn as Wi,Ka as Gi,La as bee,Na as xee,Nr as Ki,Pa as See,Qa as qi,Ra as Cee,Sa as wee,Sr as Ji,Ta as Yi,Ua as Xi,Va as Tee,Wa as Eee,Wt as Zi,Xa as Dee,Xn as Oee,Xr as kee,Zr as Aee,_ as Qi,_a as $i,_n as ea,ai as ta,an as na,ao as ra,ar as ia,at as aa,b as oa,ba as sa,bi as ca,bn as la,ci as ua,co as da,cr as fa,da as J,dr as pa,ei as ma,eo as ha,et as ga,f as _a,g as va,ga as ya,gn as ba,h as xa,ha as Sa,ii as Ca,in as wa,ir as Ta,it as Ea,ja as Da,la as Oa,m as ka,ma as Aa,ni as ja,nn as Ma,no as Na,nt as Pa,o as Fa,oa as Ia,oi as La,ot as Ra,p as za,qn as Ba,r as Va,ri as Ha,rt as Ua,si as Wa,so as Ga,ti as Ka,tn as qa,to as Ja,u as Ya,ua as Y,ur as Xa,v as Za,va as Qa,vn as $a,vr as eo,wa as to,x as no,xa as ro,xn as io,y as ao,ya as oo,zr as so}from"./client-JLEP7nv7.js";import{D as co,M as lo,O as uo,S as fo,T as po,j as mo,p as ho,v as go,y as _o}from"./__vite-browser-external-BlMfPwfH.js";import{T as vo,b as yo,g as bo,k as xo,o as So,x as Co}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_client__loadShare__.js-8kv6pj9W.js";import{r as wo,t as To}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DzoL8nR8.js";import{n as Eo,r as Do,t as Oo}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BPba2g2p.js";import{n as ko,t as Ao}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-ZBKFTPET.js";E();var jo=typeof globalThis<`u`?globalThis.__camstackTrpcReact:void 0,X=jo??To();typeof globalThis<`u`&&!jo&&(globalThis.__camstackTrpcReact=X);function Mo(e,t){let n=Rn(),r=f(t);r.current=t;let[i,a]=C(n.connectionVersion);b(()=>n.subscribeConnectionEvents((e,t)=>{e===`connected`&&a(t)}),[n]),b(()=>n.subscribeEvent(e,e=>{r.current(e)}),[n,e,i])}E();function No(e){let t=f(e);return t.current=e,t}function Po(e,t){let[n,r]=C(null),i=No(t);return Mo(e,e=>{let t=e.data,n=i.current;n&&!n(t)||r(t)}),n}function Fo(e,t,n){let[r,i]=C(()=>new Map),a=No(t),o=No(n);return Mo(e,e=>{let t=e.data,n=o.current;if(n&&!n(t))return;let r=a.current(t);i(e=>{let n=new Map(e);return n.set(r,t),n})}),{map:r,values:p(()=>Array.from(r.values()),[r])}}E();function Io(){let{data:e,isLoading:t,isError:n}=X.nodes.topology.useQuery(void 0,{staleTime:1/0});return{nodes:Po(`cluster.topology-snapshot`)?.nodes??e,isLoading:t,isError:n}}function Lo(){let{nodes:e,isLoading:t,isError:n}=Io();return{nodes:p(()=>{let t=[];for(let n of e??[])t.push({id:String(n.id??``),name:String(n.name??n.id??``),shortName:n.isHub?`HUB`:String(n.name??n.id??``),isHub:!!n.isHub,isOnline:!!n.isOnline,localIps:n.localIps??[],addons:(n.addons??[]).map(e=>({addonId:e.id,capabilities:e.capabilities}))});return t.sort((e,t)=>e.isHub===t.isHub?e.name.localeCompare(t.name):e.isHub?-1:1),t},[e]),isLoading:t,isError:n}}function Ro(e,t){return{icon:e.icon,label:t(e.labelKey,e.labelFallback)}}var zo={[J.Camera]:{icon:ot,labelKey:`uiLibrary.deviceMeta.type.camera`,labelFallback:`Camera`},[J.Hub]:{icon:De,labelKey:`uiLibrary.deviceMeta.type.hub`,labelFallback:`Hub`},[J.Light]:{icon:Xn,labelKey:`uiLibrary.deviceMeta.type.light`,labelFallback:`Light`},[J.Siren]:{icon:Sr,labelKey:`uiLibrary.deviceMeta.type.siren`,labelFallback:`Siren`},[J.Switch]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.type.switch`,labelFallback:`Switch`},[J.Sensor]:{icon:ai,labelKey:`uiLibrary.deviceMeta.type.sensor`,labelFallback:`Sensor`},[J.Thermostat]:{icon:We,labelKey:`uiLibrary.deviceMeta.type.thermostat`,labelFallback:`Thermostat`},[J.Climate]:{icon:Lr,labelKey:`uiLibrary.deviceMeta.type.climate`,labelFallback:`Air conditioner`},[J.Button]:{icon:Si,labelKey:`uiLibrary.deviceMeta.type.button`,labelFallback:`Button`},[J.EventEmitter]:{icon:nr,labelKey:`uiLibrary.deviceMeta.type.eventEmitter`,labelFallback:`Event Emitter`},[J.Update]:{icon:_e,labelKey:`uiLibrary.deviceMeta.type.update`,labelFallback:`Update`},[J.Generic]:{icon:Ze,labelKey:`uiLibrary.deviceMeta.type.generic`,labelFallback:`Generic`},[J.Notifier]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.type.notifier`,labelFallback:`Notifier`},[J.Script]:{icon:Pi,labelKey:`uiLibrary.deviceMeta.type.script`,labelFallback:`Script`},[J.Automation]:{icon:Ti,labelKey:`uiLibrary.deviceMeta.type.automation`,labelFallback:`Automation`},[J.Lock]:{icon:Cr,labelKey:`uiLibrary.deviceMeta.type.lock`,labelFallback:`Lock`},[J.Cover]:{icon:ne,labelKey:`uiLibrary.deviceMeta.type.cover`,labelFallback:`Cover`},[J.Valve]:{icon:Dt,labelKey:`uiLibrary.deviceMeta.type.valve`,labelFallback:`Valve`},[J.Humidifier]:{icon:Rt,labelKey:`uiLibrary.deviceMeta.type.humidifier`,labelFallback:`Humidifier`},[J.WaterHeater]:{icon:en,labelKey:`uiLibrary.deviceMeta.type.waterHeater`,labelFallback:`Water heater`},[J.Fan]:{icon:Ht,labelKey:`uiLibrary.deviceMeta.type.fan`,labelFallback:`Fan`},[J.MediaPlayer]:{icon:z,labelKey:`uiLibrary.deviceMeta.type.mediaPlayer`,labelFallback:`Media player`},[J.AlarmPanel]:{icon:Dr,labelKey:`uiLibrary.deviceMeta.type.alarmPanel`,labelFallback:`Alarm panel`},[J.Control]:{icon:zr,labelKey:`uiLibrary.deviceMeta.type.control`,labelFallback:`Control`},[J.Presence]:{icon:ci,labelKey:`uiLibrary.deviceMeta.type.presence`,labelFallback:`Presence`},[J.Weather]:{icon:Rr,labelKey:`uiLibrary.deviceMeta.type.weather`,labelFallback:`Weather`},[J.Vacuum]:{icon:Et,labelKey:`uiLibrary.deviceMeta.type.vacuum`,labelFallback:`Vacuum`},[J.LawnMower]:{icon:Qt,labelKey:`uiLibrary.deviceMeta.type.lawnMower`,labelFallback:`Lawn mower`},[J.Container]:{icon:Ze,labelKey:`uiLibrary.deviceMeta.type.container`,labelFallback:`Container`},[J.Image]:{icon:Nt,labelKey:`uiLibrary.deviceMeta.type.image`,labelFallback:`Image`},[J.PetFeeder]:{icon:Li,labelKey:`uiLibrary.deviceMeta.type.petFeeder`,labelFallback:`Pet feeder`},[J.Dishwasher]:{icon:Rt,labelKey:`uiLibrary.deviceMeta.type.dishwasher`,labelFallback:`Dishwasher`},[J.Washer]:{icon:ye,labelKey:`uiLibrary.deviceMeta.type.washer`,labelFallback:`Washing machine`},[J.Dryer]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.type.dryer`,labelFallback:`Dryer`}},Bo={[Y.Siren]:{icon:Sr,labelKey:`uiLibrary.deviceMeta.role.siren`,labelFallback:`Siren`},[Y.Floodlight]:{icon:Xn,labelKey:`uiLibrary.deviceMeta.role.floodlight`,labelFallback:`Floodlight`},[Y.Spotlight]:{icon:Ot,labelKey:`uiLibrary.deviceMeta.role.spotlight`,labelFallback:`Spotlight`},[Y.PirSensor]:{icon:gr,labelKey:`uiLibrary.deviceMeta.role.pirSensor`,labelFallback:`PIR sensor`},[Y.Chime]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.role.chime`,labelFallback:`Chime`},[Y.Autotrack]:{icon:fi,labelKey:`uiLibrary.deviceMeta.role.autotrack`,labelFallback:`Auto-track`},[Y.Nightvision]:{icon:St,labelKey:`uiLibrary.deviceMeta.role.nightvision`,labelFallback:`Night vision`},[Y.PrivacyMask]:{icon:Oe,labelKey:`uiLibrary.deviceMeta.role.privacyMask`,labelFallback:`Privacy mask`},[Y.Doorbell]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.doorbell`,labelFallback:`Doorbell`},[Y.CoverBlind]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverBlind`,labelFallback:`Blind`},[Y.CoverShutter]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverShutter`,labelFallback:`Shutter`},[Y.CoverAwning]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverAwning`,labelFallback:`Awning`},[Y.CoverCurtain]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverCurtain`,labelFallback:`Curtain`},[Y.CoverGarage]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.coverGarage`,labelFallback:`Garage door`},[Y.CoverGate]:{icon:Ct,labelKey:`uiLibrary.deviceMeta.role.coverGate`,labelFallback:`Gate`},[Y.CoverDoor]:{icon:pn,labelKey:`uiLibrary.deviceMeta.role.coverDoor`,labelFallback:`Door`},[Y.CoverWindow]:{icon:ne,labelKey:`uiLibrary.deviceMeta.role.coverWindow`,labelFallback:`Window`},[Y.BinaryHelper]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.role.binaryHelper`,labelFallback:`Binary helper`},[Y.Outlet]:{icon:_t,labelKey:`uiLibrary.deviceMeta.role.outlet`,labelFallback:`Outlet`},[Y.MotionSensor]:{icon:$e,labelKey:`uiLibrary.deviceMeta.role.motionSensor`,labelFallback:`Motion sensor`},[Y.ContactSensor]:{icon:pn,labelKey:`uiLibrary.deviceMeta.role.contactSensor`,labelFallback:`Contact sensor`},[Y.LeakSensor]:{icon:cn,labelKey:`uiLibrary.deviceMeta.role.leakSensor`,labelFallback:`Leak sensor`},[Y.SmokeSensor]:{icon:xn,labelKey:`uiLibrary.deviceMeta.role.smokeSensor`,labelFallback:`Smoke sensor`},[Y.COSensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.cOSensor`,labelFallback:`CO sensor`},[Y.GasSensor]:{icon:K,labelKey:`uiLibrary.deviceMeta.role.gasSensor`,labelFallback:`Gas sensor`},[Y.TamperSensor]:{icon:Dr,labelKey:`uiLibrary.deviceMeta.role.tamperSensor`,labelFallback:`Tamper sensor`},[Y.VibrationSensor]:{icon:vr,labelKey:`uiLibrary.deviceMeta.role.vibrationSensor`,labelFallback:`Vibration sensor`},[Y.ConnectivitySensor]:{icon:An,labelKey:`uiLibrary.deviceMeta.role.connectivitySensor`,labelFallback:`Connectivity`},[Y.SoundSensor]:{icon:mt,labelKey:`uiLibrary.deviceMeta.role.soundSensor`,labelFallback:`Sound sensor`},[Y.BinarySensor]:{icon:Ye,labelKey:`uiLibrary.deviceMeta.role.binarySensor`,labelFallback:`Binary sensor`},[Y.TemperatureSensor]:{icon:We,labelKey:`uiLibrary.deviceMeta.role.temperatureSensor`,labelFallback:`Temperature`},[Y.HumiditySensor]:{icon:Ue,labelKey:`uiLibrary.deviceMeta.role.humiditySensor`,labelFallback:`Humidity`},[Y.AmbientLightSensor]:{icon:wt,labelKey:`uiLibrary.deviceMeta.role.ambientLightSensor`,labelFallback:`Ambient light`},[Y.PressureSensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.pressureSensor`,labelFallback:`Pressure`},[Y.WindSensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.windSensor`,labelFallback:`Wind`},[Y.RainSensor]:{icon:Mn,labelKey:`uiLibrary.deviceMeta.role.rainSensor`,labelFallback:`Rain`},[Y.UvSensor]:{icon:V,labelKey:`uiLibrary.deviceMeta.role.uvSensor`,labelFallback:`UV index`},[Y.SolarRadiationSensor]:{icon:mn,labelKey:`uiLibrary.deviceMeta.role.solarRadiationSensor`,labelFallback:`Solar radiation`},[Y.SoilMoistureSensor]:{icon:Nr,labelKey:`uiLibrary.deviceMeta.role.soilMoistureSensor`,labelFallback:`Soil moisture`},[Y.PowerSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.powerSensor`,labelFallback:`Power`},[Y.EnergySensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.energySensor`,labelFallback:`Energy`},[Y.VoltageSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.voltageSensor`,labelFallback:`Voltage`},[Y.CurrentSensor]:{icon:nr,labelKey:`uiLibrary.deviceMeta.role.currentSensor`,labelFallback:`Current`},[Y.AirQualitySensor]:{icon:Fi,labelKey:`uiLibrary.deviceMeta.role.airQualitySensor`,labelFallback:`Air quality`},[Y.BatterySensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.batterySensor`,labelFallback:`Battery`},[Y.NumericSensor]:{icon:pe,labelKey:`uiLibrary.deviceMeta.role.numericSensor`,labelFallback:`Numeric sensor`},[Y.EnumSensor]:{icon:Gr,labelKey:`uiLibrary.deviceMeta.role.enumSensor`,labelFallback:`Enum sensor`},[Y.DateTimeSensor]:{icon:In,labelKey:`uiLibrary.deviceMeta.role.dateTimeSensor`,labelFallback:`Date / time`},[Y.GenericSensor]:{icon:vt,labelKey:`uiLibrary.deviceMeta.role.genericSensor`,labelFallback:`Sensor`},[Y.NumericControl]:{icon:zr,labelKey:`uiLibrary.deviceMeta.role.numericControl`,labelFallback:`Numeric control`},[Y.SelectControl]:{icon:Or,labelKey:`uiLibrary.deviceMeta.role.selectControl`,labelFallback:`Select control`},[Y.TextControl]:{icon:et,labelKey:`uiLibrary.deviceMeta.role.textControl`,labelFallback:`Text control`},[Y.DateTimeControl]:{icon:In,labelKey:`uiLibrary.deviceMeta.role.dateTimeControl`,labelFallback:`Date / time control`},[Y.MobilePushNotifier]:{icon:Cn,labelKey:`uiLibrary.deviceMeta.role.mobilePushNotifier`,labelFallback:`Mobile push`},[Y.MessagingNotifier]:{icon:ni,labelKey:`uiLibrary.deviceMeta.role.messagingNotifier`,labelFallback:`Messaging`},[Y.EmailNotifier]:{icon:Nn,labelKey:`uiLibrary.deviceMeta.role.emailNotifier`,labelFallback:`Email`},[Y.GenericNotifier]:{icon:Bt,labelKey:`uiLibrary.deviceMeta.role.genericNotifier`,labelFallback:`Notifier`},[Y.IrTransmitter]:{icon:ft,labelKey:`uiLibrary.deviceMeta.role.irTransmitter`,labelFallback:`IR/RF transmitter`}},Vo=new Set(Object.values(J)),Ho=new Set(Object.values(Y));function Uo(e){return Vo.has(e)}function Wo(e){return Ho.has(e)}function Go(e,t=Fn){return Ro(zo[e],t)}function Ko(e,t=Fn){return Ro(Bo[e],t)}var qo=zo[J.Generic],Jo=Bo[Y.GenericSensor];function Yo(e,t=Fn){return Uo(e)?Ro(zo[e]??qo,t):Ro(qo,t)}function Xo(e,t=Fn){return Wo(e)?Ro(Bo[e]??Jo,t):Ro(Jo,t)}var Zo={camera:ot,network:De,"toggle-left":Ye,"circle-dot":Si,"refresh-cw":_e,box:Ze,"scroll-text":Pi,workflow:Ti,lock:Cr,blinds:ne,"air-vent":Lr,"monitor-play":z,"sliders-horizontal":zr,"map-pin":ci,bot:Et,tractor:Qt,image:Nt,bone:Li,"door-closed":Ct,"door-open":pn,crosshair:fi,"eye-off":Oe,smartphone:Cn,power:nt,battery:Ee,lightbulb:Xn,flashlight:Ot,thermometer:We,droplets:Ue,droplet:cn,gauge:vt,sun:wt,"sun-medium":V,sunrise:mn,moon:St,wind:Fi,"cloud-rain":Mn,"cloud-sun":Rr,waves:Rt,sprout:Nr,zap:nr,flame:K,bell:Bt,siren:Sr,radar:gr,activity:ai,hash:pe,clock:In,pipette:Dt,fan:Ht,bath:en,footprints:$e,"alarm-smoke":xn,"shield-alert":Dr,vibrate:vr,wifi:An,"volume-2":mt,list:Gr,"list-checks":Or,mail:Nn,"message-square":ni,type:et};function Qo(e){return Object.values(J).map(t=>{let n=Yo(t,e);return{id:t,label:n.label,icon:n.icon}})}var $o=Qo(Fn);function es(e=Fn){return e===Fn?$o:Qo(e)}E();var ts,ns,rs,is=0,as=new Set;function os(){is+=1;for(let e of as)e()}function ss(e){return e.split(`-`).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(``)}function cs(){return ts===void 0?rs===void 0?(ns??=a(()=>import(`./icons-BJz9Yj7E.js`).then(e=>{ts=e,os()},e=>{throw rs=e,os(),e}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37]),import.meta.url),ns):Promise.reject(rs):Promise.resolve()}function ls(){return rs!==void 0}function us(){return ts!==void 0}function ds(e){let t=Ka(e);if(t===void 0)return;let n=Zo[t];if(n!==void 0)return n;if(ts!==void 0)return ts[ss(t)];rs===void 0&&cs().catch(()=>void 0)}function fs(e){return as.add(e),()=>{as.delete(e)}}var ps=()=>is;function ms(){return S(fs,ps,ps)}function hs(){return p(()=>e=>ds(e),[ms()])}function gs(e){let t=e.split(`+`),n=t[t.length-1]??``,r=t.slice(0,-1);return{mod:r.includes(`mod`),shift:r.includes(`shift`),alt:r.includes(`alt`),key:n}}function _s(){return typeof navigator>`u`?`other`:/mac|iphone|ipad/i.test(navigator.platform)?`mac`:`other`}function vs(e,t,n){let r=gs(t),i=n===`mac`?e.metaKey:e.ctrlKey,a=n===`mac`?e.ctrlKey:e.metaKey;return e.key.toLowerCase()===r.key&&i===r.mod&&!a&&e.shiftKey===r.shift&&e.altKey===r.alt}E();var ys=`page`,bs=`fallback`,xs=O(null),Ss=O(ys);function Cs(e){return e instanceof HTMLElement?e.isContentEditable?!0:e.tagName===`INPUT`||e.tagName===`TEXTAREA`||e.tagName===`SELECT`:!1}function ws(e,t,n){if(t.isComposing||t.keyCode===229)return;let r=Cs(t.target),i=[...[...e.scopes].reverse().map(e=>e.id),ys,bs];for(let a of i){let i=e.bindings.filter(e=>e.scope===a&&vs(t,e.combo,n)).reverse();for(let e of i)if(!(r&&!e.allowInInput)&&e.handlerRef.current(t)!==!1){e.preventDefault&&t.preventDefault();return}if(e.scopes.find(e=>e.id===a)?.modal)return}}function Ts({children:e,platform:t}){let n=f({bindings:[],scopes:[]}),r=t??_s(),i=p(()=>({addBinding:e=>(n.current={...n.current,bindings:[...n.current.bindings,e]},()=>{n.current={...n.current,bindings:n.current.bindings.filter(t=>t.id!==e.id)}}),addScope:e=>(n.current={...n.current,scopes:[...n.current.scopes,e]},()=>{n.current={...n.current,scopes:n.current.scopes.filter(t=>t!==e)}})}),[]);return b(()=>{let e=e=>ws(n.current,e,r);return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[r]),v(xs.Provider,{value:i,children:e})}var Es=0;function Ds(e,t,n={}){let r=I(xs),i=I(Ss),a=f(t);a.current=t;let o=n.scope??i,s=n.enabled??!0,c=n.preventDefault??!0,l=n.allowInInput??gs(e).mod;b(()=>{if(!(!r||!s))return Es+=1,r.addBinding({id:Es,combo:e,scope:o,handlerRef:a,preventDefault:c,allowInInput:l})},[r,s,e,o,c,l])}function Os({id:e,children:t,enabled:n=!0,modal:r=!1}){let i=I(xs);return b(()=>{if(!(!i||!n))return i.addScope({id:e,modal:r})},[i,n,e,r]),v(Ss.Provider,{value:e,children:t})}function ks(e){return e.isConnected&&!e.disabled&&e.getClientRects().length>0}function As(e,t={}){let n=t.enabled??!0,r=t.scope,i=()=>{let t=e.current;return!t||!ks(t)?!1:(t.focus(),t.select(),!0)};Ds(`mod+f`,i,{enabled:n,scope:r}),Ds(`mod+k`,i,{enabled:n,scope:r})}Do();function js(e){var t,n,r=``;if(typeof e==`string`||typeof e==`number`)r+=e;else if(typeof e==`object`)if(Array.isArray(e)){var i=e.length;for(t=0;t<i;t++)e[t]&&(n=js(e[t]))&&(r&&(r+=` `),r+=n)}else for(n in e)e[n]&&(r&&(r+=` `),r+=n);return r}function Ms(){for(var e,t,n=0,r=``,i=arguments.length;n<i;n++)(e=arguments[n])&&(t=js(e))&&(r&&(r+=` `),r+=t);return r}var Ns=(e,t)=>{let n=Array(e.length+t.length);for(let t=0;t<e.length;t++)n[t]=e[t];for(let r=0;r<t.length;r++)n[e.length+r]=t[r];return n},Ps=(e,t)=>({classGroupId:e,validator:t}),Fs=(e=new Map,t=null,n)=>({nextPart:e,validators:t,classGroupId:n}),Is=`-`,Ls=[],Rs=`arbitrary..`,zs=e=>{let t=Hs(e),{conflictingClassGroups:n,conflictingClassGroupModifiers:r}=e;return{getClassGroupId:e=>{if(e.startsWith(`[`)&&e.endsWith(`]`))return Vs(e);let n=e.split(Is);return Bs(n,+(n[0]===``&&n.length>1),t)},getConflictingClassGroupIds:(e,t)=>{if(t){let t=r[e],i=n[e];return t?i?Ns(i,t):t:i||Ls}return n[e]||Ls}}},Bs=(e,t,n)=>{if(e.length-t===0)return n.classGroupId;let r=e[t],i=n.nextPart.get(r);if(i){let n=Bs(e,t+1,i);if(n)return n}let a=n.validators;if(a===null)return;let o=t===0?e.join(Is):e.slice(t).join(Is),s=a.length;for(let e=0;e<s;e++){let t=a[e];if(t.validator(o))return t.classGroupId}},Vs=e=>e.slice(1,-1).indexOf(`:`)===-1?void 0:(()=>{let t=e.slice(1,-1),n=t.indexOf(`:`),r=t.slice(0,n);return r?Rs+r:void 0})(),Hs=e=>{let{theme:t,classGroups:n}=e;return Us(n,t)},Us=(e,t)=>{let n=Fs();for(let r in e){let i=e[r];Ws(i,n,r,t)}return n},Ws=(e,t,n,r)=>{let i=e.length;for(let a=0;a<i;a++){let i=e[a];Gs(i,t,n,r)}},Gs=(e,t,n,r)=>{if(typeof e==`string`){Ks(e,t,n);return}if(typeof e==`function`){qs(e,t,n,r);return}Js(e,t,n,r)},Ks=(e,t,n)=>{let r=e===``?t:Ys(t,e);r.classGroupId=n},qs=(e,t,n,r)=>{if(Xs(e)){Ws(e(r),t,n,r);return}t.validators===null&&(t.validators=[]),t.validators.push(Ps(n,e))},Js=(e,t,n,r)=>{let i=Object.entries(e),a=i.length;for(let e=0;e<a;e++){let[a,o]=i[e];Ws(o,Ys(t,a),n,r)}},Ys=(e,t)=>{let n=e,r=t.split(Is),i=r.length;for(let e=0;e<i;e++){let t=r[e],i=n.nextPart.get(t);i||(i=Fs(),n.nextPart.set(t,i)),n=i}return n},Xs=e=>`isThemeGetter`in e&&e.isThemeGetter===!0,Zs=e=>{if(e<1)return{get:()=>void 0,set:()=>{}};let t=0,n=Object.create(null),r=Object.create(null),i=(i,a)=>{n[i]=a,t++,t>e&&(t=0,r=n,n=Object.create(null))};return{get(e){let t=n[e];if(t!==void 0)return t;if((t=r[e])!==void 0)return i(e,t),t},set(e,t){e in n?n[e]=t:i(e,t)}}},Qs=`!`,$s=`:`,ec=[],tc=(e,t,n,r,i)=>({modifiers:e,hasImportantModifier:t,baseClassName:n,maybePostfixModifierPosition:r,isExternal:i}),nc=e=>{let{prefix:t,experimentalParseClassName:n}=e,r=e=>{let t=[],n=0,r=0,i=0,a,o=e.length;for(let s=0;s<o;s++){let o=e[s];if(n===0&&r===0){if(o===$s){t.push(e.slice(i,s)),i=s+1;continue}if(o===`/`){a=s;continue}}o===`[`?n++:o===`]`?n--:o===`(`?r++:o===`)`&&r--}let s=t.length===0?e:e.slice(i),c=s,l=!1;s.endsWith(Qs)?(c=s.slice(0,-1),l=!0):s.startsWith(Qs)&&(c=s.slice(1),l=!0);let u=a&&a>i?a-i:void 0;return tc(t,l,c,u)};if(t){let e=t+$s,n=r;r=t=>t.startsWith(e)?n(t.slice(e.length)):tc(ec,!1,t,void 0,!0)}if(n){let e=r;r=t=>n({className:t,parseClassName:e})}return r},rc=e=>{let t=new Map;return e.orderSensitiveModifiers.forEach((e,n)=>{t.set(e,1e6+n)}),e=>{let n=[],r=[];for(let i=0;i<e.length;i++){let a=e[i],o=a[0]===`[`,s=t.has(a);o||s?(r.length>0&&(r.sort(),n.push(...r),r=[]),n.push(a)):r.push(a)}return r.length>0&&(r.sort(),n.push(...r)),n}},ic=e=>({cache:Zs(e.cacheSize),parseClassName:nc(e),sortModifiers:rc(e),postfixLookupClassGroupIds:ac(e),...zs(e)}),ac=e=>{let t=Object.create(null),n=e.postfixLookupClassGroups;if(n)for(let e=0;e<n.length;e++)t[n[e]]=!0;return t},oc=/\s+/,sc=(e,t)=>{let{parseClassName:n,getClassGroupId:r,getConflictingClassGroupIds:i,sortModifiers:a,postfixLookupClassGroupIds:o}=t,s=[],c=e.trim().split(oc),l=``;for(let e=c.length-1;e>=0;--e){let t=c[e],{isExternal:u,modifiers:d,hasImportantModifier:f,baseClassName:p,maybePostfixModifierPosition:m}=n(t);if(u){l=t+(l.length>0?` `+l:l);continue}let h=!!m,g;if(h){g=r(p.substring(0,m));let e=g&&o[g]?r(p):void 0;e&&e!==g&&(g=e,h=!1)}else g=r(p);if(!g){if(!h){l=t+(l.length>0?` `+l:l);continue}if(g=r(p),!g){l=t+(l.length>0?` `+l:l);continue}h=!1}let _=d.length===0?``:d.length===1?d[0]:a(d).join(`:`),v=f?_+Qs:_,y=v+g;if(s.indexOf(y)>-1)continue;s.push(y);let b=i(g,h);for(let e=0;e<b.length;++e){let t=b[e];s.push(v+t)}l=t+(l.length>0?` `+l:l)}return l},cc=(...e)=>{let t=0,n,r,i=``;for(;t<e.length;)(n=e[t++])&&(r=lc(n))&&(i&&(i+=` `),i+=r);return i},lc=e=>{if(typeof e==`string`)return e;let t,n=``;for(let r=0;r<e.length;r++)e[r]&&(t=lc(e[r]))&&(n&&(n+=` `),n+=t);return n},uc=(e,...t)=>{let n,r,i,a,o=o=>(n=ic(t.reduce((e,t)=>t(e),e())),r=n.cache.get,i=n.cache.set,a=s,s(o)),s=e=>{let t=r(e);if(t)return t;let a=sc(e,n);return i(e,a),a};return a=o,(...e)=>a(cc(...e))},dc=[],fc=e=>{let t=t=>t[e]||dc;return t.isThemeGetter=!0,t},pc=/^\[(?:(\w[\w-]*):)?(.+)\]$/i,mc=/^\((?:(\w[\w-]*):)?(.+)\)$/i,hc=/^\d+(?:\.\d+)?\/\d+(?:\.\d+)?$/,gc=/^(\d+(\.\d+)?)?(xs|sm|md|lg|xl)$/,_c=/\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$/,vc=/^(rgba?|hsla?|hwb|(ok)?(lab|lch)|color-mix)\(.+\)$/,yc=/^(inset_)?-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/,bc=/^(url|image|image-set|cross-fade|element|(repeating-)?(linear|radial|conic)-gradient)\(.+\)$/,xc=e=>hc.test(e),Sc=e=>!!e&&!Number.isNaN(Number(e)),Cc=e=>!!e&&Number.isInteger(Number(e)),wc=e=>e.endsWith(`%`)&&Sc(e.slice(0,-1)),Tc=e=>gc.test(e),Ec=()=>!0,Dc=e=>_c.test(e)&&!vc.test(e),Oc=()=>!1,kc=e=>yc.test(e),Ac=e=>bc.test(e),jc=e=>!Z(e)&&!Q(e),Mc=e=>e.startsWith(`@container`)&&(e[10]===`/`&&e[11]!==void 0||e[11]===`s`&&e[16]!==void 0&&e.startsWith(`-size/`,10)||e[11]===`n`&&e[18]!==void 0&&e.startsWith(`-normal/`,10)),Nc=e=>Jc(e,Qc,Oc),Z=e=>pc.test(e),Pc=e=>Jc(e,$c,Dc),Fc=e=>Jc(e,el,Sc),Ic=e=>Jc(e,nl,Ec),Lc=e=>Jc(e,tl,Oc),Rc=e=>Jc(e,Xc,Oc),zc=e=>Jc(e,Zc,Ac),Bc=e=>Jc(e,rl,kc),Q=e=>mc.test(e),Vc=e=>Yc(e,$c),Hc=e=>Yc(e,tl),Uc=e=>Yc(e,Xc),Wc=e=>Yc(e,Qc),Gc=e=>Yc(e,Zc),Kc=e=>Yc(e,rl,!0),qc=e=>Yc(e,nl,!0),Jc=(e,t,n)=>{let r=pc.exec(e);return r?r[1]?t(r[1]):n(r[2]):!1},Yc=(e,t,n=!1)=>{let r=mc.exec(e);return r?r[1]?t(r[1]):n:!1},Xc=e=>e===`position`||e===`percentage`,Zc=e=>e===`image`||e===`url`,Qc=e=>e===`length`||e===`size`||e===`bg-size`,$c=e=>e===`length`,el=e=>e===`number`,tl=e=>e===`family-name`,nl=e=>e===`number`||e===`weight`,rl=e=>e===`shadow`,il=uc(()=>{let e=fc(`color`),t=fc(`font`),n=fc(`text`),r=fc(`font-weight`),i=fc(`tracking`),a=fc(`leading`),o=fc(`breakpoint`),s=fc(`container`),c=fc(`spacing`),l=fc(`radius`),u=fc(`shadow`),d=fc(`inset-shadow`),f=fc(`text-shadow`),p=fc(`drop-shadow`),m=fc(`blur`),h=fc(`perspective`),g=fc(`aspect`),_=fc(`ease`),v=fc(`animate`),y=()=>[`auto`,`avoid`,`all`,`avoid-page`,`page`,`left`,`right`,`column`],b=()=>[`center`,`top`,`bottom`,`left`,`right`,`top-left`,`left-top`,`top-right`,`right-top`,`bottom-right`,`right-bottom`,`bottom-left`,`left-bottom`],x=()=>[...b(),Q,Z],S=()=>[`auto`,`hidden`,`clip`,`visible`,`scroll`],C=()=>[`auto`,`contain`,`none`],w=()=>[Q,Z,c],T=()=>[xc,`full`,`auto`,...w()],E=()=>[Cc,`none`,`subgrid`,Q,Z],D=()=>[`auto`,{span:[`full`,Cc,Q,Z]},Cc,Q,Z],O=()=>[Cc,`auto`,Q,Z],k=()=>[`auto`,`min`,`max`,`fr`,Q,Z],A=()=>[`start`,`end`,`center`,`between`,`around`,`evenly`,`stretch`,`baseline`,`center-safe`,`end-safe`],j=()=>[`start`,`end`,`center`,`stretch`,`center-safe`,`end-safe`],M=()=>[`auto`,...w()],N=()=>[xc,`auto`,`full`,`dvw`,`dvh`,`lvw`,`lvh`,`svw`,`svh`,`min`,`max`,`fit`,...w()],P=()=>[xc,`screen`,`full`,`dvw`,`lvw`,`svw`,`min`,`max`,`fit`,...w()],F=()=>[xc,`screen`,`full`,`lh`,`dvh`,`lvh`,`svh`,`min`,`max`,`fit`,...w()],I=()=>[e,Q,Z],L=()=>[...b(),Uc,Rc,{position:[Q,Z]}],R=()=>[`no-repeat`,{repeat:[``,`x`,`y`,`space`,`round`]}],z=()=>[`auto`,`cover`,`contain`,Wc,Nc,{size:[Q,Z]}],B=()=>[wc,Vc,Pc],V=()=>[``,`none`,`full`,l,Q,Z],H=()=>[``,Sc,Vc,Pc],U=()=>[`solid`,`dashed`,`dotted`,`double`],ee=()=>[`normal`,`multiply`,`screen`,`overlay`,`darken`,`lighten`,`color-dodge`,`color-burn`,`hard-light`,`soft-light`,`difference`,`exclusion`,`hue`,`saturation`,`color`,`luminosity`],W=()=>[Sc,wc,Uc,Rc],G=()=>[``,`none`,m,Q,Z],te=()=>[`none`,Sc,Q,Z],ne=()=>[`none`,Sc,Q,Z],re=()=>[Sc,Q,Z],K=()=>[xc,`full`,...w()];return{cacheSize:500,theme:{animate:[`spin`,`ping`,`pulse`,`bounce`],aspect:[`video`],blur:[Tc],breakpoint:[Tc],color:[Ec],container:[Tc],"drop-shadow":[Tc],ease:[`in`,`out`,`in-out`],font:[jc],"font-weight":[`thin`,`extralight`,`light`,`normal`,`medium`,`semibold`,`bold`,`extrabold`,`black`],"inset-shadow":[Tc],leading:[`none`,`tight`,`snug`,`normal`,`relaxed`,`loose`],perspective:[`dramatic`,`near`,`normal`,`midrange`,`distant`,`none`],radius:[Tc],shadow:[Tc],spacing:[`px`,Sc],text:[Tc],"text-shadow":[Tc],tracking:[`tighter`,`tight`,`normal`,`wide`,`wider`,`widest`]},classGroups:{aspect:[{aspect:[`auto`,`square`,xc,Z,Q,g]}],container:[`container`],"container-type":[{"@container":[``,`normal`,`size`,Q,Z]}],"container-named":[Mc],columns:[{columns:[Sc,Z,Q,s]}],"break-after":[{"break-after":y()}],"break-before":[{"break-before":y()}],"break-inside":[{"break-inside":[`auto`,`avoid`,`avoid-page`,`avoid-column`]}],"box-decoration":[{"box-decoration":[`slice`,`clone`]}],box:[{box:[`border`,`content`]}],display:[`block`,`inline-block`,`inline`,`flex`,`inline-flex`,`table`,`inline-table`,`table-caption`,`table-cell`,`table-column`,`table-column-group`,`table-footer-group`,`table-header-group`,`table-row-group`,`table-row`,`flow-root`,`grid`,`inline-grid`,`contents`,`list-item`,`hidden`],sr:[`sr-only`,`not-sr-only`],float:[{float:[`right`,`left`,`none`,`start`,`end`]}],clear:[{clear:[`left`,`right`,`both`,`none`,`start`,`end`]}],isolation:[`isolate`,`isolation-auto`],"object-fit":[{object:[`contain`,`cover`,`fill`,`none`,`scale-down`]}],"object-position":[{object:x()}],overflow:[{overflow:S()}],"overflow-x":[{"overflow-x":S()}],"overflow-y":[{"overflow-y":S()}],overscroll:[{overscroll:C()}],"overscroll-x":[{"overscroll-x":C()}],"overscroll-y":[{"overscroll-y":C()}],position:[`static`,`fixed`,`absolute`,`relative`,`sticky`],inset:[{inset:T()}],"inset-x":[{"inset-x":T()}],"inset-y":[{"inset-y":T()}],start:[{"inset-s":T(),start:T()}],end:[{"inset-e":T(),end:T()}],"inset-bs":[{"inset-bs":T()}],"inset-be":[{"inset-be":T()}],top:[{top:T()}],right:[{right:T()}],bottom:[{bottom:T()}],left:[{left:T()}],visibility:[`visible`,`invisible`,`collapse`],z:[{z:[Cc,`auto`,Q,Z]}],basis:[{basis:[xc,`full`,`auto`,s,...w()]}],"flex-direction":[{flex:[`row`,`row-reverse`,`col`,`col-reverse`]}],"flex-wrap":[{flex:[`nowrap`,`wrap`,`wrap-reverse`]}],flex:[{flex:[Sc,xc,`auto`,`initial`,`none`,Z]}],grow:[{grow:[``,Sc,Q,Z]}],shrink:[{shrink:[``,Sc,Q,Z]}],order:[{order:[Cc,`first`,`last`,`none`,Q,Z]}],"grid-cols":[{"grid-cols":E()}],"col-start-end":[{col:D()}],"col-start":[{"col-start":O()}],"col-end":[{"col-end":O()}],"grid-rows":[{"grid-rows":E()}],"row-start-end":[{row:D()}],"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":k()}],"auto-rows":[{"auto-rows":k()}],gap:[{gap:w()}],"gap-x":[{"gap-x":w()}],"gap-y":[{"gap-y":w()}],"justify-content":[{justify:[...A(),`normal`]}],"justify-items":[{"justify-items":[...j(),`normal`]}],"justify-self":[{"justify-self":[`auto`,...j()]}],"align-content":[{content:[`normal`,...A()]}],"align-items":[{items:[...j(),{baseline:[``,`last`]}]}],"align-self":[{self:[`auto`,...j(),{baseline:[``,`last`]}]}],"place-content":[{"place-content":A()}],"place-items":[{"place-items":[...j(),`baseline`]}],"place-self":[{"place-self":[`auto`,...j()]}],p:[{p:w()}],px:[{px:w()}],py:[{py:w()}],ps:[{ps:w()}],pe:[{pe:w()}],pbs:[{pbs:w()}],pbe:[{pbe:w()}],pt:[{pt:w()}],pr:[{pr:w()}],pb:[{pb:w()}],pl:[{pl:w()}],m:[{m:M()}],mx:[{mx:M()}],my:[{my:M()}],ms:[{ms:M()}],me:[{me:M()}],mbs:[{mbs:M()}],mbe:[{mbe:M()}],mt:[{mt:M()}],mr:[{mr:M()}],mb:[{mb:M()}],ml:[{ml:M()}],"space-x":[{"space-x":w()}],"space-x-reverse":[`space-x-reverse`],"space-y":[{"space-y":w()}],"space-y-reverse":[`space-y-reverse`],size:[{size:N()}],"inline-size":[{inline:[`auto`,...P()]}],"min-inline-size":[{"min-inline":[`auto`,...P()]}],"max-inline-size":[{"max-inline":[`none`,...P()]}],"block-size":[{block:[`auto`,...F()]}],"min-block-size":[{"min-block":[`auto`,...F()]}],"max-block-size":[{"max-block":[`none`,...F()]}],w:[{w:[s,`screen`,...N()]}],"min-w":[{"min-w":[s,`screen`,`none`,...N()]}],"max-w":[{"max-w":[s,`screen`,`none`,`prose`,{screen:[o]},...N()]}],h:[{h:[`screen`,`lh`,...N()]}],"min-h":[{"min-h":[`screen`,`lh`,`none`,...N()]}],"max-h":[{"max-h":[`screen`,`lh`,...N()]}],"font-size":[{text:[`base`,n,Vc,Pc]}],"font-smoothing":[`antialiased`,`subpixel-antialiased`],"font-style":[`italic`,`not-italic`],"font-weight":[{font:[r,qc,Ic]}],"font-stretch":[{"font-stretch":[`ultra-condensed`,`extra-condensed`,`condensed`,`semi-condensed`,`normal`,`semi-expanded`,`expanded`,`extra-expanded`,`ultra-expanded`,wc,Z]}],"font-family":[{font:[Hc,Lc,t]}],"font-features":[{"font-features":[Z]}],"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:[i,Q,Z]}],"line-clamp":[{"line-clamp":[Sc,`none`,Q,Fc]}],leading:[{leading:[a,...w()]}],"list-image":[{"list-image":[`none`,Q,Z]}],"list-style-position":[{list:[`inside`,`outside`]}],"list-style-type":[{list:[`disc`,`decimal`,`none`,Q,Z]}],"text-alignment":[{text:[`left`,`center`,`right`,`justify`,`start`,`end`]}],"placeholder-color":[{placeholder:I()}],"text-color":[{text:I()}],"text-decoration":[`underline`,`overline`,`line-through`,`no-underline`],"text-decoration-style":[{decoration:[...U(),`wavy`]}],"text-decoration-thickness":[{decoration:[Sc,`from-font`,`auto`,Q,Pc]}],"text-decoration-color":[{decoration:I()}],"underline-offset":[{"underline-offset":[Sc,`auto`,Q,Z]}],"text-transform":[`uppercase`,`lowercase`,`capitalize`,`normal-case`],"text-overflow":[`truncate`,`text-ellipsis`,`text-clip`],"text-wrap":[{text:[`wrap`,`nowrap`,`balance`,`pretty`]}],indent:[{indent:w()}],"tab-size":[{tab:[Cc,Q,Z]}],"vertical-align":[{align:[`baseline`,`top`,`middle`,`bottom`,`text-top`,`text-bottom`,`sub`,`super`,Q,Z]}],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`,Q,Z]}],"bg-attachment":[{bg:[`fixed`,`local`,`scroll`]}],"bg-clip":[{"bg-clip":[`border`,`padding`,`content`,`text`]}],"bg-origin":[{"bg-origin":[`border`,`padding`,`content`]}],"bg-position":[{bg:L()}],"bg-repeat":[{bg:R()}],"bg-size":[{bg:z()}],"bg-image":[{bg:[`none`,{linear:[{to:[`t`,`tr`,`r`,`br`,`b`,`bl`,`l`,`tl`]},Cc,Q,Z],radial:[``,Q,Z],conic:[Cc,Q,Z]},Gc,zc]}],"bg-color":[{bg:I()}],"gradient-from-pos":[{from:B()}],"gradient-via-pos":[{via:B()}],"gradient-to-pos":[{to:B()}],"gradient-from":[{from:I()}],"gradient-via":[{via:I()}],"gradient-to":[{to:I()}],rounded:[{rounded:V()}],"rounded-s":[{"rounded-s":V()}],"rounded-e":[{"rounded-e":V()}],"rounded-t":[{"rounded-t":V()}],"rounded-r":[{"rounded-r":V()}],"rounded-b":[{"rounded-b":V()}],"rounded-l":[{"rounded-l":V()}],"rounded-ss":[{"rounded-ss":V()}],"rounded-se":[{"rounded-se":V()}],"rounded-ee":[{"rounded-ee":V()}],"rounded-es":[{"rounded-es":V()}],"rounded-tl":[{"rounded-tl":V()}],"rounded-tr":[{"rounded-tr":V()}],"rounded-br":[{"rounded-br":V()}],"rounded-bl":[{"rounded-bl":V()}],"border-w":[{border:H()}],"border-w-x":[{"border-x":H()}],"border-w-y":[{"border-y":H()}],"border-w-s":[{"border-s":H()}],"border-w-e":[{"border-e":H()}],"border-w-bs":[{"border-bs":H()}],"border-w-be":[{"border-be":H()}],"border-w-t":[{"border-t":H()}],"border-w-r":[{"border-r":H()}],"border-w-b":[{"border-b":H()}],"border-w-l":[{"border-l":H()}],"divide-x":[{"divide-x":H()}],"divide-x-reverse":[`divide-x-reverse`],"divide-y":[{"divide-y":H()}],"divide-y-reverse":[`divide-y-reverse`],"border-style":[{border:[...U(),`hidden`,`none`]}],"divide-style":[{divide:[...U(),`hidden`,`none`]}],"border-color":[{border:I()}],"border-color-x":[{"border-x":I()}],"border-color-y":[{"border-y":I()}],"border-color-s":[{"border-s":I()}],"border-color-e":[{"border-e":I()}],"border-color-bs":[{"border-bs":I()}],"border-color-be":[{"border-be":I()}],"border-color-t":[{"border-t":I()}],"border-color-r":[{"border-r":I()}],"border-color-b":[{"border-b":I()}],"border-color-l":[{"border-l":I()}],"divide-color":[{divide:I()}],"outline-style":[{outline:[...U(),`none`,`hidden`]}],"outline-offset":[{"outline-offset":[Sc,Q,Z]}],"outline-w":[{outline:[``,Sc,Vc,Pc]}],"outline-color":[{outline:I()}],shadow:[{shadow:[``,`none`,u,Kc,Bc]}],"shadow-color":[{shadow:I()}],"inset-shadow":[{"inset-shadow":[`none`,d,Kc,Bc]}],"inset-shadow-color":[{"inset-shadow":I()}],"ring-w":[{ring:H()}],"ring-w-inset":[`ring-inset`],"ring-color":[{ring:I()}],"ring-offset-w":[{"ring-offset":[Sc,Pc]}],"ring-offset-color":[{"ring-offset":I()}],"inset-ring-w":[{"inset-ring":H()}],"inset-ring-color":[{"inset-ring":I()}],"text-shadow":[{"text-shadow":[`none`,f,Kc,Bc]}],"text-shadow-color":[{"text-shadow":I()}],opacity:[{opacity:[Sc,Q,Z]}],"mix-blend":[{"mix-blend":[...ee(),`plus-darker`,`plus-lighter`]}],"bg-blend":[{"bg-blend":ee()}],"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":[Sc]}],"mask-image-linear-from-pos":[{"mask-linear-from":W()}],"mask-image-linear-to-pos":[{"mask-linear-to":W()}],"mask-image-linear-from-color":[{"mask-linear-from":I()}],"mask-image-linear-to-color":[{"mask-linear-to":I()}],"mask-image-t-from-pos":[{"mask-t-from":W()}],"mask-image-t-to-pos":[{"mask-t-to":W()}],"mask-image-t-from-color":[{"mask-t-from":I()}],"mask-image-t-to-color":[{"mask-t-to":I()}],"mask-image-r-from-pos":[{"mask-r-from":W()}],"mask-image-r-to-pos":[{"mask-r-to":W()}],"mask-image-r-from-color":[{"mask-r-from":I()}],"mask-image-r-to-color":[{"mask-r-to":I()}],"mask-image-b-from-pos":[{"mask-b-from":W()}],"mask-image-b-to-pos":[{"mask-b-to":W()}],"mask-image-b-from-color":[{"mask-b-from":I()}],"mask-image-b-to-color":[{"mask-b-to":I()}],"mask-image-l-from-pos":[{"mask-l-from":W()}],"mask-image-l-to-pos":[{"mask-l-to":W()}],"mask-image-l-from-color":[{"mask-l-from":I()}],"mask-image-l-to-color":[{"mask-l-to":I()}],"mask-image-x-from-pos":[{"mask-x-from":W()}],"mask-image-x-to-pos":[{"mask-x-to":W()}],"mask-image-x-from-color":[{"mask-x-from":I()}],"mask-image-x-to-color":[{"mask-x-to":I()}],"mask-image-y-from-pos":[{"mask-y-from":W()}],"mask-image-y-to-pos":[{"mask-y-to":W()}],"mask-image-y-from-color":[{"mask-y-from":I()}],"mask-image-y-to-color":[{"mask-y-to":I()}],"mask-image-radial":[{"mask-radial":[Q,Z]}],"mask-image-radial-from-pos":[{"mask-radial-from":W()}],"mask-image-radial-to-pos":[{"mask-radial-to":W()}],"mask-image-radial-from-color":[{"mask-radial-from":I()}],"mask-image-radial-to-color":[{"mask-radial-to":I()}],"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":b()}],"mask-image-conic-pos":[{"mask-conic":[Sc]}],"mask-image-conic-from-pos":[{"mask-conic-from":W()}],"mask-image-conic-to-pos":[{"mask-conic-to":W()}],"mask-image-conic-from-color":[{"mask-conic-from":I()}],"mask-image-conic-to-color":[{"mask-conic-to":I()}],"mask-mode":[{mask:[`alpha`,`luminance`,`match`]}],"mask-origin":[{"mask-origin":[`border`,`padding`,`content`,`fill`,`stroke`,`view`]}],"mask-position":[{mask:L()}],"mask-repeat":[{mask:R()}],"mask-size":[{mask:z()}],"mask-type":[{"mask-type":[`alpha`,`luminance`]}],"mask-image":[{mask:[`none`,Q,Z]}],filter:[{filter:[``,`none`,Q,Z]}],blur:[{blur:G()}],brightness:[{brightness:[Sc,Q,Z]}],contrast:[{contrast:[Sc,Q,Z]}],"drop-shadow":[{"drop-shadow":[``,`none`,p,Kc,Bc]}],"drop-shadow-color":[{"drop-shadow":I()}],grayscale:[{grayscale:[``,Sc,Q,Z]}],"hue-rotate":[{"hue-rotate":[Sc,Q,Z]}],invert:[{invert:[``,Sc,Q,Z]}],saturate:[{saturate:[Sc,Q,Z]}],sepia:[{sepia:[``,Sc,Q,Z]}],"backdrop-filter":[{"backdrop-filter":[``,`none`,Q,Z]}],"backdrop-blur":[{"backdrop-blur":G()}],"backdrop-brightness":[{"backdrop-brightness":[Sc,Q,Z]}],"backdrop-contrast":[{"backdrop-contrast":[Sc,Q,Z]}],"backdrop-grayscale":[{"backdrop-grayscale":[``,Sc,Q,Z]}],"backdrop-hue-rotate":[{"backdrop-hue-rotate":[Sc,Q,Z]}],"backdrop-invert":[{"backdrop-invert":[``,Sc,Q,Z]}],"backdrop-opacity":[{"backdrop-opacity":[Sc,Q,Z]}],"backdrop-saturate":[{"backdrop-saturate":[Sc,Q,Z]}],"backdrop-sepia":[{"backdrop-sepia":[``,Sc,Q,Z]}],"border-collapse":[{border:[`collapse`,`separate`]}],"border-spacing":[{"border-spacing":w()}],"border-spacing-x":[{"border-spacing-x":w()}],"border-spacing-y":[{"border-spacing-y":w()}],"table-layout":[{table:[`auto`,`fixed`]}],caption:[{caption:[`top`,`bottom`]}],transition:[{transition:[``,`all`,`colors`,`opacity`,`shadow`,`transform`,`none`,Q,Z]}],"transition-behavior":[{transition:[`normal`,`discrete`]}],duration:[{duration:[Sc,`initial`,Q,Z]}],ease:[{ease:[`linear`,`initial`,_,Q,Z]}],delay:[{delay:[Sc,Q,Z]}],animate:[{animate:[`none`,v,Q,Z]}],backface:[{backface:[`hidden`,`visible`]}],perspective:[{perspective:[h,Q,Z]}],"perspective-origin":[{"perspective-origin":x()}],rotate:[{rotate:te()}],"rotate-x":[{"rotate-x":te()}],"rotate-y":[{"rotate-y":te()}],"rotate-z":[{"rotate-z":te()}],scale:[{scale:ne()}],"scale-x":[{"scale-x":ne()}],"scale-y":[{"scale-y":ne()}],"scale-z":[{"scale-z":ne()}],"scale-3d":[`scale-3d`],skew:[{skew:re()}],"skew-x":[{"skew-x":re()}],"skew-y":[{"skew-y":re()}],transform:[{transform:[Q,Z,``,`none`,`gpu`,`cpu`]}],"transform-origin":[{origin:x()}],"transform-style":[{transform:[`3d`,`flat`]}],translate:[{translate:K()}],"translate-x":[{"translate-x":K()}],"translate-y":[{"translate-y":K()}],"translate-z":[{"translate-z":K()}],"translate-none":[`translate-none`],zoom:[{zoom:[Cc,Q,Z]}],accent:[{accent:I()}],appearance:[{appearance:[`none`,`auto`]}],"caret-color":[{caret:I()}],"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`,Q,Z]}],"field-sizing":[{"field-sizing":[`fixed`,`content`]}],"pointer-events":[{"pointer-events":[`auto`,`none`]}],resize:[{resize:[`none`,``,`y`,`x`]}],"scroll-behavior":[{scroll:[`auto`,`smooth`]}],"scrollbar-thumb-color":[{"scrollbar-thumb":I()}],"scrollbar-track-color":[{"scrollbar-track":I()}],"scrollbar-gutter":[{"scrollbar-gutter":[`auto`,`stable`,`both`]}],"scrollbar-w":[{scrollbar:[`auto`,`thin`,`none`]}],"scroll-m":[{"scroll-m":w()}],"scroll-mx":[{"scroll-mx":w()}],"scroll-my":[{"scroll-my":w()}],"scroll-ms":[{"scroll-ms":w()}],"scroll-me":[{"scroll-me":w()}],"scroll-mbs":[{"scroll-mbs":w()}],"scroll-mbe":[{"scroll-mbe":w()}],"scroll-mt":[{"scroll-mt":w()}],"scroll-mr":[{"scroll-mr":w()}],"scroll-mb":[{"scroll-mb":w()}],"scroll-ml":[{"scroll-ml":w()}],"scroll-p":[{"scroll-p":w()}],"scroll-px":[{"scroll-px":w()}],"scroll-py":[{"scroll-py":w()}],"scroll-ps":[{"scroll-ps":w()}],"scroll-pe":[{"scroll-pe":w()}],"scroll-pbs":[{"scroll-pbs":w()}],"scroll-pbe":[{"scroll-pbe":w()}],"scroll-pt":[{"scroll-pt":w()}],"scroll-pr":[{"scroll-pr":w()}],"scroll-pb":[{"scroll-pb":w()}],"scroll-pl":[{"scroll-pl":w()}],"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`,Q,Z]}],fill:[{fill:[`none`,...I()]}],"stroke-w":[{stroke:[Sc,Vc,Pc,Fc]}],stroke:[{stroke:[`none`,...I()]}],"forced-color-adjust":[{"forced-color-adjust":[`auto`,`none`]}]},conflictingClassGroups:{"container-named":[`container-type`],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`]},postfixLookupClassGroups:[`container-type`],orderSensitiveModifiers:[`*`,`**`,`after`,`backdrop`,`before`,`details-content`,`file`,`first-letter`,`first-line`,`marker`,`placeholder`,`selection`]}});function $(...e){return il(Ms(e))}E();var al=`(max-width: 767px)`,ol=`(min-width: 768px) and (max-width: 1023px)`;function sl(e){return typeof window.matchMedia==`function`?window.matchMedia(e):null}function cl(e){return t=>{let n=sl(e);return n===null?()=>{}:(n.addEventListener(`change`,t),()=>n.removeEventListener(`change`,t))}}function ll(e){return()=>sl(e)?.matches??!1}function ul(){return!1}function dl(){return S(cl(al),ll(al),ul)}function fl(){return S(cl(ol),ll(ol),ul)}E();function pl({open:e,onClose:t,title:n,children:r,className:i}){return b(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=``}},[e,t]),c(P,{children:[v(`div`,{className:$(`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`}),c(`div`,{role:`dialog`,"aria-modal":`true`,className:$(`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 pb-[env(safe-area-inset-bottom)]`,`max-h-[80dvh]`,e?`translate-y-0`:`translate-y-full`,i),children:[v(`div`,{className:`flex justify-center pt-2 pb-1`,children:v(`div`,{className:`h-1 w-8 rounded-full bg-foreground-subtle/30`})}),n&&c(`div`,{className:`flex items-center justify-between px-4 pb-2`,children:[v(`span`,{className:`text-sm font-medium text-foreground`,children:n}),v(`button`,{onClick:t,className:`p-1 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,children:v(Zn,{className:`h-4 w-4`})})]}),v(`div`,{className:`flex-1 overflow-y-auto px-4 pb-4`,children:r})]})]})}E();var ml=O(null);function hl(){let e=I(ml);if(!e)throw Error(`Popover compound components must be used within <Popover>`);return e}function gl({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t??r,o=y(),s=y(),c=f(null),l=_(e=>{n?.(e),t===void 0&&i(e)},[t,n]);return v(ml.Provider,{value:{open:a,setOpen:l,triggerId:o,contentId:s,triggerRef:c},children:v(`div`,{className:`relative inline-block`,children:e})})}function _l({children:e,...t}){let{open:n,setOpen:r,triggerId:i,contentId:a,triggerRef:o}=hl();return v(`button`,{type:`button`,ref:o,id:i,"aria-haspopup":`dialog`,"aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}var vl=8;function yl(e){let t=e.viewportHeight-e.triggerBottom-e.offset-vl,n=e.triggerTop-e.offset-vl,r=e.contentHeight>t&&n>t?`above`:`below`;return{side:r,maxHeight:Math.max(0,r===`above`?n:t)}}function bl({className:e,children:t,align:n=`start`,offset:r=4,...i}){let{open:a,setOpen:o,contentId:s,triggerId:c,triggerRef:l}=hl(),d=dl(),p=f(null),[m,h]=C(null),[g,_]=C(null);return u(()=>{if(!a||d){h(null);return}let e=()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),i=n===`end`?t.right:t.left;h({top:t.bottom+r,left:i,minWidth:t.width,triggerTop:t.top,triggerBottom:t.bottom})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a,d,n,r,l]),u(()=>{let e=p.current;if(!m||!e){_(null);return}_(yl({triggerTop:m.triggerTop,triggerBottom:m.triggerBottom,contentHeight:e.scrollHeight,viewportHeight:window.innerHeight,offset:r}))},[m,r]),b(()=>{if(!a||d)return;let e=e=>{let t=p.current,n=l.current;t&&!t.contains(e.target)&&!n?.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a,o,l,d]),a?d?v(pl,{open:a,onClose:()=>o(!1),children:t}):!m||typeof document>`u`?null:Oo(v(`div`,{ref:p,id:s,role:`dialog`,"aria-labelledby":c,style:{position:`fixed`,...g?.side===`above`?{bottom:window.innerHeight-m.triggerTop+r}:{top:m.top},...g?{maxHeight:g.maxHeight}:{},...n===`end`?{right:window.innerWidth-m.left}:{left:m.left},minWidth:m.minWidth},className:$(`z-50 overflow-y-auto bg-background-elevated border border-border rounded-lg shadow-lg p-3`,e),...i,children:t}),document.body):null}E();var xl=7,Sl=24,Cl=32,wl=288,Tl=96;function El(e){let t=[];for(let n=0;n<e.length;n+=xl)t.push(e.slice(n,n+xl));return t}function Dl(e){return e.kind===`header`?Sl:Cl}function Ol(e,t){return e.trim().length>0?El(ta(e,t).map(e=>e.entry.key)).map((e,t)=>({kind:`tiles`,id:`r${t}`,keys:e})):ma.flatMap(e=>{let t=Ha(e).map(e=>e.key);return[{kind:`header`,id:`h-${e}`,category:e},...El(t).map((t,n)=>({kind:`tiles`,id:`${e}-${n}`,keys:t}))]})}function kl(e,t,n,r){let i=Math.max(0,r-Tl),a=r+wl+Tl,o=0;for(;o<e.length-1&&(t[o+1]??n)<=i;)o+=1;let s=o;for(;s<e.length&&(t[s]??n)<a;)s+=1;return{rows:e.slice(o,s),padTop:t[o]??0,padBottom:Math.max(0,n-(t[s]??n))}}function Al({value:e,onPick:t,fallbackGlyph:n,labels:r,extraWords:i,clearGlyph:a,labelFor:o,categoryLabel:s=ja,disabled:l=!1}){let u=f(null);As(u);let[d,m]=C(!1),[h,g]=C(``),[_,y]=C(0),x=f(null),S=hs();b(()=>{d&&cs().catch(()=>void 0)},[d]);let w=Ka(e),T=p(()=>Ol(h,i),[h,i]),{offsets:E,total:D}=p(()=>{let e=[],t=0;for(let n of T)e.push(t),t+=Dl(n);return{offsets:e,total:t}},[T]),O=p(()=>kl(T,E,D,_),[T,E,D,_]),k=(e===null?void 0:S(e))??n,A=a??n,j=e=>{g(e),y(0),x.current!==null&&(x.current.scrollTop=0)},M=async e=>{N(!1),await t(e)},N=e=>{m(e),e||j(``)};return c(gl,{open:d,onOpenChange:N,children:[v(_l,{disabled:l,"aria-label":r.trigger,title:r.trigger,className:`rounded border border-border p-1 text-foreground-muted hover:bg-surface-hover disabled:opacity-50`,children:v(k,{className:`h-4 w-4`})}),v(bl,{"aria-label":r.panel,"aria-labelledby":void 0,className:`w-72 p-2`,children:c(`div`,{className:`w-full`,children:[v(`input`,{ref:u,type:`search`,value:h,autoFocus:!0,onChange:e=>j(e.target.value),placeholder:r.searchPlaceholder,"aria-label":r.searchPlaceholder,className:`mb-2 w-full rounded border border-border bg-surface-raised px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`}),c(`button`,{type:`button`,onClick:()=>void M(null),"aria-pressed":e===null,className:`mb-2 flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:[v(A,{className:`h-3.5 w-3.5`}),r.clear]}),T.length===0?v(`p`,{className:`px-1.5 py-2 text-[11px] text-foreground-subtle`,children:r.noMatches}):v(`div`,{ref:x,onScroll:e=>y(e.currentTarget.scrollTop),className:`max-h-72 overflow-y-auto`,children:v(`div`,{style:{paddingTop:O.padTop,paddingBottom:O.padBottom},children:O.rows.map(e=>e.kind===`header`?v(`h4`,{className:`flex h-6 items-center px-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:s(e.category)},e.id):v(`div`,{className:`grid h-8 grid-cols-7 gap-1 pb-1`,children:e.keys.map(e=>{let t=S(e);if(t===void 0)return v(`span`,{"aria-hidden":`true`},e);let n=w===e;return v(`button`,{type:`button`,onClick:()=>void M(e),"aria-pressed":n,"aria-label":o?.(e)??e,title:o?.(e)??e,className:n?`flex items-center justify-center rounded border border-primary bg-primary/10 text-foreground`:`flex items-center justify-center rounded border border-transparent text-foreground-muted hover:bg-surface-hover`,children:v(t,{className:`h-4 w-4`})},e)})},e.id))})})]})})]})}function jl(e){return{trigger:`Choose an icon for ${e}`,panel:`${e} icon`,searchPlaceholder:`Search icons`,clear:`Default icon`,noMatches:`No icon matches`}}function Ml({label:e,value:t,defaultKey:n,disabled:r,onChange:i}){let a=hs(),o=Ca(t,n),s=a(n)??Wr;return c(`div`,{className:`flex items-center gap-2`,children:[v(Al,{value:o===``?null:o,onPick:e=>i(e??n),fallbackGlyph:s,labels:jl(e),disabled:r}),v(`span`,{className:`text-[11px] text-foreground-subtle font-mono`,children:o})]})}function Nl(e){if(typeof window>`u`||typeof DOMParser>`u`)return``;let t=new Set([`A`,`UL`,`OL`,`LI`,`STRONG`,`EM`,`CODE`,`BR`,`P`,`SPAN`,`B`]),n=new DOMParser().parseFromString(`<div>${e}</div>`,`text/html`),r=n.body.firstElementChild;if(!r)return``;let i=e=>{let r=Array.from(e.children);for(let e of r){if(!t.has(e.tagName)){let t=n.createTextNode(e.textContent??``);e.replaceWith(t);continue}let r=e.tagName===`A`?new Set([`href`]):new Set;for(let t of Array.from(e.attributes))r.has(t.name)||e.removeAttribute(t.name);if(e.tagName===`A`){let t=e.getAttribute(`href`)??``,n=/^https?:\/\//i.test(t),r=t.startsWith(`mailto:`),i=t.startsWith(`/`)&&!t.startsWith(`//`);!n&&!r&&!i?e.removeAttribute(`href`):n&&(e.setAttribute(`target`,`_blank`),e.setAttribute(`rel`,`noopener noreferrer`))}i(e)}};return i(r),r.innerHTML}var Pl=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,Fl=Ms,Il=(e,t)=>n=>{if(t?.variants==null)return Fl(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,a=Object.keys(r).map(e=>{let t=n?.[e],a=i?.[e];if(t===null)return null;let o=Pl(t)||Pl(a);return r[e][o]}),o=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return Fl(e,a,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...o}[t]):{...i,...o}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)};E();var Ll=Il(`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`}}),Rl=D(({className:e,variant:t,size:n,icon:r,...i},a)=>v(`button`,{ref:a,className:$(Ll({variant:t,size:n}),e),...i,children:v(r,{className:`h-4 w-4`,"aria-hidden":`true`})}));Rl.displayName=`IconButton`,E();var zl=Il(`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-inset focus:ring-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,{variants:{state:{default:`border-border`,error:`border-danger`}},defaultVariants:{state:`default`}}),Bl=D(({className:e,state:t,leftSlot:n,rightSlot:r,searchHotkey:i,...a},o)=>{let s=f(null),l=_(e=>{s.current=e,typeof o==`function`?o(e):o&&(o.current=e)},[o]);return As(s,{enabled:i??a.type===`search`}),n||r?c(`div`,{className:$(`relative flex items-center`,e),children:[n&&v(`div`,{className:`absolute left-2.5 flex items-center text-foreground-subtle pointer-events-none`,children:n}),v(`input`,{ref:l,className:$(zl({state:t}),n&&`pl-8`,r&&`pr-8`,e),...a}),r&&v(`div`,{className:`absolute right-2.5 flex items-center text-foreground-subtle`,children:r})]}):v(`input`,{ref:l,className:$(zl({state:t}),e),...a})});Bl.displayName=`Input`,E();var Vl=O(null);function Hl(){let e=I(Vl);if(!e)throw Error(`Tooltip compound components must be used within <Tooltip>`);return e}function Ul({children:e,className:t,open:n}){let[r,i]=C(!1),a=n??r,o=f(null),s=y();return v(Vl.Provider,{value:{open:a,show:()=>{o.current=setTimeout(()=>i(!0),300)},hide:()=>{o.current&&clearTimeout(o.current),i(!1)},tooltipId:s},children:v(`div`,{className:$(`relative`,t??`inline-block`),children:e})})}function Wl({children:e,...t}){let{show:n,hide:r,tooltipId:i,open:a}=Hl();return v(`div`,{onMouseEnter:n,onMouseLeave:r,onFocus:n,onBlur:r,"aria-describedby":a?i:void 0,...t,children:e})}function Gl({className:e,children:t,...n}){let{open:r,tooltipId:i}=Hl();return v(`div`,{id:i,role:`tooltip`,className:$(`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})}E();var Kl=`w-full min-h-[60px] rounded-md border border-border bg-background px-2.5 py-1.5 pr-9 font-mono text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`,ql={WebkitTextSecurity:`disc`},Jl=D(({value:e,onValueChange:t,shown:n,onToggleShown:r,busy:i=!1,error:a=null,toggleBlockedReason:o=null,hideToggle:s=!1,multiline:l=!1,className:u,disabled:d,...f},p)=>{let m=n?`Hide password`:`Show password`;return c(`div`,{className:`relative w-full`,children:[l?v(`textarea`,{className:$(Kl,u),style:n?void 0:ql,value:e,disabled:d,spellCheck:!1,autoComplete:`off`,"aria-label":f[`aria-label`],placeholder:f.placeholder,onChange:e=>t(e.target.value)}):v(Bl,{ref:p,...f,type:n?`text`:`password`,className:$(`h-auto bg-background py-1.5`,!s&&`pr-9`,u),value:e,disabled:d,spellCheck:!1,autoComplete:`new-password`,onChange:e=>t(e.target.value)}),!s&&c(Ul,{open:a!==null,className:`absolute right-0.5 top-0.5`,children:[v(`span`,{className:`inline-flex`,title:o??void 0,children:v(Rl,{type:`button`,variant:`ghost`,icon:i?Gn:n?Oe:Zt,"aria-label":m,"aria-pressed":n,"aria-busy":i||void 0,disabled:d||i||o!==null,className:$(`h-6 w-6 text-foreground-subtle`,i&&`[&>svg]:animate-spin`),onClick:r})}),a!==null&&v(Gl,{role:`alert`,className:`left-auto right-0 w-max max-w-[16rem] translate-x-0 whitespace-normal bg-danger text-white`,children:a})]})]})});Jl.displayName=`PasswordInput`,E();var Yl=D(({className:e,options:t,disabled:n,...r},i)=>c(`div`,{className:`relative w-full`,children:[v(`select`,{ref:i,disabled:n,className:$(`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`,`disabled:opacity-50 disabled:cursor-not-allowed`,e),...r,children:t.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(`div`,{className:$(`absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none text-foreground-muted`,n===!0?`opacity-50`:``),children:v(de,{className:`h-3.5 w-3.5`})})]}));Yl.displayName=`Select`,E();var Xl=1e4,Zl=`••••••••`,Ql=5e3,$l=Kn(`camstack:secret-reveal`,null);function eu({reveal:e,children:t}){return v($l.Provider,{value:e,children:t})}function tu(e){return e===null||ha(e)||Bi(e)}function nu(e,t,n){return e.kind===`untouched`?t:e.text.length===0?n?qi:t:e.text===e.revealed?t:e.text}function ru(e){return typeof e==`string`&&e.length>0?{kind:`visible`,text:e,revealed:null}:Bi(e)?{kind:`visible`,text:``,revealed:null}:{kind:`untouched`}}function iu(e,t,n,r){return e.kind===`untouched`?t?Zl:n:e.text.length===0&&t?r(`uiLibrary.configSecretField.removedOnSave`,`Removed on save`):n}function au({field:e,value:t,onChange:n,disabled:r,multiline:i}){let a=q(),o=I($l),[s]=C(()=>ha(t)?t:null),[c]=C(()=>ha(t)||Bi(t)),[l,u]=C(()=>ru(t)),[d,f]=C(!1),[p,m]=C(!1),[h,g]=C(null);b(()=>{if(h===null)return;let e=setTimeout(()=>g(null),Ql);return()=>clearTimeout(e)},[h]);let _=s?.$secret??null,y=l.kind===`untouched`&&c,x=y&&!(_!==null&&o!==null)?a(`uiLibrary.configSecretField.cannotReveal`,`This stored value cannot be revealed here — type to replace it`):null,S=e=>{let t={kind:`visible`,text:e,revealed:l.kind===`visible`?l.revealed:null};g(null),u(t),n(nu(t,s,c))},w=()=>{if(!y){f(e=>!e);return}_===null||o===null||(g(null),m(!0),o(_).then(e=>{m(!1),u({kind:`visible`,text:e,revealed:e}),f(!0)},e=>{m(!1),g(e instanceof Error?e.message:String(e))}))},T=`label`in e?e.label:``,E=`placeholder`in e&&typeof e.placeholder==`string`?e.placeholder:``;return v(`div`,{"data-secret-field":`key`in e?e.key:void 0,children:v(Jl,{"aria-label":T,value:l.kind===`visible`?l.text:``,onValueChange:S,placeholder:iu(l,c,E,a),shown:d,onToggleShown:w,busy:p,error:h,toggleBlockedReason:x,disabled:r,multiline:i})})}var ou=X.accessories.setChildHidden.useMutation,su=X.accessories.getStatus.useQuery,cu=X.actions.list.useQuery,lu=X.actions.get.useQuery,uu=X.actions.run.useMutation,du=X.actions.stop.useMutation,fu=X.actions.getTraces.useQuery,pu=X.actions.create.useMutation,mu=X.actions.update.useMutation,hu=X.actions.delete.useMutation,gu=X.actions.listForCamera.useQuery,_u=X.actions.getLinks.useQuery,vu=X.actions.setLinks.useMutation,yu=X.actionSource.listActions.useQuery,bu=X.actionSource.runAction.useMutation,xu=X.actionSource.stopAction.useMutation,Su=X.addonPages.listPages.useQuery,Cu=X.addons.list.useQuery,wu=X.addons.getLogs.useQuery,Tu=X.addons.listPackages.useQuery,Eu=X.addons.installPackage.useMutation,Du=X.addons.installFromWorkspace.useMutation,Ou=X.addons.isWorkspaceAvailable.useQuery,ku=X.addons.listWorkspacePackages.useQuery,Au=X.addons.uninstallPackage.useMutation,ju=X.addons.listInstallations.useQuery,Mu=X.addons.reloadPackages.useMutation,Nu=X.addons.searchAvailable.useQuery,Pu=X.addons.listUpdates.useQuery,Fu=X.addons.updatePackage.useMutation,Iu=X.addons.rollbackPackage.useMutation,Lu=X.addons.forceRefresh.useMutation,Ru=X.addons.restartServer.useMutation,zu=X.addons.getLastRestart.useQuery,Bu=X.addons.listFrameworkPackages.useQuery,Vu=X.addons.listCapabilityProviders.useQuery,Hu=X.addons.setCapabilityProviderEnabled.useMutation,Uu=X.addons.getVersions.useQuery,Wu=X.addons.getPackageDocs.useQuery,Gu=X.addons.restartAddon.useMutation,Ku=X.addons.retryLoad.useMutation,qu=X.addons.getAutoUpdateSettings.useQuery,Ju=X.addons.setAutoUpdateSettings.useMutation,Yu=X.addons.getAddonAutoUpdate.useQuery,Xu=X.addons.setAddonAutoUpdate.useMutation,Zu=X.addons.applyAutoUpdateToAll.useMutation,Qu=X.addons.custom.useMutation,$u=X.addons.startJob.useMutation,ed=X.addons.getJob.useQuery,td=X.addons.listJobs.useQuery,nd=X.addons.cancelJob.useMutation,rd=X.addons.onAddonLogs.useSubscription,id=X.addonSettings.getGlobalSettings.useQuery,ad=X.addonSettings.updateGlobalSettings.useMutation,od=X.addonSettings.getIntegrationSettings.useQuery,sd=X.addonSettings.getDeviceSettings.useQuery,cd=X.addonSettings.updateDeviceSettings.useMutation,ld=X.addonWidgets.listWidgets.useQuery,ud=X.airQualitySensor.getStatus.useQuery,dd=X.alarmPanel.arm.useMutation,fd=X.alarmPanel.disarm.useMutation,pd=X.alarmPanel.trigger.useMutation,md=X.alarmPanel.getStatus.useQuery,hd=X.alerts.emit.useMutation,gd=X.alerts.update.useMutation,_d=X.alerts.list.useQuery,vd=X.alerts.getUnreadCount.useQuery,yd=X.alerts.markRead.useMutation,bd=X.alerts.markAllRead.useMutation,xd=X.alerts.dismiss.useMutation,Sd=X.ambientLightSensor.getStatus.useQuery,Cd=X.audioAnalysis.resolveDeviceSettings.useQuery,wd=X.audioAnalysis.getDeviceSettingsContribution.useQuery,Td=X.audioAnalysis.getDeviceLiveContribution.useQuery,Ed=X.audioAnalysis.applyDeviceSettingsPatch.useMutation,jee=X.audioAnalyzer.analyseChunk.useMutation,Mee=X.audioAnalyzer.classify.useQuery,Nee=X.audioAnalyzer.attachDevice.useMutation,Pee=X.audioAnalyzer.detachDevice.useMutation,Fee=X.audioAnalyzer.isReady.useQuery,Iee=X.audioAnalyzer.dispose.useMutation,Dd=X.audioAnalyzer.reprobeAudioEngine.useMutation,Lee=X.audioCodec.listSupportedCodecs.useQuery,Ree=X.audioCodec.canHandle.useQuery,zee=X.audioCodec.createDecodeSession.useMutation,Bee=X.audioCodec.createEncodeSession.useMutation,Vee=X.audioCodec.closeSession.useMutation,Hee=X.audioCodec.pushEncodedFrame.useMutation,Uee=X.audioCodec.pullPcm.useQuery,Wee=X.audioCodec.pushPcm.useMutation,Gee=X.audioCodec.pullEncoded.useQuery,Kee=X.audioCodec.flushEncode.useMutation,qee=X.audioCodec.listActiveSessions.useQuery,Od=X.audioMetrics.getCurrentSnapshot.useQuery,Jee=X.audioMetrics.getHistory.useQuery,Yee=X.automationControl.enable.useMutation,Xee=X.automationControl.disable.useMutation,Zee=X.automationControl.trigger.useMutation,Qee=X.automationControl.getStatus.useQuery,kd=X.backup.listDestinations.useQuery,Ad=X.backup.trigger.useMutation,jd=X.backup.listRuns.useQuery,Md=X.backup.cancel.useMutation,$ee=X.backup.list.useQuery,ete=X.backup.listLocations.useQuery,Nd=X.backup.getEntries.useQuery,Pd=X.backup.restore.useMutation,Fd=X.backup.getEncryption.useQuery,Id=X.backup.setupEncryption.useMutation,Ld=X.backup.disableEncryption.useMutation,tte=X.backup.checkBackupKey.useMutation,Rd=X.backup.delete.useMutation,zd=X.backup.listArchives.useQuery,nte=X.backup.upsertDestinationPolicy.useMutation,Bd=X.backup.previewSchedule.useQuery,Vd=X.backup.listSchedules.useQuery,Hd=X.backup.listAvailableDatabases.useQuery,Ud=X.backup.upsertSchedule.useMutation,Wd=X.backup.deleteSchedule.useMutation,rte=X.battery.wakeForStream.useMutation,ite=X.battery.getStatus.useQuery,ate=X.binary.getStatus.useQuery,ote=X.brightness.setBrightness.useMutation,ste=X.brightness.getStatus.useQuery,Gd=X.broker.list.useQuery,cte=X.broker.get.useQuery,Kd=X.broker.listProviders.useQuery,qd=X.broker.add.useMutation,Jd=X.broker.remove.useMutation,Yd=X.broker.testConnection.useMutation,Xd=X.broker.getSettings.useQuery,Zd=X.broker.setSettings.useMutation,lte=X.broker.getBrokerConfig.useQuery,Qd=X.broker.getSettingsSchema.useQuery,$d=X.broker.testSettings.useMutation,ef=X.broker.publish.useMutation,ute=X.broker.subscribe.useMutation,dte=X.broker.unsubscribe.useMutation,tf=X.broker.getState.useQuery,nf=X.broker.getStatus.useQuery,fte=X.button.press.useMutation,rf=X.calendars.listCalendars.useQuery,af=X.calendars.listEvents.useQuery,of=X.calendars.getPreferences.useQuery,sf=X.calendars.setCalendarPreference.useMutation,pte=X.cameraCredentials.getCredentials.useQuery,mte=X.cameraCredentials.getStatus.useQuery,hte=X.cameraGridLayout.getLayout.useQuery,gte=X.cameraGridLayout.saveLayout.useMutation,_te=X.cameraGridLayout.getDeviceSettingsContribution.useQuery,vte=X.cameraGridLayout.getDeviceLiveContribution.useQuery,yte=X.cameraGridLayout.applyDeviceSettingsPatch.useMutation,bte=X.cameraPipelineConfig.getDeviceSettingsContribution.useQuery,xte=X.cameraPipelineConfig.getDeviceLiveContribution.useQuery,Ste=X.cameraPipelineConfig.applyDeviceSettingsPatch.useMutation,Cte=X.cameraStreams.getCameraStreams.useQuery,wte=X.cameraStreams.getBrokerStreams.useQuery,cf=X.cameraStreams.getRtspEntries.useQuery,Tte=X.cameraStreams.getProfileRtspEntries.useQuery,Ete=X.cameraStreams.pickStream.useQuery,Dte=X.carbonMonoxide.getStatus.useQuery,Ote=X.climateControl.setMode.useMutation,kte=X.climateControl.setFanMode.useMutation,Ate=X.climateControl.setPreset.useMutation,jte=X.climateControl.setTarget.useMutation,Mte=X.climateControl.setTargetRange.useMutation,Nte=X.climateControl.setTargetHumidity.useMutation,Pte=X.climateControl.setSwingVertical.useMutation,Fte=X.climateControl.setSwingHorizontal.useMutation,Ite=X.climateControl.getStatus.useQuery,Lte=X.color.setColor.useMutation,Rte=X.color.getStatus.useQuery,zte=X.connectionTest.testSettings.useMutation,Bte=X.connectionTest.describeTest.useQuery,Vte=X.connectivity.getStatus.useQuery,lf=X.consumables.reset.useMutation,uf=X.consumables.getStatus.useQuery,df=X.contact.getStatus.useQuery,ff=X.control.setValue.useMutation,pf=X.control.getStatus.useQuery,mf=X.coreBlocks.list.useQuery,hf=X.coreBlocks.get.useQuery,gf=X.coreBlocks.create.useMutation,_f=X.coreBlocks.update.useMutation,vf=X.coreBlocks.delete.useMutation,yf=X.coreBlocks.setEnabled.useMutation,bf=X.coreBlocks.restart.useMutation,xf=X.coreBlocks.compile.useMutation,Sf=X.coreBlocks.getBlockSettings.useQuery,Cf=X.coreBlocks.updateBlockSettings.useMutation,wf=X.coreBlocks.migrateRawSecrets.useMutation,Tf=X.coreBlocks.getTypeDefs.useQuery,Ef=X.coreBlocks.createComposition.useMutation,Df=X.coreBlocks.updateComposition.useMutation,Of=X.coreBlocks.getComposition.useQuery,kf=X.coreBlocks.listCompositions.useQuery,Af=X.coreBlocks.getCustomization.useQuery,jf=X.coreBlocks.listComposableCaps.useQuery,Mf=X.coreBlocks.validateComposition.useMutation,Nf=X.coreBlocks.reportAutomationRun.useMutation,Pf=X.coreBlocks.getAutomationRunState.useQuery,Ff=X.coreBlocks.getTraces.useQuery,If=X.cover.open.useMutation,Lf=X.cover.close.useMutation,Rf=X.cover.stop.useMutation,zf=X.cover.setPosition.useMutation,Bf=X.cover.setTiltPosition.useMutation,Vf=X.cover.getStatus.useQuery,Hf=X.dayNight.getOptions.useQuery,Uf=X.dayNight.setSettings.useMutation,Wf=X.dayNight.getStatus.useQuery,Gf=X.decoder.getInfo.useQuery,Kf=X.decoder.reprobeHwaccel.useMutation,Hte=X.detectionPipeline.getDeviceSettingsContribution.useQuery,Ute=X.detectionPipeline.getDeviceLiveContribution.useQuery,Wte=X.detectionPipeline.applyDeviceSettingsPatch.useMutation,Gte=X.deviceAdminLink.getAdminLink.useQuery,Kte=X.deviceAdoption.listCandidateFilters.useQuery,qte=X.deviceAdoption.listCandidates.useQuery,Jte=X.deviceAdoption.getCandidate.useQuery,Yte=X.deviceAdoption.refresh.useMutation,Xte=X.deviceAdoption.adopt.useMutation,Zte=X.deviceAdoption.release.useMutation,Qte=X.deviceAdoption.resync.useMutation,$te=X.deviceAdoption.getStatus.useQuery,ene=X.deviceCredentials.listDeviceCredentials.useQuery,tne=X.deviceCredentials.startEnrollment.useMutation,qf=X.deviceCredentials.revokeDeviceCredential.useMutation,Jf=X.deviceCredentials.getDeviceCertificateSettings.useQuery,Yf=X.deviceCredentials.setDeviceCertificateSettings.useMutation,Xf=X.deviceCredentials.deleteDeviceCredential.useMutation,Zf=X.deviceCredentials.getDeviceCaStatus.useQuery,Qf=X.deviceCredentials.renameDeviceCredential.useMutation,$f=X.deviceDiscovery.listDiscovered.useQuery,ep=X.deviceDiscovery.refreshDiscovery.useMutation,tp=X.deviceDiscovery.adoptDevice.useMutation,np=X.deviceDiscovery.releaseDevice.useMutation,rp=X.deviceDiscovery.getStatus.useQuery,ip=X.deviceExport.getStatus.useQuery,ap=X.deviceExport.listSupportedDeviceKinds.useQuery,op=X.deviceExport.listExposedDevices.useQuery,sp=X.deviceExport.exposeDevice.useMutation,cp=X.deviceExport.unexposeDevice.useMutation,lp=X.deviceExport.getDeviceSettingsContribution.useQuery,up=X.deviceExport.getDeviceLiveContribution.useQuery,dp=X.deviceExport.applyDeviceSettingsPatch.useMutation,fp=X.deviceExtension.listSources.useQuery,pp=X.deviceExtension.listSlots.useQuery,mp=X.deviceExtension.listCandidates.useQuery,hp=X.deviceExtension.setSlot.useMutation,gp=X.deviceHistory.listSeries.useQuery,_p=X.deviceHistory.listNodeSeries.useQuery,vp=X.deviceHistory.query.useQuery,yp=X.deviceHistory.queryNode.useQuery,bp=X.deviceHistory.queryMany.useQuery,xp=X.deviceHistory.declareSeries.useMutation,Sp=X.deviceHistory.record.useMutation,Cp=X.deviceHistory.recordBuckets.useMutation,wp=X.deviceHistory.getDeviceEnabled.useQuery,Tp=X.deviceHistory.setDeviceEnabled.useMutation,Ep=X.deviceHistory.getStatus.useQuery,Dp=X.deviceHistory.listOrphanSeries.useQuery,Op=X.deviceHistory.deleteOrphanSeries.useMutation,kp=X.deviceManager.allocateDeviceId.useMutation,Ap=X.deviceManager.migrateDevice.useMutation,jp=X.deviceManager.registerDevice.useMutation,Mp=X.deviceManager.removeDevice.useMutation,Np=X.deviceManager.persistConfig.useMutation,Pp=X.deviceManager.loadConfig.useQuery,Fp=X.deviceManager.loadRuntimeState.useQuery,Ip=X.deviceManager.loadMeta.useQuery,Lp=X.deviceManager.setName.useMutation,Rp=X.deviceManager.setLocation.useMutation,zp=X.deviceManager.setType.useMutation,Bp=X.deviceManager.setIntegrationId.useMutation,Vp=X.deviceManager.setLinkDeviceId.useMutation,Hp=X.deviceManager.setPrimaryChildEntityId.useMutation,Up=X.deviceManager.setChildLayout.useMutation,Wp=X.deviceManager.setDisplay.useMutation,Gp=X.deviceManager.getRoleDisplayDefaults.useQuery,Kp=X.deviceManager.setRoleDisplayDefaults.useMutation,qp=X.deviceManager.getWireableFields.useQuery,Jp=X.deviceManager.setRole.useMutation,Yp=X.deviceManager.applyInitialMeta.useMutation,Xp=X.deviceManager.setMetadata.useMutation,Zp=X.deviceManager.listLocations.useQuery,Qp=X.deviceManager.addLocation.useMutation,$p=X.deviceManager.removeLocation.useMutation,em=X.deviceManager.renameLocation.useMutation,tm=X.deviceManager.listLocationIcons.useQuery,nm=X.deviceManager.setLocationIcon.useMutation,rm=X.deviceManager.listLocationDescriptions.useQuery,im=X.deviceManager.setLocationDescription.useMutation,am=X.deviceManager.listSiteZones.useQuery,om=X.deviceManager.setSiteZone.useMutation,sm=X.deviceManager.removeSiteZone.useMutation,cm=X.deviceManager.renameSiteZone.useMutation,lm=X.deviceManager.setLocationZone.useMutation,nne=X.deviceManager.setDisabled.useMutation,um=X.deviceManager.listPersistedByAddon.useQuery,dm=X.deviceManager.listAll.useQuery,fm=X.deviceManager.getDevice.useQuery,pm=X.deviceManager.getChildren.useQuery,rne=X.deviceManager.getChildrenBatch.useQuery,ine=X.deviceManager.getLinkedDevices.useQuery,ane=X.deviceManager.getLinkedDevicesBatch.useQuery,one=X.deviceManager.getStreamSources.useQuery,sne=X.deviceManager.getConfigSchema.useQuery,cne=X.deviceManager.getSettingsSchema.useQuery,lne=X.deviceManager.updateConfig.useMutation,mm=X.deviceManager.enable.useMutation,hm=X.deviceManager.disable.useMutation,gm=X.deviceManager.remove.useMutation,_m=X.deviceManager.listDeletedSince.useQuery,vm=X.deviceManager.cleanupDeletedDevicesData.useMutation,ym=X.deviceManager.removeByIntegration.useMutation,bm=X.deviceManager.getStreamProfileMap.useQuery,xm=X.deviceManager.setStreamProfileMap.useMutation,Sm=X.deviceManager.probeStreams.useMutation,Cm=X.deviceManager.getBindings.useQuery,wm=X.deviceManager.getBindingsBatch.useQuery,Tm=X.deviceManager.getAllBindings.useQuery,Em=X.deviceManager.listDeviceIdsByCaps.useQuery,Dm=X.deviceManager.setWrapperActive.useMutation,Om=X.deviceManager.getWrapperActivation.useQuery,km=X.deviceManager.listWrappersForCap.useQuery,Am=X.deviceManager.listBindableCapsForDeviceType.useQuery,jm=X.deviceManager.getDeviceSettingsAggregate.useQuery,Mm=X.deviceManager.getDeviceLiveInfoAggregate.useQuery,Nm=X.deviceManager.getDeviceAggregate.useQuery,Pm=X.deviceManager.runDeviceAction.useMutation,Fm=X.deviceManager.updateDeviceField.useMutation,Im=X.deviceManager.updateDeviceFieldsBatch.useMutation,Lm=X.deviceManager.discoverDevices.useMutation,Rm=X.deviceManager.adoptDevice.useMutation,zm=X.deviceManager.getCreationSchema.useQuery,Bm=X.deviceManager.createDevice.useMutation,Vm=X.deviceManager.testCreationField.useMutation,Hm=X.deviceManager.adoptionListCandidateFilters.useQuery,Um=X.deviceManager.adoptionListCandidates.useQuery,Wm=X.deviceManager.adoptionRefresh.useMutation,Gm=X.deviceManager.adoptionAdopt.useMutation,Km=X.deviceManager.adoptionRelease.useMutation,qm=X.deviceManager.adoptionStartJob.useMutation,Jm=X.deviceManager.adoptionListJobs.useQuery,Ym=X.deviceManager.adoptionCancelJob.useMutation,Xm=X.deviceManager.adoptionResync.useMutation,Zm=X.deviceManager.discoveryProviders.useQuery,Qm=X.deviceManager.discoverAllProviders.useMutation,$m=X.deviceManager.discoverProvider.useMutation,eh=X.deviceManager.providerCreationType.useQuery,th=X.deviceManager.providerDiscoveryParamsSchema.useQuery,nh=X.deviceManager.testField.useMutation,rh=X.deviceManager.getDeviceStatusAggregate.useQuery,ih=X.deviceManager.getDeviceStatusAggregateBatch.useQuery,ah=X.deviceOps.getStreamSources.useQuery,oh=X.deviceOps.getConfigEntries.useQuery,sh=X.deviceOps.setConfig.useMutation,ch=X.deviceOps.runAction.useMutation,lh=X.deviceOps.removeDevice.useMutation,uh=X.deviceOps.getSettingsSchema.useQuery,dh=X.deviceOps.getRawState.useQuery,fh=X.deviceProvider.start.useMutation,ph=X.deviceProvider.stop.useMutation,mh=X.deviceProvider.getStatus.useQuery,hh=X.deviceProvider.getDevices.useQuery,gh=X.deviceProvider.reloadDevice.useMutation,_h=X.deviceProvider.supportsDiscovery.useQuery,vh=X.deviceProvider.discoverDevices.useMutation,yh=X.deviceProvider.getDiscoveryParamsSchema.useQuery,bh=X.deviceProvider.getManualCreationType.useQuery,xh=X.deviceProvider.adoptDiscoveredDevice.useMutation,Sh=X.deviceProvider.supportsManualCreation.useQuery,Ch=X.deviceProvider.getChildCreationSchema.useQuery,wh=X.deviceProvider.createDevice.useMutation,Th=X.deviceProvider.testCreationField.useMutation,Eh=X.deviceState.getSnapshot.useQuery,Dh=X.deviceState.getCapSlice.useQuery,Oh=X.deviceState.getAllSnapshots.useQuery,kh=X.deviceState.setCapSlice.useMutation,Ah=X.deviceState.claimFields.useMutation,jh=X.deviceState.patchOwnedFields.useMutation,Mh=X.deviceState.releaseClaim.useMutation,Nh=X.deviceState.listClaims.useQuery,Ph=X.deviceState.getNativeCapSlice.useQuery,Fh=X.deviceStatus.getStatus.useQuery,Ih=X.dishwasher.start.useMutation,Lh=X.dishwasher.pause.useMutation,Rh=X.dishwasher.resume.useMutation,zh=X.dishwasher.stop.useMutation,Bh=X.dishwasher.setProgram.useMutation,Vh=X.dishwasher.setPower.useMutation,Hh=X.dishwasher.setHalfLoad.useMutation,Uh=X.dishwasher.setHygienePlus.useMutation,Wh=X.dishwasher.setExtraDry.useMutation,Gh=X.dishwasher.setIntensiveZone.useMutation,Kh=X.dishwasher.setVarioSpeedPlus.useMutation,qh=X.dishwasher.setChildLock.useMutation,Jh=X.dishwasher.setOption.useMutation,Yh=X.dishwasher.getOptions.useQuery,Xh=X.dishwasher.getStatus.useQuery,Zh=X.displayPalette.getPalette.useQuery,Qh=X.displayPalette.listPresets.useQuery,$h=X.displayPalette.setPalette.useMutation,eg=X.doorbell.getStatus.useQuery,tg=X.enumSensor.getStatus.useQuery,ng=X.eventEmitter.getStatus.useQuery,rg=X.faceGallery.listIdentities.useQuery,ig=X.faceGallery.createIdentity.useMutation,ag=X.faceGallery.renameIdentity.useMutation,og=X.faceGallery.deleteIdentity.useMutation,sg=X.faceGallery.listIdentitySamples.useQuery,cg=X.faceGallery.auditIdentitySamples.useQuery,lg=X.faceGallery.removeSample.useMutation,ug=X.faceGallery.listRecentFaces.useQuery,dg=X.faceGallery.getFaceByTrack.useQuery,fg=X.faceGallery.getFaceMedia.useQuery,pg=X.faceGallery.assignFace.useMutation,mg=X.faceGallery.unassignFace.useMutation,hg=X.faceGallery.deleteFace.useMutation,gg=X.faceGallery.assignFaces.useMutation,_g=X.faceGallery.unassignFaces.useMutation,vg=X.faceGallery.suggestFaceClusters.useQuery,yg=X.fanControl.setPercentage.useMutation,bg=X.fanControl.setPreset.useMutation,xg=X.fanControl.setDirection.useMutation,Sg=X.fanControl.setOscillating.useMutation,Cg=X.fanControl.getStatus.useQuery,wg=X.featureProbe.getStatus.useQuery,Tg=X.flood.getStatus.useQuery,Eg=X.gas.getStatus.useQuery,Dg=X.groupActive.getStatus.useQuery,Og=X.groupCommands.getStatus.useQuery,kg=X.groupStatus.getStatus.useQuery,Ag=X.heatingValve.getStatus.useQuery,jg=X.humidifier.setOn.useMutation,Mg=X.humidifier.setTargetHumidity.useMutation,Ng=X.humidifier.setMode.useMutation,Pg=X.humidifier.getStatus.useQuery,Fg=X.humiditySensor.getStatus.useQuery,Ig=X.image.getStatus.useQuery,Lg=X.imageSettings.getOptions.useQuery,Rg=X.imageSettings.setSettings.useMutation,zg=X.imageSettings.getStatus.useQuery,Bg=X.integrations.list.useQuery,Vg=X.integrations.get.useQuery,Hg=X.integrations.getByAddonId.useQuery,Ug=X.integrations.create.useMutation,Wg=X.integrations.update.useMutation,Gg=X.integrations.delete.useMutation,Kg=X.integrations.getSettings.useQuery,qg=X.integrations.setSettings.useMutation,Jg=X.integrations.getAvailableTypes.useQuery,Yg=X.integrations.testConnection.useMutation,Xg=X.intercom.startSession.useMutation,Zg=X.intercom.handleAnswer.useMutation,Qg=X.intercom.stopSession.useMutation,$g=X.intercom.startTalkSession.useMutation,e_=X.intercom.pushTalkAudio.useMutation,t_=X.intercom.endTalkSession.useMutation,n_=X.intercom.getStatus.useQuery,r_=X.irTransmitter.send.useMutation,i_=X.irTransmitter.getInfo.useQuery,a_=X.keychainAdmin.status.useQuery,o_=X.keychainAdmin.listSecrets.useQuery,s_=X.keychainAdmin.listAudit.useQuery,c_=X.keychainAdmin.reveal.useMutation,l_=X.keychainAdmin.setSystemSecret.useMutation,u_=X.keychainAdmin.importSecret.useMutation,d_=X.keychainAdmin.deleteOrphans.useMutation,f_=X.keychainAdmin.rotateMasterKey.useMutation,p_=X.keychainAdmin.purgeRetiredKeys.useMutation,m_=X.keychainAdmin.downloadRecoveryKey.useMutation,h_=X.keychainAdmin.resetKeychain.useMutation,g_=X.keychainAdmin.resetReport.useQuery,__=X.keychainAdmin.acknowledgeReset.useMutation,v_=X.lawnMowerControl.startMowing.useMutation,y_=X.lawnMowerControl.pause.useMutation,b_=X.lawnMowerControl.dock.useMutation,x_=X.lawnMowerControl.getStatus.useQuery,une=X.llm.generate.useMutation,dne=X.llm.generateVision.useMutation,fne=X.llm.cancel.useMutation,pne=X.llm.listProfileKinds.useQuery,mne=X.llm.listProfiles.useQuery,hne=X.llm.upsertProfile.useMutation,gne=X.llm.migrateRawSecrets.useMutation,_ne=X.llm.deleteProfile.useMutation,vne=X.llm.testProfile.useMutation,yne=X.llm.listModels.useMutation,bne=X.llm.getDefaults.useQuery,xne=X.llm.setDefault.useMutation,Sne=X.llm.getUsage.useQuery,Cne=X.llm.listModelCatalog.useQuery,wne=X.llm.listRuntimeNodes.useQuery,Tne=X.llm.listNodeModels.useQuery,Ene=X.llm.resolveModelRef.useMutation,Dne=X.llm.installModel.useMutation,One=X.llm.deleteModel.useMutation,kne=X.llm.getRuntimeStatus.useQuery,Ane=X.llm.startRuntime.useMutation,jne=X.llm.stopRuntime.useMutation,S_=X.localNetwork.list.useQuery,Mne=X.localNetwork.getPreferred.useQuery,C_=X.localNetwork.getConnectionEndpoints.useQuery,Nne=X.localNetwork.getNotificationEndpoint.useQuery,Pne=X.localNetwork.setNotificationEndpoint.useMutation,Fne=X.localNetwork.getViewerEndpoints.useQuery,Ine=X.localNetwork.setViewerEndpoints.useMutation,w_=X.localNetwork.getAddresses.useQuery,T_=X.localNetwork.addCustomAddress.useMutation,E_=X.localNetwork.removeCustomAddress.useMutation,D_=X.localNetwork.setAddressRole.useMutation,Lne=X.localNetwork.getHubAddresses.useQuery,O_=X.localNetwork.getAllowedAddresses.useQuery,k_=X.localNetwork.setAllowedAddresses.useMutation,A_=X.localNetwork.resetAllowlistToBestMatch.useMutation,j_=X.localNetwork.getTlsStatus.useQuery,M_=X.localNetwork.regenerateCertificate.useMutation,N_=X.localNetwork.uploadCertificate.useMutation,Rne=X.localNetwork.downloadCa.useQuery,P_=X.localNetwork.useStoredUploadedCertificate.useMutation,F_=X.localNetwork.revertToGeneratedCertificate.useMutation,I_=X.lockControl.lock.useMutation,L_=X.lockControl.unlock.useMutation,zne=X.lockControl.open.useMutation,Bne=X.lockControl.getStatus.useQuery,Vne=X.mediaPlayer.play.useMutation,Hne=X.mediaPlayer.pause.useMutation,Une=X.mediaPlayer.stop.useMutation,Wne=X.mediaPlayer.next.useMutation,Gne=X.mediaPlayer.previous.useMutation,Kne=X.mediaPlayer.seek.useMutation,qne=X.mediaPlayer.setVolume.useMutation,Jne=X.mediaPlayer.setMute.useMutation,Yne=X.mediaPlayer.setShuffle.useMutation,Xne=X.mediaPlayer.setRepeat.useMutation,Zne=X.mediaPlayer.selectSource.useMutation,Qne=X.mediaPlayer.playMedia.useMutation,$ne=X.mediaPlayer.getStatus.useQuery,R_=X.meshNetwork.getStatus.useQuery,ere=X.meshNetwork.join.useMutation,z_=X.meshNetwork.startLogin.useMutation,B_=X.meshNetwork.leave.useMutation,V_=X.meshNetwork.logout.useMutation,H_=X.meshNetwork.listPeers.useQuery,tre=X.meshNetwork.testConnection.useMutation,nre=X.meter.getStatus.useQuery,rre=X.metricsProvider.collectSnapshot.useQuery,ire=X.metricsProvider.getCached.useQuery,are=X.metricsProvider.getCurrent.useQuery,ore=X.metricsProvider.getDiskSpace.useQuery,sre=X.metricsProvider.getGpuInfo.useQuery,cre=X.metricsProvider.getCpuTemperature.useQuery,lre=X.metricsProvider.getProcessStats.useQuery,ure=X.metricsProvider.listAddonInstances.useQuery,dre=X.metricsProvider.getAddonStats.useQuery,U_=X.metricsProvider.listNodeProcesses.useQuery,W_=X.metricsProvider.getLoadSeries.useQuery,fre=X.motion.isDetected.useQuery,pre=X.motion.getStatus.useQuery,mre=X.motionDetection.analyze.useMutation,hre=X.motionDetection.removeCamera.useMutation,G_=X.motionDetection.reset.useMutation,K_=X.motionDetection.getDeviceSettingsContribution.useQuery,q_=X.motionDetection.getDeviceLiveContribution.useQuery,J_=X.motionDetection.applyDeviceSettingsPatch.useMutation,Y_=X.motionTrigger.setMotionTrigger.useMutation,X_=X.motionTrigger.getStatus.useQuery,Z_=X.motionZones.getOptions.useQuery,Q_=X.motionZones.setZone.useMutation,$_=X.motionZones.getStatus.useQuery,ev=X.mqttBroker.listBrokers.useQuery,tv=X.mqttBroker.getBrokerConfig.useQuery,nv=X.mqttBroker.addBroker.useMutation,rv=X.mqttBroker.removeBroker.useMutation,iv=X.mqttBroker.testConnection.useMutation,av=X.mqttBroker.startEmbeddedBroker.useMutation,ov=X.mqttBroker.stopEmbeddedBroker.useMutation,sv=X.mqttBroker.getStatus.useQuery,cv=X.nativeObjectDetection.getOptions.useQuery,lv=X.nativeObjectDetection.setSettings.useMutation,uv=X.nativeObjectDetection.setEnabled.useMutation,dv=X.nativeObjectDetection.getStatus.useQuery,fv=X.navigation.move.useMutation,pv=X.navigation.stop.useMutation,mv=X.navigation.goToPoint.useMutation,hv=X.navigation.listActions.useQuery,gv=X.navigation.runAction.useMutation,_v=X.navigation.playSound.useMutation,vv=X.navigation.setLightOn.useMutation,yv=X.navigation.setLightMode.useMutation,bv=X.navigation.setLightLevel.useMutation,xv=X.navigation.getFeatures.useQuery,Sv=X.navigation.getStatus.useQuery,Cv=X.networkAccess.start.useMutation,wv=X.networkAccess.stop.useMutation,Tv=X.networkAccess.getEndpoint.useQuery,Ev=X.networkAccess.getStatus.useQuery,Dv=X.networkAccess.listEndpoints.useQuery,Ov=X.networkLink.getStatus.useQuery,kv=X.networkQuality.getDeviceStats.useQuery,Av=X.networkQuality.getAllStats.useQuery,jv=X.networkQuality.reportClientStats.useMutation,Mv=X.nodes.topology.useQuery,Nv=X.nodes.directory.useQuery,Pv=X.nodes.deployAddon.useMutation,Fv=X.nodes.undeployAddon.useMutation,Iv=X.nodes.restartAddon.useMutation,Lv=X.nodes.restartProcess.useMutation,Rv=X.nodes.restartNode.useMutation,zv=X.nodes.shutdownNode.useMutation,Bv=X.nodes.renameNode.useMutation,Vv=X.nodes.clusterAddonStatus.useQuery,Hv=X.nodes.getCapUsageGraph.useQuery,Uv=X.nodes.getNodeAddons.useQuery,Wv=X.nodes.setProcessLogLevel.useMutation,Gv=X.nodes.executeQuery.useMutation,Kv=X.notificationOutput.listTargetKinds.useQuery,qv=X.notificationOutput.listTargets.useQuery,Jv=X.notificationOutput.getTarget.useQuery,Yv=X.notificationOutput.discoverTargets.useQuery,Xv=X.notificationOutput.probeTargetConfig.useMutation,Zv=X.notificationOutput.send.useMutation,Qv=X.notificationOutput.testTarget.useMutation,$v=X.notificationOutput.upsertTarget.useMutation,ey=X.notificationOutput.deleteTarget.useMutation,ty=X.notificationOutput.setTargetEnabled.useMutation,ny=X.notificationRules.listRules.useQuery,ry=X.notificationRules.getRule.useQuery,iy=X.notificationRules.createRule.useMutation,ay=X.notificationRules.updateRule.useMutation,oy=X.notificationRules.deleteRule.useMutation,sy=X.notificationRules.setRuleEnabled.useMutation,cy=X.notificationRules.listSequences.useQuery,ly=X.notificationRules.getSequence.useQuery,uy=X.notificationRules.createSequence.useMutation,dy=X.notificationRules.updateSequence.useMutation,fy=X.notificationRules.deleteSequence.useMutation,py=X.notificationRules.getClipRetentionAsks.useQuery,my=X.notificationRules.listDeviceMutes.useQuery,hy=X.notificationRules.setDeviceMuted.useMutation,gy=X.notificationRules.testRule.useMutation,_y=X.notificationRules.previewStateSummary.useMutation,vy=X.notificationRules.getConditionCatalog.useQuery,yy=X.notificationRules.getTemplateCatalog.useQuery,by=X.notificationRules.previewTemplate.useMutation,xy=X.notificationRules.getHistory.useQuery,Sy=X.notificationRules.getRuleLastRuns.useQuery,Cy=X.notificationRules.resolveArtifactUrl.useQuery,wy=X.notificationRules.listSnoozes.useQuery,Ty=X.notificationRules.createSnooze.useMutation,Ey=X.notificationRules.cancelSnooze.useMutation,Dy=X.notificationRules.getAlarmConfig.useQuery,Oy=X.notificationRules.setAlarmConfig.useMutation,ky=X.notificationRules.createAlarmProfile.useMutation,Ay=X.notificationRules.renameAlarmProfile.useMutation,jy=X.notificationRules.deleteAlarmProfile.useMutation,My=X.notificationRules.activateAlarmProfile.useMutation,Ny=X.notificationRules.getAlarmSensors.useQuery,Py=X.notifier.send.useMutation,Fy=X.notifier.cancel.useMutation,Iy=X.notifier.getStatus.useQuery,Ly=X.numericSensor.getStatus.useQuery,Ry=X.oidcConnections.connectionFormSchema.useQuery,zy=X.oidcConnections.listConnections.useQuery,By=X.oidcConnections.createConnection.useMutation,Vy=X.oidcConnections.updateConnection.useMutation,Hy=X.oidcConnections.deleteConnection.useMutation,Uy=X.osd.setOverlay.useMutation,Wy=X.osd.getStatus.useQuery,Gy=X.osdManager.getDeviceOsd.useQuery,Ky=X.osdManager.getSourceCatalog.useQuery,qy=X.osdManager.getConditionSupport.useQuery,Jy=X.osdManager.setSlotBinding.useMutation,Yy=X.osdManager.clearSlotBinding.useMutation,Xy=X.osdManager.setSlotCameraEnabled.useMutation,Zy=X.osdManager.copyDeviceConfiguration.useMutation,Qy=X.osdManager.previewSlot.useMutation,$y=X.osdManager.renderDevice.useMutation,eb=X.osdManager.listTemplates.useQuery,tb=X.osdManager.upsertTemplate.useMutation,nb=X.osdManager.deleteTemplate.useMutation,rb=X.petFeeder.feed.useMutation,ib=X.petFeeder.cancelFeed.useMutation,ab=X.petFeeder.resetDesiccant.useMutation,ob=X.petFeeder.markFoodReplenished.useMutation,sb=X.petFeeder.callPet.useMutation,cb=X.petFeeder.playSound.useMutation,lb=X.petFeeder.setChildLock.useMutation,ub=X.petFeeder.setIndicatorLight.useMutation,db=X.petFeeder.setFeedSound.useMutation,fb=X.petFeeder.setVolume.useMutation,pb=X.petFeeder.getStatus.useQuery,mb=X.pipelineAnalytics.getActiveTracks.useQuery,hb=X.pipelineAnalytics.getTrack.useQuery,gb=X.pipelineAnalytics.listTracks.useQuery,_b=X.pipelineAnalytics.listRecentTracks.useQuery,vb=X.pipelineAnalytics.clearTracks.useMutation,yb=X.pipelineAnalytics.getMotionEvents.useQuery,bb=X.pipelineAnalytics.getObjectEvents.useQuery,xb=X.pipelineAnalytics.getAudioEvents.useQuery,Sb=X.pipelineAnalytics.listEventKinds.useQuery,Cb=X.pipelineAnalytics.listEventKindsBatch.useQuery,wb=X.pipelineAnalytics.getSensorEvents.useQuery,Tb=X.pipelineAnalytics.getKeyEvents.useQuery,Eb=X.pipelineAnalytics.getKeyEventsBatch.useQuery,Db=X.pipelineAnalytics.readLongTermSeries.useQuery,Ob=X.pipelineAnalytics.getEventDensity.useQuery,kb=X.pipelineAnalytics.getEventDensityBatch.useQuery,Ab=X.pipelineAnalytics.pruneEventsBefore.useMutation,jb=X.pipelineAnalytics.pruneTracksBefore.useMutation,Mb=X.pipelineAnalytics.wipeAllAnalytics.useMutation,Nb=X.pipelineAnalytics.reconcileFromDisk.useMutation,Pb=X.pipelineAnalytics.deleteTracks.useMutation,Fb=X.pipelineAnalytics.setTrackFlags.useMutation,Ib=X.pipelineAnalytics.listArchivedDebugNotes.useQuery,Lb=X.pipelineAnalytics.setTrackRelation.useMutation,Rb=X.pipelineAnalytics.clearTrackRelation.useMutation,zb=X.pipelineAnalytics.setTrackPurity.useMutation,Bb=X.pipelineAnalytics.listTrackRelations.useQuery,Vb=X.pipelineAnalytics.listBirthDecisions.useQuery,Hb=X.pipelineAnalytics.getEventStoreFootprint.useQuery,Ub=X.pipelineAnalytics.getEventMediaFootprintByKind.useQuery,Wb=X.pipelineAnalytics.pruneEvents.useMutation,Gb=X.pipelineAnalytics.deleteDeviceEvents.useMutation,Kb=X.pipelineAnalytics.pauseForStorageMigration.useMutation,qb=X.pipelineAnalytics.resumeForStorageMigration.useMutation,Jb=X.pipelineAnalytics.refreshStorageLocationsForMigration.useMutation,Yb=X.pipelineAnalytics.startStorageMigrationMove.useMutation,Xb=X.pipelineAnalytics.getStorageMigrationMoveStatus.useQuery,Zb=X.pipelineAnalytics.cancelStorageMigrationMove.useMutation,Qb=X.pipelineAnalytics.relocateMedia.useMutation,$b=X.pipelineAnalytics.countUnstampedEventMedia.useQuery,ex=X.pipelineAnalytics.countRelocatableMedia.useQuery,tx=X.pipelineAnalytics.listRelocateMediaJobs.useQuery,nx=X.pipelineAnalytics.cancelRelocateMedia.useMutation,rx=X.pipelineAnalytics.listOpsLog.useQuery,ix=X.pipelineAnalytics.reclaimDebugMedia.useMutation,ax=X.pipelineAnalytics.getMediaReclaimStatus.useQuery,ox=X.pipelineAnalytics.getTrainingExportSummary.useQuery,sx=X.pipelineAnalytics.getTrainingExportUrl.useQuery,cx=X.pipelineAnalytics.listRetrainStaging.useQuery,lx=X.pipelineAnalytics.listRetrainCorpusPage.useQuery,ux=X.pipelineAnalytics.getRetrainCorpusKpi.useQuery,dx=X.pipelineAnalytics.listRetrainFrames.useQuery,fx=X.pipelineAnalytics.selectRetrainFrames.useMutation,px=X.pipelineAnalytics.deselectRetrainFrame.useMutation,mx=X.pipelineAnalytics.getRetrainFrameImage.useQuery,hx=X.pipelineAnalytics.proposeRetrainAnnotations.useMutation,gx=X.pipelineAnalytics.listRetrainAnnotations.useQuery,_x=X.pipelineAnalytics.saveRetrainAnnotations.useMutation,vx=X.pipelineAnalytics.backfillRetrainOrigins.useMutation,yx=X.pipelineAnalytics.completeRetrainTrack.useMutation,bx=X.pipelineAnalytics.restageRetrainTrack.useMutation,xx=X.pipelineAnalytics.getRetrainExportUrl.useQuery,Sx=X.pipelineAnalytics.setRetrainFrameComplete.useMutation,Cx=X.pipelineAnalytics.writeRetrainArchive.useMutation,wx=X.pipelineAnalytics.offerRetrainArchive.useMutation,Tx=X.pipelineAnalytics.listRetrainAssistProfiles.useQuery,Ex=X.pipelineAnalytics.proposeRetrainAnnotationsWithLlm.useMutation,Dx=X.pipelineAnalytics.createRetrainCollection.useMutation,Ox=X.pipelineAnalytics.listRetrainCollections.useQuery,kx=X.pipelineAnalytics.resolveRetrainTrainingCorpus.useQuery,Ax=X.pipelineAnalytics.renameRetrainCollection.useMutation,jx=X.pipelineAnalytics.deleteRetrainCollection.useMutation,Mx=X.pipelineAnalytics.addRetrainFrameFromRecording.useMutation,Nx=X.pipelineAnalytics.addRetrainFramesToCollection.useMutation,Px=X.pipelineAnalytics.removeRetrainFrameFromCollection.useMutation,Fx=X.pipelineAnalytics.listRetrainCollectionFrames.useQuery,Ix=X.pipelineAnalytics.getEventMedia.useQuery,Lx=X.pipelineAnalytics.getTrackMedia.useQuery,Rx=X.pipelineAnalytics.listTrackMedia.useQuery,zx=X.pipelineAnalytics.listEventMedia.useQuery,Bx=X.pipelineAnalytics.ownersWithMedia.useQuery,Vx=X.pipelineAnalytics.searchObjectEvents.useQuery,Hx=X.pipelineAnalytics.wipeObjectEmbeddings.useMutation,Ux=X.pipelineAnalytics.rebuildObjectEmbeddings.useMutation,Wx=X.pipelineAnalytics.getObjectEmbeddingRebuildStatus.useQuery,Gx=X.pipelineAnalytics.getDeviceSettingsContribution.useQuery,Kx=X.pipelineAnalytics.getDeviceLiveContribution.useQuery,qx=X.pipelineAnalytics.applyDeviceSettingsPatch.useMutation,Jx=X.pipelineExecutor.getAvailableEngines.useQuery,Yx=X.pipelineExecutor.getSelectedEngine.useQuery,Xx=X.pipelineExecutor.getEngineProvisioning.useQuery,Zx=X.pipelineExecutor.getVideoPipelineSteps.useQuery,Qx=X.pipelineExecutor.setVideoPipelineSteps.useMutation,$x=X.pipelineExecutor.getInferenceDeviceHealth.useQuery,eS=X.pipelineExecutor.rearmInferenceDevice.useMutation,tS=X.pipelineExecutor.getSchema.useQuery,nS=X.pipelineExecutor.getOrchestratorConfigSchema.useQuery,rS=X.pipelineExecutor.validatePipeline.useQuery,iS=X.pipelineExecutor.getCapabilities.useQuery,aS=X.pipelineExecutor.getAddonModels.useQuery,oS=X.pipelineExecutor.downloadModel.useMutation,sS=X.pipelineExecutor.deleteModel.useMutation,cS=X.pipelineExecutor.runPipeline.useMutation,lS=X.pipelineExecutor.runPipelineBatch.useMutation,uS=X.pipelineExecutor.cacheFrameInPool.useMutation,dS=X.pipelineExecutor.inferCached.useMutation,fS=X.pipelineExecutor.uncacheFrame.useMutation,pS=X.pipelineExecutor.getEffectiveTuning.useQuery,mS=X.pipelineExecutor.listLoadedEngines.useQuery,hS=X.pipelineExecutor.spinEngine.useMutation,gS=X.pipelineExecutor.killEngine.useMutation,_S=X.pipelineExecutor.listReferenceImages.useQuery,vS=X.pipelineExecutor.getReferenceImage.useQuery,yS=X.pipelineExecutor.getReferenceAudioFiles.useQuery,bS=X.pipelineExecutor.getReferenceAudio.useQuery,xS=X.pipelineExecutor.getAudioCapabilities.useQuery,SS=X.pipelineExecutor.runAudioTest.useMutation,CS=X.pipelineExecutor.getDetectionConfigSchema.useQuery,wS=X.pipelineOrchestrator.requestOccupancyLook.useMutation,TS=X.pipelineOrchestrator.pauseForStorageMigration.useMutation,ES=X.pipelineOrchestrator.resumeForStorageMigration.useMutation,DS=X.pipelineOrchestrator.assignPipeline.useMutation,OS=X.pipelineOrchestrator.unassignPipeline.useMutation,kS=X.pipelineOrchestrator.setPipelineDevicePin.useMutation,AS=X.pipelineOrchestrator.getPipelineDevicePin.useQuery,jS=X.pipelineOrchestrator.rebalance.useMutation,MS=X.pipelineOrchestrator.getPipelineAssignments.useQuery,NS=X.pipelineOrchestrator.getPipelineAssignment.useQuery,PS=X.pipelineOrchestrator.getAgentLoad.useQuery,FS=X.pipelineOrchestrator.getClusterModelChoice.useQuery,IS=X.pipelineOrchestrator.getGlobalMetrics.useQuery,LS=X.pipelineOrchestrator.getCameraMetrics.useQuery,RS=X.pipelineOrchestrator.getCapabilityBindings.useQuery,zS=X.pipelineOrchestrator.setCapabilityBinding.useMutation,BS=X.pipelineOrchestrator.getIngestOwner.useQuery,VS=X.pipelineOrchestrator.assignAudio.useMutation,HS=X.pipelineOrchestrator.unassignAudio.useMutation,US=X.pipelineOrchestrator.getAudioAssignment.useQuery,WS=X.pipelineOrchestrator.getAudioNodeLoad.useQuery,GS=X.pipelineOrchestrator.getAudioAssignments.useQuery,KS=X.pipelineOrchestrator.getAgentSettings.useQuery,qS=X.pipelineOrchestrator.listAgentSettings.useQuery,JS=X.pipelineOrchestrator.removeAgentSettings.useMutation,YS=X.pipelineOrchestrator.setAgentMaxCameras.useMutation,XS=X.pipelineOrchestrator.setAgentCapabilities.useMutation,ZS=X.pipelineOrchestrator.setAgentDecodeLimits.useMutation,QS=X.pipelineOrchestrator.setAgentReachableHost.useMutation,$S=X.pipelineOrchestrator.setAgentInferenceDevices.useMutation,eC=X.pipelineOrchestrator.setNodeStepSettings.useMutation,tC=X.pipelineOrchestrator.getNodeInferenceDevices.useQuery,nC=X.pipelineOrchestrator.forgetInferenceDevice.useMutation,rC=X.pipelineOrchestrator.resetNodePipelineDefaults.useMutation,iC=X.pipelineOrchestrator.planAutoTune.useQuery,aC=X.pipelineOrchestrator.applyAutoTune.useMutation,oC=X.pipelineOrchestrator.setLoadBalancingShares.useMutation,sC=X.pipelineOrchestrator.getPlacementStats.useQuery,cC=X.pipelineOrchestrator.suggestShares.useQuery,lC=X.pipelineOrchestrator.getEffectiveShares.useQuery,uC=X.pipelineOrchestrator.setShareSource.useMutation,dC=X.pipelineOrchestrator.getNodeBenchmarkPreflight.useQuery,fC=X.pipelineOrchestrator.startNodeBenchmark.useMutation,pC=X.pipelineOrchestrator.getNodeBenchmarkStatus.useQuery,mC=X.pipelineOrchestrator.abortNodeBenchmark.useMutation,hC=X.pipelineOrchestrator.getNodeBenchmarkCandidates.useQuery,gC=X.pipelineOrchestrator.listNodeBenchmarkResults.useQuery,_C=X.pipelineOrchestrator.deleteNodeBenchmarkResult.useMutation,vC=X.pipelineOrchestrator.getCameraSettings.useQuery,yC=X.pipelineOrchestrator.setCameraStepToggle.useMutation,bC=X.pipelineOrchestrator.getCameraDetectionSource.useQuery,xC=X.pipelineOrchestrator.setCameraDetectionSource.useMutation,SC=X.pipelineOrchestrator.setCameraStepSettings.useMutation,CC=X.pipelineOrchestrator.resolvePipeline.useQuery,wC=X.pipelineOrchestrator.getCameraSwitches.useQuery,TC=X.pipelineOrchestrator.setCameraSwitch.useMutation,EC=X.pipelineOrchestrator.getCameraStatus.useQuery,DC=X.pipelineOrchestrator.getCameraStatuses.useQuery,OC=X.pipelineOrchestrator.setCameraSensors.useMutation,kC=X.pipelineOrchestrator.reconcileFromDisk.useMutation,AC=X.pipelineOrchestrator.getReconcileFromDiskStatus.useQuery,jC=X.pipelineOrchestrator.getDeviceSettingsContribution.useQuery,MC=X.pipelineOrchestrator.getDeviceLiveContribution.useQuery,NC=X.pipelineOrchestrator.applyDeviceSettingsPatch.useMutation,PC=X.pipelineRunner.attachCamera.useMutation,FC=X.pipelineRunner.detachCamera.useMutation,IC=X.pipelineRunner.reportMotion.useMutation,LC=X.pipelineRunner.getLocalLoad.useQuery,RC=X.pipelineRunner.getLocalMetrics.useQuery,zC=X.pipelineRunner.getCameraMetrics.useQuery,BC=X.pipelineRunner.getAllCameraMetrics.useQuery,VC=X.pipelineRunner.getLocalCameras.useQuery,HC=X.pipelineRunner.requestOccupancyBurst.useMutation,UC=X.pipelineRunner.getNativeCrop.useQuery,WC=X.pipelineRunner.runDetailSubtree.useMutation,GC=X.pipelineRunner.runStatelessStep.useMutation,KC=X.pipelineRunner.parkTrackFrame.useMutation,qC=X.pipelineRunner.getParkedTrackFrame.useQuery,JC=X.pipelineRunner.releaseParkedTrackFrames.useMutation,YC=X.pipelineRunner.startNodeBench.useMutation,XC=X.pipelineRunner.getNodeBenchStatus.useQuery,ZC=X.pipelineRunner.abortNodeBench.useMutation,QC=X.plateGallery.listPlates.useQuery,$C=X.plateGallery.getPlateByTrack.useQuery,ew=X.plateGallery.getPlateMedia.useQuery,tw=X.plateGallery.searchPlates.useQuery,nw=X.plateGallery.suggestPlateClusters.useQuery,rw=X.plateGallery.correctPlateText.useMutation,iw=X.plateGallery.deletePlate.useMutation,aw=X.plateGallery.listVehicles.useQuery,ow=X.plateGallery.createVehicle.useMutation,sw=X.plateGallery.renameVehicle.useMutation,cw=X.plateGallery.deleteVehicle.useMutation,lw=X.plateGallery.listVehicleSamples.useQuery,uw=X.plateGallery.removeVehicleSample.useMutation,dw=X.plateGallery.assignPlate.useMutation,fw=X.plateGallery.unassignPlate.useMutation,pw=X.plateGallery.assignPlates.useMutation,mw=X.plateGallery.unassignPlates.useMutation,hw=X.powerMeter.getStatus.useQuery,gw=X.presence.getStatus.useQuery,_w=X.pressureSensor.getStatus.useQuery,vw=X.privacyMask.getOptions.useQuery,yw=X.privacyMask.setMask.useMutation,bw=X.privacyMask.setAudioEnabled.useMutation,xw=X.privacyMask.getStatus.useQuery,Sw=X.ptz.move.useMutation,Cw=X.ptz.continuousMove.useMutation,ww=X.ptz.stop.useMutation,Tw=X.ptz.getPresets.useQuery,Ew=X.ptz.goToPreset.useMutation,Dw=X.ptz.savePreset.useMutation,Ow=X.ptz.deletePreset.useMutation,kw=X.ptz.getOptions.useQuery,Aw=X.ptz.goHome.useMutation,jw=X.ptz.getHomePreset.useQuery,Mw=X.ptz.setHomePreset.useMutation,Nw=X.ptz.captureHomeHere.useMutation,Pw=X.ptz.getHomeReturn.useQuery,Fw=X.ptz.setHomeReturn.useMutation,Iw=X.ptz.getPosition.useQuery,Lw=X.ptz.setAutofocus.useMutation,Rw=X.ptz.getStatus.useQuery,zw=X.ptzAutotrack.getStatus.useQuery,Bw=X.ptzAutotrack.setEnabled.useMutation,Vw=X.ptzAutotrack.getSettings.useQuery,Hw=X.ptzAutotrack.setSettings.useMutation,Uw=X.reboot.reboot.useMutation,Ww=X.recordEntries.listEntryKinds.useQuery,Gw=X.recordEntries.listEntries.useQuery,Kw=X.recordEntries.putEntry.useMutation,qw=X.recordEntries.deleteEntry.useMutation,Jw=X.recording.listSources.useQuery,Yw=X.recording.getAvailability.useQuery,Xw=X.recording.getDaysWithRecordings.useQuery,Zw=X.recording.getPlayback.useQuery,Qw=X.recording.getPlaybackOptions.useQuery,$w=X.recordingArchive.getAvailabilityBatch.useQuery,eT=X.recordingArchive.getDaysWithRecordingsBatch.useQuery,tT=X.recordingArchive.getStorageUsage.useQuery,nT=X.recordingArchive.getDeviceConfig.useQuery,rT=X.recordingArchive.locateSegment.useQuery,iT=X.recordingArchive.readSegmentBytes.useQuery,aT=X.recordingArchive.readGopBytes.useQuery,oT=X.recordingArchive.readWindowBytes.useQuery,sT=X.recordingArchive.setDeviceConfig.useMutation,cT=X.recordingArchive.rescanStorage.useMutation,lT=X.recordingArchive.pruneFootage.useMutation,uT=X.recordingArchive.deleteFootprint.useMutation,dT=X.recordingArchive.listOpsLog.useQuery,fT=X.recordingArchive.renderGif.useMutation,pT=X.recordingArchive.renderClip.useMutation,mT=X.recordingArchive.pauseForStorageMigration.useMutation,hT=X.recordingArchive.resumeForStorageMigration.useMutation,gT=X.recordingArchive.refreshStorageLocationsForMigration.useMutation,_T=X.recordingArchive.startStorageMigrationMove.useMutation,vT=X.recordingArchive.getStorageMigrationMoveStatus.useQuery,yT=X.recordingArchive.cancelStorageMigrationMove.useMutation,bT=X.recordingArchive.relocateFootage.useMutation,xT=X.recordingArchive.listRelocateJobs.useQuery,ST=X.recordingArchive.getRelocateResidue.useQuery,CT=X.recordingArchive.reconcileLedgerAgainstDisk.useMutation,wT=X.recordingArchive.cancelRelocateJob.useMutation,TT=X.recordingArchive.planStorageRebalance.useQuery,ET=X.recordingArchive.startStorageRebalance.useMutation,DT=X.recordingArchive.getPlacement.useQuery,OT=X.recordingArchive.setDevicePlacement.useMutation,kT=X.recordingArchive.getStatus.useQuery,AT=X.recordingArchive.getDeviceSettingsContribution.useQuery,jT=X.recordingArchive.getDeviceLiveContribution.useQuery,MT=X.recordingArchive.applyDeviceSettingsPatch.useMutation,NT=X.recordingExport.createExport.useMutation,PT=X.recordingExport.listExports.useQuery,FT=X.recordingExport.getExport.useQuery,IT=X.recordingExport.cancelExport.useMutation,LT=X.recordingExport.deleteExport.useMutation,RT=X.recordingExport.getDownloadUrl.useQuery,zT=X.recordingExport.readExportBytes.useQuery,BT=X.recordingOnboard.getOptions.useQuery,VT=X.recordingOnboard.setSettings.useMutation,HT=X.recordingOnboard.getStatus.useQuery,UT=X.recordingSignal.getStatus.useQuery,WT=X.runningState.getStatus.useQuery,GT=X.sceneMonitor.listScenes.useQuery,KT=X.sceneMonitor.listScenesBatch.useQuery,qT=X.sceneMonitor.createScene.useMutation,JT=X.sceneMonitor.updateScene.useMutation,YT=X.sceneMonitor.deleteScene.useMutation,XT=X.sceneMonitor.captureReference.useMutation,ZT=X.sceneMonitor.deleteReference.useMutation,QT=X.sceneMonitor.recheckNow.useMutation,$T=X.sceneMonitor.resetScene.useMutation,eE=X.sceneMonitor.getStatus.useQuery,tE=X.scriptRunner.run.useMutation,nE=X.scriptRunner.stop.useMutation,rE=X.scriptRunner.getStatus.useQuery,iE=X.serverManagement.getServerPackageStatus.useQuery,aE=X.serverManagement.checkServerUpdate.useMutation,oE=X.serverManagement.applyServerUpdate.useMutation,sE=X.serverManagement.rollbackServerUpdate.useMutation,cE=X.serverManagement.restartServer.useMutation,lE=X.settingsStore.get.useQuery,uE=X.settingsStore.set.useMutation,dE=X.settingsStore.query.useQuery,fE=X.settingsStore.upsert.useMutation,pE=X.settingsStore.upsertMany.useMutation,mE=X.settingsStore.insert.useMutation,hE=X.settingsStore.insertMany.useMutation,gE=X.settingsStore.transact.useMutation,_E=X.settingsStore.update.useMutation,vE=X.settingsStore.delete.useMutation,yE=X.settingsStore.deleteWhere.useMutation,bE=X.settingsStore.updateWhere.useMutation,xE=X.settingsStore.count.useQuery,SE=X.settingsStore.aggregate.useQuery,CE=X.settingsStore.histogram.useQuery,wE=X.settingsStore.isEmpty.useQuery,TE=X.settingsStore.declareCollection.useMutation,EE=X.smoke.getStatus.useQuery,DE=X.snapshot.getSnapshot.useQuery,OE=X.snapshot.invalidateCache.useMutation,kE=X.snapshot.getSnapshotOverview.useQuery,AE=X.snapshot.getDebugState.useQuery,jE=X.snapshot.getSnapshotLinks.useQuery,ME=X.snapshot.getStatus.useQuery,NE=X.snapshot.getDeviceSettingsContribution.useQuery,PE=X.snapshot.getDeviceLiveContribution.useQuery,FE=X.snapshot.applyDeviceSettingsPatch.useMutation,IE=X.storage.resolve.useQuery,LE=X.storage.write.useMutation,RE=X.storage.read.useQuery,zE=X.storage.exists.useQuery,BE=X.storage.list.useQuery,VE=X.storage.delete.useMutation,HE=X.storage.getAvailableSpace.useQuery,UE=X.storage.beginUpload.useMutation,WE=X.storage.writeChunk.useMutation,GE=X.storage.finalizeUpload.useMutation,KE=X.storage.abortUpload.useMutation,qE=X.storage.beginDownload.useMutation,JE=X.storage.readChunk.useQuery,YE=X.storage.endDownload.useMutation,XE=X.storage.listLocations.useQuery,ZE=X.storage.listLocationDeclarations.useQuery,QE=X.storage.upsertLocation.useMutation,$E=X.storage.deleteLocation.useMutation,eD=X.storage.listDrainProgress.useQuery,tD=X.storage.testLocation.useQuery,nD=X.storage.listProviders.useQuery,rD=X.storage.testConfig.useQuery,iD=X.storageMigration.plan.useQuery,aD=X.storageMigration.start.useMutation,oD=X.storageMigration.status.useQuery,sD=X.storageMigration.cancel.useMutation,cD=X.storageMigration.movers.useQuery,lD=X.storageMigration.moverClearance.useQuery,uD=X.storageMigration.residue.useQuery,dD=X.storageMigration.drain.useMutation,fD=X.storageMigration.cleanupStart.useMutation,pD=X.storageMigration.cleanupStatus.useQuery,mD=X.storageMigration.cleanupCancel.useMutation,hD=X.storageMigration.history.useQuery,gD=X.streamBroker.reportStreamSignal.useMutation,_D=X.streamBroker.publishCameraStream.useMutation,vD=X.streamBroker.retractCameraStream.useMutation,yD=X.streamBroker.assignProfile.useMutation,bD=X.streamBroker.unassignProfile.useMutation,xD=X.streamBroker.forgetDeviceHardware.useMutation,SD=X.streamBroker.renderPreBufferClip.useMutation,CD=X.streamBroker.produceEventMedia.useMutation,wD=X.streamBroker.fetchEventMedia.useMutation,TD=X.streamBroker.listAllCameraStreams.useQuery,ED=X.streamBroker.listAllProfileSlots.useQuery,DD=X.streamBroker.getBrokerStats.useQuery,OD=X.streamBroker.probeStream.useMutation,kD=X.streamBroker.listClients.useQuery,AD=X.streamBroker.getLiveViewerCounts.useQuery,jD=X.streamBroker.killClient.useMutation,MD=X.streamBroker.restartProfile.useMutation,ND=X.streamBroker.getStreamUrl.useQuery,PD=X.streamBroker.getStreamWithCodec.useMutation,FD=X.streamBroker.releaseStreamWithCodec.useMutation,ID=X.streamBroker.acquireEgressTranscode.useMutation,LD=X.streamBroker.releaseEgressTranscode.useMutation,RD=X.streamBroker.subscribeAudioChunks.useMutation,zD=X.streamBroker.pullAudioChunks.useQuery,BD=X.streamBroker.unsubscribeAudioChunks.useMutation,VD=X.streamBroker.setPreBufferDuration.useMutation,HD=X.streamBroker.getPreBufferInfo.useQuery,UD=X.streamBroker.getRtspPort.useQuery,WD=X.streamBroker.getAllRtspEntries.useQuery,GD=X.streamBroker.getRtspEntry.useQuery,KD=X.streamBroker.regenerateRtspToken.useMutation,qD=X.streamBroker.setRtspEnabled.useMutation,JD=X.streamBroker.isRtspEnabled.useQuery,YD=X.streamBroker.getDeviceAudioMute.useQuery,XD=X.streamBroker.setDeviceAudioMute.useMutation,ZD=X.streamBroker.getDeviceSettingsContribution.useQuery,QD=X.streamBroker.getDeviceLiveContribution.useQuery,$D=X.streamBroker.applyDeviceSettingsPatch.useMutation,eO=X.streamCatalog.getCatalog.useQuery,tO=X.streamParams.getOptions.useQuery,nO=X.streamParams.setProfile.useMutation,rO=X.streamParams.getConfigSchema.useQuery,iO=X.streamParams.getStatus.useQuery,aO=X.streamSignals.listSignals.useQuery,oO=X.switch.setState.useMutation,sO=X.switch.getStatus.useQuery,cO=X.system.info.useQuery,lO=X.system.health.useQuery,uO=X.system.featureFlags.useQuery,dO=X.system.networkAddresses.useQuery,fO=X.system.getRetentionConfig.useQuery,pO=X.system.setRetentionConfig.useMutation,mO=X.system.forceRetentionCleanup.useMutation,hO=X.system.getSiteLocation.useQuery,gO=X.system.setSiteLocation.useMutation,_O=X.system.detectSiteLocation.useMutation,vO=X.system.getRequestCensus.useQuery,yO=X.system.getLoadContributions.useQuery,bO=X.system.getFailureContributions.useQuery,xO=X.system.getLoggingSettings.useQuery,SO=X.system.setLoggingSettings.useMutation,CO=X.tamper.getStatus.useQuery,wO=X.temperatureSensor.getStatus.useQuery,TO=X.terminalSession.listProfiles.useQuery,EO=X.terminalSession.listInstances.useQuery,DO=X.terminalSession.createInstance.useMutation,OO=X.terminalSession.updateInstance.useMutation,kO=X.terminalSession.deleteInstance.useMutation,AO=X.terminalSession.setInstanceEnabled.useMutation,jO=X.terminalSession.listLegacyCameras.useQuery,MO=X.terminalSession.adoptLegacyMonitor.useMutation,NO=X.terminalSession.listSessions.useQuery,PO=X.terminalSession.openSession.useMutation,FO=X.terminalSession.resize.useMutation,IO=X.terminalSession.pullOutput.useMutation,LO=X.terminalSession.writeInput.useMutation,RO=X.terminalSession.close.useMutation,zO=X.toast.onToast.useSubscription,BO=X.training.listBaseModels.useQuery,VO=X.training.planJob.useQuery,HO=X.training.startJob.useMutation,UO=X.training.startJobBatch.useMutation,WO=X.training.listJobs.useQuery,GO=X.training.getJob.useQuery,KO=X.training.cancelJob.useMutation,qO=X.training.getJobResult.useQuery,JO=X.training.listCanaryTargets.useQuery,YO=X.training.registerResult.useMutation,XO=X.training.canaryResult.useMutation,ZO=X.training.rollbackCanary.useMutation,QO=X.training.discardResult.useMutation,$O=X.turnProvider.getTurnServers.useQuery,ek=X.update.installUpdate.useMutation,tk=X.update.getStatus.useQuery,nk=X.userManagement.listUsers.useQuery,rk=X.userManagement.createUser.useMutation,ik=X.userManagement.updateUser.useMutation,ak=X.userManagement.deleteUser.useMutation,ok=X.userManagement.resetPassword.useMutation,sk=X.userManagement.setUserScopes.useMutation,gre=X.userManagement.validateCredentials.useMutation,_re=X.userManagement.setupTotp.useMutation,vre=X.userManagement.confirmTotp.useMutation,ck=X.userManagement.disableTotp.useMutation,lk=X.userManagement.getTotpStatus.useQuery,yre=X.userManagement.migrateRawSecrets.useMutation,bre=X.userManagement.verifyTotp.useMutation,xre=X.userManagement.oauthIssueCode.useMutation,Sre=X.userManagement.oauthExchangeCode.useMutation,Cre=X.userManagement.oauthRefresh.useMutation,wre=X.userManagement.oauthVerifyAccessToken.useQuery,uk=X.userManagement.listExternalIdentities.useQuery,Tre=X.userManagement.findUserByExternalIdentity.useQuery,dk=X.userManagement.unlinkExternalIdentity.useMutation,fk=X.userManagement.listOauthSessions.useQuery,pk=X.userManagement.revokeOauthSession.useMutation,Ere=X.vacuumControl.start.useMutation,Dre=X.vacuumControl.pause.useMutation,Ore=X.vacuumControl.stop.useMutation,kre=X.vacuumControl.returnToBase.useMutation,Are=X.vacuumControl.locate.useMutation,jre=X.vacuumControl.setFanSpeed.useMutation,Mre=X.vacuumControl.getStatus.useQuery,Nre=X.valve.open.useMutation,Pre=X.valve.close.useMutation,Fre=X.valve.stop.useMutation,Ire=X.valve.setPosition.useMutation,Lre=X.valve.getStatus.useQuery,Rre=X.vibration.getStatus.useQuery,mk=X.videoclips.listClips.useQuery,hk=X.videoclips.listSources.useQuery,gk=X.videoclips.getClipPlayback.useQuery,zre=X.videoclips.readClipBytes.useQuery,Bre=X.videoclips.offerClipBytes.useQuery,Vre=X.videoclips.dialClipStream.useQuery,Hre=X.videoclips.getPlaybackOptions.useQuery,Ure=X.waterHeater.setTargetTemp.useMutation,Wre=X.waterHeater.setOperationMode.useMutation,Gre=X.waterHeater.setAway.useMutation,Kre=X.waterHeater.getStatus.useQuery,qre=X.weather.getStatus.useQuery,Jre=X.webrtcSession.listStreams.useQuery,Yre=X.webrtcSession.createSession.useMutation,Xre=X.webrtcSession.handleOffer.useMutation,Zre=X.webrtcSession.handleAnswer.useMutation,Qre=X.webrtcSession.addIceCandidate.useMutation,$re=X.webrtcSession.getIceCandidates.useQuery,eie=X.webrtcSession.closeSession.useMutation,tie=X.webrtcSession.hasAdaptiveBitrate.useQuery,nie=X.webrtcSession.getSessionState.useQuery,rie=X.webrtcSession.applyDownlinkProbe.useMutation,iie=X.webrtcSession.getSessionDebug.useQuery,aie=X.zoneAnalytics.getCurrentSnapshot.useQuery,oie=X.zoneAnalytics.getCurrentSnapshotBatch.useQuery,sie=X.zoneAnalytics.getZoneHistory.useQuery,cie=X.zoneAnalytics.getCameraHistory.useQuery,lie=X.zoneAnalytics.getUnzonedHistory.useQuery,uie=X.zoneRules.listRules.useQuery,die=X.zoneRules.setRules.useMutation,_k=X.zones.listZones.useQuery,fie=X.zones.addZone.useMutation,pie=X.zones.removeZone.useMutation,mie=X.zones.updateZone.useMutation;E(),Do();var vk=O(null);function yk(){let e=I(vk);if(!e)throw Error(`Dropdown compound components must be used within <Dropdown>`);return e}function bk({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t!==void 0&&n!==void 0,o=a?t:r,s=_(e=>{a?n(e):i(e)},[a,n]),c=y(),l=y(),u=f(null);return v(vk.Provider,{value:{open:o,setOpen:s,triggerId:c,contentId:l,triggerRef:u},children:v(`div`,{className:`relative inline-block`,children:e})})}function xk({children:e,...t}){let{open:n,setOpen:r,triggerId:i,contentId:a,triggerRef:o}=yk();return v(`button`,{type:`button`,ref:o,id:i,"aria-haspopup":`menu`,"aria-expanded":n,"aria-controls":n?a:void 0,onClick:()=>r(!n),...t,children:e})}function Sk({className:e,children:t,align:n=`start`,offset:r=4,...i}){let{open:a,setOpen:o,contentId:s,triggerId:c,triggerRef:l}=yk(),d=f(null),[p,m]=C(null);return u(()=>{if(!a){m(null);return}let e=()=>{let e=l.current;if(!e)return;let t=e.getBoundingClientRect(),i=n===`end`?t.right:t.left;m({top:t.bottom+r,left:i,minWidth:t.width})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[a,n,r,l]),b(()=>{if(!a)return;let e=e=>{let t=d.current,n=l.current;t&&!t.contains(e.target)&&!n?.contains(e.target)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a,o,l]),!a||!p||typeof document>`u`?null:Oo(v(`div`,{ref:d,id:s,role:`menu`,"aria-labelledby":c,style:{position:`fixed`,top:p.top,...n===`end`?{right:window.innerWidth-p.left}:{left:p.left},minWidth:p.minWidth},className:$(`z-50 bg-background-elevated border border-border rounded-md shadow-lg py-1 min-w-[160px]`,e),...i,children:t}),document.body)}function Ck({className:e,icon:t,variant:n=`default`,children:r,onClick:i,...a}){let{setOpen:o}=yk(),s=_(e=>{i?.(e),o(!1)},[i,o]);return c(`button`,{type:`button`,role:`menuitem`,className:$(`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:s,...a,children:[t&&v(t,{size:14}),r]})}function hie(e,t){if(e.length===0||t.length===0)return!1;let n=new Set(e);return t.some(e=>n.has(e))}function wk(e,t){if(t?.excludeDeviceId!==void 0&&e.id===t.excludeDeviceId||t?.excludeTypes!==void 0&&t.excludeTypes.includes(e.type))return!1;let n=t?.caps!==void 0&&t.caps.length>0,r=t?.types!==void 0&&t.types.length>0;return!!(!n&&!r||n&&hie(e.features??[],t.caps)||r&&t.types.includes(e.type))}function Tk(e){return typeof e.location==`string`&&e.location.length>0?`${e.name} (${e.location})`:e.name}function gie(e){let t=[];return typeof e.location==`string`&&e.location.length>0&&t.push(e.location),t.push(e.type),typeof e.parentName==`string`&&e.parentName.length>0&&t.push(`in ${e.parentName}`),t.join(` · `)}function Ek(e,t){return e.filter(e=>wk(e,t)).map(e=>({value:String(e.id),label:Tk(e),description:gie(e),location:typeof e.location==`string`&&e.location.length>0?e.location:null})).toSorted((e,t)=>e.label.localeCompare(t.label))}function _ie(e){let t=new Set,n=new Set;for(let r of e)typeof r.location==`string`&&r.location.length>0&&t.add(r.location),n.add(r.type);return{locations:[...t].toSorted((e,t)=>e.localeCompare(t)),types:[...n].toSorted((e,t)=>e.localeCompare(t))}}var vie={locations:[],types:[]};function yie(e,t){return!(t.locations.length>0&&(typeof e.location!=`string`||!t.locations.includes(e.location))||t.types.length>0&&!t.types.includes(e.type))}function Dk(e,t,n){return{suggested:e.filter(e=>t.has(n(e))),others:e.filter(e=>!t.has(n(e)))}}function Ok(e,t){return e.location===t}function bie(e,t){let n=io(t.map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.role!==void 0&&e.role!==null?{role:e.role}:{},name:e.name})),e.primaryChildEntityId,e.name);return n===null?null:n.id}function kk(e,t){if(t==null||t.length===0)return new Set;let n=new Map(e.map(e=>[e.id,e])),r=new Map;for(let t of e)t.parentDeviceId===null||t.parentDeviceId===void 0||r.set(t.parentDeviceId,[...r.get(t.parentDeviceId)??[],t]);let i=e=>e!==void 0&&e.type===J.Container,a=new Set,o=new Set;for(let r of e){if(i(r)){Ok(r,t)&&a.add(r.id);continue}if(!Ok(r,t))continue;let e=r.parentDeviceId===null||r.parentDeviceId===void 0?void 0:n.get(r.parentDeviceId);e!==void 0&&i(e)?a.add(e.id):o.add(r.id)}for(let e of a){let t=n.get(e);if(t===void 0)continue;let a=bie(t,r.get(e)??[]);a!==null&&!i(n.get(a))&&o.add(a)}return o}function Ak(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?[...e]:e.filter(e=>{let t=`${e.value} ${e.label} ${e.description??``}`.toLowerCase();return n.every(e=>t.includes(e))})}function jk(e,t){let n=new Map(e.map(e=>[e.value,e]));return t.map(e=>n.get(e)??{value:e,label:e})}E();var xie=`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`,Sie=`flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30`,Mk=`block text-[11px] font-medium text-foreground mb-1 break-words`,Nk=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function Pk(e){return typeof e==`string`?e:null}function Fk(e){if(!Array.isArray(e))return[];let t=new Map;for(let n of e){if(typeof n!=`object`||!n)continue;let e=n;typeof e.id==`number`&&typeof e.name==`string`&&t.set(e.id,e.name)}let n=[];for(let r of e){if(typeof r!=`object`||!r)continue;let e=r;if(typeof e.id!=`number`||typeof e.type!=`string`||typeof e.name!=`string`)continue;let i=typeof e.parentDeviceId==`number`?t.get(e.parentDeviceId)??null:null;n.push({id:e.id,type:e.type,name:e.name,location:typeof e.location==`string`?e.location:null,features:Array.isArray(e.features)?e.features.filter(e=>typeof e==`string`):[],parentName:i,stableId:typeof e.stableId==`string`?e.stableId:``,parentDeviceId:typeof e.parentDeviceId==`number`?e.parentDeviceId:null,primaryChildEntityId:Pk(e.primaryChildEntityId),role:Pk(e.role)})}return n}var Cie=`px-2.5 pt-1.5 pb-0.5 text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,wie=`inline-flex max-w-full items-center gap-1 rounded-md border border-border bg-background px-2 py-1 text-[11px] text-foreground hover:bg-surface-hover`,Ik=`flex h-7 w-full items-center gap-2 px-2 text-left text-xs text-foreground hover:bg-surface-hover`;function Lk({label:e,values:t,chosen:n,onChange:r}){let i=q();if(t.length<2)return null;let a=n.length===0?i(`uiLibrary.deviceSelectField.all`,`All`):n.join(`, `),o=e=>{r(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return c(bk,{children:[c(xk,{className:wie,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),v(`span`,{"aria-hidden":`true`,children:`·`}),v(`span`,{className:`truncate`,children:a}),v(de,{className:`h-3 w-3 shrink-0 text-foreground-subtle`})]}),c(Sk,{className:`max-h-56 overflow-y-auto`,children:[c(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":n.length===0,className:Ik,onClick:()=>r([]),children:[v(`span`,{className:`inline-flex h-3.5 w-3.5 items-center justify-center rounded border border-border`,children:n.length===0&&v(dt,{className:`h-2.5 w-2.5`})}),i(`uiLibrary.deviceSelectField.all`,`All`)]}),t.map(e=>{let t=n.includes(e);return c(`button`,{type:`button`,role:`menuitemcheckbox`,"aria-checked":t,className:Ik,onClick:()=>o(e),children:[v(`span`,{className:[`inline-flex h-3.5 w-3.5 items-center justify-center rounded border`,t?`border-primary bg-primary text-white`:`border-border`].join(` `),children:t&&v(dt,{className:`h-2.5 w-2.5`})}),e]},e)})]})]})}function Tie({label:e,description:t,required:n,translationFn:r,children:i}){let a=Az(e,r),o=Az(t,r);return c(`div`,{className:`min-w-0`,children:[a!==void 0&&a!==``&&c(`label`,{className:Mk,children:[a,n&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),i,o&&v(`p`,{className:Nk,children:o})]})}function Rk({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{data:o}=dm({}),s=p(()=>Ek(Fk(o),e.deviceFilter),[o,e.deviceFilter]),l=t==null?``:String(t);return v(Tie,{label:e.label,description:e.description,required:e.required,translationFn:i,children:c(`select`,{className:xie,value:l,disabled:r||e.disabled,onChange:e=>n(e.target.value),children:[!e.required&&v(`option`,{value:``,children:a(`uiLibrary.deviceSelectField.select`,`— Select device —`)}),s.map(e=>v(`option`,{value:e.value,children:e.label},e.value))]})})}function zk({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{data:o}=dm({}),s=e.suggestLocation!==void 0,[l,u]=C(vie),d=p(()=>Fk(o),[o]),m=p(()=>_ie(d.filter(t=>t.id!==e.deviceFilter?.excludeDeviceId)),[d,e.deviceFilter?.excludeDeviceId]),h=p(()=>s?d.filter(e=>yie(e,l)):d,[d,l,s]),g=p(()=>Ek(h,e.deviceFilter),[h,e.deviceFilter]),_=Array.isArray(t)?t.map(String):[],y=r===!0||e.disabled===!0,b=e.maxItems!==void 0&&_.length>=e.maxItems,[x,S]=C(``),[w,T]=C(!1),[E,D]=C(0),O=f(null),k=f(null),A=p(()=>jk(g,_),[g,_]),j=p(()=>Ak(g,x),[g,x]),M=p(()=>kk(d,s?e.suggestLocation:null),[d,s,e.suggestLocation]),N=p(()=>Dk(j,M,e=>Number(e.value)),[j,M]),P=p(()=>[...N.suggested,...N.others],[N]),F=t=>{if(!y)if(_.includes(t))n(_.filter(e=>e!==t));else{if(e.maxItems!==void 0&&_.length>=e.maxItems)return;n([..._,t])}},I=e=>{if(e.key===`ArrowDown`)e.preventDefault(),T(!0),D(e=>P.length===0?0:(e+1)%P.length);else if(e.key===`ArrowUp`)e.preventDefault(),T(!0),D(e=>P.length===0?0:(e-1+P.length)%P.length);else if(e.key===`Enter`){e.preventDefault();let t=P[E];t&&F(t.value)}else e.key===`Escape`?T(!1):e.key===`Backspace`&&x===``&&_.length>0&&n(_.slice(0,-1))},L=Az(e.label,i),R=Az(e.description,i);return c(`div`,{className:`min-w-0`,children:[L!==void 0&&L!==``&&v(`label`,{className:Mk,children:L}),A.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:A.map(e=>c(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary max-w-full`,children:[v(`span`,{className:`truncate`,children:e.label}),!y&&v(`button`,{type:`button`,className:`shrink-0 hover:text-danger`,"aria-label":a(`uiLibrary.deviceSelectField.remove`,`Remove {{label}}`,{label:e.label}),onClick:()=>F(e.value),children:v(Zn,{className:`h-2.5 w-2.5`})})]},e.value))}),s&&c(`div`,{className:`mb-1.5 flex flex-wrap gap-1.5`,children:[v(Lk,{label:a(`uiLibrary.deviceSelectField.location`,`Location`),values:m.locations,chosen:l.locations,onChange:e=>u(t=>({...t,locations:e}))}),v(Lk,{label:a(`uiLibrary.deviceSelectField.type`,`Type`),values:m.types,chosen:l.types,onChange:e=>u(t=>({...t,types:e}))})]}),c(`div`,{className:Sie+(y?` opacity-50`:``),children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:O,type:`text`,role:`combobox`,"aria-label":e.label,"aria-expanded":w,"aria-controls":`dsel-${e.key}`,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,value:x,placeholder:b?a(`uiLibrary.deviceSelectField.max`,`Max {{count}} selected`,{count:e.maxItems}):e.placeholder??a(`uiLibrary.deviceSelectField.search`,`Search devices…`),disabled:y,onChange:e=>{S(e.target.value),T(!0),D(0)},onFocus:()=>T(!0),onBlur:()=>{k.current=setTimeout(()=>T(!1),120)},onKeyDown:I}),v(de,{className:`h-3.5 w-3.5 shrink-0 cursor-pointer text-foreground-subtle`,onMouseDown:e=>{e.preventDefault(),k.current&&clearTimeout(k.current),T(e=>!e),O.current?.focus()}})]}),w&&!y&&v(`div`,{id:`dsel-${e.key}`,role:`listbox`,className:`mt-1 max-h-56 overflow-y-auto rounded-md border border-border bg-surface shadow-lg`,onMouseDown:e=>{e.preventDefault()},children:P.length===0?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle italic`,children:g.length===0?a(`uiLibrary.deviceSelectField.noDevices`,`No matching devices`):a(`uiLibrary.deviceSelectField.noMatches`,`No matches for “{{query}}”`,{query:x})}):P.map((t,n)=>{let r=_.includes(t.value),i=!r&&b,a=N.suggested.length,o=s?n===0&&a>0?`Suggested · ${e.suggestLocation??``}`:n===a&&a>0?`Other devices`:null:null;return c(`div`,{children:[o!==null&&v(`div`,{className:Cie,children:o}),c(`button`,{type:`button`,role:`option`,"aria-selected":r,disabled:i,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,n===E?`bg-primary/10`:`hover:bg-surface-hover`,i?`opacity-40 cursor-not-allowed`:`cursor-pointer`].join(` `),onMouseEnter:()=>D(n),onClick:()=>F(t.value),children:[v(`span`,{className:[`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,r?`border-primary bg-primary text-white`:`border-border`].join(` `),children:r&&v(dt,{className:`h-2.5 w-2.5`})}),c(`span`,{className:`min-w-0 flex-1`,children:[v(`span`,{className:`block truncate text-foreground`,children:t.label}),t.description!==void 0&&v(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:t.description})]})]})]},t.value)})}),R&&v(`p`,{className:Nk,children:R})]})}E();var Eie=Il(`inline-flex items-center rounded-full font-medium [&>svg]:shrink-0 [&>svg]:size-3`,{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`,primary:`bg-primary/15 text-primary`,neutral:`bg-surface-hover text-foreground-muted`},styleVariant:{solid:``,fill:``,outline:`border bg-transparent`},size:{sm:`text-[10px] leading-4 px-1.5 py-0`,md:`text-xs px-2 py-0.5`},hasIcon:{true:`gap-1`,false:``},dashed:{true:`border-dashed`,false:``}},compoundVariants:[{variant:`default`,styleVariant:`fill`,class:`bg-neutral-fill text-neutral-on`},{variant:`neutral`,styleVariant:`fill`,class:`bg-neutral-fill text-neutral-on`},{variant:`success`,styleVariant:`fill`,class:`bg-success-fill text-success-on`},{variant:`warning`,styleVariant:`fill`,class:`bg-warning-fill text-warning-on`},{variant:`danger`,styleVariant:`fill`,class:`bg-danger-fill text-danger-on`},{variant:`info`,styleVariant:`fill`,class:`bg-info-fill text-info-on`},{variant:`primary`,styleVariant:`fill`,class:`bg-primary-fill text-primary-on`}],defaultVariants:{variant:`default`,styleVariant:`solid`,size:`md`,hasIcon:!1,dashed:!1}}),Bk=D(({className:e,variant:t,style:n,size:r,icon:i,dashed:a,children:o,...s},l)=>c(`span`,{ref:l,className:$(Eie({variant:t,styleVariant:n,size:r,hasIcon:i!=null,dashed:a===!0&&n===`outline`}),e),...s,children:[i,o]}));Bk.displayName=`Badge`,E();var Vk={motion:ai,audio:mt,person:it,vehicle:tt,animal:Me,package:Xt,sensor:fe,control:zr,car:tt,truck:kt,bus:xe,motorcycle:je,bicycle:je,airplane:Qe,boat:Mt,train:tee,bird:Wt,cat:U,dog:B,horse:Me,sheep:Me,cow:Me,elephant:Me,bear:Me,zebra:Me,giraffe:Me,door:pn,pir:gr,smoke:K,water:cn,gas:Fi,vibration:vr,tamper:Dr,presence:lt,generic:rn,lock:Cr,siren:Sr,switch:ke,doorbell:Yt,button:Si,"audio-speech":ni,"audio-scream":wn,"audio-crying":xt,"audio-laughter":pee,"audio-music":Yr,"audio-dog":B,"audio-cat":U,"audio-bird":Wt,"audio-animal":Me,"audio-alarm":Yt,"audio-doorbell":Yt,"audio-glass_breaking":zi,"audio-gunshot":fi,"audio-vehicle":tt,"audio-siren":Sr,"audio-fire":K,"audio-water":Ue,"audio-wind":Fi,"audio-door":pn,"audio-footsteps":$e,"audio-crowd":pr,"audio-telephone":re,"audio-engine":ar,"audio-tools":W,"audio-silence":me};function Hk(e){return Object.hasOwn(Vk,e)?Vk[e]:e.startsWith(`audio-`)?mt:rn}function Uk(e,t){if(t===void 0)return e.label;let n=t(e.labelKey);return n===e.labelKey||n.length===0?e.label:n}function Wk({iconId:e,size:t=16,color:n,className:r}){return s(Hk(e),{size:t,color:n,className:r})}var Gk=`flex items-center gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 focus-within:border-primary focus-within:ring-1 focus-within:ring-primary/30`;function Kk({label:e,onRemove:t,warning:n=!1,iconId:r,iconUrl:i,testId:a}){let o=q();return c(`span`,{"data-testid":a,className:n?`inline-flex items-center gap-1 rounded-md bg-warning/10 px-1.5 py-0.5 text-[11px] text-warning max-w-full`:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary max-w-full`,children:[i===void 0?r===void 0?null:v(Wk,{iconId:r,size:12}):v(`img`,{src:i,alt:``,className:`h-3 w-3 shrink-0 rounded-sm object-contain`}),v(`span`,{className:`truncate`,children:e}),t!==void 0&&v(`button`,{type:`button`,className:`shrink-0 hover:text-danger`,"aria-label":o(`uiLibrary.selectedChip.remove`,`Remove {{label}}`,{label:e}),onClick:t,children:v(Zn,{className:`h-2.5 w-2.5`})})]})}function qk(e){return[e.value,e.label,e.description].filter(e=>typeof e==`string`&&e.length>0).join(` `).toLowerCase()}function Jk(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);return n.length===0?e:e.filter(e=>{let t=qk(e);return n.every(e=>t.includes(e))})}function Yk(e,t){let n=new Map(e.map(e=>[e.value,e])),r=new Set(t);return{selectedOptions:t.map(e=>n.get(e)??{value:e,label:e}),unselected:e.filter(e=>!r.has(e.value))}}function Xk(e,t,n){return n===void 0?e>=8||t:n}function Zk(e){let t=e.trim();return t.length>0?t:null}function Qk(e,t){let n=t.toLowerCase();return e.some(e=>e.value.toLowerCase()===n||e.label.toLowerCase()===n)}function $k(e,t){return e&&t}function eA(e,t,n){if(!e)return!1;let r=Zk(t);return r===null?!1:!Qk(n,r)}E(),Do();var tA=4,nA=224,rA=8,Die=`block text-[11px] font-medium text-foreground mb-1 break-words`,Oie=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function kie({opt:e}){return e.iconUrl===void 0?e.iconId===void 0?null:v(Wk,{iconId:e.iconId,size:13}):v(`img`,{src:e.iconUrl,alt:``,className:`h-3.5 w-3.5 shrink-0 rounded-sm object-contain`})}function iA(e){let t=q(),{mode:n,options:r,placeholder:i=`Select…`,disabled:a=!1,emptyMessage:o=`No options available.`,creatable:s=!1,createLabel:l=`Add new…`,onCreateRequest:m,label:h,description:g,testId:_,optionTestIdPrefix:y,listboxId:x}=e,S=a,w=Xk(r.length,s,e.searchable),T=x??_??`option-select-listbox`,E=n===`single`?e.value.length>0?[e.value]:[]:e.value,D=n===`multi`?e.maxItems:void 0,O=n===`multi`&&D!==void 0&&E.length>=D,[k,A]=C(``),[j,M]=C(!1),[N,F]=C(0),[I,L]=C(null),R=f(null),z=f(null),B=f(null),V=f(null),H=()=>{let e=z.current;if(e===null)return null;let t=e.getBoundingClientRect(),n=window.innerHeight-t.bottom-rA,r=t.top-rA,i=n>=Math.min(nA,r)||n>=120,a=Math.max(96,Math.min(nA,i?n:r)),o=Math.max(rA,Math.min(t.left,window.innerWidth-t.width-rA));return i?{top:t.bottom+tA,left:o,width:t.width,maxHeight:a,placement:`below`}:{top:Math.max(rA,t.top-tA-a),left:o,width:t.width,maxHeight:a,placement:`above`}},{selectedOptions:U}=p(()=>Yk(r,E),[r,E]),ee=p(()=>Jk(r,k),[r,k]),W=eA(s,k,r),G=$k(s,m!==void 0),te=p(()=>{let e=ee.map((e,t)=>({kind:`option`,opt:e,index:t}));if(W){let t=Zk(k);t!==null&&e.push({kind:`use-query`,draft:t})}return e},[ee,W,k]);u(()=>{if(!j||S){L(null);return}let e=()=>{L(H())};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[j,S,E.length,k,te.length]),b(()=>{if(!j)return;let e=e=>{let t=e.target;B.current?.contains(t)||z.current?.contains(t)||M(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[j]);let ne=t=>{let r=t.trim();if(r.length!==0){if(m!==void 0){m(r),A(``),M(!1);return}if(n===`single`){e.onChange(r),A(``),M(!1);return}e.value.includes(r)||D!==void 0&&e.value.length>=D||(e.onChange([...e.value,r]),A(``))}},re=t=>{if(!(n!==`multi`||S))if(e.value.includes(t))e.onChange(e.value.filter(e=>e!==t));else{if(D!==void 0&&e.value.length>=D)return;e.onChange([...e.value,t])}},K=t=>{n!==`single`||S||(e.onChange(t),A(``),M(!1))},ie=e=>{if(e.kind===`option`){if(e.opt.disabled===!0)return;n===`single`?K(e.opt.value):re(e.opt.value)}else e.kind===`use-query`&&ne(e.draft)},ae=te.length+(G&&!W?1:0),oe=t=>{if(t.key===`ArrowDown`)t.preventDefault(),M(!0),F(e=>ae===0?0:(e+1)%ae);else if(t.key===`ArrowUp`)t.preventDefault(),M(!0),F(e=>ae===0?0:(e-1+ae)%ae);else if(t.key===`Enter`){if(t.preventDefault(),W&&N===te.length){let e=Zk(k);e!==null&&ne(e);return}if(G&&!W&&N===te.length){R.current?.focus();return}let e=te[N];if(e)ie(e);else if(s){let e=Zk(k);e!==null&&ne(e)}}else t.key===`Escape`?M(!1):t.key===`Backspace`&&k===``&&n===`multi`&&e.value.length>0&&e.onChange(e.value.slice(0,-1))},se=e=>{e.key===`Enter`||e.key===` `?(e.preventDefault(),M(e=>!e)):e.key===`Escape`&&M(!1)},ce=t=>{n===`single`?e.onChange(``):e.onChange(e.value.filter(e=>e!==t))},le=O===!0?`Max ${D} selected`:i,ue=r.length===0&&!W&&te.length===0&&j,fe;fe=ue?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle`,children:o}):te.length===0&&!s?v(`div`,{className:`px-2.5 py-2 text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.optionSelect.noMatches`,`No matches for “{{query}}”`,{query:k})}):v(P,{children:te.map((r,i)=>{if(r.kind===`use-query`)return c(`button`,{type:`button`,role:`option`,"aria-selected":!1,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,i===N?`bg-primary/10`:`hover:bg-surface-hover`,`cursor-pointer`].join(` `),onMouseEnter:()=>F(i),onClick:()=>ne(r.draft),children:[v(Se,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),v(`span`,{className:`truncate text-foreground`,children:t(`uiLibrary.optionSelect.use`,`Use “{{value}}”`,{value:r.draft})})]},`__use-query__`);if(r.kind!==`option`)return null;let{opt:a}=r,o=n===`single`?e.value===a.value:e.value.includes(a.value),s=n===`multi`&&!o&&O===!0,l=a.disabled===!0||s,u=te[i-1],f=u!==void 0&&u.kind===`option`?u.opt.group:void 0;return c(d,{children:[a.group!==void 0&&a.group!==f?v(`div`,{role:`presentation`,className:`px-2.5 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-wide text-foreground-subtle`,children:a.group}):null,c(`button`,{type:`button`,role:`option`,"aria-selected":o,disabled:l,"data-testid":y===void 0?void 0:`${y}-${a.value}`,className:[`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-xs transition-colors`,i===N?`bg-primary/10`:`hover:bg-surface-hover`,l?`opacity-40 cursor-not-allowed`:`cursor-pointer`].join(` `),onMouseEnter:()=>F(i),onClick:()=>ie(r),children:[v(`span`,{className:[`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,o?`border-primary bg-primary text-white`:`border-border`].join(` `),children:o&&v(dt,{className:`h-2.5 w-2.5`})}),v(kie,{opt:a}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:a.label}),a.badge!==void 0&&a.badge.length>0?v(Bk,{variant:`default`,children:a.badge}):null]})]},a.value)})});let pe=te.length,me=n===`single`&&e.singleDisplay===`field`&&U.length>0;return c(`div`,{className:`min-w-0 space-y-1`,"data-testid":_,children:[h!==void 0&&h.length>0&&v(`label`,{className:Die,children:h}),n===`multi`&&U.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:U.map(e=>v(Kk,{label:e.label,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},...e.iconId===void 0?{}:{iconId:e.iconId},...S?{}:{onRemove:()=>ce(e.value)},...y===void 0?{}:{testId:`${y}-chip-${e.value}`}},e.value))}),n===`single`&&e.singleDisplay!==`field`&&U.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:U.map(e=>v(Kk,{label:e.label,...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl},...e.iconId===void 0?{}:{iconId:e.iconId},...S?{}:{onRemove:()=>ce(e.value)}},e.value))}),w?c(`div`,{ref:e=>{z.current=e},className:Gk+(S?` opacity-50`:``),children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:R,type:`text`,role:`combobox`,"aria-expanded":j,"aria-controls":T,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,value:me&&!j&&k===``?U[0]?.label??``:k,placeholder:me?U[0]?.label??``:le,disabled:S,onChange:e=>{A(e.target.value),M(!0),F(0)},onFocus:()=>M(!0),onBlur:()=>{V.current=setTimeout(()=>{let e=document.activeElement;B.current?.contains(e)||M(!1)},120)},onKeyDown:oe}),v(de,{className:`h-3.5 w-3.5 shrink-0 cursor-pointer text-foreground-subtle`,onMouseDown:e=>{e.preventDefault(),V.current&&clearTimeout(V.current),M(e=>!e),R.current?.focus()}})]}):c(`button`,{ref:e=>{z.current=e},type:`button`,role:`combobox`,"aria-expanded":j,"aria-controls":T,disabled:S,className:[Gk,`w-full justify-between text-xs text-foreground`,S?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),onClick:()=>!S&&M(e=>!e),onKeyDown:se,children:[v(`span`,{className:`truncate text-foreground-subtle`,children:U[0]?.label??le}),v(de,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`})]}),j&&!S&&I!==null&&typeof document<`u`&&Oo(c(`div`,{ref:B,id:T,role:`listbox`,style:{position:`fixed`,top:I.top,left:I.left,width:I.width,maxHeight:I.maxHeight,zIndex:9999},className:`overflow-y-auto rounded-md border border-border bg-surface shadow-lg`,onMouseDown:e=>{e.preventDefault(),V.current&&clearTimeout(V.current)},children:[fe,G&&c(`button`,{type:`button`,className:[`flex w-full items-center gap-2 border-t border-border px-2.5 py-1.5 text-left text-xs transition-colors`,pe===N?`bg-primary/10`:`hover:bg-surface-hover`,`cursor-pointer text-primary`].join(` `),onMouseEnter:()=>F(pe),onClick:()=>{let e=Zk(k);if(e!==null){m?.(e),A(``),M(!1);return}R.current?.focus()},children:[v(Se,{className:`h-3.5 w-3.5 shrink-0`}),l]})]}),document.body),g!==void 0&&g.length>0&&v(`p`,{className:Oie,children:g})]})}function aA(e,t){return`${e}:${t}`}function oA(e,t,n,r){return e.map(e=>{let i=e.addonId!==void 0&&e.kind!==void 0?t.get(aA(e.addonId,e.kind)):void 0,a;return n?.has(e.id)===!0?a=r:e.enabled||(a=`disabled`),{value:e.id,label:e.name,...i===void 0?{}:{iconUrl:i},...a===void 0?{}:{badge:a}}})}function sA(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`kind`),r=Reflect.get(n,`addonId`),i=Reflect.get(n,`iconUrl`);typeof e!=`string`||typeof r!=`string`||typeof i==`string`&&i.length>0&&t.set(aA(r,e),i)}return t}function cA(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e=Reflect.get(n,`id`),r=Reflect.get(n,`name`),i=Reflect.get(n,`enabled`),a=Reflect.get(n,`kind`),o=Reflect.get(n,`addonId`);typeof e!=`string`||typeof r!=`string`||typeof a!=`string`||typeof o!=`string`||t.push({id:e,name:r,enabled:i===!0,kind:a,addonId:o})}return t}E();function lA({targets:e,value:t,onChange:n,disabled:r=!1,maxItems:i,testIdPrefix:a=`notification-target`,emptyMessage:o,noteIds:s,noteLabel:c,label:l,description:u,kindIconUrls:d}){let f=q(),m=Kv({}),h=p(()=>sA(m.data),[m.data]),g=d??h,_=o??f(`uiLibrary.notificationTargetsField.defaultEmpty`,`No delivery target is configured. Add one on the Targets tab first — without one the notification is rendered and thrown away.`),y=c??f(`uiLibrary.notificationTargetsField.note`,`note`);return v(iA,{mode:`multi`,options:p(()=>oA(e,g,s,y),[e,g,s,y]),value:t,onChange:n,disabled:r,searchable:!0,creatable:!1,...i===void 0?{}:{maxItems:i},emptyMessage:_,placeholder:f(`uiLibrary.notificationTargetsField.searchTargets`,`Search targets…`),label:l,description:u,testId:`${a}s`,optionTestIdPrefix:a,listboxId:`${a}-listbox`})}function uA({targets:e,value:t,onChange:n,disabled:r=!1,emptyMessage:i,placeholder:a,testId:o=`notification-target-select`,label:s,description:c,kindIconUrls:l}){let u=q(),d=Kv({}),f=p(()=>sA(d.data),[d.data]),m=l??f,h=i??u(`uiLibrary.notificationTargetsField.defaultEmpty`,`No delivery target is configured. Add one on the Targets tab first — without one the notification is rendered and thrown away.`),g=a??u(`uiLibrary.notificationTargetsField.select`,`Select…`),_=u(`uiLibrary.notificationTargetsField.note`,`note`);return v(iA,{mode:`single`,options:p(()=>oA(e,m,void 0,_),[e,m,_]),value:t,onChange:n,disabled:r,searchable:!0,creatable:!1,emptyMessage:h,placeholder:g,label:s,description:c,testId:o,optionTestIdPrefix:o,listboxId:`${o}-listbox`})}function dA({label:e,description:t,required:n,translationFn:r,children:i}){return c(`div`,{className:`space-y-1`,children:[c(`label`,{className:`block text-[11px] font-medium text-foreground mb-1 break-words`,children:[Az(e,r),n===!0?v(`span`,{className:`text-danger`,children:` *`}):null]}),i,t!==void 0&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 break-words`,children:Az(t,r)})]})}function fA({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=qv({}),s=Kv({}),c=p(()=>cA(o.data),[o.data]),l=p(()=>sA(s.data),[s.data]),u=Array.isArray(t)?t.filter(e=>typeof e==`string`):typeof t==`string`&&t.length>0?t.includes(`,`)?t.split(`,`).map(e=>e.trim()).filter(e=>e.length>0):[t]:[],d=o.isPending||s.isPending,f=o.isError?o.error:s.isError?s.error:null;return d?v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.notificationTargetsField.loading`,`Loading targets…`)})}):f===null?v(lA,{targets:c,value:u,onChange:e=>n(e),disabled:r===!0||e.disabled===!0,...e.maxItems===void 0?{}:{maxItems:e.maxItems},kindIconUrls:l,label:Az(e.label,i),description:e.description===void 0?void 0:Az(e.description,i),emptyMessage:a(`uiLibrary.notificationTargetsField.noneConfigured`,`No delivery target is configured. Add one under Notification Center → Targets first.`),testIdPrefix:`config-target-${e.key}`}):v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-danger`,children:a(`uiLibrary.notificationTargetsField.loadError`,`Could not load targets: {{message}}`,{message:f instanceof Error?f.message:String(f)})})})}function pA({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=qv({}),s=Kv({}),c=p(()=>cA(o.data),[o.data]),l=p(()=>sA(s.data),[s.data]),u=typeof t==`string`?t:``,d=o.isPending||s.isPending,f=o.isError?o.error:s.isError?s.error:null;return d?v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.notificationTargetsField.loading`,`Loading targets…`)})}):f===null?v(uA,{targets:c,value:u,onChange:e=>n(e),disabled:r===!0||e.disabled===!0,kindIconUrls:l,label:Az(e.label,i),description:e.description===void 0?void 0:Az(e.description,i),emptyMessage:a(`uiLibrary.notificationTargetsField.noneConfigured`,`No delivery target is configured. Add one under Notification Center → Targets first.`),testId:`config-target-${e.key}`}):v(dA,{label:e.label,description:e.description,required:e.required,translationFn:i,children:v(`p`,{className:`text-[11px] text-danger`,children:a(`uiLibrary.notificationTargetsField.loadError`,`Could not load targets: {{message}}`,{message:f instanceof Error?f.message:String(f)})})})}E();var mA=Kn(`camstack:custom-field-renderers`,{});function hA({renderers:e,children:t}){return v(mA.Provider,{value:e,children:t})}function gA(e){return I(mA)[e]??null}E();var Aie=Il(`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 text-foreground 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`}}),_A=D(({className:e,variant:t,size:n,...r},i)=>v(`button`,{ref:i,className:$(Aie({variant:t,size:n}),e),...r}));_A.displayName=`Button`,E();var jie=`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`,Mie=2e3,Nie=/^[A-Za-z0-9._~-]{8,}$/;function vA(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function yA(e){return typeof e==`string`?e.trim().length>0:!!(ha(e)||Ja(e))}function Pie(e){return typeof e==`string`&&e.trim().length>0?e.trim():``}function bA(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(Array.isArray(e))return e.length;if(typeof e==`string`&&e.trim().startsWith(`[`))try{let t=JSON.parse(e);if(Array.isArray(t))return t.length}catch{return null}return null}function Fie(e,t){return e===1?t:`${t}s`}function Iie(e){if(!Array.isArray(e))return[];let t=[];for(let n of e)!vA(n)||typeof n.value!=`string`||typeof n.label!=`string`||t.push({value:n.value,label:n.label,...typeof n.brand==`string`?{brand:n.brand}:{},...typeof n.region==`string`?{region:n.region}:{}});return t}function Lie(e){return typeof e==`string`?e:``}function Rie(e){return e.startsWith(`/`)&&!e.startsWith(`//`)?new URL(e,window.location.origin).toString():e}function zie(e){let t=e.trim();return t.length===0?!1:t.includes(`code=`)||t.includes(`://`)||t.includes(`error=`)?!0:Nie.test(t)}function Bie({field:e,values:t,disabled:n,onAction:r,onChangeMany:i}){let a=q(),[o,s]=C(`idle`),[l,u]=C(null),[d,p]=C(null),[m,h]=C(``),[g,_]=C(null),[y,x]=C(!1),[S,w]=C([]),T=f(!1),E=Pie(t[e.accountKey]),D=e.secretKeys.some(e=>yA(t[e])),O=E.length>0||D,k=(e.countKey===void 0?null:bA(t[e.countKey]))??(e.countFromKey===void 0?null:bA(t[e.countFromKey])),A=o===`pasting`||!O&&l!==null,j=t=>{let n={};for(let[r,i]of Object.entries(e.assignResult??{})){let e=t[i];(typeof e==`string`||typeof e==`number`)&&(n[r]=e)}Object.keys(n).length>0&&i?.(n);let r=Iie(t.choices);w(r.length>1?r:[]);let a=typeof t.gatewayId==`string`&&t.gatewayId.length>0,o=typeof t.summary==`string`?t.summary:null;o!==null&&!a&&r.length<2&&_(o),s(`idle`),h(``),u(null),p(null)},M=e.claimAction;b(()=>{if(M===void 0||l===null||o!==`pasting`||!r)return;let t=!1,n=setInterval(()=>{T.current||r(M,e.key,{attemptId:l}).then(e=>{t||!vA(e)||e.pending===!0||(t=!0,j(e))}).catch(e=>{t||(t=!0,_(e instanceof Error?e.message:String(e)))})},Mie);return()=>{t=!0,clearInterval(n)}},[M,l,o,r,e.key]);let N=async()=>{if(!(!r||y)){x(!0),_(null);try{let t=await r(e.beginAction,e.key,{});if(!vA(t)||typeof t.authorizeUrl!=`string`||typeof t.attemptId!=`string`){_(a(`uiLibrary.accountSignIn.noLink`,`The sign-in page could not be opened. Try again.`));return}if(`verifier`in t||`state`in t){_(a(`uiLibrary.accountSignIn.noLink`,`The sign-in page could not be opened. Try again.`));return}u(t.attemptId),p(t.authorizeUrl),s(`pasting`),window.open(Rie(t.authorizeUrl),`_blank`,`noopener,noreferrer`)}catch(e){_(e instanceof Error?e.message:String(e))}finally{x(!1)}}},P=async t=>{if(!(!r||l===null||T.current)){T.current=!0,x(!0),_(null);try{let n=await r(e.completeAction,e.key,{attemptId:l,callback:t});if(!vA(n)){_(a(`uiLibrary.accountSignIn.rejected`,`The sign-in was not accepted. Start again.`));return}j(n)}catch(e){_(e instanceof Error?e.message:String(e))}finally{T.current=!1,x(!1)}}},F=async()=>{if(!(!r||y)){x(!0),_(null);try{await r(e.signOutAction,e.key,{});let t={[e.accountKey]:``};e.countKey!==void 0&&(t[e.countKey]=0),e.choiceKey!==void 0&&(t[e.choiceKey]=``),e.countFromKey!==void 0&&(t[e.countFromKey]=[]);for(let n of e.secretKeys)t[n]=qi;i?.(t),w([]),s(`idle`),u(null),h(``)}catch(e){_(e instanceof Error?e.message:String(e))}finally{x(!1)}}},I=t=>{let n=S.find(e=>e.value===t);if(n===void 0||e.choiceKey===void 0)return;let r={[e.choiceKey]:n.value};n.brand!==void 0&&(r.brand=n.brand),n.region!==void 0&&(r.region=n.region),i?.(r)},L=E.length>0?E:a(`uiLibrary.accountSignIn.yourAccount`,`your account`),R=k===null?a(`uiLibrary.accountSignIn.signedIn`,`Signed in as {{account}}`,{account:L}):a(`uiLibrary.accountSignIn.signedInCount`,`Signed in as {{account}} · {{detail}}`,{account:L,detail:e.countNoun===void 0?String(k):`${k} ${Fie(k,e.countNoun)}`});return c(`div`,{className:`col-span-1 flex min-w-0 flex-col gap-2`,children:[O&&o===`idle`?c(`div`,{className:`flex flex-col gap-2`,children:[v(`p`,{className:`text-xs text-foreground`,children:R}),S.length>1&&e.choiceKey!==void 0&&v(Yl,{"aria-label":e.choiceLabel??a(`uiLibrary.accountSignIn.choose`,`Choose`),options:S.map(e=>({value:e.value,label:e.label})),value:Lie(t[e.choiceKey]),onChange:e=>I(e.target.value),disabled:n||y}),c(`div`,{className:`flex flex-wrap gap-2`,children:[v(_A,{type:`button`,variant:`outline`,size:`sm`,disabled:n||y,onClick:()=>void N(),children:a(`uiLibrary.accountSignIn.again`,`Sign in again`)}),v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:n||y,onClick:()=>void F(),children:a(`uiLibrary.accountSignIn.signOut`,`Sign out`)})]})]}):v(_A,{type:`button`,variant:`primary`,size:`sm`,disabled:n||y,onClick:()=>void N(),children:y&&o!==`pasting`?a(`uiLibrary.accountSignIn.working`,`Working…`):a(`uiLibrary.accountSignIn.signInWith`,`Sign in with {{provider}}`,{provider:e.providerLabel})}),A&&c(`div`,{className:`flex flex-col gap-1.5`,children:[d!==null&&v(`a`,{className:`text-[11px] text-primary break-all`,href:d,target:`_blank`,rel:`noopener noreferrer`,children:a(`uiLibrary.accountSignIn.open`,`Open the sign-in page`)}),M!==void 0&&v(`p`,{className:`text-[11px] text-muted-foreground`,children:a(`uiLibrary.accountSignIn.pasteFallback`,`If the page does not finish, paste the address it stops on here.`)}),v(`textarea`,{className:`${jie} min-h-[60px] resize-y`,"aria-label":a(`uiLibrary.accountSignIn.paste`,`Redirect address or code`),placeholder:e.pastePlaceholder,value:m,disabled:n||y,onChange:e=>{let t=e.target.value;h(t),zie(t)&&P(t)}})]}),g!==null&&v(`p`,{className:`text-[11px] text-danger`,children:g})]})}function Vie({field:e,values:t}){return v(`p`,{className:`col-span-1 text-xs text-foreground`,children:yA(t[e.sourceKey])?e.yesLabel:e.noLabel})}E();var xA=Kn(`camstack:device-context`,null);function SA({deviceId:e,device:t,children:n}){let r={deviceId:e,device:t??null};return v(xA.Provider,{value:r,children:n})}function CA(){return I(xA)?.deviceId??null}function wA(){return I(xA)?.device??null}E(),Do();function TA(e){let t=(typeof globalThis<`u`?globalThis:void 0)?.[e];return t&&typeof t==`object`?t:{}}var EA={singleton:!0,requiredVersion:!1},DA=e=>({version:`0.0.0`,scope:`default`,lib:e,shareConfig:EA}),OA=`__mf_module_cache__`;function kA(){let e=globalThis,t=e[OA];if(t&&typeof t==`object`){let e=t;return e.share??={},e.remote??={},e}let n={share:{},remote:{}};return e[OA]=n,n}function Hie(){let e=kA();e.share.react??=o,e.share[`react-dom`]??=Eo,e.share[`react-dom/client`]??=ko,e.share[`react/jsx-runtime`]??=N,e.share[`@tanstack/react-query`]??=F,e.share[`@trpc/client`]??=xo,e.share[`@trpc/react-query`]??=wo,e.share[`@camstack/ui-library`]??=TA(`__camstackUiLibrary`),e.share[`@camstack/sdk`]??=TA(`__camstackSdk`),e.share[`@camstack/types`]??=TA(`__camstackTypes`)}var AA=e=>({version:`0.0.0`,scope:`default`,get:()=>e().then(e=>()=>e),shareConfig:EA});function Uie(){let e=kA();a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js`).then(e=>e.l).then(t=>{e.share[`react-konva`]??=t}),[],import.meta.url),a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__konva__loadShare__.js-B7XYY0cV.js`).then(e=>e.t).then(t=>{e.share.konva??=t}),[],import.meta.url)}function jA(){Hie(),i()===null&&(Uie(),n({name:`admin_ui_host`,remotes:[],shared:{react:DA(()=>o),"react-dom":DA(()=>Eo),"react-dom/client":DA(()=>ko),"react/jsx-runtime":DA(()=>N),"@tanstack/react-query":DA(()=>F),"@trpc/client":DA(()=>xo),"@trpc/react-query":DA(()=>wo),"react-konva":AA(()=>a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-BjdR__nc.js`).then(e=>e.l),[],import.meta.url)),konva:AA(()=>a(()=>import(`./_virtual_mf___mfe_internal__admin_ui_host__loadShare__konva__loadShare__.js-B7XYY0cV.js`).then(e=>e.t),[],import.meta.url)),"@camstack/ui-library":DA(()=>TA(`__camstackUiLibrary`)),"@camstack/sdk":DA(()=>TA(`__camstackSdk`)),"@camstack/types":DA(()=>TA(`__camstackTypes`))}}))}E();var MA=Kn(`camstack:widget-registry`,null),NA=new Map,PA=new Map,FA=new Set;function IA(e,t){return`${e}::${t}`}function Wie(e){if(!e||typeof e!=`object`)return!1;let t=e.default;return typeof t==`object`&&!!t}function Gie(e){if(!e||typeof e!=`object`)return typeof e;let 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 LA(e,n,i){let a=IA(e,n),o=NA.get(a);if(o)return o;let s=PA.get(a);if(s)return s;FA.has(e)||(jA(),r([{name:e,entry:bt(i),type:`module`}],{force:!1}),FA.add(e));let c=t(`${e}/${n.startsWith(`./`)?n.slice(2):n}`).then(t=>{if(!Wie(t)){let r=Gie(t);throw Error(`Remote ${e} (${i}) does not expose a default record on '${n}'. Got: ${JSON.stringify(r)}`)}let r=t.default;return NA.set(a,r),PA.delete(a),r}).catch(e=>{throw PA.delete(a),e});return PA.set(a,c),c}function RA(e,t){return NA.get(IA(e,t))}var Kie=3e4,qie=2e3;function zA({children:e}){let t=k(),n=f(Date.now()),{data:r}=ld(void 0,{staleTime:0,refetchOnMount:`always`,refetchInterval:e=>{let t=e.state.data;return t&&t.length>0||Date.now()-n.current>=Kie?!1:qie}});Mo(`addon.widget-ready`,()=>{t.invalidateQueries({queryKey:[[`addonWidgets`,`listWidgets`]]})});let[i,a]=C(0),o=p(()=>r??[],[r]);b(()=>{if(o.length===0)return;let e=!1,t=new Set;for(let n of o){let r=IA(n.remote.remoteName,n.remote.exposedModule);if(t.has(r)||(t.add(r),NA.has(r)))continue;let i=n.bundleUrl;LA(n.remote.remoteName,n.remote.exposedModule,i).then(()=>{e||a(e=>e+1)}).catch(e=>{let t=e instanceof Error?e.message:String(e);(typeof globalThis<`u`?globalThis.console:void 0)?.error?.(`[WidgetRegistry] Failed to load widget remote`,{remoteName:n.remote.remoteName,exposedModule:n.remote.exposedModule,entryUrl:i,reason:t})})}return()=>{e=!0}},[o]);let s=p(()=>{let e=new Map,t=new Map;for(let n of o)e.set(`${n.addonId}/${n.stableId}`,n),t.set(n.remote.remoteName,n.bundleUrl);let n=(e,t)=>({widgetId:e,addonId:t.addonId,stableId:t.stableId,tab:t.tab,subTab:t.subTab,label:t.label,order:t.order,kind:t.kind,remote:t.remote,description:t.description,icon:t.icon,bundleUrl:t.bundleUrl,hosts:t.hosts,requires:t.requires,defaultSize:t.defaultSize,allowedSizes:t.allowedSizes,defaultColumns:t.defaultColumns,defaultRows:t.defaultRows});return{resolve:t=>{let n=e.get(t);if(!n)return;let r=RA(n.remote.remoteName,n.remote.exposedModule);if(!r)return null;let i=r[n.remote.componentKey??n.stableId];if(i)return i},metadata:t=>{let r=e.get(t);if(r)return n(t,r)},listAll:()=>{let t=[];for(let[r,i]of e)t.push(n(r,i));return t},entryUrlFor:e=>t.get(e)}},[o,i]);return v(MA.Provider,{value:s,children:e})}function Jie(e){return HA().resolve(e)}function BA(e){return HA().metadata(e)}function Yie(){return HA().listAll()}function VA(e,t){let n=UA(),r=t??n?.entryUrlFor(e.remoteName),[i,a]=C(0),[o,s]=C(!1);return b(()=>{if(!r||(s(!1),RA(e.remoteName,e.exposedModule)))return;let t=!1;return LA(e.remoteName,e.exposedModule,r).then(()=>{t||a(e=>e+1)}).catch(n=>{let i=n instanceof Error?n.message:String(n);(typeof globalThis<`u`?globalThis.console:void 0)?.error?.(`[WidgetRegistry] Failed to load remote component`,{remoteName:e.remoteName,exposedModule:e.exposedModule,entryUrl:r,reason:i}),t||s(!0)}),()=>{t=!0}},[e.remoteName,e.exposedModule,r]),p(()=>{if(!r||o)return;let t=RA(e.remoteName,e.exposedModule);if(!t)return null;let n=e.componentKey;return n===void 0?Object.values(t)[0]??void 0:t[n]??void 0},[e.remoteName,e.exposedModule,e.componentKey,r,i,o])}function HA(){let e=UA();if(!e)throw Error(`useWidgetRegistry(): no <WidgetRegistryProvider> in tree`);return e}function UA(){return Xie(MA)}function Xie(e){return I(e)}E();function WA(e){let t=k(),n=zw({deviceId:e??0},{enabled:e!==null&&Number.isFinite(e),refetchInterval:5e3,retry:1}),r=Bw({onSuccess:()=>{t.invalidateQueries({queryKey:[[`ptzAutotrack`]]})}}),i=Hw({onSuccess:()=>{t.invalidateQueries({queryKey:[[`ptzAutotrack`]]})}}),a=_(async t=>{e!==null&&await r.mutateAsync({deviceId:e,enabled:t})},[e,r]),o=_(async t=>{e!==null&&await i.mutateAsync({deviceId:e,settings:t})},[e,i]),s=n.error?n.error.message:r.error?r.error.message:i.error?i.error.message:null;return{status:n.data??null,isLoading:n.isLoading,isPending:r.isPending||i.isPending,error:s,setEnabled:a,setSettings:o}}E();function GA({deviceId:e}){let t=q(),{status:n,isLoading:r,isPending:i,error:a,setEnabled:o,setSettings:s}=WA(Number.isFinite(e)?e:null),[l,u]=C({targetType:``,stopDelaySeconds:30,disappearDelaySeconds:15}),[d,f]=C(!1);b(()=>{if(d)return;let e=n?.currentSettings;e&&u({targetType:e.targetType,stopDelaySeconds:e.stopDelaySeconds,disappearDelaySeconds:e.disappearDelaySeconds})},[n,d]);let p=v(fi,{className:`h-3.5 w-3.5 text-foreground-subtle`});if(r&&!n)return v($t,{title:t(`uiLibrary.autotrack.title`,`Autotrack`),icon:p,children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),t(`uiLibrary.autotrack.loading`,`Loading autotrack…`)]})});let m=c(`button`,{type:`button`,onClick:()=>{o(!(n?.enabled??!1))},disabled:i,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${n?.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":n?.enabled??!1,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${n?.enabled?`bg-success`:`bg-foreground-subtle/40`}`}),n?.enabled?t(`uiLibrary.autotrack.enabled`,`Enabled`):t(`uiLibrary.autotrack.disabled`,`Disabled`)]});return c($t,{title:t(`uiLibrary.autotrack.title`,`Autotrack`),icon:p,headerRight:m,bodyClassName:`p-3 space-y-2`,children:[a&&c(`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:[v(Ai,{className:`h-3 w-3 flex-shrink-0 mt-0.5`}),v(`span`,{className:`leading-snug break-words`,children:a})]}),c(`div`,{className:`grid grid-cols-2 gap-2 px-2`,children:[(n?.supportedTargetTypes?.length??0)>0&&c(`label`,{className:`col-span-2 flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.targetType`,`Target type`)}),v(`select`,{value:l.targetType,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,targetType:e.target.value})),onBlur:()=>{f(!1);let e=n?.currentSettings?.targetType??``;l.targetType!==e&&s({targetType:l.targetType})},disabled:i,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:(n?.supportedTargetTypes??[]).map(e=>v(`option`,{value:e.value,children:e.label},e.value))})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.stopDelay`,`Stop delay (s)`)}),v(`input`,{type:`number`,min:0,max:300,value:l.stopDelaySeconds,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,stopDelaySeconds:Number(e.target.value)||0})),onBlur:()=>{f(!1);let e=n?.currentSettings?.stopDelaySeconds??30;l.stopDelaySeconds!==e&&s({stopDelaySeconds:l.stopDelaySeconds})},disabled:i,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`})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.autotrack.disappearDelay`,`Disappear delay (s)`)}),v(`input`,{type:`number`,min:0,max:300,value:l.disappearDelaySeconds,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,disappearDelaySeconds:Number(e.target.value)||0})),onBlur:()=>{f(!1);let e=n?.currentSettings?.disappearDelaySeconds??15;l.disappearDelaySeconds!==e&&s({disappearDelaySeconds:l.disappearDelaySeconds})},disabled:i,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`})]})]}),v(`p`,{className:`px-2 text-[9.5px] text-foreground-subtle leading-snug italic`,children:t(`uiLibrary.autotrack.note`,`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).`)})]})}E();var KA=O(null);function qA(){return I(KA)}function Zie(e){let t=e.display?.label,n=t==null?``:t.trim();return{id:e.id,name:e.name,type:e.type,stableId:e.stableId,role:e.role??null,parentDeviceId:e.parentDeviceId??null,location:e.location??null,...n.length>0?{display:{label:n}}:{},...e.primaryChildEntityId===void 0?{}:{primaryChildEntityId:e.primaryChildEntityId},...e.userNamed===void 0?{}:{userNamed:e.userNamed}}}function JA(e){let t=new Map,n=new Map;for(let r of e){let e=Zie(r);t.set(e.id,e);let i=e.parentDeviceId;if(i==null||i===e.id)continue;let a=n.get(i);a===void 0?n.set(i,[e.id]):a.push(e.id)}return{byId:t,childIds:n}}function YA({devices:e,children:t}){let n=p(()=>e===null?null:JA(e),[e]);return v(KA.Provider,{value:n,children:t})}function XA({children:e}){let t=dm({projection:`slim`});return v(YA,{devices:t.data===void 0?null:t.data,children:e})}var ZA=` · `,Qie=[`compact`,`full`,`nested`,`with-location`],$ie=[` — `,` `],eae=new Set([`battery-sensor`,`temperature-sensor`,`humidity-sensor`,`ambient-light-sensor`,`connectivity-sensor`,`datetime-sensor`,`numeric-sensor`,`enum-sensor`]);function QA(e){return e.toLowerCase().replace(/[-_\s]+/g,` `).trim()}function $A(e,t){return QA(e)===QA(t)}function ej(e,t){if(t.length===0)return e;let n=e.toLowerCase(),r=t.toLowerCase();for(let t of $ie){let i=`${r}${t}`;if(n.startsWith(i))return e.slice(i.length).trim()}return e}function tj(e){let t=e.role;return t==null||t.length===0?null:t}function tae(e){if(e.type===`update`)return!0;let t=tj(e);return t!==null&&eae.has(t)}function nj(e){let t=e.display?.label;return t==null?``:t.trim()}function rj(e,t,n){let r=nj(e);if(r.length>0)return r;let i=ej(e.name,t.name),a=i.length>0?i:e.name;return e.userNamed===!0?a:i.length===0||$A(i,t.name)||n.isStockPhrase(a,tj(e),e.type)?n.shortNoun(tj(e),e.type):a}function nae(e,t,n){return $A(n,t.name)?!0:nj(e).length>0||e.userNamed===!0?!1:$A(ej(e.name,t.name),t.name)}function rae(e){let t=0;for(let n of e)tae(n)||(t+=1);return t}function iae(e,t,n){let r=io(n.map(e=>{let t=tj(e);return{id:e.id,stableId:e.stableId,type:e.type,name:e.name,...t===null?{}:{role:t}}}),t.primaryChildEntityId,t.name);return r!==null&&r.id===e.id}function aae(e,t,n,r,i){let a=rj(e,t,r);return nae(e,t,a)||i===`compact`&&t.type===`container`&&iae(e,t,n)&&rae(n)===1?t.name:`${t.name}${ZA}${a}`}function ij(e,t){if(t==null)return e;let n=t.trim();return n.length===0||e.split(` · `).some(e=>$A(e,n))?e:`${e}${ZA}${n}`}function oae(e,t){return t===null?!1:e.parentDeviceId!=null}function aj(e,t,n,r){if(!oae(e,n.parent))return t===`with-location`?ij(e.name,e.location):e.name;if(t===`nested`)return rj(e,n.parent,r);let i=aae(e,n.parent,n.siblings,r,t===`full`?`full`:`compact`);return t===`with-location`?ij(i,e.location):i}var oj=[{id:`siren`,key:`uiLibrary.deviceMeta.noun.role.siren`,en:`Siren`,it:`Sirena`,shortEn:`Siren`,shortIt:`Sirena`,aliases:[]},{id:`floodlight`,key:`uiLibrary.deviceMeta.noun.role.floodlight`,en:`Floodlight`,it:`Faro`,shortEn:`Floodlight`,shortIt:`Faro`,aliases:[]},{id:`spotlight`,key:`uiLibrary.deviceMeta.noun.role.spotlight`,en:`Spotlight`,it:`Faretto`,shortEn:`Spotlight`,shortIt:`Faretto`,aliases:[]},{id:`pir-sensor`,key:`uiLibrary.deviceMeta.noun.role.pirSensor`,en:`PIR sensor`,it:`Sensore PIR`,shortEn:`PIR`,shortIt:`PIR`,aliases:[]},{id:`chime`,key:`uiLibrary.deviceMeta.noun.role.chime`,en:`Chime`,it:`Campanello`,shortEn:`Chime`,shortIt:`Campanello`,aliases:[]},{id:`autotrack`,key:`uiLibrary.deviceMeta.noun.role.autotrack`,en:`Auto-track`,it:`Auto-tracking`,shortEn:`Auto-track`,shortIt:`Auto-tracking`,aliases:[]},{id:`nightvision`,key:`uiLibrary.deviceMeta.noun.role.nightvision`,en:`Night vision`,it:`Visione notturna`,shortEn:`Night`,shortIt:`Notturna`,aliases:[]},{id:`privacy-mask`,key:`uiLibrary.deviceMeta.noun.role.privacyMask`,en:`Privacy mask`,it:`Maschera privacy`,shortEn:`Privacy`,shortIt:`Privacy`,aliases:[]},{id:`doorbell`,key:`uiLibrary.deviceMeta.noun.role.doorbell`,en:`Doorbell`,it:`Campanello video`,shortEn:`Doorbell`,shortIt:`Campanello video`,aliases:[]},{id:`cover-blind`,key:`uiLibrary.deviceMeta.noun.role.coverBlind`,en:`Blind`,it:`Tapparella`,shortEn:`Blind`,shortIt:`Tapparella`,aliases:[]},{id:`cover-shutter`,key:`uiLibrary.deviceMeta.noun.role.coverShutter`,en:`Shutter`,it:`Persiana`,shortEn:`Shutter`,shortIt:`Persiana`,aliases:[]},{id:`cover-awning`,key:`uiLibrary.deviceMeta.noun.role.coverAwning`,en:`Awning`,it:`Tenda da sole`,shortEn:`Awning`,shortIt:`Tenda da sole`,aliases:[]},{id:`cover-curtain`,key:`uiLibrary.deviceMeta.noun.role.coverCurtain`,en:`Curtain`,it:`Tenda`,shortEn:`Curtain`,shortIt:`Tenda`,aliases:[]},{id:`cover-garage`,key:`uiLibrary.deviceMeta.noun.role.coverGarage`,en:`Garage door`,it:`Porta del garage`,shortEn:`Garage`,shortIt:`Garage`,aliases:[]},{id:`cover-gate`,key:`uiLibrary.deviceMeta.noun.role.coverGate`,en:`Gate`,it:`Cancello`,shortEn:`Gate`,shortIt:`Cancello`,aliases:[]},{id:`cover-door`,key:`uiLibrary.deviceMeta.noun.role.coverDoor`,en:`Door`,it:`Porta`,shortEn:`Door`,shortIt:`Porta`,aliases:[]},{id:`cover-window`,key:`uiLibrary.deviceMeta.noun.role.coverWindow`,en:`Window`,it:`Finestra`,shortEn:`Window`,shortIt:`Finestra`,aliases:[]},{id:`binary-helper`,key:`uiLibrary.deviceMeta.noun.role.binaryHelper`,en:`Binary helper`,it:`Helper binario`,shortEn:`Helper`,shortIt:`Helper`,aliases:[]},{id:`outlet`,key:`uiLibrary.deviceMeta.noun.role.outlet`,en:`Outlet`,it:`Presa`,shortEn:`Outlet`,shortIt:`Presa`,aliases:[]},{id:`motion-sensor`,key:`uiLibrary.deviceMeta.noun.role.motionSensor`,en:`Motion sensor`,it:`Sensore di movimento`,shortEn:`Motion`,shortIt:`Movimento`,aliases:[]},{id:`contact-sensor`,key:`uiLibrary.deviceMeta.noun.role.contactSensor`,en:`Contact sensor`,it:`Sensore di contatto`,shortEn:`Contact`,shortIt:`Contatto`,aliases:[]},{id:`leak-sensor`,key:`uiLibrary.deviceMeta.noun.role.leakSensor`,en:`Leak sensor`,it:`Sensore di perdite`,shortEn:`Leak`,shortIt:`Perdita`,aliases:[]},{id:`smoke-sensor`,key:`uiLibrary.deviceMeta.noun.role.smokeSensor`,en:`Smoke sensor`,it:`Sensore di fumo`,shortEn:`Smoke`,shortIt:`Fumo`,aliases:[]},{id:`co-sensor`,key:`uiLibrary.deviceMeta.noun.role.cOSensor`,en:`CO sensor`,it:`Sensore di CO`,shortEn:`CO`,shortIt:`CO`,aliases:[]},{id:`gas-sensor`,key:`uiLibrary.deviceMeta.noun.role.gasSensor`,en:`Gas sensor`,it:`Sensore di gas`,shortEn:`Gas`,shortIt:`Gas`,aliases:[]},{id:`tamper-sensor`,key:`uiLibrary.deviceMeta.noun.role.tamperSensor`,en:`Tamper sensor`,it:`Sensore antimanomissione`,shortEn:`Tamper`,shortIt:`Manomissione`,aliases:[]},{id:`vibration-sensor`,key:`uiLibrary.deviceMeta.noun.role.vibrationSensor`,en:`Vibration sensor`,it:`Sensore di vibrazione`,shortEn:`Vibration`,shortIt:`Vibrazione`,aliases:[]},{id:`connectivity-sensor`,key:`uiLibrary.deviceMeta.noun.role.connectivitySensor`,en:`Connectivity`,it:`Connettività`,shortEn:`Connectivity`,shortIt:`Connettività`,aliases:[]},{id:`sound-sensor`,key:`uiLibrary.deviceMeta.noun.role.soundSensor`,en:`Sound sensor`,it:`Sensore acustico`,shortEn:`Sound`,shortIt:`Suono`,aliases:[]},{id:`binary-sensor`,key:`uiLibrary.deviceMeta.noun.role.binarySensor`,en:`Binary sensor`,it:`Sensore binario`,shortEn:`Binary`,shortIt:`Binario`,aliases:[]},{id:`temperature-sensor`,key:`uiLibrary.deviceMeta.noun.role.temperatureSensor`,en:`Temperature`,it:`Temperatura`,shortEn:`Temperature`,shortIt:`Temperatura`,aliases:[]},{id:`humidity-sensor`,key:`uiLibrary.deviceMeta.noun.role.humiditySensor`,en:`Humidity`,it:`Umidità`,shortEn:`Humidity`,shortIt:`Umidità`,aliases:[]},{id:`ambient-light-sensor`,key:`uiLibrary.deviceMeta.noun.role.ambientLightSensor`,en:`Ambient light`,it:`Luce ambientale`,shortEn:`Light`,shortIt:`Luce`,aliases:[`Illumination`]},{id:`pressure-sensor`,key:`uiLibrary.deviceMeta.noun.role.pressureSensor`,en:`Pressure`,it:`Pressione`,shortEn:`Pressure`,shortIt:`Pressione`,aliases:[]},{id:`wind-sensor`,key:`uiLibrary.deviceMeta.noun.role.windSensor`,en:`Wind`,it:`Vento`,shortEn:`Wind`,shortIt:`Vento`,aliases:[]},{id:`rain-sensor`,key:`uiLibrary.deviceMeta.noun.role.rainSensor`,en:`Rain`,it:`Pioggia`,shortEn:`Rain`,shortIt:`Pioggia`,aliases:[]},{id:`uv-sensor`,key:`uiLibrary.deviceMeta.noun.role.uvSensor`,en:`UV index`,it:`Indice UV`,shortEn:`UV index`,shortIt:`Indice UV`,aliases:[]},{id:`solar-radiation-sensor`,key:`uiLibrary.deviceMeta.noun.role.solarRadiationSensor`,en:`Solar radiation`,it:`Radiazione solare`,shortEn:`Solar radiation`,shortIt:`Radiazione solare`,aliases:[]},{id:`soil-moisture-sensor`,key:`uiLibrary.deviceMeta.noun.role.soilMoistureSensor`,en:`Soil moisture`,it:`Umidità del suolo`,shortEn:`Soil moisture`,shortIt:`Umidità del suolo`,aliases:[]},{id:`power-sensor`,key:`uiLibrary.deviceMeta.noun.role.powerSensor`,en:`Power`,it:`Potenza`,shortEn:`Power`,shortIt:`Potenza`,aliases:[]},{id:`energy-sensor`,key:`uiLibrary.deviceMeta.noun.role.energySensor`,en:`Energy`,it:`Energia`,shortEn:`Energy`,shortIt:`Energia`,aliases:[]},{id:`voltage-sensor`,key:`uiLibrary.deviceMeta.noun.role.voltageSensor`,en:`Voltage`,it:`Tensione`,shortEn:`Voltage`,shortIt:`Tensione`,aliases:[]},{id:`current-sensor`,key:`uiLibrary.deviceMeta.noun.role.currentSensor`,en:`Current`,it:`Corrente`,shortEn:`Current`,shortIt:`Corrente`,aliases:[]},{id:`air-quality-sensor`,key:`uiLibrary.deviceMeta.noun.role.airQualitySensor`,en:`Air quality`,it:`Qualità dell’aria`,shortEn:`Air quality`,shortIt:`Qualità dell’aria`,aliases:[]},{id:`battery-sensor`,key:`uiLibrary.deviceMeta.noun.role.batterySensor`,en:`Battery`,it:`Batteria`,shortEn:`Battery`,shortIt:`Batteria`,aliases:[]},{id:`numeric-sensor`,key:`uiLibrary.deviceMeta.noun.role.numericSensor`,en:`Numeric sensor`,it:`Sensore numerico`,shortEn:`Value`,shortIt:`Numerico`,aliases:[]},{id:`enum-sensor`,key:`uiLibrary.deviceMeta.noun.role.enumSensor`,en:`Enum sensor`,it:`Sensore a stati`,shortEn:`State`,shortIt:`Stato`,aliases:[]},{id:`datetime-sensor`,key:`uiLibrary.deviceMeta.noun.role.dateTimeSensor`,en:`Date / time`,it:`Data / ora`,shortEn:`Time`,shortIt:`Ora`,aliases:[`Last seen`]},{id:`generic-sensor`,key:`uiLibrary.deviceMeta.noun.role.genericSensor`,en:`Sensor`,it:`Sensore`,shortEn:`Sensor`,shortIt:`Sensore`,aliases:[]},{id:`numeric-control`,key:`uiLibrary.deviceMeta.noun.role.numericControl`,en:`Numeric control`,it:`Controllo numerico`,shortEn:`Number`,shortIt:`Numero`,aliases:[]},{id:`select-control`,key:`uiLibrary.deviceMeta.noun.role.selectControl`,en:`Select control`,it:`Controllo a selezione`,shortEn:`Select`,shortIt:`Selezione`,aliases:[]},{id:`text-control`,key:`uiLibrary.deviceMeta.noun.role.textControl`,en:`Text control`,it:`Controllo testo`,shortEn:`Text`,shortIt:`Testo`,aliases:[]},{id:`datetime-control`,key:`uiLibrary.deviceMeta.noun.role.dateTimeControl`,en:`Date / time control`,it:`Controllo data / ora`,shortEn:`Time`,shortIt:`Ora`,aliases:[]},{id:`mobile-push-notifier`,key:`uiLibrary.deviceMeta.noun.role.mobilePushNotifier`,en:`Mobile push`,it:`Push su mobile`,shortEn:`Push`,shortIt:`Push`,aliases:[]},{id:`messaging-notifier`,key:`uiLibrary.deviceMeta.noun.role.messagingNotifier`,en:`Messaging`,it:`Messaggistica`,shortEn:`Messaging`,shortIt:`Messaggistica`,aliases:[]},{id:`email-notifier`,key:`uiLibrary.deviceMeta.noun.role.emailNotifier`,en:`Email`,it:`Email`,shortEn:`Email`,shortIt:`Email`,aliases:[]},{id:`generic-notifier`,key:`uiLibrary.deviceMeta.noun.role.genericNotifier`,en:`Notifier`,it:`Notificatore`,shortEn:`Notifier`,shortIt:`Notificatore`,aliases:[]}],sj=[{id:`camera`,key:`uiLibrary.deviceMeta.noun.type.camera`,en:`Camera`,it:`Telecamera`,shortEn:`Camera`,shortIt:`Telecamera`,aliases:[]},{id:`hub`,key:`uiLibrary.deviceMeta.noun.type.hub`,en:`Hub`,it:`Hub`,shortEn:`Hub`,shortIt:`Hub`,aliases:[]},{id:`light`,key:`uiLibrary.deviceMeta.noun.type.light`,en:`Light`,it:`Luce`,shortEn:`Light`,shortIt:`Luce`,aliases:[]},{id:`siren`,key:`uiLibrary.deviceMeta.noun.type.siren`,en:`Siren`,it:`Sirena`,shortEn:`Siren`,shortIt:`Sirena`,aliases:[]},{id:`switch`,key:`uiLibrary.deviceMeta.noun.type.switch`,en:`Switch`,it:`Interruttore`,shortEn:`Switch`,shortIt:`Interruttore`,aliases:[]},{id:`sensor`,key:`uiLibrary.deviceMeta.noun.type.sensor`,en:`Sensor`,it:`Sensore`,shortEn:`Sensor`,shortIt:`Sensore`,aliases:[]},{id:`thermostat`,key:`uiLibrary.deviceMeta.noun.type.thermostat`,en:`Thermostat`,it:`Termostato`,shortEn:`Thermostat`,shortIt:`Termostato`,aliases:[]},{id:`climate`,key:`uiLibrary.deviceMeta.noun.type.climate`,en:`Air conditioner`,it:`Condizionatore`,shortEn:`Climate`,shortIt:`Condizionatore`,aliases:[]},{id:`button`,key:`uiLibrary.deviceMeta.noun.type.button`,en:`Button`,it:`Pulsante`,shortEn:`Button`,shortIt:`Pulsante`,aliases:[]},{id:`event-emitter`,key:`uiLibrary.deviceMeta.noun.type.eventEmitter`,en:`Event Emitter`,it:`Emettitore di eventi`,shortEn:`Event`,shortIt:`Evento`,aliases:[]},{id:`update`,key:`uiLibrary.deviceMeta.noun.type.update`,en:`Update`,it:`Aggiornamento`,shortEn:`Update`,shortIt:`Aggiornamento`,aliases:[]},{id:`generic`,key:`uiLibrary.deviceMeta.noun.type.generic`,en:`Generic`,it:`Generico`,shortEn:`Generic`,shortIt:`Generico`,aliases:[]},{id:`notifier`,key:`uiLibrary.deviceMeta.noun.type.notifier`,en:`Notifier`,it:`Notificatore`,shortEn:`Notifier`,shortIt:`Notificatore`,aliases:[]},{id:`script`,key:`uiLibrary.deviceMeta.noun.type.script`,en:`Script`,it:`Script`,shortEn:`Script`,shortIt:`Script`,aliases:[]},{id:`automation`,key:`uiLibrary.deviceMeta.noun.type.automation`,en:`Automation`,it:`Automazione`,shortEn:`Automation`,shortIt:`Automazione`,aliases:[]},{id:`lock`,key:`uiLibrary.deviceMeta.noun.type.lock`,en:`Lock`,it:`Serratura`,shortEn:`Lock`,shortIt:`Serratura`,aliases:[]},{id:`cover`,key:`uiLibrary.deviceMeta.noun.type.cover`,en:`Cover`,it:`Copertura`,shortEn:`Cover`,shortIt:`Copertura`,aliases:[]},{id:`valve`,key:`uiLibrary.deviceMeta.noun.type.valve`,en:`Valve`,it:`Valvola`,shortEn:`Valve`,shortIt:`Valvola`,aliases:[]},{id:`humidifier`,key:`uiLibrary.deviceMeta.noun.type.humidifier`,en:`Humidifier`,it:`Umidificatore`,shortEn:`Humidifier`,shortIt:`Umidificatore`,aliases:[]},{id:`water-heater`,key:`uiLibrary.deviceMeta.noun.type.waterHeater`,en:`Water heater`,it:`Scaldabagno`,shortEn:`Heater`,shortIt:`Scaldabagno`,aliases:[]},{id:`fan`,key:`uiLibrary.deviceMeta.noun.type.fan`,en:`Fan`,it:`Ventilatore`,shortEn:`Fan`,shortIt:`Ventilatore`,aliases:[]},{id:`media-player`,key:`uiLibrary.deviceMeta.noun.type.mediaPlayer`,en:`Media player`,it:`Lettore multimediale`,shortEn:`Player`,shortIt:`Lettore`,aliases:[]},{id:`alarm-panel`,key:`uiLibrary.deviceMeta.noun.type.alarmPanel`,en:`Alarm panel`,it:`Pannello allarme`,shortEn:`Alarm`,shortIt:`Allarme`,aliases:[]},{id:`control`,key:`uiLibrary.deviceMeta.noun.type.control`,en:`Control`,it:`Controllo`,shortEn:`Control`,shortIt:`Controllo`,aliases:[]},{id:`presence`,key:`uiLibrary.deviceMeta.noun.type.presence`,en:`Presence`,it:`Presenza`,shortEn:`Presence`,shortIt:`Presenza`,aliases:[]},{id:`weather`,key:`uiLibrary.deviceMeta.noun.type.weather`,en:`Weather`,it:`Meteo`,shortEn:`Weather`,shortIt:`Meteo`,aliases:[]},{id:`vacuum`,key:`uiLibrary.deviceMeta.noun.type.vacuum`,en:`Vacuum`,it:`Aspirapolvere`,shortEn:`Vacuum`,shortIt:`Aspirapolvere`,aliases:[]},{id:`lawn-mower`,key:`uiLibrary.deviceMeta.noun.type.lawnMower`,en:`Lawn mower`,it:`Tagliaerba`,shortEn:`Mower`,shortIt:`Tagliaerba`,aliases:[]},{id:`container`,key:`uiLibrary.deviceMeta.noun.type.container`,en:`Container`,it:`Contenitore`,shortEn:`Container`,shortIt:`Contenitore`,aliases:[]},{id:`image`,key:`uiLibrary.deviceMeta.noun.type.image`,en:`Image`,it:`Immagine`,shortEn:`Image`,shortIt:`Immagine`,aliases:[]},{id:`pet-feeder`,key:`uiLibrary.deviceMeta.noun.type.petFeeder`,en:`Pet feeder`,it:`Distributore di cibo per animali`,shortEn:`Feeder`,shortIt:`Distributore`,aliases:[]},{id:`dishwasher`,key:`uiLibrary.deviceMeta.noun.type.dishwasher`,en:`Dishwasher`,it:`Lavastoviglie`,shortEn:`Dishwasher`,shortIt:`Lavastoviglie`,aliases:[]}],sae={id:``,key:`uiLibrary.deviceMeta.noun.fallback`,en:`Device`,it:`Dispositivo`,shortEn:`Device`,shortIt:`Dispositivo`,aliases:[]};function cj(e,t){if(!(t===null||t.length===0))return e.find(e=>e.id===t)}function lj(e,t){if(e!==null){let t=cj(oj,e);if(t!==void 0)return t}return cj(sj,t)??sae}function uj(e,t){let n=[],r=[cj(oj,e),cj(sj,t)];for(let e of r)e!==void 0&&n.push(e.en,e.it,e.shortEn,e.shortIt,...e.aliases);return n}function dj(e,t,n){let r=QA(e);return r.length===0?!0:uj(t,n).some(e=>QA(e)===r)}function fj(e){return{shortNoun(t,n){let r=lj(t,n);return e===`it`?r.shortIt:r.shortEn},isStockPhrase(e,t,n){return dj(e,t,n)}}}function pj(){let e=q();return{shortNoun(t,n){let r=lj(t,n);return e(r.key,r.shortEn)},isStockPhrase(e,t,n){return dj(e,t,n)}}}function mj(e){return{id:e,name:`#${String(e)}`,type:`unknown`,stableId:``,role:null,parentDeviceId:null}}function hj(e,t){let n=e.parentDeviceId;return n==null?null:t.byId.get(n)??mj(n)}function gj(e,t){let n=e.parentDeviceId;if(n==null)return[];let r=t.childIds.get(n)??[],i=[];for(let e of r){let n=t.byId.get(e);n!==void 0&&i.push(n)}return i.some(t=>t.id===e.id)||i.push(e),i}function _j(e,t,n,r,i){let a=n?.byId.get(e.id)??e;return a.parentDeviceId!=null&&n===null&&i?.parent===void 0?a.name:aj(a,t,{parent:i?.parent===void 0?n===null?null:hj(a,n):i.parent,siblings:i?.siblings??(n===null?[]:gj(a,n))},r)}function vj(e,t,n){return _j(e,t,qA(),pj(),n)}function yj(e,t,n){let r=qA(),i=pj();if(r===null)return n??`#${String(e)}`;let a=r.byId.get(e);return a===void 0?`#${String(e)}`:_j(a,t,r,i)}function bj({device:e,form:t,parent:n,siblings:r,className:i,testId:a}){let o=vj(e,t,{...n===void 0?{}:{parent:n},...r===void 0?{}:{siblings:r}});return v(`span`,{className:i,title:o,"data-testid":a,children:o})}E();function xj(e){let t=Rn(),n=p(()=>e?JSON.stringify(e):``,[e]),[r,i]=C(()=>t.listDevices(e));return b(()=>{let n=()=>{i(t.listDevices(e))};n();let r=null,a=null;try{r=t.onDeviceAdded(n),a=t.onDeviceRemoved(n)}catch{}let o=t.subscribeConnectionEvents(e=>{e===`connected`&&n()});return()=>{r?.(),a?.(),o()}},[t,e,n]),r}function Sj(e){let t=Rn(),[n,r]=C(()=>e===null?null:t.getDevice(e));return b(()=>{if(e===null){r(null);return}let n=()=>{r(t.getDevice(e))};n();let i=null,a=null;try{i=t.onDeviceAdded(n),a=t.onDeviceRemoved(n)}catch{}let o=t.subscribeConnectionEvents(e=>{e===`connected`&&n()});return()=>{i?.(),a?.(),o()}},[t,e]),n}var Cj=.02;function wj(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Tj(e){if(!wj(e))return null;let{x:t,y:n,width:r,height:i}=e;return typeof t!=`number`||typeof n!=`number`||typeof r!=`number`||typeof i!=`number`||t<0||n<0||r<=0||i<=0||t+r>1||n+i>1?null:{x:t,y:n,width:r,height:i}}function Ej(e){if(!wj(e))return null;let t=e.deviceId;if(typeof t!=`number`||!Number.isInteger(t))return null;let n=Tj(e.source),r=Tj(e.cell);return n===null||r===null?null:{deviceId:t,source:n,cell:r}}function Dj(e){if(!wj(e))return null;let t=e.profile,n=e.offered,r=e.missingSources;if(t!==`high`&&t!==`mid`&&t!==`low`||typeof n!=`boolean`||!Array.isArray(r))return null;let i=[];for(let e of r){if(typeof e!=`number`||!Number.isInteger(e))return null;i.push(e)}return{profile:t,offered:n,missingSources:i,canvas:typeof e.canvas==`string`?e.canvas:``,published:typeof e.published==`boolean`?e.published:n}}function Oj(e){if(e===null)return null;if(!wj(e))return`unreadable`;let{instanceId:t,deviceId:n,name:r,fps:i,cells:a,profiles:o}=e;if(typeof t!=`string`||typeof n!=`number`||typeof r!=`string`||typeof i!=`number`||!Array.isArray(a)||!Array.isArray(o))return`unreadable`;let s=[];for(let e of a){let t=Ej(e);if(t===null)return`unreadable`;s.push(t)}let c=[];for(let e of o){let t=Dj(e);if(t===null)return`unreadable`;c.push(t)}return{instanceId:t,deviceId:n,name:r,fps:i,cells:s,profiles:c}}function kj(e){let t=Math.min(1,Math.max(Cj,e.width)),n=Math.min(1,Math.max(Cj,e.height));return{x:Math.min(1-t,Math.max(0,e.x)),y:Math.min(1-n,Math.max(0,e.y)),width:t,height:n}}function Aj(e,t,n){return kj({...e,x:e.x+t,y:e.y+n})}function jj(e,t,n,r){let i=t===`nw`||t===`w`||t===`sw`,a=t===`ne`||t===`e`||t===`se`,o=t===`nw`||t===`n`||t===`ne`,s=t===`sw`||t===`s`||t===`se`,c=e.x,l=e.x+e.width,u=e.y,d=e.y+e.height;return i&&(c=Math.min(l-Cj,Math.max(0,c+n))),a&&(l=Math.max(c+Cj,Math.min(1,l+n))),o&&(u=Math.min(d-Cj,Math.max(0,u+r))),s&&(d=Math.max(u+Cj,Math.min(1,d+r))),kj({x:c,y:u,width:l-c,height:d-u})}function Mj(e){if(!Number.isFinite(e)||e<=0)return[];let t=Math.floor(e),n=Math.ceil(Math.sqrt(t)),r=Math.ceil(t/n),i=[],a=0;for(let e=0;e<r;e++){let o=Math.min(n,t-a),s=1/r,c=1/o;for(let t=0;t<o;t++)i.push({x:t*c,y:e*s,width:c,height:s});a+=o}return i}E();var Nj={x:0,y:0,width:1,height:1},Pj=16,Fj={type:J.Camera},Ij={touchAction:`none`},Lj=`absolute flex h-6 w-6 items-center justify-center`,Rj=[`nw`,`n`,`ne`,`e`,`se`,`s`,`sw`,`w`],zj={nw:`-top-3 -left-3 cursor-nw-resize`,n:`-top-3 left-1/2 -translate-x-1/2 cursor-n-resize`,ne:`-top-3 -right-3 cursor-ne-resize`,e:`top-1/2 -right-3 -translate-y-1/2 cursor-e-resize`,se:`-bottom-3 -right-3 cursor-se-resize`,s:`-bottom-3 left-1/2 -translate-x-1/2 cursor-s-resize`,sw:`-bottom-3 -left-3 cursor-sw-resize`,w:`top-1/2 -left-3 -translate-y-1/2 cursor-w-resize`};function Bj(e){e.currentTarget.setPointerCapture(e.pointerId)}function Vj(e,t,n){return e.mode===`move`?Aj(e.origin,t,n):jj(e.origin,e.mode,t,n)}function Hj({deviceId:e}){let t=q(),n=Rn(),r=p(()=>n.listDeviceInfos(Fj),[n,xj(Fj)]),[i,a]=C(void 0),[o,s]=C(null),[l,u]=C(!1),[d,f]=C(null),[m,h]=C(0),[g,y]=C(null),x=Ge(n.trpcClient,e),S=_(async()=>{let e=x?.cameraGridLayout;if(!e)return;let t=Oj(await e.getLayout({}));a(t),s(t===null||t===`unreadable`?null:t)},[x]);b(()=>{if(x){if(!x.cameraGridLayout){a(null);return}S().catch(()=>{a(`unreadable`)})}},[x,S]);let w=_(async e=>{let t=x?.cameraGridLayout;if(!(o===null||!t)){u(!0),f(null);try{let n=Oj(await t.saveLayout({name:o.name,fps:o.fps,cells:o.cells.map(e=>({...e})),...e?.publishedProfiles===void 0?{}:{publishedProfiles:[...e.publishedProfiles]}}));n!==null&&n!==`unreadable`&&(a(n),s(n))}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[x,o]),T=_((e,t)=>{s(n=>n===null?n:{...n,cells:n.cells.map((n,r)=>r===e?{...n,...t}:n)})},[]),E=p(()=>{let e=i==null||i===`unreadable`?[]:i.profiles;for(let t of e){if(!t.offered)continue;let[e,n]=t.canvas.split(`x`).map(Number);if(e!==void 0&&n!==void 0&&e>0&&n>0)return e/n}return 16/9},[i]);if(i===void 0)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),` `,t(`uiLibrary.cameraGridLayout.loading`,`Loading the layout…`)]})});if(i===`unreadable`)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-danger`,children:[v(Ai,{className:`h-3 w-3`}),t(`uiLibrary.cameraGridLayout.unreadable`,`The Camera Grids addon did not answer, so this layout is unknown — not empty.`)]})});if(i===null||o===null)return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),children:v(`div`,{className:`text-[10.5px] text-foreground-subtle`,children:t(`uiLibrary.cameraGridLayout.notGrid`,`This camera is not a grid.`)})});let D=e=>{if(g===null)return;let t=e.currentTarget.getBoundingClientRect();if(t.width===0||t.height===0||g.target!==`cell`)return;let n=(e.clientX-g.startX)/t.width,r=(e.clientY-g.startY)/t.height;T(g.index,{cell:Vj(g,n,r)})};return v($t,{title:t(`uiLibrary.cameraGridLayout.title`,`Grid layout`),icon:v(rt,{className:`h-3.5 w-3.5`}),headerRight:c(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,disabled:o.cells.length===0,title:t(`uiLibrary.cameraGridLayout.autofillTitle`,`Tile every cell over the whole canvas, leaving no gap`),onClick:()=>{let e=Mj(o.cells.length);s({...o,cells:o.cells.map((t,n)=>({...t,cell:e[n]??t.cell}))})},className:`flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[10px] uppercase`,children:[v(wi,{className:`h-3 w-3`}),` `,t(`uiLibrary.cameraGridLayout.autofill`,`Autofill`)]}),c(`button`,{type:`button`,disabled:l,onClick:()=>void w(),className:`flex items-center gap-1 rounded border border-border px-2 py-0.5 text-[10px] uppercase`,children:[l?v(Gn,{className:`h-3 w-3 animate-spin`}):v(ji,{className:`h-3 w-3`}),t(`uiLibrary.cameraGridLayout.save`,`Save`)]})]}),children:c(`div`,{className:`flex flex-col gap-3`,children:[d!==null&&c(`div`,{className:`flex items-center gap-2 text-[10.5px] text-danger`,children:[v(Ai,{className:`h-3 w-3`}),` `,d]}),c(`div`,{className:`relative w-full select-none overflow-hidden rounded border border-border bg-black`,style:{aspectRatio:String(E),...Ij},onPointerMove:D,onPointerUp:()=>{y(null)},onPointerCancel:()=>{y(null)},children:[o.cells.map((e,t)=>v(Wj,{cell:e,selected:t===m,onSelect:()=>{h(t)},onDragStart:(n,r)=>{h(t),y({index:t,target:`cell`,mode:n,startX:r.clientX,startY:r.clientY,origin:e.cell})}},`${String(e.deviceId)}-${String(t)}`)),o.cells.length===0&&v(`div`,{className:`absolute inset-0 flex items-center justify-center text-[10.5px] text-foreground-subtle`,children:t(`uiLibrary.cameraGridLayout.noCells`,`No cells yet — add one below.`)})]}),c(`div`,{className:`grid grid-cols-4 gap-2 text-[10.5px]`,children:[v(Xj,{label:`FPS`,value:o.fps,onChange:e=>{s({...o,fps:e})}}),c(`button`,{type:`button`,disabled:o.cells.length>=Pj,onClick:()=>{let t=r.find(t=>t.id!==e);t&&(s({...o,cells:[...o.cells,{deviceId:t.id,source:Nj,cell:kj({x:.1,y:.1,width:.4,height:.4})}]}),h(o.cells.length))},className:`flex items-center justify-center gap-1 self-end rounded border border-border px-2 py-1 uppercase`,children:[v(Se,{className:`h-3 w-3`}),` `,t(`uiLibrary.cameraGridLayout.addCell`,`Cell`)]})]}),v(Uj,{offers:i.profiles,cameras:r,onToggle:e=>{if(o===null)return;let t=i.profiles.filter(e=>e.published).map(e=>e.profile);w({publishedProfiles:t.includes(e)?t.filter(t=>t!==e):[...t,e]})}}),o.cells[m]!==void 0&&v(Kj,{cell:o.cells[m],index:m,cameras:r.filter(t=>t.id!==e),onChange:e=>{T(m,e)},onRemove:()=>{s({...o,cells:o.cells.filter((e,t)=>t!==m)}),h(0)}})]})})}function Uj({offers:e,cameras:t,onToggle:n}){let r=q(),i=e=>t.find(t=>t.id===e)?.name??`#${String(e)}`;return c(`div`,{className:`flex flex-col gap-1 rounded border border-border p-2 text-[10.5px]`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.published`,`Published profiles`)}),e.map(e=>c(`div`,{className:`flex items-baseline gap-2`,children:[v(`input`,{type:`checkbox`,checked:e.published,disabled:!e.offered,"aria-label":r(`uiLibrary.cameraGridLayout.publish`,`publish {{profile}}`,{profile:e.profile}),onChange:()=>{n(e.profile)}}),v(`span`,{className:`w-10 uppercase`,children:e.profile}),e.offered?c(`span`,{className:`text-foreground-subtle`,children:[e.canvas,` —`,` `,e.published?r(`uiLibrary.cameraGridLayout.composed`,`composed from every source’s {{profile}}`,{profile:e.profile}):r(`uiLibrary.cameraGridLayout.serviceable`,`serviceable, not published`)]}):v(`span`,{className:`text-danger`,children:e.missingSources.length===0?r(`uiLibrary.cameraGridLayout.noCellsOffer`,`not offered — this grid has no cells yet`):r(`uiLibrary.cameraGridLayout.missing`,`not offered — no {{profile}} on {{sources}}`,{profile:e.profile,sources:e.missingSources.map(i).join(`, `)})})]},e.profile))]})}function Wj({cell:e,selected:t,onSelect:n,onDragStart:r}){let{src:i}=Te(e.deviceId,{width:640}),a=`${String(100/e.source.width)}% ${String(100/e.source.height)}%`,o=e.source.width>=1&&e.source.height>=1?`center`:`${String(e.source.x/Math.max(1e-6,1-e.source.width)*100)}% ${String(e.source.y/Math.max(1e-6,1-e.source.height)*100)}%`;return v(`div`,{role:`presentation`,onPointerDown:e=>{n(),Bj(e),r(`move`,e)},className:`absolute cursor-move border ${t?`border-accent`:`border-border/60`}`,style:{...Ij,left:`${String(e.cell.x*100)}%`,top:`${String(e.cell.y*100)}%`,width:`${String(e.cell.width*100)}%`,height:`${String(e.cell.height*100)}%`,backgroundImage:i===null?void 0:`url(${i})`,backgroundSize:a,backgroundPosition:o,backgroundRepeat:`no-repeat`},children:t&&Rj.map(e=>v(`div`,{role:`presentation`,onPointerDown:t=>{t.stopPropagation(),Bj(t),r(e,t)},className:`${Lj} ${zj[e]}`,style:Ij,children:v(`span`,{className:`h-2.5 w-2.5 bg-accent`})},e))})}function Gj({camera:e}){return vj(e,`compact`)}function Kj({cell:e,index:t,cameras:n,onChange:r,onRemove:i}){let a=q();return c(`div`,{className:`flex flex-col gap-2 rounded border border-border p-2 text-[10.5px]`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:a(`uiLibrary.cameraGridLayout.cellN`,`Cell {{index}}`,{index:t+1})}),v(`button`,{type:`button`,onClick:i,className:`text-danger`,children:v(Pe,{className:`h-3 w-3`})})]}),c(`label`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`w-16 text-foreground-subtle`,children:a(`uiLibrary.cameraGridLayout.source`,`Source`)}),v(`select`,{value:String(e.deviceId),onChange:e=>{r({deviceId:Number(e.target.value)})},className:`flex-1 rounded border border-border bg-transparent px-1 py-0.5`,children:n.map(e=>v(`option`,{value:String(e.id),children:v(Gj,{camera:e})},e.id))})]}),v(qj,{deviceId:e.deviceId,source:e.source,onChange:e=>{r({source:e})}}),v(`div`,{className:`grid grid-cols-2 gap-x-3 gap-y-1.5`,children:[`x`,`y`,`width`,`height`].map(t=>v(Yj,{label:Jj(a,t),value:e.source[t],onChange:n=>{r({source:kj({...e.source,[t]:n})})}},t))})]})}function qj({deviceId:e,source:t,onChange:n}){let r=q(),{src:i}=Te(e,{width:640}),[a,o]=C(null),[s,l]=C(null),u=e=>{if(a===null)return;let t=e.currentTarget.getBoundingClientRect();t.width===0||t.height===0||n(Vj({...a,index:0,target:`source`},(e.clientX-a.startX)/t.width,(e.clientY-a.startY)/t.height))},d=t.x===0&&t.y===0&&t.width===1&&t.height===1;return c(`div`,{className:`flex flex-col gap-1`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`uppercase text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.visiblePart`,`Visible part of the camera`)}),c(`button`,{type:`button`,disabled:d,onClick:()=>{n(Nj)},className:`flex items-center gap-1 rounded border border-border px-1.5 py-0.5 uppercase disabled:opacity-40`,children:[v(Br,{className:`h-3 w-3`}),` `,r(`uiLibrary.cameraGridLayout.wholeFrame`,`Whole frame`)]})]}),c(`div`,{className:`relative w-full select-none overflow-hidden rounded border border-border bg-black`,style:{aspectRatio:String(s??16/9),...Ij},onPointerMove:u,onPointerUp:()=>{o(null)},onPointerCancel:()=>{o(null)},children:[i===null?v(`div`,{className:`absolute inset-0 flex items-center justify-center text-[10px] text-foreground-subtle`,children:r(`uiLibrary.cameraGridLayout.noSnapshot`,`No snapshot from this camera yet — the numbers below still apply.`)}):v(`img`,{src:i,alt:``,className:`absolute inset-0 h-full w-full`,onLoad:e=>{let{naturalWidth:t,naturalHeight:n}=e.currentTarget;t>0&&n>0&&l(t/n)}}),v(`div`,{className:`pointer-events-none absolute inset-0 bg-black/55`}),v(`div`,{role:`presentation`,onPointerDown:e=>{Bj(e),o({mode:`move`,startX:e.clientX,startY:e.clientY,origin:t})},className:`absolute cursor-move border border-accent`,style:{...Ij,left:`${String(t.x*100)}%`,top:`${String(t.y*100)}%`,width:`${String(t.width*100)}%`,height:`${String(t.height*100)}%`,backgroundImage:i===null?void 0:`url(${i})`,backgroundSize:`${String(100/t.width)}% ${String(100/t.height)}%`,backgroundPosition:t.width>=1&&t.height>=1?`center`:`${String(t.x/Math.max(1e-6,1-t.width)*100)}% ${String(t.y/Math.max(1e-6,1-t.height)*100)}%`},children:Rj.map(e=>v(`div`,{role:`presentation`,onPointerDown:n=>{n.stopPropagation(),Bj(n),o({mode:e,startX:n.clientX,startY:n.clientY,origin:t})},className:`${Lj} ${zj[e]}`,style:Ij,children:v(`span`,{className:`h-2.5 w-2.5 bg-accent`})},e))})]})]})}function Jj(e,t){switch(t){case`x`:return e(`uiLibrary.cameraGridLayout.cropX`,`Crop x`);case`y`:return e(`uiLibrary.cameraGridLayout.cropY`,`Crop y`);case`width`:return e(`uiLibrary.cameraGridLayout.cropWidth`,`Crop width`);case`height`:return e(`uiLibrary.cameraGridLayout.cropHeight`,`Crop height`)}}function Yj({label:e,value:t,onChange:n}){let r=Math.round(t*100)/100;return c(`label`,{className:`flex flex-col gap-0.5`,children:[c(`span`,{className:`flex items-baseline justify-between text-foreground-subtle`,children:[v(`span`,{children:e}),v(`input`,{type:`number`,min:0,max:1,step:.01,value:r,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n(t)},className:`w-12 rounded border border-border bg-transparent px-1 py-0.5 text-right`})]}),v(`input`,{type:`range`,min:0,max:1,step:.005,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&n(t)},style:Ij,className:`h-5 w-full accent-accent`})]})}function Xj({label:e,value:t,step:n=1,onChange:r}){return c(`label`,{className:`flex flex-col gap-0.5`,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),v(`input`,{type:`number`,step:n,value:t,onChange:e=>{let t=Number(e.target.value);Number.isFinite(t)&&r(t)},className:`rounded border border-border bg-transparent px-1 py-0.5`})]})}function Zj(e){let t=Ge(e.trpc,e.deviceId),n=Be(t===null?void 0:e.slice(t)),r=t===null?void 0:e.cap(t),i=Be(t===null?void 0:t.state.deviceStatus),a=i?.online??!0,o=a?null:i?.lastChangedAt??null;return{dev:t,cap:r,slice:n,available:(e.requireFeature===void 0||(e.deviceFeatures??[]).includes(e.requireFeature))&&r!==void 0&&n!==void 0&&a,online:a,offlineSince:o}}E();var Qj=`open`,$j=`closed`;function eM(e){if(e===null||typeof window>`u`)return null;try{let t=window.localStorage.getItem(e);return t===Qj?!0:t===$j?!1:null}catch{return null}}function tM(e,t){if(!(e===null||typeof window>`u`))try{window.localStorage.setItem(e,t?Qj:$j)}catch{}}function nM(e){let[t,n]=C(()=>({key:e,open:eM(e)})),r=t.key===e?t:{key:e,open:eM(e)};r!==t&&n(r);let i=_(t=>{n({key:e,open:t}),tM(e,t)},[e]);return[r.open,i]}var rM={ok:{variant:`success`,barClass:`bg-success`,labelKey:`uiLibrary.consumableLevel.ok`,labelFallback:`OK`},low:{variant:`warning`,barClass:`bg-warning`,labelKey:`uiLibrary.consumableLevel.low`,labelFallback:`Low`},empty:{variant:`danger`,barClass:`bg-danger`,labelKey:`uiLibrary.consumableLevel.empty`,labelFallback:`Empty`},full:{variant:`warning`,barClass:`bg-warning`,labelKey:`uiLibrary.consumableLevel.full`,labelFallback:`Full`},unknown:{variant:`neutral`,barClass:`bg-foreground-subtle`,labelKey:`uiLibrary.consumableLevel.unknown`,labelFallback:`Unknown`}};function iM(e){return rM[e??`unknown`]}function aM(e){return iM(e).variant}function oM(e){return iM(e).barClass}function sM(e,t){let n=iM(e);return t(n.labelKey,n.labelFallback)}function cM(e){return e.status===`full`||e.status===`replace`?`full`:e.level===null?e.status===null?null:`ok`:e.level>=85?`full`:`ok`}function lM(e){if(e.level!==null)return e.level<=0||e.status===`empty`?`empty`:e.level<=15||e.status===`replace`||e.status===`low`?`low`:`ok`;switch(e.status){case`replace`:case`low`:return`low`;case`empty`:return`empty`;case`ok`:case`full`:return`ok`;case null:return null}}function uM(e){return pa(e)===`waste`?cM(e):lM(e)}var dM=fa.exclude([`full`]).options;function fM(e){if(e.kind!==`enum`||e.enumValues===void 0)return!1;let t=dM;return e.enumValues.length===t.length&&t.every(t=>e.enumValues?.includes(t))}function pM(e){let t=fa.safeParse(e);return t.success?t.data:null}function mM({level:e,name:t,label:n,size:r=`md`,className:i}){let a=q(),o=n??sM(e,a);return v(Bk,{variant:aM(e),size:r,className:i,"data-level":e??`unknown`,children:t===void 0?o:`${t} · ${o}`})}E();var hM=D(({className:e,...t},n)=>v(`div`,{ref:n,className:$(`animate-pulse bg-surface-hover rounded-md h-4 w-full`,e),...t}));hM.displayName=`Skeleton`;function gM(e,t){if(t.value===null)return`—`;if(t.kind===`count`)return e(`uiLibrary.consumablesPanel.cycles`,{one:`{{count}} cycle`,other:`{{count}} cycles`},{count:t.value});let n=Va({value:t.value,quantity:`duration`,precision:0});return n.unit.length===0?n.text:`${n.text} ${n.unit}`}function _M(e){try{return new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`})}catch{return``}}function vM(e){return e===`low`||e===`empty`||e===`full`}function yM(e){return Math.max(0,Math.min(100,e))}function bM({item:e,warn:t,children:n}){return v(`div`,{"data-form":Xa(e),className:`flex gap-2.5 rounded-md border p-3 ${t?`border-warning/40 bg-warning/5`:`border-border-subtle`}`,children:n})}function xM({item:e,warn:t}){return v(`span`,{className:`truncate text-xs font-semibold ${t?`text-warning`:`text-foreground`}`,children:e.label})}function SM({item:e,busy:t,canReset:n,onReset:r}){let i=q(),a=uM(e),o=vM(a);return v(bM,{item:e,warn:o,children:c(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[v(xM,{item:e,warn:o}),e.level===null?v(mM,{level:a,size:`sm`,className:`w-fit`,label:e.status===`replace`?i(`uiLibrary.consumablesPanel.replace`,`Replace`):void 0}):c(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-surface-hover`,children:v(`div`,{className:`h-full rounded-full ${oM(a)} transition-all`,style:{width:`${yM(e.level)}%`}})}),c(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:[Math.round(e.level),`%`]})]}),e.remaining&&v(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:gM(i,e.remaining)}),e.lastResetAt!==null&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.consumablesPanel.replacedOn`,`Replaced {{date}}`,{date:_M(e.lastResetAt)})}),e.resettable&&v(_A,{type:`button`,variant:`outline`,size:`sm`,className:`w-fit`,onClick:()=>r(e.key),disabled:t||!n,children:i(`uiLibrary.consumablesPanel.replaced`,`Replaced`)})]})})}function CM({item:e}){let t=uM(e),n=vM(t);return c(bM,{item:e,warn:n,children:[v(`div`,{className:`relative h-10 w-3 shrink-0 overflow-hidden rounded-sm border border-border bg-surface-hover`,"data-testid":`consumable-gauge`,children:e.level!==null&&v(`div`,{className:`absolute inset-x-0 bottom-0 ${oM(t)} transition-all`,style:{height:`${yM(e.level)}%`}})}),c(`div`,{className:`flex min-w-0 flex-1 flex-col justify-center gap-1`,children:[v(xM,{item:e,warn:n}),c(`div`,{className:`flex items-center gap-2`,children:[v(mM,{level:t,size:`sm`,className:`w-fit`}),e.level!==null&&c(`span`,{className:`text-[10px] font-medium tabular-nums text-foreground-subtle`,children:[Math.round(e.level),`%`]})]})]})]})}var wM={full:3,ok:3,low:1,empty:0,unknown:0},TM=[0,1,2];function EM(e,t){if(e===`low`)return t(`uiLibrary.consumablesPanel.refillSoon`,`Refill soon`);if(e===`empty`)return t(`uiLibrary.consumablesPanel.refillNow`,`Refill now`)}function DM({item:e}){let t=q(),n=uM(e),r=vM(n),i=wM[n??`unknown`];return c(bM,{item:e,warn:r,children:[v(Xt,{className:`mt-0.5 h-4 w-4 shrink-0 ${r?`text-warning`:`text-foreground-subtle`}`}),c(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[v(xM,{item:e,warn:r}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`div`,{className:`flex gap-0.5`,"data-testid":`consumable-steps`,"data-filled":i,children:TM.map(e=>v(`span`,{className:`h-1.5 w-3 rounded-full ${e<i?oM(n):`bg-surface-hover`}`},e))}),v(mM,{level:n,size:`sm`,className:`whitespace-nowrap`,label:EM(n,t)})]})]})]})}function OM(e){switch(Xa(e.item)){case`part`:return v(SM,{...e});case`tank`:case`bin`:return v(CM,{item:e.item});case`product`:return v(DM,{item:e.item})}}var kM={empty:3,full:2,low:1};function AM(e){return e===`low`||e===`empty`||e===`full`}function jM(e){if(e.length===0)return{kind:`none`,needsAttention:!1};let t=[],n=0,r=0;for(let i of e){let e=uM(i);AM(e)?t.push({label:i.label,level:e,replace:i.status===`replace`}):e===`ok`?n+=1:r+=1}let i=[...t].sort((e,t)=>kM[t.level]-kM[e.level])[0];return i===void 0?r===0?{kind:`ok`,needsAttention:!1,count:n}:{kind:`partial`,needsAttention:!1,ok:n,unknown:r}:{kind:`attention`,needsAttention:!0,count:t.length,worst:i}}E();function MM(e){return`camstack.device.${String(e)}.consumables.open`}function NM({summary:e,t}){switch(e.kind){case`none`:return v(Bk,{variant:`neutral`,size:`sm`,children:t(`uiLibrary.consumablesPanel.noneReported`,`None reported`)});case`ok`:return v(Bk,{variant:`success`,size:`sm`,children:t(`uiLibrary.consumablesPanel.allOk`,`All OK`)});case`partial`:return v(Bk,{variant:`neutral`,size:`sm`,children:t(`uiLibrary.consumablesPanel.okAndUnknown`,`{{ok}} OK · {{unknown}} unknown`,{ok:e.ok,unknown:e.unknown})});case`attention`:return e.count===1?v(mM,{level:e.worst.level,name:e.worst.label,size:`sm`,label:e.worst.replace?t(`uiLibrary.consumablesPanel.replace`,`Replace`):void 0}):v(Bk,{variant:aM(e.worst.level),size:`sm`,children:t(`uiLibrary.consumablesPanel.needAttention`,{one:`{{count}} needs attention`,other:`{{count}} need attention`},{count:e.count})})}}function PM({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),{cap:i,slice:a,available:o}=Zj({trpc:n.trpcClient,deviceId:r?e:null,cap:e=>e.consumables,slice:e=>e.state.consumables}),[s,c]=C(null),[l,u]=nM(r?MM(e):null),d=_(async e=>{if(i){c(e);try{await i.reset({key:e})}catch(e){console.error(`consumables.reset failed`,e)}finally{c(null)}}},[i]),f=a===void 0?null:jM(a.items),p=l??f?.needsAttention??!1,m=v(hM,{className:p?`h-10 w-full`:`h-4 w-16`,"data-testid":`consumables-loading`,"aria-label":t(`uiLibrary.consumablesPanel.loading`,`Reading consumables…`)});return v($t,{title:t(`uiLibrary.consumablesPanel.title`,`Consumables`),icon:v(vt,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 overflow-y-auto`,collapsible:!0,open:p,onOpenChange:u,headerRight:p?void 0:f===null?m:v(NM,{summary:f,t}),children:a===void 0?m:a.items.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle italic leading-relaxed`,children:t(`uiLibrary.consumablesPanel.empty`,`No consumables reported.`)}):v(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2`,children:a.items.map(e=>v(OM,{item:e,busy:s===e.key,canReset:o,onReset:e=>void d(e)},e.key))})})}function FM(e){return e===null?`absent`:e.providers.length>0?`present`:`absent`}function IM(e){let t=X.capabilities.getCapability.useQuery({name:e});return t.status===`pending`?`pending`:t.status===`error`?`unknown`:FM(t.data)}var LM=[`object`,`motion`,`audio`];function RM(e,t,n){let r=[];for(let i of e){let e={motion:i.motion,object:i.object,audio:i.audio},a=e.motion+e.object+e.audio;if(a===0)continue;let o=Math.floor((i.bucketStart-t)/n),s=null,c=-1;for(let t of LM)e[t]>c&&(c=e[t],s=t);r.push({index:o,startMs:i.bucketStart,endMs:i.bucketStart+n,counts:e,total:a,dominant:s})}return r.toSorted((e,t)=>e.index-t.index)}function zM(e,t){return e<t.startMs?t.startMs-e:e>t.endMs?e-t.endMs:0}function BM(e,t){if(t.length===0)return null;let n=t.find(t=>e>=t.startMs&&e<=t.endMs);if(n)return{fromMs:e,toMs:n.endMs};let r=null,i=1/0;for(let n of t){let t=zM(e,n);t<i&&(i=t,r=n)}return r?{fromMs:r.startMs,toMs:r.endMs}:null}function VM(e,t,n){let r=n-t;if(r<=0)return 0;let i=(e-t)/r*100;return i<0?0:i>100?100:i}function HM(e,t){let n=new Date(e.getFullYear(),e.getMonth(),e.getDate(),0,0,0,0).getTime(),r=new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,0,0,0,0).getTime();return{fromMs:n,toMs:Math.max(n,Math.min(r,t))}}var UM=[24*36e5,12*36e5,6*36e5,36e5,15*6e4];function WM(e,t,n){if(t>=e.toMs-e.fromMs)return e;let r=Math.min(Math.max(n,e.fromMs+t),e.toMs);return{fromMs:r-t,toMs:r}}function GM(e,t,n){let r=e.toMs-e.fromMs,i=e.fromMs+n,a=e.toMs+n;return i<t.fromMs&&(i=t.fromMs,a=i+r),a>t.toMs&&(a=t.toMs,i=a-r),{fromMs:i,toMs:a}}var KM=[15*6e4,5*6e4,6e4,3e4,15e3,5e3];function qM(e){let t=e/100;for(let e of KM)if(e<=t)return e;return KM[KM.length-1]??5e3}function JM(e,t,n){if(n<=1)return[{pct:0,label:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}];let r=[];for(let i=0;i<n;i++){let a=e+i/(n-1)*(t-e),o=VM(a,e,t),s=new Date(a).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`});r.push({pct:o,label:s})}return r}var YM=2;function XM(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-YM),i=Math.min(t-1,e+YM);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function ZM({currentPage:e,totalItems:t,pageSize:n,onPageChange:r,itemNoun:i}){let a=q();if(t<=n)return null;let o=Math.ceil(t/n),s=(e-1)*n+1,l=Math.min(e*n,t),u=XM(e,o);return c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.pagination.showing`,`Showing {{start}}–{{end}} of {{total}} {{noun}}`,{start:s,end:l,total:t,noun:i??a(`uiLibrary.pagination.devices`,`devices`)})}),c(`span`,{className:`inline-flex items-center gap-1`,children:[v(`button`,{type:`button`,"aria-label":a(`uiLibrary.pagination.previous`,`Previous page`),disabled:e===1,onClick:()=>r(e-1),className:$(`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:v(ge,{className:`h-3 w-3`})}),u.map((t,n)=>t.kind===`ellipsis`?v(`span`,{className:`px-1 text-foreground-subtle/60 select-none`,children:`…`},`e-${n}`):v(`button`,{type:`button`,onClick:()=>r(t.n),className:$(`inline-flex items-center justify-center h-7 min-w-7 px-1.5 rounded border text-[10.5px] font-medium transition-colors`,t.n===e?`border-primary/40 bg-primary/10 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),children:t.n},`p-${t.n}`)),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.pagination.next`,`Next page`),disabled:e===o,onClick:()=>r(e+1),className:$(`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:v(It,{className:`h-3 w-3`})})]})]})}function QM({icon:e,title:t,description:n,action:r,className:i}){return c(`div`,{className:$(`flex flex-col items-center justify-center gap-3 py-12`,i),children:[e&&v(e,{className:`h-12 w-12 text-foreground-subtle`,"aria-hidden":`true`}),c(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[v(`p`,{className:`text-foreground-muted text-sm font-medium`,children:t}),n&&v(`p`,{className:`text-foreground-subtle text-xs max-w-xs`,children:n})]}),r&&v(`div`,{className:`mt-1`,children:r})]})}var $M={danger:{box:`border-danger/40 bg-danger/10`,icon:`text-danger`,title:`text-danger`,message:`text-danger`},warning:{box:`border-amber-500/40 bg-amber-500/10`,icon:`text-amber-600 dark:text-amber-400`,title:`text-amber-700 dark:text-amber-300`,message:`text-amber-700 dark:text-amber-300`}};function eN({message:e,title:t,onRetry:n,action:r,variant:i=`danger`,className:a}){let o=q(),s=$M[i],l=i===`warning`?zi:Ai;return c(`div`,{role:`alert`,className:$(`flex items-start gap-2.5 rounded border px-3 py-2.5`,s.box,a),children:[v(l,{className:$(`h-4 w-4 mt-0.5 shrink-0`,s.icon),"aria-hidden":`true`}),c(`div`,{className:`flex-1 min-w-0`,children:[t&&v(`p`,{className:$(`text-xs font-semibold`,s.title),children:t}),v(`div`,{className:$(`text-xs break-words`,s.message,t?`mt-0.5`:``),children:e})]}),r??(n&&c(`button`,{type:`button`,onClick:n,className:$(`shrink-0 inline-flex items-center gap-1 rounded px-2 py-1 text-[11px] font-medium`,`border border-current/30 hover:bg-current/10 transition-colors`,s.message),children:[v(_e,{className:`h-3 w-3`,"aria-hidden":`true`}),o(`uiLibrary.errorBox.retry`,`Retry`)]}))]})}var tN=[`chart-series-a`,`chart-series-b`,`chart-series-c`,`chart-series-d`,`chart-series-e`,`chart-series-f`,`chart-series-g`,`chart-series-h`],nN=[[],[6,4],[2,3]];function rN(e){let t=Math.max(0,Math.floor(e));return{token:tN[t%tN.length]??`chart-series-a`,dash:nN[Math.floor(t/tN.length)%nN.length]??[]}}var iN={"chart-series-a":`bg-chart-series-a`,"chart-series-b":`bg-chart-series-b`,"chart-series-c":`bg-chart-series-c`,"chart-series-d":`bg-chart-series-d`,"chart-series-e":`bg-chart-series-e`,"chart-series-f":`bg-chart-series-f`,"chart-series-g":`bg-chart-series-g`,"chart-series-h":`bg-chart-series-h`,border:`bg-border`},aN={"chart-series-a":`border-chart-series-a`,"chart-series-b":`border-chart-series-b`,"chart-series-c":`border-chart-series-c`,"chart-series-d":`border-chart-series-d`,"chart-series-e":`border-chart-series-e`,"chart-series-f":`border-chart-series-f`,"chart-series-g":`border-chart-series-g`,"chart-series-h":`border-chart-series-h`,border:`border-border`};function oN(e){return iN[e]}function sN(e){return aN[e]}function cN(e,t){if(typeof window>`u`||typeof getComputedStyle!=`function`)return`transparent`;let n=t??document.documentElement,r=getComputedStyle(n).getPropertyValue(`--color-${e}`).trim();return r.length>0?r:`transparent`}var lN=/^#[0-9a-f]{6}$/i;function uN(e,t){let n=Math.min(1,Math.max(0,t));return lN.test(e)?`${e}${Math.round(n*255).toString(16).padStart(2,`0`)}`:`color-mix(in srgb, ${e} ${String(Math.round(n*100))}%, transparent)`}function dN({title:e,actions:t,readoutTime:n,legend:r,summary:i,footer:a,placeholder:o,controls:s,className:l,children:u}){let d=r.length===1?r[0]:void 0;return c(`figure`,{className:$(`min-w-0 m-0`,l),"data-chart-frame":``,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1 min-w-0`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate min-w-0`,children:e}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:[n&&v(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:n}),d?.value!==void 0&&o===void 0&&v(mN,{entry:d}),t]})]}),o??v(`div`,{role:`img`,"aria-label":i,className:`min-w-0`,children:u}),o===void 0&&s,v(`p`,{className:`sr-only`,children:i}),r.length>1&&o===void 0&&v(`ul`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5 mt-1 list-none p-0 m-0`,children:r.map(e=>v(`li`,{className:`min-w-0`,children:v(pN,{entry:e})},e.id))}),a&&v(`div`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:a})]})}function fN({token:e,dashed:t}){return t?v(`span`,{"aria-hidden":`true`,className:$(`inline-block h-0 w-3 border-t-2 border-dashed shrink-0`,sN(e))}):v(`span`,{"aria-hidden":`true`,className:$(`inline-block h-2 w-2 rounded-[2px] shrink-0`,oN(e))})}function pN({entry:e}){return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] min-w-0`,e.muted?`text-foreground-subtle`:`text-foreground-muted`),children:[v(fN,{token:e.token,dashed:e.dashed}),v(`span`,{className:`truncate`,children:e.label}),e.value!==void 0&&v(`span`,{className:`tabular-nums text-foreground`,children:e.value})]})}function mN({entry:e}){return c(`span`,{className:`inline-flex items-center gap-1 text-[11px] tabular-nums text-foreground`,children:[v(fN,{token:e.token,dashed:e.dashed}),e.value]})}function hN({message:e,height:t}){return v(`div`,{className:$(t===`sm`?`h-8`:t===`md`?`h-24`:`h-40`,`flex items-center justify-center rounded border border-dashed border-border text-[10px] text-foreground-subtle text-center px-2`),children:e})}function gN(e){let t=e.map(e=>[...e.points].sort((e,t)=>e.t-t.t)),n=t.map((t,n)=>_N(t,e[n]?.gapMs)),r=new Set;for(let e of t)for(let t of e)r.add(t.t);for(let e of n)for(let t of e)r.add(t);let i=[...r].sort((e,t)=>e-t),a=new Map;i.forEach((e,t)=>a.set(e,t));let o=()=>i.map(()=>void 0),s=[],c=[],l=[];return t.forEach((e,t)=>{let r=o(),i=o(),u=o();for(let e of n[t]??[]){let t=a.get(e);t!==void 0&&(r[t]=null,i[t]=null,u[t]=null)}for(let t of e){let e=a.get(t.t);e!==void 0&&(r[e]=t.v,t.min!==void 0&&(i[e]=t.min),t.max!==void 0&&(u[e]=t.max))}s.push(r),c.push(i),l.push(u)}),{xs:i,ys:s,mins:c,maxs:l}}function _N(e,t){if(t===void 0||!(t>0))return[];let n=[];for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];i&&a&&a.t-i.t>t&&n.push(i.t+1)}return n}function vN(e){if(e.length===0)return[];let t=null;for(let n of e){let e=yN(n);if(t=t===null?e:bN(t,e),t.length===0)return[]}return t??[]}function yN(e){let t=e.gapMs;if(t===void 0||!(t>0))return[];let n=[...e.points].sort((e,t)=>e.t-t.t),r=[];for(let e=1;e<n.length;e++){let i=n[e-1],a=n[e];i&&a&&a.t-i.t>t&&r.push({from:i.t,to:a.t})}return r}function bN(e,t){let n=[];for(let r of e)for(let e of t){let t=Math.max(r.from,e.from),i=Math.min(r.to,e.to);i>t&&n.push({from:t,to:i})}return n}function xN(e){let t=[];return e.forEach((e,n)=>{let r=n===0?null:t[n-1];t.push(e.map((e,t)=>{if(e===void 0)return;if(e===null)return null;if(r==null)return e;let n=r[t];return n===null?null:n===void 0?e:n+e}))}),t}function SN(e,t,n){for(let r=Math.min(n,e.length-1);r>=0;r--){let e=t[r];if(e!==void 0)return e}return null}function CN(e,t,n,r=null){let i=[...e].filter(e=>e.t<n).sort((e,t)=>e.t-t.t),a=[],o=t,s=r;for(let e of i){if(e.t<=t){s=e.state;continue}e.state!==s&&(a.push({from:o,to:e.t,state:s}),o=e.t,s=e.state)}return n>o&&a.push({from:o,to:n,state:s}),a.filter(e=>e.to>e.from&&e.state!==null)}function wN(e){let t=new Map;for(let n of e)n.state!==null&&t.set(n.state,(t.get(n.state)??0)+Math.max(0,n.to-n.from));return t}function TN(e,t){for(let n of e)if(t>=n.from&&t<n.to)return n.state;return null}var EN=6e4,DN=60*EN,ON=24*DN;function kN(e){if(!(e>0))return`0s`;if(e<EN)return`${String(Math.round(e/1e3))}s`;if(e<DN)return`${String(Math.floor(e/EN))}m`;if(e<ON){let t=Math.floor(e/DN),n=Math.floor(e%DN/EN);return n>0?`${String(t)}h ${String(n)}m`:`${String(t)}h`}let t=Math.floor(e/ON),n=Math.floor(e%ON/DN);return n>0?`${String(t)}d ${String(n)}h`:`${String(t)}d`}var AN={hour:`2-digit`,minute:`2-digit`},jN={hour:`2-digit`,minute:`2-digit`,second:`2-digit`},MN={day:`2-digit`,month:`short`},NN={month:`short`,year:`2-digit`};function PN(e,t){let n=new Date(e);return t<10*EN?n.toLocaleTimeString(void 0,jN):t<=2*ON?n.toLocaleTimeString(void 0,AN):t<=120*ON?n.toLocaleDateString(void 0,MN):n.toLocaleDateString(void 0,NN)}function FN(e,t){let n=new Date(e);return t<=2*ON?n.toLocaleTimeString(void 0,t<10*EN?jN:AN):`${n.toLocaleDateString(void 0,MN)} ${n.toLocaleTimeString(void 0,AN)}`}var IN=[1,2,5,10],LN=[1,2,4,8,16,32,64,128,256,512,1024],RN=[1,1.5,2,2.5,3,4,5],zN=[4,3,5,2],BN=1e-9;function VN(e,t){if(!Number.isFinite(e)||e<=0)return!1;if(t===`bytes`){if(!Number.isInteger(e))return!1;let t=e/1024**Math.floor(Math.log(e)/Math.log(1024));return RN.some(e=>Math.abs(t-e)<BN)}let n=e/10**Math.floor(Math.log10(e));return RN.some(e=>Math.abs(n-e)<BN)}function HN(e,t,n=`linear`){let r=0;for(let t of e)t!==null&&Number.isFinite(t)&&t>r&&(r=t);if(r<=t)return t;if(n===`bytes`){let e=1024**Math.floor(Math.log(r)/Math.log(1024));for(let t of LN){let n=t*e;if(n>=r)return n}return 1024*e}let i=10**Math.floor(Math.log10(r));for(let e of IN){let t=e*i;if(t>=r)return t}return 10*i}function UN(e,t=`linear`){if(!Number.isFinite(e)||e<=0)return[];let n=zN.find(n=>VN(e/n,t))??zN[zN.length-1]??2,r=e/n,i=[];for(let e=1;e<=n;e++)i.push(r*e);return i}function WN(e){let t=1/0,n=-1/0;for(let r of e)r===null||!Number.isFinite(r)||(r<t&&(t=r),r>n&&(n=r));if(!Number.isFinite(t)||!Number.isFinite(n))return null;if(n-t<1e-9)return[t-1,n+1];let r=(n-t)*.1,i=n-t+2*r,a=10**Math.floor(Math.log10(i/4)),o=[1,2,2.5,5,10].map(e=>e*a).find(e=>i/e<=6)??a*10;return[Math.floor((t-r)/o)*o,Math.ceil((n+r)/o)*o]}var GN=2.5;function KN(e){return e*GN}var qN=10;function JN(){let e=typeof document<`u`&&document.body?getComputedStyle(document.body).fontFamily:`sans-serif`;return`${String(qN)}px ${e}`}function YN(e,t=!0){return{show:t,scale:`x`,side:2,size:t?22:0,gap:4,font:JN(),stroke:()=>cN(`foreground-subtle`),grid:{show:!1},ticks:{show:t,stroke:()=>cN(`border`),width:1,size:3},space:70,values:(t,n)=>n.map(t=>PN(t,e()))}}function XN(e,t){if(t.fixed)return t.fixed;let n=e.filter(e=>typeof e==`number`&&Number.isFinite(e));return(t.zeroBased??!0)&&n.every(e=>e>=0)?[0,HN(n,t.floor??0,t.scale??`linear`)||1]:WN(n)??[0,1]}var ZN=[1,2,2.5,5];function QN(e,t){let[n,r]=e;if(n===0&&r>0)return[...UN(r,t.scale??`linear`)];let i=r-n;if(!(i>0))return[n];let a=10**Math.floor(Math.log10(i/4)),o=[...ZN,10].map(e=>e*a).find(e=>i/e<=6)??i/4,s=[];for(let e=Math.ceil(n/o-1e-9)*o;e<=r+1e-9;e+=o)s.push(Math.round(e/o)*o);return s}function $N(e,t,n,r){return{scale:e,side:t,font:JN(),size:(e,t)=>{let n=(t??[]).reduce((e,t)=>Math.max(e,String(t).length),0);return Math.max(28,Math.min(72,n*6+10))},gap:4,stroke:()=>cN(`foreground-subtle`),grid:{show:r,stroke:()=>uN(cN(`foreground-subtle`),.18),width:1},ticks:{show:!1},values:(e,t)=>t.map(e=>n(e))}}function eP(e){return{y:!1,drag:{x:!1,y:!1,setScale:!1},points:{size:6,width:1.5},focus:{prox:16},...e===void 0?{}:{sync:{key:e,setSeries:!1}}}}function tP(e){return t=>{let n=e();if(n.length===0)return;let r=t.ctx;r.save(),r.fillStyle=uN(cN(`foreground-subtle`),.12);for(let e of n){let n=t.valToPos(e.from,`x`,!0),i=t.valToPos(e.to,`x`,!0);r.fillRect(n,t.bbox.top,Math.max(1,i-n),t.bbox.height)}r.restore()}}var nP=new Set([`B`,`bytes`,`byte`]);function rP(e){return e!=null&&nP.has(e)}var iP=new Set([`°C`,`°F`,`K`,`dBFS`,`dB`,`dBm`,`hPa`,`mbar`,`inHg`]);function aP(e){return rP(e)?{scale:`bytes`}:e===`%`?{floor:10}:e!=null&&iP.has(e)?{zeroBased:!1}:{}}function oP(e){if(!Number.isFinite(e))return`—`;if(Math.abs(e)<1024)return`${String(Math.round(e))} B`;let t=[`KB`,`MB`,`GB`,`TB`,`PB`],n=e/1024,r=`KB`;for(let e of t){if(r=e,Math.abs(n)<1024)break;n/=1024}return`${Math.abs(n)<100?n.toFixed(1):n.toFixed(0)} ${r}`}function sP(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e3?Math.round(e).toLocaleString():t>=100?e.toFixed(0):t>=10?cP(e.toFixed(1)):t>=1?cP(e.toFixed(2)):t===0?`0`:cP(e.toFixed(3))}function cP(e){return e.includes(`.`)?e.replace(/\.?0+$/,``):e}function lP(e,t){if(rP(t))return oP(e);let n=sP(e);return t==null||t===``||t===`count`?n:t===`%`?`${n}%`:`${n} ${t}`}function uP({options:e,value:t,onChange:n,ariaLabel:r,className:i}){return e.length<2?null:v(`div`,{role:`radiogroup`,"aria-label":r,className:$(`inline-flex items-center gap-0.5 border border-border rounded-md p-0.5 bg-background`,i),children:e.map(({id:e,label:r})=>{let i=t===e;return v(`button`,{type:`button`,role:`radio`,"aria-checked":i,onClick:()=>n(e),className:$(`px-2 py-0.5 rounded text-[10px] font-medium transition-colors`,i?`bg-primary/10 text-primary`:`text-foreground-subtle hover:text-foreground`),children:r},e)})})}function dP(e,t){let n=[];for(let r=0;r<t;r++)n.push(e.map(e=>{let t=null;for(let n=0;n<=r;n++){let r=e.values[n];r!=null&&(t=(t??0)+r)}return t}));return n}function fP(e,t){let n=Array.from({length:t},()=>0),r=!1;for(let i of e)for(let e=0;e<t;e++){let t=i.values[e];t!=null&&(r=!0,n[e]=(n[e]??0)+t)}return{perLayer:n,total:n.reduce((e,t)=>e+t,0),known:r}}function pP(e,t,n){for(let r=0;r<e.length;r++){let i=e[r];if(i&&n>=i.t&&n<i.t+t)return r}return null}var mP=`—`,hP=new Set([`information`,`duration`,`duration-ms`,`none`,`device`,`count`,`index`,`ratio`,`humidity`,`percentage`]),gP={selection:{visible:!1,dataX:null,anchorX:0,anchorY:0,pinned:!1},gesture:null,lockHorizontalScroll:!1},_P=[{placed:`right`,vertical:`above`},{placed:`left`,vertical:`above`},{placed:`right`,vertical:`below`},{placed:`left`,vertical:`below`}];function vP(e,t){if(e.length===0||!Number.isFinite(t))return null;let n=0,r=e.length-1;for(;n<r;){let i=Math.floor((n+r)/2);(e[i]??0)<t?n=i+1:r=i}let i=n,a=Math.max(0,i-1);return Math.abs((e[a]??0)-t)<=Math.abs((e[i]??0)-t)?a:i}function yP(e){if(!(e.plotWidth>0)||!Number.isFinite(e.localX))return null;let t=e.localX-e.plotLeft;if(!e.clamp&&(t<0||t>e.plotWidth))return null;let n=Math.min(e.plotWidth,Math.max(0,t));return e.xMin+n/e.plotWidth*(e.xMax-e.xMin)}function bP(e,t,n){if(e.length===0||!Number.isFinite(n))return null;let r=0,i=1/0;for(let a=0;a<e.length;a++){let o=e[a]?.t;if(o===void 0)continue;let s=o+t;if(n>=o&&n<s)return a;let c=n<o?o-n:n-s;c<i&&(i=c,r=a)}return r}function xP(e,t,n){if(e.length===0)return null;let r=[...e].sort((e,t)=>e-t);if(t===null||!Number.isFinite(t))return n>0?r[0]??null:r[r.length-1]??null;let i=0,a=1/0;for(let e=0;e<r.length;e++){let n=Math.abs((r[e]??0)-t);n<a&&(a=n,i=e)}let o=i+n;return o<0||o>=r.length?r[i]??null:r[o]??null}function SP(e,t,n,r){return{visible:!0,dataX:e,anchorX:t,anchorY:n,pinned:r}}function CP(e,t,n){return{selection:e,gesture:t,lockHorizontalScroll:n}}function wP(e,t,n){if(e.axis!==`pending`)return e.axis;let r=Math.abs(t-e.originX),i=Math.abs(n-e.originY);return r<10&&i<10?`pending`:r>=i?`x`:`y`}function TP(e,t){return t.kind===`mouse`?e:CP(e.selection,{kind:t.kind,originX:t.x,originY:t.y,axis:`pending`},!1)}function EP(e,t){if(t.kind===`mouse`)return t.dataX===null?e.selection.pinned?e:gP:CP(SP(t.dataX,t.x,t.y,!1),null,!1);let n=e.gesture;if(n===null)return e;let r=wP(n,t.x,t.y),i={...n,axis:r};return r!==`x`||t.dataX===null?CP(e.selection,i,!1):CP(SP(t.dataX,t.x,t.y,!0),i,!0)}function DP(e,t){return t.kind===`mouse`||e.gesture===null?e:e.gesture.axis===`y`||e.gesture.axis===`x`?CP(e.selection,null,!1):e.selection.visible&&e.selection.pinned||t.dataX===null?gP:CP(SP(t.dataX,t.x,t.y,!0),null,!1)}function OP(e,t){switch(t.type){case`hide`:case`outside`:return gP;case`leave`:return e.selection.pinned?CP(e.selection,null,!1):gP;case`hover`:return CP(SP(t.dataX,t.anchorX,t.anchorY,!1),null,!1);case`key`:return CP(SP(t.dataX,t.anchorX,t.anchorY,!0),null,!1);case`down`:return TP(e,t);case`move`:return EP(e,t);case`up`:return DP(e,t);default:return t}}function kP(e){if(e==null||e.length===0)return;let t;for(let n of Object.keys(Xi))if(!(!Gi(n)||hP.has(n))&&Xi[n]===e){if(t!==void 0)return;t=n}return t}function AP(e,t,n){return e.length===0?n:t.length===0?e:t===`%`?`${e}%`:`${e} ${t}`}function jP(e){let t=e.unknownLabel??mP;if(e.value===null||!Number.isFinite(e.value))return t;let n=e.quantity===`device`?void 0:e.quantity??kP(e.unit);if(n===void 0)return lP(e.value,e.unit??null);let r=Va({value:e.value,quantity:n,preference:e.preference,precision:e.precision});return AP(r.text,r.unit,t)}function MP(e,t){return t.length===0?e:`${e}, ${t.map(e=>`${e.label} ${e.value}`).join(`, `)}`}function NP(e,t){return{heading:e,lines:t,liveText:MP(e,t)}}function PP(e){let t=e.series.filter(e=>e.visible!==!1).map(t=>({id:t.id,label:t.label,value:jP({value:t.value,quantity:t.quantity,unit:t.unit,precision:t.precision,preference:e.preference})}));return NP(e.timeLabel,t)}function FP(e,t){for(let n of e)if(t>=n.from&&t<n.to)return{state:n.state,spanMs:Math.max(0,n.to-n.from)};return null}function IP(e,t){return e===null||e.length===0?mP:t===null||!(t>0)?e:`${e} · ${kN(t)}`}function LP(e){let t=e.rows.map(e=>({id:e.id,label:e.label,value:IP(e.stateLabel,e.spanMs)}));return NP(e.timeLabel,t)}function RP(e,t,n){return`${FN(e,n)} – ${FN(e+t,n)}`}function zP(e){let t=e.layers.map(t=>({id:t.id,label:t.label,value:jP({value:t.value,quantity:t.quantity,unit:t.unit,precision:t.precision,preference:e.preference})}));return NP(e.rangeLabel,t)}function BP(e,t,n){return{left:e.placed===`right`?t.anchorX+n:t.anchorX-n-t.tooltipWidth,top:e.vertical===`above`?t.anchorY-n-t.tooltipHeight:t.anchorY+n}}function VP(e,t,n){return e>=4&&t>=4&&e+n.tooltipWidth<=n.boundsWidth-4&&t+n.tooltipHeight<=n.boundsHeight-4}function HP(e,t,n){return n.anchorX>=e&&n.anchorX<=e+n.tooltipWidth&&n.anchorY>=t&&n.anchorY<=t+n.tooltipHeight}function UP(e,t,n){let r=Math.max(4,n.boundsWidth-4-n.tooltipWidth),i=Math.max(4,n.boundsHeight-4-n.tooltipHeight);return{left:Math.min(Math.max(e,4),r),top:Math.min(Math.max(t,4),i)}}function WP(e){let t=e.gap??12,n=null;for(let r of _P){let i=BP(r,e,t),a=UP(i.left,i.top,e),o={...r,...a};if(n===null&&!HP(a.left,a.top,e)&&(n=o),VP(i.left,i.top,e)&&!HP(i.left,i.top,e))return{...r,...i}}if(n!==null)return n;let r=_P[0]??{placed:`right`,vertical:`above`},i=UP(BP(r,e,t).left,BP(r,e,t).top,e);return{...r,...i}}E(),Do();function GP(e){return e===`mouse`?`mouse`:`touch`}function KP(e,t,n,r,i,a){let o=n.getBoundingClientRect(),s=e-o.left,c=t-o.top;if(r!==null){let n=r.over.getBoundingClientRect(),i=e-n.left,o=t-n.top,l=r.bbox.left,u=r.bbox.left+r.bbox.width,d=i>=l&&i<=u&&o>=r.bbox.top&&o<=r.bbox.top+r.bbox.height;return!d&&!a?{dataX:null,anchorX:s,anchorY:c,inside:!1}:{dataX:r.posToVal(Math.min(u,Math.max(l,i)),`x`),anchorX:s,anchorY:c,inside:d}}let l=yP({localX:s,plotLeft:0,plotWidth:o.width,xMin:i.xMin,xMax:i.xMax,clamp:a});return{dataX:l,anchorX:s,anchorY:c,inside:l!==null}}function qP(e,t,n,r){if(n!==null&&t!==null){let r=n.over.getBoundingClientRect(),i=t.getBoundingClientRect();return{x:r.left-i.left+n.valToPos(e,`x`),y:r.top-i.top+n.bbox.top+n.bbox.height/2}}let i=t?.getBoundingClientRect().width??0,a=t?.getBoundingClientRect().height??0,o=r.xMax-r.xMin,s=o===0?0:(e-r.xMin)/o;return{x:Math.min(1,Math.max(0,s))*i,y:a/2}}function JP(e,t){if(e!==null){if(t===null){e.setCursor({left:-10,top:-10});return}e.setCursor({left:e.valToPos(t,`x`),top:e.bbox.top+e.bbox.height/2})}}function YP({view:e}){let t=f(null);return u(()=>{let n=t.current;if(n===null)return;let r=WP({anchorX:e.anchorX,anchorY:e.anchorY,tooltipWidth:n.offsetWidth,tooltipHeight:n.offsetHeight,boundsWidth:e.boundsWidth,boundsHeight:e.boundsHeight});n.style.left=`${String(r.left)}px`,n.style.top=`${String(r.top)}px`},[e]),c(`div`,{ref:t,role:`tooltip`,"data-chart-tooltip":``,className:`pointer-events-none absolute z-20 max-w-64 rounded-md border border-border bg-background-elevated px-2 py-1 text-foreground shadow-md`,children:[v(`p`,{className:`m-0 text-[10px] tabular-nums text-foreground-subtle`,children:e.body.heading}),v(`ul`,{className:`m-0 list-none p-0`,children:e.body.lines.map(e=>c(`li`,{className:`flex items-baseline justify-between gap-3 text-xs`,children:[v(`span`,{className:`min-w-0 truncate text-foreground-muted`,children:e.label}),v(`span`,{className:`shrink-0 tabular-nums`,children:e.value})]},e.id))})]})}function XP({spec:e,plotRef:t,kind:n,label:r,inline:i=!1,children:a}){let o=f(null),s=f(e);s.current=e;let l=f(gP),u=f(null),[d,p]=C(null),m=d!==null&&l.current.selection.pinned,h=_(e=>{l.current=e;let t=s.current,n=o.current,r=e.selection.visible?e.selection.dataX:null,i=t!==null&&r!==null?t.resolve(r):null;if(i===null||r===null){p(null),u.current!==null&&(u.current=null,t?.onDataX?.(null));return}p({body:i,anchorX:e.selection.anchorX,anchorY:e.selection.anchorY,boundsWidth:n?.getBoundingClientRect().width??0,boundsHeight:n?.getBoundingClientRect().height??0}),u.current!==r&&(u.current=r,t?.onDataX?.(r))},[]);b(()=>{let e=o.current;if(e===null)return;let n=(n,r)=>{let i=s.current;return i===null?null:KP(n.clientX,n.clientY,e,t.current,i,r)},r=e=>{if(GP(e.pointerType)===`mouse`)return;let t=n(e,!1);t!==null&&h(OP(l.current,{type:`down`,kind:`touch`,x:t.anchorX,y:t.anchorY,dataX:t.dataX}))},i=r=>{let i=GP(r.pointerType),a=l.current.gesture?.axis===`x`,o=n(r,i!==`mouse`&&a);if(o===null)return;if(i===`mouse`){if(!o.inside||o.dataX===null){h(OP(l.current,{type:`leave`})),l.current.selection.visible||JP(t.current,null);return}h(OP(l.current,{type:`hover`,dataX:o.dataX,anchorX:o.anchorX,anchorY:o.anchorY})),JP(t.current,o.dataX);return}let s=OP(l.current,{type:`move`,kind:`touch`,x:o.anchorX,y:o.anchorY,dataX:o.dataX});s.lockHorizontalScroll&&(r.preventDefault(),r.pointerId!==0&&!e.hasPointerCapture(r.pointerId)&&e.setPointerCapture(r.pointerId)),h(s),s.selection.dataX!==null&&s.selection.visible&&JP(t.current,s.selection.dataX)},a=e=>{if(GP(e.pointerType)===`mouse`)return;let r=n(e,l.current.gesture?.axis===`x`);if(r===null)return;let i=OP(l.current,{type:`up`,kind:`touch`,x:r.anchorX,y:r.anchorY,dataX:r.dataX});h(i),JP(t.current,i.selection.visible?i.selection.dataX:null)},c=e=>{if(GP(e.pointerType)!==`mouse`)return;let n=OP(l.current,{type:`leave`});h(n),n.selection.visible||JP(t.current,null)};return e.addEventListener(`pointerdown`,r),e.addEventListener(`pointermove`,i),e.addEventListener(`pointerup`,a),e.addEventListener(`pointercancel`,a),e.addEventListener(`pointerleave`,c),()=>{e.removeEventListener(`pointerdown`,r),e.removeEventListener(`pointermove`,i),e.removeEventListener(`pointerup`,a),e.removeEventListener(`pointercancel`,a),e.removeEventListener(`pointerleave`,c)}},[h,t]),b(()=>{if(!m)return;let e=e=>{let n=o.current;n!==null&&e.target instanceof Node&&n.contains(e.target)||(h(OP(l.current,{type:`outside`})),JP(t.current,null))};return document.addEventListener(`pointerdown`,e,!0),()=>document.removeEventListener(`pointerdown`,e,!0)},[h,m,t]);let g=e=>{let n=s.current;if(n===null)return;if(e.key===`Escape`){e.preventDefault(),h(OP(l.current,{type:`hide`})),JP(t.current,null);return}if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let r=l.current.selection.visible?l.current.selection.dataX:null,i=xP(n.stops,r,e.key===`ArrowRight`?1:-1);if(i===null)return;let a=qP(i,o.current,t.current,n);h(OP(l.current,{type:`key`,dataX:i,anchorX:a.x,anchorY:a.y})),JP(t.current,i)},y=e=>{o.current=e},x=$(`relative min-w-0 touch-pan-y outline-none focus-visible:ring-2 focus-visible:ring-primary`,i?`inline-block w-full`:`w-full`),S=d===null?null:v(YP,{view:d}),w=d!==null&&typeof document<`u`?Oo(v(`div`,{className:`sr-only`,"aria-live":`polite`,"data-chart-tooltip-live":``,children:d.body.liveText}),document.body):null;return c(i?`span`:`div`,{ref:y,className:x,"data-chart-shell":``,"data-chart-kind":n,tabIndex:e===null?void 0:0,"aria-label":r,onKeyDown:g,children:[a,S,w]})}E();var ZP=null;function QP(){if(typeof document>`u`||typeof window>`u`||typeof window.matchMedia!=`function`)return!1;try{return document.createElement(`canvas`).getContext(`2d`)!==null}catch{return!1}}function $P(){return ZP===null&&(ZP=QP()?a(()=>import(`./uPlot.esm-B6hGABOr.js`).then(e=>e.default),[],import.meta.url).catch(()=>null):Promise.resolve(null)),ZP}function eF({optionsKey:e,buildOptions:t,data:n,height:r,onInstance:i,className:a,inline:o=!1,tooltip:s=null,kind:c,label:l}){let u=f(null),d=f(null),[p,m]=C(null),h=f({buildOptions:t,data:n,onInstance:i});h.current={buildOptions:t,data:n,onInstance:i},b(()=>{let e=!0;return $P().then(t=>{e&&t!==null&&m(()=>t)}),()=>{e=!1}},[]),b(()=>{let e=u.current;if(p===null||e===null)return;let t=Math.max(1,Math.floor(e.clientWidth)),n=new p({...h.current.buildOptions(t,p),width:t,height:r},h.current.data,e);return n.over.style.touchAction=`pan-y`,n.root.style.touchAction=`pan-y`,d.current=n,h.current.onInstance?.(n),()=>{h.current.onInstance?.(null),n.destroy(),d.current=null}},[p,e,r]),b(()=>{d.current?.setData(n)},[n]),b(()=>{let e=u.current;if(e===null||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=Math.floor(e[0]?.contentRect.width??0),n=d.current;n!==null&&t>0&&t!==n.width&&n.setSize({width:t,height:r})});return t.observe(e),()=>t.disconnect()},[r]),b(()=>{if(typeof MutationObserver>`u`)return;let e=new MutationObserver(()=>d.current?.redraw(!1,!0));return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[]);let g=e=>{u.current=e};return v(XP,{spec:s,plotRef:d,kind:c,label:l,inline:o,children:o?v(`span`,{ref:g,className:a??`block w-full min-w-0`,"data-chart-plot":``}):v(`div`,{ref:g,className:a??`w-full min-w-0`,"data-chart-plot":``})})}E();function tF({title:e,layers:t,buckets:n,bucketMs:r,range:i,unit:a=null,formatValue:o,displayPreference:s,height:l,stacked:u,showTotal:d=!1,syncKey:m,pending:h=!1,emptyMessage:g,actions:y,footer:b,windowToggle:x,compact:S=!1,minBarFraction:w=0,selectedIndex:T=null,onSelect:E,bucketLabel:D,bucketTestId:O,className:k}){let A=q(),j=l??(S?24:100),M=u??t.length>1,N=_(e=>(o??lP)(e,a),[o,a]),F=p(()=>M?dP(n,t.length):t.map((e,t)=>n.map(e=>e.values[t]??null)),[n,t,M]),I=p(()=>fP(n,t.length),[n,t.length]),[L,R]=C(null),z=p(()=>({xMin:i.from,xMax:i.to,stops:n.map(e=>e.t),resolve:e=>{let o=bP(n,r,e);if(o===null)return null;let c=n[o];return c===void 0?null:zP({rangeLabel:RP(c.t,r,i.to-i.from),preference:s,layers:t.map((e,t)=>({id:e.id,label:e.label,value:c.values[t]??null,unit:a}))})},onDataX:e=>{R(e===null?null:bP(n,r,e))}}),[n,r,i,t,a,s]),B=f({buckets:n,tops:F,range:i,selectedIndex:T,onSelect:E,bucketLabel:D,fmt:N});B.current={buckets:n,tops:F,range:i,selectedIndex:T,onSelect:E,bucketLabel:D,fmt:N};let V=`${t.map(e=>`${e.id}:${e.colorIndex}`).join(`,`)}#${S?`C`:``}#${M?`S`:``}#${m??``}#${String(r)}`,H=p(()=>{let e=F.at(-1)??[],t=M?e:n.map((e,t)=>Math.max(...F.map(e=>e[t]??0)));return[n.map(e=>e.t),t.map(e=>e??null)]},[n,F,M,T]),U=_(()=>{let e={floor:0};return{ms:1,legend:{show:!1},padding:S?[0,0,0,0]:[8,30,0,0],scales:{x:{time:!0,range:()=>[B.current.range.from,B.current.range.to]},y:{range:t=>{let n=XN([...t.data[1]??[]],e);return[n[0],n[1]]}}},axes:S?[{show:!1,scale:`x`},{show:!1,scale:`y`}]:[YN(()=>B.current.range.to-B.current.range.from),{...$N(`y`,3,e=>B.current.fmt(e),!0),splits:(t,n,r,i)=>QN([r,i],e)}],series:[{},{scale:`y`,stroke:()=>`transparent`,points:{show:!1},paths:()=>null}],cursor:{...eP(m),points:{show:!1}},hooks:{draw:[e=>{let{buckets:n,tops:i,selectedIndex:a}=B.current,o=e.ctx,s=e.valToPos(0,`y`,!0),c=w*e.bbox.height,l=Math.max(1,Math.round(devicePixelRatio));o.save(),n.forEach((n,u)=>{let d=e.valToPos(n.t,`x`,!0),f=e.valToPos(n.t+r,`x`,!0),p=Math.max(1,f-d-l),m=s;t.forEach((n,r)=>{let a=i[r]?.[u];if(a==null||!(a>(M&&r>0?i[r-1]?.[u]??0:0)))return;let f=e.valToPos(a,`y`,!0),h=M?m:s;r===t.length-1&&s-f<c&&(f=s-c),o.fillStyle=cN(rN(n.colorIndex).token);let g=Math.max(1,h-f-(M&&r>0?l:0));o.fillRect(d,f,p,g),m=f}),a===u&&(o.strokeStyle=cN(`primary`),o.lineWidth=l*1.5,o.strokeRect(d,e.bbox.top+l,p,e.bbox.height-2*l))}),o.restore()}],setCursor:[e=>{let t=e.cursor.left??-1,n=t<0?null:pP(B.current.buckets,r,e.posToVal(t,`x`));R(n);let i=n===null?void 0:B.current.buckets[n],a=i===void 0||n===null?``:B.current.bucketLabel?.(i,n)??``;e.over.title=a}],ready:[e=>{e.over.addEventListener(`click`,()=>{let t=e.cursor.left??-1;if(t<0)return;let n=pP(B.current.buckets,r,e.posToVal(t,`x`));n!==null&&B.current.onSelect?.(n)})}]}}},[V,w]),ee=i.to-i.from,W=L===null?void 0:n[L],G=t.map((e,t)=>{let n=W?W.values[t]:I.known?I.perLayer[t]:void 0;return{id:e.id,label:e.label,token:rN(e.colorIndex).token,value:n==null?W?`—`:void 0:N(n)}}),te=A(`uiLibrary.charts.barSummary`,`{{title}}, {{from}} to {{to}}: total {{total}}`,{title:e,from:PN(i.from,ee),to:PN(i.to,ee),total:I.known?N(I.total):A(`uiLibrary.charts.unknown`,`unknown`)}),ne=E===void 0?null:v(`div`,{className:`sr-only`,children:n.map((e,t)=>{let n=e.values.reduce((e,t)=>e+(t??0),0);return n<=0?null:v(`button`,{type:`button`,"data-testid":O,"aria-pressed":T===t,onClick:()=>E(t),children:D?.(e,t)??`${PN(e.t,ee)} ${N(n)}`},e.t)})}),re=v(eF,{optionsKey:V,buildOptions:U,data:H,height:j,tooltip:z,kind:`bars`,label:e});if(S)return c(`div`,{className:$(`relative min-w-0`,k),children:[v(`div`,{role:`img`,"aria-label":te,children:re}),ne]});let K=d&&I.known?A(`uiLibrary.charts.total`,`Total {{value}}`,{value:N(I.total)}):null,ie=!I.known,ae=j<=64?`sm`:j<=120?`md`:`lg`;return v(dN,{title:e,actions:c(P,{children:[K&&v(`span`,{className:`text-[11px] tabular-nums text-foreground`,children:K}),x&&v(uP,{...x}),y]}),readoutTime:W?FN(W.t,ee):null,legend:t.length>1||W?G:[],summary:te,footer:b,placeholder:h?v(hN,{message:A(`uiLibrary.charts.loading`,`Loading…`),height:ae}):ie?v(hN,{message:g??A(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`),height:ae}):void 0,controls:ne,className:k,children:re})}E();var nF=[`motion`,`object`,`audio`],rF={motion:6,object:5,audio:4},iF=.15;function aF({windowFrom:e,windowTo:t,buckets:n,selectedIndex:r,onSelectBucket:i}){let a=q(),o=p(()=>n.filter(e=>e.total>0&&e.dominant!==null),[n]),s=p(()=>o.map(e=>({t:e.startMs,values:nF.map(t=>e.counts[t])})),[o]),c=p(()=>nF.map(e=>({id:e,label:a(`uiLibrary.eventHeatmap.kind.${e}`,e),colorIndex:rF[e]})),[a]),l=n[0],u=l?Math.max(1,l.endMs-l.startMs):1,d=r===null?null:o.findIndex(e=>e.index===r);return v(`div`,{className:`rounded bg-background/40`,children:v(tF,{compact:!0,title:a(`uiLibrary.eventHeatmap.title`,`Event density`),layers:c,buckets:s,bucketMs:u,range:{from:e,to:t},stacked:!0,minBarFraction:iF,selectedIndex:d===null||d<0?null:d,onSelect:e=>{let t=o[e];t&&i(t.index)},bucketTestId:`heatmap-bar`,bucketLabel:(e,t)=>{let n=o[t];return n?a(`uiLibrary.eventHeatmap.bucketTitle`,`{{time}} · motion {{motion}} · object {{object}}`,{time:new Date(n.startMs).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`}),motion:n.counts.motion,object:n.counts.object}):``}})})}function oF(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`}function sF(e){let t=e.split(`-`),n=t[0]===void 0?NaN:parseInt(t[0],10),r=t[1]===void 0?NaN:parseInt(t[1],10),i=t[2]===void 0?NaN:parseInt(t[2],10);return isNaN(n)||isNaN(r)||isNaN(i)?null:new Date(n,r-1,i)}function cF({day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i}){let a=q(),o=e=>{let n=sF(e.target.value);n!==null&&t(n)},s=n.toMs-n.fromMs,l=(()=>{let e=0,t=1/0;for(let n=0;n<UM.length;n++){let r=UM[n];if(r===void 0)continue;let i=Math.abs(r-s);i<t&&(t=i,e=n)}return e})(),u=n.toMs,d=()=>{let e=UM[Math.min(l+1,UM.length-1)];e!==void 0&&i(WM(r,e,u))},f=()=>{let e=UM[Math.max(l-1,0)];e!==void 0&&i(WM(r,e,u))},p=l<UM.length-1,m=l>0,h=Math.max(1,Math.round(s*.9)),g=n.fromMs>r.fromMs,_=n.toMs<r.toMs;return c(`div`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`date`,value:oF(e),max:oF(new Date),onChange:o,className:`rounded border border-border bg-background px-2 py-0.5 text-[11px] text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":a(`uiLibrary.timelineControls.day`,`Select recording day`)}),c(`div`,{className:`ml-auto flex items-center gap-1`,children:[v(`button`,{type:`button`,onClick:()=>{i(GM(n,r,-h))},disabled:!g,title:a(`uiLibrary.timelineControls.earlierTitle`,`Earlier (pan back)`),"aria-label":a(`uiLibrary.timelineControls.earlier`,`Pan earlier`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(ge,{size:14})}),v(`button`,{type:`button`,onClick:()=>{i(GM(n,r,h))},disabled:!_,title:a(`uiLibrary.timelineControls.laterTitle`,`Later (pan forward)`),"aria-label":a(`uiLibrary.timelineControls.later`,`Pan later`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(It,{size:14})}),v(`span`,{className:`mx-0.5 h-3 w-px bg-border`,"aria-hidden":`true`}),v(`button`,{type:`button`,onClick:f,disabled:!m,title:a(`uiLibrary.timelineControls.zoomOut`,`Zoom out`),"aria-label":a(`uiLibrary.timelineControls.zoomOut`,`Zoom out`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(Kr,{size:13})}),v(`button`,{type:`button`,onClick:d,disabled:!p,title:a(`uiLibrary.timelineControls.zoomIn`,`Zoom in`),"aria-label":a(`uiLibrary.timelineControls.zoomIn`,`Zoom in`),className:`rounded p-1 text-foreground-subtle transition-colors hover:bg-background/60 hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:v(kr,{size:13})})]}),v(`span`,{className:`text-[9px] text-foreground-subtle`,children:lF(s)})]})}function lF(e){let t=e/36e5;if(t>=24)return`24h`;if(t>=1)return`${Math.round(t)}h`;let n=e/6e4;return`${Math.round(n)}m`}E();var uF=18e3/100;function dF({day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i,buckets:a,selectedBucketIndex:o,onSelectBucket:s,densityLoading:l}){let u=q(),d=f(null),p=_(e=>{let t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;t!==0&&(e.preventDefault(),i(GM(n,r,t*uF)))},[n,r,i]),m=JM(n.fromMs,n.toMs,5);return c(`div`,{className:`space-y-1`,children:[v(cF,{day:e,onDayChange:t,view:n,dayBounds:r,onViewChange:i}),c(`div`,{ref:d,onWheel:p,className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:u(`uiLibrary.clipBandBar.eventsDensity`,`Events · density`)}),l?v(`div`,{className:`h-6 animate-pulse rounded bg-background/40`}):v(aF,{windowFrom:n.fromMs,windowTo:n.toMs,buckets:a,selectedIndex:o,onSelectBucket:s}),v(`div`,{className:`relative h-3`,children:m.map(e=>v(`span`,{className:`absolute -translate-x-1/2 text-[9px] text-foreground-subtle`,style:{left:`${String(e.pct)}%`},children:e.label},e.pct))})]})]})}E();var fF=Kn(`camstack:vod-playback`,{request:null,play:()=>{},clear:()=>{}});function pF({children:e}){let[t,n]=C(null),r=p(()=>({request:t,play:e=>n(e),clear:()=>n(null)}),[t]);return v(fF.Provider,{value:r,children:e})}function mF(){return I(fF)}E();var hF=Il(`rounded-lg p-3`,{variants:{variant:{flat:`bg-surface`,bordered:`bg-surface border border-border`}},defaultVariants:{variant:`bordered`}}),gF=D(({className:e,variant:t,...n},r)=>v(`div`,{ref:r,className:$(hF({variant:t}),e),...n}));gF.displayName=`Card`,E();var _F=[`low`,`mid`,`high`];function vF({deviceId:e,clip:t,profile:n,onProfileChange:r}){let i=q(),a=mF(),o=gk({deviceId:e,clipId:t.id,profile:n}),s=o.data,l=`${new Date(t.timeRange.startMs).toLocaleString()} · ${t.source}`;return b(()=>{s!==void 0&&a.play({url:bt(s.playbackUrl),...s.format===void 0?{}:{format:s.format},label:l})},[s,l]),c(gF,{className:`space-y-2 text-sm`,children:[v(`div`,{className:`font-medium text-foreground`,children:l}),c(`div`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`mr-1 text-[10px] uppercase tracking-wide text-foreground-subtle`,children:i(`uiLibrary.clipPanel.quality`,`Quality`)}),_F.map(e=>v(_A,{variant:e===n?`primary`:`secondary`,"aria-pressed":e===n,onClick:()=>r(e),children:e},e))]}),o.status===`pending`?c(`div`,{className:`space-y-1`,children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:i(`uiLibrary.clipPanel.preparing`,`Preparing the clip — the file is fetched and muxed once…`)}),v(hM,{className:`h-4 w-48`})]}):o.status===`error`?v(eN,{title:i(`uiLibrary.clipPanel.prepareFailed`,`This clip could not be prepared`),message:o.error?.message??i(`uiLibrary.clipPanel.noReasonGiven`,`no reason given`)}):s===void 0?null:c(`div`,{className:`space-y-2`,children:[s.served===void 0||s.served===n?null:v(eN,{variant:`warning`,message:v(gi,{uiKey:`uiLibrary.clipPanel.servedFallback`,fallback:`Served the <0>{{served}}</0> stream — this clip has no {{profile}} twin.`,components:[v(`strong`,{},`served`)],values:{served:s.served,profile:n}})}),c(`a`,{href:bt(s.playbackUrl),download:!0,className:`inline-flex items-center gap-1.5 text-xs font-medium text-primary hover:underline`,children:[v(nn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),i(`uiLibrary.clipPanel.download`,`Download this clip`)]})]})]})}function yF(e){let t=Math.round(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}var bF={sleeping:(e,t)=>t(`uiLibrary.clipTile.refusal.sleeping`,`The camera is asleep — a still would cost a wake`),"camera-refused":(e,t)=>t(`uiLibrary.clipTile.refusal.camera_refused`,`The camera refused — {{reason}}`,{reason:e}),"no-keyframe":(e,t)=>t(`uiLibrary.clipTile.refusal.no_keyframe`,`No decodable frame inside this window`),unsupported:(e,t)=>t(`uiLibrary.clipTile.refusal.unsupported`,`This source cannot produce stills`),"queue-full":(e,t)=>t(`uiLibrary.clipTile.refusal.queue_full`,`Waiting for the camera — its still queue is full`),"camera-backoff":(e,t)=>t(`uiLibrary.clipTile.refusal.camera_backoff`,`The camera is resting after refusing — trying again shortly`),"no-catalog-row":(e,t)=>t(`uiLibrary.clipTile.refusal.no_catalog_row`,`This clip is no longer in the catalog`),"unknown-device":(e,t)=>t(`uiLibrary.clipTile.refusal.unknown_device`,`This camera is not served here`),"uid-missing":(e,t)=>t(`uiLibrary.clipTile.refusal.uid_missing`,`The camera’s id is not known yet`)};function xF(e,t,n){let r=e===void 0?void 0:bF[e];return r===void 0?t:r(t,n)}function SF(e,t,n){return{kind:`unavailable`,reason:e,text:xF(n,e,t)}}function CF(e,t=Fn){return e.thumbnail===void 0?e.thumbnailUnavailable===void 0?e.thumbnailMint===void 0?{kind:`none`,text:t(`uiLibrary.clipTile.noStill`,`This clip carries no still and offered none`)}:{kind:`mint`,url:e.thumbnailMint}:SF(e.thumbnailUnavailable.reason,t,e.thumbnailUnavailable.reason):{kind:`vouched`,url:e.thumbnail}}function wF(e,t=Fn){return e.disposition===`deferred`?{kind:`deferred`,reason:e.reason,text:xF(e.code,e.reason,t),retryAfterMs:e.retryAfterMs??null}:SF(e.reason,t,e.code)}async function TF(e,t,n=Fn){let r;try{r=await t(e,{credentials:`same-origin`})}catch(e){return DF(e,n)}if(r.status===204)return wF(EF(r,n),n);if(!r.ok)return wF({code:void 0,reason:n(`uiLibrary.clipThumbnail.httpStatus`,`HTTP {{status}}`,{status:String(r.status)}),disposition:void 0},n);try{return{kind:`image`,blob:await r.blob()}}catch(e){return DF(e,n)}}function EF(e,t){let n=e.headers.get(`retry-after`),r=n===null?NaN:Number(n);return{code:e.headers.get(`x-camstack-reason-code`)??void 0,reason:e.headers.get(`x-camstack-reason`)??t(`uiLibrary.clipThumbnail.noReason`,`no reason given`),disposition:e.headers.get(`x-camstack-disposition`)??void 0,retryAfterMs:Number.isFinite(r)&&r>0?r*1e3:null}}function DF(e,t){return wF({code:void 0,reason:e instanceof Error?e.message:String(e),disposition:`deferred`},t)}var OF=4e3,kF=3e4,AF=.25;function jF(e){if(e.attempt>=4||e.attempt<0)return null;let t=OF*2**e.attempt,n=Math.max(t,e.serverHintMs??0),r=Math.min(n,kF),i=1+(e.random()*2-1)*AF;return{waitMs:Math.round(r*i)}}E();function MF(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function NF(e){let t=q(),n=f(t);n.current=t;let r=p(()=>CF(e,t),[e.thumbnail,e.thumbnailMint,e.thumbnailUnavailable?.reason,t]),[i,a]=C(null),o=r.kind===`mint`?r.url:null;return b(()=>{if(a(null),o===null||typeof fetch!=`function`)return;let e=null,t=!1,r,i=async s=>{let c=await TF(bt(o),fetch,n.current);if(t)return;if(c.kind===`image`){e=URL.createObjectURL(c.blob),a({kind:`vouched`,url:e});return}if(c.kind!==`deferred`){a(c);return}let l=jF({attempt:s,serverHintMs:c.retryAfterMs,random:Math.random});if(l===null){a({kind:`unavailable`,reason:c.reason,text:c.text});return}r=setTimeout(()=>{i(s+1)},l.waitMs)};return i(0),()=>{t=!0,r!==void 0&&clearTimeout(r),e!==null&&URL.revokeObjectURL(e)}},[o]),i??r}function PF({clip:e,selected:t,onSelect:n}){let r=q(),i=NF(e),a=e.playable!==!1,o=[...e.labels??[],...e.behaviours??[]];return v(`li`,{children:v(`button`,{type:`button`,onClick:()=>n(e),disabled:!a,"aria-current":t?`true`:void 0,className:`block w-full text-left disabled:cursor-not-allowed`,children:c(gF,{className:`flex gap-3 transition-colors ${t?`border-primary`:``} ${a?`hover:bg-surface-hover`:`opacity-70`}`,children:[v(`div`,{className:`flex h-16 w-28 shrink-0 items-center justify-center overflow-hidden rounded bg-surface-hover text-[10px] text-foreground-subtle`,children:i.kind===`vouched`?v(`img`,{src:i.url,alt:``,className:`h-full w-full object-cover`}):i.kind===`mint`||i.kind===`deferred`?v(`span`,{role:`status`,"aria-label":i.kind===`mint`?r(`uiLibrary.clipTile.loadingStill`,`Loading the still`):i.text,className:`h-full w-full`,children:v(hM,{className:`h-full w-full rounded-none`})}):v(`span`,{className:`px-1 text-center leading-tight`,children:i.text})}),c(`div`,{className:`min-w-0 flex-1 space-y-1`,children:[c(`div`,{className:`flex items-baseline gap-2`,children:[v(`span`,{className:`text-sm font-medium text-foreground`,children:MF(e.timeRange.startMs)}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.inProgress===!0?r(`uiLibrary.clipTile.recording`,`Recording…`):yF(e.timeRange.endMs-e.timeRange.startMs)})]}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:e.source}),o.length===0&&e.nativeTypes===void 0?null:c(`div`,{className:`flex flex-wrap gap-1`,children:[o.map(e=>v(Bk,{variant:`info`,children:e},`label:${e}`)),(e.nativeTypes??[]).map(e=>v(Bk,{style:`outline`,children:e},`native:${e}`))]}),a?null:v(`div`,{className:`text-[11px] text-warning`,children:r(`uiLibrary.clipTile.notPlayable`,`Not playable — {{reason}}`,{reason:e.unplayableReason??r(`uiLibrary.clipTile.noReason`,`the source gave no reason`)})})]})]})})})}function FF(e){return e<10?`0${String(e)}`:String(e)}function IF(e){let[t,n,r]=e.split(`-`).map(e=>Number(e));return new Date(t??1970,(n??1)-1,r??1,0,0,0,0)}function LF(e){return`${String(e.getFullYear())}-${FF(e.getMonth()+1)}-${FF(e.getDate())}`}function RF(e,t){let n=IF(e);return n.setDate(n.getDate()+t),LF(n)}function zF(e){return IF(e).toLocaleDateString(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`})}var BF=366;function VF(e){let t=Math.max(e.fromMs,e.toMs-1),n=LF(new Date(t)),r=LF(new Date(e.fromMs)),i=0;for(;r<=n&&i<BF;)i+=1,r=RF(r,1);return i}function HF(e){let t=VF(e);return t>2?{kind:`too-wide`,band:e,localDays:t,maxLocalDays:2}:{kind:`askable`,band:e,localDays:t}}function UF(e,t){return t===null?{fromMs:e.fromMs,toMs:e.toMs}:{fromMs:Math.max(t.startMs,e.fromMs),toMs:Math.min(t.endMs,e.toMs)}}function WF(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function GF(e){let t=LF(new Date(e.fromMs)),n=LF(new Date(Math.max(e.fromMs,e.toMs-1)));return t===n?`${zF(t)}, ${WF(e.fromMs)} – ${WF(e.toMs)}`:`${zF(t)} ${WF(e.fromMs)} – ${zF(n)} ${WF(e.toMs)}`}var KF={ok:{headlineKey:`uiLibrary.clipSource.state.ok`,headlineFallback:`Answering`,tone:`ok`,answered:!0},sleeping:{headlineKey:`uiLibrary.clipSource.state.sleeping`,headlineFallback:`Asleep — showing the catalog read while it was awake`,tone:`warn`,answered:!0},unreachable:{headlineKey:`uiLibrary.clipSource.state.unreachable`,headlineFallback:`Could not be reached — its clips are missing from this list`,tone:`error`,answered:!1},"no-storage":{headlineKey:`uiLibrary.clipSource.state.no_storage`,headlineFallback:`No storage card — this camera keeps nothing of its own`,tone:`warn`,answered:!1},"index-empty":{headlineKey:`uiLibrary.clipSource.state.index_empty`,headlineFallback:`The camera's calendar marks these days, and its own index lists nothing`,tone:`warn`,answered:!1}};function qF(e,t=Fn){let n=KF[e.availability.state];return{source:e.source,label:e.label,headline:t(n.headlineKey,n.headlineFallback),detail:e.availability.reason??null,tone:n.tone,answered:n.answered}}function JF(e,t=Fn){if(e.plan.kind===`too-wide`)return{kind:`refused`,band:e.plan.band,localDays:e.plan.localDays,maxLocalDays:e.plan.maxLocalDays};if(e.clipsStatus===`error`)return{kind:`failed`,message:e.clipsError??t(`uiLibrary.clipView.clipsFailed`,`The clip list could not be read`)};if(e.sourcesStatus===`error`&&e.clips.length===0)return{kind:`failed`,message:e.sourcesError??t(`uiLibrary.clipView.sourcesFailed`,`The source list could not be read`)};let n=e.sources.map(e=>qF(e,t)),r=n.filter(e=>e.answered),i=n.filter(e=>!e.answered),a=e.clips;return e.provider===null&&e.sourcesStatus===`success`?{kind:`empty`,band:e.plan.band,answered:r,silent:i,nobodyAnswered:!0}:e.clipsStatus===`pending`||e.sourcesStatus===`pending`?{kind:`loading`}:a.length===0?{kind:`empty`,band:e.plan.band,answered:r,silent:i,nobodyAnswered:r.length===0}:{kind:`listed`,clips:a,answered:r,silent:i}}E();var YF=500,XF=60;function ZF({silent:e}){let t=q();return e.length===0?null:v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.silentSources`,{one:`One source contributed nothing to this list`,other:`{{count}} sources contributed nothing to this list`},{count:e.length}),message:v(`div`,{className:`space-y-1`,children:e.map(e=>c(`div`,{children:[v(`span`,{className:`font-medium`,children:e.label}),c(`span`,{className:`opacity-70`,children:[` (`,e.source,`)`]}),v(`div`,{children:e.headline}),e.detail===null?null:v(`div`,{className:`opacity-80 break-words`,children:e.detail})]},e.source))})})}function QF({deviceId:e}){let t=q(),[n,r]=C(()=>new Date),[i,a]=C(()=>HM(new Date,Date.now())),[o,s]=C(null),[l,u]=C(``),[d,f]=C(1),[m,h]=C(null),[g,_]=C(`low`),y=IM(`videoclips`),x=p(()=>HM(n,Date.now()),[n]),S=qM(i.toMs-i.fromMs),w=Ob({deviceId:e,since:i.fromMs,until:i.toMs,bucketMs:S}),T=p(()=>RM(w.data??[],i.fromMs,S),[w.data,i.fromMs,S]),E=o===null?void 0:T.find(e=>e.index===o),D=p(()=>UF(i,E===void 0?null:{startMs:E.startMs,endMs:E.endMs}),[i,E]),O=HF(D),k=hk({deviceId:e}),A=k.data??[],j=p(()=>l===``?A.find(e=>e.addonId!==void 0)?.addonId??``:l,[l,A]),M=mk({deviceId:e,since:D.fromMs,until:D.toMs,limit:YF,provider:j},{enabled:O.kind===`askable`&&j!==``}),N=JF({plan:O,provider:j===``?null:j,clipsStatus:M.status,clips:M.data??[],sourcesStatus:k.status,sources:A,...M.error?{clipsError:M.error.message}:{},...k.error?{sourcesError:k.error.message}:{}},t),F=p(()=>{let e=new Map;for(let t of A){let n=t.addonId;if(n===void 0)continue;let r=e.get(n);r===void 0?e.set(n,[t.label]):r.push(t.label)}return[...e].map(([e,t])=>({value:e,label:t.join(` · `)}))},[A]);b(()=>{f(1)},[D.fromMs,D.toMs]);let I=e=>{r(e),a(HM(e,Date.now())),s(null)},L=e=>{a(e),s(null)},R=e=>{s(t=>t===e?null:e)},z=e=>{u(e),f(1)};if(y===`pending`)return c(`div`,{className:`space-y-2`,children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`uiLibrary.clipsSection.asking`,`Asking the registry whether this cluster serves clips…`)}),v(hM,{className:`h-24 w-full`})]});if(y===`unknown`)return v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.unknownTitle`,`Clip sources unknown`),message:t(`uiLibrary.clipsSection.unknownMessage`,`The capability registry could not be reached, so whether this camera has clip sources is unknown — not absent.`)});if(y===`absent`)return v(`div`,{role:`status`,children:v(QM,{icon:Un,title:t(`uiLibrary.clipsSection.absentTitle`,`No provider of videoclips in this cluster`),description:t(`uiLibrary.clipsSection.absentDescription`,`Nothing is installed that could list a camera's stored clips.`)})});let B=N.kind===`listed`?N.clips:[],V=B.slice((d-1)*XF,d*XF);return c(`div`,{className:`space-y-3`,children:[c(`div`,{children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:t(`uiLibrary.clipsSection.clips`,`Clips`)}),v(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.intro`,`Every source this camera has, side by side — CamStack's own recordings and whatever the camera or an export keeps of its own. A source is listed because it exists, not because it was switched on here; pick sources to narrow the view.`)}),v(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.periodHint`,`The list follows the period selected on the timebar below — the recording section's own control. Zoom out to widen it, pan or pick a day to move it, click a density bar to narrow it to that window.`)})]}),c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`label`,{htmlFor:`clips-provider`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:t(`uiLibrary.clipsSection.source`,`Source`)}),v(`div`,{className:`w-60`,children:v(Yl,{id:`clips-provider`,options:F,value:j,disabled:F.length<2,onChange:e=>z(e.target.value)})}),F.length<2?v(`span`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.clipsSection.oneProvider`,`This camera is bound to one clip provider today.`)}):null,c(`div`,{className:`ml-auto flex items-center gap-1`,children:[v(`span`,{className:`px-1 text-xs font-medium text-foreground`,children:GF(D)}),o===null?null:v(_A,{variant:`outline`,onClick:()=>s(null),children:t(`uiLibrary.clipsSection.expand`,`Expand to the visible window`)})]})]}),v(dF,{day:n,onDayChange:I,view:i,dayBounds:x,onViewChange:L,buckets:T,selectedBucketIndex:o,onSelectBucket:R,densityLoading:w.status===`pending`}),v(`section`,{"aria-label":t(`uiLibrary.clipsSection.clips`,`Clips`),className:`space-y-2`,children:N.kind===`refused`?v(eN,{variant:`warning`,title:t(`uiLibrary.clipsSection.tooWideTitle`,`That period is too wide to list`),message:t(`uiLibrary.clipsSection.tooWideMessage`,`{{band}} covers {{days}} local days, and a clip listing is asked one local day at a time — at most {{max}}. Nothing was asked for; narrow the band and the list follows it.`,{band:GF(N.band),days:N.localDays,max:N.maxLocalDays})}):N.kind===`loading`?c(P,{children:[v(`div`,{role:`status`,className:`text-xs text-foreground-subtle`,children:t(`uiLibrary.clipsSection.loadingFor`,`Loading clips for {{band}}…`,{band:GF(D)})}),v(hM,{className:`h-24 w-full`})]}):N.kind===`failed`?v(eN,{title:t(`uiLibrary.clipsSection.listFailed`,`The clip list could not be read`),message:N.message}):N.kind===`empty`?c(P,{children:[v(`div`,{role:`status`,children:v(QM,{icon:Kt,title:N.nobodyAnswered?t(`uiLibrary.clipsSection.noSourceAnswered`,`No source could answer for {{band}}`,{band:GF(N.band)}):t(`uiLibrary.clipsSection.noClips`,`No clips in {{band}}`,{band:GF(N.band)}),...N.nobodyAnswered?{}:{description:t(`uiLibrary.clipsSection.asked`,`Asked {{sources}}.`,{sources:N.answered.map(e=>e.label).join(`, `)})}})}),v(ZF,{silent:N.silent})]}):c(P,{children:[v(ZF,{silent:N.silent}),v(`ul`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3`,children:V.map(e=>v(PF,{clip:e,selected:m?.id===e.id,onSelect:h},`${e.source}:${e.id}`))}),v(ZM,{currentPage:d,totalItems:B.length,pageSize:XF,onPageChange:f,itemNoun:t(`uiLibrary.clipsSection.itemNoun`,`clips`)})]})}),m===null?null:v(vF,{deviceId:e,clip:m,profile:g,onProfileChange:_})]})}function $F(e,t){let n=e.slot;return t.some(e=>e===n)}function eI(e,t=Aee,n=Fn){let r=e=>t.indexOf(e);if(e.status===`pending`)return{kind:`pending`};if(e.status===`error`)return{kind:`unknown`,reason:e.error?.message??n(`uiLibrary.extensions.requestFailed`,`the request failed`)};let i=e.data??[];if(i.length===0)return{kind:`none`};let a=[],o=[],s=[];for(let e of i)e.state===`ok`?$F(e,t)?a.push(e):o.push({slot:e.slot,slotRef:e.slotRef}):s.push(e);return{kind:`rows`,slots:a.toSorted((e,t)=>r(e.slot)-r(t.slot)),unknownSlots:o,unreachable:s}}function tI(e,t,n){return e.includes(t)?e.filter(e=>e!==t):n===`one`?[t]:[...e,t]}function nI(e,t){return e.filter(e=>e.suggested&&!t.includes(e.deviceId))}function rI(e,t,n){let r=n.trim().toLowerCase();return r.length===0?[]:e.filter(e=>!t.includes(e.deviceId)&&[e.name,e.location??``,e.parentName??``,e.type].some(e=>e.toLowerCase().includes(r)))}function iI(e,t){return e.length!==t.length||e.some((e,n)=>t[n]!==e)}function aI(e){return e.slot===`linked-devices`?e.trackedDeviceIds:void 0}function oI(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function sI(e,t){return e.length!==t.length||e.some(e=>!t.includes(e))}function cI(e){let t=[],n=new Set,r=(e,r)=>{n.has(e)||(n.add(e),t.push({deviceId:e,origin:r}))};for(let t of e.picks)e.invalidPicks.includes(t)||r(t,`pick`);for(let t of e.implied)r(t,`implied`);for(let t of e.tracked)r(t,`not-linked`);return t}function lI(e,t,n){return n.includes(t)?e:e.filter(e=>e!==t)}function uI(e,t,n){return e.slot===`linked-devices`&&n!==void 0?{slot:`linked-devices`,deviceIds:[...t],trackedDeviceIds:[...n]}:{slot:e.slot,deviceIds:[...t]}}E();function dI(e,t){switch(e){case`ok`:return t(`uiLibrary.associationSlotCard.healthOk`,`OK`);case`missing`:return t(`uiLibrary.associationSlotCard.healthMissing`,`Missing`);case`foreign`:return t(`uiLibrary.associationSlotCard.healthForeign`,`Other owner`);case`unavailable`:return t(`uiLibrary.associationSlotCard.healthUnavailable`,`Not a valid source`)}}var fI={ok:`success`,missing:`danger`,foreign:`warning`,unavailable:`warning`};function pI({sources:e,tracked:t}){let n=q();return e.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:n(`uiLibrary.associationSlotCard.noDevicesPicked`,`No devices picked.`)}):v(`ul`,{className:`flex flex-col gap-1`,children:e.map(e=>c(`li`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[v(`span`,{className:`text-foreground`,children:e.name??n(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e.deviceId})}),v(Bk,{variant:fI[e.health],children:dI(e.health,n)}),t?.includes(e.deviceId)===!0&&v(Bk,{variant:`info`,children:n(`uiLibrary.associationSlotCard.trackedEvents`,`Tracked events`)}),e.detail!==void 0&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.detail})]},e.deviceId))})}function mI({row:e}){let t=q(),n=e.activation;return n===null?null:c(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px] text-foreground-subtle`,children:[v(Bk,{variant:n.state===`active`?`success`:n.state===`inactive`?`warning`:`default`,children:n.state===`active`?t(`uiLibrary.associationSlotCard.active`,`Active`):n.state===`inactive`?t(`uiLibrary.associationSlotCard.inactive`,`Inactive`):t(`uiLibrary.associationSlotCard.unknown`,`Unknown`)}),v(`span`,{children:t(`uiLibrary.associationSlotCard.setBy`,`set by {{authority}}`,{authority:n.authority})}),n.detail!==void 0&&v(`span`,{children:n.detail})]})}function hI({sources:e,tracked:t}){let n=q();return e.length===0?null:c(`div`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:n(`uiLibrary.associationSlotCard.alwaysLinked`,`Always linked (device tree):`)}),v(`ul`,{"aria-label":n(`uiLibrary.associationSlotCard.alwaysLinkedAria`,`Always linked`),className:`flex flex-col gap-1`,children:e.map(e=>c(`li`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[v(`span`,{className:`text-foreground`,children:e.name??n(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e.deviceId})}),t?.includes(e.deviceId)===!0&&v(Bk,{variant:`info`,children:n(`uiLibrary.associationSlotCard.trackedEvents`,`Tracked events`)})]},e.deviceId))})]})}function gI(e,t){switch(e){case`pick`:return null;case`implied`:return t(`uiLibrary.associationSlotCard.originImplied`,`always linked`);case`not-linked`:return t(`uiLibrary.associationSlotCard.originNotLinked`,`not linked any more — untick to remove`)}}function _I({options:e,tracked:t,nameOf:n,onToggle:r}){let i=q();return e.length===0?null:c(`fieldset`,{className:`flex flex-col gap-1`,children:[v(`legend`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.associationSlotCard.produceTracked`,`Produce tracked events on this camera (opt-in):`)}),e.map(({deviceId:e,origin:a})=>c(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground`,children:[v(`input`,{type:`checkbox`,"aria-label":i(`uiLibrary.associationSlotCard.trackedFrom`,`Tracked events from {{name}}`,{name:n(e)}),checked:t.includes(e),onChange:()=>r(e)}),n(e),gI(a,i)!==null&&c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`· `,gI(a,i)]})]},e))]})}function vI({deviceId:e,row:t,onSaved:n,readOnly:r=!1}){let i=f(null);As(i);let a=q(),o=kee[t.slot].descriptor,s=t.value.deviceIds,l=aI(t.value),u=t.impliedSources??[],d=u.map(e=>e.deviceId),p=t.sources.filter(e=>e.health===`unavailable`).map(e=>e.deviceId),[m,h]=C(!1),[g,_]=C(s),[y,b]=C(l??[]),[x,S]=C(``),[w,T]=C(null),E=mp({deviceId:e,slotRef:t.slotRef},{enabled:m}),D=hp(),O=E.data?.candidates??[],k=e=>O.find(t=>t.deviceId===e)?.name??t.sources.find(t=>t.deviceId===e)?.name??u.find(t=>t.deviceId===e)?.name??a(`uiLibrary.associationSlotCard.deviceN`,`Device {{id}}`,{id:e}),A=e=>{_(tI(g,e,o.cardinality)),b(lI(y,e,d))},j=()=>{_(s),b(l??[]),T(null),h(!0)},M=async()=>{T(null);try{await D.mutateAsync({deviceId:e,slotRef:t.slotRef,value:uI(t.value,g,l===void 0?void 0:y)}),h(!1),n()}catch(e){T(e instanceof Error?e.message:String(e))}};return c(`div`,{role:`group`,"aria-label":o.label,className:`flex flex-col gap-2 rounded-md border border-border/40 bg-surface-elevated/30 p-3`,children:[c(`div`,{className:`flex items-start justify-between gap-2`,children:[c(`div`,{className:`flex flex-col gap-0.5`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:o.label}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:o.description}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.storedIn`,`Stored in {{authority}}`,{authority:t.authority})})]}),!m&&!r&&v(_A,{variant:`outline`,size:`sm`,onClick:j,children:a(`uiLibrary.associationSlotCard.edit`,`Edit`)})]}),v(mI,{row:t}),!m&&v(pI,{sources:t.sources,tracked:l}),!m&&v(hI,{sources:u,tracked:l}),m&&c(`div`,{className:`flex flex-col gap-2`,children:[v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.pickedDevices`,`Picked devices`),className:`flex flex-wrap gap-1.5`,children:g.map(e=>v(`li`,{children:c(`button`,{type:`button`,"aria-label":a(`uiLibrary.associationSlotCard.removeN`,`Remove {{name}}`,{name:k(e)}),onClick:()=>A(e),className:`inline-flex items-center gap-1 rounded-full bg-primary/15 px-2 py-0.5 text-[11px] text-foreground`,children:[k(e),v(Zn,{className:`h-3 w-3`})]})},e))}),E.status===`pending`&&v(`p`,{role:`status`,className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.loadingCandidates`,`Loading candidates…`)}),E.status===`error`&&v(`p`,{role:`alert`,className:`text-[10px] text-danger`,children:a(`uiLibrary.associationSlotCard.candidatesError`,`Candidates could not be read: {{message}}`,{message:E.error.message})}),nI(O,g).length>0&&c(`div`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.suggested`,`Suggested — added only if you click them:`)}),v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.suggestions`,`Suggestions`),className:`flex flex-wrap gap-1.5`,children:nI(O,g).map(e=>v(`li`,{children:c(`button`,{type:`button`,"aria-label":a(`uiLibrary.associationSlotCard.addN`,`Add {{name}}`,{name:e.name}),onClick:()=>_(tI(g,e.deviceId,o.cardinality)),className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[11px] text-foreground-muted`,children:[v(Se,{className:`h-3 w-3`}),e.name,e.reason!==null&&c(`span`,{className:`text-foreground-subtle`,children:[`· `,e.reason]})]})},e.deviceId))})]}),v(`input`,{ref:i,type:`search`,"aria-label":a(`uiLibrary.associationSlotCard.searchDevices`,`Search devices`),value:x,onChange:e=>S(e.target.value),placeholder:a(`uiLibrary.associationSlotCard.searchPlaceholder`,`Search devices by name, location or type`),className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground outline-none focus:border-primary`}),rI(O,g,x).length>0&&v(`ul`,{"aria-label":a(`uiLibrary.associationSlotCard.searchResults`,`Search results`),className:`flex max-h-40 flex-col gap-0.5 overflow-y-auto`,children:rI(O,g,x).map(e=>v(`li`,{children:c(`button`,{type:`button`,onClick:()=>{_(tI(g,e.deviceId,o.cardinality)),S(``)},className:`w-full rounded px-2 py-1 text-left text-[11px] text-foreground hover:bg-surface-hover`,children:[e.name,e.parentName!==null&&v(`span`,{className:`ml-1 text-foreground-subtle`,children:a(`uiLibrary.associationSlotCard.inParent`,`in {{name}}`,{name:e.parentName})}),e.location!==null&&c(`span`,{className:`ml-1 text-foreground-subtle`,children:[`· `,e.location]})]})},e.deviceId))}),l!==void 0&&v(_I,{options:cI({picks:g,invalidPicks:p,implied:d,tracked:y}),tracked:y,nameOf:k,onToggle:e=>b(oI(y,e))}),w!==null&&v(`p`,{role:`alert`,className:`text-[11px] text-danger break-words`,children:a(`uiLibrary.associationSlotCard.notSaved`,`Not saved: {{reason}}`,{reason:w})}),c(`div`,{className:`flex justify-end gap-2`,children:[v(_A,{variant:`ghost`,size:`sm`,onClick:()=>h(!1),children:a(`uiLibrary.associationSlotCard.cancel`,`Cancel`)}),v(_A,{size:`sm`,disabled:!(iI(s,g)||l!==void 0&&sI(l,y))||D.isPending,onClick:()=>void M(),children:a(`uiLibrary.associationSlotCard.save`,`Save`)})]})]})]})}function yI({deviceId:e,slots:t,title:n,readOnly:r=!1}){let i=q(),a=pp({deviceId:e}),o=eI({status:a.status,data:a.data,error:a.error},void 0,i),s=e=>t===void 0||t.some(t=>t===e),l=o.kind===`rows`?o.slots.filter(e=>s(e.slot)):[],u=o.kind===`rows`?o.unknownSlots.filter(e=>s(e.slot)):[],d=n??i(`uiLibrary.extensionsPanel.title`,`Extensions`),f=o.kind===`rows`&&t!==void 0&&l.length===0&&u.length===0&&o.unreachable.length===0;return v($t,{title:d,icon:v(dr,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3`,children:c(`section`,{"aria-label":d,className:`flex flex-col gap-3`,children:[o.kind===`pending`&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.loading`,`Loading this device’s extensions…`)}),o.kind===`unknown`&&v(eN,{title:i(`uiLibrary.extensionsPanel.unknownTitle`,`Extensions could not be read`),message:i(`uiLibrary.extensionsPanel.unknownMessage`,`Nothing is known about this device’s extensions yet: {{reason}}`,{reason:o.reason}),onRetry:()=>void a.refetch()}),o.kind===`none`&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle italic`,children:i(`uiLibrary.extensionsPanel.none`,`No extensions are offered on this device.`)}),o.kind===`rows`&&c(P,{children:[f&&v(`p`,{role:`status`,className:`text-[11px] text-foreground-subtle italic`,children:i(`uiLibrary.extensionsPanel.filteredToNothing`,`None of these extensions is offered on this device.`)}),l.map(t=>v(vI,{deviceId:e,row:t,onSaved:()=>void a.refetch(),readOnly:r},t.slotRef)),u.map(e=>c(`div`,{role:`alert`,className:`flex flex-col gap-1 rounded-md border border-warning/40 bg-warning/5 p-3`,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(Bk,{variant:`warning`,children:i(`uiLibrary.extensionsPanel.unknownSlot`,`Unknown slot`)}),v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.slot})]}),v(`p`,{className:`text-[11px] text-foreground-muted break-words`,children:e.slotRef}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.disagree`,`The admin UI and the server disagree: the server offers a slot this admin UI does not know. Update the admin UI, or the server.`)})]},`unknown:${e.slotRef}`)),o.unreachable.map(e=>c(`div`,{role:`alert`,className:`flex flex-col gap-1 rounded-md border border-warning/40 bg-warning/5 p-3`,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(Bk,{variant:`warning`,children:i(`uiLibrary.extensionsPanel.unreachable`,`Unreachable`)}),v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.addonId})]}),v(`p`,{className:`text-[11px] text-foreground-muted break-words`,children:e.reason}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.extensionsPanel.unreachableHint`,`The extensions this component owns are unknown until it answers.`)})]},`unreachable:${e.addonId}`))]})]})})}E();var bI=1e3,xI={forward:{pan:0,tilt:1},left:{pan:-1,tilt:0},right:{pan:1,tilt:0},spin:{pan:0,tilt:-1}};function SI(e){let t=e instanceof Error?e.message:String(e);return/not available|no provider|NOT_FOUND|PRECONDITION/i.test(t)}function CI(e,t,n){let r=n?.enabled??!0,i=Ge(e,r?t:null)?.navigation,a=qr(e,r?t:null,e=>e.navigation),[o,s]=C(null),[c,l]=C([]),[u,d]=C(!1),[p,m]=C(null),[h,g]=C(null),v=f(null);b(()=>{if(!r||!i)return;let e=!1;return(async()=>{try{let[t,n]=await Promise.all([i.getFeatures({}),i.listActions({})]);if(e)return;s(t),l(n)}catch(t){if(e||SI(t))return;m(t instanceof Error?t.message:String(t))}})(),()=>{e=!0}},[i,r]);let y=_(async e=>{if(!(!r||!i)){m(null),d(!0);try{await e()}catch(e){m(e instanceof Error?e.message:String(e))}finally{d(!1)}}},[r,i]),x=_(()=>{v.current!==null&&(clearInterval(v.current),v.current=null)},[]),S=_(async()=>{x(),g(null),i&&await y(()=>i.stop({}))},[x,i,y]),w=_(e=>{if(!i)return;x(),g(e);let t=xI[e],n=()=>{i.move({pan:t.pan,tilt:t.tilt}).catch(e=>{m(e instanceof Error?e.message:String(e))})};n(),v.current=setInterval(n,bI)},[x,i]);b(()=>()=>{v.current!==null&&(clearInterval(v.current),v.current=null,i?.stop({}).catch(()=>void 0))},[i]);let T=_(e=>y(async()=>i?.runAction({actionId:e})),[i,y]),E=_(e=>y(async()=>i?.playSound({soundId:e})),[i,y]),D=_(e=>y(async()=>i?.setLightOn({on:e})),[i,y]),O=_((e,t)=>y(async()=>i?.setLightMode(t===void 0?{mode:e}:{mode:e,level:t})),[i,y]),k=_(e=>y(async()=>i?.setLightLevel({level:e})),[i,y]);return{features:o,actions:c,status:a??null,startDrive:w,stopDrive:S,runAction:T,playSound:E,setLightOn:D,setLightMode:O,setLightLevel:k,busy:u,error:p,driving:h}}var wI={play:Le,pause:Vt,hand:_r,home:Oi,bell:Bt,crosshair:fi,"paw-print":Me,footprints:$e,droplets:Ue,"trash-2":Pe,flashlight:Ot,"flashlight-off":Ri,cat:U,dog:B,clock:In};function TI(e){return wI[e]??ti}var EI=[{direction:`left`,labelKey:`uiLibrary.navigationPanel.turnLeft`,labelFallback:`Turn left`,Icon:Lt},{direction:`forward`,labelKey:`uiLibrary.navigationPanel.forward`,labelFallback:`Forward`,Icon:R},{direction:`right`,labelKey:`uiLibrary.navigationPanel.turnRight`,labelFallback:`Turn right`,Icon:Di},{direction:`spin`,labelKey:`uiLibrary.navigationPanel.turnAround`,labelFallback:`Turn around`,Icon:ze}],DI=`inline-flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors bg-surface-elevated/40 text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`,OI=`bg-success/15 text-success hover:bg-success/25`;function kI({entry:e,disabled:t,onRun:n}){let r=TI(e.icon);return c(`button`,{type:`button`,className:DI,disabled:t,onClick:()=>n(e),title:e.label,"aria-label":e.label,children:[v(r,{className:`h-3.5 w-3.5`}),v(`span`,{children:e.label})]})}function AI({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),i=CI(n.trpcClient,r?e:0,{enabled:r});if(!r)return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.navigationPanel.notLoaded`,`Device #{{deviceId}} not loaded.`,{deviceId:e})});let a=i.features,o=i.actions.filter(e=>e.enabled&&e.kind===`action`),s=i.actions.filter(e=>e.enabled&&e.kind===`sound`),l=i.status,u=l?.lightMode===`manual`,d=e=>{if(e.kind===`sound`){e.soundId!==void 0&&i.playSound(e.soundId);return}i.runAction(e.id)};return c($t,{title:t(`uiLibrary.navigationPanel.title`,`Navigation`),icon:v(qe,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 flex flex-col gap-3 overflow-y-auto`,children:[l&&c(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[v(`span`,{className:`rounded-full bg-surface-elevated/60 px-2 py-0.5 text-foreground`,children:l.mode}),l.following&&v(`span`,{className:`rounded-full bg-info/15 px-2 py-0.5 text-info`,children:t(`uiLibrary.navigationPanel.following`,`following`)}),l.flash&&v(`span`,{className:`rounded-full bg-warning/15 px-2 py-0.5 text-warning`,children:t(`uiLibrary.navigationPanel.lightOn`,`light on`)})]}),a?.move&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.driveHold`,`Drive (hold)`)}),v(`div`,{className:`grid grid-cols-4 gap-1.5`,children:EI.map(({direction:e,labelKey:n,labelFallback:r,Icon:a})=>v(`button`,{type:`button`,className:$(DI,`justify-center select-none`,i.driving===e&&OI),"aria-label":t(n,r),title:t(n,r),onPointerDown:()=>i.startDrive(e),onPointerUp:()=>void i.stopDrive(),onPointerLeave:()=>{i.driving===e&&i.stopDrive()},onPointerCancel:()=>void i.stopDrive(),children:v(a,{className:`h-4 w-4`})},e))}),a.stop&&c(`button`,{type:`button`,className:$(DI,`justify-center`),onClick:()=>void i.stopDrive(),children:[v(_r,{className:`h-3.5 w-3.5`}),v(`span`,{children:t(`uiLibrary.navigationPanel.stop`,`Stop`)})]})]}),a?.runAction&&o.length>0&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.actions`,`Actions`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>v(kI,{entry:e,disabled:i.busy,onRun:d},e.id))})]}),a?.playSound&&s.length>0&&c(`section`,{className:`flex flex-col gap-1.5`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.sounds`,`Sounds`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>v(kI,{entry:e,disabled:i.busy,onRun:d},e.id))})]}),a?.light&&c(`section`,{className:`flex flex-col gap-1.5 border-t border-border/40 pt-2`,children:[c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.navigationPanel.fillLight`,`Fill light`)}),c(`button`,{type:`button`,className:$(DI,l?.flash&&OI),"aria-pressed":l?.flash===!0,disabled:i.busy,onClick:()=>void i.setLightOn(l?.flash!==!0),children:[l?.flash?v(Ot,{className:`h-3.5 w-3.5`}):v(Ri,{className:`h-3.5 w-3.5`}),l?.flash?t(`uiLibrary.navigationPanel.on`,`On`):t(`uiLibrary.navigationPanel.off`,`Off`)]})]}),a.lightMode&&c(`div`,{className:`flex items-center gap-2`,children:[c(`select`,{"aria-label":t(`uiLibrary.navigationPanel.lightMode`,`Light mode`),className:`rounded-md bg-surface-elevated/40 px-2 py-1 text-[10px] text-foreground`,value:l?.lightMode??`auto`,disabled:i.busy,onChange:e=>{let t=e.target.value===`manual`?`manual`:`auto`;i.setLightMode(t,t===`manual`?l?.lightLevel:void 0)},children:[v(`option`,{value:`auto`,children:t(`uiLibrary.navigationPanel.auto`,`Auto`)}),v(`option`,{value:`manual`,children:t(`uiLibrary.navigationPanel.manual`,`Manual`)})]}),u&&v(`input`,{type:`range`,"aria-label":t(`uiLibrary.navigationPanel.lightLevel`,`Light level`),className:`flex-1`,min:40,max:100,step:1,value:l?.lightLevel??100,disabled:i.busy,onChange:e=>void i.setLightLevel(Number(e.target.value))}),u&&v(`span`,{className:`text-[10px] text-foreground-subtle w-8 text-right`,children:l?.lightLevel??100})]})]}),i.error&&v(`div`,{className:`text-[10px] text-danger`,children:i.error})]})}E();var jI={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 MI(e,t,n){let r=n?.defaultSpeed??.5,i=n?.pulseMs??250,a=n?.enabled??!0,o=Ge(e,a?t:null)?.ptz,[s,c]=C([]),[l,u]=C(null),[d,f]=C(null),[p,m]=C(null),[h,g]=C(!1),[v,y]=C(null),x=_(async()=>{if(!(!a||!o))try{c(await o.getPresets({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]),S=_(async()=>{if(!(!a||!o))try{u(await o.getHomePreset({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]),w=_(async()=>{if(!(!a||!o))try{f(await o.getHomeReturn({}))}catch(e){if(zt(e))return;f(null)}},[o,a]),T=_(async()=>{if(!(!a||!o))try{m(await o.getOptions({}))}catch(e){if(zt(e))return;y(e instanceof Error?e.message:String(e))}},[o,a]);b(()=>{x(),T(),S(),w()},[x,T,S,w]);let E=_(async e=>{if(!(!a||!o)){y(null),g(!0);try{return await e()}catch(e){y(e instanceof Error?e.message:String(e));return}finally{g(!1)}}},[a,o]);return{move:_(async(e,t)=>{if(!o)return;let n=jI[e],a=t??r;await E(async()=>{await o.move({pan:n.pan,tilt:n.tilt,speed:a}),await new Promise(e=>setTimeout(e,i)),await o.stop({})})},[o,r,i,E]),startContinuous:_(async(e,t)=>{if(!o)return;let n=jI[e],i=t??r;await E(()=>o.continuousMove({pan:n.pan,tilt:n.tilt,speed:i}))},[o,r,E]),stopContinuous:_(async()=>{o&&await E(()=>o.stop({}))},[o,E]),zoom:_(async(e,t)=>{if(!o)return;let n=e===`in`?1:-1,a=t??r;await E(async()=>{await o.move({zoom:n,speed:a}),await new Promise(e=>setTimeout(e,i)),await o.stop({})})},[o,r,i,E]),goHome:_(async()=>{o&&await E(()=>o.goHome({}))},[o,E]),homePreset:l,setHomePreset:_(async e=>{o&&(await E(()=>o.setHomePreset({presetId:e})),await S())},[o,E,S]),captureHomeHere:_(async()=>{o&&(await E(()=>o.captureHomeHere({})),await S())},[o,E,S]),homeReturn:d,setHomeReturn:_(async(e,t)=>{o&&(await E(()=>o.setHomeReturn({enabled:e,seconds:t})),await w())},[o,E,w]),goToPreset:_(async e=>{o&&await E(()=>o.goToPreset({presetId:e}))},[o,E]),savePreset:_(async e=>{if(o)return E(async()=>{let t=new Set(s.map(e=>Number(e.id)).filter(e=>Number.isInteger(e)&&e>=0)),n=0;for(;t.has(n);)n+=1;let r=String(n);return await o.savePreset({presetId:r,name:e}),await x(),r})},[o,s,x,E]),updatePreset:_(async e=>{o&&await E(async()=>{let t=s.find(t=>t.id===e);await o.savePreset({presetId:e,name:t?.name??``}),await x()})},[o,s,x,E]),deletePreset:_(async e=>{o&&await E(async()=>{await o.deletePreset({presetId:e}),await x()})},[o,x,E]),presets:s,refreshPresets:x,options:p,busy:h,error:v}}E();var NI=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`;function PI({controls:e}){let t=q(),{homePreset:n,presets:r,setHomePreset:i,captureHomeHere:a,homeReturn:o,setHomeReturn:s,busy:l}=e,[u,d]=C(!1);if(n===null)return null;let f=l||u,p=e=>{d(!0),e().finally(()=>d(!1))},m=n.source===`native`?`This camera stores its own home position. “Set home here” pins it to where the camera is pointing now.`:n.source===`firmware`?`Taken from the camera, which names this preset as its home.`:n.source===`none`?`Nothing is set, so Home refuses rather than moving to an arbitrary preset.`:`Pinned here. Clear it to fall back to the camera’s own home.`;return c(`div`,{className:`flex flex-col gap-2 px-2 pt-2`,children:[n.source!==`native`&&c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.label`,`Home preset`)}),c(`select`,{value:n.presetId??``,disabled:f,onChange:e=>{let t=e.target.value===``?null:e.target.value;p(()=>i(t))},className:NI,children:[v(`option`,{value:``,children:t(`uiLibrary.homePresetPicker.notSet`,`Not set — Home is refused`)}),r.map(e=>v(`option`,{value:e.id,children:e.fn===`home`?t(`uiLibrary.homePresetPicker.ownHome`,`{{name}} (camera’s own home)`,{name:e.name||e.id}):e.name||e.id},e.id))]})]}),v(`button`,{type:`button`,disabled:f,onClick:()=>p(()=>a()),className:`self-start rounded-md border border-border px-2 py-1 text-[11px] text-foreground hover:bg-primary/10 disabled:opacity-50`,children:t(`uiLibrary.homePresetPicker.setHere`,`Set home here`)}),o!==null&&c(`div`,{className:`flex flex-col gap-1`,children:[c(`label`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`checkbox`,checked:o.enabled,disabled:f,onChange:e=>p(()=>s(e.target.checked,o.seconds))}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.returnIdle`,`Return home when idle`)})]}),c(`label`,{className:`flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle`,children:t(`uiLibrary.homePresetPicker.after`,`After (s)`)}),v(`input`,{type:`number`,min:0,max:3600,defaultValue:o.seconds,disabled:f,onBlur:e=>{let t=Number(e.target.value);!Number.isFinite(t)||Math.round(t)===o.seconds||p(()=>s(o.enabled,Math.round(t)))},className:NI})]})]}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:m})]})}E(),Do();function FI({direction:e,icon:t,disabled:n,className:r,variant:i,onMove:a,onStart:o,onStop:s}){let[c,l]=C(null),[u,d]=C(!1),f=_(t=>{if(n)return;t.currentTarget.setPointerCapture(t.pointerId),l(Date.now()),d(!1);let r=setTimeout(()=>{d(!0),o(e)},250);t.currentTarget.dataset.timer=String(r)},[e,n,o]),p=_(t=>{let n=Number(t.currentTarget.dataset.timer);n&&clearTimeout(n),t.currentTarget.dataset.timer=``,u?s():c!==null&&a(e),l(null),d(!1)},[u,e,a,s,c]),m=_(e=>{let t=Number(e.currentTarget.dataset.timer);t&&clearTimeout(t),e.currentTarget.dataset.timer=``,u&&s(),l(null),d(!1)},[u,s]),h=i===`panel`?`h-9 w-9`:`h-7 w-7`,g=i===`panel`?`h-4 w-4`:`h-3.5 w-3.5`;return v(`button`,{type:`button`,disabled:n,onPointerDown:f,onPointerUp:p,onPointerCancel:m,className:$(`flex items-center justify-center rounded transition-colors disabled:opacity-40`,i===`panel`?`text-foreground hover:bg-surface-hover active:bg-surface-hover/80`:`text-white hover:bg-white/15 active:bg-white/25`,h,r),title:e,children:v(t,{className:g})})}function II({controls:e,mode:t=`overlay`,showPresets:n,showZoom:r=!0,showHome:i=!0,className:a}){let o=q(),{move:s,startContinuous:l,stopContinuous:d,zoom:p,goHome:m,homePreset:h,goToPreset:g,savePreset:y,updatePreset:x,deletePreset:S,presets:w,options:T,busy:E,error:D}=e,O=li(),[k,A]=C(!1),[j,M]=C(``),N=f(null),F=f(null),[I,L]=C(null),z=t===`panel`,B=r&&(T?.hasZoom??!0),V=T?.supportsPresets??w.length>0,H=(n??V)&&V,U=z&&(T?.supportsPresets??!1),ee=T?.maxPresets!==void 0&&w.length>=T.maxPresets,W=_(async()=>{let e=j.trim();!e||E||ee||await y(e)!==void 0&&M(``)},[j,E,ee,y]),G=_(async(e,t)=>{await O({title:o(`uiLibrary.ptzOverlay.deleteTitle`,`Delete preset`),message:o(`uiLibrary.ptzOverlay.deleteMessage`,`Delete PTZ preset "{{label}}"? This removes it from the camera.`,{label:t}),confirmLabel:o(`uiLibrary.ptzOverlay.delete`,`Delete`),variant:`danger`})&&await S(e)},[O,S,o]),te=_(async(e,t)=>{await O({title:o(`uiLibrary.ptzOverlay.updateTitle`,`Update preset`),message:o(`uiLibrary.ptzOverlay.updateMessage`,`Overwrite preset "{{label}}" with the camera's current position?`,{label:t}),confirmLabel:o(`uiLibrary.ptzOverlay.update`,`Update`)})&&await x(e)},[O,x,o]);u(()=>{if(!k){L(null);return}let e=()=>{let e=N.current?.getBoundingClientRect();e&&L({top:e.bottom+4,right:window.innerWidth-e.right})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[k]),b(()=>{if(!k)return;let e=e=>{let t=e.target;F.current?.contains(t)||N.current?.contains(t)||A(!1)},t=e=>{e.key===`Escape`&&A(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[k]);let ne=z?`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`,re=$(z?`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`,E&&`ring-1 ring-primary/40`),K=z?`h-9 w-9`:`h-7 w-7`,ie=z?`h-4 w-4`:`h-3.5 w-3.5`,ae=z?`text-foreground hover:bg-surface-hover`:`text-white hover:bg-white/15`,oe=z?`h-12 w-px bg-border mx-1`:`h-12 w-px bg-white/15 mx-1`;return c(`div`,{className:$(ne,a),children:[D&&v(`div`,{className:`rounded bg-danger/90 px-2 py-1 text-[10px] font-medium text-white shadow-lg max-w-[200px] self-center`,children:o(`uiLibrary.ptzOverlay.error`,`PTZ: {{error}}`,{error:D})}),c(`div`,{className:$(re,z&&`justify-center`),children:[c(`div`,{className:`grid grid-cols-3 gap-0.5`,children:[v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`up`,icon:R,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`left`,icon:jr,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`right`,icon:di,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`}),v(FI,{direction:`down`,icon:$r,variant:t,onMove:s,onStart:l,onStop:d}),v(`span`,{"aria-hidden":!0,className:z?`h-9 w-9`:`h-7 w-7`})]}),(B||i)&&v(`div`,{className:oe}),c(`div`,{className:`flex flex-col gap-0.5`,children:[B&&c(P,{children:[v(`button`,{type:`button`,onClick:()=>p(`in`),disabled:E,title:o(`uiLibrary.ptzOverlay.zoomIn`,`Zoom in`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(kr,{className:ie})}),v(`button`,{type:`button`,onClick:()=>p(`out`),disabled:E,title:o(`uiLibrary.ptzOverlay.zoomOut`,`Zoom out`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(Kr,{className:ie})})]}),i&&v(`button`,{type:`button`,onClick:()=>m(),disabled:E||h?.source===`none`,title:h?.source===`none`?o(`uiLibrary.ptzOverlay.noHome`,`No home preset set for this camera — pick one in PTZ settings`):o(`uiLibrary.ptzOverlay.goHome`,`Go home`),className:$(`flex items-center justify-center rounded disabled:opacity-40`,K,ae),children:v(Oi,{className:ie})})]}),H&&c(`div`,{className:`relative`,children:[c(`button`,{ref:N,type:`button`,onClick:()=>A(e=>!e),disabled:E,className:$(`flex items-center gap-1 rounded px-2 text-[10px] disabled:opacity-40`,z?`h-9 text-foreground hover:bg-surface-hover`:`h-7 text-white hover:bg-white/15`),title:o(`uiLibrary.ptzOverlay.presets`,`Presets`),children:[o(`uiLibrary.ptzOverlay.presets`,`Presets`),v(de,{className:$(`h-3 w-3 transition-transform`,k&&`rotate-180`)})]}),k&&I&&Oo(c(`div`,{ref:F,style:{position:`fixed`,top:I.top,right:I.right,zIndex:60},className:$(`rounded-lg shadow-xl py-1`,U?`min-w-[220px]`:`min-w-[140px]`,z?`bg-surface border border-border`:`border border-white/30 bg-zinc-900/95 backdrop-blur-md`),children:[w.length===0&&v(`div`,{className:$(`px-3 py-1.5 text-[10px]`,z?`text-foreground-subtle`:`text-white/60`),children:o(`uiLibrary.ptzOverlay.noPresets`,`No presets yet`)}),w.map(e=>c(`div`,{className:$(`group flex items-center`,z?`hover:bg-surface-hover`:`hover:bg-white/15`),children:[v(`button`,{type:`button`,onClick:()=>{g(e.id),A(!1)},disabled:E,className:$(`flex-1 px-3 py-1.5 text-left text-[10px] disabled:opacity-40`,z?`text-foreground`:`text-white`),children:e.name||e.id}),U&&e.writable&&c(P,{children:[v(`button`,{type:`button`,onClick:()=>void te(e.id,e.name||e.id),disabled:E,title:o(`uiLibrary.ptzOverlay.overwriteTitle`,`Overwrite "{{name}}" with current position`,{name:e.name||e.id}),className:$(`flex h-5 w-5 shrink-0 items-center justify-center rounded`,`text-foreground-subtle hover:bg-primary/15 hover:text-primary disabled:opacity-40`),children:v(fi,{className:`h-3 w-3`})}),v(`button`,{type:`button`,onClick:()=>void G(e.id,e.name||e.id),disabled:E,title:o(`uiLibrary.ptzOverlay.deletePreset`,`Delete preset {{name}}`,{name:e.name||e.id}),className:$(`mr-1 flex h-5 w-5 shrink-0 items-center justify-center rounded`,`text-foreground-subtle hover:bg-danger/15 hover:text-danger disabled:opacity-40`),children:v(Zn,{className:`h-3 w-3`})})]})]},e.id)),U&&c(P,{children:[w.length>0&&v(`div`,{className:$(`my-1 h-px`,z?`bg-border`:`bg-white/15`)}),c(`div`,{className:`flex items-center gap-1 px-2 py-1`,children:[v(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),onKeyDown:e=>{e.key===`Enter`&&W()},disabled:E||ee,placeholder:o(`uiLibrary.ptzOverlay.newPreset`,`New preset name`),maxLength:64,className:$(`min-w-0 flex-1 rounded border px-2 py-1 text-[11px]`,`focus:outline-none focus:ring-1 focus:ring-primary/50 disabled:opacity-40`,z?`border-border bg-surface text-foreground placeholder:text-foreground-subtle`:`border-white/30 bg-zinc-800 text-white placeholder:text-white/40`)}),v(`button`,{type:`button`,onClick:()=>void W(),disabled:E||ee||j.trim().length===0,title:ee?o(`uiLibrary.ptzOverlay.limitTitle`,`Camera preset limit reached ({{max}})`,{max:T?.maxPresets}):o(`uiLibrary.ptzOverlay.saveTitle`,`Save current position as a new preset`),className:$(`flex h-7 w-7 shrink-0 items-center justify-center rounded`,`bg-primary/15 text-primary hover:bg-primary/25 disabled:opacity-40`),children:v(Se,{className:`h-3.5 w-3.5`})})]}),ee&&v(`span`,{className:$(`block px-2 pb-1 text-[10px]`,z?`text-foreground-subtle`:`text-white/60`),children:o(`uiLibrary.ptzOverlay.limit`,`Preset limit reached ({{max}}).`,{max:T?.maxPresets})})]})]}),document.body)]})]})]})}E();function LI({deviceId:e}){let t=q(),n=Ge(Rn().trpcClient,e),[r,i]=C(null),[a,o]=C(!1);b(()=>{if(!n)return;let e=!1;return(async()=>{try{let t=await n.ptz?.getStatus({});if(e||!t)return;i(t.autofocus)}catch{}})(),()=>{e=!0}},[n]);let s=_(async()=>{if(!(!n?.ptz||r===null)){o(!0);try{let e=!r;await n.ptz.setAutofocus({enabled:e}),i(e)}catch(e){console.error(`ptz.setAutofocus failed`,e)}finally{o(!1)}}},[n,r]);return r===null?null:c(`div`,{className:`flex items-center justify-between border-t border-border/40 mt-2 pt-2`,children:[v(`span`,{className:`text-[10.5px] font-semibold text-foreground`,children:t(`uiLibrary.ptzPanel.autofocus`,`Autofocus`)}),c(`button`,{type:`button`,onClick:()=>void s(),disabled:a,"aria-pressed":r,className:`flex items-center gap-1.5 rounded-md px-2 py-1 text-[10px] font-medium transition-colors ${r?`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`,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${r?`bg-success`:`bg-foreground-subtle/40`}`}),r?t(`uiLibrary.ptzPanel.on`,`On`):t(`uiLibrary.ptzPanel.off`,`Off`)]})]})}function RI({deviceId:e}){let t=q(),n=Rn(),r=Number.isFinite(e),i=MI(n.trpcClient,r?e:0,{enabled:r});if(!r)return v(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:t(`uiLibrary.ptzPanel.notLoaded`,`Device #{{deviceId}} not loaded.`,{deviceId:e})});let a=i.options?.hasAutofocus===!0;return c($t,{title:`PTZ`,icon:v(He,{className:`h-3.5 w-3.5 text-foreground-subtle`}),bodyClassName:`p-3 flex flex-col overflow-y-auto`,children:[v(II,{controls:i,mode:`panel`}),v(PI,{controls:i}),a&&v(LI,{deviceId:e})]})}var zI=[0,1,2,3,4,5,6],BI=`00:00`,VI=`23:59`;function HI(e,t){return{days:[...zI],start:BI,end:VI,mode:e,...t}}function UI(){return{days:[...zI],start:`09:00`,end:`18:00`,mode:`continuous`}}function WI(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function GI(e,t){return e.filter((e,n)=>n!==t)}var KI=[1,2,3,4,5,6,0];function qI(e,t){switch(t){case 1:return e(`uiLibrary.recordingBands.mon`,`Mon`);case 2:return e(`uiLibrary.recordingBands.tue`,`Tue`);case 3:return e(`uiLibrary.recordingBands.wed`,`Wed`);case 4:return e(`uiLibrary.recordingBands.thu`,`Thu`);case 5:return e(`uiLibrary.recordingBands.fri`,`Fri`);case 6:return e(`uiLibrary.recordingBands.sat`,`Sat`);default:return e(`uiLibrary.recordingBands.sun`,`Sun`)}}var JI=[`continuous`,`events`];function YI(e,t){return t===`continuous`?e(`uiLibrary.recordingBands.continuous`,`Continuous`):e(`uiLibrary.recordingBands.events`,`Events`)}function XI({bands:e,onChange:t,sensorContext:n}){let r=q();return c(`div`,{className:`space-y-2`,children:[e.length===0?v(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.recordingBands.empty`,`No bands — nothing is recorded. Add one to start.`)}):e.map((r,i)=>v(eL,{band:r,onChange:n=>t(WI(e,i,n)),onRemove:()=>t(GI(e,i)),sensorContext:n},i)),c(`button`,{type:`button`,onClick:()=>t([...e,UI()]),className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[v(Se,{className:`h-3 w-3`}),` `,r(`uiLibrary.recordingBands.add`,`Add band`)]})]})}var ZI=Object.keys(Ia);function QI(e,t){return{type:`device-multiselect`,key:`sensorDeviceIds`,label:e(`uiLibrary.recordingBands.sensors`,`Sensors`),description:e(`uiLibrary.recordingBands.sensorsHint`,`Sensors whose ACTIVE edge starts a recording — a contact opening, a PIR firing. Same-location devices are suggested first.`),placeholder:e(`uiLibrary.recordingBands.addSensor`,`Add a sensor…`),maxItems:16,deviceFilter:{caps:ZI,types:[`sensor`],excludeDeviceId:t.cameraId},...t.location===null?{}:{suggestLocation:t.location}}}function $I(e){return e===``?void 0:Number(e)}function eL({band:e,onChange:t,onRemove:n,sensorContext:r}){let i=q(),a=n=>{let r=e.days.length===0?KI:e.days;t({days:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},o=n=>t({triggers:{...e.triggers,...n}});return c(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[v(`input`,{type:`time`,"aria-label":i(`uiLibrary.recordingBands.start`,`Band start`),value:e.start,onChange:e=>t({start:e.target.value}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),v(`span`,{className:`text-foreground-subtle`,children:`→`}),v(`input`,{type:`time`,"aria-label":i(`uiLibrary.recordingBands.end`,`Band end`),value:e.end,onChange:e=>t({end:e.target.value}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),v(`span`,{className:`flex gap-1`,children:JI.map(n=>v(`button`,{type:`button`,onClick:()=>t({mode:n}),className:`rounded px-2 py-0.5 ${e.mode===n?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:YI(i,n)},n))}),c(`button`,{type:`button`,"aria-label":i(`uiLibrary.recordingBands.audio`,`Band audio`),"aria-pressed":e.audio!==`muted`,title:e.audio===`muted`?i(`uiLibrary.recordingBands.silentTitle`,`Silent — this band records the video-only stream.`):i(`uiLibrary.recordingBands.soundTitle`,`With sound — this band records the camera’s audio.`),onClick:()=>t({audio:e.audio===`muted`?`on`:`muted`}),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 ${e.audio===`muted`?`bg-surface-hover text-foreground-subtle`:`bg-primary/10 text-primary`}`,children:[e.audio===`muted`?v(me,{className:`h-3.5 w-3.5`}):v(mt,{className:`h-3.5 w-3.5`}),e.audio===`muted`?i(`uiLibrary.recordingBands.silent`,`Silent`):i(`uiLibrary.recordingBands.sound`,`Sound`)]}),v(`span`,{className:`flex-1`}),v(`button`,{type:`button`,onClick:n,"aria-label":i(`uiLibrary.recordingBands.remove`,`Remove band`),className:`text-foreground-subtle hover:text-red-500`,children:v(Pe,{className:`h-3.5 w-3.5`})})]}),c(`div`,{className:`flex flex-wrap gap-1`,children:[KI.map(t=>v(`button`,{type:`button`,onClick:()=>a(t),className:`rounded px-1.5 py-0.5 text-[10px] ${e.days.length===0||e.days.includes(t)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:qI(i,t)},t)),e.days.length===0?v(`span`,{className:`self-center text-[10px] text-foreground-subtle`,children:i(`uiLibrary.recordingBands.everyDay`,`every day`)}):null]}),e.mode===`events`?c(`div`,{className:`space-y-1.5 border-t border-border pt-1.5`,children:[c(`label`,{className:`flex items-center gap-2 text-xs`,children:[v(`input`,{type:`checkbox`,checked:e.triggers?.motion??!1,onChange:e=>o({motion:e.target.checked?!0:void 0})}),i(`uiLibrary.recordingBands.motion`,`Motion`)]}),c(`label`,{className:`flex items-center gap-2 text-xs`,children:[v(`input`,{type:`checkbox`,checked:e.triggers?.audioThresholdDbfs!=null,onChange:e=>o({audioThresholdDbfs:e.target.checked?-30:void 0})}),i(`uiLibrary.recordingBands.audioAbove`,`Audio above threshold`),e.triggers?.audioThresholdDbfs==null?null:v(`input`,{type:`number`,"aria-label":i(`uiLibrary.recordingBands.threshold`,`Audio threshold dBFS`),value:e.triggers.audioThresholdDbfs,onChange:e=>o({audioThresholdDbfs:$I(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-0.5 text-xs`}),v(`span`,{className:`text-foreground-subtle`,children:`dBFS`})]}),c(`div`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[v(`span`,{className:`text-foreground-subtle`,children:i(`uiLibrary.recordingBands.objects`,`Objects`)}),bee.map(t=>{let n=e.triggers?.objectClasses??[],r=n.includes(t);return v(`button`,{type:`button`,"aria-label":i(`uiLibrary.recordingBands.triggerOn`,`Trigger on {{class}}`,{class:t}),"aria-pressed":r,onClick:()=>{let e=r?n.filter(e=>e!==t):[...n,t];o({objectClasses:e.length>0?e:void 0})},className:`rounded px-1.5 py-0.5 text-[10px] ${r?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:t},t)})]}),r===void 0?null:v(zk,{field:QI(i,r),value:(e.triggers?.sensorDeviceIds??[]).map(String),onChange:e=>{let t=Array.isArray(e)?e.map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>0):[];o({sensorDeviceIds:t.length>0?t:void 0})}}),v(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:c(`label`,{className:`flex items-center gap-1`,children:[i(`uiLibrary.recordingBands.postBuffer`,`Post-buffer`),v(`input`,{type:`number`,min:0,value:e.postBufferSec??``,placeholder:String(xee.postBufferSec),onChange:e=>t({postBufferSec:$I(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`s`]})})]}):null]})}E();var tL=[{value:`off`,labelKey:`uiLibrary.recordingSettings.modeOff`,labelFallback:`Off`},{value:`events`,labelKey:`uiLibrary.recordingSettings.modeEvents`,labelFallback:`Events`},{value:`continuous`,labelKey:`uiLibrary.recordingSettings.modeContinuous`,labelFallback:`Continuous`},{value:`on-device-decision`,labelKey:`uiLibrary.recordingSettings.modeDeviceDecides`,labelFallback:`Device decides`}];function nL(e,t){return e===`present`?null:e===`pending`?t(`uiLibrary.recordingSettings.noteChecking`,`checking the camera…`):e===`absent`?t(`uiLibrary.recordingSettings.noteAbsent`,`this camera does not report when it needs recording`):t(`uiLibrary.recordingSettings.noteUnknown`,`could not check the camera`)}function rL({initial:e,availableProfiles:t,saving:n,onSave:r,sensorContext:i}){let a=q(),[o,s]=C([...e.bands]),[l,u]=C(e.deviceDecision===!0),[d,f]=C({profiles:e.profiles,segmentSeconds:e.segmentSeconds,retention:e.retention}),p=d.retention??{},m=e=>f({...d,retention:{...p,...e}}),h=e=>e===``?void 0:Number(e),g=vee({enabled:l||o.length>0,bands:o,deviceDecision:l}),_=i?.deviceSignal,y=_===`present`||l,b=Ui(t,d.profiles),x=e=>{let t=b.includes(e)?b.filter(t=>t!==e):[...b,e];f({...d,profiles:t.length?t:void 0})},S=e=>{if(e===`off`){s([]),u(!1);return}if(e===`on-device-decision`){s([]),u(!0);return}u(!1),e!==g&&s([HI(e)])},w=()=>{let e=t.length>0?Ui(t,d.profiles):d.profiles?[...d.profiles]:void 0;r({enabled:l||o.length>0,bands:l?[]:o,...l?{deviceDecision:!0}:{},...e===void 0?{}:{profiles:e},segmentSeconds:d.segmentSeconds,retention:d.retention})},T=Cee.filter(e=>t.includes(e));return c(`div`,{className:`space-y-4`,children:[c(`div`,{className:`flex items-center gap-2 text-xs`,children:[v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.mode`,`Mode:`)}),tL.map(e=>{let t=e.value===`on-device-decision`,n=t?nL(_,a):null;return v(`button`,{type:`button`,"aria-label":a(`uiLibrary.recordingSettings.modeAria`,`Mode {{label}}`,{label:a(e.labelKey,e.labelFallback)}),title:n??void 0,disabled:t&&!y,onClick:()=>S(e.value),className:`rounded px-2.5 py-1 ${g===e.value?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`} disabled:cursor-not-allowed disabled:opacity-50`,children:a(e.labelKey,e.labelFallback)},e.value)})]}),l?v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.deviceDecides`,`The DEVICE decides: this camera records for as long as it reports it is in function — a robot while it cleans — and one job is one clip. There is nothing to schedule, so this mode has no bands.`)}):c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.bands`,`Recording bands`)}),v(XI,{bands:o,onChange:s,sensorContext:i}),v(`p`,{className:`mt-1.5 text-[11px] text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.bandsHint`,`A band says WHEN to record and HOW. Nothing is recorded outside every band — an empty table means this camera is off.`)})]}),c(`div`,{className:`flex flex-wrap items-center gap-4 text-xs`,children:[T.length>0?c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.profiles`,`Profiles:`)}),T.map(e=>v(`button`,{type:`button`,onClick:()=>x(e),className:`rounded px-2 py-1 ${b.includes(e)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:e},e))]}):v(`span`,{className:`text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.noStreams`,`No assigned streams to record yet.`)}),c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.segment`,`Segment`),v(`input`,{type:`number`,min:1,value:d.segmentSeconds??``,placeholder:a(`uiLibrary.recordingSettings.default`,`default`),onChange:e=>f({...d,segmentSeconds:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`s`]})]}),c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:a(`uiLibrary.recordingSettings.retention`,`Retention (empty = node default)`)}),c(`div`,{className:`flex flex-wrap items-center gap-3 text-xs`,children:[c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.maxAge`,`Max age`),v(`input`,{type:`number`,min:0,value:p.maxAgeDays??``,placeholder:`14`,onChange:e=>m({maxAgeDays:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),a(`uiLibrary.recordingSettings.days`,`days`)]}),c(`label`,{className:`flex items-center gap-1`,children:[a(`uiLibrary.recordingSettings.maxSize`,`Max size`),v(`input`,{type:`number`,min:0,value:p.maxSizeGb??``,placeholder:`∞`,onChange:e=>m({maxSizeGb:h(e.target.value)}),className:`w-16 rounded-md border border-border bg-background px-1 py-1 text-xs`}),`GB`]})]})]}),v(`div`,{className:`flex justify-end`,children:c(`button`,{type:`button`,disabled:n,onClick:w,className:`flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-60`,children:[n?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(ji,{className:`h-3.5 w-3.5`}),a(`uiLibrary.recordingSettings.save`,`Save`)]})})]})}function iL(e){return JSON.stringify(e)}var aL=[`live`,`loading`,`playing`,`paused`,`gap`,`ended`,`error`];function oL(e){return typeof e==`string`&&aL.includes(e)}function sL(e){return e===`high`||e===`mid`||e===`low`}function cL(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!=`object`||!t)return null;let n={...t};return n.t===`state`&&oL(n.state)?{kind:`state`,state:n.state}:n.t===`position`&&typeof n.epochMs==`number`?{kind:`position`,epochMs:n.epochMs}:n.t===`servedProfile`&&sL(n.profile)&&typeof n.requested==`string`?{kind:`servedProfile`,profile:n.profile,requested:n.requested}:null}E();var lL=Kn(`camstack:recorded-playback`,{bindControlChannel:null,channelOpen:!1,mode:`live`,positionMs:null,send:()=>!1});function uL({children:e}){let t=f(null),[n,r]=C(!1),[i,a]=C(`live`),[o,s]=C(null),c=_(e=>{t.current=e;let n=()=>{t.current===e&&(t.current=null,r(!1),a(`live`),s(null))};e.onopen=()=>{t.current===e&&r(!0)},e.onclose=n,e.onerror=n,e.onmessage=n=>{if(t.current!==e)return;let r=n.data;if(typeof r!=`string`)return;let i=cL(r);i&&(i.kind===`position`?s(i.epochMs):i.kind===`state`&&(a(i.state),i.state===`live`&&s(null)))},e.readyState===`open`?r(!0):e.readyState===`closed`||e.readyState===`closing`?n():r(!1)},[]),l=_(e=>{let n=t.current;return!n||n.readyState!==`open`?!1:(n.send(iL(e)),!0)},[]),u=p(()=>({bindControlChannel:c,channelOpen:n,mode:i,positionMs:o,send:l}),[c,n,i,o,l]);return v(lL.Provider,{value:u,children:e})}function dL(){return I(lL)}E();var fL={scrubbing:!1,scrubEpoch:null,playheadEpoch:null,lastSource:null};function pL(e,t){switch(t.type){case`begin`:return{...e,scrubbing:!0,scrubEpoch:null,lastSource:t.source};case`update`:return{...e,scrubbing:!0,scrubEpoch:t.epoch,lastSource:t.source};case`end`:return{...e,scrubbing:!1,scrubEpoch:null,playheadEpoch:t.epoch,lastSource:t.source};case`seek`:return{...e,scrubbing:!1,scrubEpoch:null,playheadEpoch:t.epoch,lastSource:t.source};case`playhead`:return e.scrubbing?e:{...e,playheadEpoch:t.epoch};case`reset`:return fL;default:return e}}function mL(e,t,n=70){return t-e>=n}var hL=2e3;function gL(e,t,n,r=750,i=hL){if(e===null)return!0;let a=Math.abs(t-e.epoch)<=r,o=n-e.at<=i;return!(a&&o)}function _L(e,t){let n=e.scrubbing?e.scrubEpoch:e.playheadEpoch;if(n===null)return null;let r=t.to-t.from;return r<=0?null:Math.min(1,Math.max(0,(n-t.from)/r))}function vL(e,t,n,r={current:null},i=()=>!1){let a=(e,t)=>{let n=Date.now();if(i()){r.current={epoch:e,at:n},t(e);return}gL(r.current,e,n)&&(r.current={epoch:e,at:n},t(e))};return{beginScrub:n=>{t({type:`begin`,source:n}),e.scrubStart()},updateScrub:(r,i)=>{t({type:`update`,epoch:r,source:i});let a=Date.now();mL(n.current,a)&&(n.current=a,e.scrubTo(r))},endScrub:(n,r)=>{t({type:`end`,epoch:n,source:r}),a(n,e.scrubCommit)},seek:(n,r)=>{t({type:`seek`,epoch:n,source:r}),a(n,e.seek)},setPlayhead:e=>t({type:`playhead`,epoch:e}),reset:()=>t({type:`reset`})}}function yL(e,t=()=>!1){let[n,r]=A(pL,fL),i=f(0),a=f(null),o=f(t);return o.current=t,{state:n,...p(()=>vL(e,r,i,a,()=>o.current()),[e])}}E();var bL=O(null);function xL(){let e=I(bL);if(!e)throw Error(`Dialog compound components must be used within <Dialog>`);return e}function SL({children:e,open:t,onOpenChange:n}){let[r,i]=C(!1),a=t??r,o=y(),s=_(e=>{n?.(e),t===void 0&&i(e)},[t,n]);return v(bL.Provider,{value:{open:a,setOpen:s,contentId:o},children:e})}function CL({children:e,...t}){let{setOpen:n}=xL();return v(`button`,{type:`button`,onClick:()=>n(!0),...t,children:e})}var wL=Il(`relative fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 m-0 w-[calc(100vw-2rem)] bg-background-elevated text-foreground border border-border rounded-lg p-4 backdrop:bg-black/50 backdrop:backdrop-blur-sm max-h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] [&:not([open])]:hidden`,{variants:{width:{sm:`max-w-sm`,md:`max-w-md`,lg:`max-w-lg`,xl:`max-w-4xl`},scroll:{content:`overflow-y-auto overscroll-contain`,body:`flex flex-col overflow-hidden overscroll-contain`},placement:{center:``,"sheet-on-mobile":`bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none max-h-[92dvh] pb-[calc(1rem+env(safe-area-inset-bottom))] md:left-1/2 md:top-1/2 md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:bottom-auto md:pb-4 md:max-h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))]`}},compoundVariants:[{placement:`sheet-on-mobile`,width:`sm`,class:`md:w-[calc(100vw-2rem)] md:max-w-sm`},{placement:`sheet-on-mobile`,width:`md`,class:`md:w-[calc(100vw-2rem)] md:max-w-md`},{placement:`sheet-on-mobile`,width:`lg`,class:`md:w-[calc(100vw-2rem)] md:max-w-lg`},{placement:`sheet-on-mobile`,width:`xl`,class:`md:w-[calc(100vw-2rem)] md:max-w-4xl`},{scroll:`body`,placement:`sheet-on-mobile`,class:`h-[92dvh] md:h-auto`},{scroll:`body`,placement:`center`,class:`h-[calc(100dvh-2rem-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] md:h-auto`}],defaultVariants:{width:`md`,placement:`center`,scroll:`content`}}),TL=D(({className:e,width:t,placement:n,scroll:r,children:i,...a},o)=>{let{open:s,setOpen:l,contentId:u}=xL(),d=q(),p=f(null),m=o??p;return b(()=>{let e=m.current;e&&(s&&!e.open&&e.showModal(),!s&&e.open&&e.close())},[s,m]),c(`dialog`,{ref:m,id:u,className:$(wL({width:t,placement:n,scroll:r}),e),onClose:()=>l(!1),...a,children:[v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:Zn,"aria-label":d(`uiLibrary.dialog.close`,`Close`),className:`absolute right-4 top-4 z-10 shrink-0`,onClick:()=>l(!1)}),v(Os,{id:u,modal:!0,enabled:s,children:i})]})});TL.displayName=`DialogContent`;function EL({className:e,...t}){return v(`div`,{className:$(`flex flex-col gap-1 mb-3 shrink-0 pr-10`,e),...t})}function DL({className:e,...t}){return v(`div`,{className:$(`flex-1 min-h-0 overflow-y-auto overscroll-contain`,e),...t})}function OL({className:e,...t}){return v(`div`,{className:$(`flex justify-end gap-2 mt-4 shrink-0`,e),...t})}function kL({className:e,...t}){return v(`h2`,{className:$(`text-sm font-semibold text-foreground`,e),...t})}function AL({className:e,...t}){return v(`p`,{className:$(`text-xs text-foreground-muted`,e),...t})}E();function jL({value:e,onChange:t}){let n=q(),r=Ox({}),i=Dx(),[a,o]=C(``),[s,l]=C(null),u=r.data??[],d=async()=>{l(null);let e=await i.mutateAsync({name:a});if(e.kind===`refused`){l(e.reason);return}o(``),await r.refetch(),t(e.collection.id)};return c(`div`,{className:`space-y-2`,"data-testid":`training-collection-picker`,children:[u.length>0?v(Yl,{"aria-label":n(`uiLibrary.trainingCollectionPicker.collection`,`Collection`),value:e??``,options:[{value:``,label:n(`uiLibrary.trainingCollectionPicker.choose`,`Choose a collection…`)},...u.map(e=>({value:e.id,label:`${e.name} (${String(e.frameCount)})`}))],onChange:e=>{e.target.value!==``&&t(e.target.value)}}):v(`p`,{className:`text-xs text-foreground-subtle`,children:r.isLoading?n(`uiLibrary.trainingCollectionPicker.reading`,`Reading the collections…`):n(`uiLibrary.trainingCollectionPicker.none`,`No collection yet — create one.`)}),c(`div`,{className:`flex items-center gap-2`,children:[v(Bl,{className:`flex-1`,"aria-label":n(`uiLibrary.trainingCollectionPicker.newName`,`New collection name`),placeholder:n(`uiLibrary.trainingCollectionPicker.newPlaceholder`,`New collection (e.g. missed at night)`),value:a,onChange:e=>{o(e.target.value)}}),c(_A,{type:`button`,variant:`secondary`,size:`sm`,disabled:i.isPending||a.trim()===``,onClick:()=>void d(),children:[v(Se,{className:`h-3 w-3`}),n(`uiLibrary.trainingCollectionPicker.create`,`Create`)]})]}),s!==null&&v(`p`,{className:`text-xs text-danger`,children:s===`empty-name`?n(`uiLibrary.trainingCollectionPicker.emptyName`,`Give the collection a name.`):n(`uiLibrary.trainingCollectionPicker.duplicateName`,`A collection with that name already exists.`)})]})}var ML={"unknown-collection":`That collection no longer exists — pick another one.`,"still-unavailable":`No frame could be taken from the recording at that moment.`,"still-busy":`The recorder is busy decoding other frames. Try again in a moment.`,"unreadable-image":`The recorder returned something that is not a picture.`,"write-failed":`The frame could not be stored. Check the artifacts storage.`};function NL(e,t){let n=ML[e];return t!==void 0&&t!==``?`${n} (${t})`:n}E();function PL({deviceId:e,epochMs:t}){let n=q(),r=Ox({},{retry:!1}),i=Mx(),[a,o]=C(!1),[s,l]=C(null),[u,d]=C(null),[f,p]=C(null);if(r.isError)return null;let m=async()=>{if(s===null||u===null)return;let t=await i.mutateAsync({collectionId:s,deviceId:e,epochMs:u}),a=r.data?.find(e=>e.id===s)?.name??n(`uiLibrary.sendFrameToTraining.theCollection`,`the collection`);p(t.kind===`added`?{kind:`added`,reused:t.reused,collection:a}:{kind:`refused`,text:NL(t.reason,t.detail)}),t.kind===`added`&&await r.refetch()};return c(P,{children:[c(_A,{type:`button`,variant:`secondary`,size:`sm`,"data-testid":`send-frame-to-training`,disabled:t===null,title:t===null?n(`uiLibrary.sendFrameToTraining.playFirst`,`Play back a recording first — the frame at the playhead is the one sent`):n(`uiLibrary.sendFrameToTraining.addFrame`,`Add the frame at the playhead to a training collection`),onClick:()=>{d(t),p(null),o(!0)},children:[v(ct,{className:`h-3.5 w-3.5`}),n(`uiLibrary.sendFrameToTraining.button`,`Send frame to training`)]}),v(SL,{open:a,onOpenChange:e=>!i.isPending&&o(e),children:c(TL,{children:[c(EL,{children:[v(kL,{children:n(`uiLibrary.sendFrameToTraining.title`,`Send this frame to training`)}),v(AL,{children:u===null?``:n(`uiLibrary.sendFrameToTraining.description`,`The camera's frame at {{time}} is taken from the recording at full resolution and added to the collection. Annotate it on the Retrain page — including what the model missed.`,{time:new Date(u).toLocaleString()})})]}),v(jL,{value:s,onChange:l}),f!==null&&v(`p`,{className:`mt-2 text-xs ${f.kind===`added`?`text-success`:`text-danger`}`,role:`status`,children:f.kind===`added`?f.reused?n(`uiLibrary.sendFrameToTraining.reused`,`That moment was already in the dataset; it is now in {{collection}}.`,{collection:f.collection}):n(`uiLibrary.sendFrameToTraining.added`,`Added to {{collection}}.`,{collection:f.collection}):f.text}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:i.isPending,onClick:()=>{o(!1)},children:f?.kind===`added`?n(`uiLibrary.sendFrameToTraining.done`,`Done`):n(`uiLibrary.sendFrameToTraining.cancel`,`Cancel`)}),c(_A,{type:`button`,size:`sm`,disabled:s===null||i.isPending||f?.kind===`added`,onClick:()=>void m(),children:[i.isPending&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),n(`uiLibrary.sendFrameToTraining.send`,`Send`)]})]})]})})]})}E();function FL({windowFrom:e,windowTo:t,spans:n,playheadMs:r,onSeek:i,onScrubStart:a,onScrubMove:o,onScrubEnd:s}){let l=q(),[u,d]=C(null),p=!!s,[m,h]=C(!1),g=f(null),_=n=>{let r=n.currentTarget.getBoundingClientRect();if(r.width<=0)return null;let i=(n.clientX-r.left)/r.width;return e+Math.min(1,Math.max(0,i))*(t-e)},y=e=>{if(p)return;let t=_(e);t!==null&&i(t)},b=e=>{if(!p)return;e.currentTarget.setPointerCapture(e.pointerId),h(!0),a?.();let t=_(e);t!==null&&(g.current=t,o?.(t))},x=e=>{if(!p||!m)return;let t=_(e);t!==null&&(g.current=t,o?.(t))},S=e=>{if(!p||!m)return;h(!1);let t=_(e)??g.current;g.current=null,t!==null&&s?.(t)},w=()=>{if(!m)return;h(!1);let e=g.current;g.current=null,e!==null&&s?.(e)},T=e=>{let t=_(e);if(t===null)return;let n=e.currentTarget.getBoundingClientRect();d({xPct:n.width>0?(e.clientX-n.left)/n.width*100:0,ms:t})},E=()=>{d(null)},D=u===null?null:new Date(u.ms).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`});return c(`div`,{className:`relative`,children:[c(`div`,{"data-testid":`coverage-track`,"data-scrubbing":m?`true`:`false`,onClick:y,onPointerDown:b,onPointerMove:x,onPointerUp:S,onPointerCancel:w,onMouseMove:T,onMouseLeave:E,className:`relative h-5 overflow-hidden rounded bg-background/40 ${p?`cursor-ew-resize touch-none select-none`:`cursor-pointer`}`,role:`group`,"aria-label":l(`uiLibrary.coverageTrack.ariaLabel`,`Recorded coverage timeline`),children:[n.map(n=>{let r=VM(n.startMs,e,t),i=VM(n.endMs,e,t);return v(`div`,{"data-testid":`coverage-band`,className:`absolute inset-y-0 bg-gradient-to-b from-primary to-primary/80`,style:{left:`${r}%`,width:`${Math.max(.5,i-r)}%`}},`${n.startMs}-${n.endMs}`)}),r===null?null:v(`div`,{"data-testid":`coverage-playhead`,className:`absolute inset-y-[-2px] w-0.5 bg-amber-500 shadow-[0_0_6px] shadow-amber-500`,style:{left:`${VM(r,e,t)}%`}})]}),u!==null&&D!==null?v(`div`,{"data-testid":`coverage-hover-tooltip`,className:`pointer-events-none absolute top-full z-10 mt-0.5 -translate-x-1/2 rounded bg-popover px-1.5 py-0.5 text-[9px] text-popover-foreground shadow`,style:{left:`${u.xPct}%`},children:D}):null]})}E();function IL({mediaUrl:e,kind:t}){let[n,r]=C(!1);return e&&!n?v(`img`,{src:e,alt:``,className:`h-full w-full object-cover`,loading:`lazy`,onError:()=>r(!0)}):v(`div`,{className:`flex h-full w-full items-center justify-center text-white/30`,children:v(LL,{kind:t,large:!0})})}function LL({kind:e,large:t=!1}){return v(e===`object`?Ze:e===`audio`?mt:ai,{className:t?`h-7 w-7`:`h-3.5 w-3.5 text-foreground-subtle`})}var RL=[`motion`,`object`,`audio`];function zL(e){return new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}function BL({clips:e,loading:t,busyKey:n,onPlay:r,enabledKinds:i,onToggleKind:a,hasMore:o,onLoadMore:s}){let l=q(),u=v(`div`,{className:`flex items-center gap-3 pb-1`,children:RL.map(e=>c(`label`,{className:`flex cursor-pointer items-center gap-1 text-xs text-foreground-subtle select-none`,children:[v(`input`,{type:`checkbox`,checked:i.has(e),onChange:()=>a(e),className:`h-3.5 w-3.5 accent-primary`}),e]},e))});return t&&e.length===0?c(`div`,{className:`space-y-2`,children:[u,v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.loading`,`Loading events…`)})]}):e.length===0?c(`div`,{className:`space-y-2`,children:[u,v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.empty`,`No events in this window.`)})]}):c(`div`,{className:`space-y-2`,children:[u,t?v(`div`,{className:`px-1 text-[10px] text-foreground-subtle`,children:l(`uiLibrary.eventBucketStrip.loading`,`Loading events…`)}):null,v(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.map(e=>{let t=`${e.kind}:${e.id}`;return c(`button`,{type:`button`,disabled:n!==null,onClick:()=>r(e),className:`group overflow-hidden rounded-lg border border-border text-left transition-colors hover:border-primary disabled:opacity-60`,children:[c(`div`,{className:`relative aspect-video bg-black/90`,children:[v(IL,{mediaUrl:e.mediaUrl,kind:e.kind}),v(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/0 transition-colors group-hover:bg-black/30`,children:n===t?v(Gn,{className:`h-6 w-6 animate-spin text-white`}):v(Le,{className:`h-6 w-6 text-white opacity-0 transition-opacity group-hover:opacity-100`})})]}),c(`div`,{className:`flex items-center gap-1.5 bg-surface px-2 py-1.5`,children:[v(LL,{kind:e.kind}),c(`div`,{className:`min-w-0 flex-1`,children:[v(`div`,{className:`truncate text-xs font-medium text-foreground`,children:e.label}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:zL(e.timestamp)})]})]})]},t)})}),e.length>0?c(`div`,{className:`flex items-center gap-2 pt-1 text-[11px] text-foreground-subtle`,children:[v(`span`,{children:l(`uiLibrary.eventBucketStrip.shown`,`({{count}} shown)`,{count:e.length})}),o?v(`button`,{type:`button`,onClick:s,className:`rounded px-2 py-0.5 text-[11px] font-medium text-primary hover:underline`,children:l(`uiLibrary.eventBucketStrip.loadMore`,`Load more`)}):null]}):null]})}function VL(e){let t=e.filter(e=>e.endMs>e.startMs).map(e=>({startMs:e.startMs,endMs:e.endMs})).toSorted((e,t)=>e.startMs-t.startMs),n=[];for(let e of t){let t=n[n.length-1];t&&e.startMs<=t.endMs?e.endMs>t.endMs&&(n[n.length-1]={startMs:t.startMs,endMs:e.endMs}):n.push(e)}return n}function HL(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1024)return`${Math.round(e)} B`;let t=[`KB`,`MB`,`GB`,`TB`,`PB`],n=e/1024,r=`KB`;for(let e of t){if(r=e,n<1024)break;n/=1024}return`${n>=100?Math.round(n).toString():n.toFixed(1)} ${r}`}E();var UL=[`motion`,`object`,`audio`],WL=60,GL=18e3/100,KL=5e3,qL=1e4,JL=[];function YL(e,t){switch(t){case`live`:return e(`uiLibrary.recordingTimeline.modeLive`,`Live`);case`loading`:return e(`uiLibrary.recordingTimeline.modeLoading`,`Loading…`);case`playing`:return e(`uiLibrary.recordingTimeline.modePlaying`,`Playing`);case`paused`:return e(`uiLibrary.recordingTimeline.modePaused`,`Paused`);case`gap`:return e(`uiLibrary.recordingTimeline.modeGap`,`No footage`);case`ended`:return e(`uiLibrary.recordingTimeline.modeEnded`,`Ended`);case`error`:return e(`uiLibrary.recordingTimeline.modeError`,`Error`)}}function XL({deviceId:e}){let t=q(),n=Rn(),r=mF(),[i,a]=C(null),[o,s]=C(null),[l,u]=C(null),[d,m]=C(null),h=dL(),{send:g,mode:y,positionMs:x}=h,[S,w]=C(!1),T=h.channelOpen&&!S,E=f(T);E.current=T;let D=p(()=>({scrubStart:()=>{},scrubTo:()=>{},scrubCommit:e=>{g({t:`scrubCommit`,epoch:e})},seek:e=>{g({t:`seek`,epoch:e})}}),[g]),O=f(y);O.current=y;let{state:k,beginScrub:A,updateScrub:j,endScrub:M,seek:N,setPlayhead:P,reset:F}=yL(D,_(()=>O.current===`live`,[]));b(()=>{x!==null&&P(x)},[x,P]),b(()=>{(!h.channelOpen||y===`live`)&&F()},[h.channelOpen,y,F]);let I=_(()=>{g({t:`goLive`}),F()},[g,F]),L=_(()=>{g({t:`setRate`,rate:+(O.current===`paused`)})},[g]),[R,z]=C(()=>new Set(UL)),B=_(e=>{z(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[V,H]=C(WL),U=_(()=>{H(e=>e+WL)},[]);b(()=>{H(WL)},[i]);let[ee,W]=C(()=>new Date),[G,te]=C(()=>HM(new Date,Date.now())),ne=p(()=>HM(ee,Date.now()),[ee]),re=_(e=>{W(e),te(HM(e,Date.now())),a(null)},[]),K=_(e=>{te(e),a(null)},[]),ie=f(null),ae=_(e=>{let t=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.shiftKey?e.deltaY:0;if(t===0)return;e.preventDefault();let n=t*GL;te(e=>GM(e,ne,n))},[ne]),oe=qM(G.toMs-G.fromMs),se=Yw({deviceId:e,provider:ia,fromMs:G.fromMs,toMs:G.toMs}),ce=Ob({deviceId:e,since:G.fromMs,until:G.toMs,bucketMs:oe}),le=se.data?.read===`unreadable`,ue=se.data?.read===`read`?se.data.ranges:JL,de=p(()=>VL(ue),[ue]),pe=p(()=>RM(ce.data??[],G.fromMs,oe),[ce.data,G.fromMs,oe]),me=i===null?void 0:pe.find(e=>e.index===i),he=me!==void 0,ge=me?.startMs??0,_e=me?Math.min(me.endMs,G.toMs):0,ve=bb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`object`)}),ye=yb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`motion`)}),be=xb({deviceId:e,since:ge,until:_e,limit:V,projection:`slim`},{enabled:he&&R.has(`audio`)}),xe=p(()=>{if(!me)return[];let e=[];if(R.has(`object`))for(let t of ve.data??[])e.push({id:String(t.id),timestamp:t.timestamp,kind:`object`,label:t.label??t.className,mediaUrl:t.mediaUrl});if(R.has(`motion`))for(let n of ye.data??[])e.push({id:String(n.id),timestamp:n.timestamp,kind:`motion`,label:t(`uiLibrary.recordingTimeline.motionClip`,`Motion ({{count}})`,{count:n.regionCount}),mediaUrl:n.mediaUrl});if(R.has(`audio`))for(let n of be.data??[])e.push({id:String(n.id),timestamp:n.timestamp,kind:`audio`,label:n.classification?.className??t(`uiLibrary.recordingTimeline.audioClip`,`Audio`),mediaUrl:n.mediaUrl});return e.toSorted((e,t)=>t.timestamp-e.timestamp)},[me,R,ve.data,ye.data,be.data,t]),Se=p(()=>!!(R.has(`object`)&&(ve.data?.length??0)===V||R.has(`motion`)&&(ye.data?.length??0)===V||R.has(`audio`)&&(be.data?.length??0)===V),[R,ve.data,ye.data,be.data,V]),Ce=_(async(t,i,a,o,c)=>{u(t),m(null);try{let t=await n.trpcClient.recording.getPlayback.query({deviceId:e,provider:ia,fromMs:i,toMs:a});t.kind===`hls`&&t.manifest.playbackUrl?(s(c),r.play({url:t.manifest.playbackUrl,label:o})):m(t.kind===`none`?`No playable footage for this selection — ${t.reason}`:`No playable footage for this selection.`)}catch{m(`Could not load this recording.`)}finally{u(null)}},[n,e,r]),we=_(e=>{let t=BM(e,de);if(!t)return;if(E.current){N(t.fromMs,`timeline`);return}let n=`Recording · ${new Date(t.fromMs).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}`;Ce(`seek:${t.fromMs}`,t.fromMs,t.toMs,n,t.fromMs)},[de,Ce,N]),Te=_(()=>{A(`timeline`)},[A]),Ee=_(e=>{j(e,`timeline`)},[j]),De=_(e=>{M(BM(e,de)?.fromMs??e,`timeline`)},[de,M]),Oe=_(e=>{if(E.current){N(e.timestamp-KL,`timeline`);return}let t=`${e.label} · ${new Date(e.timestamp).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`})}`;Ce(`${e.kind}:${e.id}`,e.timestamp-KL,e.timestamp+qL,t,e.timestamp)},[Ce,N]),ke=_(e=>{a(t=>t===e?null:e)},[]),Ae=se.isLoading,je=ce.isLoading,Me=(ve.isLoading||ye.isLoading||be.isLoading)&&he,Ne=p(()=>JM(G.fromMs,G.toMs,5),[G.fromMs,G.toMs]),Pe=T?k.scrubbing?k.scrubEpoch:k.playheadEpoch:o,Fe=T&&(y===`playing`||y===`paused`);return c(`div`,{className:`space-y-3`,children:[se.isError?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingTimeline.recorderUnavailable`,`Recorder unavailable — the recording service may not be running for this node.`)}):null,le?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingTimeline.availabilityUnreadable`,`CamStack could not be asked about this camera's recordings — this bar shows nothing, which is not the same as no footage.`)}):null,d?v(eN,{variant:`warning`,message:d}):null,v(cF,{day:ee,onDayChange:re,view:G,dayBounds:ne,onViewChange:K}),v(`div`,{className:`flex justify-end`,children:v(PL,{deviceId:e,epochMs:Pe})}),h.channelOpen?c(`div`,{"data-testid":`frame-push-status-row`,className:`flex flex-wrap items-center gap-2 text-[10px]`,children:[v(`span`,{"data-testid":`frame-push-mode-chip`,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-semibold uppercase tracking-wider ${T&&y!==`live`?y===`error`?`bg-rose-500/15 text-rose-400`:`bg-primary/15 text-primary`:`bg-background/40 text-foreground-subtle`}`,children:T?YL(t,y):t(`uiLibrary.recordingTimeline.hlsMode`,`HLS mode`)}),T&&x!==null&&!k.scrubbing?v(`span`,{className:`tabular-nums text-foreground-subtle`,children:new Date(x).toLocaleTimeString()}):null,Fe?c(`button`,{type:`button`,"data-testid":`frame-push-rate-toggle`,onClick:L,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,title:y===`paused`?t(`uiLibrary.recordingTimeline.resumeTitle`,`Resume playback`):t(`uiLibrary.recordingTimeline.pauseTitle`,`Pause playback`),children:[v(y===`paused`?Le:Vt,{className:`h-3 w-3`}),y===`paused`?t(`uiLibrary.recordingTimeline.resume`,`Resume`):t(`uiLibrary.recordingTimeline.pause`,`Pause`)]}):null,T&&y!==`live`?c(`button`,{type:`button`,"data-testid":`frame-push-go-live`,onClick:I,className:`inline-flex items-center gap-1 rounded bg-danger/10 px-1.5 py-0.5 font-medium text-danger transition-colors hover:bg-danger/20`,title:t(`uiLibrary.recordingTimeline.liveTitle`,`Return to the live stream`),children:[v(fe,{className:`h-3 w-3`}),t(`uiLibrary.recordingTimeline.goLive`,`Go live`)]}):null,v(`button`,{type:`button`,"data-testid":`frame-push-hls-toggle`,onClick:()=>w(e=>!e),className:`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 font-medium transition-colors ${S?`bg-primary/15 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:t(`uiLibrary.recordingTimeline.hlsTitle`,`Play recordings through the HLS player instead of the live WebRTC session`),children:`HLS`})]}):null,c(`div`,{ref:ie,onWheel:ae,className:`space-y-1`,children:[c(`div`,{className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`uiLibrary.recordingTimeline.recorded`,`Recorded`)}),Ae?v(`div`,{className:`h-5 animate-pulse rounded bg-background/40`}):de.length===0?v(QM,{icon:Kt,title:t(`uiLibrary.recordingTimeline.noRecordings`,`No recordings for this window.`)}):v(FL,{windowFrom:G.fromMs,windowTo:G.toMs,spans:de,playheadMs:Pe,onSeek:we,...T?{onScrubStart:Te,onScrubMove:Ee,onScrubEnd:De}:{}})]}),c(`div`,{className:`space-y-1`,children:[v(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:t(`uiLibrary.recordingTimeline.density`,`Events · density`)}),je?v(`div`,{className:`h-6 animate-pulse rounded bg-background/40`}):v(aF,{windowFrom:G.fromMs,windowTo:G.toMs,buckets:pe,selectedIndex:i,onSelectBucket:ke})]}),v(`div`,{className:`relative h-3`,children:Ne.map(e=>v(`span`,{className:`absolute -translate-x-1/2 text-[9px] text-foreground-subtle`,style:{left:`${e.pct}%`},children:e.label},e.pct))})]}),me?v(BL,{clips:xe,loading:Me,busyKey:l,onPlay:Oe,enabledKinds:R,onToggleKind:B,hasMore:Se,onLoadMore:U}):v(`p`,{className:`text-[11px] text-foreground-subtle`,children:T?t(`uiLibrary.recordingTimeline.helpFramePush`,`Click or drag the coverage bar to play from any point (frames play in the main player above), or click a density bar to browse that window’s events.`):t(`uiLibrary.recordingTimeline.helpHls`,`Click the coverage bar to play from any point, or a density bar to browse that window’s events.`)})]})}E();var ZL=1440*60*1e3;function QL({deviceId:e}){let t=q(),n=k(),r=kT({deviceId:e}),i=nT({deviceId:e}),a=fm({deviceId:e}).data?.location??null,o=Cm({deviceId:e}),s=o.status===`pending`?`pending`:o.status===`error`?`unknown`:o.data.entries.some(e=>e.capName===`recording-signal`)?`present`:`absent`,l=sT(),u=cT(),{data:d}=ED(void 0,{staleTime:3e4}),f=p(()=>Tee(d??[],e).map(e=>e.profile),[d,e]),m=t=>{l.mutate({deviceId:e,config:t},{onSuccess:()=>{i.refetch(),r.refetch()}})},h=_(()=>{u.mutate({deviceId:e},{onSuccess:()=>{n.invalidateQueries({queryKey:[[`recording`]]})}})},[e,n,u]),g=p(()=>Date.now(),[]),y=Yw({deviceId:e,provider:ia,fromMs:g-ZL,toMs:g}),b=r.data?Ta.safeParse(r.data):null,x=b?.success?b.data:null,S=i.data?See.safeParse(i.data):null,C=S?.success?S.data:null,w=y.data?.read===`unreadable`,T=y.data?.read===`read`?y.data.ranges:[],E=T.reduce((e,t)=>e+Math.max(0,t.endMs-t.startMs),0),D=x?.enabled===!0&&x.activeMode===`continuous`;return c(`div`,{className:`space-y-3`,children:[v($t,{title:t(`uiLibrary.recordingPanel.settings`,`Settings`),icon:v(Yn,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:C?v(rL,{initial:C,availableProfiles:f,saving:l.isPending,onSave:m,sensorContext:{cameraId:e,location:a,deviceSignal:s}},JSON.stringify(C)):v(`div`,{className:`px-1 py-2 text-xs text-foreground-subtle`,children:t(`uiLibrary.recordingPanel.loadingSettings`,`Loading settings…`)})}),v($t,{title:t(`uiLibrary.recordingPanel.recording`,`Recording`),icon:v(Kt,{className:`h-3.5 w-3.5 text-foreground-subtle`}),headerRight:c(`span`,{className:`flex items-center gap-2`,children:[D?c(`span`,{className:`flex items-center gap-1.5 text-[10px] text-emerald-500`,children:[v(fe,{className:`h-3 w-3`}),` `,t(`uiLibrary.recordingPanel.recording`,`Recording`)]}):null,v(`button`,{type:`button`,onClick:h,disabled:u.isPending,"aria-label":t(`uiLibrary.recordingPanel.rescanStorage`,`Rescan storage`),className:`flex items-center rounded p-0.5 text-foreground-subtle transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50`,children:v(_e,{className:`h-3.5 w-3.5 ${u.isPending?`animate-spin`:``}`})})]}),children:c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-3`,children:[v(an,{label:t(`uiLibrary.recordingPanel.status`,`Status`),icon:v(Si,{className:`h-3.5 w-3.5 ${D?`text-emerald-500`:``}`}),footer:x?.nodeId?t(`uiLibrary.recordingPanel.nodeFooter`,`node: {{nodeId}}`,{nodeId:x.nodeId}):void 0,children:r.isLoading?`…`:D?t(`uiLibrary.recordingPanel.recordingContinuous`,`Recording (continuous)`):t(`uiLibrary.recordingPanel.idle`,`Idle`)}),v(an,{label:t(`uiLibrary.recordingPanel.storage`,`Storage`),icon:v(pt,{className:`h-3.5 w-3.5`}),children:x?HL(x.storageBytes):`—`}),v(an,{label:t(`uiLibrary.recordingPanel.recorded24h`,`Recorded (24h)`),icon:v(In,{className:`h-3.5 w-3.5`}),footer:w?t(`uiLibrary.recordingPanel.nobodyCouldLook`,`nobody could look`):t(`uiLibrary.recordingPanel.segmentRange`,{one:`{{count}} segment range`,other:`{{count}} segment ranges`},{count:T.length}),children:y.isLoading?`…`:w?`—`:yF(E)})]}),r.isError?v(eN,{variant:`warning`,message:t(`uiLibrary.recordingPanel.recorderUnavailable`,`Recorder unavailable — the recording service may not be running for this node.`)}):null,v(XL,{deviceId:e}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.recordingPanel.playbackHint`,`Recordings play in the main player above — switch back to live from there.`)})]})})]})}E();var $L={"host/motion-zones-grid":m(()=>a(()=>import(`./MotionZonesSettings-BXHdXw3X.js`).then(e=>({default:e.MotionZonesSettings})),__vite__mapDeps([38,1,2,3,39]),import.meta.url)),"host/privacy-mask-grid":m(()=>a(()=>import(`./PrivacyMaskSettings-BXiuTmLQ.js`).then(e=>({default:e.PrivacyMaskSettings})),__vite__mapDeps([40,1,2,3,23,39]),import.meta.url)),"host/ptz-panel":RI,"host/navigation-panel":AI,"host/consumables-panel":PM,"host/ptz-autotrack":GA,"host/recording-panel":QL,"host/camera-grid-layout":Hj,"host/clips-browser":QF,"host/extensions-panel":yI};E();function eR(e){let{widgetId:t,deviceId:n}=e,r=$L[t];return r===void 0?v(tR,{...e}):n===void 0?v(iR,{widgetId:t,reason:`missing-device-context`}):v(g,{fallback:v(rR,{}),children:v(r,{deviceId:n})})}function tR(e){let{widgetId:t}=e,n=BA(t);return n===void 0?v(iR,{widgetId:t,reason:`unknown`}):v(nR,{...e,metadata:n})}function nR(e){let{widgetId:t,host:n=`device-tab`,config:r,deviceId:i,integrationId:a,instanceId:o,size:s,columns:c,rows:l,metadata:u}=e,d=VA(u.remote,u.bundleUrl),f=p(()=>o??t,[o,t]);return d===null?v(rR,{}):d===void 0?v(iR,{widgetId:t,reason:`missing-export`}):u.requires.deviceContext&&i===void 0?v(iR,{widgetId:t,reason:`missing-device-context`}):u.requires.integrationContext&&a===void 0?v(iR,{widgetId:t,reason:`missing-integration-context`}):v(d,{instanceId:f,host:n,config:r,deviceId:i,integrationId:a,size:s,columns:c,rows:l})}function rR(){return c(`div`,{className:`rounded-lg border border-border bg-surface/40 p-4 animate-pulse`,children:[v(`div`,{className:`h-3 w-24 bg-foreground-subtle/20 rounded mb-2`}),v(`div`,{className:`h-2 w-full bg-foreground-subtle/10 rounded mb-1`}),v(`div`,{className:`h-2 w-3/4 bg-foreground-subtle/10 rounded`})]})}function iR({widgetId:e,reason:t}){return v(`div`,{className:`rounded-lg border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children: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`})}E();var aR=Object.defineProperty,oR=Object.getOwnPropertySymbols,sR=Object.prototype.hasOwnProperty,cR=Object.prototype.propertyIsEnumerable,lR=(e,t,n)=>t in e?aR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,uR=(e,t)=>{for(var n in t||={})sR.call(t,n)&&lR(e,n,t[n]);if(oR)for(var n of oR(t))cR.call(t,n)&&lR(e,n,t[n]);return e},dR=(e,t)=>{var n={};for(var r in e)sR.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&oR)for(var r of oR(e))t.indexOf(r)<0&&cR.call(e,r)&&(n[r]=e[r]);return n},fR;(e=>{let t=class t{constructor(e,n,r,a){if(this.version=e,this.errorCorrectionLevel=n,this.modules=[],this.isFunction=[],e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version value out of range`);if(a<-1||a>7)throw RangeError(`Mask value out of range`);this.size=e*4+17;let o=[];for(let e=0;e<this.size;e++)o.push(!1);for(let e=0;e<this.size;e++)this.modules.push(o.slice()),this.isFunction.push(o.slice());this.drawFunctionPatterns();let s=this.addEccAndInterleave(r);if(this.drawCodewords(s),a==-1){let e=1e9;for(let t=0;t<8;t++){this.applyMask(t),this.drawFormatBits(t);let n=this.getPenaltyScore();n<e&&(a=t,e=n),this.applyMask(t)}}i(0<=a&&a<=7),this.mask=a,this.applyMask(a),this.drawFormatBits(a),this.isFunction=[]}static encodeText(n,r){let i=e.QrSegment.makeSegments(n);return t.encodeSegments(i,r)}static encodeBinary(n,r){let i=e.QrSegment.makeBytes(n);return t.encodeSegments([i],r)}static encodeSegments(e,r,a=1,s=40,c=-1,l=!0){if(!(t.MIN_VERSION<=a&&a<=s&&s<=t.MAX_VERSION)||c<-1||c>7)throw RangeError(`Invalid value`);let u,d;for(u=a;;u++){let n=t.getNumDataCodewords(u,r)*8,i=o.getTotalBits(e,u);if(i<=n){d=i;break}if(u>=s)throw RangeError(`Data too long`)}for(let e of[t.Ecc.MEDIUM,t.Ecc.QUARTILE,t.Ecc.HIGH])l&&d<=t.getNumDataCodewords(u,e)*8&&(r=e);let f=[];for(let t of e){n(t.mode.modeBits,4,f),n(t.numChars,t.mode.numCharCountBits(u),f);for(let e of t.getData())f.push(e)}i(f.length==d);let p=t.getNumDataCodewords(u,r)*8;i(f.length<=p),n(0,Math.min(4,p-f.length),f),n(0,(8-f.length%8)%8,f),i(f.length%8==0);for(let e=236;f.length<p;e^=253)n(e,8,f);let m=[];for(;m.length*8<f.length;)m.push(0);return f.forEach((e,t)=>m[t>>>3]|=e<<7-(t&7)),new t(u,r,m,c)}getModule(e,t){return 0<=e&&e<this.size&&0<=t&&t<this.size&&this.modules[t][e]}getModules(){return this.modules}drawFunctionPatterns(){for(let e=0;e<this.size;e++)this.setFunctionModule(6,e,e%2==0),this.setFunctionModule(e,6,e%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);let e=this.getAlignmentPatternPositions(),t=e.length;for(let n=0;n<t;n++)for(let r=0;r<t;r++)n==0&&r==0||n==0&&r==t-1||n==t-1&&r==0||this.drawAlignmentPattern(e[n],e[r]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(e){let t=this.errorCorrectionLevel.formatBits<<3|e,n=t;for(let e=0;e<10;e++)n=n<<1^(n>>>9)*1335;let a=(t<<10|n)^21522;i(a>>>15==0);for(let e=0;e<=5;e++)this.setFunctionModule(8,e,r(a,e));this.setFunctionModule(8,7,r(a,6)),this.setFunctionModule(8,8,r(a,7)),this.setFunctionModule(7,8,r(a,8));for(let e=9;e<15;e++)this.setFunctionModule(14-e,8,r(a,e));for(let e=0;e<8;e++)this.setFunctionModule(this.size-1-e,8,r(a,e));for(let e=8;e<15;e++)this.setFunctionModule(8,this.size-15+e,r(a,e));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let e=this.version;for(let t=0;t<12;t++)e=e<<1^(e>>>11)*7973;let t=this.version<<12|e;i(t>>>18==0);for(let e=0;e<18;e++){let n=r(t,e),i=this.size-11+e%3,a=Math.floor(e/3);this.setFunctionModule(i,a,n),this.setFunctionModule(a,i,n)}}drawFinderPattern(e,t){for(let n=-4;n<=4;n++)for(let r=-4;r<=4;r++){let i=Math.max(Math.abs(r),Math.abs(n)),a=e+r,o=t+n;0<=a&&a<this.size&&0<=o&&o<this.size&&this.setFunctionModule(a,o,i!=2&&i!=4)}}drawAlignmentPattern(e,t){for(let n=-2;n<=2;n++)for(let r=-2;r<=2;r++)this.setFunctionModule(e+r,t+n,Math.max(Math.abs(r),Math.abs(n))!=1)}setFunctionModule(e,t,n){this.modules[t][e]=n,this.isFunction[t][e]=!0}addEccAndInterleave(e){let n=this.version,r=this.errorCorrectionLevel;if(e.length!=t.getNumDataCodewords(n,r))throw RangeError(`Invalid argument`);let a=t.NUM_ERROR_CORRECTION_BLOCKS[r.ordinal][n],o=t.ECC_CODEWORDS_PER_BLOCK[r.ordinal][n],s=Math.floor(t.getNumRawDataModules(n)/8),c=a-s%a,l=Math.floor(s/a),u=[],d=t.reedSolomonComputeDivisor(o);for(let n=0,r=0;n<a;n++){let i=e.slice(r,r+l-o+(n<c?0:1));r+=i.length;let a=t.reedSolomonComputeRemainder(i,d);n<c&&i.push(0),u.push(i.concat(a))}let f=[];for(let e=0;e<u[0].length;e++)u.forEach((t,n)=>{(e!=l-o||n>=c)&&f.push(t[e])});return i(f.length==s),f}drawCodewords(e){if(e.length!=Math.floor(t.getNumRawDataModules(this.version)/8))throw RangeError(`Invalid argument`);let n=0;for(let t=this.size-1;t>=1;t-=2){t==6&&(t=5);for(let i=0;i<this.size;i++)for(let a=0;a<2;a++){let o=t-a,s=t+1&2?i:this.size-1-i;!this.isFunction[s][o]&&n<e.length*8&&(this.modules[s][o]=r(e[n>>>3],7-(n&7)),n++)}}i(n==e.length*8)}applyMask(e){if(e<0||e>7)throw RangeError(`Mask value out of range`);for(let t=0;t<this.size;t++)for(let n=0;n<this.size;n++){let r;switch(e){case 0:r=(n+t)%2==0;break;case 1:r=t%2==0;break;case 2:r=n%3==0;break;case 3:r=(n+t)%3==0;break;case 4:r=(Math.floor(n/3)+Math.floor(t/2))%2==0;break;case 5:r=n*t%2+n*t%3==0;break;case 6:r=(n*t%2+n*t%3)%2==0;break;case 7:r=((n+t)%2+n*t%3)%2==0;break;default:throw Error(`Unreachable`)}!this.isFunction[t][n]&&r&&(this.modules[t][n]=!this.modules[t][n])}}getPenaltyScore(){let e=0;for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[n][o]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[n][o],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size;n++){let r=!1,i=0,a=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][n]==r?(i++,i==5?e+=t.PENALTY_N1:i>5&&e++):(this.finderPenaltyAddHistory(i,a),r||(e+=this.finderPenaltyCountPatterns(a)*t.PENALTY_N3),r=this.modules[o][n],i=1);e+=this.finderPenaltyTerminateAndCount(r,i,a)*t.PENALTY_N3}for(let n=0;n<this.size-1;n++)for(let r=0;r<this.size-1;r++){let i=this.modules[n][r];i==this.modules[n][r+1]&&i==this.modules[n+1][r]&&i==this.modules[n+1][r+1]&&(e+=t.PENALTY_N2)}let n=0;for(let e of this.modules)n=e.reduce((e,t)=>e+ +!!t,n);let r=this.size*this.size,a=Math.ceil(Math.abs(n*20-r*10)/r)-1;return i(0<=a&&a<=9),e+=a*t.PENALTY_N4,i(0<=e&&e<=2568888),e}getAlignmentPatternPositions(){if(this.version==1)return[];{let e=Math.floor(this.version/7)+2,t=this.version==32?26:Math.ceil((this.version*4+4)/(e*2-2))*2,n=[6];for(let r=this.size-7;n.length<e;r-=t)n.splice(1,0,r);return n}}static getNumRawDataModules(e){if(e<t.MIN_VERSION||e>t.MAX_VERSION)throw RangeError(`Version number out of range`);let n=(16*e+128)*e+64;if(e>=2){let t=Math.floor(e/7)+2;n-=(25*t-10)*t-55,e>=7&&(n-=36)}return i(208<=n&&n<=29648),n}static getNumDataCodewords(e,n){return Math.floor(t.getNumRawDataModules(e)/8)-t.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e]*t.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][e]}static reedSolomonComputeDivisor(e){if(e<1||e>255)throw RangeError(`Degree out of range`);let n=[];for(let t=0;t<e-1;t++)n.push(0);n.push(1);let r=1;for(let i=0;i<e;i++){for(let e=0;e<n.length;e++)n[e]=t.reedSolomonMultiply(n[e],r),e+1<n.length&&(n[e]^=n[e+1]);r=t.reedSolomonMultiply(r,2)}return n}static reedSolomonComputeRemainder(e,n){let r=n.map(e=>0);for(let i of e){let e=i^r.shift();r.push(0),n.forEach((n,i)=>r[i]^=t.reedSolomonMultiply(n,e))}return r}static reedSolomonMultiply(e,t){if(e>>>8||t>>>8)throw RangeError(`Byte out of range`);let n=0;for(let r=7;r>=0;r--)n=n<<1^(n>>>7)*285,n^=(t>>>r&1)*e;return i(n>>>8==0),n}finderPenaltyCountPatterns(e){let t=e[1];i(t<=this.size*3);let n=t>0&&e[2]==t&&e[3]==t*3&&e[4]==t&&e[5]==t;return(n&&e[0]>=t*4&&e[6]>=t?1:0)+(n&&e[6]>=t*4&&e[0]>=t?1:0)}finderPenaltyTerminateAndCount(e,t,n){return e&&(this.finderPenaltyAddHistory(t,n),t=0),t+=this.size,this.finderPenaltyAddHistory(t,n),this.finderPenaltyCountPatterns(n)}finderPenaltyAddHistory(e,t){t[0]==0&&(e+=this.size),t.pop(),t.unshift(e)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],t.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=t;function n(e,t,n){if(t<0||t>31||e>>>t)throw RangeError(`Value out of range`);for(let r=t-1;r>=0;r--)n.push(e>>>r&1)}function r(e,t){return(e>>>t&1)!=0}function i(e){if(!e)throw Error(`Assertion error`)}let a=class e{constructor(e,t,n){if(this.mode=e,this.numChars=t,this.bitData=n,t<0)throw RangeError(`Invalid argument`);this.bitData=n.slice()}static makeBytes(t){let r=[];for(let e of t)n(e,8,r);return new e(e.Mode.BYTE,t.length,r)}static makeNumeric(t){if(!e.isNumeric(t))throw RangeError(`String contains non-numeric characters`);let r=[];for(let e=0;e<t.length;){let i=Math.min(t.length-e,3);n(parseInt(t.substring(e,e+i),10),i*3+1,r),e+=i}return new e(e.Mode.NUMERIC,t.length,r)}static makeAlphanumeric(t){if(!e.isAlphanumeric(t))throw RangeError(`String contains unencodable characters in alphanumeric mode`);let r=[],i;for(i=0;i+2<=t.length;i+=2){let a=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i))*45;a+=e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i+1)),n(a,11,r)}return i<t.length&&n(e.ALPHANUMERIC_CHARSET.indexOf(t.charAt(i)),6,r),new e(e.Mode.ALPHANUMERIC,t.length,r)}static makeSegments(t){return t==``?[]:e.isNumeric(t)?[e.makeNumeric(t)]:e.isAlphanumeric(t)?[e.makeAlphanumeric(t)]:[e.makeBytes(e.toUtf8ByteArray(t))]}static makeEci(t){let r=[];if(t<0)throw RangeError(`ECI assignment value out of range`);if(t<128)n(t,8,r);else if(t<16384)n(2,2,r),n(t,14,r);else if(t<1e6)n(6,3,r),n(t,21,r);else throw RangeError(`ECI assignment value out of range`);return new e(e.Mode.ECI,0,r)}static isNumeric(t){return e.NUMERIC_REGEX.test(t)}static isAlphanumeric(t){return e.ALPHANUMERIC_REGEX.test(t)}getData(){return this.bitData.slice()}static getTotalBits(e,t){let n=0;for(let r of e){let e=r.mode.numCharCountBits(t);if(r.numChars>=1<<e)return 1/0;n+=4+e+r.bitData.length}return n}static toUtf8ByteArray(e){e=encodeURI(e);let t=[];for(let n=0;n<e.length;n++)e.charAt(n)==`%`?(t.push(parseInt(e.substring(n+1,n+3),16)),n+=2):t.push(e.charCodeAt(n));return t}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`;let o=a;e.QrSegment=a})(fR||={}),(e=>{(e=>{let t=class{constructor(e,t){this.ordinal=e,this.formatBits=t}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(e.QrCode||={})})(fR||={}),(e=>{(e=>{let t=class{constructor(e,t){this.modeBits=e,this.numBitsCharCount=t}numCharCountBits(e){return this.numBitsCharCount[Math.floor((e+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(e.QrSegment||={})})(fR||={});var pR=fR,mR={L:pR.QrCode.Ecc.LOW,M:pR.QrCode.Ecc.MEDIUM,Q:pR.QrCode.Ecc.QUARTILE,H:pR.QrCode.Ecc.HIGH},hR=128,gR=`L`,_R=`#FFFFFF`,vR=`#000000`,yR=!1,bR=1,xR=4,SR=0,CR=.1;function wR(e,t=0){let n=[];return e.forEach(function(e,r){let i=null;e.forEach(function(a,o){if(!a&&i!==null){n.push(`M${i+t} ${r+t}h${o-i}v1H${i+t}z`),i=null;return}if(o===e.length-1){if(!a)return;i===null?n.push(`M${o+t},${r+t} h1v1H${o+t}z`):n.push(`M${i+t},${r+t} h${o+1-i}v1H${i+t}z`);return}a&&i===null&&(i=o)})}),n.join(``)}function TR(e,t){return e.slice().map((e,n)=>n<t.y||n>=t.y+t.h?e:e.map((e,n)=>n<t.x||n>=t.x+t.w?e:!1))}function ER(e,t,n,r){if(r==null)return null;let i=e.length+n*2,a=Math.floor(t*CR),o=i/t,s=(r.width||a)*o,c=(r.height||a)*o,l=r.x==null?e.length/2-s/2:r.x*o,u=r.y==null?e.length/2-c/2:r.y*o,d=r.opacity==null?1:r.opacity,f=null;if(r.excavate){let e=Math.floor(l),t=Math.floor(u);f={x:e,y:t,w:Math.ceil(s+l-e),h:Math.ceil(c+u-t)}}let p=r.crossOrigin;return{x:l,y:u,h:c,w:s,excavation:f,opacity:d,crossOrigin:p}}function DR(e,t){return t==null?e?xR:SR:Math.max(Math.floor(t),0)}function OR({value:e,level:t,minVersion:n,includeMargin:r,marginSize:i,imageSettings:a,size:o,boostLevel:s}){let c=l.useMemo(()=>{let r=(Array.isArray(e)?e:[e]).reduce((e,t)=>(e.push(...pR.QrSegment.makeSegments(t)),e),[]);return pR.QrCode.encodeSegments(r,mR[t],n,void 0,void 0,s)},[e,t,n,s]),{cells:u,margin:d,numCells:f,calculatedImageSettings:p}=l.useMemo(()=>{let e=c.getModules(),t=DR(r,i);return{cells:e,margin:t,numCells:e.length+t*2,calculatedImageSettings:ER(e,o,t,a)}},[c,o,a,r,i]);return{qrcode:c,margin:d,cells:u,numCells:f,calculatedImageSettings:p}}var kR=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),AR=l.forwardRef(function(e,t){let n=e,{value:r,size:i=hR,level:a=gR,bgColor:o=_R,fgColor:s=vR,includeMargin:c=yR,minVersion:u=bR,boostLevel:d,marginSize:f,imageSettings:p}=n,m=dR(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`marginSize`,`imageSettings`]),{style:h}=m,g=dR(m,[`style`]),_=p?.src,v=l.useRef(null),y=l.useRef(null),b=l.useCallback(e=>{v.current=e,typeof t==`function`?t(e):t&&(t.current=e)},[t]),[x,S]=l.useState(!1),{margin:C,cells:w,numCells:T,calculatedImageSettings:E}=OR({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:f,imageSettings:p,size:i});l.useEffect(()=>{if(v.current!=null){let e=v.current,t=e.getContext(`2d`);if(!t)return;let n=w,r=y.current,a=E!=null&&r!==null&&r.complete&&r.naturalHeight!==0&&r.naturalWidth!==0;a&&E.excavation!=null&&(n=TR(w,E.excavation));let c=window.devicePixelRatio||1;e.height=e.width=i*c;let l=i/T*c;t.scale(l,l),t.fillStyle=o,t.fillRect(0,0,T,T),t.fillStyle=s,kR?t.fill(new Path2D(wR(n,C))):w.forEach(function(e,n){e.forEach(function(e,r){e&&t.fillRect(r+C,n+C,1,1)})}),E&&(t.globalAlpha=E.opacity),a&&t.drawImage(r,E.x+C,E.y+C,E.w,E.h)}}),l.useEffect(()=>{S(!1)},[_]);let D=uR({height:i,width:i},h),O=null;return _!=null&&(O=l.createElement(`img`,{src:_,key:_,style:{display:`none`},onLoad:()=>{S(!0)},ref:y,crossOrigin:E?.crossOrigin})),l.createElement(l.Fragment,null,l.createElement(`canvas`,uR({style:D,height:i,width:i,ref:b,role:`img`},g)),O)});AR.displayName=`QRCodeCanvas`;var jR=l.forwardRef(function(e,t){let n=e,{value:r,size:i=hR,level:a=gR,bgColor:o=_R,fgColor:s=vR,includeMargin:c=yR,minVersion:u=bR,boostLevel:d,title:f,marginSize:p,imageSettings:m}=n,h=dR(n,[`value`,`size`,`level`,`bgColor`,`fgColor`,`includeMargin`,`minVersion`,`boostLevel`,`title`,`marginSize`,`imageSettings`]),{margin:g,cells:_,numCells:v,calculatedImageSettings:y}=OR({value:r,level:a,minVersion:u,boostLevel:d,includeMargin:c,marginSize:p,imageSettings:m,size:i}),b=_,x=null;m!=null&&y!=null&&(y.excavation!=null&&(b=TR(_,y.excavation)),x=l.createElement(`image`,{href:m.src,height:y.h,width:y.w,x:y.x+g,y:y.y+g,preserveAspectRatio:`none`,opacity:y.opacity,crossOrigin:y.crossOrigin}));let S=wR(b,g);return l.createElement(`svg`,uR({height:i,width:i,viewBox:`0 0 ${v} ${v}`,ref:t,role:`img`},h),!!f&&l.createElement(`title`,null,f),l.createElement(`path`,{fill:o,d:`M0,0 h${v}v${v}H0z`,shapeRendering:`crispEdges`}),l.createElement(`path`,{fill:s,d:S,shapeRendering:`crispEdges`}),x)});jR.displayName=`QRCodeSVG`;var MR=192;function NR({value:e,size:t=MR,className:n,alt:r}){let i=q(),a=e.trim();return a.length===0?null:v(`div`,{className:$(`inline-flex rounded-md bg-white p-2`,n),children:v(jR,{value:a,size:t,marginSize:1,title:r??i(`uiLibrary.qrCode.alt`,`QR code`)})})}var PR=`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`;function FR({value:e,onChange:t,disabled:n}){let r=q(),i=[];for(let e of Vi)i.includes(e.region)||i.push(e.region);return c(`select`,{className:PR,value:e,disabled:n,onChange:e=>t(e.target.value),children:[!Da(e)&&v(`option`,{value:``,children:r(`uiLibrary.timezoneSelector.select`,`— Select timezone —`)}),i.map(e=>v(`optgroup`,{label:e,children:Vi.filter(t=>t.region===e).map(e=>v(`option`,{value:e.id,children:e.label},e.id))},e))]})}E();var IR=`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`,LR=`block text-[11px] font-medium text-foreground mb-1 break-words`,RR=`text-[10px] text-foreground-subtle mt-0.5 break-words`;function zR({label:e,description:t,required:n,span:r,htmlFor:i,children:a,translationFn:o}){let s=r===2?`col-span-1 @[480px]:col-span-2`:r===3?`col-span-1 @[480px]:col-span-2 @[880px]:col-span-3`:r===4?`col-span-1 @[480px]:col-span-2 @[1140px]:col-span-4`:`col-span-1`,l=Az(e,o),u=Az(t,o),d=l!==void 0&&l!==``;return c(`div`,{className:`${s} min-w-0`,children:[d&&c(`label`,{className:LR,...i===void 0?{}:{htmlFor:i},children:[l,n&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),a,u&&v(`p`,{className:RR,children:u})]})}function BR({field:e,value:t,onChange:n,disabled:r,translationFn:i,multiline:a,children:o}){let s=ra(e),[c,l]=C(()=>s&&tu(t)),u=s&&ha(t);return u&&!c&&l(!0),!c&&!u?v(P,{children:o}):v(zR,{label:`label`in e?e.label:void 0,description:`description`in e?e.description:void 0,required:`required`in e?e.required:void 0,span:`span`in e?e.span:void 0,translationFn:i,children:v(au,{field:e,value:t,onChange:n,disabled:r,multiline:a})})}function VR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`input`,{type:e.inputType??`text`,className:IR,value:t==null?``:String(t),placeholder:e.placeholder,maxLength:e.maxLength,pattern:e.pattern,disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function HR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let[a,o]=C(t==null?``:String(t)),s=f(!1);b(()=>{s.current||o(t==null?``:String(t))},[t]);let l=e=>{if(o(e),e===``||e===`-`){n(void 0);return}let t=Number(e);Number.isNaN(t)||n(t)};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex items-center gap-1`,children:[v(`input`,{type:`number`,className:IR,value:a,placeholder:e.placeholder,min:e.min,max:e.max,step:e.step,disabled:r||e.disabled,onFocus:()=>{s.current=!0},onBlur:()=>{s.current=!1},onChange:e=>l(e.target.value)}),e.unit&&v(`span`,{className:`text-xs text-foreground-subtle whitespace-nowrap`,children:e.unit})]})})}function UR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=!!t,o=r||e.disabled;return e.style===`checkbox`?v(zR,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[v(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,checked:a,disabled:o,onChange:e=>n(e.target.checked)}),v(`span`,{className:`text-xs font-medium text-foreground`,children:Az(e.label,i)}),e.required&&v(`span`,{className:`text-danger`,children:`*`})]})}):v(zR,{label:void 0,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex items-center justify-between`,children:[c(`span`,{className:`block text-[11px] font-medium text-foreground mb-1 break-words mb-0`,children:[Az(e.label,i),e.required&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),v(`button`,{type:`button`,role:`switch`,"aria-checked":a,disabled:o,onClick:()=>!o&&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`,o?`opacity-50 cursor-not-allowed`:`cursor-pointer`].join(` `),children:v(`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 WR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=e.options.some(e=>e.value===``),s=[...!e.required&&!o?[{value:``,label:a(`uiLibrary.configFormField.select`,`— Select —`)}]:[],...e.options.map(e=>({value:e.value,label:e.label}))],c=`config-select-${e.key}`;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,htmlFor:c,translationFn:i,children:v(Yl,{id:c,options:s,value:t==null?``:String(t),disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function GR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(FR,{value:typeof t==`string`?t:``,onChange:n,disabled:r||e.disabled})})}function KR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`input`,{type:`datetime-local`,className:IR,value:typeof t==`string`?t:``,placeholder:e.placeholder,disabled:r||e.disabled,onChange:e=>n(e.target.value)})})}function qR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=Array.isArray(t)?t:[],o=t=>{if(a.includes(t))n(a.filter(e=>e!==t));else{if(e.maxItems!==void 0&&a.length>=e.maxItems)return;n([...a,t])}};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`div`,{className:`flex flex-wrap gap-2`,children:e.options.map(t=>{let n=a.includes(t.value);return c(`label`,{className:[`flex items-center gap-1.5 rounded-md border px-2 py-1 text-xs cursor-pointer select-none transition-colors`,n?`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:[v(`input`,{type:`checkbox`,className:`sr-only`,checked:n,disabled:r||e.disabled,onChange:()=>o(t.value)}),t.iconId!==void 0&&v(Wk,{iconId:t.iconId,size:13}),t.label]},t.value)})})})}function JR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let[a,o]=C(!1),s=t==null?``:String(t);return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(Jl,{"aria-label":e.label,value:s,onValueChange:e=>n(e),shown:a,onToggleShown:()=>o(e=>!e),hideToggle:e.showToggle===!1,placeholder:e.placeholder,disabled:r||e.disabled,onFocus:e=>{s.length>0&&/^[•●*]{4,}$/u.test(s)&&e.currentTarget.select()}})})}function YR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`textarea`,{className:`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 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:e=>n(e.target.value)})})}function XR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=t==null,s=e.nullable===!0,l=o?e.default??e.min:Number(t),u=e.showValue!==!1,d=e.nullLabel??a(`uiLibrary.configFormField.auto`,`Auto`),f=r||e.disabled,p=e.displayScale??1,m=e.min/p,h=e.max/p,g=l/p,_=(e.step??1)/p;if(s&&o)return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`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:a(`uiLibrary.configFormField.clickToSet`,`{{label}} — click to set manually`,{label:d})})});let y=e.showStepper===!0&&u,b=t=>{let r=l+t*(e.step??1),i=Math.min(e.max,Math.max(e.min,r));i!==l&&n(i)},x=`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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[c(`div`,{className:`flex min-w-0 flex-1 basis-[160px] items-center gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums shrink-0`,children:m}),v(`input`,{type:`range`,className:`min-w-0 flex-1 h-1 accent-primary cursor-pointer disabled:opacity-50`,min:m,max:h,step:_,value:g,disabled:f,onChange:e=>n(Number(e.target.value)*p)}),v(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums shrink-0`,children:h})]}),(u||s||e.unit)&&c(`div`,{className:`flex shrink-0 items-center gap-2`,children:[y&&v(`button`,{type:`button`,className:x,disabled:f||l<=e.min,onClick:()=>b(-1),title:a(`uiLibrary.configFormField.decreaseBy`,`Decrease by {{step}}`,{step:e.step??1}),"aria-label":a(`uiLibrary.configFormField.decrement`,`Decrement`),children:v(zn,{className:`h-3 w-3`})}),u&&v(`input`,{type:`number`,className:`w-16 rounded border border-border bg-surface px-1.5 py-0.5 text-xs text-center text-foreground tabular-nums focus:outline-none focus:ring-1 focus:ring-primary`,min:m,max:h,step:_,value:g,disabled:f,onChange:t=>{if(t.target.value===``){n(s?null:e.min);return}let r=Number(t.target.value)*p,i=e.step??1,a=r-e.min,o=e.min+Math.round(a/i)*i;n(Math.min(e.max,Math.max(e.min,o)))}}),y&&v(`button`,{type:`button`,className:x,disabled:f||l>=e.max,onClick:()=>b(1),title:a(`uiLibrary.configFormField.increaseBy`,`Increase by {{step}}`,{step:e.step??1}),"aria-label":a(`uiLibrary.configFormField.increment`,`Increment`),children:v(Se,{className:`h-3 w-3`})}),e.unit&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.unit}),s&&v(`button`,{className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors`,title:a(`uiLibrary.configFormField.resetTo`,`Reset to {{label}}`,{label:d}),disabled:f,onClick:()=>n(null),children:d})]})]})})}function ZR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),o=Array.isArray(t)?t.filter(e=>typeof e==`string`):[],s=e.creatable!==!1,c=(e.suggestions??[]).map(e=>({value:e,label:e})),l=r===!0||e.disabled===!0;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(iA,{mode:`multi`,options:c,value:o,onChange:e=>n(e),disabled:l,creatable:s,...e.createLabel===void 0?{}:{createLabel:e.createLabel},...e.maxTags===void 0?{}:{maxItems:e.maxTags},placeholder:e.placeholder??a(`uiLibrary.configFormField.searchOrAdd`,`Search or add…`),testId:`config-tags-${e.key}`})})}function QR({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=q(),{nodes:o}=Lo(),s=typeof t==`string`?t:``,l=e.showOffline?o:o.filter(e=>e.isOnline);return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:c(`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:s,onChange:e=>n(e.target.value),disabled:r,children:[v(`option`,{value:``,children:a(`uiLibrary.configFormField.selectNode`,`Select node…`)}),l.map(e=>v(`option`,{value:e.id,disabled:!e.isOnline,children:e.isOnline?e.shortName:a(`uiLibrary.configFormField.nodeOffline`,`{{name}} (offline)`,{name:e.shortName})},e.id))]})})}function $R({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let{nodes:a}=Lo(),o=new Set(Array.isArray(t)?t.map(String):[]),s=e.showOffline?a:a.filter(e=>e.isOnline),c=e=>{let t=new Set(o);t.has(e)?t.delete(e):t.add(e),n([...t])};return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>{let t=o.has(e.id);return v(`button`,{type:`button`,onClick:()=>c(e.id),disabled:r||!e.isOnline,className:`px-2.5 py-1 text-xs font-medium rounded-md border transition-colors ${t?`border-primary bg-primary/10 text-primary`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover`} ${e.isOnline?``:`opacity-50 cursor-not-allowed`}`,children:e.shortName},e.id)})})})}function ez({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=t==null?`#000000`:String(t);return c(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(`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:e=>n(e.target.value)}),v(`input`,{type:`text`,className:`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 flex-1 font-mono`,value:a,placeholder:`#000000`,disabled:r||e.disabled,onChange:e=>n(e.target.value)})]}),e.presets&&e.presets.length>0&&v(`div`,{className:`flex gap-1.5 mt-1.5`,children:e.presets.map(t=>v(`button`,{type:`button`,className:`h-5 w-5 rounded-md border border-border hover:scale-110 transition-transform disabled:opacity-50`,style:{backgroundColor:t},disabled:r||e.disabled,title:t,onClick:()=>n(t)},t))})]})}function tz({field:e,value:t,onChange:n,disabled:r,translationFn:i}){let a=typeof e.default==`string`?e.default:``;return v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:v(Ml,{label:Az(e.label,i)??e.label,value:t,defaultKey:a,disabled:r||e.disabled,onChange:n})})}function nz({field:e,value:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o,externalProbe:s}){let l=q(),[u,d]=C(`idle`),[f,p]=C(null),m=s?.status??u,h=s?.result??f,g=!!a||!!o,y=_(async()=>{if(g){d(`probing`),p(null);try{let n=a?await a(e.key,t):await o(`test-probe`,e.key,t),r=n&&typeof n==`object`?n:{status:`error`,error:l(`uiLibrary.configFormField.probeNoResult`,`Probe handler returned no result`)};p(r),d(r.status===`ok`?`ok`:`error`)}catch(e){p({status:`error`,error:e instanceof Error?e.message:String(e)}),d(`error`)}}},[a,o,e.key,t,g]),b=m===`probing`?`border-primary/40 bg-primary/10 text-primary`:m===`ok`?`border-success/40 bg-success/10 text-success hover:bg-success/15`:m===`error`?`border-danger/40 bg-danger/10 text-danger hover:bg-danger/15`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,x=m===`probing`?v(Gn,{className:`h-3 w-3 animate-spin`}):v(m===`ok`?Dn:m===`error`?Ai:An,{className:`h-3 w-3`});return c(zR,{label:e.label,description:e.description,required:e.required,span:e.span,translationFn:i,children:[c(`div`,{className:`@container flex items-center gap-2`,style:{containerType:`inline-size`},children:[c(`button`,{type:`button`,onClick:y,title:l(`uiLibrary.configFormField.test`,`Test`),disabled:e.disabled||m===`probing`||!g||!t,className:`flex-shrink-0 inline-flex items-center gap-1.5 rounded-md border px-2 py-2 text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed @[280px]:px-3 ${b}`,children:[x,v(`span`,{className:`hidden @[280px]:inline`,children:l(`uiLibrary.configFormField.test`,`Test`)})]}),v(`input`,{type:e.inputType??`url`,className:`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 flex-1 min-w-0`,value:t==null?``:String(t),placeholder:e.placeholder,disabled:r||e.disabled,onChange:e=>{n(e.target.value),u!==`idle`&&(d(`idle`),p(null))}})]}),m===`ok`&&h?.labels&&h.labels.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mt-1.5`,children:h.labels.map((e,t)=>v(`span`,{className:`text-xs bg-success/10 text-success rounded px-2 py-0.5 font-mono`,children:e},t))}),m===`error`&&h?.error&&v(`p`,{className:`text-xs text-danger mt-1 truncate`,title:h.error,children:h.error})]})}function rz({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:s}){let[l,u]=C(e.defaultCollapsed??!1),d=e.style===`accordion`;return v(`div`,{className:`${e.span===2?`col-span-2`:e.span===3?`col-span-3`:e.span===4?`col-span-4`:`col-span-1`} min-w-0`,children:c(`div`,{className:`@container rounded-lg border border-border bg-surface/50 overflow-hidden`,style:{containerType:`inline-size`},children:[c(`div`,{className:[`px-3 py-2 flex items-center justify-between min-w-0`,d?`cursor-pointer hover:bg-surface`:``].join(` `),onClick:d?()=>u(e=>!e):void 0,children:[v(`span`,{className:`text-xs font-semibold text-foreground min-w-0 break-words`,children:Az(e.label,a)}),d&&v(`span`,{className:`text-foreground-subtle text-xs shrink-0 ml-2`,children:l?`▸`:`▾`})]}),!l&&v(`div`,{className:`px-3 pb-3 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:s},e.key))})]})})}function iz({field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o}){let[s,l]=C(e.tabs[0]?.id??``),u=e.span===2?`col-span-2`:e.span===3?`col-span-3`:e.span===4?`col-span-4`:`col-span-1`;return e.tabs.length===0?null:c(`div`,{className:`${u} min-w-0`,children:[e.label&&v(`div`,{className:LR,children:Az(e.label,i)}),c(`div`,{className:`@container rounded-lg border border-border-subtle bg-surface-hover/40 overflow-hidden`,style:{containerType:`inline-size`},children:[v(`div`,{className:`flex flex-wrap gap-1 p-1.5 border-b border-border-subtle bg-surface/40`,role:`tablist`,children:e.tabs.map(e=>{let t=e.id===s;return c(`button`,{type:`button`,role:`tab`,"aria-selected":t,onClick:()=>l(e.id),className:`inline-flex items-center gap-1.5 whitespace-nowrap rounded-md px-2.5 py-1 text-[11px] transition-colors ${t?`bg-primary text-primary-foreground font-medium shadow-sm`:`bg-transparent text-foreground-subtle hover:bg-surface hover:text-foreground`}`,children:[v(`span`,{children:Az(e.label,i)}),e.badge&&v(`span`,{className:`text-[9px] px-1 py-0.5 rounded-full font-medium ${t?`bg-primary-foreground/20 text-primary-foreground`:`bg-primary/10 text-primary`}`,children:e.badge})]},e.id)})}),e.tabs.map(e=>e.id===s?v(`div`,{role:`tabpanel`,className:`px-3 pb-3 pt-2 grid grid-cols-1 @[480px]:grid-cols-2 gap-x-4 gap-y-3`,children:e.fields.map((s,c)=>{let l=`key`in s&&typeof s.key==`string`?s.key:`__${e.id}__${c}`;return v(Oz,{field:s,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o},l)})},e.id):null)]})]})}function az({span:e}){return v(`div`,{className:e===2?`col-span-2`:e===3?`col-span-3`:e===4?`col-span-4`:`col-span-full`,children:v(`hr`,{className:`border-border`})})}var oz={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 sz({field:e}){let t=oz[e.variant??`info`]??oz.info,n=e.format===`html`;return v(`div`,{className:`col-span-full`,children:c(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${t.border} ${t.bg}`,children:[e.label&&v(`p`,{className:e.content.length>0?`text-xs font-semibold mb-0.5 ${t.text}`:`text-xs text-foreground-subtle leading-relaxed whitespace-pre-line break-words`,children:e.label}),n?v(`div`,{className:`text-xs text-foreground-subtle leading-relaxed info-html-content`,dangerouslySetInnerHTML:{__html:Nl(e.content)}}):e.content.length>0&&v(`p`,{className:`text-xs text-foreground-subtle leading-relaxed whitespace-pre-line break-words`,children:e.content})]})})}function cz({field:e}){let t=e.value;if(!t||t.length===0)return null;let n=e.size??192,r=e.alt??e.label;return v(`div`,{className:`col-span-full`,children:c(`div`,{className:`rounded-md border border-foreground-subtle/20 px-3 py-3 bg-background-subtle/40 flex flex-col items-start gap-2`,children:[e.label&&v(`p`,{className:`text-xs font-semibold text-foreground`,children:e.label}),e.caption&&v(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:e.caption}),v(NR,{value:t,size:n,alt:r})]})})}var lz={ok:`bg-success`,warn:`bg-amber-500`,danger:`bg-danger`,idle:`bg-foreground-subtle/40`,unknown:`bg-foreground-subtle/40`};function uz(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function dz(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString()}function fz({kind:e,value:t}){return t==null||t===``?v(`span`,{className:`text-foreground-subtle/60`,children:`—`}):e===`monospace`?v(`span`,{className:`font-mono text-[11px]`,children:String(t)}):e===`status`?c(`span`,{className:`inline-flex items-center gap-1.5`,children:[v(`span`,{className:`inline-block h-1.5 w-1.5 rounded-full ${lz[String(t).toLowerCase()]??lz.unknown}`}),v(`span`,{children:String(t)})]}):e===`duration`&&typeof t==`number`?v(`span`,{className:`font-mono text-[11px]`,children:uz(t)}):e===`timestamp`&&typeof t==`number`?v(`span`,{className:`font-mono text-[11px]`,children:dz(t)}):v(`span`,{children:String(t)})}function pz({field:e}){let t=q(),n=e.value??[],r=e.description;return c(`div`,{className:`col-span-full`,children:[e.label&&v(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1`,children:e.label}),r&&v(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:r}),n.length===0?v(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle`,children:e.emptyMessage??t(`uiLibrary.configFormField.noEntries`,`No entries`)}):v(`div`,{className:`rounded-md border border-border overflow-x-auto`,children:c(`table`,{className:`w-full min-w-[28rem] text-xs`,children:[v(`thead`,{className:`bg-surface-subtle border-b border-border`,children:v(`tr`,{children:e.columns.map(e=>v(`th`,{className:`px-3 py-1.5 text-left font-medium text-foreground-subtle`,style:e.width?{width:e.width}:void 0,children:e.label},e.key))})}),v(`tbody`,{className:`divide-y divide-border`,children:n.map((t,n)=>v(`tr`,{className:`hover:bg-surface-hover/40`,children:e.columns.map(e=>v(`td`,{className:`px-3 py-1.5 align-top text-foreground`,children:v(fz,{kind:e.kind,value:t[e.key]})},e.key))},n))})]})})]})}function mz({field:e,value:t,onChange:n,disabled:r,translationFn:i,onTestField:a,onAction:o}){let s=q(),l=Array.isArray(t)?t:[],u=e.minRows??0,d=e.maxRows??1/0,f=(e,t,r)=>{let i=l.slice();i[e]={...i[e]??{},[t]:r},n(i)},p=e=>{l.length<=u||n(l.filter((t,n)=>n!==e))},m=()=>{if(l.length>=d)return;let t=e.defaultItem??{};n([...l,{...t}])},h=(t,n)=>e.rowTitleTemplate?e.rowTitleTemplate.replace(/\{(\w+)\}/g,(e,n)=>{let r=t[n];return r==null||r===``?`—`:String(r)}):s(`uiLibrary.configFormField.row`,`Row {{n}}`,{n:n+1}),g=l.length>u,_=l.length<d,y=e.itemIdKey??`id`,b=(e,t)=>{let n=e[y];return typeof n==`string`&&n.length>0?n:typeof n==`number`&&Number.isFinite(n)?String(n):`row-${String(t)}`};return c(`div`,{className:`col-span-full space-y-2`,children:[c(`div`,{className:`space-y-0.5`,children:[e.label&&v(`p`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:Az(e.label,i)}),e.description&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:Az(e.description,i)})]}),l.length===0?v(`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??s(`uiLibrary.configFormField.noEntries`,`No entries`)}):v(`div`,{className:`space-y-2`,children:l.map((t,n)=>c(`div`,{className:`rounded-md border border-border bg-background`,children:[c(`div`,{className:`flex items-center justify-between border-b border-border px-3 py-1.5`,children:[v(`span`,{className:`text-xs font-medium text-foreground`,children:h(t,n)}),c(`button`,{type:`button`,onClick:()=>p(n),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?s(`uiLibrary.configFormField.removeRow`,`Remove this row`):s(`uiLibrary.configFormField.minRows`,{one:`At least {{count}} row required`,other:`At least {{count}} rows required`},{count:u}),children:[v(zn,{className:`h-3 w-3`}),s(`uiLibrary.configFormField.remove`,`Remove`)]})]}),v(`div`,{className:`grid grid-cols-1 @[480px]:grid-cols-2 gap-x-3 gap-y-2 p-3`,children:e.itemFields.map(s=>v(Oz,{field:s,values:t,onChange:(e,t)=>f(n,e,t),disabled:r,translationFn:i,onTestField:a,allFields:e.itemFields,onAction:o},s.key))})]},b(t,n)))}),c(`div`,{children:[c(`button`,{type:`button`,onClick:m,disabled:r||!_,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:[v(Se,{className:`h-3 w-3`}),e.addLabel??s(`uiLibrary.configFormField.add`,`Add`)]}),!_&&Number.isFinite(d)&&v(`span`,{className:`ml-2 text-[10px] text-foreground-subtle`,children:s(`uiLibrary.configFormField.limit`,`(limit: {{max}})`,{max:d})})]})]})}function hz({field:e,disabled:t,onAction:n}){let r=q(),[i,a]=C(!1),o=li(),s=async()=>{if(!(e.confirmMessage&&!await o({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`}))&&n){a(!0);try{await n(e.action,e.key)}finally{a(!1)}}},c={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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:v(`button`,{onClick:s,disabled:t||i,className:`inline-flex items-center gap-1.5 rounded-md px-3 py-1.5 text-xs font-medium transition-colors disabled:opacity-50 ${c[e.variant??`default`]??c.default}`,children:i?r(`uiLibrary.configFormField.processing`,`Processing...`):e.buttonLabel})})}function gz(e,t){let n={...e.paramsStatic};if(e.paramsFromForm)for(let[r,i]of Object.entries(e.paramsFromForm)){let e=t[i];e!=null&&e!==``&&!Bi(e)&&(n[r]=e)}return n}function _z({field:e,value:t,values:n,onChange:r,disabled:i,onAction:a}){let o=q(),[s,l]=C(!1),[u,d]=C(null),[p,m]=C(null),h=gz(e,n),g=Object.keys(e.paramsFromForm??{}).some(e=>h[e]===void 0),_=e.mapOption.value,y=e.mapOption.label,x=e.mapOption.description,S=(e.refreshOn??Object.values(e.paramsFromForm??{})).map(e=>`${e}=${JSON.stringify(n[e])}`).join(`|`),w=f(a);w.current=a;let T=f(r);T.current=r;let E=f(h);E.current=h;let D=f(t);return D.current=t,b(()=>{let t=w.current;if(!t||g){m(null),d(null);return}let n=!1;l(!0),d(null);let r=E.current;return t(e.action,e.key,r).then(t=>{if(n)return;let r=t,i=[];if(Array.isArray(r))i=r;else if(r&&typeof r==`object`)for(let e of Object.keys(r)){let t=r[e];if(Array.isArray(t)){i=t;break}}m(i);let a=D.current;if(e.hideWhenFewerThan!==void 0&&i.length===1&&(typeof a!=`string`||a.length===0)){let e=i[0]?.[_];typeof e==`string`&&e.length>0&&T.current(e)}}).catch(e=>{n||(d(e instanceof Error?e.message:String(e)),m([]))}).finally(()=>{n||l(!1)}),()=>{n=!0}},[S,g,a!==void 0,e.action,e.key,e.hideWhenFewerThan,_]),!a&&e.hideWhenFewerThan!==void 0||e.hideWhenFewerThan!==void 0&&p!==null&&p.length<e.hideWhenFewerThan?null:v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:g?v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e.emptyParamsMessage??o(`uiLibrary.configFormField.fillPrerequisites`,`Fill the prerequisite fields above first.`)}):s?c(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),` `,o(`uiLibrary.configFormField.loadingOptions`,`Loading options…`)]}):u?v(`div`,{className:`text-[11px] text-danger`,children:u}):p&&p.length===0?v(`div`,{className:`text-[11px] text-foreground-subtle italic`,children:e.emptyResultsMessage??o(`uiLibrary.configFormField.noOptions`,`No options returned.`)}):(()=>{let e=(p??[]).some(e=>{let t=e[_];return t===``||t===void 0});return c(`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:i,onChange:e=>r(e.target.value),children:[!e&&v(`option`,{value:``,children:o(`uiLibrary.configFormField.select`,`— Select —`)}),(p??[]).map((e,t)=>{let n=e[_],r=e[y],i=x?e[x]:void 0,a=typeof n==`string`&&n!==``?n:`row-${t}`;return c(`option`,{value:typeof n==`string`?n:String(n??``),children:[typeof r==`string`?r:String(r??a),i===void 0?``:` (${String(i)})`]},a)})]})})()})}function vz({field:e,values:t,disabled:n,onAction:r,onChange:i,onChangeMany:a}){let o=q(),[s,l]=C(!1),[u,d]=C(null),f=li(),p=Pn(),m=CA(),h=async()=>{let n=e.prompt?await p({title:e.prompt.title??e.label,...e.prompt.message===void 0?{}:{message:e.prompt.message},...e.prompt.placeholder===void 0?{}:{placeholder:e.prompt.placeholder},confirmLabel:e.buttonLabel}):null;if(e.prompt&&n===null||e.confirmMessage&&!await f({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`})||!r)return;let o=gz(e,t);e.prompt&&n!==null&&(o[e.prompt.param]=n),e.includeDeviceId===!0&&m!=null&&(o.deviceId=m),l(!0),d(null);try{let t=await r(e.action,e.key,o),n=typeof t==`object`&&t?t:null;if(n!==null&&e.assignResult&&(i||a)){let t={};for(let[r,i]of Object.entries(e.assignResult)){let e=n[i];typeof e==`string`&&(t[r]=e)}if(Object.keys(t).length>0){if(a)a(t);else if(i)for(let[e,n]of Object.entries(t))i(e,n)}}d({kind:`ok`,text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(e,t)=>{let r=n?.[t];return r===void 0?``:String(r)}):`Done.`})}catch(e){d({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{l(!1)}},g={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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:c(`div`,{className:`flex flex-col gap-1.5`,children:[v(`button`,{onClick:h,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 ${g[e.variant??`default`]??g.default}`,children:s?o(`uiLibrary.configFormField.working`,`Working…`):e.buttonLabel}),u&&v(`div`,{className:`text-[11px] ${u.kind===`ok`?`text-emerald-700 dark:text-emerald-300`:`text-danger`}`,children:u.text})]})})}function yz({field:e,values:t,disabled:n,onAction:r}){let i=q(),[a,o]=C(!1),[s,l]=C(null),u=li(),d=async()=>{if(e.confirmMessage&&!await u({title:e.label,message:e.confirmMessage,confirmLabel:e.buttonLabel,variant:e.variant===`danger`?`danger`:`default`})||!r)return;let n=gz(e,t);o(!0),l(null);try{let t=await r(`device-custom-action`,e.action,n),i=typeof t==`object`&&t?t:null;l({kind:`ok`,text:e.successMessage?e.successMessage.replace(/\{(\w+)\}/g,(e,t)=>{let n=i?.[t];return n===void 0?``:String(n)}):`Done.`})}catch(e){l({kind:`error`,text:e instanceof Error?e.message:String(e)})}finally{o(!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 v(zR,{label:e.label,description:e.description,required:e.required,span:e.span,children:c(`div`,{className:`flex flex-col gap-1.5`,children:[v(`button`,{onClick:d,disabled:n||a,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:a?i(`uiLibrary.configFormField.working`,`Working…`):e.buttonLabel}),s&&v(`div`,{className:`text-[11px] ${s.kind===`ok`?`text-emerald-700 dark:text-emerald-300`:`text-danger`}`,children:s.text})]})})}function bz({field:e}){let t=CA();return v(zR,{label:void 0,description:void 0,span:e.span,children:v(eR,{widgetId:e.widgetId,host:`device-tab`,config:e.widgetConfig,deviceId:t??void 0,instanceId:e.key})})}function xz(e,t){if(e==null)return`—`;if(typeof e==`boolean`)return e?`yes`:`no`;if(typeof e==`number`){let n=Number.isInteger(e)?String(e):e.toFixed(2);return t?`${n} ${t}`:n}return typeof e==`string`?e:JSON.stringify(e)}function Sz({field:e,values:t,onAction:n,translationFn:r}){let i=`key`in e?e.key:void 0;if(!i)return null;let a=t[i],o=a===void 0?`default`in e?e.default:void 0:a,s=xz(o,`unit`in e?e.unit:void 0),l=`label`in e?e.label:void 0,u=`description`in e?e.description:void 0,d=`span`in e?e.span:void 0,f=`actions`in e?e.actions??[]:[];return v(zR,{label:l,description:u,span:d,translationFn:r,children:c(`div`,{className:`flex items-stretch gap-1`,children:[v(`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:s}),f.length>0&&v(`div`,{className:`flex items-center gap-1`,children:f.map(e=>v(wz,{action:e,fieldKey:i,value:o,onAction:n},e.action))})]})})}function Cz({name:e}){let t=`h-3.5 w-3.5`;switch(e){case`copy`:return v(ei,{className:t});case`refresh-cw`:return v(_e,{className:t});case`external-link`:return v(Je,{className:t});case`trash-2`:return v(Pe,{className:t});case`download`:return v(nn,{className:t});case`upload`:return v(yt,{className:t});default:return v(yn,{className:t})}}function wz({action:e,fieldKey:t,value:n,onAction:r}){let i=li(),[a,o]=C(!1),s=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 v(`button`,{type:`button`,onClick:async()=>{if(!(e.confirmMessage&&!await i({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){o(!0);try{await r(e.action,t)}finally{o(!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 ${s}`,children:v(Cz,{name:e.icon})})}function Tz(e){return`multiple`in e&&e.multiple!=null}function Ez({field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,externalProbe:o,allFields:s,onAction:l}){let u=q(),d=e.multiple,f=d.min,p=d.max,m=t[e.key],h=[...Array.isArray(m)?m:m==null?[]:[m]],g=d.itemDefault===void 0?`default`in e&&e.default!==void 0?e.default:``:d.itemDefault;for(;h.length<f;)h.push(g);let _=t=>n(e.key,[...t]),y=(e,t)=>{let n=[...h];n[e]=t,_(n)},b=()=>{h.length>=p||_([...h,g])},x=e=>{h.length<=f||_(h.filter((t,n)=>n!==e))},S=()=>{let{multiple:t,...n}=e,r={label:void 0,description:void 0,required:!1};return{...n,...r}};return v(zR,{label:e.label,description:e.description,required:f>0?e.required:!1,span:e.span,translationFn:i,children:c(`div`,{className:`space-y-2`,children:[h.map((n,o)=>{let p=d.itemLabel?.replace("${n}",String(o+1));return c(`div`,{className:`space-y-1`,children:[p&&v(`div`,{className:LR,children:p}),c(`div`,{className:`flex items-center gap-2`,children:[v(`div`,{className:`flex-1 min-w-0`,children:v(Oz,{field:S(),values:{...t,[e.key]:n},onChange:(e,t)=>y(o,t),disabled:r,translationFn:i,onTestField:a,onAction:l,allFields:s})}),h.length>f&&v(`button`,{type:`button`,onClick:()=>x(o),disabled:r,title:u(`uiLibrary.configFormField.remove`,`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:v(Pe,{className:`h-3.5 w-3.5`})})]})]},o)}),c(`div`,{className:`flex items-center justify-between pt-1`,children:[h.length<p?c(`button`,{type:`button`,onClick:b,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:[v(Se,{className:`h-3 w-3`}),d.addLabel??u(`uiLibrary.configFormField.add`,`Add`)]}):v(`span`,{}),c(`span`,{className:`text-[10px] text-foreground-subtle tabular-nums`,children:[h.length,`/`,p]})]})]})})}function Dz(e,t,n){if(!(`showWhen`in e)||!e.showWhen)return!0;let r=e.showWhen,i=t[r.field],a=n?.find(e=>`key`in e&&e.key===r.field),o=a&&`default`in a?a.default:void 0,s=i===void 0?o:i;return r.equals===void 0?r.notEquals===void 0?r.in===void 0?r.notIn===void 0?r.includes===void 0?r.notIncludes===void 0?!0:!Array.isArray(s)||!s.includes(r.notIncludes):Array.isArray(s)&&s.includes(r.includes):!r.notIn.includes(s):r.in.includes(s):s!==r.notEquals:s===r.equals}function Oz({field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,externalProbe:s,allFields:c,onAction:l}){if(Tz(e))return v(Ez,{field:e,values:t,onChange:n,disabled:i,translationFn:a,onTestField:o,externalProbe:s,allFields:c,onAction:l});if(`readonlyField`in e&&e.readonlyField===!0)return v(Sz,{field:e,values:t,onAction:l,translationFn:a});if(!Dz(e,t,c))return null;let u=t[e.key],d=u===void 0?`default`in e?e.default:void 0:u,f=t=>n(e.key,t),p=gA(e.type);switch(e.type){case`text`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,children:v(VR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`number`:return v(HR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`boolean`:return v(UR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`select`:return v(WR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`multiselect`:return v(qR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`timezone`:return v(GR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`datetime`:return v(KR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`password`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,children:v(JR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`textarea`:return v(BR,{field:e,value:d,onChange:f,disabled:i,translationFn:a,multiline:!0,children:v(YR,{field:e,value:d,onChange:f,disabled:i,translationFn:a})});case`slider`:return v(XR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`tags`:return v(ZR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`color`:return v(ez,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`icon`:return v(tz,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`node-select`:return v(QR,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`node-multiselect`:return v($R,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`device-select`:return v(Rk,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`device-multiselect`:return v(zk,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`notification-target-select`:return v(pA,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`notification-target-multiselect`:return v(fA,{field:e,value:d,onChange:f,disabled:i,translationFn:a});case`probe`:return v(nz,{field:e,value:d,onChange:f,disabled:i,translationFn:a,onTestField:o,onAction:l,externalProbe:s});case`group`:return v(rz,{field:e,values:t,onChange:n,onChangeMany:r,disabled:i,translationFn:a,onTestField:o,onAction:l});case`sub-tabs`:return v(iz,{field:e,values:t,onChange:n,disabled:i,translationFn:a,onTestField:o,onAction:l});case`separator`:return v(az,{});case`info`:return v(sz,{field:e});case`qr-code`:return v(cz,{field:e});case`object-array`:return v(pz,{field:e});case`editable-array`:return v(mz,{field:e,value:d,onChange:f,disabled:i,translationFn:a,onTestField:o,onAction:l});case`button`:return v(hz,{field:e,disabled:i,onAction:l});case`addon-action-select`:{let r=e.writesKey??e.key;return v(_z,{field:e,value:t[r],values:t,onChange:e=>n(r,e),disabled:i,onAction:l})}case`addon-action-button`:return v(vz,{field:e,values:t,disabled:i,onAction:l,onChange:n,onChangeMany:r});case`account-sign-in`:return v(Bie,{field:e,values:t,disabled:i,onAction:l,onChangeMany:r});case`secret-presence`:return v(Vie,{field:e,values:t});case`device-action-button`:return v(yz,{field:e,values:t,disabled:i,onAction:l});case`widget`:return v(bz,{field:e});default:return p?v(p,{field:e,value:d,onChange:f,disabled:i}):null}}E();function kz(e){return/^[a-zA-Z0-9_]+(\.[a-zA-Z0-9_]+)+$/.test(e)}function Az(e,t){if(e!==void 0)return t&&kz(e)?t(e):e}function jz(e){let t=e??2;return t===1?`grid-cols-1`:t===3?`grid-cols-1 @[480px]:grid-cols-2 @[880px]:grid-cols-3`:t===4?`grid-cols-1 @[480px]:grid-cols-2 @[1140px]:grid-cols-4`:`grid-cols-1 @[480px]:grid-cols-2`}function Mz({section:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o}){let[s,l]=C(e.defaultCollapsed??!1),u=e.style===`accordion`,d=jz(e.columns);return c(`div`,{className:`@container rounded-lg border border-border bg-surface p-3`,style:{containerType:`inline-size`},children:[c(`div`,{className:[`flex items-center justify-between mb-2`,u?`cursor-pointer`:``].join(` `),onClick:u?()=>l(e=>!e):void 0,children:[c(`div`,{children:[v(`h3`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wider`,children:Az(e.title,i)}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Az(e.description,i)})]}),u&&v(`span`,{className:`text-foreground-subtle text-xs ml-2`,children:s?`▸`:`▾`})]}),!s&&v(`div`,{className:`grid ${d} gap-x-3 gap-y-2.5`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,externalProbe:o?.[e.key]},e.key))})]})}function Nz({schema:e,values:t,onChange:n,disabled:r,translationFn:i,onTestField:a,probeResults:o,onClearProbe:s,bare:c=!1}){let l=(e,r)=>{n({...t,[e]:r}),s?.(e)};return c?v(`div`,{className:`space-y-4`,children:e.sections.map(e=>v(`div`,{className:`@container`,style:{containerType:`inline-size`},children:v(`div`,{className:`grid ${jz(e.columns)} gap-x-3 gap-y-2.5`,children:e.fields.map(e=>v(Oz,{field:e,values:t,onChange:l,disabled:r,translationFn:i,onTestField:a,externalProbe:o?.[e.key]},e.key))})},e.id))}):v(`div`,{className:`space-y-4`,children:e.sections.map(e=>v(Mz,{section:e,values:t,onChange:l,disabled:r,translationFn:i,onTestField:a,probeResults:o},e.id))})}E();var Pz=({open:e})=>v(`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:v(`polyline`,{points:`9 18 15 12 9 6`})});function Fz(e){return e.type!==`separator`&&e.type!==`info`&&e.type!==`button`&&e.type!==`group`}function Iz(e){let t={};if(!e)return t;for(let n of e.sections)for(let e of n.fields){if(!Fz(e))continue;let n=e.key;t[n]=e.value}return t}function Lz(e,t){return{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{if(!Fz(e))return e;let n=e.key;return n in t?{...e,value:t[n]}:e})}))}}function Rz(e){return Dee(e)}function zz({trpc:e,addonId:t,nodeId:n,title:r,disabled:i,onAfterChange:a,refreshToken:o,sectionIds:s,bare:l=!1,collapsible:u,defaultOpen:d,mode:m,onOverrideChange:h}){let g=q(),_=m??`persist`,[y,x]=C(null),[S,w]=C(!0),[T,E]=C(null),[D,O]=C(!1),[k,A]=C(d??!1),[j,M]=C({}),[N,F]=C(null),I=f(0);b(()=>{F(null),M({})},[e,t,n,o,_]),b(()=>{let r=!1;w(!0),E(null);let i=_===`override`&&Object.keys(j).length>0?j:void 0;return e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n,...i?{overlay:i}:{}}).then(e=>{r||(x(t=>e??t),!i&&e&&F(Iz(e)),w(!1))}).catch(e=>{r||(E(e instanceof Error?e.message:String(e)),w(!1))}),()=>{r=!0}},[e,t,n,o,_,JSON.stringify(j)]);let L=p(()=>Iz(y),[y]),R=s?.join(`\0`),z=p(()=>{if(!y)return null;let e=Rz(y);if(s===void 0)return e;let t=new Set(s);return{...e,sections:e.sections.filter(e=>t.has(e.id))}},[y,R]),B=async r=>{if(_===`override`){let e=N??L,t={};for(let n of Object.keys(r))r[n]!==e[n]&&(t[n]=r[n]);let n={...e,...t};M(t),h?.(t,n);return}let i={};for(let e of Object.keys(r))r[e]!==L[e]&&(i[e]=r[e]);if(Object.keys(i).length===0)return;let o=++I.current;x(e=>e===null?e:Lz(e,r)),O(!0),E(null);try{await e.addonSettings.updateGlobalSettings.mutate({addonId:t,nodeId:n,patch:i});let r=await e.addonSettings.getGlobalSettings.query({addonId:t,nodeId:n});r&&o===I.current&&x(r),o===I.current&&a?.()}catch(e){o===I.current&&E(e instanceof Error?e.message:String(e))}finally{o===I.current&&O(!1)}};if(S)return v(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:g(`uiLibrary.addonGlobalSettings.loading`,`Loading {{name}}…`,{name:r??t})});if(T)return c(`div`,{className:`text-xs text-red-400`,children:[r??t,`: `,T]});if(!y||!z)return v(`div`,{className:`text-xs text-foreground-subtle`,children:g(`uiLibrary.addonGlobalSettings.unavailable`,`{{name}} not available on {{node}}.`,{name:r??t,node:n})});let V=_===`override`?{...L,...j}:L,H=c(P,{children:[_===`override`?v(`div`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:g(`uiLibrary.addonGlobalSettings.override`,`Benchmark override — applies to this run only. The addon's saved settings are not changed.`)}):null,D?v(`div`,{className:`mb-2 text-[11px] text-foreground-subtle`,"aria-live":`polite`,children:g(`uiLibrary.addonGlobalSettings.saving`,`Saving…`)}):null,v(Nz,{schema:z,values:V,onChange:B,disabled:i===!0,bare:l})]});return l?v(`div`,{children:H}):u===!0?c(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[c(`button`,{type:`button`,onClick:()=>A(e=>!e),className:`w-full px-4 py-2 flex items-center gap-2 hover:bg-surface-hover text-left`,"aria-expanded":k,children:[v(Pz,{open:k}),v(`h3`,{className:`text-xs font-semibold text-foreground uppercase tracking-wide flex-1`,children:r??t}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:k?g(`uiLibrary.addonGlobalSettingsForm.hide`,`hide`):g(`uiLibrary.addonGlobalSettingsForm.edit`,`edit`)})]}),k?v(`div`,{className:`border-t border-border px-4 py-3`,children:H}):null]}):r?c(`section`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[v(`div`,{className:`border-b border-border px-4 py-2`,children:v(`h3`,{className:`text-xs font-semibold text-foreground uppercase tracking-wide`,children:r})}),v(`div`,{className:`px-4 py-3`,children:H})]}):v(`div`,{children:H})}var Bz=/^(usb|pci)(?::(\d+))?$/;function Vz(e){let t=Bz.exec(e);if(t===null||t[1]===`usb`&&t[2]===void 0)return{label:`Coral Edge TPU`,short:`Coral`};let n=t[1]===`pci`?`PCIe`:`USB`,r=t[2]===void 0?n:`${n} ${Number(t[2])+1}`;return{label:`Coral Edge TPU (${r})`,short:`Coral ${r}`}}function Hz(e){let t=e.backend.toLowerCase(),n=e.device.toLowerCase();if(e.key===`cpu`||n===`cpu`||t===`cpu`)return{label:`CPU`,short:`CPU`};if(n===`npu`)return{label:`Intel NPU`,short:`NPU`};if(n===`gpu`||n===`igpu`)return{label:`Intel iGPU`,short:`iGPU`};if(t===`edgetpu`)return Vz(n);if(t===`coreml`)return{label:`Apple Neural Engine`,short:`ANE`};let r=`${e.backend} ${e.device}`.trim().replace(/\b\w/g,e=>e.toUpperCase());return{label:r.length>0?r:e.key,short:e.backend||e.key}}function Uz(e){return Hz(e).label}function Wz(e){return Hz(e).short}function Gz({active:e,onClick:t,disabled:n,children:r,title:i}){return v(`button`,{type:`button`,onClick:t,disabled:n,title:i,className:$(`rounded-full px-3 py-1 text-[11px] font-medium border transition-colors`,e?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:text-foreground hover:border-foreground-subtle/40`,n?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:r})}function Kz({catalog:e,value:t,onChange:n,disabled:r}){let i=q(),a=Qa(e),o=oo(e,t),s=a.find(e=>e.family===o?.family)?.family??a[0]?.family??``,l=a.find(e=>e.family===s)??a[0];if(!l)return null;let u=l.tiers.find(e=>e.tier===o?.tier)?.tier??l.tiers[0]?.tier??``,d=l.tiers.find(e=>e.tier===u)??l.tiers[0];if(!d)return null;let f=[...new Set(d.options.map(e=>e.resolution))].sort((e,t)=>(t??1/0)-(e??1/0)),p=f.includes(o?.resolution)?o?.resolution:f[0],m=d.options.filter(e=>e.resolution===p),h=e=>e===void 0?i(`uiLibrary.groupedModelSelector.native`,`native`):`${e}`,g=e=>{let t=l.tiers.find(t=>t.tier===e);t&&n((t.options.find(e=>e.precision===(o?.precision??`fp32`)&&e.optimization===(o?.optimization??`standard`)&&e.resolution===o?.resolution)??t.options[0]).modelId)},_=e=>{let t=d.options.filter(t=>t.resolution===e),r=t.find(e=>e.precision===(o?.precision??`fp32`)&&e.optimization===(o?.optimization??`standard`))??t[0];r&&n(r.modelId)},y=t=>{let r=sa(e,{family:l.family,tier:d.tier,precision:t.precision,optimization:t.optimization,resolution:t.resolution});r&&n(r)},b=d.options.find(e=>e.modelId===t)??null;return c(`div`,{className:`space-y-3`,children:[a.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.family`,`Family`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:a.map(e=>v(Gz,{active:e.family===l.family,disabled:r,...e.hint===void 0?{}:{title:e.hint},onClick:()=>n(e.tiers[0]?.baseModelId??``),children:e.label},e.family))}),l.hint!==void 0&&c(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,"data-testid":`model-family-hint`,children:[l.label,`: `,l.hint]})]}),l.tiers.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.size`,`{{family}} — size`,{family:l.label})}),v(`div`,{className:`grid grid-cols-2 gap-1.5 sm:grid-cols-4`,children:l.tiers.map(e=>{let t=e.tier===d.tier,n=e.options.find(e=>e.resolution===p&&e.precision===`fp32`)??e.options.find(t=>t.modelId===e.baseModelId)??e.options[0];return c(`button`,{type:`button`,disabled:r,onClick:()=>g(e.tier),className:$(`rounded-lg border px-2 py-2 text-left transition-all`,t?`border-primary bg-primary/5 ring-1 ring-primary/30`:`border-border bg-background hover:border-foreground-subtle/40`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:[c(`div`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`text-xs font-semibold text-foreground`,children:e.label}),t&&v(dt,{className:`h-3 w-3 text-primary`})]}),n!==void 0&&n.sizeMB>0&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i(`uiLibrary.groupedModelSelector.approxSize`,`~{{size}} MB`,{size:n.sizeMB})})]},e.tier)})})]}),f.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.resolution`,`Resolution`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:f.map(e=>v(Gz,{active:e===p,disabled:r,title:e===void 0?i(`uiLibrary.groupedModelSelector.nativeTitle`,`native (best accuracy)`):i(`uiLibrary.groupedModelSelector.fasterTitle`,`{{size}}×{{size}} (faster)`,{size:e}),onClick:()=>_(e),children:h(e)},e??`native`))})]}),m.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:i(`uiLibrary.groupedModelSelector.variant`,`Variant`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:m.map(e=>v(Gz,{active:e.modelId===t,disabled:r,title:e.sizeMB>0?i(`uiLibrary.groupedModelSelector.formatsSize`,`{{formats}} · ~{{size}} MB`,{formats:e.formats.join(`, `),size:e.sizeMB}):e.formats.join(`, `),onClick:()=>y(e),children:c(`span`,{className:`inline-flex items-center gap-1`,children:[e.optimization===`test`&&v(nr,{className:`h-3 w-3`}),e.label]})},e.modelId))})]}),c(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle pt-0.5`,children:[v(Mr,{className:`h-3 w-3`}),v(`span`,{className:`font-mono`,children:t||`—`}),b&&c(`span`,{children:[`· `,b.formats.join(`, `),b.sizeMB>0?i(`uiLibrary.groupedModelSelector.sizeSuffix`,` · ~{{size}} MB`,{size:b.sizeMB}):``]})]})]})}E();var qz={camstack:`CamStack`,frigate:`plus catalog`,scrypted:`plugin catalog`,custom:`Custom`};function Jz(e){return e.provider??`camstack`}function Yz({models:e,value:t,onChange:n,disabled:r,defaultModelId:i}){let a=q(),o=p(()=>{let t=new Map;for(let n of e){let e=Jz(n),r=t.get(e);r?r.push(n):t.set(e,[n])}return t},[e]),s=p(()=>Aa.filter(e=>(o.get(e)?.length??0)>0),[o]),l=p(()=>{let n=e.find(e=>e.id===t);return n?Jz(n):void 0},[e,t])??(s.includes(`camstack`)?`camstack`:s[0]??`camstack`),[u,d]=C(l);b(()=>{d(l)},[l]);let f=t!==``&&!e.some(e=>e.id===t),m=i!==void 0&&e.some(e=>e.id===i)?i:e[0]?.id,h=f&&c(`div`,{className:`rounded border border-amber-500/40 bg-amber-500/10 px-2 py-1.5 text-[10px] text-amber-300 space-y-1.5`,children:[v(`p`,{children:v(gi,{uiKey:`uiLibrary.modelPicker.unresolved`,fallback:`Current pin (<0>{{value}}</0>) is not offered for this device. The runtime tries it as a custom model and refuses it if it cannot serve it. Pick a replacement and Save.`,components:[v(`span`,{className:`font-mono`},`v`)],values:{value:t}})}),m!==void 0&&v(`button`,{type:`button`,disabled:r,onClick:()=>n(m),className:`rounded border border-amber-500/50 px-2 py-0.5 text-[10px] font-medium hover:bg-amber-500/20 disabled:opacity-50`,children:v(gi,{uiKey:`uiLibrary.modelPicker.useDefault`,fallback:`Use default (<0>{{id}}</0>) — then Save`,components:[v(`span`,{className:`font-mono`},`d`)],values:{id:m}})})]}),g=o.get(u)??[],_=g.filter(e=>e.group!==void 0),y=g.filter(e=>e.group===void 0);return c(`div`,{className:`space-y-3`,children:[h,s.length>1&&c(`div`,{children:[v(`p`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1.5`,children:a(`uiLibrary.modelPicker.provider`,`Provider`)}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>v(`button`,{type:`button`,disabled:r,onClick:()=>d(e),className:$(`rounded-full px-3 py-1 text-[11px] font-medium border transition-colors`,e===u?`border-primary bg-primary/10 text-primary`:`border-border bg-background text-foreground-subtle hover:text-foreground hover:border-foreground-subtle/40`,r?`opacity-50 cursor-not-allowed`:`cursor-pointer`),children:qz[e]},e))})]}),_.length>0&&v(Kz,{catalog:_,value:t,onChange:n,disabled:r}),y.length>0&&((e,i)=>c(`select`,{disabled:r,className:`w-full bg-surface border border-border rounded px-2 py-1 text-xs disabled:opacity-50`,value:e.some(e=>e.id===t)?t:``,onChange:e=>n(e.target.value),children:[i!==void 0&&v(`option`,{value:``,disabled:!0,children:i}),e.map(e=>v(`option`,{value:e.id,children:e.name},e.id))]}))(y,_.length>0?`— other models —`:`— select a model —`),e.length===0&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.modelPicker.none`,`No model is published for this engine format.`)})]})}function Xz(e,t){let n=n=>e.models.find(e=>e.id===n)?.formats[t]!==void 0,r=e.defaultModelIdByFormat?.[t];if(r!==void 0&&n(r))return r;if(n(e.defaultModelId))return e.defaultModelId;let i=e.models.filter(e=>e.formats[t]!==void 0&&e.legacy!==!0);return i.length===0?e.defaultModelId:[...i].toSorted((e,n)=>(e.formats[t]?.sizeMB??1/0)-(n.formats[t]?.sizeMB??1/0))[0].id}function Zz(e,t){let n=t?.format;if(n===void 0)return;let r=t?.defaultModelId;return e.slot===`detector`&&r!==void 0&&e.models.some(e=>e.id===r)?r:Xz(e,n)}function Qz(e,t){return t===void 0?[]:e.filter(e=>e.formats[t]!==void 0)}function $z(e,t){return Qz(e,t).length>0}function eB(e){return e.base??Zz(e.catalog,e.device)}function tB(e,t,n){return ya(e)?$i(e,t,n?.supplies):null}function nB(e,t){return{...e,[Sa]:t}}function rB(e,t=Fn){if(e.kind===`label`){let n=e.uncovered.length>0?[t(`uiLibrary.rootModelSource.notProduced`,`Not produced by this model: {{classes}}.`,{classes:e.uncovered.join(`, `)})]:[];return e.stepId===`package-detection`?[...n,t(`uiLibrary.rootModelSource.packageNote`,`The root model's own package boxes become the package result at this step's threshold; this step's zone-crop view is not used, so small parcels the full-frame model misses stay missed.`)]:[...n,t(`uiLibrary.rootModelSource.labelNote`,`This step's class list decides which of the root's labels become the fine class; a switched-off class stays at its macro.`)]}return e.kind===`mask`?[t(`uiLibrary.rootModelSource.maskNote`,`Masks come from the root model: each detection carries the root's own instance mask, so this step's model does not run. A root mask follows the model's mask grid (a quarter of its input), coarser than this step's own per-crop mask.`)]:e.stepId===`face-detection`?[t(`uiLibrary.rootModelSource.faceNote`,`Face boxes come from the root model. Each is re-found by this step's face detector in a square around it before recognition, so only a face it finds is recognised; a box with no face in it is dropped.`)]:[t(`uiLibrary.rootModelSource.plateNote`,`Plate boxes come from the root model and the plate reader reads them. The crop margin around a root plate box has not been measured for this model yet.`)]}function iB(e,t,n){switch(e.inactiveReason){case`root-input-too-small`:return n(`uiLibrary.rootModelSource.inactiveTooSmall`,`the current root model ({{name}}) sees the frame too small to find faces reliably (it needs an input of 640 px or more).`,{name:t.name});case`root-does-not-declare`:case void 0:return n(`uiLibrary.rootModelSource.inactiveCannot`,`the current root model ({{name}}) cannot supply this.`,{name:t.name})}}function aB({stepId:e,settings:t,rootModel:n,disabled:r,onChange:i}){let a=q();if(n===void 0)return null;let o=tB(e,t,n);if(o===null)return null;let s=o.inactive?v(`div`,{className:`rounded bg-muted/40 px-3 py-2 text-[11px] text-foreground-subtle`,"data-testid":`root-model-inactive`,children:a(`uiLibrary.rootModelSource.inactive`,`Use the root model: inactive — {{reason}} The step runs its own model.`,{reason:iB(o,n,a)})}):null;if(o.supply===void 0)return s;let l=o.intent;return c(`div`,{className:`space-y-1`,"data-testid":`root-model-source`,children:[c(`label`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[v(`input`,{type:`checkbox`,checked:l,disabled:r,onChange:e=>i(e.target.checked)}),a(`uiLibrary.rootModelSource.use`,`Use the root model ({{name}})`,{name:n.name})]}),s,o.effective&&rB(o.supply,a).map(e=>v(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:e},e))]})}function oB(e,t){switch(e){case`override`:return t(`uiLibrary.modelBoundSlider.sourceOverride`,`Override for this model`);case`model-default`:return t(`uiLibrary.modelBoundSlider.sourceModelDefault`,`Model default`);case`global-default`:return t(`uiLibrary.modelBoundSlider.sourceGlobalDefault`,`Default — not tuned for this model`)}}function sB(e,t){return(t===void 0?e:e/t).toFixed(2).replace(/\.?0+$/,``)}function cB({field:e,modelId:t,settings:n,disabled:r,onChangeSettings:i,hideSourceRow:a=!1}){let o=q(),s=e.modelApplicability?.defaultByModel?.[t],l=oa(n,e.key,t.length>0?t:void 0,s,e.default),u=typeof e.default==`number`?e.default:e.min??0,d=typeof l.value==`number`?l.value:u,f=e.type===`slider`?e.displayScale:void 0,p=`unit`in e?e.unit:void 0,m=l.inapplicableOverride,h=n?.[e.key]!==void 0,g=r=>{i(t.length>0?no(n,e.key,r,t):{...n,[e.key]:r})};return c(`div`,{children:[c(`div`,{className:`flex items-center justify-between mb-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:e.label}),c(`span`,{className:`text-xs font-medium text-foreground tabular-nums`,children:[sB(d,f),p?` ${p}`:``]})]}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:e.description}),v(`input`,{type:`range`,min:e.min??0,max:e.max??1,step:e.step??.01,value:d,disabled:r||e.disabled,onChange:e=>g(Number(e.target.value)),className:`w-full accent-primary h-1.5`}),!a&&c(`div`,{className:`mt-1 flex items-center justify-between gap-2 text-[10px]`,children:[v(`span`,{"data-testid":`model-bound-source`,className:l.source===`override`?`text-primary font-medium`:`text-foreground-subtle`,children:oB(l.source,o)}),h&&v(`button`,{type:`button`,disabled:r,className:`text-foreground-subtle hover:text-foreground disabled:opacity-50`,onClick:()=>i(va(n,e.key)),children:o(`uiLibrary.modelBoundSlider.resetToDefault`,`Reset to model default`)})]}),m!==void 0&&typeof m.value==`number`&&v(`p`,{className:`mt-1 text-[10px] text-amber-400/90`,children:o(`uiLibrary.modelBoundSlider.staleOverride`,`The override {{value}} was set for {{modelId}} and does not apply to this model.`,{value:sB(m.value,f),modelId:m.modelId})})]})}function lB(e){return e.flatMap(e=>e.type===`group`?lB(e.fields):`key`in e&&`bindsToModel`in e&&e.bindsToModel===!0?[e.key]:[])}function uB({fields:e,modelId:t,settings:n,disabled:r,onReset:i}){let a=q(),o=lB(e),s=t.length>0?t:void 0;return o.length===0||!Za(n,o,s)?null:v(`button`,{type:`button`,disabled:r,className:`text-[10px] text-primary hover:underline disabled:opacity-50`,onClick:()=>i(xa(n,o,s)),children:a(`uiLibrary.modelBoundSlider.resetThresholds`,`Reset thresholds to model defaults`)})}function dB({expanded:e,onExpandedChange:t,header:n,children:r,dimmed:i=!1,hideChevron:a=!1,className:o}){return c(`div`,{className:$(`rounded-lg border border-border bg-surface overflow-hidden`,i&&`opacity-[0.45]`,o),children:[c(`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:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(!e))},children:[!a&&v(`span`,{className:`text-foreground-subtle shrink-0`,children:v(e?de:It,{className:`h-4 w-4`})}),n]}),e&&r&&v(`div`,{className:`border-t border-border px-3 py-3`,children:r})]})}E();function fB(e){return e?.models??[]}function pB({step:e,schema:t,allSchemas:n,depth:r=0,onChange:i,onDelete:a,readOnly:o=!1}){let s=q(),[l,u]=C(!1),d=fB(t);if(d.length>0&&!d.some(t=>t.id===e.modelId)&&!o){let n=(t?.defaultModelId?d.find(e=>e.id===t.defaultModelId):null)??d[0];n&&n.id!==e.modelId&&queueMicrotask(()=>i({...e,modelId:n.id}))}let f=c(P,{children:[c(`div`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`text-[10px] uppercase tracking-wider font-medium text-foreground-subtle/60 block leading-none`,children:e.slot}),v(`span`,{className:`text-sm font-semibold text-foreground truncate block leading-tight`,children:e.addonName}),c(`div`,{className:`flex items-center gap-1 mt-0.5 flex-wrap`,children:[e.inputClasses.map(e=>v(`span`,{className:`text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-blue-500/12 text-blue-400`,children:e},e)),e.inputClasses.length>0&&e.outputClasses.length>0&&v(`span`,{className:`text-foreground-subtle/40 text-[10px]`,children:`→`}),e.outputClasses.map(e=>v(`span`,{className:`text-[9px] uppercase font-semibold tracking-wide px-1.5 py-0.5 rounded bg-green-500/12 text-green-400`,children:e},e))]})]}),!o&&v(`button`,{onClick:t=>{t.stopPropagation(),i({...e,enabled:!e.enabled})},className:$(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full transition-colors`,e.enabled?`bg-success`:`bg-foreground-subtle/30`),children:v(`span`,{className:$(`inline-block h-4 w-4 rounded-full bg-white shadow transition-transform`,e.enabled?`translate-x-6`:`translate-x-1`)})})]});return v(dB,{expanded:l,onExpandedChange:u,dimmed:!e.enabled,header:f,children:c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`space-y-2`,children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:s(`uiLibrary.pipelineStep.model`,`Model`)}),v(Yz,{models:d,value:e.modelId,disabled:o,onChange:t=>i({...e,modelId:t})})]}),t?.configSchema?.map(n=>v(_B,{field:n,allFields:t.configSchema??[],step:e,disabled:o,onChange:i},n.key))]})})}function mB({label:e,value:t,options:n,disabled:r,onChange:i}){let a=q();return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5`,children:e}),c(`select`,{value:t,onChange:e=>i(e.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&&v(`option`,{value:t,children:t||a(`uiLibrary.pipelineStep.default`,`default`)}),n.map(e=>v(`option`,{value:e.value,disabled:e.disabled,children:e.label},e.value))]})]})}function hB({label:e,description:t,value:n,options:r,disabled:i,onChange:a}){function o(e){i||a(n.includes(e)?n.filter(t=>t!==e):[...n,e])}return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1`,children:e}),t&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:t}),v(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>c(`button`,{type:`button`,disabled:i,onClick:()=>o(e.value),className:$(`inline-flex items-center gap-1 text-[10px] font-medium px-2 py-1 rounded-md border transition-colors`,n.includes(e.value)?`bg-primary/20 text-primary border-primary/40`:`bg-surface text-foreground-subtle border-border hover:border-primary/30`,i&&`opacity-50 cursor-not-allowed`),children:[e.iconId!==void 0&&v(Wk,{iconId:e.iconId,size:12}),e.label]},e.value))})]})}function gB(e,t,n){let r=t.settings?.[e];if(r!==void 0)return r;let i=n.find(t=>`key`in t&&t.key===e);return i&&`default`in i?i.default:void 0}function _B({field:e,allFields:t,step:n,disabled:r,onChange:i,hideModelBoundSourceRow:a}){let o=q(),s=`modelApplicability`in e?e.modelApplicability:void 0,l=s?.inapplicable?.[n.modelId],u=v(vB,{field:e,allFields:t,step:n,disabled:r||l!==void 0,modelScopedOptions:s?.optionsByModel?.[n.modelId],onChange:i,hideModelBoundSourceRow:a===!0});return l===void 0?u:c(`div`,{className:`space-y-1`,children:[u,v(`div`,{className:`text-[10px] text-amber-400/90`,children:o(`uiLibrary.pipelineStep.noEffect`,`No effect with the selected model — {{reason}}`,{reason:l})})]})}function vB({field:e,allFields:t,step:n,disabled:r,modelScopedOptions:i,onChange:a,hideModelBoundSourceRow:o}){let s=e.type!==`separator`&&e.type!==`info`?e.showWhen:void 0;if(s){let{field:e,equals:r,notEquals:i,in:a,notIn:o}=s,c=gB(e,n,t);if(r!==void 0&&c!==r||i!==void 0&&c===i||a!==void 0&&!a.includes(c)||o!==void 0&&o.includes(c))return null}function l(t){a({...n,settings:{...n.settings,[e.key]:t}})}if(e.type===`select`){let t=n.settings?.[e.key],a=typeof t==`string`?t:e.default??``;return v(mB,{label:e.label,value:a,disabled:r||e.disabled,options:i??e.options,onChange:l})}if(e.type===`multiselect`){let t=n.settings?.[e.key],a=Array.isArray(t)?t:Array.isArray(e.default)?e.default:[];return v(hB,{label:e.label,description:e.description,value:a,options:i??e.options,disabled:r||e.disabled,onChange:l})}if((e.type===`slider`||e.type===`number`)&&e.bindsToModel===!0)return v(cB,{field:e,modelId:n.modelId,settings:n.settings,disabled:r,onChangeSettings:e=>a({...n,settings:e}),hideSourceRow:o});if(e.type===`slider`||e.type===`number`){let t=n.settings?.[e.key],i=typeof e.default==`number`?e.default:e.min??0,a=typeof t==`number`?t:i,o=e.min??0,s=e.max??1,u=e.step??.01,d=e.type===`slider`?e.showValue:!0,f=`unit`in e?e.unit:void 0,p=e.type===`slider`?e.displayScale:void 0,m=p?a/p:a;return c(`div`,{children:[c(`div`,{className:`flex items-center justify-between mb-1`,children:[v(`span`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide`,children:e.label}),d&&c(`span`,{className:`text-xs font-medium text-foreground tabular-nums`,children:[typeof m==`number`?m.toFixed(2).replace(/\.?0+$/,``):m,f?` ${f}`:``]})]}),e.description&&v(`p`,{className:`text-[10px] text-foreground-subtle/60 mb-1.5`,children:e.description}),v(`input`,{type:`range`,min:o,max:s,step:u,value:a,disabled:r||e.disabled,onChange:e=>l(Number(e.target.value)),className:`w-full accent-primary h-1.5`})]})}if(e.type===`boolean`){let t=n.settings?.[e.key];return c(`label`,{className:`flex items-center gap-2`,children:[v(`input`,{type:`checkbox`,checked:typeof t==`boolean`?t:e.default===!0,disabled:r||e.disabled,onChange:e=>l(e.target.checked),className:`h-3.5 w-3.5 accent-primary`}),v(`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`){let t=n.settings?.[e.key],i=typeof t==`string`?t:e.default??``,a=e.type===`password`?`password`:`text`;return c(`div`,{children:[v(`label`,{className:`block text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-1.5`,children:e.label}),e.type===`textarea`?v(`textarea`,{value:i,disabled:r||e.disabled,placeholder:e.placeholder,onChange:e=>l(e.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`}):v(`input`,{type:a,value:i,disabled:r||e.disabled,placeholder:e.placeholder,onChange:e=>l(e.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`?v(`div`,{className:`border-t border-border my-2`}):e.type===`info`?v(`div`,{className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[10px] text-foreground-subtle`,children:e.content}):null}function yB(e){return e.type!==`separator`&&e.type!==`info`&&e.type!==`group`}function bB(e){return`bindsToModel`in e&&e.bindsToModel===!0?!0:`key`in e&&_ee(e.key)}function xB(e){return e.flatMap(e=>{if(e.type===`group`){let t=xB(e.fields);return t.length>0?[{...e,fields:[...t]}]:[]}return bB(e)?[]:[e]})}function SB(e){return(e.type===`slider`||e.type===`number`)&&e.bindsToModel===!0}function CB(e,t){let n=`modelApplicability`in e?e.modelApplicability?.defaultByModel?.[t]:void 0;return n===void 0?{value:`default`in e?e.default:void 0,fromModel:!1}:{value:n,fromModel:!0}}function wB(e){return e.toFixed(2).replace(/\.?0+$/,``)}function TB(e,t){if(t==null)return`—`;if(typeof t==`boolean`)return t?`on`:`off`;if(typeof t==`number`){let n=e.type===`slider`?e.displayScale:void 0,r=`unit`in e&&typeof e.unit==`string`?` ${e.unit}`:``;return`${wB(n===void 0?t:t/n)}${r}`}let n=`options`in e&&Array.isArray(e.options)?e.options:[],r=e=>{let t=n.find(t=>t.value===e);return t?t.label:String(e)};return Array.isArray(t)?t.length===0?`none`:t.map(r).join(`, `):typeof t==`string`?r(t):JSON.stringify(t)}var EB={camera:`border-primary/40 bg-primary/10 text-primary`,node:`border-border bg-muted/40 text-foreground`,default:`border-border/60 text-foreground-subtle`};function DB(e){return`step-field-${e}`}function OB(e,t,n){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:t,children:[],settings:{...n}}}var kB=[`camera`,`node`];function AB({field:e,layers:t,target:n,labels:r,boundKeys:i,modelId:a,pinned:o,disabled:s,onReset:l,action:u}){let d=q(),f=Ya(t),p=CB(e,a),m=p.fromModel?d(`uiLibrary.layeredSettings.modelDefault`,`model default`):d(`uiLibrary.layeredSettings.default`,`default`),h=_a(t,e.key,i),g=SB(e),_=g?oa(f,e.key,a,p.value,p.value):null,y=_===null||_.source===`override`?h:`default`,b=y==="default"?m:r[y]??y,x=kB.filter(e=>e!==y&&r[e]!==void 0).filter(n=>t[n]?.[e.key]!==void 0).map(n=>{let i=g?t[n]?.[ao(e.key)]:void 0,o=typeof i==`string`&&i!==a?d(`uiLibrary.layeredSettings.forModel`,` (for {{model}})`,{model:i}):``;return`${r[n]} ${TB(e,t[n]?.[e.key])}${o}`}),S=y==="default"?x:[...x,`${m} ${TB(e,p.value)}`],C=_a({[n]:t[n]},e.key,i)!=="default",w=kB.slice(kB.indexOf(n)+1).find(n=>r[n]!==void 0&&t[n]?.[e.key]!==void 0),T=w===void 0?m:r[w]??w,E=h==="default"?`default`:_a({...t,[h]:void 0},e.key,i),D=E==="default"?m:r[E]??E;return c(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px]`,children:[v(`span`,{"data-testid":`setting-source`,className:$(`rounded border px-1.5 py-px font-medium`,EB[y]),children:b}),S.length>0&&v(`span`,{"data-testid":`setting-levels`,className:`text-foreground-subtle`,children:S.join(` · `)}),o&&v(`span`,{className:`rounded border border-warning/40 px-1.5 py-px text-warning`,title:d(`uiLibrary.layeredSettings.pinnedHint`,`Stored by an older editor as a copy of the value below. It changes nothing today, but it stops later changes below from reaching this camera.`),children:d(`uiLibrary.layeredSettings.pinned`,`pinned at the {{source}} value`,{source:D.toLowerCase()})}),c(`span`,{className:`ml-auto flex items-center gap-2`,children:[u,C&&v(`button`,{type:`button`,disabled:s,onClick:l,className:`rounded px-1 text-foreground-subtle hover:bg-muted hover:text-foreground disabled:opacity-50`,children:d(`uiLibrary.layeredSettings.resetTo`,`Reset to {{target}}`,{target:T.toLowerCase()})})]})]})}function jB({addon:e,fields:t,layers:n,target:r,labels:i,modelId:a,onChangeLayer:o,rootModel:s,pinnedKeys:l=[],fieldActions:u,headerActions:d,highlightKey:f=null,disabled:p=!1}){let m=q(),h=r===`camera`?xB(t):t,g=Qi(h),_=Ya(n),y=n[r],b=OB(e,a,_),x=tB(e.id,_,s);return c(`div`,{className:`space-y-2 text-xs`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`h3`,{className:Ut,children:m(`uiLibrary.layeredSettings.title`,`Settings`)}),v(`span`,{className:Ii,children:m(`uiLibrary.layeredSettings.editing`,`editing: {{target}}`,{target:i[r]??r})}),c(`span`,{className:`ml-auto flex flex-wrap items-center gap-3`,children:[d,v(uB,{fields:h,modelId:a,settings:y,disabled:p,onReset:e=>o(e)})]})]}),x!==null&&v(aB,{stepId:e.id,settings:_,rootModel:s,disabled:p,onChange:e=>o(za(y,`useRootModel`,nB(_,e),[]))}),h.map(e=>{if(!yB(e))return v(_B,{field:e,allFields:h,step:b,disabled:p,onChange:()=>{}},e.key);let t=f===e.key;return c(`div`,{id:DB(e.key),"data-field-key":e.key,className:$(`rounded-md border border-transparent px-2 py-1 -mx-2`,t&&`border-primary/50 bg-primary/5`),children:[v(_B,{field:e,allFields:h,step:b,disabled:p,hideModelBoundSourceRow:!0,onChange:t=>o(za(y,e.key,t.settings??{},g))}),v(AB,{field:e,layers:n,target:r,labels:i,boundKeys:g,modelId:a,pinned:l.includes(e.key),disabled:p,onReset:()=>o(ka(y,e.key,g)),action:u?.(e.key,_a(n,e.key,g))})]},e.key)})]})}E();function MB(e){let t=new Set(Ji(e.id).map(e=>e.key));return(e.configSchema??[]).filter(e=>!t.has(e.key))}function NB(e,t,n,r){return r!==void 0&&tB(e.id,n,r)?.effective?r.modelId:t??e.defaultModelId}function PB({addonId:e}){let t=q();return Ji(e).length===0?null:v(`p`,{className:`text-[10px] leading-snug text-foreground-subtle`,children:t(`uiLibrary.agentStepEditor.clusterHint`,`Admission knobs for this step live in Pipeline → Cluster → Settings → Enrichment models. They apply to every camera — a per-device copy would fill the shared index from two policies.`)})}function FB({rootModel:e,stepModelId:t}){return v(`div`,{className:`rounded bg-primary/10 px-3 py-2 text-[11px] text-foreground-subtle`,"data-testid":`root-supplied-model`,children:v(gi,{uiKey:`uiLibrary.agentStepEditor.rootSupplied`,fallback:`<0>Model: {{name}}</0> (the root model). This step's own model{{stepModel}} is kept and runs again whenever the root model cannot supply the step.`,components:[v(`span`,{className:`font-semibold text-foreground`},`m`)],values:{name:e.name,stepModel:t===void 0?``:` (${t})`}})})}function IB({addon:e,agentDefault:t,onChangeAgentConfig:n,engineFormat:r,effectiveModelId:i,rootModel:a}){let o=q(),s=p(()=>Qz(e.models,r),[e.models,r]),l=e=>{n?.({...t,...e})},u=MB(e),d=e.defaultModelIdByFormat?.[r]??e.defaultModelId,f=t.settings??{},m=tB(e.id,f,a)?.effective===!0,h=t.modelId??i;return c(`div`,{className:`space-y-4 text-xs`,children:[m&&a!==void 0?v(FB,{rootModel:a,stepModelId:h}):c(`div`,{children:[v(`div`,{className:`text-[10px] uppercase tracking-widest text-foreground-subtle mb-1`,children:o(`uiLibrary.agentStepEditor.model`,`Model`)}),v(Yz,{models:s,value:h??``,defaultModelId:d,onChange:e=>l({modelId:e})})]}),(u.length>0||tB(e.id,f,a))&&v(`div`,{className:`pt-2 border-t border-border/50`,children:v(jB,{addon:e,fields:u,layers:{node:f},target:`node`,labels:{node:`This node`},modelId:NB(e,h,f,a),...a===void 0?{}:{rootModel:a},onChangeLayer:e=>l({settings:e})})}),v(PB,{addonId:e.id})]})}E();var LB=D(({className:e,...t},n)=>v(`label`,{ref:n,className:$(`text-[10px] uppercase tracking-wider text-foreground-muted font-medium`,e),...t}));LB.displayName=`Label`,E();var RB=Il(``,{variants:{orientation:{horizontal:`h-px w-full bg-border-subtle`,vertical:`w-px h-full bg-border-subtle`}},defaultVariants:{orientation:`horizontal`}}),zB=D(({className:e,orientation:t,...n},r)=>v(`div`,{ref:r,role:`separator`,"aria-orientation":t??`horizontal`,className:$(RB({orientation:t}),e),...n}));zB.displayName=`Separator`,E();var BB=D(({className:e,...t},n)=>v(`input`,{ref:n,type:`checkbox`,className:$(`w-3.5 h-3.5 rounded-sm border border-border accent-primary`,e),...t}));BB.displayName=`Checkbox`,E();var VB=D(({className:e,checked:t,onCheckedChange:n,label:r,...i},a)=>c(`button`,{ref:a,role:`switch`,"aria-checked":t,type:`button`,onClick:()=>n(!t),className:$(`inline-flex items-center gap-2`,e),...i,children:[v(`span`,{className:$(`w-8 h-4 rounded-full transition-colors`,t?`bg-primary`:`bg-surface-hover`),children:v(`span`,{className:$(`block w-3.5 h-3.5 rounded-full bg-white transition-transform`,t?`translate-x-4`:`translate-x-0.5`)})}),r&&v(`span`,{className:`text-xs text-foreground`,children:r})]}));VB.displayName=`Switch`,E();function HB(e){let{scrollLeft:t,scrollWidth:n,clientWidth:r}=e,i=n>r+1;return{overflowLeft:i&&t>1,overflowRight:i&&t+r<n-1}}function UB(e){typeof e.scrollIntoView==`function`&&e.scrollIntoView({inline:`nearest`,block:`nearest`})}function WB(e,t){let n=e.querySelectorAll(`[role="tab"]`);if(n.length===0)return;let r=e.scrollLeft;if(t===`right`){for(let e of n)if(e.offsetLeft+e.offsetWidth>r+1){UB(e);return}return}for(let e=n.length-1;e>=0;e--){let t=n[e];if(t!==void 0&&t.offsetLeft<r-1){UB(t);return}}}function GB(e){let t=e.querySelector(`[role="tab"][aria-selected="true"]`);t!==null&&typeof t.scrollIntoView==`function`&&t.scrollIntoView({inline:`nearest`,block:`nearest`})}function KB({activeTabKey:e,listClassName:t,className:n,children:r,...i}){let a=f(null),[o,s]=C({overflowLeft:!1,overflowRight:!1}),[l,u]=C(!1),d=_(()=>{let e=a.current;e!==null&&s(HB(e))},[]);b(()=>{d();let e=a.current;if(e===null)return;e.addEventListener(`scroll`,d,{passive:!0});let t=typeof ResizeObserver<`u`?new ResizeObserver(d):null;t?.observe(e);for(let n of e.children)t?.observe(n);return()=>{e.removeEventListener(`scroll`,d),t?.disconnect()}},[d,r]),b(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let e=window.matchMedia(`(hover: hover) and (pointer: fine)`),t=()=>{u(e.matches)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),b(()=>{let t=a.current;t===null||e===void 0||(GB(t),d())},[e,d]);let p=e=>{let t=a.current;t!==null&&WB(t,e)};return c(`div`,{className:$(`relative min-w-0`,n),"data-tab-strip-overflow-left":o.overflowLeft?``:void 0,"data-tab-strip-overflow-right":o.overflowRight?``:void 0,children:[o.overflowLeft&&v(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 left-0 z-[1] w-8 bg-gradient-to-r from-background to-transparent`}),o.overflowRight&&v(`div`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 right-0 z-[1] w-8 bg-gradient-to-l from-background to-transparent`}),l&&o.overflowLeft&&v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:ge,"aria-label":`Scroll tabs left`,className:`absolute left-0 top-1/2 z-[2] -translate-y-1/2 bg-background/80 shadow-sm`,onClick:()=>p(`left`)}),l&&o.overflowRight&&v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:It,"aria-label":`Scroll tabs right`,className:`absolute right-0 top-1/2 z-[2] -translate-y-1/2 bg-background/80 shadow-sm`,onClick:()=>p(`right`)}),v(`div`,{ref:a,role:`tablist`,className:t,...i,children:r})]})}E();var qB=O(null);function JB(){let e=I(qB);if(!e)throw Error(`Tabs compound components must be used within <Tabs>`);return e}function YB({value:e,onValueChange:t,defaultValue:n=``,appearance:r=`underline`,className:i,...a}){let[o,s]=C(n),c=e??o,l=_(n=>{t?.(n),e===void 0&&s(n)},[e,t]);return v(qB.Provider,{value:{value:c,setValue:l,appearance:r},children:v(`div`,{className:i,...a})})}function XB({className:e,...t}){let{appearance:n,value:r}=JB();return v(KB,{activeTabKey:r,listClassName:$(`flex flex-row overflow-x-auto overflow-y-hidden`,n===`pills`?`gap-1 border-b border-border-subtle py-1`:`border-b border-border-subtle`,e),...t})}var ZB=D(function({value:e,className:t,...n},r){let{value:i,setValue:a,appearance:o}=JB(),s=e===i;return v(`button`,{ref:r,type:`button`,role:`tab`,"aria-selected":s,"aria-controls":`tabpanel-${e}`,tabIndex:s?0:-1,className:$(`inline-flex h-7 shrink-0 items-center justify-center gap-1.5 whitespace-nowrap text-xs px-3 transition-colors`,o===`pills`?s?`rounded-md bg-primary/10 font-medium text-primary`:`rounded-md text-foreground-muted hover:bg-surface-hover hover:text-foreground`:s?`border-b-2 border-primary text-foreground font-medium`:`text-foreground-muted hover:text-foreground`,t),onClick:()=>a(e),...n})});function QB({value:e,className:t,...n}){let{value:r}=JB();return e===r?v(`div`,{role:`tabpanel`,id:`tabpanel-${e}`,className:$(`pt-3`,t),...n}):null}E();var $B=D(({className:e,...t},n)=>v(`div`,{ref:n,className:$(`overflow-auto [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-track]:bg-transparent [&::-webkit-scrollbar-thumb]:bg-surface-hover [&::-webkit-scrollbar-thumb]:rounded-full`,e),...t}));$B.displayName=`ScrollArea`,E();function eV({title:e,icon:t,position:n,onPositionChange:r,size:i,onSizeChange:a,onClose:o,children:s,defaultWidth:l=360,defaultHeight:u=280,minWidth:d=280,minHeight:p=160,offsetIndex:m=0,className:h}){let g=q(),[y,x]=C({x:80+m*30,y:80+m*30}),[S,w]=C({w:l,h:u}),T=n??y,E=i??S,D=f({size:E,onPositionChange:r,onSizeChange:a});D.current={size:E,onPositionChange:r,onSizeChange:a};let[O,k]=C(!1),A=f(!1),j=f(!1),M=f({x:0,y:0}),N=dl(),P=_(e=>{e.preventDefault(),A.current=!0,M.current={x:e.clientX-T.x,y:e.clientY-T.y}},[T]),F=_(e=>{e.preventDefault(),e.stopPropagation(),j.current=!0,M.current={x:e.clientX,y:e.clientY}},[]);return b(()=>{let e=e=>{if(A.current){let t={x:e.clientX-M.current.x,y:e.clientY-M.current.y};x(t),D.current.onPositionChange?.(t)}if(j.current){let t=e.clientX-M.current.x,n=e.clientY-M.current.y;M.current={x:e.clientX,y:e.clientY};let r=D.current.size,i={w:Math.max(d,r.w+t),h:Math.max(p,r.h+n)};D.current={...D.current,size:i},w(i),D.current.onSizeChange?.(i)}},t=()=>{A.current=!1,j.current=!1};return window.addEventListener(`mousemove`,e),window.addEventListener(`mouseup`,t),()=>{window.removeEventListener(`mousemove`,e),window.removeEventListener(`mouseup`,t)}},[d,p]),N?c(`div`,{className:$(`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 pb-[env(safe-area-inset-bottom)]`,h),style:{maxHeight:`60dvh`},children:[c(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2 border-b border-border shrink-0 bg-surface`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[t&&v(t,{size:12,className:`text-primary shrink-0`}),v(`span`,{className:`text-[11px] font-medium truncate`,children:e})]}),c(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v(`button`,{onClick:()=>k(!O),className:`p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors`,children:v(O?Br:mi,{size:12})}),v(`button`,{onClick:o,className:`p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors`,children:v(Zn,{size:12})})]})]}),!O&&v(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:s})]}):c(`div`,{className:$(`fixed z-50 rounded-lg border border-border bg-background-elevated shadow-2xl flex flex-col overflow-hidden`,h),style:{left:T.x,top:T.y,width:O?280:E.w,height:O?`auto`:E.h},children:[c(`div`,{onMouseDown:P,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:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(fr,{size:12,className:`text-foreground-subtle shrink-0`}),t&&v(t,{size:12,className:`text-primary shrink-0`}),v(`span`,{className:`text-[11px] font-medium truncate`,children:e})]}),c(`div`,{className:`flex items-center gap-1 shrink-0`,children:[v(`button`,{onClick:()=>k(!O),className:`p-0.5 rounded hover:bg-surface-hover text-foreground-muted transition-colors`,title:O?g(`uiLibrary.floatingPanel.restore`,`Restore`):g(`uiLibrary.floatingPanel.minimize`,`Minimize`),children:v(O?Br:mi,{size:12})}),v(`button`,{onClick:o,className:`p-0.5 rounded hover:bg-danger/20 text-foreground-muted hover:text-danger transition-colors`,title:g(`uiLibrary.floatingPanel.close`,`Close`),children:v(Zn,{size:12})})]})]}),!O&&c(`div`,{className:`flex-1 min-h-0 overflow-y-auto relative`,children:[s,v(`div`,{onMouseDown:F,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}})]})]})}E();function tV({open:e,onClose:t,children:n,className:r,width:i=`w-64`}){let a=f(null);return b(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return document.addEventListener(`keydown`,n),document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,n),document.body.style.overflow=``}},[e,t]),c(P,{children:[v(`div`,{className:$(`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`}),v(`div`,{ref:a,role:`dialog`,"aria-modal":`true`,className:$(`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 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,i,e?`translate-x-0`:`-translate-x-full`,r),children:n})]})}function nV({label:e,icon:t,href:n,badge:r,active:i=!1,className:a}){return c(`a`,{href:n,className:$(`flex items-center gap-2 h-7 px-2 text-[11px] transition-colors`,i?`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:[v(t,{className:`h-3.5 w-3.5 shrink-0`}),v(`span`,{className:`truncate flex-1`,children:e}),r!==void 0&&v(Bk,{className:`ml-auto text-[10px] px-1.5 py-0`,children:r})]})}function rV({logo:e,sections:t,footer:n,onNavigate:r,className:i}){return c(`nav`,{className:$(`bg-surface border-r border-border h-full flex flex-col`,i),children:[e&&v(`div`,{className:`px-3 py-2 shrink-0`,children:e}),v(`div`,{className:`flex-1 overflow-auto px-1 py-1`,children:t.map((e,t)=>c(`div`,{className:$(t>0?`mt-3`:``),children:[e.label&&v(`span`,{className:`text-[10px] text-foreground-disabled uppercase tracking-wider px-2 mb-1 block`,children:e.label}),v(`div`,{className:`flex flex-col gap-0.5`,onClick:r,children:e.items.map(e=>v(nV,{...e},e.href))})]},t))}),n&&n.length>0&&c(`div`,{className:`shrink-0 px-1 pb-1`,children:[v(zB,{className:`mb-1`}),v(`div`,{className:`flex flex-col gap-0.5`,onClick:r,children:n.map(e=>v(nV,{...e},e.href))})]})]})}E();function iV({sidebar:e,header:t,mobileLogo:n,mobileActions:r,children:i,className:a}){let o=q(),s=dl(),[l,u]=C(!1);return c(`div`,{className:$(`flex h-screen`,a),children:[!s&&v(rV,{...e,className:$(`w-44`,e.className)}),s&&v(tV,{open:l,onClose:()=>u(!1),width:`w-64`,children:v(rV,{...e,onNavigate:()=>u(!1),className:`w-full border-r-0`})}),c(`div`,{className:`flex flex-1 flex-col min-w-0`,children:[s&&c(`header`,{className:`flex items-center h-12 border-b border-border px-3 shrink-0 bg-surface/80 backdrop-blur-sm`,children:[v(`button`,{onClick:()=>u(!0),className:`p-1.5 -ml-1.5 rounded-md hover:bg-surface-hover text-foreground-muted transition-colors`,"aria-label":o(`uiLibrary.appShell.openMenu`,`Open menu`),children:v(sr,{className:`h-5 w-5`})}),n&&v(`div`,{className:`flex-1 flex justify-center`,children:n}),r&&v(`div`,{className:`shrink-0`,children:r})]}),!s&&t&&c(`header`,{className:`flex items-center h-10 border-b border-border px-4 shrink-0`,children:[t.breadcrumbs&&t.breadcrumbs.length>0&&v(`nav`,{className:`flex items-center gap-1 text-xs flex-1 min-w-0`,children:t.breadcrumbs.map((e,n)=>{let r=n===t.breadcrumbs.length-1;return c(`span`,{className:`flex items-center gap-1`,children:[n>0&&v(It,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),e.href&&!r?v(`a`,{href:e.href,className:`text-foreground-subtle hover:text-foreground transition-colors truncate`,children:e.label}):v(`span`,{className:`text-foreground truncate`,children:e.label})]},n)})}),t.actions&&v(`div`,{className:`flex items-center gap-2 ml-auto shrink-0`,children:t.actions})]}),v(`main`,{className:`flex-1 overflow-auto p-4`,children:i})]})]})}function aV(e){return e>=.8?`bg-emerald-500`:e>=.5?`bg-amber-500`:e>=.3?`bg-orange-500`:`bg-zinc-500`}function oV(e){return e>=.8?`text-emerald-400`:e>=.5?`text-amber-400`:e>=.3?`text-orange-400`:`text-zinc-400`}function sV({classifications:e,processing:t=!1,inferenceMs:n,maxItems:r=10,className:i=``}){let a=q(),o=e.slice(0,r),s=o.length>0?o[0].score:1;return t?v(`div`,{className:`rounded-xl border border-border bg-surface p-4 text-center ${i}`,children:v(`div`,{className:`text-sm text-foreground-subtle animate-pulse`,children:a(`uiLibrary.audioClassificationList.processing`,`Classifying audio...`)})}):o.length===0?v(`div`,{className:`rounded-xl border border-border bg-surface p-4 text-center ${i}`,children:v(`div`,{className:`text-xs text-foreground-subtle`,children:a(`uiLibrary.audioClassificationList.empty`,`No classifications yet`)})}):c(`div`,{className:`rounded-xl border border-border bg-surface overflow-hidden ${i}`,children:[c(`div`,{className:`px-3 py-2 border-b border-border flex items-center justify-between`,children:[v(`h3`,{className:`text-xs font-medium text-foreground`,children:a(`uiLibrary.audioClassificationList.title`,`Audio Classifications`)}),c(`div`,{className:`flex items-center gap-3 text-[10px] text-foreground-subtle`,children:[o.length<e.length&&v(`span`,{children:a(`uiLibrary.audioClassificationList.showing`,`showing {{shown}} of {{total}}`,{shown:o.length,total:e.length})}),n!==void 0&&c(`span`,{className:`font-mono`,children:[n.toFixed(1),`ms`]})]})]}),v(`div`,{className:`divide-y divide-border/50`,children:o.map((e,t)=>{let n=s>0?e.score/s*100:0;return c(`div`,{className:`px-3 py-1.5 flex items-center gap-3 hover:bg-surface-hover/30`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle w-5 text-right font-mono`,children:t+1}),v(`span`,{className:`text-xs font-medium text-foreground min-w-[120px]`,children:e.className}),v(`div`,{className:`flex-1 h-2 rounded-full bg-zinc-800 overflow-hidden`,children:v(`div`,{className:`h-full rounded-full transition-all duration-300 ${aV(e.score)}`,style:{width:`${n}%`}})}),c(`span`,{className:`text-xs font-mono font-semibold w-14 text-right ${oV(e.score)}`,children:[(e.score*100).toFixed(1),`%`]})]},`${e.className}-${t}`)})})]})}E();function cV({currentDbfs:e,durationSec:t=30,maxSamples:n=120,height:r=64,className:i=``,color:a=`#10b981`,clipColor:o=`#ef4444`,clipThreshold:s=-6,minDbfs:l=-96}){let u=q(),d=f(null),p=f(null),[m,h]=C([]);b(()=>{e!==null&&h(t=>{let r=[...t,{dbfs:e,timestamp:Date.now()}];return r.length>n?r.slice(-n):r})},[e,n]);let g=_(()=>{let e=d.current,n=p.current;if(!e||!n)return;let i=n.clientWidth;if(i===0)return;let c=window.devicePixelRatio||1;e.width=i*c,e.height=r*c,e.style.width=`${i}px`,e.style.height=`${r}px`;let u=e.getContext(`2d`);if(!u||(u.scale(c,c),u.clearRect(0,0,i,r),m.length===0))return;let f=m[m.length-1].timestamp,h=t*1e3,g=f-h,_=m.filter(e=>e.timestamp>=g);if(_.length===0)return;let v=Math.max(1,Math.floor(i/(t*2))),y=Math.abs(l);for(let e of _){let t=e.timestamp-g,n=Math.floor(t/h*i),c=(Math.max(l,Math.min(0,e.dbfs))-l)/y,d=Math.max(1,c*r);u.fillStyle=e.dbfs>=s?o:a,u.globalAlpha=.8,u.fillRect(n,r-d,v,d)}u.globalAlpha=1;let b=r-(s-l)/y*r;u.strokeStyle=o,u.globalAlpha=.25,u.lineWidth=1,u.setLineDash([4,4]),u.beginPath(),u.moveTo(0,b),u.lineTo(i,b),u.stroke(),u.setLineDash([]),u.globalAlpha=1},[m,t,r,a,o,s,l]);b(()=>{g()},[g]),b(()=>{let e=new ResizeObserver(()=>g()),t=p.current;return t&&e.observe(t),()=>e.disconnect()},[g]);let y=m.length>0?m[m.length-1].dbfs:null;return c(`div`,{ref:p,className:`relative ${i}`,children:[v(`canvas`,{ref:d,className:`w-full rounded-md`}),c(`div`,{className:`absolute top-1 left-2 text-[9px] text-foreground-subtle/50 font-mono`,children:[t,`s`]}),y!==null&&v(`div`,{className:`absolute bottom-1 right-2 text-[9px] text-foreground-subtle/50 font-mono`,children:u(`uiLibrary.audioLevelWaveform.readout`,{one:`{{dbfs}} dBFS · {{count}} sample`,other:`{{dbfs}} dBFS · {{count}} samples`},{dbfs:y.toFixed(1),count:m.length})})]})}E();function lV({samples:e,sampleRate:t=16e3,height:n=96,className:r=``,color:i=`#3b82f6`,bgColor:a=`transparent`}){let o=q(),s=f(null),l=f(null),u=_(()=>{let t=s.current,r=l.current;if(!t||!r||!e||e.length===0)return;let o=r.clientWidth;if(o===0)return;let c=window.devicePixelRatio||1;t.width=o*c,t.height=n*c,t.style.width=`${o}px`,t.style.height=`${n}px`;let u=t.getContext(`2d`);if(!u)return;u.scale(c,c),a===`transparent`?u.clearRect(0,0,o,n):(u.fillStyle=a,u.fillRect(0,0,o,n));let d=e.length/o,f=n/2;u.fillStyle=i,u.globalAlpha=.7;for(let t=0;t<o;t++){let n=Math.floor(t*d),r=Math.min(Math.floor((t+1)*d),e.length),i=0,a=0;for(let t=n;t<r;t++){let n=e[t];n<i&&(i=n),n>a&&(a=n)}let o=f-a*f,s=f-i*f,c=Math.max(1,s-o);u.fillRect(t,o,1,c)}u.globalAlpha=1,u.strokeStyle=i,u.globalAlpha=.2,u.lineWidth=1,u.beginPath(),u.moveTo(0,f),u.lineTo(o,f),u.stroke(),u.globalAlpha=1},[e,n,i,a]);b(()=>{u()},[u]),b(()=>{let e=new ResizeObserver(()=>u()),t=l.current;return t&&e.observe(t),()=>e.disconnect()},[u]);let d=((e&&t?Math.round(e.length/t*1e3):0)/1e3).toFixed(1);return c(`div`,{ref:l,className:`relative ${r}`,children:[v(`canvas`,{ref:s,className:`w-full rounded-md`}),e&&e.length>0&&v(`div`,{className:`absolute bottom-1 right-2 text-[10px] text-foreground-subtle/60 font-mono`,children:o(`uiLibrary.audioWaveform.summary`,`{{duration}}s · {{rate}}kHz · {{samples}} samples`,{duration:d,rate:t/1e3,samples:e.length.toLocaleString()})})]})}var uV=`uiLibrary.batteryBadge.low`,dV=`uiLibrary.batteryBadge.normal`;function fV(e){return e<50}function pV(e){return e<=10?Ke:e<=30?Ve:e<=70?Jr:on}function mV(e){return e===`dc`||e===`solar`}function hV(e,t){return mV(t)?`text-emerald-400`:e<=10?`text-rose-400`:e<=30?`text-amber-400`:`text-foreground-subtle`}function gV({status:e,variant:t=`compact`,className:n}){let r=q();if(!e)return null;let{level:i,charging:a,sleeping:o,binary:s}=e;if(i===null)return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,n),title:r(`uiLibrary.batteryBadge.titleUnknown`,`Battery: unknown`),children:[v(Ee,{className:`h-3.5 w-3.5`}),v(`span`,{children:r(`uiLibrary.batteryBadge.unknown`,`Unknown`)})]});if(s===!0){let e=fV(i),t=e?Ke:on;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,e?`text-rose-400`:`text-foreground-subtle`,n),title:e?r(`uiLibrary.batteryBadge.titleLow`,`Battery: low`):r(`uiLibrary.batteryBadge.titleNormal`,`Battery: normal`),children:[v(t,{className:`h-3.5 w-3.5`}),v(`span`,{children:e?r(uV,`Low`):r(dV,`Normal`)})]})}let l=pV(i),u=hV(i,a),d=a===`solar`?wt:a===`dc`?_t:null,f=o;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,u,n),title:[r(`uiLibrary.batteryBadge.titlePercent`,`Battery: {{percent}}%`,{percent:Math.round(i)}),mV(a)?r(`uiLibrary.batteryBadge.charging`,`charging ({{source}})`,{source:a}):null,o?r(`uiLibrary.batteryBadge.sleeping`,`sleeping`):null].filter(e=>e!==null).join(` · `),children:[v(l,{className:`h-3.5 w-3.5`}),c(`span`,{children:[Math.round(i),`%`]}),d&&v(d,{className:`h-3 w-3`}),f&&v(St,{className:`h-3 w-3 text-blue-300`}),t===`full`&&mV(a)&&v(`span`,{className:`text-foreground-subtle`,children:a})]})}function _V(e){if(e===null)return;let t=e.trim();return t===``?void 0:t}function vV(e,t){if(e===null||!Number.isFinite(e)||e<=0)return null;let n=t-e;if(n<=0)return null;let r=Math.floor(n/6e4);return r<60?{minutes:Math.max(1,r)}:{hours:Math.floor(r/60)}}function yV(e,t,n,r){let i=_V(n);if(e===null)return{key:`unknown`};if(e===!1)return i===void 0?{key:`idle`}:{key:`idle`,phase:i};let a=vV(t,r);return a===null?i===void 0?{key:`running`}:{key:`running`,phase:i}:{key:`running`,duration:a,...i===void 0?{}:{phase:i}}}function bV({running:e,children:t,className:n}){let r=q();return e===null?v(`span`,{"data-running":`unknown`,className:$(`inline-flex shrink-0`,n),children:t}):e===!0?c(`span`,{"data-running":`running`,className:$(`relative inline-flex shrink-0 rounded-full p-0.5`,n),"aria-label":r(`uiLibrary.runningBadge.running`,`Running`),children:[v(`span`,{className:`pointer-events-none absolute inset-0 rounded-full border border-primary animate-pulse`,"aria-hidden":!0}),t]}):c(`span`,{"data-running":`idle`,className:$(`relative inline-flex shrink-0`,n),"aria-label":r(`uiLibrary.runningBadge.idle`,`Idle`),children:[t,v(`span`,{className:`pointer-events-none absolute -bottom-px -right-px h-1.5 w-1.5 rounded-full bg-foreground-subtle`,"aria-hidden":!0})]})}function xV({running:e,since:t,phase:n,className:r,now:i=Date.now()}){let a=q(),o=yV(e,t,n,i);if(o.key===`unknown`||e!==!0&&e!==!1)return null;if(o.key===`idle`){let e=a(`uiLibrary.runningStatus.idle`,`Idle`),t=o.phase===void 0?e:a(`uiLibrary.runningStatus.withPhase`,`{{state}} · {{phase}}`,{state:e,phase:o.phase});return v(`p`,{className:$(`text-[11px] text-foreground-muted`,r),children:t})}let s;s=o.duration===void 0?a(`uiLibrary.runningStatus.running`,`Running`):`minutes`in o.duration?a(`uiLibrary.runningStatus.runningForMinutes`,`Running for {{count}} min`,{count:o.duration.minutes}):a(`uiLibrary.runningStatus.runningForHours`,`Running for {{count}} h`,{count:o.duration.hours});let c=o.phase===void 0?s:a(`uiLibrary.runningStatus.withPhase`,`{{state}} · {{phase}}`,{state:s,phase:o.phase});return v(`p`,{className:$(`text-[11px] text-foreground-muted`,r),children:c})}function SV(e){return e===null?An:e<=20?fee:e<=50?le:e<=80?uee:An}function CV(e){return e===null?`text-foreground-subtle`:e<=20?`text-rose-400`:e<=50?`text-amber-400`:`text-foreground-subtle`}function wV({status:e,className:t}){let n=q();if(!e||e.type===`unknown`)return null;if(e.type===`ethernet`)return v(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium text-foreground-subtle`,t),title:n(`uiLibrary.networkLinkBadge.ethernet`,`Network: ethernet`),children:v(gt,{className:`h-3.5 w-3.5`})});let r=e.type===`cellular`?ft:SV(e.signal),i=e.signal===null?null:Math.round(e.signal),a=e.ssid?n(`uiLibrary.networkLinkBadge.typeSsid`,`Network: {{type}} ({{ssid}})`,{type:e.type,ssid:e.ssid}):n(`uiLibrary.networkLinkBadge.type`,`Network: {{type}}`,{type:e.type}),o=i===null?a:`${a} · ${n(`uiLibrary.networkLinkBadge.signal`,`signal {{percent}}%`,{percent:i})}`;return c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px] font-medium`,CV(e.signal),t),title:o,children:[v(r,{className:`h-3.5 w-3.5`}),i!==null&&c(`span`,{children:[i,`%`]})]})}var TV={"node-a":`bg-node-a`,"node-b":`bg-node-b`,"node-c":`bg-node-c`,"node-d":`bg-node-d`,"node-e":`bg-node-e`,"node-f":`bg-node-f`,"node-g":`bg-node-g`,"node-h":`bg-node-h`},EV={"node-a":`text-node-a`,"node-b":`text-node-b`,"node-c":`text-node-c`,"node-d":`text-node-d`,"node-e":`text-node-e`,"node-f":`text-node-f`,"node-g":`text-node-g`,"node-h":`text-node-h`},DV={"node-a":`bg-node-a/15`,"node-b":`bg-node-b/15`,"node-c":`bg-node-c/15`,"node-d":`bg-node-d/15`,"node-e":`bg-node-e/15`,"node-f":`bg-node-f/15`,"node-g":`bg-node-g/15`,"node-h":`bg-node-h/15`};function OV(e){return TV[e]}function kV(e){return EV[e]}function AV(e){return DV[e]}function jV(e){for(let[t,n]of Object.entries(e))if(t===`color`)return n}function MV(e){let t=new Map;for(let n of e??[]){let e=to.safeParse(jV(n.settings));t.set(n.nodeId,e.success?e.data:Yi(n.nodeId))}return t}function NV(e,t){return e.get(t)??Yi(t)}var PV={detection:`bg-info/12 text-info ring-info/35`,decode:`bg-warning/12 text-warning ring-warning/35`,audio:`bg-success/12 text-success ring-success/35`},FV={detection:`bg-info/22 text-info ring-info/55`,decode:`bg-warning/22 text-warning ring-warning/55`,audio:`bg-success/22 text-success ring-success/55`},IV={"node-a":`bg-node-a/12`,"node-b":`bg-node-b/12`,"node-c":`bg-node-c/12`,"node-d":`bg-node-d/12`,"node-e":`bg-node-e/12`,"node-f":`bg-node-f/12`,"node-g":`bg-node-g/12`,"node-h":`bg-node-h/12`},LV={"node-a":`bg-node-a/22`,"node-b":`bg-node-b/22`,"node-c":`bg-node-c/22`,"node-d":`bg-node-d/22`,"node-e":`bg-node-e/22`,"node-f":`bg-node-f/22`,"node-g":`bg-node-g/22`,"node-h":`bg-node-h/22`},RV={"node-a":`ring-node-a/45`,"node-b":`ring-node-b/45`,"node-c":`ring-node-c/45`,"node-d":`ring-node-d/45`,"node-e":`ring-node-e/45`,"node-f":`ring-node-f/45`,"node-g":`ring-node-g/45`,"node-h":`ring-node-h/45`};function zV({roleLabel:e,roleId:t,nodeName:n,colorId:r,emphasized:i=!1,pinned:a=!1,onSelect:o,disabled:s=!1,trailing:l}){let u=q(),d=e===void 0?n:a?`${e} pinned on ${n}`:`${e} on ${n}`,f=e!==void 0&&t!==void 0,p=$(`inline-flex max-w-full items-center gap-1 rounded-full px-2 py-0.5 text-[10px] leading-tight ring-1 ring-inset`,f?i?$(`role-node-pill-emphasized font-semibold ring-2`,FV[t]):$(`font-medium`,PV[t]):i?$(`role-node-pill-emphasized font-semibold ring-2`,LV[r],RV[r],kV(r)):$(`font-medium text-foreground-muted ring-border/60`,IV[r]),o!==void 0&&!s&&`cursor-pointer transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,s&&`cursor-not-allowed opacity-50`),m=v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,OV(r)),"aria-hidden":!0}),h=e===void 0?c(P,{children:[m,v(`span`,{className:$(`min-w-0 truncate font-medium`,i?kV(r):`text-foreground`),children:n}),l]}):c(P,{children:[a&&v(mee,{className:`h-2.5 w-2.5 shrink-0 opacity-80`,"aria-label":u(`uiLibrary.roleNodePill.pinned`,`pinned`)}),v(`span`,{className:`shrink-0`,children:e}),v(`span`,{className:$(`min-w-0 truncate`,f?`opacity-80`:i?kV(r):`text-foreground-subtle`),children:n}),m]});return o===void 0?v(`span`,{"data-testid":`role-node-pill`,"data-role":t,title:d,className:p,children:h}):v(`button`,{type:`button`,role:`tab`,"aria-selected":i,"data-testid":`role-node-pill`,"data-role":t,title:d,disabled:s,onClick:o,className:p,children:h})}E();function BV({items:e,className:t}){return v(`nav`,{className:`hidden md:flex items-center gap-1 text-[11px] text-foreground-subtle ${t??``}`,children:e.map((t,n)=>{let r=n===e.length-1,i=!r&&(t.onClick||t.href);return c(l.Fragment,{children:[n>0&&v(It,{className:`h-3 w-3 flex-shrink-0`}),i?t.onClick?v(`button`,{type:`button`,onClick:t.onClick,className:`hover:text-foreground transition-colors`,children:t.label}):v(`a`,{href:t.href,className:`hover:text-foreground transition-colors`,children:t.label}):v(`span`,{className:r?`text-foreground font-medium`:``,children:t.label})]},n)})})}var VV={baseDelayMs:1500,maxDelayMs:15e3,maxAttempts:40};function HV(e,t=Math.random){if(e>=VV.maxAttempts)return{kind:`exhausted`,attempts:e};let n=Math.min(VV.maxDelayMs,VV.baseDelayMs*2**e);return{kind:`retry`,delayMs:Math.round(n*(.8+t()*.4))}}var UV=`/adaptive-probe`,WV=2500,GV=15e3,KV=250,qV=2;function JV(e){return e>=8?`high`:e>=2.5?`mid`:`low`}function YV(e){let{downlinkMbps:t,...n}=e;return n}function XV(e){return JV(e)!==`low`}function ZV(e){if(e===void 0||e===``)return null;let t;try{t=new URL(e)}catch{return null}return t.protocol!==`http:`&&t.protocol!==`https:`?null:`${t.origin}${t.pathname.replace(/\/+$/,``)}`}function QV(e,t){return ZV(e)??ZV(t)}function $V(e){let t=e.downlinkMbps===void 0?`none`:JV(e.downlinkMbps);return[e.phase,e.viewportWidth??`-`,e.viewportHeight??`-`,e.devicePixelRatio??`-`,t,e.prefersTier??`-`,e.probeOrigin??`unreachable`,e.probeStatus??`-`,e.probeAnswer??`-`].join(`|`)}function eH(e,t){return e<65536||!(t>0)?null:e*8/t/1e3}async function tH(e,t){let n=null,r=0,i=0;try{for(;;){let a=await e.read();if(a.done)break;let o=a.value?.byteLength??0,s=t();n===null?n=s:i+=o,r=s}}catch{e.cancel().catch(()=>void 0)}return n===null?null:eH(i,r-n)}async function nH(e,t){let n=e.replace(/\/+$/,``),r=new AbortController,i=setTimeout(()=>r.abort(),WV);try{let e=await t.fetchImpl(`${n}${UV}`,{signal:r.signal});if(!e.ok)return e.status!==void 0&&t.onRefused?.(e.status),null;let i=e.body?.getReader()??null;if(i!==null)return await tH(i,t.now);let a=t.now();return eH((await e.arrayBuffer()).byteLength,t.now()-a)}catch{return null}finally{clearTimeout(i)}}async function rH(e,t=GV){let n=e.now()+t;for(;;){if(e.signal.aborted)return`aborted`;if((e.readyState()??0)>=qV)return`frame`;if(e.now()>=n)return`timeout`;await e.sleep(KV)}}async function iH(e){if(await e.waitFrame()===`frame`)return e.measure()}function aH(e){let t=new Map,n=new Map,r=new Set,i=n=>{let r=t.get(n);return r!==void 0&&e.now()-r.at<=e.ttlMs?r.mbps:void 0};return{cached:i,firstRefusal:(e,t)=>{let n=`${e}|${String(t)}`;return r.has(n)?!1:(r.add(n),!0)},latest:n=>{let r=t.get(n);return r===void 0?null:{mbps:r.mbps,ageMs:Math.max(0,e.now()-r.at)}},measured:(r,a)=>{let o=i(r);if(o!==void 0)return Promise.resolve(o);let s=n.get(r);if(s!==void 0)return s;let c=a().then(n=>{if(!(n===null||!Number.isFinite(n)))return t.set(r,{mbps:n,at:e.now()}),n}).catch(()=>void 0).finally(()=>{n.delete(r)});return n.set(r,c),c}}}async function oH(e,t,n){if(e===void 0)return{kind:`unsupported`,why:`no-wiring`};if(t===null)return{kind:`unsupported`,why:`no-session`};try{return{kind:`answered`,answer:await e(t,n)}}catch{return{kind:`unsupported`,why:`call-failed`}}}var sH=100;function cH(e,t,n){if(n.renegotiating)return{baseline:null,sample:null};if(e===null||e.pc!==t.pc||t.ts<=e.ts)return{baseline:t,sample:null};let r=Math.max(0,t.lost-e.lost),i=r+Math.max(0,t.recv-e.recv),a=i>0?Math.min(sH,r/i*100):0,o=Math.max(0,Math.round((t.bytes-e.bytes)*8/(t.ts-e.ts)));return{baseline:t,sample:{rttMs:Math.round(t.rttS*1e3),jitterMs:Math.round(t.jitterS*1e3),estimatedBandwidthKbps:o,packetLossPercent:a,...n.probe===null?{}:{downlinkMbps:n.probe.mbps,downlinkAgeMs:n.probe.ageMs}}}}var lH={urls:`stun:stun.l.google.com:19302`};function uH(e,t){let n=[...e??[],lH];return t===void 0?{iceServers:n}:{iceServers:n,iceTransportPolicy:t}}var dH=8;function fH(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function pH(e){return typeof e==`string`&&e.length>0?e:null}function mH(e,t){if(e===null||t===null)return null;let n=e-t;return n<0?null:n}function hH(e,t){if(e===null||t===null)return null;let n=e+t;return n<=0?null:e/n*100}function gH(e){return e===null?null:/profile-level-id=([0-9a-fA-F]+)/.exec(e)?.[1]??null}function _H(e){let t={inbound:null,codecs:new Map,candidates:new Map,pair:null,selectedPairId:null},n=[];e.forEach(e=>{let r=e,i=pH(r.id);switch(r.type){case`inbound-rtp`:(r.kind??r.mediaType)===`video`&&(t.inbound=r);break;case`codec`:i!==null&&t.codecs.set(i,r);break;case`local-candidate`:case`remote-candidate`:i!==null&&t.candidates.set(i,r);break;case`candidate-pair`:n.push(r);break;case`transport`:t.selectedPairId=pH(r.selectedCandidatePairId);break;default:break}});let r=t.selectedPairId;return t.pair=n.find(e=>pH(e.id)===r)??n.find(e=>e.selected===!0)??n.find(e=>e.nominated===!0&&e.state===`succeeded`)??n.find(e=>e.nominated===!0)??n.find(e=>e.state===`succeeded`)??null,t}function vH(e){return e===null?{timestamp:null,bytesReceived:null,packetsReceived:null,packetsLost:null,framesDecoded:null,framesDropped:null,freezeCount:null,totalFreezesDurationS:null,totalDecodeTimeS:null,nackCount:null,pliCount:null}:{timestamp:fH(e.timestamp),bytesReceived:fH(e.bytesReceived),packetsReceived:fH(e.packetsReceived),packetsLost:fH(e.packetsLost),framesDecoded:fH(e.framesDecoded),framesDropped:fH(e.framesDropped),freezeCount:fH(e.freezeCount),totalFreezesDurationS:fH(e.totalFreezesDuration),totalDecodeTimeS:fH(e.totalDecodeTime),nackCount:fH(e.nackCount),pliCount:fH(e.pliCount)}}var yH={spanMs:null,kbps:null,packetsReceived:null,packetsLost:null,lossPercent:null,framesDecoded:null,framesDropped:null,freezeCount:null,freezeMs:null,nackCount:null,pliCount:null,decodeMs:null};function bH(e,t){if(t===null)return yH;let n=mH(e.timestamp,t.timestamp);if(n===null||n<=0)return yH;let r=mH(e.bytesReceived,t.bytesReceived),i=mH(e.packetsLost,t.packetsLost),a=mH(e.packetsReceived,t.packetsReceived),o=mH(e.framesDecoded,t.framesDecoded),s=mH(e.totalDecodeTimeS,t.totalDecodeTimeS),c=mH(e.totalFreezesDurationS,t.totalFreezesDurationS);return{spanMs:n,kbps:r===null?null:Math.round(r*8/n),packetsReceived:a,packetsLost:i,lossPercent:hH(i,a),framesDecoded:o,framesDropped:mH(e.framesDropped,t.framesDropped),freezeCount:mH(e.freezeCount,t.freezeCount),freezeMs:c===null?null:Math.round(c*1e3),nackCount:mH(e.nackCount,t.nackCount),pliCount:mH(e.pliCount,t.pliCount),decodeMs:s===null||o===null||o<=0?null:s/o*1e3}}function xH(e,t,n,r){if(t===null||n===null)return e;let i=e.at(-1);if(i!==void 0&&i.width===t&&i.height===n)return e;let a=[...e,{width:t,height:n,at:r}];return a.length>dH?a.slice(a.length-dH):a}function SH(e){let{inbound:t,codecs:n,candidates:r,pair:i}=_H(e.report),a=vH(t),o=t===null?void 0:n.get(pH(t.codecId)??``),s=pH(o?.mimeType),c=pH(o?.sdpFmtpLine),l=i===null?void 0:r.get(pH(i.localCandidateId)??``),u=i===null?void 0:r.get(pH(i.remoteCandidateId)??``),d=pH(l?.candidateType),f=pH(u?.candidateType),p=fH(t?.frameWidth),m=fH(t?.frameHeight),h=a.totalFreezesDurationS,g=a.totalDecodeTimeS,_=a.framesDecoded;return{at:e.now,hasInboundVideo:t!==null,width:p,height:m,fps:fH(t?.framesPerSecond),codec:s===null?null:s.split(`/`)[1]??s,codecProfileLevelId:gH(c),jitterMs:CH(t),packetsReceived:a.packetsReceived,packetsLost:a.packetsLost,lossPercent:hH(a.packetsLost,a.packetsReceived),nackCount:a.nackCount,pliCount:a.pliCount,framesDecoded:_,framesDropped:a.framesDropped,freezeCount:a.freezeCount,totalFreezeMs:h===null?null:Math.round(h*1e3),avgDecodeMs:g===null||_===null||_<=0?null:g/_*1e3,rttMs:wH(i),availableIncomingKbps:TH(i),localCandidateType:d,remoteCandidateType:f,candidatePairType:d===null&&f===null?null:`${d??`?`}/${f??`?`}`,candidateProtocol:pH(l?.protocol),iceConnectionState:e.iceConnectionState,dtlsState:e.dtlsState,window:bH(a,e.prev?.raw??null),resolutionLog:xH(e.prev?.resolutionLog??[],p,m,e.now),raw:a}}function CH(e){let t=fH(e?.jitter);return t===null?null:t*1e3}function wH(e){let t=fH(e?.currentRoundTripTime);return t===null?null:t*1e3}function TH(e){let t=fH(e?.availableIncomingBitrate);return t===null?null:Math.round(t/1e3)}var EH={unknown:`no window yet`,decoding:`decoding`,"decoder-stall":`DECODER STALL — bytes arriving, no frames out`,"transport-stall":`TRANSPORT STALL — nothing arriving`,"frozen-unknown":`frames stopped — byte rate unknown`};function DH(e){let t=OH(e);return{kind:t,label:EH[t]}}function OH(e){if(e===null||!e.hasInboundVideo)return`unknown`;let t=e.window.framesDecoded;if(t===null)return`unknown`;if(t>0)return`decoding`;let n=e.window.kbps;return n===null?`frozen-unknown`:n>0?`decoder-stall`:`transport-stall`}E();var kH=`—`;function AH(e,t){if(e==null||!Number.isFinite(e))return kH;let n=t?.digits??0;return`${e.toFixed(n)}${t?.suffix??``}`}function jH(e){return e==null||e===``?kH:e}function MH(e,t){return e==null?kH:e?t(`uiLibrary.streamDebugOverlay.yes`,`yes`):t(`uiLibrary.streamDebugOverlay.no`,`no`)}function NH(e,t,n){if(e===null)return kH;let r=Math.max(0,t-e);return r<1e3?n(`uiLibrary.streamDebugOverlay.msAgo`,`{{value}}ms ago`,{value:r}):r<6e4?n(`uiLibrary.streamDebugOverlay.sAgo`,`{{value}}s ago`,{value:(r/1e3).toFixed(1)}):n(`uiLibrary.streamDebugOverlay.msAgoLong`,`{{minutes}}m{{seconds}}s ago`,{minutes:Math.floor(r/6e4),seconds:Math.floor(r%6e4/1e3)})}var PH=3e3,FH={unknown:`bg-white/15 text-white/70`,decoding:`bg-emerald-500/25 text-emerald-200`,"decoder-stall":`bg-amber-500/30 text-amber-100`,"transport-stall":`bg-rose-500/30 text-rose-100`,"frozen-unknown":`bg-white/15 text-white/70`};function IH({label:e,value:t,window:n,strong:r=!1}){return c(`div`,{className:`flex items-baseline justify-between gap-2 leading-[1.25]`,children:[v(`span`,{className:`text-white/55 shrink-0`,children:e}),c(`span`,{className:`flex items-baseline gap-1 text-right`,children:[v(`span`,{className:r?`text-white font-semibold tabular-nums`:`text-white/90 tabular-nums`,children:t}),n!==void 0&&v(`span`,{className:`text-sky-300/80 tabular-nums`,children:n})]})]})}function LH({title:e,measuredAt:t,now:n}){let r=q(),i=t!==null&&n-t>PH;return c(`div`,{className:`flex items-baseline justify-between gap-3 mt-2 first:mt-0 pb-0.5 border-b border-white/20`,children:[v(`span`,{className:`text-white/80 font-semibold tracking-wide uppercase text-[9px]`,children:e}),c(`span`,{className:i?`text-amber-300 text-[9px]`:`text-white/45 text-[9px]`,children:[i?`${r(`uiLibrary.streamDebugOverlay.staleUpper`,`STALE`)} · `:``,NH(t,n,r)]})]})}var RH={unknown:`bg-white/50`,decoding:`bg-emerald-400`,"decoder-stall":`bg-amber-400`,"transport-stall":`bg-rose-400`,"frozen-unknown":`bg-white/50`};function zH(e){let t=q(),{stats:n,server:r,serverError:i,serverWired:a,now:o,sessionId:s}=e,l=DH(n),u=n?.window,[d,f]=C(!1),p=n!==null&&o-n.at>PH;return d?c(`div`,{className:`absolute bottom-10 left-2 z-20 transform-gpu w-[13.5rem] max-h-[70%] overflow-y-auto rounded-md bg-neutral-950/95 ring-1 ring-white/25 shadow-lg px-1.5 py-1 text-[9px] font-mono text-white/90 select-text`,"data-testid":`stream-debug-overlay`,children:[v(`button`,{type:`button`,onClick:()=>f(!1),className:`w-full text-left rounded px-1.5 py-0.5 mb-1 text-[9px] font-semibold ${FH[l.kind]}`,children:l.label}),v(LH,{title:`decode`,measuredAt:n?.at??null,now:o}),v(IH,{label:`framesDecoded`,value:AH(n?.framesDecoded),window:u?.framesDecoded===null?void 0:`+${AH(u?.framesDecoded)}`,strong:!0}),v(IH,{label:`freezeCount`,value:AH(n?.freezeCount),strong:!0}),v(IH,{label:`frozen`,value:AH(n?.totalFreezeMs,{suffix:`ms`}),window:u?.freezeMs===null?void 0:`+${AH(u?.freezeMs)}ms`,strong:!0}),v(IH,{label:`pliCount`,value:AH(n?.pliCount),window:u?.pliCount===null?void 0:`+${AH(u?.pliCount)}`,strong:!0}),v(IH,{label:`framesDropped`,value:AH(n?.framesDropped)}),v(IH,{label:`decode`,value:AH(n?.avgDecodeMs,{digits:1,suffix:`ms`}),window:u?.decodeMs===null?void 0:`${AH(u?.decodeMs,{digits:1})}ms`}),v(LH,{title:`picture`,measuredAt:n?.at??null,now:o}),v(IH,{label:`resolution`,value:n?.width!==null&&n?.width!==void 0&&n.height!==null?`${n.width}×${n.height}`:kH}),v(IH,{label:`fps`,value:AH(n?.fps)}),v(IH,{label:`codec`,value:n?.codec===null||n?.codec===void 0?kH:`${n.codec}${n.codecProfileLevelId===null?``:` ${n.codecProfileLevelId}`}`}),(n?.resolutionLog.length??0)>1&&v(`div`,{className:`mt-0.5 text-white/60 leading-tight`,children:n?.resolutionLog.map(e=>c(`div`,{className:`flex justify-between`,children:[c(`span`,{children:[e.width,`×`,e.height]}),v(`span`,{className:`text-white/40`,children:NH(e.at,o,t)})]},`${e.at}-${e.width}x${e.height}`))}),v(LH,{title:`transport`,measuredAt:n?.at??null,now:o}),v(IH,{label:`bitrate`,value:AH(u?.kbps,{suffix:` kbps`})}),v(IH,{label:`rtt`,value:AH(n?.rttMs,{digits:0,suffix:`ms`})}),v(IH,{label:`jitter`,value:AH(n?.jitterMs,{digits:1,suffix:`ms`})}),v(IH,{label:`packetsLost`,value:AH(n?.packetsLost),window:u?.packetsLost===null?void 0:`+${AH(u?.packetsLost)}`}),v(IH,{label:`loss`,value:AH(n?.lossPercent,{digits:2,suffix:`%`}),window:u?.lossPercent===null?void 0:AH(u?.lossPercent,{digits:2,suffix:`%`})}),v(IH,{label:`nackCount`,value:AH(n?.nackCount),window:u?.nackCount===null?void 0:`+${AH(u?.nackCount)}`}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.candidatePair`,`candidate pair`),value:jH(n?.candidatePairType)}),v(IH,{label:`protocol`,value:jH(n?.candidateProtocol)}),v(IH,{label:`ice`,value:jH(n?.iceConnectionState)}),v(IH,{label:`dtls`,value:jH(n?.dtlsState)}),v(LH,{title:`server`,measuredAt:r?.observedAt??null,now:o}),a?i===null?r===null?v(`div`,{className:`text-white/50 leading-tight py-0.5`,children:t(`uiLibrary.streamDebugOverlay.waiting`,`waiting for the first answer…`)}):r.alive?c(P,{children:[v(IH,{label:t(`uiLibrary.streamDebugOverlay.servedRung`,`served rung`),value:jH(r.servedTier),strong:!0}),v(IH,{label:`adaptive`,value:MH(r.adaptive,t)}),v(IH,{label:`source`,value:jH(r.camStreamId)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.sourceKind`,`source kind`),value:r.sourceKind}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.ingestNode`,`ingest node`),value:jH(r.ingestNodeId)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.remote`,`· remote`),value:MH(r.ingestIsRemote,t)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.egressLeg`,`egress leg`),value:r.egressLeg,strong:!0}),v(IH,{label:`codec src→out`,value:`${jH(r.sourceCodec)}→${jH(r.negotiatedCodec)}`}),v(IH,{label:`broker`,value:jH(r.brokerStatus)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.bitrate`,`· bitrate`),value:AH(r.brokerBitrateKbps,{suffix:` kbps`})}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.inputFps`,`· input fps`),value:AH(r.brokerInputFps)}),v(IH,{label:`rtp sent`,value:AH(r.rtpPacketsSent)}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.trackMode`,`track mode`),value:jH(r.trackMode)}),r.lastDecision===null?v(IH,{label:`ladder`,value:r.climbHold?t(`uiLibrary.streamDebugOverlay.held`,`held`):t(`uiLibrary.streamDebugOverlay.neverMoved`,`never moved`)}):c(P,{children:[v(IH,{label:t(`uiLibrary.streamDebugOverlay.ladderMove`,`ladder move`),value:`${r.lastDecision.causeDetail??r.lastDecision.cause}${r.lastDecision.tier===null?``:` → ${r.lastDecision.tier}`}`,strong:!0}),v(IH,{label:t(`uiLibrary.streamDebugOverlay.when`,`· when`),value:NH(r.lastDecision.at,o,t)}),v(IH,{label:`· lossRatio`,value:AH(r.lastDecision.lossRatio,{digits:4})}),v(IH,{label:`· clientKbps`,value:AH(r.lastDecision.clientKbps,{suffix:` kbps`})}),v(IH,{label:`· stalledFor`,value:AH(r.lastDecision.stalledForMs,{suffix:`ms`})}),v(IH,{label:`· serverSending`,value:MH(r.lastDecision.serverSending,t)}),v(IH,{label:`· transcode-down`,value:MH(r.lastDecision.forcedTranscodeDown,t)})]}),r.climbHold?v(IH,{label:`climb`,value:r.climbHold.summary}):null,v(IH,{label:`promotions`,value:AH(r.upgradeCount)}),r.tierFailures.length>0&&v(IH,{label:t(`uiLibrary.streamDebugOverlay.tierFailures`,`tier failures`),value:r.tierFailures.map(e=>`${e.tier}:${e.failures}`).join(` `)})]}):v(`div`,{className:`text-amber-300 leading-tight py-0.5`,children:t(`uiLibrary.streamDebugOverlay.sessionNotFound`,`session not found on the server — it ended, or this node never had it`)}):v(`div`,{className:`text-rose-300 leading-tight py-0.5 break-words`,children:i}):v(`div`,{className:`text-amber-300/90 leading-tight py-0.5`,children:v(gi,{uiKey:`uiLibrary.streamDebugOverlay.notWired`,fallback:`not wired on this surface — this player was mounted without <0>getSessionDebug</0>, so the server half cannot be asked`,components:[v(`span`,{className:`text-white/80`},`fn`)]})}),s!==null&&v(`div`,{className:`mt-1 pt-0.5 border-t border-white/15 text-white/40 break-all leading-tight`,children:s})]}):c(`button`,{type:`button`,onClick:()=>f(!0),className:`absolute bottom-10 left-2 z-20 transform-gpu flex items-center gap-1.5 rounded bg-neutral-950/90 ring-1 ring-white/20 px-1.5 py-0.5 text-[9px] font-mono text-white/85 tabular-nums select-text`,"data-testid":`stream-debug-pill`,title:l.label,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full ${RH[l.kind]}`}),v(`span`,{children:n?.width!==null&&n?.width!==void 0?`${n.width}×${n.height}`:kH}),c(`span`,{children:[AH(n?.fps),`fps`]}),c(`span`,{children:[AH(u?.kbps),`k`]}),p&&v(`span`,{className:`text-amber-300`,children:t(`uiLibrary.streamDebugOverlay.stale`,`stale`)})]})}E();function BH(e,t){e.muted=t;let n=e.srcObject;if(n instanceof MediaStream)for(let e of n.getAudioTracks())e.enabled=!t}function VH(){return typeof window>`u`?!1:window.matchMedia(`(hover: none) and (pointer: coarse)`).matches||typeof navigator<`u`&&navigator.maxTouchPoints>0||`ontouchstart`in window}function HH(e,t,n){let r=0;for(let i=0;i<8;i++)for(let a=0;a<8;a++){let o=Math.min(t-1,Math.floor((a+.5)/8*t)),s=Math.min(n-1,Math.floor((i+.5)/8*n)),{data:c}=e.getImageData(o,s,1,1);.2126*(c[0]??0)+.7152*(c[1]??0)+.0722*(c[2]??0)>12&&r++}return r<=1}function UH(e){let t={};if(typeof window<`u`){let n=window.devicePixelRatio||1;if(e){let r=e.getBoundingClientRect();r.width>0&&r.height>0&&(t.viewportWidth=Math.round(r.width*n),t.viewportHeight=Math.round(r.height*n))}t.viewportWidth===void 0&&(t.viewportWidth=Math.round(window.innerWidth*n),t.viewportHeight=Math.round(window.innerHeight*n)),t.devicePixelRatio=n}return t}var WH=aH({now:()=>Date.now(),ttlMs:3e4});function GH(e){return QV(e,typeof window<`u`?un():void 0)}function KH(e,t,n){let r=GH(e);return r===null?Promise.resolve(void 0):WH.measured(r,()=>nH(r,{onRefused:e=>{WH.firstRefusal(r,e)&&n(r,e)},fetchImpl:(e,n)=>fetch(e,{...n,...t===null?{}:{headers:{authorization:`Bearer ${t}`}}}),now:()=>Date.now()}))}function qH(e){let t=GH(e);return t===null?void 0:WH.cached(t)}function JH(e){let t=GH(e);return t===null?null:WH.latest(t)}function YH(e){return iH({waitFrame:()=>rH({readyState:()=>{let t=e.video();return t!==null&&t.srcObject===e.stream?t.readyState:null},signal:e.signal,sleep:e=>new Promise(t=>setTimeout(t,e)),now:()=>Date.now()}),measure:()=>KH(e.serverUrl,e.authToken,e.onRefused)})}function XH(e,t,n,r){let i={...e,...n===void 0?{}:{downlinkMbps:n},...t};return r?YV(i):i}var ZH=8e3;function QH({serverUrl:e,streamKey:t,label:n,autoPlay:r=!0,muted:i=!0,showControls:a=!0,showStats:o=!1,onDebugStats:s,onPlaybackStats:l,onClientNetworkSample:u,probeAuthToken:d,onConnectTiming:p,className:m=``,onStateChange:h,onError:g,onReconnectAttempt:y,overlay:x,createSession:S,sendAnswer:w,handleOffer:T,getIceServers:E,addIceCandidate:D,getIceCandidates:O,closeSession:k,getSessionState:A,getSessionDebug:j,applyDownlinkProbe:M,reoffer:N,posterUrl:P,hintsOverride:F,onAdaptiveHints:I,reconnectSignal:L,onControlChannel:R,onVideoElement:z,iceTransportPolicy:B,onPeerConnection:V}){let H=q(),U=f(null),ee=f(null),W=f(null),G=f(new Set),te=f(null),ne=f(null),re=f(0),K=f(!0),ie=f(R);ie.current=R;let ae=f(B);ae.current=B;let oe=f(V);oe.current=V;let se=f(z);se.current=z,b(()=>(se.current?.(U.current),()=>se.current?.(null)),[]);let ce=f(I);ce.current=I;let le=f(null),ue=_((e,t,n)=>{let r=ce.current;if(!r)return;let i={phase:e,probeOrigin:n,...t},a=$V(i);a!==le.current&&(le.current=a,r(i))},[]),de=f(M);de.current=M;let fe=_(async(t,n,r)=>{let i=await oH(de.current,t,n);if(!K.current)return;if(i.kind===`unsupported`){r();return}let{outcome:a,tier:o,reason:s}=i.answer;ce.current?.({phase:`probe-in-session`,probeOrigin:GH(e),downlinkMbps:n,probeAnswer:`${a}:${o??`-`}:${s}`})},[e]),pe=_((e,t)=>{ce.current?.({phase:`probe-refused`,probeOrigin:e,probeStatus:t})},[]),me=f(null),he=f(null),ge=f(0),_e=f(!1),ve=f(!1),ye=f(async()=>{}),[be,xe]=C(`idle`),[Se,Ce]=C(``),[we,Te]=C(i),Ee=f(we);Ee.current=we;let[De,Oe]=C(!1),[ke,Ae]=C(!1),je=VH(),[Me,Ne]=C(!0),Pe=f(null),Fe=f(!1);(w||S)&&(Fe.current=!0);let Ie=Fe.current,Le=f(!1);T&&(Le.current=!0);let Re=Le.current,[ze,Be]=C(!1),Ve=f(null),[He,Ue]=C(null),[We,Ge]=C(!1),Ke=_(()=>{let e=U.current;if(!(!e||e.readyState<2||!e.videoWidth||!e.videoHeight))try{let t=document.createElement(`canvas`);t.width=e.videoWidth,t.height=e.videoHeight;let n=t.getContext(`2d`);if(!n||(n.drawImage(e,0,0),HH(n,t.width,t.height)))return;Ve.current=t.toDataURL(`image/jpeg`,.6)}catch{}},[]),qe=_(e=>{xe(e),e===`playing`&&Be(!0),h?.(e)},[h]),Je=_(()=>{if(te.current?.abort(),te.current=null,ne.current&&=(clearTimeout(ne.current),null),he.current&&=(clearTimeout(he.current),null),me.current=null,ve.current=!1,ge.current=0,W.current&&=(W.current.close(),null),k&&G.current.size>0){for(let e of G.current)k(e).catch(()=>{});G.current.clear()}},[k]),Ye=_(()=>{te.current?.abort(),te.current=null,ne.current&&=(clearTimeout(ne.current),null),he.current&&=(clearTimeout(he.current),null),me.current=null,ve.current=!1,ge.current=0},[]),Xe=1e3,Ze=_(e=>{if(!A||!N)return;he.current&&=(clearTimeout(he.current),null);let t=async()=>{if(K.current&&me.current===e){if(!ve.current)try{let{pendingRenegotiation:t}=await A(e);if(K.current&&me.current===e&&t&&t.epoch>ge.current&&!ve.current){ge.current=t.epoch,await ye.current(e,t.target);return}}catch{}!K.current||me.current!==e||(he.current=setTimeout(()=>{t()},Xe))}};he.current=setTimeout(()=>{t()},Xe)},[A,N]),Qe=_(async(t=!1,n=t,r)=>{if(!K.current||!S||!w)return;let i=t?W.current:null,a=t?new Set(G.current):null;t?Ye():Je(),qe(`connecting`);let o=new AbortController;te.current=o;try{let s=XH(UH(ee.current),F,n?r??await KH(e,d??null,pe):void 0,!n);ue(n?`probe-climb`:`cold-start`,s,GH(e));let{sessionId:c,sdpOffer:l,iceServers:u}=await S(s);if(G.current.add(c),!K.current||o.signal.aborted){k?.(c).catch(()=>{}),G.current.delete(c);return}let f=new RTCPeerConnection(uH(u,ae.current));oe.current?.(f),t||(W.current=f);let p=new MediaStream;n||YH({video:()=>U.current,stream:p,signal:o.signal,serverUrl:e,authToken:d??null,onRefused:pe}).then(e=>{e===void 0||!XV(e)||!K.current||o.signal.aborted||_e.current||(_e.current=!0,fe(c,e,()=>{!K.current||o.signal.aborted||Qe(!0,!0,e)}))});let m=!1,h=()=>{if(!(m||!K.current)){if(m=!0,W.current=f,U.current&&(U.current.srcObject=p,BH(U.current,Ee.current),U.current.play().catch(()=>{})),i&&i!==f)try{i.close()}catch{}if(a)for(let e of a)G.current.delete(e),k?.(e).catch(()=>{})}};f.ontrack=e=>{if(console.debug(`[WebRTC] ontrack`,e.track.kind,e.track.readyState),p.addTrack(e.track),t){h();return}U.current&&(U.current.srcObject=p,BH(U.current,Ee.current),U.current.play().catch(()=>{}))},f.oniceconnectionstatechange=()=>{if(!K.current)return;let e=f.iceConnectionState;if(console.debug(`[WebRTC] ICE state:`,e),e===`connected`||e===`completed`)re.current=0,t&&h(),qe(`playing`),U.current?.paused&&(console.debug(`[WebRTC] video was paused at ICE connected — calling play()`),U.current.play().catch(()=>{}));else if(e===`failed`||e===`disconnected`||e===`closed`){if(t&&!m)try{f.close()}catch{}qe(`disconnected`),at()}},f.onicecandidateerror=e=>{console.debug(`[WebRTC] ICE candidate error:`,e)},console.debug(`[WebRTC] Setting remote description (server offer)...`),await f.setRemoteDescription({type:`offer`,sdp:l});let g=await f.createAnswer();if(await f.setLocalDescription(g),console.debug(`[WebRTC] Local description set, waiting for ICE gathering...`),await eU(f),!K.current)return;let _=(f.localDescription?.sdp??``).split(`
|
|
3
3
|
`).filter(e=>e.startsWith(`a=candidate:`)).length;console.debug(`[WebRTC] Sending answer to server`,{localCandidates:_,sessionId:c.slice(0,8)}),await w(c,f.localDescription?.sdp??``),console.debug(`[WebRTC] Answer sent successfully`);let v=f,y=()=>{let e=v.connectionState;if(e===`closed`||e===`failed`)return;let t=U.current;t&&t.readyState===0&&console.log(`[WebRTC] no video data yet (ice=${v.iceConnectionState})`)};setTimeout(y,3e3),setTimeout(y,8e3)}catch(e){if(!K.current)return;let t=e instanceof Error?e.message:String(e);Ce(t),qe(`error`),g?.(t),at()}},[e,t,S,w,Je,Ye,k,qe,g,F,ue,d,pe,fe]),$e=_(async()=>{if(K.current){Je(),qe(`connecting`);try{let n=new RTCPeerConnection({iceServers:[{urls:`stun:stun.l.google.com:19302`}]});W.current=n,n.addTransceiver(`video`,{direction:`recvonly`}),n.addTransceiver(`audio`,{direction:`recvonly`});let r=new MediaStream;n.ontrack=e=>{r.addTrack(e.track),U.current&&(U.current.srcObject=r,BH(U.current,Ee.current),U.current.play().catch(()=>{}))},n.oniceconnectionstatechange=()=>{if(!K.current)return;let e=n.iceConnectionState;e===`connected`||e===`completed`?(re.current=0,qe(`playing`),U.current?.paused&&U.current.play().catch(()=>{})):(e===`failed`||e===`disconnected`||e===`closed`)&&(qe(`disconnected`),at())};let i=await n.createOffer();if(await n.setLocalDescription(i),await eU(n),!K.current)return;let a=`${e}/api/webrtc?src=${encodeURIComponent(t)}`,o=await fetch(a,{method:`POST`,headers:{"Content-Type":`application/sdp`},body:n.localDescription?.sdp??``});if(!o.ok)throw Error(`WHEP ${o.status}: ${o.statusText}`);let s=await o.text();await n.setRemoteDescription({type:`answer`,sdp:s})}catch(e){if(!K.current)return;let t=e instanceof Error?e.message:String(e);Ce(t),qe(`error`),g?.(t),at()}}},[e,t,Je,qe,g]),et=_(async(n=!1,r=n,i)=>{if(!K.current||!T)return;let a=n?W.current:null,o=n?new Set(G.current):null;n?Ye():Je(),qe(`connecting`);let s=new AbortController;te.current=s;let c=performance.now(),l=()=>Math.round(performance.now()-c),u={};try{let c=await E?.();if(u.iceServersMs=l(),!K.current||s.signal.aborted)return;let f=new RTCPeerConnection(uH(c,ae.current));oe.current?.(f),n||(W.current=f);let m=new MediaStream,h=null;r||YH({video:()=>U.current,stream:m,signal:s.signal,serverUrl:e,authToken:d??null,onRefused:pe}).then(e=>{e===void 0||!XV(e)||!K.current||s.signal.aborted||_e.current||(_e.current=!0,fe(h,e,()=>{!K.current||s.signal.aborted||et(!0,!0,e)}))});let g=!1,_=()=>{if(!(g||!K.current)){if(g=!0,W.current=f,U.current&&(U.current.srcObject=m,BH(U.current,Ee.current),U.current.play().catch(()=>{})),a&&a!==f)try{a.close()}catch{}if(o)for(let e of o)G.current.delete(e),k?.(e).catch(()=>{})}};f.ontrack=e=>{if(u.firstTrackMs===void 0&&(u.firstTrackMs=l()),console.debug(`[WebRTC] ontrack (client-offer)`,e.track.kind,e.track.readyState),m.addTrack(e.track),n){_();return}U.current&&(U.current.srcObject=m,BH(U.current,Ee.current),U.current.play().catch(()=>{}))};let v=!1;f.oniceconnectionstatechange=()=>{if(!K.current)return;let e=f.iceConnectionState;if(console.debug(`[WebRTC] ICE state (client-offer):`,e),e===`connected`||e===`completed`){if(!v){v=!0,u.iceConnectedMs=l(),console.info(`[WebRTC timing] client-offer connected`,{streamKey:t,...u}),p?.({...u});let e=U.current;e&&`requestVideoFrameCallback`in e&&(e.requestVideoFrameCallback(()=>{u.firstFrameMs=l(),console.info(`[WebRTC timing] first decoded frame`,{streamKey:t,firstFrameMs:u.firstFrameMs}),p?.({...u})}),setTimeout(()=>{K.current&&u.firstFrameMs===void 0&&(console.warn(`[WebRTC timing] NO decoded frame (stalled)`,{streamKey:t,sinceIceConnectedMs:l()-(u.iceConnectedMs??0),iceConnectedMs:u.iceConnectedMs,firstTrackMs:u.firstTrackMs}),it.current(`no decoded frame after connect`),at())},ZH))}re.current=0,n&&_(),qe(`playing`),U.current?.paused&&U.current.play().catch(()=>{})}else if(e===`failed`||e===`disconnected`||e===`closed`){if(n&&!g)try{f.close()}catch{}qe(`disconnected`),at()}};let y=null,b=[];if(f.onicecandidate=e=>{if(!e.candidate)return;let t=e.candidate.toJSON();y&&D?D(y,t).catch(()=>{}):b.push(t)},f.addTransceiver(`video`,{direction:`recvonly`}),f.addTransceiver(`audio`,{direction:`recvonly`}),ie.current){let e=f.createDataChannel(`camstack-control`);ie.current(e)}let x=await f.createOffer();if(u.offerCreatedMs=l(),await f.setLocalDescription(x),u.localSetMs=l(),!K.current||s.signal.aborted)return;let S=r?i??await KH(e,d??null,pe):void 0,C=XH(UH(ee.current),F,S,!r);ue(r?`probe-climb`:`cold-start`,C,GH(e));let w=l(),{sessionId:A,sdpAnswer:j}=await T(f.localDescription?.sdp??x.sdp??``,void 0,C);if(u.signalingRttMs=l()-w,y=A,h=A,G.current.add(A),me.current=A,!K.current||s.signal.aborted){k?.(A).catch(()=>{}),G.current.delete(A);return}if(D)for(let e of b)D(A,e).catch(()=>{});if(b.length=0,await f.setRemoteDescription({type:`answer`,sdp:j}),u.answerSetMs=l(),console.debug(`[WebRTC] Client-offer answer set (trickle)`,{sessionId:A.slice(0,8)}),O){let e=new Set,t=Date.now(),n=async()=>{if(!(!K.current||s.signal.aborted)&&!(f.connectionState===`closed`||f.signalingState===`closed`)){try{let{candidates:n,done:r}=await O(A);for(let t of n){let n=t.candidate??``;n&&!e.has(n)&&(e.add(n),f.addIceCandidate(new RTCIceCandidate(t)).catch(()=>{}))}let i=f.iceConnectionState;if(r||Date.now()-t>1e4||i===`connected`||i===`completed`)return}catch{}setTimeout(()=>{n()},200)}};n()}Ze(A)}catch(e){if(!K.current)return;let t=e instanceof Error?e.message:String(e);Ce(t),qe(`error`),g?.(t),at()}},[e,T,E,D,O,k,Je,Ye,qe,g,Ze,F,ue,d,pe,fe]);ye.current=_(async(t,n)=>{let r=N;if(!K.current||!r)return;let i=W.current;ve.current=!0;try{let a=await E?.();if(!K.current)return;let o=new RTCPeerConnection(uH(a,ae.current));oe.current?.(o);let s=new MediaStream,c=!1,l=!1,u=null,d,f,p=()=>{f!==void 0&&(clearTimeout(f),f=void 0);let e=u;if(u=null,e){d!==void 0&&typeof e.cancelVideoFrameCallback==`function`&&e.cancelVideoFrameCallback(d),e.removeEventListener(`loadeddata`,m);try{e.srcObject=null}catch{}e.remove()}};function m(){if(c||!K.current){p();return}c=!0,W.current=o,U.current&&(U.current.srcObject=s,U.current.play().catch(()=>{})),i&&i!==o&&i.close(),p()}let h=()=>{if(l||c||!K.current)return;if(l=!0,typeof document>`u`){m();return}let e=document.createElement(`video`);e.muted=!0,e.playsInline=!0,e.autoplay=!0,e.style.cssText=`position:absolute;left:-9999px;top:0;width:1px;height:1px;opacity:0;pointer-events:none;`,e.srcObject=s,u=e,(ee.current??document.body).appendChild(e),e.play().catch(()=>{}),typeof e.requestVideoFrameCallback==`function`&&(d=e.requestVideoFrameCallback(()=>m())),e.addEventListener(`loadeddata`,m,{once:!0}),f=setTimeout(()=>m(),1800)};o.ontrack=e=>{console.debug(`[WebRTC] ontrack (reoffer)`,e.track.kind,e.track.readyState),s.addTrack(e.track),h()},o.oniceconnectionstatechange=()=>{if(!K.current)return;let e=o.iceConnectionState;console.debug(`[WebRTC] ICE state (reoffer):`,e),e===`connected`||e===`completed`?(re.current=0,h(),qe(`playing`),U.current?.paused&&U.current.play().catch(()=>{})):(e===`failed`||e===`closed`)&&(p(),!c&&e===`failed`&&o.close(),qe(`disconnected`),at())};let g=null,_=[];if(o.onicecandidate=e=>{if(!e.candidate)return;let t=e.candidate.toJSON();g&&D?D(g,t).catch(()=>{}):_.push(t)},o.addTransceiver(`video`,{direction:`recvonly`}),o.addTransceiver(`audio`,{direction:`recvonly`}),ie.current){let e=o.createDataChannel(`camstack-control`);ie.current(e)}let v=await o.createOffer();if(await o.setLocalDescription(v),!K.current){o.close();return}let y=qH(e),b={...UH(ee.current),...y===void 0?{}:{downlinkMbps:y},...F};ue(`renegotiate`,b,GH(e));let{sessionId:x,sdpAnswer:S}=await r(t,o.localDescription?.sdp??v.sdp??``,n,b);if(!K.current){o.close();return}if(g=x,G.current.add(x),me.current=x,D)for(let e of _)D(x,e).catch(()=>{});if(_.length=0,await o.setRemoteDescription({type:`answer`,sdp:S}),O){let e=new Set,t=Date.now(),n=async()=>{if(K.current&&!(o.connectionState===`closed`||o.signalingState===`closed`)){try{let{candidates:n,done:r}=await O(x);for(let t of n){let n=t.candidate??``;n&&!e.has(n)&&(e.add(n),o.addIceCandidate(new RTCIceCandidate(t)).catch(()=>{}))}let i=o.iceConnectionState;if(r||Date.now()-t>1e4||i===`connected`||i===`completed`)return}catch{}setTimeout(()=>{n()},200)}};n()}Ze(x)}catch(e){console.debug(`[WebRTC] reoffer failed; keeping last frame, re-arming poll`,e instanceof Error?e.message:String(e)),Ze(t)}finally{ve.current=!1}},[e,N,E,D,O,qe,Ze,F,ue]);let tt=Re?et:Ie?Qe:$e,nt=f(()=>{}),rt=f(y);rt.current=y;let it=f(()=>{});it.current=e=>{console.warn(`[WebRTC] hard error`,{streamKey:t,msg:e}),Ce(e),g?.(e),qe(`error`)},nt.current=tt;let at=_(()=>{if(!K.current)return;let e=re.current,t=HV(e);if(rt.current?.(t),t.kind===`exhausted`){it.current(`reconnect attempts exhausted (${t.attempts})`);return}re.current+=1,ne.current=setTimeout(()=>{K.current&&nt.current()},t.delayMs)},[]);b(()=>(K.current=!0,re.current=0,r&&tt(),()=>{K.current=!1,Je()}),[]);let ot=f(!1);b(()=>{if(r){if(Re){if(!T)return}else if(Ie){if(!S||!w)return}else return;ot.current||W.current||(ot.current=!0,tt())}},[r,Re,Ie,T,S,w,tt]);let st=()=>{re.current=0,tt()},ct=()=>{if(re.current=0,W.current&&Re){et(!0);return}if(W.current&&Ie){Qe(!0);return}tt()},lt=f(e),ut=f(t);b(()=>{let n=lt.current!==e,r=ut.current!==t;if(lt.current=e,ut.current=t,!(!n&&!r)&&K.current){if(re.current=0,_e.current=!1,n){Je(),tt();return}ct()}},[e,t]);let dt=f(L);b(()=>{dt.current!==L&&(dt.current=L,K.current&&ct())},[L]);let ft=()=>{if(U.current){let e=!U.current.muted;BH(U.current,e),Te(e)}},pt=async()=>{if(ee.current)try{if(document.fullscreenElement){await document.exitFullscreen();return}if(ee.current.requestFullscreen){await ee.current.requestFullscreen();return}let e=U.current;e?.webkitEnterFullscreen&&e.webkitEnterFullscreen()}catch(e){console.warn(`Fullscreen toggle failed: ${e instanceof Error?e.message:e}`)}},mt=async()=>{let e=U.current;if(e)try{if(typeof e.webkitSetPresentationMode==`function`){e.webkitSetPresentationMode(e.webkitPresentationMode===`picture-in-picture`?`inline`:`picture-in-picture`);return}document.pictureInPictureElement?await document.exitPictureInPicture():await e.requestPictureInPicture()}catch(e){console.warn(`PiP toggle failed: ${e instanceof Error?e.message:String(e)}`)}},ht=()=>{if(!U.current)return;let e=document.createElement(`canvas`);e.width=U.current.videoWidth||1280,e.height=U.current.videoHeight||720;let n=e.getContext(`2d`);if(!n)return;n.drawImage(U.current,0,0);let r=document.createElement(`a`);r.download=`${t.replace(/[/:]/g,`-`)}-${Date.now()}.jpg`,r.href=e.toDataURL(`image/jpeg`,.92),r.click()};b(()=>{let e=()=>Oe(!!document.fullscreenElement);document.addEventListener(`fullscreenchange`,e);let t=U.current;return t?.addEventListener(`webkitbeginfullscreen`,e),t?.addEventListener(`webkitendfullscreen`,e),()=>{document.removeEventListener(`fullscreenchange`,e),t?.removeEventListener(`webkitbeginfullscreen`,e),t?.removeEventListener(`webkitendfullscreen`,e)}},[]),b(()=>{let e=U.current,t=typeof document<`u`&&document.pictureInPictureEnabled===!0,n=e!==null&&typeof e.webkitSetPresentationMode==`function`;Ae(t||n)},[]);let[gt,_t]=C(null),[vt,yt]=C(null),[bt,xt]=C(null),[St,Ct]=C(()=>Date.now()),wt=o||s!==void 0;b(()=>{if(!o)return;let e=setInterval(()=>Ct(Date.now()),500);return()=>clearInterval(e)},[o]),b(()=>{if(!wt){_t(null);return}let e={current:null},t=!1,n=async()=>{let n=W.current;if(n)try{let r=await n.getStats();if(t)return;let i=SH({report:r,prev:e.current,now:Date.now(),iceConnectionState:n.iceConnectionState,dtlsState:n.connectionState});e.current=i,_t(i)}catch{}};n();let r=setInterval(()=>{n()},1e3);return()=>{t=!0,clearInterval(r)}},[wt]),b(()=>{if(!wt||!j){yt(null),xt(null);return}let e=!1,t=async()=>{let t=me.current;if(t===null){xt(`no session id on this player yet — nothing to ask the server about`);return}try{let n=await j(t);if(e)return;yt(n),xt(null)}catch(t){if(e)return;xt(t instanceof Error?t.message:String(t))}};t();let n=setInterval(()=>{t()},1e3);return()=>{e=!0,clearInterval(n)}},[wt,j]);let Tt=f(s);Tt.current=s,b(()=>{if(s===void 0)return;let e=()=>{Tt.current?.({at:Date.now(),verdict:DH(Et.current).kind,sessionId:me.current,stats:Et.current,server:Dt.current,serverError:Ot.current,serverWired:j!==void 0})};e();let t=setInterval(e,1e3);return()=>clearInterval(t)},[s===void 0,j]);let Et=f(null);Et.current=gt;let Dt=f(null);Dt.current=vt;let Ot=f(null);Ot.current=bt;let kt=f(null);b(()=>{if(!u){kt.current=null;return}let t=async()=>{let t=W.current;if(t)try{let n=await t.getStats(),r=0,i=0,a=0,o=0,s=0,c=0;n.forEach(e=>{let t=e;t.type===`inbound-rtp`&&(t.kind??t.mediaType)===`video`?(r=t.packetsLost??0,i=t.packetsReceived??0,a=t.bytesReceived??0,o=t.timestamp,s=t.jitter??0):t.type===`candidate-pair`&&t.nominated&&typeof t.currentRoundTripTime==`number`&&(c=t.currentRoundTripTime)});let l=cH(kt.current,{pc:t,lost:r,recv:i,bytes:a,ts:o,rttS:c,jitterS:s},{renegotiating:ve.current,probe:JH(e)});kt.current=l.baseline,l.sample!==null&&u(l.sample)}catch{}},n=setInterval(()=>{t()},2e3);return()=>clearInterval(n)},[u,e]);let At=f(null);b(()=>{if(!l){At.current=null;return}let e=async()=>{let e=W.current,t=U.current;if(e)try{let n=await e.getStats(),r=0,i=0,a=0,o=0,s=0,c=0,u=0,d=0;n.forEach(e=>{let t=e;t.type===`inbound-rtp`&&(t.kind??t.mediaType)===`video`&&(r=t.framesReceived??0,i=t.framesDecoded??0,a=t.framesDropped??0,o=t.framesPerSecond??0,s=t.freezeCount??0,c=t.totalFreezesDuration??0,u=t.jitterBufferDelay??0,d=t.jitterBufferEmittedCount??0)});let f=t?.currentTime??0,p=Date.now(),m=At.current,h=d>0?Math.round(u/d*1e3):0;m&&l({dRecv:r-m.recv,dDec:i-m.dec,dDrop:a-m.drop,fps:Math.round(o),dFreeze:s-m.freeze,freezeTotalMs:Math.round(c*1e3),avgJitterMs:h,dCtMs:Math.round((f-m.ct)*1e3),dtMs:p-m.ts,readyState:t?.readyState??-1}),At.current={recv:r,dec:i,drop:a,freeze:s,ct:f,ts:p}}catch{}};e();let t=setInterval(()=>{e()},5e3);return()=>clearInterval(t)},[l]),b(()=>{Te(i);let e=U.current;e&&(BH(e,i),i||e.play().catch(()=>{}))},[i]);let jt=()=>{je||(Ne(!0),Pe.current&&clearTimeout(Pe.current),Pe.current=setTimeout(()=>Ne(!1),3e3))},Mt=()=>{Ne(e=>!e),Pe.current&&clearTimeout(Pe.current)};b(()=>{if(be===`playing`){Ke();let e=setInterval(Ke,2e3);return()=>clearInterval(e)}ze&&Ve.current&&Ue(Ve.current)},[be,ze,Ke]),b(()=>{if(be!==`playing`){Ge(!1);return}let e=U.current;if(!e)return;let t=!1,n=()=>{t||Ge(!0)},r;typeof e.requestVideoFrameCallback==`function`&&(r=e.requestVideoFrameCallback(()=>n())),e.addEventListener(`loadeddata`,n,{once:!0});let i=setTimeout(n,12e3);return()=>{t=!0,clearTimeout(i),r!==void 0&&typeof e.cancelVideoFrameCallback==`function`&&e.cancelVideoFrameCallback(r),e.removeEventListener(`loadeddata`,n)}},[be]);let Nt=ze&&He?He:P??null,Pt=!We&&Nt!==null;return c(`div`,{ref:ee,className:`relative isolate bg-black overflow-hidden group ${m}`,onMouseMove:jt,onMouseEnter:jt,onTouchStart:Mt,children:[v(`video`,{ref:U,autoPlay:r,muted:we,playsInline:!0,className:`w-full h-full object-contain relative z-0`}),Pt&&Nt&&v(`img`,{src:Nt,alt:``,className:`absolute inset-0 w-full h-full object-contain z-[5] transform-gpu pointer-events-none`}),n&&be===`playing`&&v(`div`,{className:`absolute top-2 left-2 z-10 transform-gpu px-2 py-0.5 rounded bg-black/60 text-[10px] text-white font-medium`,children:n}),o&&v(zH,{stats:gt,server:vt,serverError:bt,serverWired:j!==void 0,now:St,sessionId:me.current}),x,a&&!Nt&&be===`connecting`&&c(`div`,{className:`absolute inset-0 z-10 transform-gpu flex flex-col items-center justify-center bg-black/70 gap-2`,children:[v(`svg`,{className:`h-6 w-6 text-white/60 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:v(`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]`})}),v(`span`,{className:`text-xs text-white/60`,children:H(`uiLibrary.cameraStreamPlayer.connecting`,`Connecting…`)})]}),a&&!Nt&&(be===`error`||be===`disconnected`)&&c(`div`,{className:`absolute inset-0 z-10 transform-gpu flex flex-col items-center justify-center bg-black/70 gap-2`,children:[v(`svg`,{className:`h-6 w-6 text-red-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:v(`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`})}),v(`span`,{className:`text-xs text-red-400 text-center px-4`,children:be===`error`?Se||H(`uiLibrary.cameraStreamPlayer.failed`,`Connection failed`):H(`uiLibrary.cameraStreamPlayer.disconnected`,`Disconnected`)}),v(`button`,{onClick:st,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:H(`uiLibrary.cameraStreamPlayer.reconnect`,`Reconnect`)})]}),a&&Nt&&(be===`connecting`||be===`disconnected`)&&v(`div`,{className:`absolute top-2 left-2 z-10 transform-gpu flex h-6 w-6 items-center justify-center rounded-full bg-black/55`,children:v(`svg`,{className:`h-3.5 w-3.5 text-white/90 animate-spin`,viewBox:`0 0 24 24`,fill:`none`,children:v(`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]`})})}),a&&Nt&&be===`error`&&v(`button`,{onClick:st,title:Se||H(`uiLibrary.cameraStreamPlayer.reconnect`,`Reconnect`),className:`absolute top-2 left-2 z-10 transform-gpu flex h-6 w-6 items-center justify-center rounded-full bg-black/55 text-white/90 hover:bg-black/75 transition-colors`,children:c(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`path`,{d:`M23 4v6h-6M1 20v-6h6`}),v(`path`,{d:`M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15`})]})}),a&&be!==`idle`&&be!==`error`&&c(`div`,{className:`absolute bottom-0 inset-x-0 z-20 transform-gpu flex items-center justify-between px-3 py-1.5 bg-gradient-to-t from-black/80 to-transparent transition-opacity duration-200 ${je||Me?`opacity-100 pointer-events-auto`:`opacity-0 pointer-events-none`}`,children:[v(`div`,{className:`flex items-center gap-1`,children:v($H,{onClick:ft,title:we?H(`uiLibrary.cameraStreamPlayer.unmute`,`Unmute`):H(`uiLibrary.cameraStreamPlayer.mute`,`Mute`),children:we?c(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[v(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),v(`line`,{x1:`23`,y1:`9`,x2:`17`,y2:`15`}),v(`line`,{x1:`17`,y1:`9`,x2:`23`,y2:`15`})]}):c(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[v(`polygon`,{points:`11 5 6 9 2 9 2 15 6 15 11 19 11 5`}),v(`path`,{d:`M19.07 4.93a10 10 0 010 14.14M15.54 8.46a5 5 0 010 7.07`})]})})}),c(`div`,{className:`flex items-center gap-1`,children:[v($H,{onClick:ht,title:H(`uiLibrary.cameraStreamPlayer.snapshot`,`Take snapshot`),children:c(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:[v(`path`,{d:`M23 19a2 2 0 01-2 2H3a2 2 0 01-2-2V8a2 2 0 012-2h4l2-3h6l2 3h4a2 2 0 012 2z`}),v(`circle`,{cx:`12`,cy:`13`,r:`4`})]})}),ke&&v($H,{onClick:mt,title:H(`uiLibrary.cameraStreamPlayer.pip`,`Picture-in-Picture`),children:c(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`path`,{d:`M21 9V6a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2h4`}),v(`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`})]})}),v($H,{onClick:pt,title:De?H(`uiLibrary.cameraStreamPlayer.exitFullscreen`,`Exit fullscreen`):H(`uiLibrary.cameraStreamPlayer.fullscreen`,`Fullscreen`),children:De?v(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:v(`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`})}):v(`svg`,{className:`h-3.5 w-3.5`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,children:v(`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 $H({onClick:e,title:t,children:n}){return v(`button`,{onClick:e,title:t,className:`rounded-full p-1.5 min-w-[44px] min-h-[44px] flex items-center justify-center text-white/80 hover:text-white hover:bg-white/20 active:bg-white/30 transition-colors`,children:n})}async function eU(e){if(e.iceGatheringState!==`complete`)return new Promise(t=>{let n=!1,r,i=()=>{n||(n=!0,r&&clearInterval(r),e.removeEventListener(`icegatheringstatechange`,a),t())},a=()=>{e.iceGatheringState===`complete`&&i()};e.addEventListener(`icegatheringstatechange`,a);let o=Date.now();r=setInterval(()=>{let t=e.localDescription?.sdp??``;/ typ host/.test(t)&&Date.now()-o>=600&&i()},100),setTimeout(i,2500)})}function tU({page:e,labels:t,onPageChange:n}){let r=e.page===0,i=e.page>=e.pageCount-1;return c(`nav`,{"aria-label":t.navLabel,className:`flex items-center justify-end gap-2 pt-2`,children:[v(`span`,{"aria-live":`polite`,className:`text-[11px] tabular-nums text-foreground-subtle`,children:t.range(e.from,e.to,e.total)}),v(Rl,{type:`button`,variant:`outline`,size:`sm`,icon:ge,"aria-label":t.previous,title:t.previous,disabled:r,onClick:()=>n(e.page-1)}),v(Rl,{type:`button`,variant:`outline`,size:`sm`,icon:It,"aria-label":t.next,title:t.next,disabled:i,onClick:()=>n(e.page+1)})]})}function nU(e,t,n){let r=Math.max(1,Math.floor(n)),i=e.length,a=Math.max(1,Math.ceil(i/r)),o=Math.min(Math.max(0,Math.floor(t)),a-1),s=o*r,c=e.slice(s,s+r);return{pageRows:c,page:o,pageCount:a,from:c.length===0?0:s+1,to:s+c.length,total:i}}var rU={navLabel:`Table pages`,previous:`Previous page`,next:`Next page`,range:(e,t,n)=>`${e}–${t} of ${n}`};E();var iU=`__select`,aU=`cursor-pointer align-middle`;function oU({checked:e,indeterminate:t,disabled:n,label:r,onToggle:i}){let a=f(null);return b(()=>{a.current!==null&&(a.current.indeterminate=t)},[t]),v(BB,{ref:a,"aria-label":r,checked:e,disabled:n,onChange:i,className:aU})}function sU(e,t,n){let r=e.isSelectable??(()=>!0),i=t.filter(r).map(n),a=i.filter(t=>e.selected.has(t)).length,o=i.length>0&&a===i.length,s=()=>{let t=new Set(e.selected);for(let e of i)o?t.delete(e):t.add(e);e.onChange(t)},c=t=>{let n=new Set(e.selected);n.has(t)?n.delete(t):n.add(t),e.onChange(n)};return{key:iU,width:`w-8`,headerRender:()=>v(oU,{checked:o,indeterminate:a>0&&!o,disabled:i.length===0,label:e.pageLabel,onToggle:s}),render:t=>{if(!r(t))return null;let i=n(t);return v(BB,{"aria-label":e.rowLabel(t),checked:e.selected.has(i),onChange:()=>c(i),onClick:e=>e.stopPropagation(),className:aU})}}}function cU({label:e,active:t,dir:n,onSort:r}){return c(`button`,{type:`button`,onClick:r,className:`group/sort inline-flex items-center gap-0.5 hover:text-foreground transition-colors`,children:[v(`span`,{children:e}),t?v(n===`asc`?Ei:de,{className:`h-3 w-3 flex-shrink-0`}):v(Ei,{className:$(`h-3 w-3 flex-shrink-0 opacity-0 transition-opacity`,`group-hover/sort:opacity-30`)})]})}function lU(e,t){return!e||t===null?`asc`:t===`asc`?`desc`:null}function uU(e,t){let n=lU(e!==null&&e.columnKey===t,e===null?null:e.dir);return n===null?null:{columnKey:t,dir:n}}function dU(e,t){return typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t))}function fU(e,t,n){if(t===null)return[...e];let r=t.dir===`asc`?1:-1;return e.toSorted((e,t)=>{let i=n(e),a=n(t);return i===null||a===null?i===a?0:i===null?1:-1:r*dU(i,a)})}function pU(e,t){return e===null||e.columnKey!==t?`none`:e.dir===`asc`?`ascending`:`descending`}E();var mU=`max-h-[60vh]`,hU={left:`text-left`,right:`text-right`,center:`text-center`};function gU({columns:e,rows:t,rowKey:n,onRowClick:r,minWidthPx:i=480,emptyMessage:a,className:o,bordered:s=!0,rowClassName:l,maxBodyHeight:u,fill:f=!1,defaultSort:m,sort:h,onSortChange:g,pageSize:_,page:y,onPageChange:b,paginationLabels:x=rU,selection:S,renderExpanded:w,isExpanded:T}){let[E,D]=C(m??null),[O,k]=C(0),A=h===void 0?E:h,j=e=>{h===void 0&&D(e),g?.(e)},M=e=>{y===void 0&&k(e),b?.(e)},N=f||u!==void 0,P=f?`h-full min-h-0`:u??``,F=p(()=>A===null?void 0:e.find(e=>e.key===A.columnKey&&e.sortValue!==void 0),[e,A]),I=F?.sortValue,L=p(()=>I===void 0?t:fU(t,A,I),[t,A,I]),R=F===void 0?null:A,z=_===void 0?null:nU(L,y??O,_),B=z===null?L:z.pageRows,V=z!==null&&z.pageCount>1?v(tU,{page:z,labels:x,onPageChange:M}):null,H=S===void 0?e:[sU(S,B,e=>String(n?n(e,t.indexOf(e)):t.indexOf(e))),...e];if(t.length===0&&a)return v(`div`,{className:`rounded-lg ${s?`border border-border`:``} bg-surface px-3 py-4 text-xs text-foreground-subtle text-center ${o??``}`,children:a});if(t.length===0)return null;let U=v(`div`,{className:[`rounded-lg`,s?`border border-border`:``,`bg-surface overflow-x-auto`,N?`${P} overflow-y-auto`:``,f?`min-h-0 flex-1`:``,!f&&V===null?o??``:``].filter(Boolean).join(` `),children:c(`table`,{className:`w-full text-xs ${N?`border-separate border-spacing-0`:``}`,style:{minWidth:`${i}px`},children:[v(`thead`,{className:`bg-surface`,children:v(`tr`,{children:H.map(e=>{let t=e.align??`left`,n=e.nowrap??!0,r=e.sortValue!==void 0,i=R!==null&&R.columnKey===e.key;return v(`th`,{"aria-sort":r?pU(R,e.key):void 0,title:r?void 0:e.notSortableReason,className:[`px-3 py-2 text-foreground-subtle font-medium bg-surface border-b border-border`,N?`sticky top-0 z-10`:``,hU[t],n?`whitespace-nowrap`:``,e.width??``].filter(Boolean).join(` `),children:r?v(cU,{label:e.headerRender?e.headerRender():e.header,active:i,dir:i&&R!==null?R.dir:`asc`,onSort:()=>j(uU(A,e.key))}):e.headerRender?e.headerRender():e.header},e.key)})})}),v(`tbody`,{children:B.map((e,t)=>{let i=n?n(e,t):t,a=l?.(e,t)??``,o=r!==void 0,s=w!==void 0&&T?.(e)===!0?w(e,t):null;return c(d,{children:[v(`tr`,{onClick:o?()=>r(e,t):void 0,className:[o?`cursor-pointer hover:bg-primary/5`:`hover:bg-primary/5`,a].filter(Boolean).join(` `),children:H.map(n=>{let r=n.align??`left`,i=n.nowrap??!0;return v(`td`,{"data-cell":n.key,className:[`px-3 py-2 text-foreground border-b border-border`,hU[r],i?`whitespace-nowrap`:``].filter(Boolean).join(` `),children:n.render(e,t)},n.key)})}),s!==null&&v(`tr`,{"data-expanded-row":``,className:`bg-surface`,children:v(`td`,{colSpan:H.length,className:`border-b border-border px-3 py-2`,children:s})})]},i)})})]})});return V===null?f?v(`div`,{className:`flex min-h-0 flex-1 flex-col ${o??``}`,children:U}):U:c(`div`,{className:f?`flex min-h-0 flex-1 flex-col ${o??``}`:o,children:[U,V]})}function _U({label:e,children:t,actions:n,elements:r=`plain`,className:i,valueClassName:a}){let o=r===`description`?`dt`:`span`,s=r===`description`?`dd`:`div`;return c(`div`,{"data-setting-row":``,className:$(H,i),children:[v(o,{"data-setting-row-label":``,className:lr,children:e}),c(s,{"data-setting-row-value":``,className:at,children:[v(`span`,{"data-setting-row-value-text":``,className:$(ht,a),children:t}),n!==void 0&&v(`span`,{className:`flex shrink-0 items-center gap-0.5`,children:n})]})]})}function vU({items:e,className:t}){return v(`dl`,{className:$(`flex flex-col`,t),children:e.map(e=>v(_U,{elements:`description`,label:e.key,children:e.value},e.key))})}function yU({headingId:e,title:t,icon:n,actions:r,testId:i,children:a}){return c(`section`,{"aria-labelledby":e,className:ut,"data-testid":i,children:[c(`header`,{className:`${mr} flex min-h-9 flex-wrap items-center gap-2`,children:[n!==void 0&&v(n,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),v(`h2`,{id:e,className:`${Ut} min-w-0 flex-1`,children:t}),r]}),a]})}var bU=[`host`,`srflx`,`prflx`,`relay`];function xU(e){if(e===void 0||!/^\d+$/.test(e))return null;let t=Number(e);return Number.isSafeInteger(t)?t:null}function SU(e){return e.length===0?`unknown`:e.toLowerCase().endsWith(`.local`)?`mdns`:e.includes(`:`)?`ipv6`:/^\d{1,3}(\.\d{1,3}){3}$/.test(e)?`ipv4`:`unknown`}function CU(e){let t=e.split(`.`);if(t.length!==4)return null;let n=t.map(e=>Number(e));return n.every(e=>Number.isInteger(e)&&e>=0&&e<=255)?n:null}function wU(e){let t=CU(e);if(t===null)return`unknown`;let[n=-1,r=-1]=t;return n===127?`loopback`:n===169&&r===254?`link-local`:n===10||n===192&&r===168||n===172&&r>=16&&r<=31?`lan`:n===100&&r>=64&&r<=127?`tailscale`:`public`}function TU(e){let t=e.toLowerCase();return t===`::1`?`loopback`:/^fe[89ab]/.test(t)?`link-local`:t.startsWith(`fd7a:115c:a1e0:`)?`tailscale`:/^f[cd]/.test(t)?`lan`:`public`}function EU(e){switch(SU(e)){case`mdns`:return`mdns`;case`ipv4`:return wU(e);case`ipv6`:return TU(e);default:return`unknown`}}function DU(e){let t=e.trim().replace(/^a=/,``);if(!t.startsWith(`candidate:`))return null;let n=t.slice(10).split(/\s+/),r=n[4]??``,i=n.indexOf(`typ`),a=i>=0?n[i+1]:void 0,o=bU.find(e=>e===a)??`unknown`,s=n.indexOf(`raddr`),c=n.indexOf(`rport`),l=n[2]?.toLowerCase();return{type:o,protocol:l!==void 0&&l.length>0?l:null,address:r.length>0?r:null,port:xU(n[5]),relatedAddress:s>=0?n[s+1]??null:null,relatedPort:c>=0?xU(n[c+1]):null,family:SU(r),scope:EU(r),raw:t}}function OU(e){return e.split(/\r?\n/).map(e=>e.trim()).filter(e=>e.startsWith(`a=candidate:`))}function kU(e){return`${e.type}|${e.protocol??`?`}|${e.address??`?`}|${String(e.port??`?`)}`}var AU=new Set([`loopback`,`link-local`,`lan`,`tailscale`,`mdns`]);function jU(){return{host:0,srflx:0,prflx:0,relay:0,unknown:0}}function MU(e){let t=jU();for(let n of e)t[n.type]+=1;return t}function NU(e,t){return!e&&t.length===0?`unknown`:t.length===0?`none`:t.some(e=>e.type===`srflx`||e.type===`relay`||e.type===`host`&&e.scope===`public`)?`public-path`:t.every(e=>AU.has(e.scope))?`private-only`:`public-path`}function PU(e){let t=new Set,n=[],r=e=>{let r=DU(e);if(r===null)return!1;let i=kU(r);return t.has(i)?!1:(t.add(i),n.push(r),!0)},i=0;for(let t of OU(e.sdpAnswer??``))r(t)&&(i+=1);let a=0;for(let t of e.trickled)r(t)&&(a+=1);return{candidates:n,fromSdp:i,fromTrickle:a,countByType:MU(n),hasSrflx:n.some(e=>e.type===`srflx`),hasRelay:n.some(e=>e.type===`relay`),hasPublicHost:n.some(e=>e.type===`host`&&e.scope===`public`),flag:NU(e.sdpAnswer!==null,n),trickleDone:e.trickleDone}}function FU(e){return e.map(e=>/^turns?:/i.test(e.url)&&e.username!==void 0&&e.credential!==void 0?{urls:e.url,username:e.username,credential:e.credential}:{urls:e.url})}function IU(e){return`url`in e&&typeof e.url==`string`&&e.url.length>0?e.url:null}function LU(e){return`relayProtocol`in e&&typeof e.relayProtocol==`string`&&e.relayProtocol.length>0?e.relayProtocol:null}function RU(e,t){let n=e.candidate?.candidate;if(e.candidate===null||n===void 0||n.length===0)return null;let r=DU(n);return r===null?null:{candidate:r,url:IU(e),relayProtocol:LU(e.candidate),tMs:t}}function zU(e){return e instanceof Error?e.message:String(e)}async function BU(e,t,n=8e3){let r=performance.now(),i=[],a=new RTCPeerConnection({iceServers:FU(e),iceTransportPolicy:t});try{a.createDataChannel(`probe`);let e=new Promise(e=>{let t=setTimeout(()=>e(!0),n);a.addEventListener(`icecandidate`,n=>{if(n.candidate===null){clearTimeout(t),e(!1);return}let a=RU(n,performance.now()-r);a!==null&&i.push(a)})});await a.setLocalDescription(await a.createOffer());let t=await e;return{candidates:i,durationMs:performance.now()-r,timedOut:t,error:null}}catch(e){return{candidates:i,durationMs:performance.now()-r,timedOut:!1,error:zU(e)}}finally{a.close()}}function VU(e){let t=new Map,n=[],r={id:null};e.forEach(e=>{let i=e;i.id!==void 0&&t.set(i.id,i),i.type===`candidate-pair`&&n.push(i),i.type===`transport`&&i.selectedCandidatePairId!==void 0&&(r.id=i.selectedCandidatePairId)});let i=n.find(e=>r.id!==null&&e.id===r.id)??n.find(e=>e.selected===!0)??n.find(e=>e.nominated===!0&&e.state===`succeeded`)??null;if(i===null)return{rttMs:null,relayProtocol:null};let a=i.localCandidateId===void 0?void 0:t.get(i.localCandidateId);return{rttMs:typeof i.currentRoundTripTime==`number`?Math.round(i.currentRoundTripTime*1e3):null,relayProtocol:typeof a?.relayProtocol==`string`?a.relayProtocol:null}}async function HU(e,t=1e4){let n=performance.now(),r={iceServers:FU(e),iceTransportPolicy:`relay`},i=new RTCPeerConnection(r),a=new RTCPeerConnection(r);try{i.createDataChannel(`probe`),i.addEventListener(`icecandidate`,e=>{e.candidate&&a.addIceCandidate(e.candidate).catch(()=>void 0)}),a.addEventListener(`icecandidate`,e=>{e.candidate&&i.addIceCandidate(e.candidate).catch(()=>void 0)});let e=new Promise(e=>{let n=setTimeout(()=>e(!1),t);i.addEventListener(`iceconnectionstatechange`,()=>{let t=i.iceConnectionState;t===`connected`||t===`completed`?(clearTimeout(n),e(!0)):(t===`failed`||t===`closed`)&&(clearTimeout(n),e(!1))})}),r=await i.createOffer();await i.setLocalDescription(r),await a.setRemoteDescription(r);let o=await a.createAnswer();await a.setLocalDescription(o),await i.setRemoteDescription(o);let s=await e,c=s?VU(await i.getStats()):{rttMs:null,relayProtocol:null};return{connected:s,state:i.iceConnectionState,rttMs:c.rttMs,relayProtocol:c.relayProtocol,durationMs:performance.now()-n,error:null}}catch(e){return{connected:!1,state:i.iceConnectionState,rttMs:null,relayProtocol:null,durationMs:performance.now()-n,error:zU(e)}}finally{i.close(),a.close()}}function UU(e){return e.relatedAddress===null||e.relatedAddress===`0.0.0.0`||e.relatedAddress===`::`||e.relatedPort===null||e.relatedPort===0}function WU(e){return UU(e)?`public:${e.address}`:`base:${e.relatedAddress??`?`}:${String(e.relatedPort??`?`)}`}function GU(e,t=[]){return{kind:`unknown`,confidence:`none`,reason:e,mappings:t}}function KU(e){let t=[];for(let n of e){let e=/^stuns?:([^?]+)/i.exec(n.trim());if(e===null)continue;let r=`stun:${(e[1]??``).toLowerCase()}`;t.includes(r)||t.push(r)}return t}function qU(e,t,n=Fn){let r=e.filter(e=>e.protocol.toLowerCase()===`udp`);if(t<2)return GU(n(`uiLibrary.natMapping.needTwo`,`needs two STUN destinations to compare; only one was queried`));if(r.length===0)return GU(n(`uiLibrary.natMapping.noSrflx`,`no server-reflexive candidate: STUN unreachable or blocked from this browser`));let i=new Map;for(let e of r){let t=WU(e);i.set(t,[...i.get(t)??[],e])}let a=[...new Set(r.map(e=>`${e.address}:${String(e.port)}`))];for(let e of i.values()){let t=new Set(e.map(e=>`${e.address}:${String(e.port)}`));if(t.size>1)return{kind:`endpoint-dependent`,confidence:`confirmed`,reason:n(`uiLibrary.natMapping.symmetric`,`one local socket got {{count}} different public mappings — symmetric NAT: only a TURN relay reaches this browser`,{count:t.size}),mappings:a}}let o=[...i.values()].some(e=>new Set(e.map(e=>e.url).filter(e=>e!==null)).size>=2);return{kind:`endpoint-independent`,confidence:o?`confirmed`:`likely`,reason:o?n(`uiLibrary.natMapping.confirmedSame`,`two STUN destinations saw the same public mapping`):n(`uiLibrary.natMapping.likelySame`,`one public mapping across the STUN destinations (the browser drops an identical second candidate, so the second answer cannot be told from no answer)`),mappings:a}}var JU=[`stun:stun.l.google.com:19302`,`stun:stun1.l.google.com:19302`];function YU(e){let t=e.toLowerCase();return t.startsWith(`turns:`)?`turns`:t.startsWith(`turn:`)?`turn`:t.startsWith(`stun:`)||t.startsWith(`stuns:`)?`stun`:`other`}function XU(e){return/[?&]transport=([a-z]+)/i.exec(e)?.[1]?.toLowerCase()??null}function ZU(e){let t=[];for(let n of e){let e=typeof n.urls==`string`?[n.urls]:n.urls;for(let r of e)t.some(e=>e.id===r)||t.push({id:r,url:r,...n.username===void 0?{}:{username:n.username},...n.credential===void 0?{}:{credential:n.credential},scheme:YU(r),transport:XU(r),hasCredentials:n.credential!==void 0})}return t}function QU(e,t,n){let r=t.candidates.find(e=>e.candidate.type===`srflx`),i=t.candidates.find(e=>e.candidate.type===`relay`),a=r!==void 0&&r.candidate.address!==null&&r.candidate.port!==null?`${r.candidate.address}:${String(r.candidate.port)}`:null;return{id:e.id,url:e.url,scheme:e.scheme,transport:e.transport,srflx:a,relay:i!==void 0,relayProtocol:n?.relayProtocol??i?.relayProtocol??null,eventUrl:i?.url??r?.url??null,relayConnected:n?.connected??null,rttMs:n?.rttMs??null,timedOut:t.timedOut,error:t.error??n?.error??null}}var $U=6e3,eW=8e3;function tW(e){return[{url:e.url,...e.username===void 0?{}:{username:e.username},...e.credential===void 0?{}:{credential:e.credential}}]}async function nW(e){let t=tW(e);return QU(e,await BU(t,`all`,$U),e.scheme===`turn`||e.scheme===`turns`?await HU(t,eW):null)}function rW(e){let t=[...KU(e.map(e=>e.url))];for(let e of KU(JU)){if(t.length>=2)break;t.includes(e)||t.push(e)}return t}function iW(e){let t=[];for(let n of e.candidates){let e=n.candidate;e.type!==`srflx`||e.address===null||e.port===null||e.protocol===null||t.push({address:e.address,port:e.port,protocol:e.protocol,relatedAddress:e.relatedAddress,relatedPort:e.relatedPort,url:n.url})}return t}async function aW(e,t=Fn){let n=rW(e),r=await BU(n.map(e=>({url:e})),`all`,$U);return{destinations:n,verdict:qU(iW(r),n.length,t),error:r.error}}var oW=`unknown`;function sW(e,t){return e===null?oW:t(e)}var cW=e=>sW(e,e=>`${String(Math.round(e))} ms`),lW=e=>sW(e,e=>e.toLocaleString()),uW=e=>sW(e,e=>e<1024?`${String(e)} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(2)} MiB`),dW=e=>sW(e,e=>`${e.toFixed(1)} %`),fW=e=>sW(e,e=>e);E();var pW={stun:`info`,turn:`warning`,turns:`success`,other:`default`};function mW(e){return e instanceof Error?e.message:String(e)}function hW(e,t,n){return e===null?v(`span`,{className:`text-foreground-subtle`,children:oW}):v(`span`,{className:e?`text-success`:`text-danger`,children:e?t:n})}function gW(e){return[{key:`endpoint`,header:e(`uiLibrary.endpointTest.colEndpoint`,`Endpoint`),nowrap:!1,render:e=>v(`span`,{className:`break-all font-mono text-[11px]`,children:e.url})},{key:`srflx`,header:e(`uiLibrary.endpointTest.colMapped`,`Mapped (srflx)`),render:t=>v(`span`,{className:`font-mono text-[11px]`,children:t.srflx??e(`uiLibrary.endpointTest.none`,`none`)})},{key:`relay`,header:e(`uiLibrary.endpointTest.colRelay`,`Relay`),render:t=>t.scheme===`stun`?v(`span`,{className:`text-foreground-subtle`,children:e(`uiLibrary.endpointTest.na`,`n/a`)}):hW(t.relay,e(`uiLibrary.endpointTest.allocated`,`allocated`),e(`uiLibrary.endpointTest.none`,`none`))},{key:`proto`,header:e(`uiLibrary.endpointTest.colProto`,`Relay protocol`),render:t=>t.scheme===`stun`?e(`uiLibrary.endpointTest.na`,`n/a`):fW(t.relayProtocol)},{key:`connect`,header:e(`uiLibrary.endpointTest.colConnect`,`Relay connect`),render:t=>t.relayConnected===null?v(`span`,{className:`text-foreground-subtle`,children:e(`uiLibrary.endpointTest.na`,`n/a`)}):hW(t.relayConnected,e(`uiLibrary.endpointTest.connected`,`connected`),e(`uiLibrary.endpointTest.failed`,`failed`))},{key:`rtt`,header:`RTT`,align:`right`,render:e=>cW(e.rttMs)},{key:`url`,header:e(`uiLibrary.endpointTest.colUrl`,`Event url`),nowrap:!1,render:e=>v(`span`,{className:`break-all font-mono text-[10px]`,children:fW(e.eventUrl)})},{key:`note`,header:e(`uiLibrary.endpointTest.colNote`,`Note`),nowrap:!1,render:t=>v(`span`,{className:Ii,children:t.error??(t.timedOut?e(`uiLibrary.endpointTest.timedOut`,`gathering timed out`):``)})}]}function _W(e,t){switch(t){case`endpoint-independent`:return e(`uiLibrary.endpointTest.natIndependent`,`Endpoint-independent mapping`);case`endpoint-dependent`:return e(`uiLibrary.endpointTest.natDependent`,`Symmetric NAT (endpoint-dependent)`);case`unknown`:return e(`uiLibrary.endpointTest.natUnknown`,`Unknown`)}}function vW({result:e}){let t=q(),{verdict:n}=e,r=n.kind===`endpoint-independent`?`success`:n.kind===`endpoint-dependent`?`danger`:`default`;return v(`div`,{className:ue,"data-testid":`nat-check-result`,children:v(vU,{items:[{key:t(`uiLibrary.endpointTest.natMapping`,`NAT mapping`),value:c(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[v(Bk,{variant:r,children:_W(t,n.kind)}),n.confidence!==`none`&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:n.confidence})]})},{key:t(`uiLibrary.endpointTest.why`,`Why`),value:v(`span`,{className:`text-xs`,children:n.reason})},{key:t(`uiLibrary.endpointTest.mappings`,`Mappings seen`),value:v(`span`,{className:`font-mono text-[11px]`,children:n.mappings.length>0?n.mappings.join(`, `):t(`uiLibrary.endpointTest.none`,`none`)})},{key:t(`uiLibrary.endpointTest.stunQueried`,`STUN queried`),value:v(`span`,{className:`break-all font-mono text-[11px]`,children:e.destinations.join(`, `)})},...e.error===null?[]:[{key:t(`uiLibrary.endpointTest.error`,`Error`),value:e.error}]]})})}function yW({rows:e}){let t=q(),n=p(()=>gW(t),[t]);return v(yU,{headingId:`webrtc-diag-endpoint-results`,title:t(`uiLibrary.endpointTest.results`,`Per-endpoint results`),icon:Le,children:v(gU,{columns:n,rows:e,rowKey:e=>e.id,bordered:!1,minWidthPx:760})})}function bW({result:e}){return v(yU,{headingId:`webrtc-diag-nat`,title:q()(`uiLibrary.endpointTest.natTitle`,`NAT mapping (this browser)`),icon:se,children:v(vW,{result:e})})}function xW({endpoint:e,checked:t,onToggle:n}){let r=q();return c(`label`,{className:`${Ft} flex cursor-pointer items-center gap-2 hover:bg-surface-hover/40`,children:[v(BB,{checked:t,onChange:()=>n(e.id)}),v(Bk,{variant:pW[e.scheme],className:`shrink-0 uppercase text-[10px]`,children:e.scheme}),v(`span`,{className:`min-w-0 flex-1 break-all font-mono text-[11px] text-foreground`,children:e.url}),e.transport!==null&&v(`span`,{className:`text-[10px] text-foreground-subtle uppercase`,children:e.transport}),e.hasCredentials&&v(`span`,{className:`text-[10px] text-foreground-subtle text-success`,children:r(`uiLibrary.endpointTestCard.authWord`,`auth`)})]})}function SW({loadServers:e}){let t=q(),[n,r]=C(null),[i,a]=C(null),[o,s]=C(!1),[l,u]=C(new Set),[d,f]=C(null),[m,h]=C([]),[g,y]=C(null),x=_(async()=>{s(!0),a(null);try{let t=ZU(await e());r(t),u(new Set(t.map(e=>e.id)))}catch(e){a(mW(e))}finally{s(!1)}},[e]);b(()=>{x()},[x]);let S=p(()=>(n??[]).filter(e=>l.has(e.id)),[n,l]),w=_(e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),T=_(async()=>{f(`endpoints`),h([]);let e=[];for(let t of S)e.push(await nW(t)),h([...e]);f(null)},[S]),E=_(async()=>{f(`nat`),y(null);try{y(await aW(n??[],t))}finally{f(null)}},[n,t]),D=d!==null;return c(`div`,{className:`space-y-3 sm:space-y-4`,children:[v(yU,{headingId:`webrtc-diag-ice-servers`,title:n===null?t(`uiLibrary.endpointTest.ice`,`ICE servers`):t(`uiLibrary.endpointTest.iceCount`,`ICE servers ({{count}})`,{count:n.length}),icon:De,testId:`webrtc-diag-ice-servers`,actions:c(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c(_A,{variant:`ghost`,onClick:()=>void x(),disabled:o||D,children:[o?v(Gn,{className:`h-3 w-3 animate-spin`}):v(_e,{className:`h-3 w-3`}),t(`uiLibrary.endpointTest.reload`,`Reload`)]}),c(_A,{variant:`outline`,onClick:()=>void E(),disabled:D||n===null,children:[d===`nat`?v(Gn,{className:`h-3 w-3 animate-spin`}):v(se,{className:`h-3 w-3`}),t(`uiLibrary.endpointTest.checkNat`,`Check NAT`)]}),c(_A,{onClick:()=>void T(),disabled:D||S.length===0,children:[d===`endpoints`?v(Gn,{className:`h-3 w-3 animate-spin`}):v(Le,{className:`h-3 w-3`}),t(`uiLibrary.endpointTest.testEach`,`Test each endpoint`)]})]}),children:c(`div`,{className:`divide-y divide-border/50`,children:[i!==null&&v(`div`,{className:`px-3 sm:px-4 py-1.5 sm:py-2 text-xs text-danger`,children:t(`uiLibrary.endpointTest.loadFailed`,`Failed to load ICE servers: {{error}}`,{error:i})}),i===null&&n===null&&v(`div`,{className:`px-3 sm:px-4 py-1.5 sm:py-2 text-[10px] text-foreground-subtle`,children:t(`uiLibrary.endpointTest.loading`,`Loading…`)}),n!==null&&n.length===0&&v(`div`,{className:`px-3 sm:px-4 py-1.5 sm:py-2 text-[10px] text-foreground-subtle`,children:t(`uiLibrary.endpointTest.noServers`,`No ICE servers configured. Add a TURN provider under TURN Servers.`)}),(n??[]).map(e=>v(xW,{endpoint:e,checked:l.has(e.id),onToggle:w},e.id))]})}),m.length>0&&v(yW,{rows:m}),g!==null&&v(bW,{result:g})]})}var CW=5*6e4,wW=720*6e4,TW=`camstack:turn-servers:v1`;function EW(){let e=globalThis;try{return e.localStorage??null}catch{return null}}function DW(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.fetchedAt!=`number`||!Array.isArray(t.servers)?!1:t.servers.every(e=>{if(typeof e!=`object`||!e)return!1;let t=e;return!(!(typeof t.urls==`string`||Array.isArray(t.urls)&&t.urls.every(e=>typeof e==`string`))||t.username!==void 0&&typeof t.username!=`string`||t.credential!==void 0&&typeof t.credential!=`string`)})}var OW=class{freshTtlMs;staleCapMs;storage;now;storageKey;memory=new WeakMap;inflight=new WeakMap;constructor(e={}){this.freshTtlMs=e.freshTtlMs??CW,this.staleCapMs=e.staleCapMs??wW,this.storage=`storage`in e?e.storage??null:EW(),this.now=e.now??(()=>Date.now()),this.storageKey=e.storageKey??TW}async getOrFetch(e,t){let n=this.now(),r=this.memory.get(e)??this.readStorage();if(r){let i=n-r.fetchedAt;if(i<this.freshTtlMs)return r.servers;if(i<this.staleCapMs)return this.startFetch(e,t,r),r.servers}return this.startFetch(e,t,r)}startFetch(e,t,n){let r=this.inflight.get(e);if(r)return r;let i=(async()=>{try{let n=await t();if(n.length>0){let t={servers:n,fetchedAt:this.now()};this.memory.set(e,t),this.writeStorage(t)}return n}catch{return n?.servers}})().finally(()=>{this.inflight.delete(e)});return this.inflight.set(e,i),i}readStorage(){if(this.storage)try{let e=this.storage.getItem(this.storageKey);if(e===null)return;let t=JSON.parse(e);return DW(t)?t:void 0}catch{return}}writeStorage(e){if(this.storage)try{this.storage.setItem(this.storageKey,JSON.stringify(e))}catch{}}};E();var kW=new OW;function AW(e,t,n=5e3){let[r,i]=C([]);b(()=>{if(t===null)return;let r=!1,a=()=>{e.webrtcSession.listStreams.query({deviceId:t}).then(e=>{r||i(e)}).catch(()=>{})};a();let o=setInterval(a,n);return()=>{r=!0,clearInterval(o)}},[e,t,n]);let[a,o]=C(null);b(()=>{if(t===null)return;let n=!1;return e.pipelineOrchestrator&&e.pipelineOrchestrator.getCameraMetrics.query({deviceId:t}).then(e=>{n||!e||o({phase:e.phase,detectionFps:e.actualFps,avgInferenceMs:e.avgInferenceTimeMs,droppedFrames:e.droppedFrames})}).catch(()=>{}),()=>{n=!0}},[e,t]),Mo(`pipeline.camera-metrics-snapshot`,e=>{if(t===null)return;let n=e.data;n.deviceId!==t||!n.metrics||o({phase:n.metrics.phase,detectionFps:n.metrics.actualFps,avgInferenceMs:n.metrics.avgInferenceTimeMs,droppedFrames:n.metrics.droppedFrames})});let{streams:s,hasWebrtc:c}=p(()=>t===null||r.length===0?{streams:[],hasWebrtc:!1}:{streams:r.map(e=>({id:e.id,label:e.label,target:e.target,status:e.status,inputFps:e.inputFps,bitrateKbps:e.bitrateKbps})),hasWebrtc:!0},[t,r]),l=_(async()=>{let t=e.turnProvider;if(t)return kW.getOrFetch(e,async()=>(await t.getTurnServers.query()).map(e=>({urls:typeof e.urls==`string`?e.urls:[...e.urls],...e.username===void 0?{}:{username:e.username},...e.credential===void 0?{}:{credential:e.credential}})))},[e]);b(()=>{l()},[l]);let u=_(async(n,r)=>{if(t===null)throw Error(`No device selected`);let i=await e.webrtcSession.createSession.mutate({deviceId:t,target:n,hints:r}),a=await l();return{sessionId:i.sessionId,sdpOffer:i.sdpOffer,...a?{iceServers:a}:{}}},[e,t,l]),d=_(async(n,r,i,a)=>{if(t===null)throw Error(`No device selected`);return e.webrtcSession.handleOffer.mutate({deviceId:t,target:n,sdpOffer:r,...i===void 0?{}:{sessionId:i},...a===void 0?{}:{hints:a}})},[e,t]),f=_(async(n,r)=>{if(t===null)throw Error(`No device selected`);await e.webrtcSession.handleAnswer.mutate({deviceId:t,sessionId:n,sdpAnswer:r})},[e,t]);return{streams:s,hasWebrtc:c,pipelineMetrics:a,createSession:u,handleOffer:d,getIceServers:l,addIceCandidate:_(async(n,r)=>{t!==null&&await e.webrtcSession.addIceCandidate.mutate({deviceId:t,sessionId:n,candidate:r.candidate??``,sdpMid:r.sdpMid??null,sdpMLineIndex:r.sdpMLineIndex??null}).catch(()=>{})},[e,t]),getIceCandidates:_(async n=>t===null?{candidates:[],done:!0}:e.webrtcSession.getIceCandidates.query({deviceId:t,sessionId:n}),[e,t]),sendAnswer:f,closeSession:_(async n=>{t!==null&&await e.webrtcSession.closeSession.mutate({deviceId:t,sessionId:n}).catch(()=>{})},[e,t]),getSessionState:_(async n=>{if(t===null)return{pendingRenegotiation:null};try{return await e.webrtcSession.getSessionState.query({deviceId:t,sessionId:n})}catch{return{pendingRenegotiation:null}}},[e,t]),getSessionDebug:_(async n=>{if(t===null)throw Error(`getSessionDebug: no device bound to this player`);return e.webrtcSession.getSessionDebug.query({deviceId:t,sessionId:n})},[e,t]),applyDownlinkProbe:_(async(n,r)=>{let i=e.webrtcSession.applyDownlinkProbe;if(t===null||i===void 0)throw Error(`applyDownlinkProbe: not available for this player`);return i.mutate({deviceId:t,sessionId:n,downlinkMbps:r})},[e,t])}}var jW={healthy:`success`,"loss-keyframe":`warning`,transport:`danger`,"hub-dtls":`danger`,"media-black-hole":`danger`,"hub-not-sending":`danger`,unknown:`default`};function MW(e,t){switch(e){case`public-path`:return t(`uiLibrary.runReport.flagPublicPath`,`has a public path (srflx / relay / public host)`);case`private-only`:return t(`uiLibrary.runReport.flagPrivateOnly`,`LAN/Tailscale only, no srflx/relay`);case`none`:return t(`uiLibrary.runReport.flagNone`,`answered with no candidate`);case`unknown`:return t(`uiLibrary.runReport.flagUnknown`,`no answer received`)}}function NW(e,t){let n=e.address===null?t(`uiLibrary.runReport.unknown`,`unknown`):`${e.address}:${e.port===null?`?`:String(e.port)}`;return`${e.type} ${e.protocol??`?`} ${n} · ${e.scope}`}function PW(e,t){let n=Object.entries(e).filter(([,e])=>e>0).map(([e,t])=>`${String(t)} ${e}`);return n.length>0?n.join(` · `):t(`uiLibrary.runReport.none`,`none`)}function FW({title:e,children:t}){return c(`div`,{className:`space-y-0.5`,children:[v(`div`,{className:Ut,children:e}),t]})}function IW({report:e,title:t}){let n=q(),{hub:r,timeline:i,path:a,media:o,verdict:s,local:l}=e;return c(`section`,{className:ut,"data-testid":`webrtc-diag-run-${e.policy}`,children:[c(`header`,{className:`${mr} flex flex-wrap items-center gap-2`,children:[v(`h3`,{className:`${Ut} min-w-0 flex-1`,children:t}),v(Bk,{variant:jW[s.layer],children:s.title})]}),c(`div`,{className:`${ue} space-y-3`,children:[v(`p`,{className:`text-xs text-foreground`,children:s.detail}),c(FW,{title:n(`uiLibrary.runReport.hubCandidates`,`Hub candidates`),children:[v(vU,{items:[{key:n(`uiLibrary.runReport.offered`,`Offered`),value:c(`span`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[PW(r.countByType,n),v(Bk,{variant:r.flag===`private-only`?`warning`:r.flag===`public-path`?`success`:`default`,children:MW(r.flag,n)})]})},{key:n(`uiLibrary.runReport.source`,`Source`),value:`${n(`uiLibrary.runReport.sourceCounts`,`{{sdp}} in the answer SDP · {{trickled}} trickled`,{sdp:r.fromSdp,trickled:r.fromTrickle})}${r.trickleDone===!0?` · ${n(`uiLibrary.runReport.gatheringDone`,`gathering done`)}`:``}`}]}),r.candidates.length>0&&v(`ul`,{className:`mt-1 space-y-0.5 font-mono text-[10px] text-foreground-subtle`,children:r.candidates.map(e=>v(`li`,{className:`break-all`,children:NW(e,n)},e.raw))})]}),v(FW,{title:n(`uiLibrary.runReport.timeline`,`Timeline`),children:v(vU,{items:[{key:`ICE connected`,value:cW(i.iceConnectedMs)},{key:`DTLS connected`,value:cW(i.dtlsConnectedMs)},{key:n(`uiLibrary.runReport.firstFrame`,`First frame`),value:cW(i.firstFrameMs)},{key:`ICE · DTLS final`,value:`${fW(i.iceFinalState)} · ${fW(i.dtlsFinalState)}`}]})}),v(FW,{title:n(`uiLibrary.runReport.path`,`Path`),children:v(vU,{items:[{key:n(`uiLibrary.runReport.selectedPair`,`Selected pair`),value:a.pairType===null?fW(null):n(`uiLibrary.runReport.pairType`,`{{type}} (local/remote)`,{type:a.pairType})},{key:`Protocol · RTT`,value:`${fW(a.protocol)} · ${cW(a.rttMs)}`},{key:n(`uiLibrary.runReport.browserOffered`,`Browser offered`),value:`${PW(l.countByType,n)}${l.relayProtocols.length>0?` · ${n(`uiLibrary.runReport.relayOver`,`relay over {{protocols}}`,{protocols:l.relayProtocols.join(`/`)})}`:``}`}]})}),v(FW,{title:n(`uiLibrary.runReport.media`,`Media`),children:v(vU,{items:[{key:n(`uiLibrary.runReport.hubSent`,`Hub sent`),value:`${n(`uiLibrary.runReport.rtpPackets`,`{{value}} RTP packets`,{value:lW(o.serverPacketsSent)})}${o.servedTier===null?``:` · ${o.servedTier}`}${o.egressLeg===null?``:` · ${o.egressLeg}`}`},{key:n(`uiLibrary.runReport.browserGot`,`Browser got`),value:`${n(`uiLibrary.runReport.packets`,`{{value}} packets`,{value:lW(o.clientPacketsReceived)})} · ${uW(o.clientBytesReceived)}`},{key:n(`uiLibrary.runReport.framesDecoded`,`Frames decoded`),value:lW(o.framesDecoded)},{key:n(`uiLibrary.runReport.lossFreezes`,`Loss · freezes`),value:`${dW(o.lossPercent)} · ${lW(o.freezeCount)} (${cW(o.totalFreezeMs)})`},{key:`PLI · NACK`,value:`${lW(o.pliCount)} · ${lW(o.nackCount)}`}]})}),(e.reconnects>0||e.errors.length>0||e.serverError!==null)&&c(`div`,{className:`text-[10px] text-foreground-subtle`,children:[e.reconnects>0&&v(`div`,{children:n(`uiLibrary.runReport.reconnects`,`Player reconnects: {{count}}`,{count:e.reconnects})}),e.errors.map((e,t)=>v(`div`,{children:n(`uiLibrary.runReport.playerError`,`Player error: {{message}}`,{message:e})},`${String(t)}-${e}`)),e.serverError!==null&&v(`div`,{children:n(`uiLibrary.runReport.serverDebug`,`Server debug: {{message}}`,{message:e.serverError})})]}),v(`div`,{className:Ii,children:n(`uiLibrary.runReport.sessions`,`Sessions: {{ids}} · {{seconds}} s`,{ids:e.sessionIds.length>0?e.sessionIds.map(e=>e.slice(0,8)).join(`, `):n(`uiLibrary.runReport.none`,`none`),seconds:Math.round(e.durationMs/1e3)})})]})]})}function LW(e,t){let n={state:e.iceFinalState??t(`uiLibrary.sessionVerdict.state.unknown`,`unknown`)};return e.hubFlag===`unknown`?t(`uiLibrary.sessionVerdict.transport.noAnswer`,`ICE {{state}}; the hub never answered the offer, so no hub candidate was seen`,n):e.hubFlag===`none`?t(`uiLibrary.sessionVerdict.transport.noCandidate`,`ICE {{state}}; the hub answered but offered no candidate`,n):e.policy===`relay`&&e.hubFlag===`private-only`?t(`uiLibrary.sessionVerdict.transport.relayPrivateOnly`,`ICE {{state}}; this browser was limited to TURN relay candidates and the hub offered only LAN/Tailscale addresses (no srflx/relay) — a relayed client cannot reach it`,n):e.hubFlag===`private-only`?t(`uiLibrary.sessionVerdict.transport.privateOnly`,`ICE {{state}}; the hub offered only LAN/Tailscale addresses (no srflx/relay) — reachable only from inside those networks`,n):t(`uiLibrary.sessionVerdict.transport.noPair`,`ICE {{state}}; no candidate pair between this browser and the hub succeeded`,n)}function RW(e,t,n){return{layer:e,title:t,detail:n}}function zW(e,t){return e===null?t(`uiLibrary.sessionVerdict.state.unknown`,`unknown`):String(e)}function BW(e,t){let n=e.clientPacketsReceived,r=e.serverPacketsSent;if(n===null)return RW(`unknown`,t(`uiLibrary.sessionVerdict.mediaUnknown.title`,`Media unknown`),t(`uiLibrary.sessionVerdict.mediaUnknown.detail`,`the browser reported no inbound video statistics`));if(n===0)return r===null?RW(`unknown`,t(`uiLibrary.sessionVerdict.nothingReceived.title`,`Nothing received`),t(`uiLibrary.sessionVerdict.nothingReceived.detail`,`the browser received no packets and the hub's own count is unknown`)):r>0?RW(`media-black-hole`,t(`uiLibrary.sessionVerdict.blackHole.title`,`Media black-hole`),t(`uiLibrary.sessionVerdict.blackHole.detail`,`the hub sent {{sent}} RTP packets and this browser received none — media is lost between them after DTLS`,{sent:String(r)})):RW(`hub-not-sending`,t(`uiLibrary.sessionVerdict.hubNotSending.title`,`Hub not sending`),t(`uiLibrary.sessionVerdict.hubNotSending.detail`,`the session is connected but the hub sent no RTP — the source or the broker is not producing`));if(e.framesDecoded===null)return RW(`unknown`,t(`uiLibrary.sessionVerdict.decodeUnknown.title`,`Decode unknown`),t(`uiLibrary.sessionVerdict.decodeUnknown.detail`,`packets arrive; the browser reported no decode count`));let i=t(`uiLibrary.sessionVerdict.lossKeyframe.title`,`Loss / keyframe size`);if(e.framesDecoded===0)return RW(`loss-keyframe`,i,t(`uiLibrary.sessionVerdict.lossKeyframe.noFrame`,`packets arrive but no frame decoded — a keyframe never completes over this path`));let{pliCount:a,freezeCount:o,lossPercent:s}=e,c=a!==null&&a>=3||o!==null&&o>0||s!==null&&s>=2,l=t(`uiLibrary.sessionVerdict.signals`,`{{pli}} PLI, {{freezes}} freezes, {{loss}} loss`,{pli:zW(a,t),freezes:zW(o,t),loss:s===null?zW(null,t):`${s.toFixed(1)}%`});return c?RW(`loss-keyframe`,i,t(`uiLibrary.sessionVerdict.lossKeyframe.lossy`,`frames decode but the path is lossy: {{signals}}`,{signals:l})):a===null&&o===null&&s===null?RW(`healthy`,t(`uiLibrary.sessionVerdict.decoding.title`,`Decoding`),t(`uiLibrary.sessionVerdict.decoding.detail`,`frames decode; the browser reported no loss signal to judge`)):RW(`healthy`,t(`uiLibrary.sessionVerdict.healthy.title`,`Healthy`),t(`uiLibrary.sessionVerdict.healthy.detail`,`connected, receiving and decoding: {{signals}}`,{signals:l}))}function VW(e,t=Fn){return e.iceConnected?!e.dtlsConnected&&e.dtlsFinalState!==null?RW(`hub-dtls`,t(`uiLibrary.sessionVerdict.dtls.title`,`DTLS stuck (hub side)`),t(`uiLibrary.sessionVerdict.dtls.detail`,`ICE connected but DTLS stayed {{state}} — the hub never completed the handshake`,{state:e.dtlsFinalState})):BW(e,t):RW(`transport`,t(`uiLibrary.sessionVerdict.transport.title`,`Transport (ICE) failed`),LW(e,t))}function HW(e){return{policy:e,sessionIds:[],sdpAnswer:null,trickled:[],trickleDone:null,local:[],ice:[],dtls:[],peer:[],firstFrameAt:null,lastStats:null,lastServer:null,maxServerPacketsSent:null,lastServerError:null,samples:0,reconnects:0,errors:[]}}function UW(e,t,n){return e.at(-1)?.state===t?e:[...e,{state:t,at:n}]}function WW(e,t){return e===null?t:t===null?e:Math.max(e,t)}function GW(e,t){return{...e,samples:e.samples+1,lastStats:t.stats??e.lastStats,lastServer:t.server??e.lastServer,maxServerPacketsSent:WW(e.maxServerPacketsSent,t.server?.rtpPacketsSent??null),lastServerError:t.serverError,sessionIds:t.sessionId!==null&&!e.sessionIds.includes(t.sessionId)?[...e.sessionIds,t.sessionId]:e.sessionIds}}function KW(e,t){switch(t.kind){case`offer-answered`:return{...e,sdpAnswer:e.sdpAnswer??t.sdpAnswer,sessionIds:e.sessionIds.includes(t.sessionId)?e.sessionIds:[...e.sessionIds,t.sessionId]};case`hub-candidates`:return{...e,trickled:[...e.trickled,...t.candidates.filter(t=>!e.trickled.includes(t))],trickleDone:t.done||e.trickleDone===!0};case`local-candidate`:{let n=DU(t.candidate);return n===null?e:{...e,local:[...e.local,{candidate:n,url:t.url,relayProtocol:t.relayProtocol}]}}case`ice-state`:return{...e,ice:UW(e.ice,t.state,t.at)};case`dtls-state`:return{...e,dtls:UW(e.dtls,t.state,t.at)};case`peer-state`:return{...e,peer:UW(e.peer,t.state,t.at)};case`first-frame`:return{...e,firstFrameAt:e.firstFrameAt??t.at};case`sample`:return GW(e,t.sample);case`reconnect`:return{...e,reconnects:e.reconnects+1};case`error`:return{...e,errors:[...e.errors,t.message]}}}var qW=new Set([`connected`,`completed`]);function JW(e,t){return e.find(e=>t.has(e.state))?.at??null}var YW=new Set([`connected`]);function XW(e){let t=JW(e.dtls,YW)??JW(e.peer,YW),n=e.dtls.at(-1)?.state??e.peer.at(-1)?.state??null;return{iceConnectedMs:JW(e.ice,qW),dtlsConnectedMs:t,firstFrameMs:e.firstFrameAt,iceFinalState:e.ice.at(-1)?.state??null,dtlsFinalState:n}}function ZW(e){let t=e.lastStats,n=e.lastServer;return{clientBytesReceived:t?.raw.bytesReceived??null,clientPacketsReceived:t?.packetsReceived??null,framesDecoded:t?.framesDecoded??null,serverPacketsSent:e.maxServerPacketsSent,serverAlive:n?.alive??null,servedTier:n?.servedTier??null,egressLeg:n?.egressLeg??null,lossPercent:t?.lossPercent??null,freezeCount:t?.freezeCount??null,totalFreezeMs:t?.totalFreezeMs??null,pliCount:t?.pliCount??null,nackCount:t?.nackCount??null}}function QW(e){let t=e=>[...new Set(e.filter(e=>e!==null))];return{countByType:MU(e.local.map(e=>e.candidate)),relayProtocols:t(e.local.filter(e=>e.candidate.type===`relay`).map(e=>e.relayProtocol)),urls:t(e.local.map(e=>e.url))}}function $W(e,t,n=Fn){let r=PU({sdpAnswer:e.sdpAnswer,trickled:e.trickled,trickleDone:e.trickleDone}),i=XW(e),a=ZW(e),o=VW({policy:e.policy,durationMs:t,iceConnected:i.iceConnectedMs!==null,iceFinalState:i.iceFinalState,dtlsConnected:i.dtlsConnectedMs!==null,dtlsFinalState:i.dtlsFinalState,hubFlag:r.flag,clientPacketsReceived:a.clientPacketsReceived,framesDecoded:a.framesDecoded,serverPacketsSent:a.serverPacketsSent,pliCount:a.pliCount,freezeCount:a.freezeCount,lossPercent:a.lossPercent},n);return{policy:e.policy,durationMs:t,sessionIds:e.sessionIds,hub:r,local:QW(e),timeline:i,path:{pairType:e.lastStats?.candidatePairType??null,protocol:e.lastStats?.candidateProtocol??null,rttMs:e.lastStats?.rttMs??null},media:a,reconnects:e.reconnects,errors:e.errors,serverError:e.lastServerError,verdict:o}}E();var eG=15e3,tG=[`all`,`relay`],nG=750,rG=500;function iG(e){let t=e=>{let t=e.target;return t.kind===`profile`?t.profile===`low`?0:t.profile===`mid`?2:3:t.kind===`cam-stream`?/sub|low|ext/i.test(t.camStreamId)?1:4:9};return e.filter(e=>e.target.kind!==`adaptive`).toSorted((e,n)=>t(e)-t(n))}function aG(e,t){switch(t){case`all`:return e(`uiLibrary.hubSessionTest.policyAll`,`ICE policy all`);case`relay`:return e(`uiLibrary.hubSessionTest.policyRelay`,`ICE policy relay (TURN only)`)}}function oG({trpc:e,serverUrl:t,deviceId:n,cameraField:r,runMs:i=eG}){let a=q(),o=f(a);o.current=a;let s=AW(e,n),l=p(()=>iG(s.streams),[s.streams]),[u,d]=C(null),m=l.find(e=>e.id===u)??l[0]??null,[h,g]=C(null),[y,x]=C([]),[S,w]=C(0),[T,E]=C(!1),D=f(HW(`all`)),O=f(0),k=f(0),A=f(null),j=_(()=>Math.round(performance.now()-O.current),[]),M=_((e,t)=>{e===k.current&&(D.current=KW(D.current,t))},[]),N=_(()=>{k.current+=1,A.current!==null&&clearTimeout(A.current),A.current=null,g(null),E(!1)},[]),P=_(e=>{let t=tG[e];t!==void 0&&(k.current+=1,D.current=HW(t),O.current=performance.now(),w(0),g({index:e,policy:t,token:k.current}))},[]);b(()=>{if(h===null)return;let e=setInterval(()=>w(j()),rG),t=setTimeout(()=>{let e=$W(D.current,j(),o.current);x(t=>[...t,e]),k.current+=1,g(null);let t=h.index+1;t<tG.length?A.current=setTimeout(()=>P(t),nG):E(!1)},i);return()=>{clearInterval(e),clearTimeout(t)}},[h,i,j,P]),b(()=>()=>{k.current+=1,A.current!==null&&clearTimeout(A.current)},[]);let F=_(()=>{x([]),E(!0),P(0)},[P]),I=m?.target??null,L=h?.token??-1,R=_(async(e,t,n)=>{if(I===null)throw Error(`no stream selected`);let r=await s.handleOffer(I,e,t,n);return M(L,{kind:`offer-answered`,at:j(),sessionId:r.sessionId,sdpAnswer:r.sdpAnswer}),r},[I,s,M,L,j]),z=_(async e=>{let t=await s.getIceCandidates(e);return M(L,{kind:`hub-candidates`,at:j(),candidates:t.candidates.map(e=>e.candidate??``).filter(e=>e.length>0),done:t.done}),t},[s,M,L,j]),B=_(e=>{let t=new WeakSet;e.addEventListener(`iceconnectionstatechange`,()=>M(L,{kind:`ice-state`,at:j(),state:e.iceConnectionState})),e.addEventListener(`connectionstatechange`,()=>M(L,{kind:`peer-state`,at:j(),state:e.connectionState})),e.addEventListener(`icecandidate`,e=>{let t=RU(e,j());t!==null&&M(L,{kind:`local-candidate`,at:t.tMs,candidate:t.candidate.raw,url:t.url,relayProtocol:t.relayProtocol})}),e.addEventListener(`track`,e=>{let n=e.receiver.transport;n===null||t.has(n)||(t.add(n),M(L,{kind:`dtls-state`,at:j(),state:n.state}),n.addEventListener(`statechange`,()=>M(L,{kind:`dtls-state`,at:j(),state:n.state})))})},[M,L,j]),V=_(e=>M(L,{kind:`sample`,at:j(),sample:e}),[M,L,j]),H=_(e=>{e.firstFrameMs!==void 0&&M(L,{kind:`first-frame`,at:j()})},[M,L,j]),U=h===null?null:Math.min(100,Math.round(S/i*100)),ee=n!==null&&m!==null&&!T;return c(yU,{headingId:`webrtc-diag-hub-session`,title:a(`uiLibrary.hubSessionTest.title`,`Hub session test`),icon:ai,testId:`webrtc-diag-hub-session`,actions:T?c(_A,{variant:`outline`,onClick:N,children:[v(pi,{className:`h-3 w-3`}),a(`uiLibrary.hubSessionTest.stop`,`Stop`)]}):c(_A,{onClick:F,disabled:!ee,children:[v(Le,{className:`h-3 w-3`}),a(`uiLibrary.hubSessionTest.run`,`Run test ({{seconds}} s)`,{seconds:Math.round(i*tG.length/1e3)})]}),children:[c(`div`,{className:`${ue} space-y-3`,children:[c(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 ${ki}`,children:[r,c(`label`,{className:`flex min-w-0 flex-col gap-1`,children:[v(`span`,{className:`text-[11px] text-foreground-subtle`,children:a(`uiLibrary.hubSessionTest.stream`,`Stream (pinned)`)}),v(Yl,{value:m?.id??``,disabled:l.length===0||T,onChange:e=>d(e.target.value),options:l.length===0?[{value:``,label:n===null?a(`uiLibrary.hubSessionTest.pickCamera`,`Pick a camera first`):a(`uiLibrary.hubSessionTest.noStream`,`No pinned stream`)}]:l.map(e=>({value:e.id,label:e.label}))})]})]}),v(`p`,{className:Ii,children:a(`uiLibrary.hubSessionTest.hint`,`Opens a real live session from this browser twice — first with every candidate type, then TURN relay only — and reads both ends of it.`)}),h!==null&&n!==null&&m!==null&&c(`div`,{className:`grid grid-cols-1 sm:grid-cols-[minmax(0,16rem)_1fr] gap-2 sm:gap-3 items-start`,children:[v(`div`,{className:`aspect-video w-full overflow-hidden rounded-md border border-border bg-black`,children:v(QH,{serverUrl:t,streamKey:`diag-${m.id}-${h.policy}`,autoPlay:!0,muted:!0,showControls:!1,className:`h-full w-full`,handleOffer:R,getIceServers:s.getIceServers,addIceCandidate:s.addIceCandidate,getIceCandidates:z,closeSession:s.closeSession,getSessionDebug:s.getSessionDebug,applyDownlinkProbe:s.applyDownlinkProbe,iceTransportPolicy:h.policy,onPeerConnection:B,onDebugStats:V,onConnectTiming:H,onReconnectAttempt:()=>M(L,{kind:`reconnect`,at:j()}),onError:e=>M(L,{kind:`error`,at:j(),message:e})},`${String(h.token)}-${h.policy}`)}),c(`div`,{className:`space-y-1.5`,"data-testid":`webrtc-diag-progress`,children:[c(`div`,{className:`flex items-center gap-2 text-xs text-foreground`,children:[v(Gn,{className:`h-3 w-3 animate-spin`}),a(`uiLibrary.hubSessionTest.progress`,`Run {{index}} of {{total}} · {{policy}}`,{index:h.index+1,total:tG.length,policy:aG(a,h.policy)})]}),v(`div`,{className:`h-1.5 w-full overflow-hidden rounded bg-surface-hover`,children:v(`div`,{className:`h-full bg-primary transition-[width]`,style:{width:`${String(U??0)}%`}})}),v(`div`,{className:`text-[10px] text-foreground-subtle`,children:a(`uiLibrary.hubSessionTest.elapsed`,`{{elapsed}} s of {{total}} s`,{elapsed:Math.round(S/1e3),total:Math.round(i/1e3)})})]})]})]}),y.length>0&&v(`div`,{className:`grid grid grid-cols-1 lg:grid-cols-2 gap-2 sm:gap-3 border-t border-border p-2 sm:p-3`,children:y.map((e,t)=>v(IW,{report:e,title:a(`uiLibrary.hubSessionTest.runTitle`,`Run {{index}} · {{policy}}`,{index:t+1,policy:aG(a,e.policy)})},`${String(t)}-${e.policy}`))}),y.length===0&&!T&&v(`div`,{className:`px-3 sm:px-4 py-1.5 sm:py-2 border-t border-border text-[10px] text-foreground-subtle`,children:a(`uiLibrary.hubSessionTest.noRun`,`No run yet.`)})]})}var sG=`object-detection`;function cG(e,t){let n=e.nodeId.localeCompare(t.nodeId);if(n!==0)return n;let r=e.label.localeCompare(t.label);return r===0?e.deviceKey.localeCompare(t.deviceKey):r}function lG(e,t=sG){let n=new Map;for(let r of e)for(let e of r.devices){if(!e.enabled||!$z(r.catalog.models,e.format))continue;let i=eB({catalog:r.catalog,device:e,base:e.steps?.[t]?.modelId});if(i===void 0)continue;let a=n.get(i)??[];a.push({nodeId:r.nodeId,deviceKey:e.key,label:Wz(e)}),n.set(i,a)}let r=new Map;for(let[e,t]of n)r.set(e,[...t].toSorted(cG));return r}function uG(e){return[...e.keys()].toSorted((e,t)=>e.localeCompare(t))}function dG(e,t){let n=new Set(t);return e.filter(e=>n.has(e))}var fG=`Not in use on any node`;function pG(e){return`${e.nodeId} · ${e.label}`}function mG(e,t,n,r){return r?n?e.includes(t)?e:[...e,t]:e.filter(e=>e!==t):n?[t]:[]}function hG(e,t,n){let r=dG(e,t),i=n.find(e=>r.includes(e.modelId)&&e.recommended===!0);return i===void 0?r[0]===void 0?n.find(e=>e.recommended===!0)?.modelId??n[0]?.modelId:r[0]:i.modelId}function gG({models:e,clusterRootModelIds:t,value:n,onChange:r,disabled:i=!1,multiple:a=!0}){let o=q(),s=new Set(n);return c(`div`,{className:`space-y-2`,"data-testid":`training-base-model-picker`,children:[c(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[v(_A,{type:`button`,variant:`secondary`,size:`sm`,disabled:i,onClick:()=>{if(a){r(dG(e.map(e=>e.modelId),t));return}let n=hG(e.map(e=>e.modelId),t,e);r(n===void 0?[]:[n])},children:a?o(`uiLibrary.trainingBaseModelPicker.selectAll`,`Select all roots`):o(`uiLibrary.trainingBaseModelPicker.selectRoot`,`Select cluster root`)}),v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:i||n.length===0,onClick:()=>r([]),children:o(`uiLibrary.trainingBaseModelPicker.clear`,`Clear`)})]}),v(`ul`,{className:`divide-y divide-border-subtle rounded-md border border-border bg-surface`,children:e.map(e=>{let t=s.has(e.modelId),o=e.recommended?`${e.label} (recommended)`:e.label;return v(`li`,{className:`px-2 py-2 sm:px-3`,"data-testid":`training-base-model-${e.modelId}`,children:c(`label`,{className:`flex min-w-0 cursor-pointer items-start gap-2`,children:[v(BB,{className:`mt-0.5`,checked:t,disabled:i,"aria-label":e.label,onChange:t=>r(mG(n,e.modelId,t.target.checked,a))}),c(`span`,{className:`min-w-0 flex-1 space-y-1`,children:[v(`span`,{className:`block text-sm text-foreground`,children:o}),e.placements.length===0?v(`span`,{className:$(Ii,`block`),children:fG}):v(`span`,{className:$(Ii,`flex flex-wrap gap-x-2 gap-y-0.5`),children:e.placements.map(e=>v(`span`,{children:pG(e)},`${e.nodeId}:${e.deviceKey}`))})]})]})},e.modelId)})})]})}E();function _G({children:e,maxHeight:t=300,className:n}){let r=q(),[i,a]=C(!1),o=_(()=>{navigator.clipboard.writeText(e).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})},[e]);return c(`div`,{className:$(`relative group`,n),children:[v($B,{style:{maxHeight:t},children:v(`pre`,{className:`font-mono text-xs bg-surface p-3 rounded-md border border-border-subtle`,children:v(`code`,{children:e})})}),v(`div`,{className:`absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity`,children:v(Rl,{icon:i?dt:ei,"aria-label":r(`uiLibrary.codeBlock.copy`,`Copy code`),variant:`ghost`,size:`sm`,onClick:o})})]})}E();function vG({label:e,icon:t,title:n,description:r,confirmLabel:i,triggerVariant:a=`outline`,confirmVariant:o=`danger`,size:s=`sm`,disabled:l,className:u,action:d,onSuccess:f}){let p=q(),[m,h]=C(!1),[g,_]=C(!1),[y,b]=C(null),x=async()=>{b(null),_(!0);try{let e=await d();f?.(e),h(!1)}catch(e){b(e instanceof Error?e.message:String(e))}finally{_(!1)}};return c(P,{children:[c(_A,{type:`button`,variant:a,size:s,disabled:l,onClick:()=>{b(null),h(!0)},className:u,children:[t&&v(t,{className:`h-3.5 w-3.5`}),e]}),v(SL,{open:m,onOpenChange:e=>!g&&h(e),children:c(TL,{children:[c(EL,{children:[c(kL,{className:`flex items-center gap-2`,children:[v(zi,{className:`h-4 w-4 text-amber-400`}),n??p(`uiLibrary.confirmActionButton.defaultTitle`,`Confirm action`)]}),typeof r==`string`?v(AL,{children:r}):r]}),y&&v(`div`,{className:$(`mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10`,`text-xs text-danger`),children:y}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:s,disabled:g,onClick:()=>h(!1),children:p(`uiLibrary.confirmActionButton.cancel`,`Cancel`)}),c(_A,{type:`button`,variant:o,size:s,disabled:g,onClick:()=>{x()},children:[g&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),i??e]})]})]})})]})}E();var yG=2e3;function bG({value:e,label:t,srLabel:n,className:r,disabled:i}){let a=q(),[o,s]=C(!1),l=_(()=>{e&&navigator.clipboard.writeText(e).then(()=>{s(!0),setTimeout(()=>s(!1),yG)})},[e]);return c(_A,{size:`sm`,variant:`ghost`,type:`button`,disabled:i||e.length===0,onClick:l,className:$(r),"aria-label":o?a(`uiLibrary.copyButton.copied`,`Copied`):a(`uiLibrary.copyButton.copy`,`Copy {{what}}`,{what:n??t??a(`uiLibrary.copyButton.value`,`value`)}),children:[o?v(dt,{className:`h-3.5 w-3.5 text-success`}):v(ei,{className:`h-3.5 w-3.5`}),t?v(`span`,{className:`ml-1`,children:o?a(`uiLibrary.copyButton.copied`,`Copied`):t}):null]})}function xG(e){return e.toLowerCase().replace(/[-_\s]+/g,``)}function SG(e,t){let n=xG(e);return n===``?!0:xG(t).includes(n)}var CG={search:``,facets:[]};function wG(e,t){if(t===void 0)return[];let n=new Map;for(let r of e){let e=t(r);n.set(e,(n.get(e)??0)+1)}return[...n.entries()].map(([e,t])=>({value:e,count:t})).toSorted((e,t)=>t.count-e.count||e.value.localeCompare(t.value))}function TG(e,t){return(t??[]).map(t=>({id:t.id,facets:wG(e,t.value)}))}function EG(e){let t=Object.values(e.groups??{}).some(e=>e.length>0);return e.search.trim()!==``||e.facets.length>0||t}function DG(e,t,n){let r=e.groups?.[t]??[],i=r.includes(n)?r.filter(e=>e!==n):[...r,n];return{...e,groups:{...e.groups,[t]:i}}}function OG(e,t){return{...e,facets:e.facets.includes(t)?e.facets.filter(e=>e!==t):[...e.facets,t]}}function kG(e,t,n){let r=t.search.trim(),i=n.facetValue,a=new Set(wG(e,i).map(e=>e.value)),o=new Set(t.facets.filter(e=>a.has(e))),s=(n.facetGroups??[]).flatMap(n=>{let r=new Set(wG(e,n.value).map(e=>e.value)),i=new Set((t.groups?.[n.id]??[]).filter(e=>r.has(e)));return i.size===0?[]:[{value:n.value,chosen:i}]});return e.filter(e=>!(o.size>0&&i!==void 0&&!o.has(i(e))||s.some(t=>!t.chosen.has(t.value(e)))||r!==``&&!n.searchText(e).some(e=>SG(r,e))))}E();function AG({label:e,options:t,selected:n,onChange:r}){let i=q(),[a,o]=C(!1),s=f(null);b(()=>{if(!a)return;let e=e=>{let t=e.target instanceof Node?e.target:null;t&&s.current&&!s.current.contains(t)&&o(!1)},t=e=>{e.key===`Escape`&&o(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[a]);let l=new Set(n),u=n.length,d=e=>{let n=new Set(l);n.has(e)?n.delete(e):n.add(e),r(t.filter(e=>n.has(e.id)).map(e=>e.id))};return c(`div`,{ref:s,className:`relative`,children:[c(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-haspopup":`listbox`,"aria-expanded":a,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors ${u>0?`border-primary/40 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[c(`span`,{children:[e,u>0?` · ${String(u)}`:``]}),v(de,{className:`h-3 w-3 transition-transform ${a?`rotate-180`:``}`})]}),a&&c(`div`,{role:`listbox`,className:`absolute left-0 top-full mt-1 z-30 min-w-[180px] max-h-72 overflow-y-auto rounded-lg border border-border bg-surface shadow-xl py-1`,children:[u>0&&v(`button`,{type:`button`,onClick:()=>r([]),className:`flex w-full items-center px-3 py-1.5 text-left text-[10.5px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:i(`uiLibrary.multiSelect.clear`,`Clear selection`)}),t.map(e=>{let t=l.has(e.id),n=e.icon;return c(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>d(e.id),className:`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[10.5px] text-foreground hover:bg-surface-hover`,children:[v(`span`,{className:`flex h-3.5 w-3.5 items-center justify-center rounded border shrink-0 ${t?`border-primary bg-primary`:`border-border`}`,children:t&&v(dt,{className:`h-2.5 w-2.5 text-primary-foreground`})}),n&&v(n,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`span`,{className:`truncate`,children:e.label})]},e.id)})]})]})}E();var jG=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,MG=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`;function NG({state:e,facets:t,labels:n,onSearch:r,onToggleFacet:i,onClear:a,facetLabel:o,groups:s=[],onToggleGroupFacet:l}){let u=f(null);As(u);let d=EG(e),p=t.length>1;return c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[c(`label`,{className:`relative min-w-[12rem] flex-1`,children:[v(Ci,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`}),v(`input`,{ref:u,type:`search`,value:e.search,onChange:e=>r(e.target.value),placeholder:n.searchPlaceholder,"aria-label":n.searchLabel,className:`w-full rounded border border-border bg-background py-1.5 pl-7 pr-2 text-xs text-foreground`})]}),p&&v(`div`,{role:`group`,"aria-label":n.facetsLabel,className:`flex flex-wrap gap-1`,children:t.map(t=>{let n=e.facets.includes(t.value);return c(`button`,{type:`button`,onClick:()=>i(t.value),"aria-pressed":n,className:n?jG:MG,children:[o?o(t.value):t.value,` `,v(`span`,{className:`text-foreground-subtle tabular-nums`,children:t.count})]},t.value)})}),s.filter(e=>e.facets.length>1).map(e=>e.display===`menu`?v(AG,{label:e.label,options:e.facets.map(t=>({id:t.value,label:`${e.facetLabel?e.facetLabel(t.value):t.value} (${String(t.count)})`})),selected:e.selected,onChange:t=>{let n=new Set(t);for(let t of e.facets)n.has(t.value)!==e.selected.includes(t.value)&&l?.(e.id,t.value)}},e.id):c(`div`,{role:`group`,"aria-label":e.label,className:`flex flex-wrap items-center gap-1`,children:[v(`span`,{"aria-hidden":!0,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),e.facets.map(t=>{let n=e.selected.includes(t.value);return c(`button`,{type:`button`,onClick:()=>l?.(e.id,t.value),"aria-pressed":n,className:n?jG:MG,children:[e.facetLabel?e.facetLabel(t.value):t.value,` `,v(`span`,{className:`text-foreground-subtle tabular-nums`,children:t.count})]},t.value)})]},e.id)),d&&c(`button`,{type:`button`,onClick:a,className:`flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[v(Zn,{className:`h-3 w-3`}),n.clearLabel]})]})}E();function PG(e,t,n=CG){let[r,i]=C(n),a=_(e=>{i(t=>({...t,search:e}))},[]),o=_(e=>{i(t=>OG(t,e))},[]),s=_((e,t)=>{i(n=>DG(n,e,t))},[]),c=_(()=>i(CG),[]),{searchText:l,facetValue:u,facetGroups:d}=t,f=p(()=>wG(e,u),[e,u]);return{state:r,setSearch:a,toggleFacet:o,toggleGroupFacet:s,groups:p(()=>TG(e,d).map(e=>({...e,selected:r.groups?.[e.id]??[]})),[e,d,r.groups]),clear:c,facets:f,rows:p(()=>kG(e,r,{searchText:l,facetValue:u,facetGroups:d}),[e,r,l,u,d]),active:EG(r)}}var FG=Ki(),IG=new Set([`live`,`recording`,`heatmapScrub`]),LG=Object.freeze(Object.fromEntries(so.filter(e=>!IG.has(e)).map(e=>[e,Hi(FG.swatches,FG.fallbacks,e)])));function RG(e){let t=e[0];if(t===void 0)throw Error(`display palette has no fallback colour`);return t}var zG=RG(FG.fallbacks);function BG(e,t,n){let r=t?.[e];if(r!==void 0&&r.length>0)return r;let i=e.toLowerCase(),a=t?.[i];return a!==void 0&&a.length>0?a:Hi(n?.swatches??FG.swatches,n?.fallbacks??FG.fallbacks,e)}E();var VG=Ki(),HG=O({status:`absent`});function UG({value:e,children:t}){return v(HG.Provider,{value:e,children:t})}function WG(){return I(HG)}function GG(){let e=I(HG),t=e.status===`ready`?e.palette:VG;return(e,n)=>BG(e,n,t)}E();function KG({src:e,imageWidth:t,imageHeight:n,detections:r=[],classColors:i,aspectRatio:a,className:o,placeholder:s,showConfidence:l=!0,minConfidence:u=0,borderWidth:d=2}){let f=q(),p=GG();function m(e){return p(e,i)}let h=a??(t&&n?`${t}/${n}`:`16/9`),g=r.filter(e=>e.score>=u),_=g.filter(e=>e.kind===`first-level`),y=g.filter(e=>e.kind===`detail`),b=XG(y,e=>e.parentId??``);return v(`div`,{className:$(`rounded-lg border border-border bg-surface overflow-hidden relative`,o),style:{aspectRatio:h},children:e?c(P,{children:[v(`img`,{src:e,className:`absolute inset-0 w-full h-full object-fill`,alt:``}),g.map((e,r)=>e.debug?.mask&&e.debug.maskWidth&&e.debug.maskHeight?v(JG,{mask:e.debug.mask,maskWidth:e.debug.maskWidth,maskHeight:e.debug.maskHeight,bbox:e.bbox,imageWidth:t,imageHeight:n,color:m(e.macroClass)},`mask-${r}`):null),_.map(e=>{let r=b.get(e.id)??[];return v(qG,{detection:e,imageWidth:t,imageHeight:n,color:m(e.macroClass),showConfidence:l,borderWidth:e.debug?.mask?1:d,children:r.map(t=>v(YG,{child:t,parentBbox:e.bbox,color:m(t.macroClass),showConfidence:l},`child-${t.id}`))},`det-${e.id}`)}),y.filter(e=>!e.parentId||!_.some(t=>t.id===e.parentId)).map(e=>v(qG,{detection:e,imageWidth:t,imageHeight:n,color:m(e.macroClass),showConfidence:l,borderWidth:d},`orphan-${e.id}`))]}):v(`div`,{className:`w-full h-full flex items-center justify-center text-foreground-subtle text-sm`,children:s??f(`uiLibrary.detectionCanvas.noImage`,`No image loaded`)})})}function qG({detection:e,imageWidth:t,imageHeight:n,color:r,showConfidence:i,borderWidth:a,children:o}){let s=GG(),{x:l,y:u,width:d,height:f}=e.bbox,p=c(`div`,{className:`absolute left-0 flex flex-col items-start gap-px`,style:{bottom:`100%`,marginBottom:`2px`},children:[c(`span`,{className:`text-[10px] px-1 rounded-sm whitespace-nowrap text-white`,style:{backgroundColor:r},children:[e.macroClass,i&&` ${(e.score*100).toFixed(0)}%`]}),e.labels.map((t,n)=>c(`span`,{className:`text-[9px] font-semibold px-1 rounded-sm whitespace-nowrap text-white`,style:{backgroundColor:s(t.label)},children:[t.label,` `,(t.score*100).toFixed(0),`%`]},`${e.id}-lbl-${n}`))]});return c(`div`,{className:`absolute rounded-sm`,style:{left:`${l/t*100}%`,top:`${u/n*100}%`,width:`${d/t*100}%`,height:`${f/n*100}%`,borderWidth:`${a}px`,borderStyle:`solid`,borderColor:r},children:[p,o]})}function JG({mask:e,maskWidth:t,maskHeight:n,bbox:r,imageWidth:i,imageHeight:a,color:o}){let s=f(null);return b(()=>{let r=s.current;if(!r)return;let i=r.getContext(`2d`);if(!i)return;let a=atob(e),c=new Uint8Array(a.length);for(let e=0;e<a.length;e++)c[e]=a.charCodeAt(e);let l=parseInt(o.slice(1,3),16),u=parseInt(o.slice(3,5),16),d=parseInt(o.slice(5,7),16);r.width=t,r.height=n;let f=i.createImageData(t,n),p=t*n;for(let e=0;e<p;e++){let t=e<c.length?c[e]:0,n=e*4;t>0&&(f.data[n]=l,f.data[n+1]=u,f.data[n+2]=d,f.data[n+3]=120)}i.putImageData(f,0,0)},[e,t,n,o]),v(`canvas`,{ref:s,className:`absolute pointer-events-none`,style:{left:`${r.x/i*100}%`,top:`${r.y/a*100}%`,width:`${r.width/i*100}%`,height:`${r.height/a*100}%`,imageRendering:`pixelated`}})}function YG({child:e,parentBbox:t,color:n,showConfidence:r}){let i=GG();if(t.width<=0||t.height<=0)return null;let a=(e.bbox.x-t.x)/t.width*100,o=(e.bbox.y-t.y)/t.height*100,s=e.bbox.width/t.width*100,l=e.bbox.height/t.height*100;return v(`div`,{className:`absolute rounded-sm`,style:{left:`${Math.max(0,a)}%`,top:`${Math.max(0,o)}%`,width:`${Math.min(100,s)}%`,height:`${Math.min(100,l)}%`,borderWidth:`1px`,borderStyle:`solid`,borderColor:n},children:c(`div`,{className:`absolute left-0 flex flex-col items-start gap-px`,style:{bottom:`100%`,marginBottom:`1px`},children:[c(`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((t,n)=>c(`span`,{className:`text-[8px] font-semibold px-0.5 rounded-sm whitespace-nowrap text-white`,style:{backgroundColor:i(t.label)},children:[t.label,` `,(t.score*100).toFixed(0),`%`]},`${e.id}-lbl-${n}`))]})})}function XG(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e)??[];i.push(r),n.set(e,i)}return n}var ZG={idle:{labelKey:`uiLibrary.phase.idle`,labelFallback:`Idle`,textColor:`text-foreground-subtle`,badgeClass:`border-border bg-surface-hover text-foreground-subtle`,dotClass:`bg-gray-400`,icon:`PowerOff`},active:{labelKey:`uiLibrary.phase.active`,labelFallback:`Active`,textColor:`text-success`,badgeClass:`border-success/40 bg-success/10 text-success`,dotClass:`bg-red-500 animate-pulse`,icon:`Activity`},watching:{labelKey:`uiLibrary.phase.watching`,labelFallback:`Watching`,textColor:`text-foreground-subtle`,badgeClass:`border-border bg-surface-hover text-foreground-subtle`,dotClass:`bg-emerald-500`,icon:`Eye`},"load-shed":{labelKey:`uiLibrary.phase.loadShed`,labelFallback:`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:{labelKey:`uiLibrary.phase.paused`,labelFallback:`Paused`,textColor:`text-gray-400`,badgeClass:`border-gray-500/40 bg-gray-500/10 text-gray-400`,dotClass:`bg-gray-400`,icon:`PauseCircle`}};function QG(e,t=Fn){let{labelKey:n,labelFallback:r,...i}=ZG[e]??ZG.watching;return{...i,label:t(n,r)}}function $G(e){return e.track?.movementState===`idle`}function eK({detections:{motion:e,motionRaw:t,detection:n,phase:r},showMotionZones:i=!0,showMotionRaw:a=!0,showDetections:o=!0,showMoving:s=!0,showStationary:l=!0,stationaryObjects:u,showPhaseIndicator:d=!0}){let f=i&&e&&e.zones.length>0,p=a&&t&&t.boxes.length>0,m=o&&n?n.detections.filter(e=>$G(e)?l:s):[],h=m.length>0,g=o&&l?u??[]:[],_=g.length>0;return!f&&!p&&!h&&!_&&!d?null:c(`div`,{className:`absolute inset-0 pointer-events-none z-10`,children:[d&&v(tK,{phase:r}),p&&v(nK,{raw:t}),f&&v(rK,{motion:e}),_&&v(iK,{boxes:g}),h&&v(aK,{detections:m,frameWidth:n.frameWidth,frameHeight:n.frameHeight})]})}function tK({phase:e}){let t=QG(e);return c(`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:[v(`span`,{className:`w-2 h-2 rounded-full ${t.dotClass}`}),v(`span`,{className:`text-[10px] font-semibold text-white uppercase tracking-wider`,children:t.label})]})}function nK({raw:e}){return e.frameWidth===0||e.frameHeight===0?null:v(P,{children:e.boxes.map((t,n)=>{let[r,i,a,o]=t.bbox,s=r/e.frameWidth*100,c=i/e.frameHeight*100,l=(a-r)/e.frameWidth*100,u=(o-i)/e.frameHeight*100,d=Math.max(.05,Math.min(.25,t.changeScore*.3));return v(`div`,{className:`absolute rounded-sm`,style:{left:`${s}%`,top:`${c}%`,width:`${l}%`,height:`${u}%`,backgroundColor:`rgba(239, 68, 68, ${d})`}},`mr-${n}`)})})}function rK({motion:e}){return e.frameWidth===0||e.frameHeight===0?null:v(P,{children:e.zones.filter(t=>t.w*t.h/(e.frameWidth*e.frameHeight)<.9).map((t,n)=>{let r=Math.max(.15,Math.min(.5,t.intensity/255));return v(`div`,{className:`absolute rounded-sm`,style:{left:`${t.x/e.frameWidth*100}%`,top:`${t.y/e.frameHeight*100}%`,width:`${t.w/e.frameWidth*100}%`,height:`${t.h/e.frameHeight*100}%`,border:`1px solid rgba(250, 204, 21, ${r})`,backgroundColor:`rgba(250, 204, 21, ${r*.15})`}},`mz-${n}`)})})}function iK({boxes:e}){let t=GG(),n=Date.now();return v(P,{children:e.map(e=>{let r=t(e.className);return v(`div`,{"data-census-box":``,className:`absolute`,style:{left:`${String(e.x1*100)}%`,top:`${String(e.y1*100)}%`,width:`${String((e.x2-e.x1)*100)}%`,height:`${String((e.y2-e.y1)*100)}%`,borderColor:r,borderWidth:ro.borderWidth,borderStyle:ro.dashed?`dashed`:`solid`,borderRadius:ro.borderRadius,opacity:ro.opacity},children:c(`span`,{className:`absolute -top-5 left-0 px-1 text-[10px] font-medium rounded-sm whitespace-nowrap`,style:{backgroundColor:r,color:`#000`},children:[e.label??e.className,` · `,wee(n-e.becameStationaryAt)]})},e.id)})})}function aK({detections:e,frameWidth:t,frameHeight:n}){let r=GG();return t===0||n===0?null:v(P,{children:e.map(e=>{let{x:i,y:a,width:o,height:s}=e.bbox,c=i/t*100,l=a/n*100,u=o/t*100,d=s/n*100,f=r(e.macroClass),p=[`${e.macroClass} ${(e.score*100).toFixed(0)}%`];for(let t of e.labels)p.push(t.label);return v(`div`,{className:`absolute border-2 rounded-sm`,style:{left:`${c}%`,top:`${l}%`,width:`${u}%`,height:`${d}%`,borderColor:f},children:v(`div`,{className:`absolute -top-4 left-0 px-1 py-0.5 text-[9px] font-bold text-white rounded-sm whitespace-nowrap`,style:{backgroundColor:f},children:p.join(` | `)})},`det-${e.id}`)})})}E();function oK({detections:e,classColors:t,className:n,hiddenKeys:r,onToggleVisibility:i}){let a=q(),o=t;if(e.length===0)return v(`div`,{className:`text-sm text-foreground-subtle italic text-center py-4`,children:a(`uiLibrary.detectionResultTree.none`,`No detections`)});let s=e.filter(e=>e.kind===`first-level`),l=e.filter(e=>e.kind===`detail`),u=new Map;for(let e of l){if(!e.parentId)continue;let t=u.get(e.parentId)??[];t.push(e),u.set(e.parentId,t)}let d=l.filter(e=>!e.parentId||!s.some(t=>t.id===e.parentId));return c(`div`,{className:n,children:[v(`div`,{className:`text-xs font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:a(`uiLibrary.detectionResultTree.title`,`Detections ({{count}})`,{count:e.length})}),c(`div`,{className:`space-y-2`,children:[s.map(e=>v(sK,{detection:e,children_:u.get(e.id)??[],colors:o,hiddenKeys:r,onToggleVisibility:i},e.id)),d.map(e=>v(sK,{detection:e,children_:[],colors:o,hiddenKeys:r,onToggleVisibility:i},e.id))]})]})}function sK({detection:e,children_:t,colors:n,hiddenKeys:r,onToggleVisibility:i}){let a=GG(),o=a(e.macroClass,n),s=!r?.has(e.id),l=e.debug?.mask,u=e.debug?.maskWidth,d=e.debug?.maskHeight,f=e.debug?.alternateLabels;return c(`div`,{className:`rounded-md border border-border bg-surface p-3 space-y-1 ${s?``:`opacity-40`}`,children:[c(`div`,{className:`flex justify-between items-center`,children:[c(`div`,{className:`flex items-center gap-2`,children:[i&&v(`input`,{type:`checkbox`,checked:s,onChange:()=>i(e.id,!s),className:`h-3.5 w-3.5 rounded border-border accent-primary cursor-pointer shrink-0`}),v(`span`,{className:`h-2.5 w-2.5 rounded-full shrink-0`,style:{backgroundColor:o}}),v(`span`,{className:`text-sm font-medium text-foreground`,children:e.macroClass}),e.kind===`detail`&&v(`span`,{className:`text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary`,children:`detail`}),l&&u&&d&&c(`span`,{className:`text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary`,children:[`mask `,u,`x`,d]})]}),v(uK,{confidence:e.score})]}),c(`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&&v(`div`,{className:`flex flex-wrap gap-1 mt-1`,children:e.labels.map((e,t)=>c(`span`,{className:`inline-flex items-center gap-1 text-[10px] font-medium px-1.5 py-0.5 rounded-full`,style:{backgroundColor:a(e.label,n)+`20`,color:a(e.label,n)},children:[e.label,c(`span`,{className:`opacity-60`,children:[(e.score*100).toFixed(0),`%`]}),e.detectionId&&c(`span`,{className:`opacity-40 text-[8px]`,children:[`→ `,e.detectionId]})]},t))}),f&&Object.keys(f).length>0&&v(lK,{alternateLabels:f,colors:n}),t.length>0&&v(cK,{items:t,colors:n,hiddenKeys:r,onToggleVisibility:i})]})}function cK({items:e,colors:t,hiddenKeys:n,onToggleVisibility:r}){let i=GG();return v(`div`,{className:`ml-4 mt-1.5 space-y-1.5 border-l-2 border-border pl-3`,children:e.map(e=>{let a=i(e.macroClass,t),o=!n?.has(e.id),s=e.debug?.mask,l=e.debug?.maskWidth,u=e.debug?.maskHeight;return c(`div`,{className:`text-xs space-y-0.5 ${o?``:`opacity-40`}`,children:[c(`div`,{className:`flex items-center gap-1.5`,children:[r&&v(`input`,{type:`checkbox`,checked:o,onChange:()=>r(e.id,!o),className:`h-3 w-3 rounded border-border accent-primary cursor-pointer shrink-0`}),v(`span`,{className:`h-1.5 w-1.5 rounded-full shrink-0`,style:{backgroundColor:a}}),v(`span`,{className:`font-medium`,style:{color:a},children:e.macroClass}),c(`span`,{className:`text-foreground-subtle`,children:[(e.score*100).toFixed(0),`%`]}),s&&l&&u&&c(`span`,{className:`text-[9px] font-mono px-1 py-0.5 rounded bg-primary/10 text-primary`,children:[`mask `,l,`x`,u]})]}),e.labels.length>0&&v(`div`,{className:`flex flex-wrap gap-1 ml-5 mt-0.5`,children:e.labels.map((e,n)=>c(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] font-medium px-1 py-0.5 rounded-full`,style:{backgroundColor:i(e.label,t)+`20`,color:i(e.label,t)},children:[e.label,` `,c(`span`,{className:`opacity-60`,children:[(e.score*100).toFixed(0),`%`]})]},n))})]},e.id)})})}function lK({alternateLabels:e,colors:t}){let[n,r]=C(!1),i=GG(),a=q(),o=Object.keys(e);return c(`div`,{className:`mt-1`,children:[c(`button`,{onClick:()=>r(e=>!e),className:`text-[9px] text-foreground-subtle hover:text-foreground transition-colors flex items-center gap-1`,children:[v(`span`,{className:`transition-transform ${n?`rotate-90`:``}`,children:`▶`}),a(`uiLibrary.detectionResultTree.alternates`,{one:`Alternates ({{count}} source)`,other:`Alternates ({{count}} sources)`},{count:o.length})]}),n&&v(`div`,{className:`mt-1 ml-3 space-y-1.5`,children:o.map(n=>{let r=e[n];return!r||r.length===0?null:c(`div`,{children:[v(`div`,{className:`text-[9px] font-medium text-foreground-subtle mb-0.5`,children:n}),v(`div`,{className:`flex flex-wrap gap-1`,children:r.map((e,r)=>c(`span`,{className:`inline-flex items-center gap-0.5 text-[9px] px-1 py-0.5 rounded-full`,style:{backgroundColor:i(n,t)+`10`,color:i(n,t),opacity:Math.max(.4,e.score)},children:[e.label,c(`span`,{className:`opacity-60`,children:[(e.score*100).toFixed(1),`%`]})]},r))})]},n)})})]})}function uK({confidence:e}){return c(`span`,{className:`text-xs font-medium px-2 py-0.5 rounded-full ${e>=.8?`bg-success/10 text-success`:e>=.5?`bg-warning/10 text-warning`:`bg-danger/10 text-danger`}`,children:[(e*100).toFixed(1),`%`]})}var dK=class{constructor(){this.keyToValue=new Map,this.valueToKey=new Map}set(e,t){this.keyToValue.set(e,t),this.valueToKey.set(t,e)}getByKey(e){return this.keyToValue.get(e)}getByValue(e){return this.valueToKey.get(e)}clear(){this.keyToValue.clear(),this.valueToKey.clear()}},fK=class{constructor(e){this.generateIdentifier=e,this.kv=new dK}register(e,t){this.kv.getByValue(e)||(t||=this.generateIdentifier(e),this.kv.set(t,e))}clear(){this.kv.clear()}getIdentifier(e){return this.kv.getByValue(e)}getValue(e){return this.kv.getByKey(e)}},pK=class extends fK{constructor(){super(e=>e.name),this.classToAllowedProps=new Map}register(e,t){typeof t==`object`?(t.allowProps&&this.classToAllowedProps.set(e,t.allowProps),super.register(e,t.identifier)):super.register(e,t)}getAllowedProps(e){return this.classToAllowedProps.get(e)}};function mK(e){if(`values`in Object)return Object.values(e);let t=[];for(let n in e)e.hasOwnProperty(n)&&t.push(e[n]);return t}function hK(e,t){let n=mK(e);if(`find`in n)return n.find(t);let r=n;for(let e=0;e<r.length;e++){let n=r[e];if(t(n))return n}}function gK(e,t){Object.entries(e).forEach(([e,n])=>t(n,e))}function _K(e,t){return e.indexOf(t)!==-1}function vK(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(t(r))return r}}var yK=class{constructor(){this.transfomers={}}register(e){this.transfomers[e.name]=e}findApplicable(e){return hK(this.transfomers,t=>t.isApplicable(e))}findByName(e){return this.transfomers[e]}},bK=e=>Object.prototype.toString.call(e).slice(8,-1),xK=e=>e===void 0,SK=e=>e===null,CK=e=>typeof e!=`object`||!e||e===Object.prototype?!1:Object.getPrototypeOf(e)===null?!0:Object.getPrototypeOf(e)===Object.prototype,wK=e=>CK(e)&&Object.keys(e).length===0,TK=e=>Array.isArray(e),EK=e=>typeof e==`string`,DK=e=>typeof e==`number`&&!isNaN(e),OK=e=>typeof e==`boolean`,kK=e=>e instanceof RegExp,AK=e=>e instanceof Map,jK=e=>e instanceof Set,MK=e=>bK(e)===`Symbol`,NK=e=>e instanceof Date&&!isNaN(e.valueOf()),PK=e=>e instanceof Error,FK=e=>typeof e==`number`&&isNaN(e),IK=e=>OK(e)||SK(e)||xK(e)||DK(e)||EK(e)||MK(e),LK=e=>typeof e==`bigint`,RK=e=>e===1/0||e===-1/0,zK=e=>ArrayBuffer.isView(e)&&!(e instanceof DataView),BK=e=>e instanceof URL,VK=e=>e.replace(/\\/g,`\\\\`).replace(/\./g,`\\.`),HK=e=>e.map(String).map(VK).join(`.`),UK=(e,t)=>{let n=[],r=``;for(let i=0;i<e.length;i++){let a=e.charAt(i);if(!t&&a===`\\`){let t=e.charAt(i+1);if(t===`\\`){r+=`\\`,i++;continue}else if(t!==`.`)throw Error(`invalid path`)}if(a===`\\`&&e.charAt(i+1)===`.`){r+=`.`,i++;continue}if(a===`.`){n.push(r),r=``;continue}r+=a}let i=r;return n.push(i),n};function WK(e,t,n,r){return{isApplicable:e,annotation:t,transform:n,untransform:r}}var GK=[WK(xK,`undefined`,()=>null,()=>void 0),WK(LK,`bigint`,e=>e.toString(),e=>typeof BigInt<`u`?BigInt(e):(console.error(`Please add a BigInt polyfill.`),e)),WK(NK,`Date`,e=>e.toISOString(),e=>new Date(e)),WK(PK,`Error`,(e,t)=>{let n={name:e.name,message:e.message};return`cause`in e&&(n.cause=e.cause),t.allowedErrorProps.forEach(t=>{n[t]=e[t]}),n},(e,t)=>{let n=Error(e.message,{cause:e.cause});return n.name=e.name,n.stack=e.stack,t.allowedErrorProps.forEach(t=>{n[t]=e[t]}),n}),WK(kK,`regexp`,e=>``+e,e=>{let t=e.slice(1,e.lastIndexOf(`/`)),n=e.slice(e.lastIndexOf(`/`)+1);return new RegExp(t,n)}),WK(jK,`set`,e=>[...e.values()],e=>new Set(e)),WK(AK,`map`,e=>[...e.entries()],e=>new Map(e)),WK(e=>FK(e)||RK(e),`number`,e=>FK(e)?`NaN`:e>0?`Infinity`:`-Infinity`,Number),WK(e=>e===0&&1/e==-1/0,`number`,()=>`-0`,Number),WK(BK,`URL`,e=>e.toString(),e=>new URL(e))];function KK(e,t,n,r){return{isApplicable:e,annotation:t,transform:n,untransform:r}}var qK=KK((e,t)=>MK(e)?!!t.symbolRegistry.getIdentifier(e):!1,(e,t)=>[`symbol`,t.symbolRegistry.getIdentifier(e)],e=>e.description,(e,t,n)=>{let r=n.symbolRegistry.getValue(t[1]);if(!r)throw Error(`Trying to deserialize unknown symbol`);return r}),JK=[Int8Array,Uint8Array,Int16Array,Uint16Array,Int32Array,Uint32Array,Float32Array,Float64Array,Uint8ClampedArray].reduce((e,t)=>(e[t.name]=t,e),{}),YK=KK(zK,e=>[`typed-array`,e.constructor.name],e=>[...e],(e,t)=>{let n=JK[t[1]];if(!n)throw Error(`Trying to deserialize unknown typed array`);return new n(e)});function XK(e,t){return e?.constructor?!!t.classRegistry.getIdentifier(e.constructor):!1}var ZK=KK(XK,(e,t)=>[`class`,t.classRegistry.getIdentifier(e.constructor)],(e,t)=>{let n=t.classRegistry.getAllowedProps(e.constructor);if(!n)return{...e};let r={};return n.forEach(t=>{r[t]=e[t]}),r},(e,t,n)=>{let r=n.classRegistry.getValue(t[1]);if(!r)throw Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);return Object.assign(Object.create(r.prototype),e)}),QK=KK((e,t)=>!!t.customTransformerRegistry.findApplicable(e),(e,t)=>[`custom`,t.customTransformerRegistry.findApplicable(e).name],(e,t)=>t.customTransformerRegistry.findApplicable(e).serialize(e),(e,t,n)=>{let r=n.customTransformerRegistry.findByName(t[1]);if(!r)throw Error(`Trying to deserialize unknown custom value`);return r.deserialize(e)}),$K=[ZK,qK,QK,YK],eq=(e,t)=>{let n=vK($K,n=>n.isApplicable(e,t));if(n)return{value:n.transform(e,t),type:n.annotation(e,t)};let r=vK(GK,n=>n.isApplicable(e,t));if(r)return{value:r.transform(e,t),type:r.annotation}},tq={};GK.forEach(e=>{tq[e.annotation]=e});var nq=(e,t,n)=>{if(TK(t))switch(t[0]){case`symbol`:return qK.untransform(e,t,n);case`class`:return ZK.untransform(e,t,n);case`custom`:return QK.untransform(e,t,n);case`typed-array`:return YK.untransform(e,t,n);default:throw Error(`Unknown transformation: `+t)}else{let r=tq[t];if(!r)throw Error(`Unknown transformation: `+t);return r.untransform(e,n)}},rq=(e,t)=>{if(t>e.size)throw Error(`index out of bounds`);let n=e.keys();for(;t>0;)n.next(),t--;return n.next().value};function iq(e){if(_K(e,`__proto__`))throw Error(`__proto__ is not allowed as a property`);if(_K(e,`prototype`))throw Error(`prototype is not allowed as a property`);if(_K(e,`constructor`))throw Error(`constructor is not allowed as a property`)}var aq=(e,t)=>{iq(t);for(let n=0;n<t.length;n++){let r=t[n];if(jK(e))e=rq(e,+r);else if(AK(e)){let i=+r,a=+t[++n]==0?`key`:`value`,o=rq(e,i);switch(a){case`key`:e=o;break;case`value`:e=e.get(o);break}}else e=e[r]}return e},oq=(e,t,n)=>{if(iq(t),t.length===0)return n(e);let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];if(TK(r)){let e=+n;r=r[e]}else if(CK(r))r=r[n];else if(jK(r)){let e=+n;r=rq(r,e)}else if(AK(r)){if(e===t.length-2)break;let i=+n,a=+t[++e]==0?`key`:`value`,o=rq(r,i);switch(a){case`key`:r=o;break;case`value`:r=r.get(o);break}}}let i=t[t.length-1];if(TK(r)?r[+i]=n(r[+i]):CK(r)&&(r[i]=n(r[i])),jK(r)){let e=rq(r,+i),t=n(e);e!==t&&(r.delete(e),r.add(t))}if(AK(r)){let e=+t[t.length-2],a=rq(r,e);switch(+i==0?`key`:`value`){case`key`:{let e=n(a);r.set(e,r.get(a)),e!==a&&r.delete(a);break}case`value`:r.set(a,n(r.get(a)));break}}return e},sq=e=>e<1;function cq(e,t,n,r=[]){if(!e)return;let i=sq(n);if(!TK(e)){gK(e,(e,a)=>cq(e,t,n,[...r,...UK(a,i)]));return}let[a,o]=e;o&&gK(o,(e,a)=>{cq(e,t,n,[...r,...UK(a,i)])}),t(a,r)}function lq(e,t,n,r){return cq(t,(t,n)=>{e=oq(e,n,e=>nq(e,t,r))},n),e}function uq(e,t,n){let r=sq(n);function i(t,n){let i=aq(e,UK(n,r));t.map(e=>UK(e,r)).forEach(t=>{e=oq(e,t,()=>i)})}if(TK(t)){let[n,a]=t;n.forEach(t=>{e=oq(e,UK(t,r),()=>e)}),a&&gK(a,i)}else gK(t,i);return e}var dq=(e,t)=>CK(e)||TK(e)||AK(e)||jK(e)||PK(e)||XK(e,t);function fq(e,t,n){let r=n.get(e);r?r.push(t):n.set(e,[t])}function pq(e,t){let n={},r;return e.forEach(e=>{if(e.length<=1)return;t||(e=e.map(e=>e.map(String)).sort((e,t)=>e.length-t.length));let[i,...a]=e;i.length===0?r=a.map(HK):n[HK(i)]=a.map(HK)}),r?wK(n)?[r]:[r,n]:wK(n)?void 0:n}var mq=(e,t,n,r,i=[],a=[],o=new Map)=>{let s=IK(e);if(!s){fq(e,i,t);let n=o.get(e);if(n)return r?{transformedValue:null}:n}if(!dq(e,n)){let t=eq(e,n),r=t?{transformedValue:t.value,annotations:[t.type]}:{transformedValue:e};return s||o.set(e,r),r}if(_K(a,e))return{transformedValue:null};let c=eq(e,n),l=c?.value??e,u=TK(l)?[]:{},d={};gK(l,(s,c)=>{if(c===`__proto__`||c===`constructor`||c===`prototype`)throw Error(`Detected property ${c}. This is a prototype pollution risk, please remove it from your object.`);let l=mq(s,t,n,r,[...i,c],[...a,e],o);u[c]=l.transformedValue,TK(l.annotations)?d[VK(c)]=l.annotations:CK(l.annotations)&&gK(l.annotations,(e,t)=>{d[VK(c)+`.`+t]=e})});let f=wK(d)?{transformedValue:u,annotations:c?[c.type]:void 0}:{transformedValue:u,annotations:c?[c.type,d]:d};return s||o.set(e,f),f};function hq(e){return Object.prototype.toString.call(e).slice(8,-1)}function gq(e){return hq(e)===`Array`}function _q(e){if(hq(e)!==`Object`)return!1;let t=Object.getPrototypeOf(e);return!!t&&t.constructor===Object&&t===Object.prototype}function vq(e,t,n,r,i){let a={}.propertyIsEnumerable.call(r,t)?`enumerable`:`nonenumerable`;a===`enumerable`&&(e[t]=n),i&&a===`nonenumerable`&&Object.defineProperty(e,t,{value:n,enumerable:!1,writable:!0,configurable:!0})}function yq(e,t={}){if(gq(e))return e.map(e=>yq(e,t));if(!_q(e))return e;let n=Object.getOwnPropertyNames(e),r=Object.getOwnPropertySymbols(e);return[...n,...r].reduce((n,r)=>{if(r===`__proto__`||gq(t.props)&&!t.props.includes(r))return n;let i=e[r];return vq(n,r,yq(i,t),e,t.nonenumerable),n},{})}var bq=class{constructor({dedupe:e=!1}={}){this.classRegistry=new pK,this.symbolRegistry=new fK(e=>e.description??``),this.customTransformerRegistry=new yK,this.allowedErrorProps=[],this.dedupe=e}serialize(e){let t=new Map,n=mq(e,t,this,this.dedupe),r={json:n.transformedValue};n.annotations&&(r.meta={...r.meta,values:n.annotations});let i=pq(t,this.dedupe);return i&&(r.meta={...r.meta,referentialEqualities:i}),r.meta&&(r.meta.v=1),r}deserialize(e,t){let{json:n,meta:r}=e,i=t?.inPlace?n:yq(n);return r?.values&&(i=lq(i,r.values,r.v??0,this)),r?.referentialEqualities&&(i=uq(i,r.referentialEqualities,r.v??0)),i}stringify(e){return JSON.stringify(this.serialize(e))}parse(e){return this.deserialize(JSON.parse(e),{inPlace:!0})}registerClass(e,t){this.classRegistry.register(e,t)}registerSymbol(e,t){this.symbolRegistry.register(e,t)}registerCustom(e,t){this.customTransformerRegistry.register({name:t,...e})}allowErrorProps(...e){this.allowedErrorProps.push(...e)}};bq.defaultInstance=new bq,bq.serialize=bq.defaultInstance.serialize.bind(bq.defaultInstance),bq.deserialize=bq.defaultInstance.deserialize.bind(bq.defaultInstance),bq.stringify=bq.defaultInstance.stringify.bind(bq.defaultInstance),bq.parse=bq.defaultInstance.parse.bind(bq.defaultInstance),bq.registerClass=bq.defaultInstance.registerClass.bind(bq.defaultInstance),bq.registerSymbol=bq.defaultInstance.registerSymbol.bind(bq.defaultInstance),bq.registerCustom=bq.defaultInstance.registerCustom.bind(bq.defaultInstance),bq.allowErrorProps=bq.defaultInstance.allowErrorProps.bind(bq.defaultInstance),bq.serialize,bq.deserialize,bq.stringify,bq.parse,bq.registerClass,bq.registerCustom,bq.registerSymbol,bq.allowErrorProps;var xq=5*6e4,Sq=3e4,Cq=1e3;function wq(e){let t=e.split(`.`)[1];if(t===void 0)return null;try{let e=t.replace(/-/g,`+`).replace(/_/g,`/`),n=typeof atob==`function`?atob(e):Buffer.from(e,`base64`).toString(`utf8`),r=JSON.parse(n);if(typeof r!=`object`||!r)return null;let i=Reflect.get(r,`exp`);return typeof i==`number`&&Number.isFinite(i)?i*1e3:null}catch{return null}}function Tq(e){if(typeof e!=`object`||!e)return!1;let t=Reflect.get(e,`data`),n=typeof t==`object`&&t?Reflect.get(t,`code`):void 0;return n===`UNAUTHORIZED`||n===`FORBIDDEN`}var Eq=class{options;current=null;cancel=null;inflight=null;now;setTimer;constructor(e){this.options=e,this.now=e.now??Date.now,this.setTimer=e.setTimer??((e,t)=>{let n=setTimeout(e,t);return()=>clearTimeout(n)})}adopt(e){this.current=e,this.schedule()}tokens(){return this.current}async ensureFresh(e=this.margin()){let t=this.current;if(t?.refreshToken===void 0)return;let n=this.expiresAtOf(t);n!==null&&n-this.now()>e||await this.refreshNow()}refreshNow(){if(this.inflight!==null)return this.inflight;let e=this.current?.refreshToken;return e===void 0?Promise.resolve(null):(this.inflight=this.options.refresh(e).then(e=>(this.current=e,this.options.onTokens(e),this.schedule(),e)).catch(e=>(Tq(e)?(this.stop(),this.current=null,this.options.onExpired()):this.arm(Sq),null)).finally(()=>{this.inflight=null}),this.inflight)}stop(){this.cancel?.(),this.cancel=null}margin(){return this.options.marginMs??xq}expiresAtOf(e){return e.expiresAt??wq(e.token)}schedule(){this.stop();let e=this.current;if(e?.refreshToken===void 0)return;let t=this.expiresAtOf(e);if(t===null)return;let n=t-this.now(),r=Math.min(this.margin(),Math.max(0,n/2));this.arm(Math.max(Cq,n-r))}arm(e){this.stop(),this.cancel=this.setTimer(()=>{this.cancel=null,this.refreshNow()},e)}};function Dq(e){return e.refreshable===!0?{refreshable:!0}:{}}var Oq=1e4,kq=6e3,Aq=2e3,jq=4401,Mq=15e3,Nq=new Set([`auth.refreshSession`,`auth.listLoginMethods`,`auth.getServerName`,`auth.login`,`auth.loginVerifyTotp`,`auth.loginBeginPasskey`,`auth.loginVerifyPasskey`,`auth.passkeyLoginBegin`,`auth.passkeyLoginFinish`]),Pq=3e4,Fq=class{_serverUrl;useWs;baseRetryMs;maxRetryMs;onConnectionChange;token;getLanguage;refreshCredential;_trpcClient;_wsClient=null;_eventSubs=new Map;mirror=null;mirrorInit=null;connected=!1;_wsHandshake=null;_rejectedToken;connectedPromise=null;_systemProxy;_connectionVersion=0;_wsEpoch=0;connectionListeners=new Set;constructor(e){this._serverUrl=e.serverUrl.replace(/\/+$/,``),this.token=e.token,this.getLanguage=e.getLanguage??(()=>void 0),this.refreshCredential=e.refreshCredential;let t=typeof window<`u`;this.useWs=e.useWebSocket??t,this.onConnectionChange=e.onConnectionChange,this.baseRetryMs=e.retryDelayMs??Aq,this.maxRetryMs=e.maxRetryDelayMs??Pq,this._trpcClient=this.buildTrpcClient(),this._systemProxy=Zi(this._trpcClient)}get serverUrl(){return this._serverUrl}get connectionVersion(){return this._connectionVersion}subscribeConnectionEvents(e){return this.connectionListeners.add(e),()=>{this.connectionListeners.delete(e)}}emitConnectionEvent(e){try{this.onConnectionChange?.(e)}catch{}for(let t of this.connectionListeners)try{t(e,this._connectionVersion)}catch{}}async awaitConnected(e){if(this.connected)return;if(this.connectedPromise)return this.connectedPromise;let t=e??15e3;this.connectedPromise=(async()=>{let e=this._trpcClient.auth.me.query();Number.isFinite(t)?await new Promise((n,r)=>{let i=setTimeout(()=>r(Error(`System.awaitConnected: probe timed out after ${t}ms`)),t);e.then(()=>{clearTimeout(i),n()},e=>{clearTimeout(i),r(e instanceof Error?e:Error(String(e)))})}):await e,this.connected=!0})();try{await this.connectedPromise}finally{this.connectedPromise=null}}async init(e){if(this.mirror?.isReady())return;if(this.mirrorInit)return this.mirrorInit;let t=new Ma(this._trpcClient);return this.mirror=t,this.mirrorInit=(async()=>{await this.awaitConnected(e),await t.init(e)})().finally(()=>{this.mirrorInit=null}),this.mirrorInit}async awaitReady(){if(!this.mirror?.isReady())return this.mirrorInit?this.mirrorInit:this.init()}isReady(){return this.mirror?.isReady()??!1}isConnected(){return this.connected}reconnect(){this.useWs&&(this._wsEpoch+=1,this.emitConnectionEvent(`connecting`),this._wsClient?.close(),this.disposeMirror(),this.resetEventSubs(),this.connected=!1,this.connectedPromise=null,this._wsHandshake=null,this._trpcClient=this.buildTrpcClient(),this._systemProxy=Zi(this._trpcClient))}switchServerUrl(e){let t=e.replace(/\/+$/,``);t!==this._serverUrl&&(this._serverUrl=t,this.reconnect())}async raceConnectionEndpoints(e){let t=e?.perCandidateTimeoutMs??1500,n=(()=>{try{return new URL(this._serverUrl)}catch{return null}})(),r=n?.port?Number(n.port):n?.protocol===`https:`?443:80,i=n?.protocol===`https:`?`https`:`http`,a=this._trpcClient.localNetwork?.getConnectionEndpoints;if(!a)return{winner:this._serverUrl,switched:!1};let o;try{o=(await a.query({port:r,ipv4Only:e?.ipv4Only,scheme:i,includeLoopback:!1})).endpoints}catch{return{winner:this._serverUrl,switched:!1}}if(o.length===0)return{winner:this._serverUrl,switched:!1};let s=await Lq(o.map(e=>e.baseUrl),t);return!s||s===this._serverUrl?{winner:s??this._serverUrl,switched:!1}:(this.switchServerUrl(s),{winner:s,switched:!0})}close(){this.disposeMirror(),this.connected=!1,this.connectedPromise=null,this._wsClient?.close()}disposeMirror(){this.mirror?.dispose(),this.mirror=null,this.mirrorInit=null}async login(e,t,n={}){let r=await this._trpcClient.auth.login.mutate({username:e,password:t,...Dq(n)});if(typeof r==`object`&&r&&`token`in r){let e=r,t=e.token,n=e.requiresTotp===!0||Array.isArray(e.secondFactors)&&e.secondFactors.length>0;typeof t==`string`&&!n&&this.setToken(t)}return r}async loginVerifyTotp(e,t,n={}){let r=await this._trpcClient.auth.loginVerifyTotp.mutate({challengeToken:e,code:t,...Dq(n)});if(typeof r==`object`&&r&&`token`in r){let e=r.token;typeof e==`string`&&this.setToken(e)}return r}async loginBeginPasskey(e){return await this._trpcClient.auth.loginBeginPasskey.mutate({challengeToken:e})}async loginVerifyPasskey(e,t,n={}){let r=await this._trpcClient.auth.loginVerifyPasskey.mutate({challengeToken:e,response:t,...Dq(n)});if(typeof r==`object`&&r&&`token`in r){let e=r.token;typeof e==`string`&&this.setToken(e)}return r}async passkeyLoginBegin(){return await this._trpcClient.auth.passkeyLoginBegin.mutate()}async passkeyLoginFinish(e,t={}){let n=await this._trpcClient.auth.passkeyLoginFinish.mutate({response:e,...Dq(t)});if(typeof n==`object`&&n&&`token`in n){let e=n,t=e.requiresTotp===!0||Array.isArray(e.secondFactors)&&e.secondFactors.length>0;typeof e.token==`string`&&!t&&this.setToken(e.token)}return n}async refreshSession(e){let t=await this._trpcClient.auth.refreshSession.mutate({refreshToken:e});return this.setToken(t.token),t}async logout(e={}){await this._trpcClient.auth.logout.mutate(e.everywhere===!0?{everywhere:!0}:void 0)}async getMe(){return await this._trpcClient.auth.me.query()}async changeOwnPassword(e){return await this._trpcClient.auth.changeOwnPassword.mutate(e)}async setupOwnTotp(){return await this._trpcClient.auth.setupOwnTotp.mutate()}async confirmOwnTotp(e){return await this._trpcClient.auth.confirmOwnTotp.mutate(e)}async disableOwnTotp(e){return await this._trpcClient.auth.disableOwnTotp.mutate(e)}async reauthBeginPasskey(){return await this._trpcClient.auth.reauthBeginPasskey.mutate()}async reauthenticate(e){return await this._trpcClient.auth.reauthenticate.mutate(e)}async getOwnTotpStatus(){return await this._trpcClient.auth.getOwnTotpStatus.query()}async beginOwnPasskeyRegistration(){return await this._trpcClient.auth.beginOwnPasskeyRegistration.mutate()}async finishOwnPasskeyRegistration(e){return await this._trpcClient.auth.finishOwnPasskeyRegistration.mutate(e)}async listOwnPasskeys(){return await this._trpcClient.auth.listOwnPasskeys.query()}async removeOwnPasskey(e){return await this._trpcClient.auth.removeOwnPasskey.mutate(e)}async getOwnPasskeySecondFactorPreference(){return await this._trpcClient.auth.getOwnPasskeySecondFactorPreference.query()}async setOwnPasskeySecondFactorPreference(e){return await this._trpcClient.auth.setOwnPasskeySecondFactorPreference.mutate(e)}setToken(e){this.token=e}isSocketTokenStale(){return!this.useWs||this._wsHandshake===null?!1:this._wsHandshake.token!==this.token}listDevices(e){return this.mirror?(e?this.mirror.query(e):this.mirror.getAllDevices()).map(e=>this.attachBinding(e)):[]}getDeviceInfo(e){return this.mirror?.getDeviceInfo(e)??null}listDeviceInfos(e){let t=this.mirror;if(!t)return[];let n=e?t.query(e):t.getAllDevices(),r=[];for(let e of n){let n=t.getDeviceInfo(e.deviceId);n&&r.push(n)}return r}getDevice(e){let t=this.mirror?.getDeviceById(e)??null;return t?this.attachBinding(t):null}getDeviceByName(e){let t=this.mirror?.getDeviceByName(e)??null;return t?this.attachBinding(t):null}getDeviceByStableId(e){let t=this.mirror?.getDeviceByStableId(e)??null;return t?this.attachBinding(t):null}async waitForDevice(e,t){this.mirror||await this.init();let n=await this.mirror.waitForDevice(e,t??3e4);return this.attachBinding(n)}onDeviceAdded(e){if(!this.mirror)throw Error(`System.onDeviceAdded: call init() before subscribing`);return this.mirror.onDeviceAdded(e)}onDeviceRemoved(e){if(!this.mirror)throw Error(`System.onDeviceRemoved: call init() before subscribing`);return this.mirror.onDeviceRemoved(e)}attachBinding(e){let t=this.lookupBinding(e.deviceId);if(t===e.binding)return e;let n=e;return n.binding=t,e}lookupBinding(e){return this.mirror?this.mirror.getDeviceById(e)?.binding??null:null}get addonPages(){return this._systemProxy.addonPages}get addonSettings(){return this._systemProxy.addonSettings}get alerts(){return this._systemProxy.alerts}get audioAnalyzer(){return this._systemProxy.audioAnalyzer}get audioCodec(){return this._systemProxy.audioCodec}get backup(){return this._systemProxy.backup}get decoder(){return this._systemProxy.decoder}get deviceManager(){return this._systemProxy.deviceManager}get deviceProvider(){return this._systemProxy.deviceProvider}get deviceState(){return this._systemProxy.deviceState}get metricsProvider(){return this._systemProxy.metricsProvider}get notificationOutput(){return this._systemProxy.notificationOutput}get pipelineExecutor(){return this._systemProxy.pipelineExecutor}get pipelineOrchestrator(){return this._systemProxy.pipelineOrchestrator}get pipelineRunner(){return this._systemProxy.pipelineRunner}get settingsStore(){return this._systemProxy.settingsStore}get storage(){return this._systemProxy.storage}get streamBroker(){return this._systemProxy.streamBroker}get turnProvider(){return this._systemProxy.turnProvider}get userManagement(){return this._systemProxy.userManagement}subscribeEvent(e,t){let n=t,r=this._eventSubs.get(e);if(r===void 0){let t=new Set,n=this._trpcClient.live.onEvent.subscribe({category:e},{onData:e=>{for(let n of[...t])try{n(e)}catch{}}});r={listeners:t,unsubscribe:()=>{try{n.unsubscribe()}catch{}}},this._eventSubs.set(e,r)}r.listeners.add(n);let i=!1;return()=>{if(i)return;i=!0;let t=this._eventSubs.get(e);t!==void 0&&(t.listeners.delete(n),t.listeners.size===0&&(t.unsubscribe(),this._eventSubs.delete(e)))}}resetEventSubs(){for(let e of this._eventSubs.values())e.unsubscribe();this._eventSubs.clear()}get trpcClient(){return this._trpcClient}get wsClient(){return this._wsClient}async handshakeToken(){let e=e=>{if(e===this._rejectedToken)return!0;let t=wq(e);return t!==null&&t-Date.now()<=Mq},t=this.token;if(t===void 0||!e(t))return t;if(this.refreshCredential!==void 0)try{await this.refreshCredential(t===this._rejectedToken?`rejected`:`expired`)}catch{}let n=this.token;return n!==void 0&&!e(n)?n:void 0}buildTrpcClient(){let e=()=>{let e={};this.token&&(e.Authorization=`Bearer ${this.token}`);let t=this.getLanguage();return t&&(e[`x-camstack-lang`]=t),e};if(this.useWs){let e=this._serverUrl.replace(/^http/,`ws`)+`/trpc`,t=this.baseRetryMs,n=this.maxRetryMs,r=this._wsEpoch;return this._wsClient=vo({url:e,connectionParams:async()=>{let e=await this.handshakeToken();r===this._wsEpoch&&(this._wsHandshake={token:e});let t=this.getLanguage();return{...e===void 0?{}:{token:e},...t?{lang:t}:{}}},retryDelayMs:e=>Math.min(t*2**e,n),keepAlive:{enabled:!0,intervalMs:Oq,pongTimeoutMs:kq},onOpen:()=>{r===this._wsEpoch&&(this._connectionVersion+=1,this.emitConnectionEvent(`connected`))},onClose:e=>{r===this._wsEpoch&&(e?.code===jq&&(this._rejectedToken=this._wsHandshake?.token??this._rejectedToken),this.emitConnectionEvent(`disconnected`))}}),Co({links:[bo({condition:e=>Nq.has(e.path),true:So({url:`${this._serverUrl}/trpc`,headers:()=>{let e=this.getLanguage();return e?{"x-camstack-lang":e}:{}},transformer:bq}),false:yo({client:this._wsClient,transformer:bq})})]})}return this._wsClient=null,Co({links:[So({url:`${this._serverUrl}/trpc`,headers:e,transformer:bq})]})}};function Iq(e){return new Fq(e)}async function Lq(e,t){if(e.length===0)return null;if(typeof fetch!=`function`)return e[0]??null;let n=typeof window<`u`&&window.location!==void 0&&window.location.protocol===`https:`?e.filter(e=>e.toLowerCase().startsWith(`https://`)):e;if(n.length===0)return null;let r=n.map(()=>new AbortController),i=n.map(async(e,n)=>{let i=r[n],a=setTimeout(()=>i.abort(),t);try{let t=await fetch(`${e.replace(/\/+$/,``)}/health`,{method:`GET`,signal:i.signal,credentials:`omit`});if(!t.ok)throw Error(`${t.status}`);return e}finally{clearTimeout(a)}});try{let e=await Promise.any(i);for(let e of r)try{e.abort()}catch{}return e}catch{return null}}var Rq=function(e){return e.Motion=`motion`,e.Person=`person`,e.Vehicle=`vehicle`,e.Animal=`animal`,e.Audio=`audio`,e.Face=`face`,e.Plate=`plate`,e.Package=`package`,e.Doorbell=`doorbell`,e.Sensor=`sensor`,e}({}),zq=`animal.dog_cat.dog.cat.horse.sheep.cow.elephant.bear.zebra.giraffe.mouse.rabbit.deer.lion.tiger.bird.eagle.owl.pigeon.fish.whale.dolphin.snake.turtle.lizard`.split(`.`),Bq=[`person`,`people`,`pedestrian`,`rider`,`driver`,`cyclist`,`skier`,`skateboarder`,`face`,`hand`,`head`,`body`],Vq=[`vehicle`,`car`,`truck`,`bus`,`motorcycle`,`bicycle`,`van`,`ambulance`,`police_car`,`fire_truck`,`train`,`subway`,`tram`,`airplane`,`boat`,`ship`,`helicopter`],Hq=`face.eyes.nose.mouth.ears.eyebrows.left_eye.right_eye.pupil.iris.eyelid.eye_corner.upper_lip.lower_lip.teeth.chin.cheek.forehead.jaw.glasses.sunglasses.facial_hair.beard.mustache.facial_landmark.facial_keypoint`.split(`.`),Uq=[`plate`,`license_plate`,`front_plate`,`rear_plate`,`motorcycle_plate`,`temporary_plate`,`dealer_plate`,`licensePlate`,`plate_number`,`plate_character`,`plate_digit`,`plate_letter`,`plate_symbol`,`plate_region`,`plate_country_identifier`,`plate_frame`,`plate_bolt`,`plate_sticker`,`plate_validation_tag`,`damaged_plate`,`obscured_plate`,`dirty_plate`],Wq=[`motion`,`movement`,`other`],Gq=[`package`,`packet`],Kq=[`audio`],qq=`speech.scream.babbling.yell.bellow.whoop.whispering.laughter.snicker.crying.cry.sigh.singing.choir.chant.mantra.child_singing.rapping.humming.groan.grunt.whistling.breathing.wheeze.snoring.gasp.pant.snort.cough.throat_clearing.sneeze.sniff.cheering.applause.chatter.crowd.children_playing.bark.yip.howl.bow-wow.growling.whimper_dog.purr.meow.hiss.caterwaul.pets.livestock.doorbell.ding-dong.door.slam.knock.alarm.telephone.music.dog.dogs`.split(`.`),Jq=[`doorbell`,`ring`],Yq=[`lock`,`binary`,`flood`,`entry`,`door`,`leak`,`door_open`,`flooded`,`entry_open`];function Xq(e,t){return e.includes(t)}var Zq={...zq.reduce((e,t)=>({...e,[t]:`animal`}),{}),...Bq.reduce((e,t)=>({...e,[t]:`person`}),{}),...Vq.reduce((e,t)=>({...e,[t]:`vehicle`}),{}),...Wq.reduce((e,t)=>({...e,[t]:`motion`}),{}),...Gq.reduce((e,t)=>({...e,[t]:`package`}),{}),...Hq.reduce((e,t)=>({...e,[t]:`face`}),{}),...Uq.reduce((e,t)=>({...e,[t]:`plate`}),{}),...Kq.reduce((e,t)=>({...e,[t]:`audio`}),{}),...qq.reduce((e,t)=>({...e,[t]:`audio`}),{}),...Jq.reduce((e,t)=>({...e,[t]:`doorbell`}),{}),...Yq.reduce((e,t)=>({...e,[t]:`sensor`}),{})},Qq=e=>Xq(Hq,e),$q=e=>Xq(Uq,e),eJ=e=>Xq(zq,e),tJ=e=>Xq(Bq,e),nJ=e=>Xq(Vq,e),rJ=e=>Xq(Wq,e),iJ=e=>Xq(Jq,e),aJ=e=>Xq(Gq,e),oJ=e=>Xq(Kq,e)||Xq(qq,e),sJ=e=>Xq(Yq,e),cJ=e=>Qq(e)||$q(e),lJ=e=>Zq[e],uJ=e=>{let{className:t}=e,n={face:`person`,plate:`vehicle`},r=Zq[t];return r&&r!==t?r:n[t]},dJ=Object.values(Rq),fJ=dJ.filter(e=>e!==`motion`),pJ=[`person`,`doorbell`,`package`],mJ=[...pJ,`vehicle`,`animal`,`audio`,`face`,`plate`],hJ=[...fJ];function gJ(e,t){switch(e){case`critical`:return pJ;case`important`:return mJ;case`all`:return hJ;case`custom`:return t?.length?t:fJ;default:return fJ}}var _J=e({DEFAULT_ENABLED_CLASSES:()=>fJ,DetectionClass:()=>Rq,SessionKeeper:()=>Eq,System:()=>Fq,TIMELINE_PRESET_ALL:()=>hJ,TIMELINE_PRESET_CRITICAL:()=>pJ,TIMELINE_PRESET_IMPORTANT:()=>mJ,animalClasses:()=>zq,audioClasses:()=>Kq,audioLabelClasses:()=>qq,createSystem:()=>Iq,defaultDetectionClasses:()=>dJ,detectionClassesDefaultMap:()=>Zq,doorbellClasses:()=>Jq,faceClasses:()=>Hq,getClassesForTimelinePreset:()=>gJ,getParentClass:()=>lJ,getParentDetectionClass:()=>uJ,isAnimalClassname:()=>eJ,isAudioClassname:()=>oJ,isDoorbellClassname:()=>iJ,isFaceClassname:()=>Qq,isLabelDetection:()=>cJ,isMotionClassname:()=>rJ,isPackageClassname:()=>aJ,isPersonClassname:()=>tJ,isPlateClassname:()=>$q,isSensorLabelClassname:()=>sJ,isSessionRefusal:()=>Tq,isVehicleClassname:()=>nJ,jwtExpiresAt:()=>wq,licensePlateClasses:()=>Uq,motionClasses:()=>Wq,packageClasses:()=>Gq,personClasses:()=>Bq,raceFastestEndpoint:()=>Lq,sensorLabelClasses:()=>Yq,vehicleClasses:()=>Vq});E();var vJ=O(null),yJ=[`dark`,`light`,`system`];function bJ(){return typeof window>`u`||window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`}function xJ(e,t){if(typeof window>`u`)return t;let n=localStorage.getItem(e);return n===`dark`||n===`light`||n===`system`?n:t}function SJ(e){return e===`system`?bJ():e}function CJ({children:e,defaultMode:t=`system`,storageKey:n=`camstack-theme-mode`}){let[r,i]=C(()=>xJ(n,t)),[a,o]=C(()=>SJ(r)),s=_(e=>{i(e),o(SJ(e)),typeof window<`u`&&localStorage.setItem(n,e)},[n]),c=_(()=>{s(yJ[(yJ.indexOf(r)+1)%yJ.length]??`dark`)},[r,s]);b(()=>{if(typeof document>`u`)return;let e=document.documentElement;e.classList.remove(`dark`,`light`),e.classList.add(a)},[r,a]),b(()=>{if(typeof window>`u`||r!==`system`)return;let e=window.matchMedia(`(prefers-color-scheme: dark)`),t=()=>{o(bJ())};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[r]);let l=p(()=>({mode:r,resolvedMode:a,setMode:s,toggleMode:c}),[r,a,s,c]);return v(vJ.Provider,{value:l,children:e})}E();function wJ(){let e=I(vJ);if(!e)throw Error(`useThemeMode must be used within a ThemeProvider`);return e}var TJ=[[`deviceManager`,`listAll`]],EJ=3e4,DJ=5*6e4;function OJ(e){e.setQueryDefaults(TJ,{staleTime:EJ,gcTime:DJ})}E();function kJ({className:e}){return c(`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:[v(`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`}),v(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function AJ({className:e}){return c(`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:[v(`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`}),v(`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`}),v(`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`}),v(`path`,{d:`m2 2 20 20`})]})}function jJ({className:e}){return v(`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:v(`path`,{d:`M21 12a9 9 0 1 1-6.219-8.56`})})}function MJ({onLogin:e,serverUrl:t,logoSrc:n,error:r,className:i}){let a=q(),[o,s]=C(``),[l,u]=C(``),[d,f]=C(!1),[p,m]=C(!1),[h,g]=C(null),_=r??h;return v(`div`,{className:$(`flex min-h-screen items-center justify-center bg-background p-4`,i),children:c(`div`,{className:`w-full max-w-sm`,children:[n&&v(`div`,{className:`flex justify-center mb-8`,children:v(`img`,{src:n,alt:a(`uiLibrary.loginForm.logo`,`Logo`),className:`h-12`})}),t&&v(`p`,{className:`mb-4 text-center text-xs text-foreground-subtle truncate`,children:t}),c(`form`,{onSubmit:async t=>{if(t.preventDefault(),!p){g(null),m(!0);try{await e(o,l)}catch(e){g(e instanceof Error?e.message:a(`uiLibrary.loginForm.failed`,`Login failed. Please try again.`))}finally{m(!1)}}},className:`space-y-4 rounded-xl border border-border bg-surface p-6 shadow-xl shadow-black/10`,children:[_&&v(`div`,{className:`rounded-md bg-danger/10 border border-danger/20 px-3 py-2 text-xs text-danger`,children:_}),c(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:a(`uiLibrary.loginForm.username`,`Username`)}),v(`input`,{type:`text`,value:o,onChange:e=>s(e.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`})]}),c(`div`,{className:`space-y-1.5`,children:[v(`label`,{className:`text-xs font-medium text-foreground-subtle`,children:a(`uiLibrary.loginForm.password`,`Password`)}),c(`div`,{className:`relative`,children:[v(`input`,{type:d?`text`:`password`,value:l,onChange:e=>u(e.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`}),v(`button`,{type:`button`,onClick:()=>f(e=>!e),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,tabIndex:-1,children:v(d?AJ:kJ,{className:`h-4 w-4`})})]})]}),c(`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&&v(jJ,{className:`h-4 w-4 animate-spin`}),p?a(`uiLibrary.loginForm.submitting`,`Logging in...`):a(`uiLibrary.loginForm.submit`,`Log in`)]})]})]})})}E();var NJ=`camstack_dev_token`,PJ=O(null);function FJ(){let e=I(PJ);if(!e)throw Error(`useDevShell must be used within a DevShell`);return e}function IJ(){return typeof window>`u`?null:localStorage.getItem(NJ)}function LJ({className:e}){return c(`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:[v(`circle`,{cx:`12`,cy:`12`,r:`4`}),v(`path`,{d:`M12 2v2`}),v(`path`,{d:`M12 20v2`}),v(`path`,{d:`m4.93 4.93 1.41 1.41`}),v(`path`,{d:`m17.66 17.66 1.41 1.41`}),v(`path`,{d:`M2 12h2`}),v(`path`,{d:`M20 12h2`}),v(`path`,{d:`m6.34 17.66-1.41 1.41`}),v(`path`,{d:`m19.07 4.93-1.41 1.41`})]})}function RJ({className:e}){return v(`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:v(`path`,{d:`M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z`})})}function zJ({children:e,serverUrl:t,title:n,token:r,onLogout:i}){let a=q(),o=wJ(),s=p(()=>[bo({condition:e=>e.type===`subscription`,true:yo({client:vo({url:t.replace(/^http/,`ws`)+`/trpc`,connectionParams:()=>({token:r})}),transformer:bq}),false:So({url:`${t}/trpc`,transformer:bq,headers:()=>({authorization:`Bearer ${r}`})})})],[t,r]),l=p(()=>Co({links:s}),[s]),u=p(()=>X.createClient({links:s}),[s]),d=p(()=>Iq({serverUrl:t,token:r}),[t,r]);b(()=>(d.init().catch(()=>void 0),()=>{d.close()}),[d]);let f=p(()=>{let e=new T;return OJ(e),e},[]),m=o.mode===`dark`?a(`uiLibrary.devShell.themeDark`,`Dark`):o.mode===`light`?a(`uiLibrary.devShell.themeLight`,`Light`):a(`uiLibrary.devShell.themeSystem`,`System`),h=p(()=>({trpc:l,token:r,logout:i}),[l,r,i]);return v(wr,{system:d,children:v(X.Provider,{client:u,queryClient:f,children:v(M,{client:f,children:v(PJ.Provider,{value:h,children:c(`div`,{className:`min-h-screen bg-background text-foreground`,children:[c(`div`,{className:`flex items-center justify-between border-b border-border bg-surface px-4 py-2`,children:[c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`rounded bg-warning/20 px-2 py-0.5 text-xs font-bold text-warning`,children:a(`uiLibrary.devShell.devMode`,`DEV MODE`)}),n&&v(`span`,{className:`text-sm font-medium text-foreground`,children:n}),v(`span`,{className:`text-xs text-foreground-subtle`,children:t})]}),c(`div`,{className:`flex items-center gap-2`,children:[c(`button`,{type:`button`,onClick:o.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:a(`uiLibrary.devShell.theme`,`Theme: {{mode}}`,{mode:m}),children:[o.resolvedMode===`dark`?v(LJ,{className:`h-3.5 w-3.5`}):v(RJ,{className:`h-3.5 w-3.5`}),m]}),v(`button`,{type:`button`,onClick:i,className:`rounded-md px-2.5 py-1 text-xs font-medium text-danger hover:bg-danger/10 transition-colors`,children:a(`uiLibrary.devShell.logout`,`Logout`)})]})]}),v(`div`,{className:`p-4`,children:e({trpc:l,theme:o})})]})})})})})}function BJ({children:e,serverUrl:t=`https://localhost:4443`,title:n}){let[r,i]=C(IJ),a=_(async(e,n)=>{let r=await Co({links:[So({url:`${t}/trpc`,transformer:bq})]}).auth.login.mutate({username:e,password:n});if(!r.token)throw Error(`No token returned`);localStorage.setItem(NJ,r.token),i(r.token)},[t]),o=_(()=>{localStorage.removeItem(NJ),i(null)},[]);return r?v(CJ,{children:v(zJ,{serverUrl:t,title:n,token:r,onLogout:o,children:e})}):v(CJ,{children:v(MJ,{onLogin:a,serverUrl:t})})}E();function VJ(e){let[t,n]=C([]),r=_(t=>{n(n=>{let r=[...n,t];return r.length>e?r.slice(-e):r})},[e]),i=_(()=>{n([])},[]);return p(()=>({entries:t,append:r,reset:i}),[t,r,i])}E();function HJ(e,t){let[n,r]=C(e);return b(()=>{let n=setTimeout(()=>r(e),t);return()=>clearTimeout(n)},[e,t]),n}async function UJ(e){let{fetchSlice:t,limit:n,signal:r,onProgress:i}=e,a=[],o=e.before,s=0,c;for(;;){if(r.aborted)return{entries:a,nextBefore:o??null,done:!1,cancelled:!0,scannedBytes:s,source:c};let e;try{e=await t(o,Math.max(1,n-a.length),r)}catch(e){if(r.aborted)return{entries:a,nextBefore:o??null,done:!1,cancelled:!0,scannedBytes:s,source:c};throw e}a.push(...e.entries),s+=e.scannedBytes,c=e.source,i?.(s);let l=e.done||e.nextBefore===null;if(e.cancelled===!0)return{entries:a,nextBefore:e.nextBefore,done:l,cancelled:!0,scannedBytes:s,source:c};if(l||a.length>=n)return{entries:a,nextBefore:e.nextBefore,done:l,cancelled:!1,scannedBytes:s,source:c};o=e.nextBefore??void 0}}function WJ(e){return e.id!==void 0&&e.id!==``?`id:${e.id}`:`${e.timestamp}|${e.level}|${e.scope??``}|${e.message}`}function GJ(e,t){let n=new Map;for(let t of e)n.set(WJ(t),t);for(let e of t)n.set(WJ(e),e);return[...n.values()].toSorted((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())}E();var KJ={entries:[],nextBefore:null,done:!1,status:`loading`,scannedBytes:0,source:void 0,error:null};function qJ(e,t){let n=X.useUtils(),[r,i]=C(KJ),a=f(r);a.current=r;let o=f(e);o.current=e;let s=f(null),c=JSON.stringify(e),l=_(async(e,r)=>{s.current?.abort();let a=new AbortController;s.current=a,i(e=>({...r?KJ:e,status:`loading`,scannedBytes:0,error:null}));let c=(e,t,r)=>n.client.logs.query.query({...o.current,limit:t,...e===void 0?{}:{before:e}},{signal:r});try{let n=await UJ({fetchSlice:c,limit:t,...e===void 0?{}:{before:e},signal:a.signal,onProgress:e=>{s.current===a&&i(t=>({...t,scannedBytes:e}))}});if(s.current!==a)return;i(e=>({entries:r?n.entries:[...e.entries,...n.entries],nextBefore:n.nextBefore,done:n.done,status:`idle`,scannedBytes:n.scannedBytes,source:n.source??e.source,error:null}))}catch(e){if(s.current!==a)return;i(t=>({...t,status:`idle`,error:e instanceof Error?e.message:String(e)}))}},[n,t]);b(()=>(l(void 0,!0),()=>{s.current?.abort(),s.current=null}),[l,c]);let u=_(()=>{let e=a.current;e.status===`loading`||e.done||l(e.nextBefore??void 0,!1)},[l]),d=_(()=>{s.current?.abort()},[]);return{entries:r.entries,status:r.status,done:r.done,scannedBytes:r.scannedBytes,source:r.source,error:r.error,loadOlder:u,cancel:d}}function JJ(e,t=40){return e.scrollHeight-e.scrollTop-e.clientHeight<=t}E();function YJ(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)}}var XJ={error:{icon:Ai,color:`text-red-400`},warn:{icon:zi,color:`text-amber-400`},info:{icon:kn,color:`text-blue-400`},debug:{icon:Ie,color:`text-gray-500`}},ZJ=[`debug`,`info`,`warn`,`error`],QJ=500,$J=300,eY=24,tY=1024*1024;function nY({agentId:e,addonId:t,deviceId:n,containerDeviceId:r,integrationId:i,requestId:a,level:o,maxHeight:s=`max-h-96`,showScope:l=!1,showDeviceChip:d=!1,showFilters:m=!0,showSourceSelect:h,limit:g=100,liveBuffer:y,onClose:x,className:S}){let w=f(null);As(w);let T=q(),E=h??m,[D,O]=C(``),[k,A]=C(``),[j,M]=C(o??`info`),[N,P]=C(void 0),F=e,I=t??(D||void 0),L=n??(k?Number(k):void 0),R=i,z=a,B=p(()=>{let e={};return F&&(e.agentId=F),I&&(e.addonId=I),r!==void 0&&Number.isFinite(r)?e.containerDeviceId=r:L!==void 0&&Number.isFinite(L)&&(e.deviceId=L),R&&(e.integrationId=R),z&&(e.requestId=z),Object.keys(e).length>0?e:void 0},[F,I,L,r,R,z]),V=VJ(QJ),H=y??V,U=H.entries,[ee,W]=C(0),[G,te]=C(!0),ne=f(!1),[re,K]=C(!1),[ie,ae]=C(!1),[se,ce]=C(new Set),[le,ue]=C(``),fe=f(null),pe=`${F??``}:${I??``}:${String(L??``)}:${String(r??``)}:${R??``}:${z??``}`,me=f(pe);b(()=>{me.current!==pe&&(me.current=pe,H.reset(),W(0),ce(new Set),K(!1))},[pe,H]);let he=HJ(le,$J).trim(),ge=X.logs.sources.useQuery(void 0,{staleTime:6e4}),_e=p(()=>(ge.data??[]).filter(e=>e.readable),[ge.data]),ve=qJ(p(()=>({...N?{source:N}:{},level:j,...he?{text:he}:{},...B?{tags:B}:{}}),[N,j,he,B]),g);X.logs.subscribe.useSubscription({level:j,...he?{text:he}:{},...B?{tags:B}:{}},{onData:e=>{H.append(e)}});let ye=`${N??``}|${j}|${he}`,be=f(ye);b(()=>{be.current!==ye&&(be.current=ye,H.reset(),te(!0))},[ye,H]);let xe=p(()=>{let e=GJ(ve.entries,U);return ee>0?e.filter(e=>new Date(e.timestamp).getTime()>ee):e},[ve.entries,U,ee]),Se=f(null),Ce=_(()=>{if(ve.status===`loading`||ve.done)return;let e=fe.current;e&&(Se.current={height:e.scrollHeight,top:e.scrollTop}),ve.loadOlder()},[ve]);u(()=>{let e=Se.current,t=fe.current;if(!e||!t||ve.status!==`idle`)return;Se.current=null;let n=e.top+(t.scrollHeight-e.height);Math.abs(n-t.scrollTop)<1||(ne.current=!0,t.scrollTop=n)},[ve.status,ve.entries.length]);let we=_(e=>{let t=fe.current;t&&(ne.current=!0,t.scrollTo({top:t.scrollHeight,...e?{behavior:e}:{}}))},[]),[Te,Ee]=C(!1),De=xe.length>0?WJ(xe[xe.length-1]):``,Oe=f(De);u(()=>{let e=De!==``&&De!==Oe.current;Oe.current=De,e&&(G?we():Ee(!0))},[De,G,we]),b(()=>{G&&Te&&Ee(!1)},[G,Te]);let ke=_(()=>{te(!0),we(`smooth`)},[we]),Ae=_(()=>{if(ne.current){ne.current=!1;return}let e=fe.current;if(!e)return;let t=JJ(e,40);te(e=>e===t?e:t),e.scrollTop<=eY&&Ce()},[Ce]),je=p(()=>xe.filter(e=>e.tags&&Object.keys(e.tags).length>0||e.meta&&Object.keys(e.meta).length>0).map(WJ),[xe]),Me=_(()=>{K(e=>(e&&ce(new Set),!e))},[]),Ne=_(()=>{let e=xe.map(e=>{let t=new Date(e.timestamp).toLocaleTimeString(),n=e.tags?` `+Object.entries(e.tags).filter(([,e])=>e).map(([e,t])=>`${e}=${t}`).join(` `):``;return`${t} [${e.level.toUpperCase()}]${e.scope?` [${e.scope}]`:``}${n} ${e.message}`});navigator.clipboard.writeText(e.join(`
|
|
4
4
|
`)).then(()=>{ae(!0),setTimeout(()=>ae(!1),1500)})},[xe]),Fe=X.logs.clear.useMutation(),Ie=_(()=>{W(Date.now()),H.reset(),Fe.mutate(B?{tags:B}:{})},[H,Fe,B]),Le=_(e=>{ce(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),[Re,ze]=C(null),Be=_((e,t)=>{let n=new Date(e.timestamp).toISOString(),r=e.tags?` `+Object.entries(e.tags).filter(([,e])=>e).map(([e,t])=>`${e}=${t}`).join(` `):``,i=e.meta&&Object.keys(e.meta).length>0?` meta=${JSON.stringify(e.meta)}`:``,a=`${n} [${e.level.toUpperCase()}]${e.scope?` [${e.scope}]`:``}${r} ${e.message}${i}`;navigator.clipboard.writeText(a).then(()=>{ze(t),setTimeout(()=>ze(e=>e===t?null:e),1200)})},[]),Ve=WJ;return c(`div`,{className:$(`h-full min-h-0 flex flex-col`,S),onClick:e=>e.stopPropagation(),children:[c(`div`,{className:`flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0`,children:[c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[v(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:T(`uiLibrary.logStream.logs`,`Logs`)}),F&&v(oY,{label:T(`uiLibrary.logStream.scopeAgent`,`agent`),value:F}),I&&v(oY,{label:T(`uiLibrary.logStream.scopeAddon`,`addon`),value:I}),L!==void 0&&v(oY,{label:T(`uiLibrary.logStream.scopeDevice`,`device`),value:`#${L}`}),v(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:ZJ.map((e,t)=>c(`button`,{type:`button`,onClick:()=>M(e),className:$(`px-1.5 py-0.5 capitalize transition-colors`,j===e?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`,t>0&&`border-l border-border`),children:[e,`+`]},e))}),E&&_e.length>1&&v(`div`,{className:`w-36`,children:v(Yl,{"aria-label":T(`uiLibrary.logStream.source`,`Log source`),className:`h-5 text-[10px]`,value:N??_e.find(e=>e.isDefault)?.addonId??``,onChange:e=>P(e.target.value),options:_e.map(e=>({value:e.addonId,label:e.addonId}))})}),E&&_e.length<=1&&ve.source&&v(`span`,{className:`text-[9px] text-foreground-subtle`,children:T(`uiLibrary.logStream.sourceName`,`Source: {{name}}`,{name:ve.source})}),v(cY,{icon:ir,label:G?T(`uiLibrary.logStream.following`,`Following`):T(`uiLibrary.logStream.paused`,`Paused`),active:G,onClick:()=>{G?te(!1):ke()}}),v(cY,{icon:re?oe:jt,label:re?T(`uiLibrary.logStream.collapse`,`Collapse`):T(`uiLibrary.logStream.expand`,`Expand`),active:re,onClick:Me,disabled:je.length===0}),v(cY,{icon:ei,label:ie?T(`uiLibrary.logStream.copied`,`Copied!`):T(`uiLibrary.logStream.copy`,`Copy`),onClick:Ne,disabled:xe.length===0}),v(cY,{icon:Pe,label:T(`uiLibrary.logStream.clear`,`Clear`),onClick:Ie}),c(`div`,{className:`relative`,children:[v(`input`,{ref:w,type:`text`,value:le,onChange:e=>ue(e.target.value),placeholder:T(`uiLibrary.logStream.searchPlaceholder`,`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`}),le&&v(`button`,{type:`button`,onClick:()=>ue(``),className:`absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,title:T(`uiLibrary.logStream.clearSearch`,`Clear search`),children:v(Zn,{className:`h-2.5 w-2.5`})})]}),U.length>0&&v(`span`,{className:`text-[9px] text-emerald-400 font-medium`,children:T(`uiLibrary.logStream.live`,`+{{count}} live`,{count:U.length})})]}),x&&v(`button`,{type:`button`,onClick:x,className:`text-foreground-subtle hover:text-foreground`,"aria-label":T(`uiLibrary.logStream.close`,`Close`),children:v(Zn,{className:`h-3.5 w-3.5`})})]}),m&&(!t||!n)&&c(`div`,{className:`flex items-center gap-2 px-3 py-1 border-b border-border/50 bg-surface/50 text-[10px]`,children:[!t&&c(`label`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`text-foreground-subtle`,children:T(`uiLibrary.logStream.addon`,`Addon:`)}),v(`input`,{type:`text`,value:D,onChange:e=>O(e.target.value),placeholder:T(`uiLibrary.logStream.all`,`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&&c(`label`,{className:`flex items-center gap-1`,children:[v(`span`,{className:`text-foreground-subtle`,children:T(`uiLibrary.logStream.device`,`Device:`)}),v(`input`,{type:`text`,inputMode:`numeric`,value:k,onChange:e=>A(e.target.value),placeholder:T(`uiLibrary.logStream.all`,`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`})]})]}),c(`div`,{className:`relative flex-1 min-h-0 flex flex-col`,children:[!G&&Te&&c(`button`,{type:`button`,onClick:ke,className:`absolute bottom-2 left-1/2 -translate-x-1/2 z-10 inline-flex items-center gap-1 px-2 py-1 rounded-full border border-primary/40 bg-primary/15 text-primary text-[10px] font-medium shadow-md backdrop-blur-sm hover:bg-primary/25 transition-colors`,title:T(`uiLibrary.logStream.jumpTitle`,`Jump to the newest log line and resume following`),children:[v(ir,{className:`h-3 w-3`}),T(`uiLibrary.logStream.jumpToLatest`,`Jump to latest`)]}),c(`div`,{ref:fe,onScroll:Ae,className:$(`flex-1 min-h-0 overflow-auto font-mono text-[10px]`,s),children:[v(aY,{status:ve.status,done:ve.done,scannedBytes:ve.scannedBytes,hasRows:xe.length>0,error:ve.error,onLoadOlder:Ce,onCancel:ve.cancel}),ve.status===`idle`&&ve.done&&xe.length===0&&v(`div`,{className:`py-4 text-center text-foreground-subtle`,children:T(`uiLibrary.logStream.noLogs`,`No logs found`)}),xe.length>0&&v(`table`,{className:`w-full`,children:v(`tbody`,{children:xe.map(e=>{let t=XJ[e.level]??XJ.info,n=t.icon,r=Ve(e),i=re||se.has(r),a=e.tags&&Object.keys(e.tags).length>0,o=e.meta&&Object.keys(e.meta).length>0,s=a||o;return c(`tr`,{className:$(`hover:bg-surface-hover/30 border-b border-border/30`,s&&`cursor-pointer`),onClick:s?()=>Le(r):void 0,children:[v(`td`,{className:`px-2 py-1 text-foreground-subtle whitespace-nowrap align-top w-[70px]`,children:new Date(e.timestamp).toLocaleTimeString()}),v(`td`,{className:$(`px-1 py-1 align-top w-5`,t.color),children:v(n,{className:`h-3 w-3`})}),l&&v(`td`,{className:`px-2 py-1 text-foreground-subtle align-top truncate max-w-[120px]`,title:e.scope,children:e.scope?.replace(/^addon:/,``)??``}),v(`td`,{className:`px-2 py-1 text-foreground break-all`,children:c(`div`,{className:`flex items-start gap-1`,children:[s&&v(i?de:It,{className:`h-3 w-3 text-foreground-subtle shrink-0 mt-0.5`}),c(`div`,{className:`flex-1 min-w-0`,children:[d&&e.tags?.deviceId!==void 0&&v(iY,{deviceId:e.tags.deviceId,deviceName:e.tags.deviceName}),e.message,i&&s&&c(`div`,{className:`mt-0.5 pl-3 text-[9px] leading-snug`,children:[o&&Object.entries(e.meta).filter(([,e])=>e!==void 0&&e!==``).map(([e,t])=>c(`div`,{className:`break-all`,children:[v(`span`,{className:`text-amber-400/80`,children:e}),v(`span`,{className:`text-foreground-subtle`,children:`=`}),v(`span`,{className:`text-foreground`,children:YJ(t)})]},`m-${e}`)),a&&Object.entries(e.tags).filter(([,e])=>e!==void 0).map(([e,t])=>c(`div`,{className:`break-all`,children:[v(`span`,{className:`text-primary/70`,children:e}),v(`span`,{className:`text-foreground-subtle`,children:`=`}),v(`span`,{className:`text-foreground`,children:t})]},`t-${e}`))]})]})]})}),v(`td`,{className:`px-1 py-1 align-top w-5`,children:v(sY,{copied:Re===r,onCopy:()=>Be(e,r)})})]},r)})})})]})]})]})}function rY({position:e=`bottom`,className:t,...n}){return v(`div`,{className:$(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:v(nY,{maxHeight:`max-h-48`,...n})})}function iY({deviceId:e,deviceName:t}){let n=q(),r=t?`${t} #${e}`:`#${e}`;return v(`span`,{className:`inline-block align-middle mr-1 px-1 py-0 rounded bg-primary/10 text-primary text-[9px] font-medium whitespace-nowrap`,title:n(`uiLibrary.logStream.deviceTitle`,`device {{id}}`,{id:e}),children:r})}function aY({status:e,done:t,scannedBytes:n,hasRows:r,error:i,onLoadOlder:a,onCancel:o}){let s=q();return e===`loading`?c(`div`,{className:`flex items-center justify-center gap-2 py-2 text-foreground-subtle`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),n>0?s(`uiLibrary.logStream.searching`,`Searching older logs… ({{mb}} MB scanned)`,{mb:(n/tY).toFixed(1)}):s(`uiLibrary.logStream.loading`,`Loading logs...`),v(_A,{variant:`outline`,size:`sm`,onClick:o,children:s(`uiLibrary.logStream.cancel`,`Cancel`)})]}):i?c(`div`,{className:`flex items-center justify-center gap-2 py-2 text-danger`,children:[i,v(_A,{variant:`outline`,size:`sm`,onClick:a,children:s(`uiLibrary.logStream.retry`,`Retry`)})]}):t?r?v(`div`,{className:`py-2 text-center text-foreground-subtle`,children:s(`uiLibrary.logStream.beginning`,`Beginning of logs`)}):null:v(`div`,{className:`flex justify-center py-1.5`,children:v(_A,{variant:`outline`,size:`sm`,onClick:a,children:s(`uiLibrary.logStream.loadOlder`,`Load older`)})})}function oY({label:e,value:t}){return c(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:[e,`: `,t]})}function sY({copied:e,onCopy:t}){return v(`button`,{type:`button`,title:q()(`uiLibrary.logStream.copyRow`,`Copy this row`),onClick:e=>{e.stopPropagation(),t()},className:$(`rounded p-0.5 transition-colors`,e?`text-emerald-400`:`text-foreground-subtle/60 hover:text-foreground hover:bg-surface-hover`),children:v(e?dt:ei,{className:`h-3 w-3`})})}function cY({icon:e,label:t,onClick:n,disabled:r,active:i}){return c(`button`,{type:`button`,onClick:n,disabled:r,className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,i?`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:[v(e,{className:`h-2.5 w-2.5`}),t]})}E();function lY(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){let n=e.source.nodeId;if(!n||n!==t&&!n.startsWith(`${t}/`))return!1}return!0}var uY={[Ga.AddonStarted]:{icon:Le,color:`bg-emerald-500/15 text-emerald-400 border-emerald-500/30`,labelKey:`uiLibrary.eventStream.kindStarted`,labelFallback:`Started`},[Ga.AddonInstalled]:{icon:nn,color:`bg-emerald-500/15 text-emerald-400 border-emerald-500/30`,labelKey:`uiLibrary.eventStream.kindInstalled`,labelFallback:`Installed`},[Ga.AddonRestarted]:{icon:_e,color:`bg-blue-500/15 text-blue-400 border-blue-500/30`,labelKey:`uiLibrary.eventStream.kindRestarted`,labelFallback:`Restarted`},[Ga.AddonUpdated]:{icon:yt,color:`bg-blue-500/15 text-blue-400 border-blue-500/30`,labelKey:`uiLibrary.eventStream.kindUpdated`,labelFallback:`Updated`},[Ga.AddonStopped]:{icon:pi,color:`bg-foreground-subtle/10 text-foreground-subtle border-border`,labelKey:`uiLibrary.eventStream.kindStopped`,labelFallback:`Stopped`},[Ga.AddonUninstalled]:{icon:Pe,color:`bg-foreground-subtle/10 text-foreground-subtle border-border`,labelKey:`uiLibrary.eventStream.kindUninstalled`,labelFallback:`Uninstalled`},[Ga.AddonCrashed]:{icon:Ai,color:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`uiLibrary.eventStream.kindCrashed`,labelFallback:`Crashed`},[Ga.AddonError]:{icon:zi,color:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`uiLibrary.eventStream.kindError`,labelFallback:`Error`},[Ga.DetectionPhaseTransition]:{icon:ai,color:`bg-violet-500/15 text-violet-400 border-violet-500/30`,labelKey:`uiLibrary.eventStream.kindPhase`,labelFallback:`Phase`},[Ga.DetectionResult]:{icon:On,color:`bg-purple-500/15 text-purple-400 border-purple-500/30`,labelKey:`uiLibrary.eventStream.kindDetection`,labelFallback:`Detection`},[Ga.DetectionEvent]:{icon:Zt,color:`bg-blue-500/15 text-blue-400 border-blue-500/30`,labelKey:`uiLibrary.eventStream.kindEvent`,labelFallback:`Event`},[Ga.DetectionCameraNative]:{icon:ln,color:`bg-cyan-500/15 text-cyan-400 border-cyan-500/30`,labelKey:`uiLibrary.eventStream.kindCameraAi`,labelFallback:`Camera AI`},[Ga.ProviderMotion]:{icon:nr,color:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`uiLibrary.eventStream.kindMotion`,labelFallback:`Motion`},[Ga.MotionOnMotionChanged]:{icon:nr,color:`bg-orange-500/15 text-orange-400 border-orange-500/30`,labelKey:`uiLibrary.eventStream.kindMotion`,labelFallback:`Motion`},[Ga.MotionAnalysis]:{icon:ai,color:`bg-orange-500/10 text-orange-300 border-orange-500/20`,labelKey:`uiLibrary.eventStream.kindMotionAnalysis`,labelFallback:`Motion analysis`},[Ga.MotionZonesRaw]:{icon:ai,color:`bg-orange-500/10 text-orange-300 border-orange-500/20`,labelKey:`uiLibrary.eventStream.kindMotionZones`,labelFallback:`Motion zones`},[Ga.ProviderDetection]:{icon:ln,color:`bg-cyan-500/15 text-cyan-400 border-cyan-500/30`,labelKey:`uiLibrary.eventStream.kindProviderDet`,labelFallback:`Provider Det`},[Ga.PipelineAudioInferenceResult]:{icon:Pr,color:`bg-pink-500/15 text-pink-400 border-pink-500/30`,labelKey:`uiLibrary.eventStream.kindAudio`,labelFallback:`Audio`},[Ga.AgentOnline]:{icon:Le,color:`bg-emerald-500/15 text-emerald-400 border-emerald-500/30`,labelKey:`uiLibrary.eventStream.kindAgentOnline`,labelFallback:`Agent Online`},[Ga.AgentOffline]:{icon:pi,color:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`uiLibrary.eventStream.kindAgentOffline`,labelFallback:`Agent Offline`},[Ga.DeviceRegistered]:{icon:nn,color:`bg-emerald-500/15 text-emerald-400 border-emerald-500/30`,labelKey:`uiLibrary.eventStream.kindRegistered`,labelFallback:`Registered`},[Ga.DeviceUnregistered]:{icon:Pe,color:`bg-red-500/15 text-red-400 border-red-500/30`,labelKey:`uiLibrary.eventStream.kindUnregistered`,labelFallback:`Unregistered`},[Ga.DeviceStateChanged]:{icon:ai,color:`bg-foreground-subtle/10 text-foreground-subtle border-border`,labelKey:`uiLibrary.eventStream.kindState`,labelFallback:`State`},[Ga.EventEmitted]:{icon:nr,color:`bg-amber-500/15 text-amber-400 border-amber-500/30`,labelKey:`uiLibrary.eventStream.kindEvent`,labelFallback:`Event`}};function dY(e,t,n){let r=uY[t],i=r?{icon:r.icon,color:r.color,label:e(r.labelKey,r.labelFallback)}:{icon:Le,color:`bg-foreground-subtle/10 text-foreground-subtle border-border`,label:t.split(`.`).pop()??t};if(t===Ga.DeviceStateChanged&&n&&typeof n.capName==`string`){let e=n.capName;return{...i,label:e}}return i}var fY=Object.freeze([...da()]),pY=Object.freeze([Ga.PipelineCameraMetricsSnapshot,Ga.PipelineRunnerLoadSnapshot,Ga.PipelineEngineMetricsSnapshot,Ga.PipelineInferenceResult,Ga.PipelineTrace,Ga.PipelineProgress,Ga.StreamBrokerMetricsSnapshot,Ga.MetricsNodeResourcesSnapshot,Ga.MetricsNodeProcessesSnapshot,Ga.ClusterTopologySnapshot,Ga.MotionAnalysis,Ga.MotionZonesRaw,Ga.DetectionResult,Ga.PipelineAudioInferenceResult,Ga.PlatformProbePhase,Ga.BenchmarkProgress,Ga.ModelDownloadProgress,Ga.ProviderMotion]),mY=new Set(pY),hY=Object.freeze(fY.filter(e=>!mY.has(e)));function gY(e,t,n,r){if(typeof t==`object`&&t&&`kind`in t&&t.kind===`sensor`){let e=`deviceId`in t?t.deviceId:void 0;return r(`uiLibrary.eventStream.summary.sessionBySensor`,`Detection session started by {{who}} motion — phase active`,{who:typeof n==`string`&&n.length>0?n:r(`uiLibrary.eventStream.summary.sensorFallback`,`sensor #{{id}}`,{id:String(e??`?`)})})}return e===null?r(`uiLibrary.eventStream.summary.sessionStarted`,`Detection session started — phase active`):r(`uiLibrary.eventStream.summary.sessionBySensor`,`Detection session started by {{who}} motion — phase active`,{who:e})}function _Y(e,t,n=Fn){if(e===Ga.DetectionPhaseTransition){let e=t.to,r=t.from,i=typeof t.source==`string`?t.source:null,a=typeof t.cooldownMs==`number`?t.cooldownMs:null,o=a?n(`uiLibrary.eventStream.summary.cooldown`,`{{source}}, {{seconds}}s cooldown`,{source:i??``,seconds:Math.round(a/1e3)}):i,s=i?` (${o})`:``,c=t.cause;return c===`attach`?gY(i,t.triggeredBy,t.sensorName,n):c===`detach`?n(`uiLibrary.eventStream.summary.sessionEnded`,`Detection session ended — phase watching`):e===`active`?n(`uiLibrary.eventStream.summary.motionActive`,`Motion detected — phase active{{suffix}}`,{suffix:s}):e===`watching`?n(`uiLibrary.eventStream.summary.cooldownExpired`,`Cooldown expired — phase watching{{suffix}}`,{suffix:s}):n(`uiLibrary.eventStream.summary.phaseChange`,`Phase: {{from}} → {{to}}{{suffix}}`,{from:String(r),to:String(e),suffix:s})}if(e===Ga.DetectionResult){let e=t.frame?.detections??[];if(e.length===0)return null;let n=new Map;for(let t of e){let e=t,r=e.class??e.macroClass,i=typeof r==`string`?r:``;i&&n.set(i,(n.get(i)??0)+1)}return[...n.entries()].map(([e,t])=>t>1?`${e} ×${t}`:e).join(`, `)}if(e===Ga.PipelineAudioInferenceResult){let e=t.frame?.detections??[];return e.length===0?null:e.map(e=>{let t=e,n=t.macroClass??t.class??t.label,r=typeof n==`string`?n:``,i=t.score;return i?`${r} (${Math.round(i*100)}%)`:r}).filter(Boolean).join(`, `)}if(e===Ga.DetectionEvent){let e=t.label??t.class,n=t.score??t.confidence,r=[];return typeof e==`string`&&r.push(e),typeof n==`number`&&r.push(`${Math.round(n*100)}%`),r.length>0?r.join(` — `):null}if(e===Ga.ProviderMotion)return t.detected===!0?n(`uiLibrary.eventStream.summary.motionStart`,`motion start`):n(`uiLibrary.eventStream.summary.motionStop`,`motion stop`);if(e===Ga.DeviceStateChanged){let e=t.slice;if(e&&typeof e==`object`){let t=Object.keys(e).filter(e=>e!==`lastFetchedAt`&&e!==`ts`);if(t.length>0)return t.slice(0,4).join(`, `)+(t.length>4?`…`:``)}return null}if(e===Ga.EventEmitted)return(typeof t.eventType==`string`?t.eventType:null)??null;if(e===Ga.MotionOnMotionChanged){let e=t.detected,n=typeof t.source==`string`?t.source:null,r=e===!0?`motion start`:e===!1?`motion stop`:`motion`;return n?`${r} (${n})`:r}if(e===Ga.ProviderDetection||e===Ga.DetectionCameraNative){let e=t.detections??[];if(!Array.isArray(e)||e.length===0)return(typeof t.class==`string`?t.class:null)??null;let n=new Map;for(let t of e){let e=t,r=e.class??e.macroClass,i=typeof r==`string`?r:``;i&&n.set(i,(n.get(i)??0)+1)}return[...n.entries()].map(([e,t])=>t>1?`${e} ×${t}`:e).join(`, `)}let r=t.addonId;return t.error||(r?`addon: ${r}`:null)}function vY(e){let t=e.category;return t===Ga.DetectionResult||t===Ga.PipelineAudioInferenceResult?_Y(t,e.data)!==null:!0}var yY=300;function bY({agentId:e,addonId:t,deviceId:n,defaultCategories:r,categories:i,category:a,maxHeight:o=`max-h-96`,limit:s=50,showCategoryFilter:l=!0,showFilters:u=!1,liveBuffer:d,onClose:m,className:h}){let g=f(null);As(g);let y=q(),x=p(()=>r??i??hY,[r,i]),S=p(()=>[...x].toSorted().join(`,`),[x]),[w,T]=C(()=>new Set(x)),E=f(S);b(()=>{E.current!==S&&(E.current=S,T(new Set(x)))},[S,x]);let D=VJ(yY),O=d??D,k=O.entries,[A,j]=C(!0),[M,N]=C(new Set),[P,F]=C(``),[I,L]=C(!1),[R,z]=C(``),[B,V]=C(0),H=f(null),U=f(null),ee=`${e??``}:${t??``}:${String(n??``)}:${a??``}`,W=f(ee);b(()=>{W.current!==ee&&(W.current=ee,O.reset(),N(new Set),V(0))},[ee,O]),b(()=>{if(!I)return;let e=e=>{let t=U.current;t&&e.target instanceof Node&&!t.contains(e.target)&&L(!1)};return document.addEventListener(`mousedown`,e),()=>{document.removeEventListener(`mousedown`,e)}},[I]);let G=p(()=>{let r={};return e&&(r.agentId=e),t&&(r.addonId=t),n!==void 0&&(r.deviceId=n),a&&(r.category=a),r},[e,t,n,a]),te=p(()=>[...w].toSorted(),[w]),ne=p(()=>{let e={...G,limit:s};return te.length>0&&te.length<fY.length&&(e.category=te),e},[G,s,p(()=>te.join(`,`),[te]),te]),{data:re,isLoading:K}=X.systemEvents.getRecent.useQuery(ne,{staleTime:3e4}),ie=f(w);b(()=>{ie.current=w},[w]);let ae=G;X.systemEvents.subscribe.useSubscription(ae,{onData:r=>{let i=r;i?.id&&lY(i,e,t,n)&&ie.current.has(i.category)&&O.append(i)}});let oe=f(k.length);b(()=>{let e=H.current;if(!e){oe.current=k.length;return}let t=oe.current;if(oe.current=k.length,!(k.length<=t)){if(A&&e.scrollTop<=8)e.scrollTo({top:0});else if(!A&&e.scrollTop>0){let n=e.firstElementChild?.firstElementChild,r=n instanceof HTMLElement?n.offsetHeight:28;e.scrollTop+=r*(k.length-t)}}},[k.length,A]);let se=p(()=>{let e=new Map;for(let t of re??[])e.set(t.id,t);for(let t of k)e.set(t.id,t);let t=[...e.values()].filter(e=>w.has(e.category)).filter(vY);B>0&&(t=t.filter(e=>new Date(e.timestamp).getTime()>B));let n=P.trim().toLowerCase();return n&&(t=t.filter(e=>{if(e.category.toLowerCase().includes(n)||dY(y,e.category,e.data).label.toLowerCase().includes(n))return!0;let t=_Y(e.category,e.data,y);if(t&&t.toLowerCase().includes(n))return!0;try{if(new Date(e.timestamp).toLocaleTimeString().toLowerCase().includes(n))return!0}catch{}try{if(JSON.stringify(e.data).toLowerCase().includes(n)||JSON.stringify(e.source).toLowerCase().includes(n))return!0}catch{}return!1})),t.toSorted((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime())},[re,k,w,P,B,y]),ce=_(e=>{N(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),le=_(e=>{T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ue=_(()=>{T(new Set(x)),F(``),V(0)},[x]),fe=_(()=>{V(Date.now()),O.reset()},[O]),[pe,me]=C(!1),[he,ge]=C(null),_e=_(e=>{let t=new Date(e.timestamp).toISOString(),n=_Y(e.category,e.data,y)??``,r=n?` ${n}`:``;return`${t} [${e.category}]${r} data=${JSON.stringify(e.data)}`},[y]),ve=_(()=>{let e=se.map(_e);navigator.clipboard.writeText(e.join(`
|
|
5
5
|
`)).then(()=>{me(!0),setTimeout(()=>me(!1),1500)})},[se,_e]),ye=_(e=>{navigator.clipboard.writeText(_e(e)).then(()=>{ge(e.id),setTimeout(()=>ge(t=>t===e.id?null:t),1200)})},[_e]),be=_(()=>{T(new Set(fY))},[]),xe=_(()=>{T(new Set)},[]),Se=p(()=>{let e=R.trim().toLowerCase();return e?fY.filter(t=>t.toLowerCase().includes(e)):fY},[R]),Ce=fY.length,we=w.size,Te=we===Ce,Ee=Te?`All`:`${we}/${Ce}`;return c(`div`,{className:$(`h-full min-h-0 flex flex-col`,h),onClick:e=>e.stopPropagation(),children:[c(`div`,{className:`flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0`,children:[c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[v(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:y(`uiLibrary.eventStream.title`,`Events`)}),e&&v(CY,{label:`agent`,value:e}),t&&v(CY,{label:`addon`,value:t}),n!==void 0&&v(CY,{label:`device`,value:`#${n}`}),a&&v(CY,{label:`category`,value:a}),c(`button`,{type:`button`,onClick:()=>{j(e=>!e),!A&&H.current&&H.current.scrollTo({top:0,behavior:`smooth`})},className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,A?`border-border text-foreground-subtle hover:text-foreground`:`border-amber-500/30 bg-amber-500/10 text-amber-400`),children:[v(aee,{className:`h-2.5 w-2.5`}),A?y(`uiLibrary.eventStream.auto`,`Auto`):y(`uiLibrary.eventStream.paused`,`Paused`)]}),l&&c(`div`,{className:`relative`,ref:U,children:[c(`button`,{type:`button`,onClick:()=>L(e=>!e),className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,Te?`border-border text-foreground-subtle hover:text-foreground`:`border-violet-500/30 bg-violet-500/10 text-violet-400`),title:y(`uiLibrary.eventStream.pickEvents`,`Pick events to track`),children:[v(Re,{className:`h-2.5 w-2.5`}),y(`uiLibrary.eventStream.filter`,`Filter ({{label}})`,{label:Ee})]}),I&&v(xY,{search:R,onSearchChange:z,categories:Se,active:w,onToggle:le,onSelectAll:be,onSelectNone:xe,onResetDefaults:ue})]}),c(`button`,{type:`button`,onClick:ue,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:y(`uiLibrary.eventStream.resetTitle`,`Reset filters to defaults`),children:[v(Lt,{className:`h-2.5 w-2.5`}),y(`uiLibrary.eventStream.reset`,`Reset`)]}),c(`button`,{type:`button`,onClick:fe,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:y(`uiLibrary.eventStream.clearTitle`,`Clear visible entries`),children:[v(Pe,{className:`h-2.5 w-2.5`}),y(`uiLibrary.eventStream.clear`,`Clear`)]}),c(`button`,{type:`button`,onClick:ve,disabled:se.length===0,className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,pe?`border-emerald-500/30 bg-emerald-500/10 text-emerald-400`:`border-border text-foreground-subtle hover:text-foreground`,se.length===0&&`opacity-40 cursor-not-allowed`),title:y(`uiLibrary.eventStream.copyAllTitle`,`Copy all visible events`),children:[v(ei,{className:`h-2.5 w-2.5`}),pe?y(`uiLibrary.eventStream.copied`,`Copied!`):y(`uiLibrary.eventStream.copy`,`Copy`)]}),c(`div`,{className:`relative`,children:[v(`input`,{ref:g,type:`text`,value:P,onChange:e=>F(e.target.value),placeholder:y(`uiLibrary.eventStream.search`,`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`}),P&&v(`button`,{type:`button`,onClick:()=>F(``),className:`absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,title:y(`uiLibrary.eventStream.clearSearch`,`Clear search`),children:v(Zn,{className:`h-2.5 w-2.5`})})]}),k.length>0&&v(`span`,{className:`text-[9px] text-emerald-400 font-medium`,children:y(`uiLibrary.eventStream.live`,`+{{count}} live`,{count:k.length})})]}),m&&v(`button`,{type:`button`,onClick:m,className:`text-foreground-subtle hover:text-foreground`,children:v(Zn,{className:`h-3.5 w-3.5`})})]}),c(`div`,{ref:H,className:$(`flex-1 min-h-0 overflow-auto text-[10px]`,o),children:[K&&c(`div`,{className:`flex items-center justify-center gap-2 py-6 text-foreground-subtle`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),y(`uiLibrary.eventStream.loading`,`Loading events...`)]}),!K&&se.length===0&&v(`div`,{className:`py-4 text-center text-foreground-subtle`,children:y(`uiLibrary.eventStream.empty`,`No events found`)}),se.length>0&&v(`div`,{className:`divide-y divide-border/30`,children:se.map(e=>{let t=dY(y,e.category,e.data),n=t.icon,r=_Y(e.category,e.data,y),i=M.has(e.id);return c(`div`,{className:`flex items-start gap-2 px-3 py-1.5 hover:bg-surface-hover/30 cursor-pointer`,onClick:()=>ce(e.id),children:[v(`span`,{className:`text-foreground-subtle whitespace-nowrap w-[70px] shrink-0 pt-0.5`,children:new Date(e.timestamp).toLocaleTimeString()}),v(wY,{copied:he===e.id,onCopy:()=>ye(e)}),c(`div`,{className:`flex-1 min-w-0`,children:[c(`div`,{className:`flex items-center gap-1.5`,children:[v(i?de:It,{className:`h-3 w-3 text-foreground-subtle shrink-0`}),c(`span`,{className:$(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[9px] font-medium`,t.color),children:[v(n,{className:`h-2.5 w-2.5`}),t.label]}),e.source.nodeId&&e.source.nodeId!==`hub`&&v(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-foreground-subtle/10 text-foreground-subtle font-mono`,children:e.source.nodeId})]}),r&&v(`p`,{className:`text-foreground-subtle text-[10px] mt-0.5 ml-5`,children:r}),i&&c(`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:[c(`div`,{children:[v(`span`,{className:`text-primary/70`,children:`source`}),v(`span`,{className:`text-foreground-subtle`,children:`: `}),v(`span`,{className:`text-foreground`,children:JSON.stringify(e.source)})]}),c(`div`,{children:[v(`span`,{className:`text-primary/70`,children:`category`}),v(`span`,{className:`text-foreground-subtle`,children:`: `}),v(`span`,{className:`text-foreground`,children:e.category})]}),Object.entries(e.data).map(([e,t])=>c(`div`,{children:[v(`span`,{className:`text-primary/70`,children:e}),v(`span`,{className:`text-foreground-subtle`,children:`: `}),v(`span`,{className:`text-foreground break-all`,children:typeof t==`object`?JSON.stringify(t):String(t)})]},e))]})]})]},e.id)})})]})]})}function xY({search:e,onSearchChange:t,categories:n,active:r,onToggle:i,onSelectAll:a,onSelectNone:o,onResetDefaults:s}){let l=q();return c(`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:e=>e.stopPropagation(),children:[c(`div`,{className:`flex items-center gap-1 px-2 py-1.5 border-b border-border/50`,children:[v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),v(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:l(`uiLibrary.eventStream.filterCategories`,`Filter categories…`),className:`flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle`,autoFocus:!0}),e&&v(`button`,{type:`button`,onClick:()=>t(``),className:`text-foreground-subtle hover:text-foreground`,children:v(Zn,{className:`h-2.5 w-2.5`})})]}),c(`div`,{className:`flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]`,children:[v(`button`,{type:`button`,onClick:a,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.eventStream.all`,`All`)}),v(`button`,{type:`button`,onClick:o,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.eventStream.none`,`None`)}),v(`button`,{type:`button`,onClick:s,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.eventStream.defaults`,`Defaults`)})]}),c(`div`,{className:`overflow-y-auto flex-1`,children:[n.length===0&&v(`div`,{className:`text-[10px] text-foreground-subtle italic px-2 py-3 text-center`,children:l(`uiLibrary.eventStream.noMatches`,`No matches`)}),n.map(e=>{let t=r.has(e),n=dY(l,e),a=n.icon;return c(`button`,{type:`button`,onClick:()=>i(e),className:`w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]`,children:[v(`input`,{type:`checkbox`,readOnly:!0,checked:t,className:`accent-violet-500`}),c(`span`,{className:$(`inline-flex items-center gap-1 rounded-full border px-1.5 py-0.5 text-[9px] font-medium shrink-0`,n.color),children:[v(a,{className:`h-2.5 w-2.5`}),n.label]}),v(`span`,{className:`text-foreground-subtle font-mono truncate`,children:e})]},e)})]})]})}function SY({position:e=`bottom`,className:t,...n}){return v(`div`,{className:$(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:v(bY,{maxHeight:`max-h-48`,...n})})}function CY({label:e,value:t}){return c(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium`,children:[e,`: `,t]})}function wY({copied:e,onCopy:t}){return v(`button`,{type:`button`,title:q()(`uiLibrary.eventStream.copyOne`,`Copy this event`),onClick:e=>{e.stopPropagation(),t()},className:$(`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:v(e?dt:ei,{className:`h-3 w-3`})})}var TY=[/at$/i,/atms$/i,/^timestamp$/i,/timestamp$/i,/since$/i,/^lastseen$/i,/lastseen$/i,/^expires?$/i,/expiry$/i],EY=0xe8d4a51000,DY=4e12,OY=1e9,kY=4e9;function AY(e){return TY.some(t=>t.test(e))}function jY(e){return Number.isFinite(e)?e>=EY&&e<=DY?e:e>=OY&&e<=kY?e*1e3:null:null}function MY(e){let t=new Date(e);return Number.isNaN(t.getTime())?String(e):t.toLocaleString(void 0,{year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function NY(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 PY(e,t){if(typeof t==`number`&&AY(e)){let e=jY(t);if(e!==null)return{text:MY(e),raw:String(t)}}if(typeof t==`string`&&FY(t)){let e=Date.parse(t);if(!Number.isNaN(e))return{text:MY(e),raw:t}}return{text:NY(t),raw:null}}function FY(e){return/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?(Z|[+-]\d{2}:?\d{2})?$/.test(e)}E();function IY(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(n.category!==Ga.DeviceStateChanged)return null;let r=n.data;return!r||typeof r!=`object`||r.deviceId!==t||typeof r.capName!=`string`||!r.slice||typeof r.slice!=`object`?null:{capName:r.capName,slice:r.slice}}function LY(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function RY(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.source==`string`?!!t.data&&typeof t.data==`object`&&!Array.isArray(t.data):!1}function zY(e,t){let n=new Map;for(let[r,i]of Object.entries(e)){let e=i&&typeof i==`object`&&!Array.isArray(i)?i:{value:i};n.set(r,{slice:e,updatedAt:t})}return n}var BY=Object.freeze([...new Set(qa.filter(e=>e.scope===`device`).map(e=>e.name))].toSorted());function VY(e){let t=qa.find(t=>t.name===e)?.runtimeState;if(!t||typeof t!=`object`)return[];let n=Reflect.get(t,`shape`);return!n||typeof n!=`object`?[]:Object.keys(n)}function HY(e){let t=VY(e);if(t.length===0)return null;let n={};for(let e of t)n[e]=null;return n}var UY=1;function WY({deviceId:e,defaultCaps:t,maxHeight:n=`max-h-96`,onClose:r,className:i}){let a=f(null);As(a);let o=q(),[s,l]=C(p(()=>new Set(t??[]),[t])),[u,d]=C(``),[m,h]=C(!1),[g,y]=C(``),[x,S]=C(`normalized`),T=f(null),[E,D]=C(new Map),[O,k]=C(new Map),[,A]=C(0),j=f(e);b(()=>{j.current!==e&&(j.current=e,D(new Map),k(new Map))},[e]);let{data:M,isLoading:N}=X.deviceState.getAllSnapshots.useQuery({},{staleTime:3e4});b(()=>{if(!LY(M))return;let t=M[String(e)];if(!t)return;let n=Date.now();D(e=>{let r=!1,i=new Map(e);for(let[e,a]of Object.entries(t)){let t=i.get(e);t&&t.placeholder!==!0||(i.set(e,{slice:a,updatedAt:n}),r=!0)}return r?i:e})},[M,e]);let{data:F}=X.deviceManager.getBindings.useQuery({deviceId:e},{staleTime:3e4});b(()=>{let e=F?.entries;if(!e||e.length===0)return;let t=Date.now();D(n=>{let r=!1,i=new Map(n);for(let n of e){if(i.has(n.capName))continue;let e=HY(n.capName);e&&(i.set(n.capName,{slice:e,updatedAt:t,placeholder:!0}),r=!0)}return r?i:n})},[F,e]);let I=_((e,t)=>{D(n=>{let r=new Map(n);return r.set(e,{slice:t,updatedAt:Date.now()}),r})},[]),L=Ge(Rn().trpcClient,e)?.deviceOps?.getRawState,R=w({queryKey:[`device-raw-state`,e],queryFn:()=>L({deviceId:e}),enabled:L!=null,staleTime:6e4}),z=RY(R.data)?R.data:null,B=R.isFetched&&!R.isError&&z!=null;b(()=>{x===`raw`&&!B&&S(`normalized`)},[x,B]);let V=p(()=>z?zY(z.data,R.dataUpdatedAt||Date.now()):new Map,[z,R.dataUpdatedAt]);b(()=>{let e=setInterval(()=>A(e=>e+1),5e3);return()=>clearInterval(e)},[]);let H=p(()=>{let e=new Set(BY);for(let t of E.keys())e.add(t);return[...e].toSorted()},[E]),U=p(()=>{let e=u.trim().toLowerCase();return[...E.keys()].toSorted().filter(t=>s.size>0&&!s.has(t)?!1:!e||t.toLowerCase().includes(e)?!0:eX(E.get(t)?.slice??{},e))},[E,s,u]),ee=_(e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),W=_(()=>{l(new Set(t??[])),d(``)},[t]),G=_(()=>{l(new Set(H))},[H]),te=_(()=>{l(new Set)},[]),ne=_((e,t)=>{k(n=>{let r=new Map(n);return r.set(e,!t),r})},[]),re=_((e,t)=>{let n=O.get(e);return n===void 0?t<UY:n},[O]),[K,ie]=C(!1),ae=_(()=>{let e={};for(let t of U){let n=E.get(t);n&&(e[t]=n.slice)}navigator.clipboard.writeText(JSON.stringify(e,null,2)).then(()=>{ie(!0),setTimeout(()=>ie(!1),1500)})},[U,E]),oe=p(()=>{let e=g.trim().toLowerCase();return e?H.filter(t=>t.toLowerCase().includes(e)):H},[g,H]),se=H.length,ce=s.size,le=ce===0||ce===se,ue=le?o(`uiLibrary.stateValuesStream.filterAll`,`All`):`${ce}/${se}`;b(()=>{if(!m)return;let e=e=>{let t=T.current;t&&!t.contains(e.target)&&h(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[m]);let de=u.trim().toLowerCase();return c(`div`,{className:$(`h-full min-h-0 flex flex-col`,i),onClick:e=>e.stopPropagation(),children:[c(`div`,{className:`flex items-center justify-between px-3 py-1.5 bg-surface-hover/30 gap-2 shrink-0`,children:[c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[v(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:o(`uiLibrary.stateValuesStream.state`,`State`)}),v(nX,{label:o(`uiLibrary.stateValuesStream.scopeDevice`,`device`),value:`#${e}`}),B&&v(GY,{mode:x,onChange:S}),x===`normalized`&&c(P,{children:[c(`div`,{className:`relative`,ref:T,children:[c(`button`,{type:`button`,onClick:()=>h(e=>!e),className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,le?`border-border text-foreground-subtle hover:text-foreground`:`border-violet-500/30 bg-violet-500/10 text-violet-400`),title:o(`uiLibrary.stateValuesStream.pickCaps`,`Pick caps to show`),children:[v(Re,{className:`h-2.5 w-2.5`}),o(`uiLibrary.stateValuesStream.filter`,`Filter ({{label}})`,{label:ue})]}),m&&v(rX,{search:g,onSearchChange:y,caps:oe,active:s,onToggle:ee,onSelectAll:G,onSelectNone:te,onResetDefaults:W})]}),c(`button`,{type:`button`,onClick:W,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:o(`uiLibrary.stateValuesStream.resetFilters`,`Reset filters`),children:[v(Lt,{className:`h-2.5 w-2.5`}),o(`uiLibrary.stateValuesStream.reset`,`Reset`)]}),c(`button`,{type:`button`,onClick:ae,disabled:U.length===0,className:$(`inline-flex items-center gap-1 text-[9px] px-1.5 py-0.5 rounded border transition-colors`,K?`border-emerald-500/30 bg-emerald-500/10 text-emerald-400`:`border-border text-foreground-subtle hover:text-foreground`,U.length===0&&`opacity-40 cursor-not-allowed`),title:o(`uiLibrary.stateValuesStream.copyTitle`,`Copy visible state as JSON`),children:[v(ei,{className:`h-2.5 w-2.5`}),K?o(`uiLibrary.stateValuesStream.copied`,`Copied!`):o(`uiLibrary.stateValuesStream.copy`,`Copy`)]}),c(`div`,{className:`relative`,children:[v(`input`,{ref:a,type:`text`,value:u,onChange:e=>d(e.target.value),placeholder:o(`uiLibrary.stateValuesStream.search`,`Search…`),className:`w-32 pl-1.5 pr-5 py-0.5 rounded border border-border bg-background text-foreground text-[10px] focus:outline-none focus:border-primary/50`}),u&&v(`button`,{type:`button`,onClick:()=>d(``),className:`absolute right-1 top-1/2 -translate-y-1/2 text-foreground-subtle hover:text-foreground`,title:o(`uiLibrary.stateValuesStream.clearSearch`,`Clear search`),children:v(Zn,{className:`h-2.5 w-2.5`})})]}),c(`span`,{className:`text-[9px] text-emerald-400 font-medium inline-flex items-center gap-1`,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-emerald-400 animate-pulse`}),o(`uiLibrary.stateValuesStream.live`,`live`)]})]}),x===`raw`&&z&&c(P,{children:[v(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-sky-500/30 bg-sky-500/15 text-sky-400 px-2 py-0.5 text-[9px] font-medium font-sans`,children:o(`uiLibrary.stateValuesStream.source`,`source: {{source}}`,{source:z.source})}),c(`button`,{type:`button`,onClick:()=>R.refetch(),disabled:R.isFetching,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`,R.isFetching&&`opacity-60 cursor-wait`),title:o(`uiLibrary.stateValuesStream.rereadTitle`,`Re-read raw upstream state`),children:[v(Lt,{className:$(`h-2.5 w-2.5`,R.isFetching&&`animate-spin`)}),o(`uiLibrary.stateValuesStream.refresh`,`Refresh`)]})]})]}),x===`normalized`&&v(KY,{deviceId:e,onPatch:I}),r&&v(`button`,{type:`button`,onClick:r,className:`text-foreground-subtle hover:text-foreground`,children:v(Zn,{className:`h-3.5 w-3.5`})})]}),v(`div`,{className:$(`flex-1 min-h-0 overflow-auto text-[10px] font-mono`,n),children:x===`raw`?V.size===0?v(`div`,{className:`py-4 text-center text-foreground-subtle font-sans`,children:o(`uiLibrary.stateValuesStream.noRawState`,`No raw state`)}):v(`div`,{className:`py-1`,children:[...V.entries()].map(([e,t])=>v(qY,{capName:e,slice:t.slice,updatedAt:t.updatedAt,searchNeedle:``,isPathOpen:re,onToggle:ne},e))}):c(P,{children:[N&&E.size===0&&c(`div`,{className:`flex items-center justify-center gap-2 py-6 text-foreground-subtle font-sans`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),o(`uiLibrary.stateValuesStream.loading`,`Loading device state...`)]}),!N&&E.size===0&&v(`div`,{className:`py-4 text-center text-foreground-subtle font-sans`,children:o(`uiLibrary.stateValuesStream.noRuntimeState`,`No runtime state`)}),!N&&E.size>0&&U.length===0&&v(`div`,{className:`py-4 text-center text-foreground-subtle font-sans`,children:o(`uiLibrary.stateValuesStream.noCapsMatch`,`No caps match the filter`)}),U.length>0&&v(`div`,{className:`py-1`,children:U.map(e=>{let t=E.get(e);return t?v(qY,{capName:e,slice:t.slice,updatedAt:t.updatedAt,searchNeedle:de,isPathOpen:re,onToggle:ne},e):null})})]})})]})}function GY({mode:e,onChange:t}){let n=q();return v(`div`,{className:`inline-flex items-center rounded border border-border overflow-hidden`,children:[{value:`normalized`,label:n(`uiLibrary.stateValuesStream.normalized`,`Normalized`)},{value:`raw`,label:n(`uiLibrary.stateValuesStream.raw`,`Raw`)}].map(n=>v(`button`,{type:`button`,onClick:()=>t(n.value),className:$(`text-[9px] px-1.5 py-0.5 transition-colors`,e===n.value?`bg-violet-500/15 text-violet-400`:`text-foreground-subtle hover:text-foreground`),children:n.label},n.value))})}function KY({deviceId:e,onPatch:t}){return X.systemEvents.subscribe.useSubscription({deviceId:e,category:Ga.DeviceStateChanged},{onData:n=>{let r=IY(n,e);r&&t(r.capName,r.slice)}}),null}function qY({capName:e,slice:t,updatedAt:n,searchNeedle:r,isPathOpen:i,onToggle:a}){let o=q(),s=e,l=i(s,0),u=Object.entries(t);return c(`div`,{children:[c(`div`,{className:`flex items-center gap-1.5 px-3 py-1 hover:bg-surface-hover/30 cursor-pointer select-none`,onClick:()=>a(s,l),children:[v(XY,{open:l,hasChildren:u.length>0}),v(`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 font-sans`,children:e}),v(`span`,{className:`text-[9px] text-foreground-subtle font-sans`,children:o(`uiLibrary.stateValuesStream.keys`,{one:`{{count}} key`,other:`{{count}} keys`},{count:u.length})}),v(`span`,{className:`ml-auto text-[9px] text-foreground-subtle/70 font-sans tabular-nums`,children:o(`uiLibrary.stateValuesStream.updated`,`updated {{age}}`,{age:tX(n,o)})})]}),l&&v(`div`,{children:u.length===0?v(YY,{depth:1,label:o(`uiLibrary.stateValuesStream.emptySlice`,`empty slice`)}):u.map(([e,t])=>v(JY,{path:`${s}.${e}`,nodeKey:e,value:t,depth:1,searchNeedle:r,isPathOpen:i,onToggle:a},e))})]})}function JY({path:e,nodeKey:t,value:n,depth:r,searchNeedle:i,isPathOpen:a,onToggle:o}){let s=q(),l=ZY(n),u={paddingLeft:`${12+r*14}px`};if(!l){let e=PY(t,n);return c(`div`,{className:`flex items-start gap-1 px-3 py-0.5`,style:u,children:[v(`span`,{className:$(`shrink-0`,$Y(t,i,`text-primary/70`)),children:t}),v(`span`,{className:`text-foreground-subtle`,children:`:`}),v(`span`,{className:$(`break-all`,$Y(e.text,i,QY(n))),...e.raw===null?{}:{title:e.raw},children:e.text})]})}let d=a(e,r);return c(`div`,{children:[c(`div`,{className:`flex items-center gap-1 px-3 py-0.5 hover:bg-surface-hover/30 cursor-pointer select-none`,style:u,onClick:()=>o(e,d),children:[v(XY,{open:d,hasChildren:l.entries.length>0}),v(`span`,{className:$Y(t,i,`text-primary/70`),children:t}),v(`span`,{className:`text-foreground-subtle/70 text-[9px]`,children:l.summary})]}),d&&(l.entries.length===0?v(YY,{depth:r+1,label:l.kind===`array`?s(`uiLibrary.stateValuesStream.emptyArray`,`empty array`):s(`uiLibrary.stateValuesStream.emptyObject`,`empty object`)}):l.entries.map(([t,n])=>v(JY,{path:`${e}.${t}`,nodeKey:t,value:n,depth:r+1,searchNeedle:i,isPathOpen:a,onToggle:o},t)))]})}function YY({depth:e,label:t}){return v(`div`,{className:`px-3 py-0.5 text-foreground-subtle/60 italic`,style:{paddingLeft:`${12+e*14}px`},children:t})}function XY({open:e,hasChildren:t}){return t?v(e?de:It,{className:`h-3 w-3 text-foreground-subtle shrink-0`}):v(`span`,{className:`inline-block w-3 shrink-0`})}function ZY(e){if(Array.isArray(e))return{kind:`array`,entries:e.map((e,t)=>[String(t),e]),summary:`[${e.length}]`};if(e&&typeof e==`object`){let t=Object.entries(e);return{kind:`object`,entries:t,summary:`{${t.length}}`}}return null}function QY(e){return e==null?`text-foreground-subtle/60`:typeof e==`number`?`text-amber-400`:typeof e==`boolean`?e?`text-emerald-400`:`text-rose-400`:`text-foreground`}function $Y(e,t,n){return t&&e.toLowerCase().includes(t)?$(n,`bg-violet-500/20 rounded px-0.5`):n}function eX(e,t,n=``){if(Array.isArray(e))return e.some((e,n)=>eX(e,t,String(n)));if(e&&typeof e==`object`){for(let[n,r]of Object.entries(e))if(n.toLowerCase().includes(t)||eX(r,t,n))return!0;return!1}let r=PY(n,e);return r.text.toLowerCase().includes(t)?!0:r.raw!==null&&r.raw.toLowerCase().includes(t)}function tX(e,t){let n=Date.now()-e;if(n<5e3)return t(`uiLibrary.stateValuesStream.justNow`,`just now`);let r=Math.floor(n/1e3);if(r<60)return t(`uiLibrary.stateValuesStream.secondsAgo`,`{{count}}s ago`,{count:r});let i=Math.floor(r/60);return i<60?t(`uiLibrary.stateValuesStream.minutesAgo`,`{{count}}m ago`,{count:i}):t(`uiLibrary.stateValuesStream.hoursAgo`,`{{count}}h ago`,{count:Math.floor(i/60)})}function nX({label:e,value:t}){return c(`span`,{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-primary/10 text-primary font-medium font-sans`,children:[e,`: `,t]})}function rX({search:e,onSearchChange:t,caps:n,active:r,onToggle:i,onSelectAll:a,onSelectNone:o,onResetDefaults:s}){let l=q();return c(`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 font-sans`,onClick:e=>e.stopPropagation(),children:[c(`div`,{className:`flex items-center gap-1 px-2 py-1.5 border-b border-border/50`,children:[v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),v(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:l(`uiLibrary.stateValuesStream.filterCaps`,`Filter caps…`),className:`flex-1 bg-transparent text-[10px] focus:outline-none text-foreground placeholder:text-foreground-subtle`,autoFocus:!0}),e&&v(`button`,{type:`button`,onClick:()=>t(``),className:`text-foreground-subtle hover:text-foreground`,children:v(Zn,{className:`h-2.5 w-2.5`})})]}),c(`div`,{className:`flex items-center gap-1 px-2 py-1 border-b border-border/50 text-[9px]`,children:[v(`button`,{type:`button`,onClick:a,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.stateValuesStream.all`,`All`)}),v(`button`,{type:`button`,onClick:o,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.stateValuesStream.none`,`None`)}),v(`button`,{type:`button`,onClick:s,className:`px-1.5 py-0.5 rounded border border-border text-foreground-subtle hover:text-foreground`,children:l(`uiLibrary.stateValuesStream.defaults`,`Defaults`)})]}),c(`div`,{className:`overflow-y-auto flex-1`,children:[n.length===0&&v(`div`,{className:`text-[10px] text-foreground-subtle italic px-2 py-3 text-center`,children:l(`uiLibrary.stateValuesStream.noMatches`,`No matches`)}),n.map(e=>c(`button`,{type:`button`,onClick:()=>i(e),className:`w-full flex items-center gap-2 px-2 py-1 text-left hover:bg-surface-hover/40 text-[10px]`,children:[v(`input`,{type:`checkbox`,readOnly:!0,checked:r.has(e),className:`accent-violet-500`}),v(`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:e})]},e))]})]})}E();var iX=500,aX=[{id:`logs`,labelKey:`uiLibrary.deviceActivityPanel.logs`,labelFallback:`Logs`,icon:Pi},{id:`events`,labelKey:`uiLibrary.deviceActivityPanel.events`,labelFallback:`Events`,icon:Bt},{id:`state`,labelKey:`uiLibrary.deviceActivityPanel.state`,labelFallback:`State`,icon:oee}];function oX({deviceId:e,containerDeviceId:t,defaultEventCategories:n,defaultStateCaps:r,initialTab:i=`events`,className:a,maxHeight:o=`max-h-96`}){let s=q(),[l,u]=C(i),d=VJ(iX),f=VJ(iX),p=VJ(iX),m=d.reset,h=f.reset,g=p.reset;return b(()=>{m(),h(),g()},[e,m,h,g]),c(`div`,{className:$(`flex flex-col h-full min-h-0`,a),children:[v(`div`,{className:`flex items-center gap-1 mb-2 shrink-0`,children:aX.map(({id:e,labelKey:t,labelFallback:n,icon:r})=>c(`button`,{type:`button`,onClick:()=>u(e),className:$(`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-[11px] font-medium transition-colors`,l===e?`bg-primary/15 text-primary border border-primary/30`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover border border-transparent`),children:[v(r,{className:`h-3.5 w-3.5`}),s(t,n)]},e))}),c(`div`,{className:`flex-1 min-h-0 overflow-hidden`,children:[l===`logs`&&v(nY,{...t===void 0?{deviceId:e}:{containerDeviceId:t},maxHeight:o,showFilters:!1,liveBuffer:d}),l===`events`&&v(bY,{deviceId:e,defaultCategories:n,maxHeight:o,showCategoryFilter:!0,liveBuffer:f}),l===`state`&&v(WY,{deviceId:e,defaultCaps:r,maxHeight:o,liveBuffer:p})]})]})}var sX={online:`bg-success`,offline:`bg-danger`,warning:`bg-warning`,unknown:`bg-foreground-subtle`};function cX({title:e,subtitle:t,status:n,selected:r,onClick:i,badges:a,actions:o,offlineAction:s,className:l}){let u=n===`offline`;return c(`div`,{onClick:i,className:$(`w-full rounded-lg border p-3 text-left transition-colors`,i&&`cursor-pointer`,r?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`,u&&!r&&`opacity-50`,l),children:[c(`div`,{className:`flex items-center justify-between mb-2`,children:[v(`span`,{className:`text-sm font-medium truncate`,children:e}),n&&v(`span`,{className:$(`h-2 w-2 rounded-full shrink-0`,sX[n])})]}),t&&v(`div`,{className:`text-[11px] text-foreground-muted`,children:t}),a&&a.length>0&&v(`div`,{className:`flex flex-wrap gap-1 mt-2`,children:a.map((e,t)=>{let n=$(`rounded px-1.5 py-0.5 text-[10px] flex items-center gap-0.5`,r?`bg-primary/20`:`bg-surface-hover`,e.onClick&&`hover:opacity-80 transition-opacity cursor-pointer`);return e.onClick?c(`button`,{onClick:t=>{t.stopPropagation(),e.onClick()},className:n,children:[e.icon,e.label]},t):c(`span`,{className:n,children:[e.icon,e.label]},t)})}),!u&&o&&o.length>0&&v(`div`,{className:`flex items-center gap-0.5 mt-2 -mb-1`,children:o.map((e,t)=>v(`button`,{onClick:t=>{t.stopPropagation(),e.onClick()},className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground transition-colors`,title:e.label,"aria-label":e.label,children:e.icon},t))}),u&&s&&v(`div`,{className:`mt-2`,onClick:e=>e.stopPropagation(),children:s})]})}E();var lX=`fill`,uX=`right`,dX=`center`;function fX({align:e,children:t,className:n,...r}){if(e===`fit`)return v(`div`,{...r,className:$(`inline-flex items-center`,n),children:t});let i=e===`center`?`justify-center`:`justify-end`;return v(`div`,{...r,className:$(`w-[140px] shrink-0 flex items-center gap-1.5`,i,e===`fill`?`[&>*:last-child]:w-full`:``,n),children:t})}function pX({value:e,unit:t}){return c(`span`,{className:`text-sm text-foreground`,children:[e,t?v(`span`,{"data-unit":!0,className:`ml-0.5 text-[11px] text-foreground-subtle`,children:t}):null]})}function mX({value:e,unit:t,onDelta:n}){let r=q();return c(`div`,{className:`flex h-8 w-full overflow-hidden rounded-lg border border-border bg-surface`,children:[v(`button`,{type:`button`,"aria-label":r(`uiLibrary.deviceControlAtoms.decrement`,`Decrement`),className:`w-9 shrink-0 bg-surface-hover text-base text-foreground`,onClick:()=>n(-1),children:`−`}),c(`span`,{className:`flex flex-1 items-center justify-center gap-0.5 border-x border-border/60 text-sm`,children:[e,t?v(`span`,{"data-unit":!0,className:`text-[11px] text-foreground-subtle`,children:t}):null]}),v(`button`,{type:`button`,"aria-label":r(`uiLibrary.deviceControlAtoms.increment`,`Increment`),className:`w-9 shrink-0 bg-surface-hover text-base text-foreground`,onClick:()=>n(1),children:`+`})]})}function hX({on:e,targetLabel:t,onConfirm:n}){let r=f(null),i=f(!1);return c(`div`,{className:$(`relative h-12 w-full rounded-full border flex items-center`,e?`bg-emerald-50 border-emerald-200 pl-4`:`bg-amber-50 border-amber-200 justify-end pr-4`),children:[v(`span`,{className:`text-xs font-semibold opacity-60`,children:t}),v(`span`,{"data-testid":`slide-thumb`,className:`absolute top-1 left-1 h-10 w-14 rounded-[19px] bg-surface shadow flex items-center justify-center`,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId),r.current=e.clientX,i.current=!1},onPointerMove:e=>{r.current!==null&&Math.abs(e.clientX-r.current)>40&&(i.current=!0)},onPointerUp:()=>{i.current&&n(),i.current=!1,r.current=null},onPointerCancel:()=>{i.current=!1,r.current=null}})]})}var gX=2,_X=270,vX=315;function yX(e){let t=(e-135+360)%360;return t>_X?+(t<=vX):t/_X}function bX({fraction:e,color:t,knobTopPx:n,onDragFraction:r}){let i=-135+e*270,a=f(null),[o,s]=C(!1),c=r!==void 0,l=n??gX,u=e=>{r!==void 0&&(e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture?.(e.pointerId),s(!0))},d=e=>{if(r===void 0||!o)return;let t=a.current;if(t===null)return;let n=t.getBoundingClientRect(),i=n.left+n.width/2,s=n.top+n.height/2;r(yX(Math.atan2(e.clientY-s,e.clientX-i)*180/Math.PI))},p=e=>{r!==void 0&&(e.currentTarget.releasePointerCapture?.(e.pointerId),s(!1))};return v(`div`,{ref:a,className:`absolute inset-0`,style:{transform:`rotate(${i}deg)`},children:v(`div`,{className:$(`absolute left-1/2 h-5 w-5 -translate-x-1/2 rounded-full bg-white shadow`,c&&(o?`cursor-grabbing`:`cursor-grab`)),style:{top:l,border:`3px solid ${t}`},...c?{onPointerDown:u,onPointerMove:d,onPointerUp:p,onPointerCancel:p}:{}})})}function xX({fraction:e,color:t}){return c(`div`,{className:`relative h-2 w-full rounded-full bg-border`,children:[v(`div`,{className:`absolute left-0 top-0 h-2 rounded-full`,style:{width:`${e*100}%`,background:t??`var(--color-primary)`}}),v(`div`,{className:`absolute -top-1 h-4 w-4 rounded-full bg-white shadow`,style:{left:`calc(${e*100}% - 8px)`}})]})}var SX=150,CX=64,wX=SX/2,TX=2*Math.PI*CX,EX=270/360*TX;function DX({fraction:e,color:t,children:n,onDragFraction:r}){let i=Math.min(1,Math.max(0,e)),a=SX/2,o=SX/2,s=TX-EX,l=i*EX;return c(`div`,{className:`relative`,style:{width:SX,height:SX},children:[c(`svg`,{width:SX,height:SX,viewBox:`0 0 ${SX} ${SX}`,"aria-hidden":`true`,className:`absolute inset-0`,style:{transform:`rotate(135deg)`},children:[v(`circle`,{cx:a,cy:o,r:CX,fill:`none`,stroke:`var(--color-border)`,strokeWidth:11,strokeDasharray:`${EX} ${s}`,strokeLinecap:`round`}),v(`circle`,{cx:a,cy:o,r:CX,fill:`none`,stroke:t,strokeWidth:11,strokeDasharray:`${l} ${TX-l}`,strokeLinecap:`round`})]}),v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:i,color:t,knobTopPx:wX-CX-10,...r===void 0?{}:{onDragFraction:r}})}),v(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-0.5 pointer-events-none`,children:n})]})}function OX({on:e,busy:t,onToggle:n}){let r=q(),i={transform:e?`translateX(30px)`:`translateX(3px)`};return v(`button`,{type:`button`,"aria-pressed":e,title:e?r(`uiLibrary.tapToggle.turnOff`,`Turn off`):r(`uiLibrary.tapToggle.turnOn`,`Turn on`),disabled:t,onClick:e=>{e.stopPropagation(),n()},className:$(`relative inline-flex h-8 w-16 items-center rounded-full border transition-colors flex-shrink-0`,e?`bg-success/30 border-success/50`:`bg-surface-hover border-border`,t&&`opacity-60 cursor-not-allowed`),children:v(`span`,{className:$(`absolute h-6 w-6 rounded-full transition-all`,e?`bg-success`:`bg-foreground-subtle`),style:i})})}function kX({trpc:e,deviceId:t}){let n=q(),r=Ge(e,t),i=r===null?void 0:r.button;if(i===void 0)return null;let a=()=>{i.press({deviceId:t})};return c(`button`,{type:`button`,"aria-label":n(`uiLibrary.buttonControl.press`,`Press`),title:n(`uiLibrary.buttonControl.press`,`Press`),onClick:e=>{e.stopPropagation(),a()},className:$(`inline-flex h-5 items-center gap-1 rounded px-1.5 text-xs`,`bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`),children:[v(fn,{className:`h-3 w-3`}),v(`span`,{children:n(`uiLibrary.buttonControl.press`,`Press`)})]})}function AX({trpc:e,deviceId:t}){let n=q(),r=Ge(e,t),i=r===null?void 0:r.button;return i===void 0?null:c(`div`,{className:`flex flex-col items-center justify-center gap-4 rounded-lg border border-border bg-surface p-6`,children:[v(`button`,{type:`button`,"aria-label":n(`uiLibrary.buttonControl.pressButton`,`Press button`),onClick:()=>{i.press({deviceId:t})},className:$(`inline-flex h-14 w-14 items-center justify-center rounded-full`,`bg-primary text-primary-foreground hover:bg-primary/90 transition-colors`,`shadow-md`),children:v(fn,{className:`h-6 w-6`})}),v(`span`,{className:`text-sm font-medium text-foreground`,children:n(`uiLibrary.buttonControl.press`,`Press`)})]})}function jX({trpc:e,deviceId:t,features:n,layout:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.cover,slice:e=>e.state.cover});if(o===void 0)return null;let l=(n??[]).includes(`cover-positionable`),u=!s,d=o.position,f=e=>{u||!e||e({})};return c(`div`,{className:$(`inline-flex items-center gap-1`,r===`full`&&`flex-col items-stretch gap-2`),children:[c(`div`,{className:`inline-flex items-center gap-1`,children:[v(MX,{label:i(`uiLibrary.coverPanel.open`,`Open`),busy:u,onClick:()=>f(a?.open),children:v(Ei,{className:`h-3.5 w-3.5`})}),v(MX,{label:i(`uiLibrary.coverPanel.stop`,`Stop`),busy:u,onClick:()=>f(a?.stop),children:v(pi,{className:`h-3 w-3`})}),v(MX,{label:i(`uiLibrary.coverPanel.close`,`Close`),busy:u,onClick:()=>f(a?.close),children:v(de,{className:`h-3.5 w-3.5`})})]}),l&&r===`full`&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:i(`uiLibrary.coverPanel.position`,`Position`)}),v(`input`,{"aria-label":i(`uiLibrary.coverPanel.position`,`Position`),type:`range`,min:0,max:100,step:1,value:d??0,disabled:u,onChange:e=>{u||a?.setPosition({position:Number(e.target.value)})}}),c(`span`,{className:`tabular-nums w-8 text-right`,children:[d??`—`,`%`]})]})]})}function MX({label:e,busy:t,onClick:n,children:r}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),n()},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,t&&`opacity-40 cursor-not-allowed`),children:r})}E();var NX=4e3;function PX(e){if(e!==void 0)return typeof e==`object`&&e&&`lastChangedAt`in e&&typeof e.lastChangedAt==`number`?e.lastChangedAt:e}function FX(e,t){let n=t?.enabled!==!1,r=t?.timeoutMs??NX,[i,a]=C(void 0),o=f(void 0),s=f(void 0),c=f(!1),l=f(void 0),u=_(()=>{l.current!==void 0&&(clearTimeout(l.current),l.current=void 0),o.current=void 0,c.current=!1,s.current=void 0,a(void 0)},[]);b(()=>{if(!n||!c.current)return;let t=PX(e),r=s.current;t!==void 0&&t!==r&&u()}),b(()=>()=>{l.current!==void 0&&clearTimeout(l.current)},[]);let d=_(t=>{if(!n)return;l.current!==void 0&&(clearTimeout(l.current),l.current=void 0);let i=o.current??e;if(i!==void 0){let e={...i,...t};o.current=e,a(e)}s.current=PX(e),c.current=!0,l.current=setTimeout(u,r)},[n,e,u,r]);return n?{display:i===void 0?e:i,applyOptimistic:d,rollback:u}:{display:e,applyOptimistic:()=>{},rollback:()=>{}}}E();function IX(e){return e instanceof Error?e.message:String(e)}function LX({trpc:e,deviceId:t,layout:n,optimistic:r,features:i}){let a=q(),{cap:o,slice:s,available:l}=Zj({trpc:e,deviceId:t,cap:e=>e.lockControl,slice:e=>e.state.lockControl}),{display:u,applyOptimistic:d}=FX(s,{enabled:r??!0}),[f,p]=C(null),[m,h]=C(!1),[g,_]=C(null);if(u===void 0)return null;let y=u.state===`locked`||u.state===`locking`,b=!l||u.state===`jammed`,x=i?.includes(Oa.LockOpen)===!0,S=n===`compact`,w=()=>{d({state:`locking`}),o?.lock({})},T=()=>{d({state:`unlocking`}),o?.unlock({})},E=()=>{o?.open({})},D=()=>{if(!b){if(!y){w();return}if(S){_(null),p(`unlock`);return}T()}},O=()=>{if(!b){if(S){_(null),p(`open`);return}E()}},k=()=>{m||p(null)},A=async()=>{if(!(m||f===null)){_(null),h(!0);try{f===`unlock`?(d({state:`unlocking`}),await o?.unlock({})):await o?.open({}),p(null)}catch(e){_(IX(e))}finally{h(!1)}}},j=y?a(`uiLibrary.lockPanel.unlock`,`Unlock`):a(`uiLibrary.lockPanel.lock`,`Lock`),M=f===`open`?a(`uiLibrary.lockPanel.openDoorTitle`,`Open door?`):a(`uiLibrary.lockPanel.unlockTitle`,`Unlock device?`),N=f===`open`?a(`uiLibrary.lockPanel.openDoorBody`,`This will release the latch and open the door.`):a(`uiLibrary.lockPanel.unlockBody`,`This will unlock the device.`),P=f===`open`?a(`uiLibrary.lockPanel.confirmOpen`,`Confirm open`):a(`uiLibrary.lockPanel.confirmUnlock`,`Confirm unlock`),F=v(f===`open`?pn:yi,{className:`h-4 w-4 text-amber-400`});return c(`div`,{className:$(`inline-flex items-center`,n===`full`?`gap-2`:`gap-1`),children:[c(`button`,{type:`button`,"aria-label":j,title:u.state===`jammed`?a(`uiLibrary.lockPanel.jammed`,`Jammed`):j,disabled:b,onClick:e=>{e.stopPropagation(),D()},className:$(`inline-flex items-center justify-center rounded transition-colors`,n===`full`?`h-7 gap-1.5 px-2 text-xs`:`h-5 w-5`,y?`text-success`:`text-warning`,b&&`opacity-40 cursor-not-allowed`,`hover:bg-surface-hover`),children:[v(y?Cr:yi,{className:`h-3.5 w-3.5`}),n===`full`&&v(`span`,{children:u.state})]}),x&&c(`button`,{type:`button`,"aria-label":a(`uiLibrary.lockPanel.openDoor`,`Open door`),title:a(`uiLibrary.lockPanel.openDoor`,`Open door`),disabled:b,onClick:e=>{e.stopPropagation(),O()},className:$(`inline-flex items-center justify-center rounded transition-colors`,n===`full`?`h-7 gap-1.5 px-2 text-xs`:`h-5 w-5`,`text-foreground-muted`,b&&`opacity-40 cursor-not-allowed`,`hover:bg-surface-hover`),children:[v(pn,{className:`h-3.5 w-3.5`}),n===`full`&&v(`span`,{children:a(`uiLibrary.lockPanel.open`,`Open`)})]}),S&&v(SL,{open:f!==null,onOpenChange:e=>{e||k()},children:c(TL,{width:`sm`,onClick:e=>e.stopPropagation(),children:[c(EL,{children:[c(kL,{className:`flex items-center gap-2`,children:[F,M]}),v(AL,{children:N})]}),g!==null&&v(`div`,{className:`mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10 text-xs text-danger`,children:g}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:m,onClick:()=>k(),children:a(`uiLibrary.lockPanel.cancel`,`Cancel`)}),c(_A,{type:`button`,variant:`danger`,size:`sm`,"aria-label":P,disabled:m,onClick:()=>{A()},children:[m&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),P]})]})]})})]})}E();function RX({trpc:e,deviceId:t,optimistic:n}){let r=q(),{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),{display:s,applyOptimistic:c}=FX(a,{enabled:n??!0}),[l,u]=C(!1);if(s===void 0)return null;let d=s.on===!0,f=l||!o,p={transform:d?`translateX(14px)`:`translateX(2px)`},m=async()=>{if(f||!i)return;let e=!d;c({on:e}),u(!0);try{await i.setState({on:e})}finally{u(!1)}};return v(`button`,{type:`button`,"aria-pressed":d,title:d?r(`uiLibrary.switchPanel.turnOff`,`Turn off`):r(`uiLibrary.switchPanel.turnOn`,`Turn on`),disabled:f,onClick:e=>{e.stopPropagation(),m()},className:$(`relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0`,d?`bg-success/30 border-success/50`:`bg-surface-hover border-border`,f&&`opacity-60`),children:v(`span`,{className:$(`absolute h-3 w-3 rounded-full transition-all`,d?`bg-success`:`bg-foreground-subtle`),style:p})})}function zX({trpc:e,deviceId:t,layout:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.brightness,slice:e=>e.state.brightness}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(l===void 0)return null;let d=!s;return c(`label`,{className:$(`flex items-center gap-2 text-xs text-foreground-subtle`,n===`compact`&&`min-w-[140px]`),children:[v(`input`,{"aria-label":i(`uiLibrary.brightnessPanel.brightness`,`Brightness`),type:`range`,min:0,max:100,step:1,value:l.level,disabled:d,onChange:e=>{let t=Number(e.target.value);u({level:t}),d||a?.setBrightness({level:t})}}),c(`span`,{className:`tabular-nums w-8 text-right`,children:[l.level,`%`]})]})}function BX({trpc:e,deviceId:t,features:n,layout:r,optimistic:i}){let a=q(),{cap:o,slice:s,available:l}=Zj({trpc:e,deviceId:t,cap:e=>e.fanControl,slice:e=>e.state.fanControl}),{display:u,applyOptimistic:d}=FX(s,{enabled:i??!0});if(u===void 0)return null;let f=!l,p=n??[],m=p.includes(`fan-speed`),h=p.includes(`fan-preset`),g=s?.percentageStep!=null&&s.percentageStep>0?s.percentageStep:1;return c(`div`,{className:$(`inline-flex items-center gap-2`,r===`full`&&`flex-col items-stretch`),children:[m&&c(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`input`,{"aria-label":a(`uiLibrary.fanPanel.speed`,`Fan speed`),type:`range`,min:0,max:100,step:g,value:u.speed??0,disabled:f,onChange:e=>{let t=Number(e.target.value),n=Math.min(100,Math.max(0,Math.round(t/g)*g));d({speed:n}),f||o?.setPercentage({speed:n})}}),c(`span`,{className:`tabular-nums w-8 text-right`,children:[u.speed??`—`,`%`]})]}),h&&u.availablePresets.length>0&&v(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:c(`select`,{"aria-label":a(`uiLibrary.fanPanel.preset`,`Fan preset`),value:u.preset,disabled:f,onChange:e=>{let t=e.target.value;!f&&t&&(d({preset:t}),o?.setPreset({preset:t}))},className:`bg-surface border border-border rounded px-1 py-0.5`,children:[v(`option`,{value:``,disabled:!0,children:`—`}),u.availablePresets.map(e=>v(`option`,{value:e,children:e},e))]})})]})}function VX(e){return typeof e==`number`&&Number.isFinite(e)&&e>0?e:1}var HX=2,UX=3;function WX(e){if(!Number.isFinite(e))return 0;for(let t=0;t<UX;t+=1)if(Math.abs(e*10**t-Math.round(e*10**t))<1e-9)return t;return UX}function GX(e){let t=VX(e.tempStep),n=[e.minTemp,e.maxTemp].filter(e=>typeof e==`number`&&Number.isFinite(e)),r=n.length===0?HX:Math.max(...n.map(e=>String(Math.trunc(Math.abs(e))).length)),i=+!!n.some(e=>e<0),a=Math.max(WX(t),...n.map(WX));return i+r+(a>0?1+a:0)}var KX={1:`min-w-[1ch]`,2:`min-w-[2ch]`,3:`min-w-[3ch]`,4:`min-w-[4ch]`,5:`min-w-[5ch]`,6:`min-w-[6ch]`,7:`min-w-[7ch]`,8:`min-w-[8ch]`};function qX(e){return`${KX[Math.min(Math.max(GX(e),1),8)]} text-center`}function JX(e,t,n){let r=e+t*VX(n.tempStep),i=n.minTemp,a=n.maxTemp;return typeof i==`number`&&Number.isFinite(i)&&(r=Math.max(r,i)),typeof a==`number`&&Number.isFinite(a)&&(r=Math.min(r,a)),r}var YX={heat:`border-amber-400 bg-amber-50 dark:bg-amber-950`,cool:`border-blue-400 bg-blue-50 dark:bg-blue-950`,auto:`border-purple-400 bg-purple-50 dark:bg-purple-950`,heat_cool:`border-fuchsia-400 bg-fuchsia-50 dark:bg-fuchsia-950`,fan_only:`border-slate-400 bg-slate-50 dark:bg-slate-950`,dry:`border-cyan-400 bg-cyan-50 dark:bg-cyan-950`,off:`border-zinc-300 bg-zinc-50 dark:bg-zinc-900`},XX={heat:`text-amber-600 dark:text-amber-400`,cool:`text-blue-600 dark:text-blue-400`,auto:`text-purple-600 dark:text-purple-400`,heat_cool:`text-fuchsia-600 dark:text-fuchsia-400`,fan_only:`text-slate-600 dark:text-slate-400`,dry:`text-cyan-600 dark:text-cyan-400`,off:`text-foreground`},ZX={heat:`bg-amber-400 text-amber-950`,cool:`bg-blue-400 text-blue-950`,auto:`bg-purple-400 text-purple-950`,heat_cool:`bg-fuchsia-400 text-fuchsia-950`,fan_only:`bg-slate-400 text-slate-950`,dry:`bg-cyan-400 text-cyan-950`,off:`bg-zinc-300 text-zinc-700`};function QX({trpc:e,deviceId:t,features:n,layout:r,optimistic:i}){let a=q(),{cap:o,slice:s,available:l}=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl}),{display:u,applyOptimistic:d}=FX(s,{enabled:i??!0});if(o===void 0||u===void 0)return null;let f=!l;if(r===`compact`)return c(`div`,{"data-mode":u.mode,className:`inline-flex items-center gap-1`,children:[v(`span`,{className:$(`text-xs tabular-nums font-medium`,XX[u.mode]),children:u.target===null?u.currentTemp===null?null:c(`span`,{className:`text-foreground-subtle`,children:[u.currentTemp,`°`]}):c(P,{children:[u.target,`°`,u.currentTemp!==null&&c(`span`,{className:`text-foreground-subtle font-normal`,children:[` `,`(`,u.currentTemp,`°)`]})]})}),u.target!==null&&c(P,{children:[v(`button`,{type:`button`,"aria-label":a(`uiLibrary.climatePanel.decreaseTarget`,`Decrease target`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.target!==null){let e=JX(u.target,-1,u);d({target:e}),o.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,f&&`opacity-40 cursor-not-allowed`),children:`−`}),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.climatePanel.increaseTarget`,`Increase target`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.target!==null){let e=JX(u.target,1,u);d({target:e}),o.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,f&&`opacity-40 cursor-not-allowed`),children:`+`})]}),v(`select`,{"aria-label":a(`uiLibrary.climatePanel.mode`,`Mode`),value:u.mode,disabled:f,onChange:e=>{e.stopPropagation();let t=e.target.value;f||(d({mode:t}),o.setMode({mode:t}))},className:$(`bg-transparent px-0.5 text-xs text-foreground-subtle hover:text-foreground cursor-pointer`,f&&`opacity-40 cursor-not-allowed`),children:u.availableModes.map(e=>v(`option`,{value:e,children:e},e))})]});let p=u.mode===`heat_cool`||u.targetLow!==null&&u.targetHigh!==null,m=!p&&u.target!==null;return c(`div`,{"data-mode":u.mode,className:$(`inline-flex items-center gap-2 rounded border px-2 py-1 transition-colors`,YX[u.mode],`flex-col items-stretch gap-3`),children:[c(`div`,{className:`inline-flex items-center gap-1 text-xs tabular-nums`,children:[u.currentTemp!==null&&c(`span`,{className:`text-foreground-subtle`,children:[u.currentTemp,`°`]}),m&&c(P,{children:[v(`span`,{className:`text-foreground-subtle`,children:`→`}),c(`span`,{className:`font-medium`,children:[u.target,`°`]}),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.climatePanel.decreaseTarget`,`Decrease target`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.target!==null){let e=JX(u.target,-1,u);d({target:e}),o.setTarget({target:e})}},className:$(`inline-flex h-4 w-4 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,f&&`opacity-40 cursor-not-allowed`),children:`−`}),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.climatePanel.increaseTarget`,`Increase target`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.target!==null){let e=JX(u.target,1,u);d({target:e}),o.setTarget({target:e})}},className:$(`inline-flex h-4 w-4 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,f&&`opacity-40 cursor-not-allowed`),children:`+`})]})]}),v(`div`,{className:`inline-flex items-center gap-0.5 rounded bg-surface-subtle p-0.5`,children:u.availableModes.map(e=>v(`button`,{type:`button`,"aria-label":e,disabled:f,onClick:t=>{t.stopPropagation(),f||(d({mode:e}),o.setMode({mode:e}))},className:$(`rounded px-1.5 py-0.5 text-xs transition-colors`,e===u.mode?ZX[e]:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,f&&`opacity-40 cursor-not-allowed`),children:e},e))}),p&&c(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[c(`label`,{className:`flex items-center gap-1`,children:[v(`span`,{children:a(`uiLibrary.climatePanel.low`,`Low`)}),v(`input`,{"aria-label":a(`uiLibrary.climatePanel.targetLow`,`Target low`),type:`number`,step:.5,value:u.targetLow??``,disabled:f,onChange:e=>{if(!f){let t=Number(e.target.value),n=u.targetHigh??t;d({targetLow:t}),o.setTargetRange({targetLow:t,targetHigh:n})}},className:`w-14 rounded border border-border bg-surface px-1 py-0.5 tabular-nums`})]}),c(`label`,{className:`flex items-center gap-1`,children:[v(`span`,{children:a(`uiLibrary.climatePanel.high`,`High`)}),v(`input`,{"aria-label":a(`uiLibrary.climatePanel.targetHigh`,`Target high`),type:`number`,step:.5,value:u.targetHigh??``,disabled:f,onChange:e=>{if(!f){let t=Number(e.target.value),n=u.targetLow??t;d({targetHigh:t}),o.setTargetRange({targetLow:n,targetHigh:t})}},className:`w-14 rounded border border-border bg-surface px-1 py-0.5 tabular-nums`})]})]}),u.availableFanModes.length>0&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.climatePanel.fan`,`Fan`)}),c(`select`,{"aria-label":a(`uiLibrary.climatePanel.fanMode`,`Fan mode`),value:u.fanMode,disabled:f,onChange:e=>{let t=e.target.value;!f&&t&&(d({fanMode:t}),o.setFanMode({fanMode:t}))},className:`rounded border border-border bg-surface px-1 py-0.5`,children:[v(`option`,{value:``,disabled:!0,children:`—`}),u.availableFanModes.map(e=>v(`option`,{value:e,children:e},e))]})]}),u.availablePresets.length>0&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.climatePanel.preset`,`Preset`)}),c(`select`,{"aria-label":a(`uiLibrary.climatePanel.preset`,`Preset`),value:u.preset,disabled:f,onChange:e=>{let t=e.target.value;!f&&t&&(d({preset:t}),o.setPreset({preset:t}))},className:`rounded border border-border bg-surface px-1 py-0.5`,children:[v(`option`,{value:``,disabled:!0,children:`—`}),u.availablePresets.map(e=>v(`option`,{value:e,children:e},e))]})]}),u.targetHumidity!==null&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.climatePanel.humidity`,`Humidity`)}),v(`input`,{"aria-label":a(`uiLibrary.climatePanel.targetHumidity`,`Target humidity`),type:`range`,min:0,max:100,step:1,value:u.targetHumidity,disabled:f,onChange:e=>{let t=Number(e.target.value);d({targetHumidity:t}),f||o.setTargetHumidity({targetHumidity:t})}}),c(`span`,{className:`tabular-nums w-8 text-right`,children:[u.targetHumidity,`%`]})]})]})}var $X={playing:`border-green-400 bg-green-50 dark:bg-green-950`,paused:`border-amber-400 bg-amber-50 dark:bg-amber-950`,buffering:`border-blue-400 bg-blue-50 dark:bg-blue-950`,on:`border-slate-400 bg-slate-50 dark:bg-slate-950`,idle:`border-slate-400 bg-slate-50 dark:bg-slate-950`,off:`border-zinc-300 bg-zinc-50 dark:bg-zinc-900`,standby:`border-zinc-300 bg-zinc-50 dark:bg-zinc-900`},eZ={playing:`bg-green-500`,paused:`bg-amber-400`,buffering:`bg-blue-400`,on:`bg-slate-400`,idle:`bg-slate-400`,off:`bg-zinc-300`,standby:`bg-zinc-300`},tZ=[`off`,`all`,`one`];function nZ(e){return tZ.includes(e)}function rZ(e,t){switch(t){case`off`:return e(`uiLibrary.mediaPlayerPanel.repeatOff`,`Off`);case`all`:return e(`uiLibrary.mediaPlayerPanel.repeatAll`,`All`);case`one`:return e(`uiLibrary.mediaPlayerPanel.repeatOne`,`One`)}}function iZ(e){return e===`playing`||e===`buffering`?`pause`:`play`}function aZ({trpc:e,deviceId:t,features:n,layout:r,optimistic:i}){let a=q(),{cap:o,slice:s,available:l}=Zj({trpc:e,deviceId:t,cap:e=>e.mediaPlayer,slice:e=>e.state.mediaPlayer}),{display:u,applyOptimistic:d}=FX(s,{enabled:i??!0});if(u===void 0)return null;let f=!l,p=iZ(u.state);return c(`div`,{"data-state":u.state,className:$(`inline-flex items-center gap-2 rounded border px-2 py-1 transition-colors`,$X[u.state],r===`full`&&`flex-col items-stretch gap-3`),children:[c(`div`,{className:`inline-flex items-center gap-2`,children:[v(`span`,{role:`status`,"aria-label":u.state,className:$(`inline-block h-2 w-2 rounded-full flex-shrink-0`,eZ[u.state])}),v(`button`,{type:`button`,"aria-label":p===`play`?a(`uiLibrary.mediaPlayerPanel.play`,`Play`):a(`uiLibrary.mediaPlayerPanel.pause`,`Pause`),disabled:f,onClick:e=>{e.stopPropagation(),!f&&(p===`play`?(d({state:`playing`}),o?.play({})):(d({state:`paused`}),o?.pause({})))},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,f&&`opacity-40 cursor-not-allowed`),children:p===`play`?`▶`:`⏸`})]}),r===`full`&&c(P,{children:[c(`div`,{className:`inline-flex items-center gap-1`,children:[v(`button`,{type:`button`,"aria-label":a(`uiLibrary.mediaPlayerPanel.previous`,`Previous`),disabled:f,onClick:e=>{e.stopPropagation(),f||o?.previous({})},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,f&&`opacity-40 cursor-not-allowed`),children:`⏮`}),v(`button`,{type:`button`,"aria-label":a(`uiLibrary.mediaPlayerPanel.next`,`Next`),disabled:f,onClick:e=>{e.stopPropagation(),f||o?.next({})},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,f&&`opacity-40 cursor-not-allowed`),children:`⏭`})]}),u.volumeLevel!==null&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.mediaPlayerPanel.vol`,`Vol`)}),v(`input`,{"aria-label":a(`uiLibrary.mediaPlayerPanel.volume`,`Volume`),type:`range`,min:0,max:100,step:1,value:u.volumeLevel,disabled:f,onChange:e=>{let t=Number(e.target.value);d({volumeLevel:t}),f||o?.setVolume({volumeLevel:t})}}),c(`span`,{className:`tabular-nums w-8 text-right`,children:[u.volumeLevel,`%`]})]}),u.isMuted!==null&&v(`button`,{type:`button`,"aria-label":u.isMuted?a(`uiLibrary.mediaPlayerPanel.unmute`,`Unmute`):a(`uiLibrary.mediaPlayerPanel.mute`,`Mute`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.isMuted!==null){let e=!u.isMuted;d({isMuted:e}),o?.setMute({muted:e})}},className:$(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-colors`,u.isMuted?`bg-amber-400 text-amber-950`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,f&&`opacity-40 cursor-not-allowed`),children:u.isMuted?`🔇`:`🔊`}),u.availableSources.length>0&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.mediaPlayerPanel.source`,`Source`)}),c(`select`,{"aria-label":a(`uiLibrary.mediaPlayerPanel.source`,`Source`),value:u.source,disabled:f,onChange:e=>{let t=e.target.value;!f&&t&&(d({source:t}),o?.selectSource({source:t}))},className:`rounded border border-border bg-surface px-1 py-0.5`,children:[v(`option`,{value:``,disabled:!0,children:`—`}),u.availableSources.map(e=>v(`option`,{value:e,children:e},e))]})]}),u.shuffle!==null&&c(`button`,{type:`button`,"aria-label":a(`uiLibrary.mediaPlayerPanel.shuffle`,`Shuffle`),disabled:f,onClick:e=>{if(e.stopPropagation(),!f&&u.shuffle!==null){let e=!u.shuffle;d({shuffle:e}),o?.setShuffle({shuffle:e})}},className:$(`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-xs transition-colors`,u.shuffle?`bg-green-400 text-green-950`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,f&&`opacity-40 cursor-not-allowed`),children:[`⇌ `,a(`uiLibrary.mediaPlayerPanel.shuffle`,`Shuffle`)]}),u.repeat!==null&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:a(`uiLibrary.mediaPlayerPanel.repeat`,`Repeat`)}),v(`select`,{"aria-label":a(`uiLibrary.mediaPlayerPanel.repeat`,`Repeat`),value:u.repeat,disabled:f,onChange:e=>{let t=e.target.value;!f&&nZ(t)&&(d({repeat:t}),o?.setRepeat({repeat:t}))},className:`rounded border border-border bg-surface px-1 py-0.5`,children:tZ.map(e=>v(`option`,{value:e,children:rZ(a,e)},e))})]})]})]})}function oZ(e,t){return t===void 0?Number.isInteger(e)?String(e):e.toFixed(1):e.toFixed(t)}function sZ(e){if(e!==void 0)return ua(e)??e}function cZ(e){if(e.quantity!==void 0){if(e.quantity===`device`){let t=e.deviceQuantity;return t===void 0||t===`device`?void 0:t}return e.quantity}}function lZ(e){let t=e.capName===void 0?void 0:e.display?.perCap?.[e.capName],n=t?.precision??e.display?.precision??e.roleDefault?.precision??e.declarationPrecision,r=cZ(e),i=e.preference??`metric`,a=r===void 0?void 0:Eee(r),o=r===void 0?void 0:yee(r,i),s=sZ(t?.unit??e.display?.unit??e.roleDefault?.unit),c=s!==void 0&&a!==void 0&&s!==a&&Ba(a,s),l=c?s:o??``,u=r===`duration`||r===`information`||r===`duration-ms`,d=e=>u||a===void 0||l.length===0||l===a?e:Wi(e,a,l)??e;return{unit:l,precision:n,toDisplayValue:d,fromDisplayValue:e=>u||a===void 0||l.length===0||l===a?e:Wi(e,l,a)??e,format:e=>{if(r!==void 0&&!c){let t=Va({value:e,quantity:r,preference:i,precision:n});return{text:t.text,unit:t.unit}}return{text:oZ(d(e),n),unit:l}}}}var uZ=/^(\d{4})-(\d{2})-(\d{2})/,dZ=/^(\d{2}):(\d{2})(?::(\d{2}))?$/;function fZ(e,t){let n=uZ.exec(e);if(n===null)return e;let r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=new Date(r,i-1,a);if(Number.isNaN(o.getTime()))return e;try{return o.toLocaleDateString(t)}catch{return e}}function pZ(e,t){let n=dZ.exec(e);if(n===null)return e;let r=new Date(1970,0,1,Number(n[1]),Number(n[2]),n[3]===void 0?0:Number(n[3]));if(Number.isNaN(r.getTime()))return e;try{return r.toLocaleTimeString(t,{hour:`2-digit`,minute:`2-digit`})}catch{return e}}function mZ(e,t){let n=e.includes(`T`)?e:e.replace(` `,`T`),r=new Date(n);if(Number.isNaN(r.getTime()))return e;try{return r.toLocaleString(t,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function hZ(e,t,n){return e===``?e:t===`date`?fZ(e,n):t===`time`?pZ(e,n):mZ(e,n)}E();function gZ(e){return e.slice(0,10)}function _Z(e){return e.slice(0,5)}function vZ(e,t){return e===`date`?{type:`date`,value:gZ(t)}:e===`time`?{type:`time`,value:_Z(t)}:{type:`datetime-local`,value:yZ(t)}}function yZ(e){return(e.includes(`T`)?e:e.replace(` `,`T`)).slice(0,16)}function bZ({value:e,busy:t,onCommit:n,unit:r,min:i,max:a,step:o,precision:s}){let l=q(),[u,d]=C(oZ(e,s)),f=Number(u),p=u!==``&&!Number.isNaN(f),m=o??1,h=e=>{let t=e;return i!==void 0&&(t=Math.max(i,t)),a!==void 0&&(t=Math.min(a,t)),t},g=()=>{!t&&p&&n(h(f))};return c(`div`,{className:`inline-flex items-center gap-1`,children:[v(`button`,{type:`button`,"aria-label":l(`uiLibrary.controlPanel.decrement`,`Decrement`),disabled:t,onClick:r=>{if(r.stopPropagation(),!t){let t=h(e-m);d(oZ(t,s)),n(t)}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded border border-border bg-surface text-xs transition-colors hover:bg-surface-hover`,t&&`opacity-40 cursor-not-allowed`),children:`−`}),v(`input`,{"aria-label":l(`uiLibrary.controlPanel.numeric`,`Numeric value`),type:`number`,disabled:t,value:u,onChange:e=>{d(e.target.value);let r=Number(e.target.value);e.target.value!==``&&!Number.isNaN(r)&&(t||n(h(r)))},onBlur:g,onKeyDown:e=>{e.key===`Enter`&&g()},className:$(`w-16 rounded border border-border bg-surface px-1 py-0.5 text-xs tabular-nums text-center`,t&&`opacity-40 cursor-not-allowed`)}),r!==void 0&&v(`span`,{className:`text-foreground-subtle text-xs`,children:r}),v(`button`,{type:`button`,"aria-label":l(`uiLibrary.controlPanel.increment`,`Increment`),disabled:t,onClick:r=>{if(r.stopPropagation(),!t){let t=h(e+m);d(oZ(t,s)),n(t)}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded border border-border bg-surface text-xs transition-colors hover:bg-surface-hover`,t&&`opacity-40 cursor-not-allowed`),children:`+`})]})}function xZ({value:e,busy:t,onCommit:n}){let[r,i]=C(e);return v(`input`,{type:`text`,disabled:t,value:r,onChange:e=>i(e.target.value),onBlur:()=>{t||n(r)},onKeyDown:e=>{e.key===`Enter`&&!t&&n(r)},className:$(`rounded border border-border bg-surface px-2 py-0.5 text-xs`,t&&`opacity-40 cursor-not-allowed`)})}function SZ({slice:e,busy:t,setValueFn:n,layout:r,quantity:i,display:a,dateTimeShape:o}){let s=q();switch(e.kind){case`numeric`:{let r=typeof e.value==`number`?e.value:Number(e.value),o=i===void 0?void 0:lZ({quantity:i,display:a,capName:`control`}),s=o?.toDisplayValue??(e=>e),c=o?.fromDisplayValue??(e=>e),l=o!==void 0&&o.unit.length>0?o.unit:void 0;return v(bZ,{value:s(r),busy:t,onCommit:e=>{n({control:{kind:`numeric`,value:c(e)}})},unit:l,min:e.min===void 0?void 0:s(e.min),max:e.max===void 0?void 0:s(e.max),step:e.step===void 0?void 0:s(e.step),precision:o?.precision})}case`select`:{let r=String(e.value);return v(`select`,{"aria-label":s(`uiLibrary.controlPanel.value`,`Control value`),disabled:t,value:r,onChange:e=>{e.stopPropagation(),t||n({control:{kind:`select`,value:e.target.value}})},className:$(`w-full max-w-full min-w-0 truncate rounded bg-transparent px-0.5 py-0.5 text-xs`,t&&`opacity-40 cursor-not-allowed`),children:e.options.map(e=>v(`option`,{value:e,children:e},e))})}case`text`:return v(xZ,{value:String(e.value),busy:t,onCommit:e=>{n({control:{kind:`text`,value:e}})}});case`datetime`:{let i=String(e.value),a=o??`datetime`;if(r===`compact`)return i===``?v(`span`,{"aria-label":s(`uiLibrary.controlPanel.value`,`Control value`),className:`text-xs text-foreground-subtle`,children:`—`}):v(`span`,{"aria-label":s(`uiLibrary.controlPanel.value`,`Control value`),className:`text-xs text-foreground`,children:hZ(i,a)});let c=vZ(a,i),l=c.type,u=c.value;return v(`input`,{type:l,"aria-label":s(`uiLibrary.controlPanel.value`,`Control value`),disabled:t,value:u,onChange:e=>{e.stopPropagation(),t||n({control:{kind:`datetime`,value:e.target.value}})},className:$(`rounded border border-border bg-surface px-1 py-0.5 text-xs`,t&&`opacity-40 cursor-not-allowed`)})}default:return null}}function CZ({trpc:e,deviceId:t,features:n,layout:r,optimistic:i}){let a=bi()?.getDeviceInfo(t)??null,{cap:o,slice:s,available:c}=Zj({trpc:e,deviceId:t,cap:e=>e.control,slice:e=>e.state.control}),{display:l,applyOptimistic:u}=FX(s,{enabled:i??!0});if(l===void 0)return null;let d=!c,f=a?.sourceInfo?.quantity,p=Gi(f)&&f!==`device`&&f!==`none`?f:void 0;return v(`div`,{"data-kind":l.kind,className:`inline-flex min-w-0 max-w-full items-center gap-1 rounded border border-border px-2 py-1 transition-colors`,children:v(SZ,{slice:l,busy:d,setValueFn:e=>{!d&&o&&(u({value:e.control.value}),o.setValue(e))},layout:r,quantity:p,display:a?.display,dateTimeShape:a?.sourceInfo?.dateTimeShape})})}var wZ=[`cover`,`lock-control`,`switch`,`brightness`,`fan-control`,`climate-control`,`media-player`,`control`,`pet-feeder`,`dishwasher`];E(),Do();var TZ=240,EZ=6;function DZ({icon:e,title:t,children:n}){let r=f(null),i=f(null),[a,o]=C(null),s=a!==null,l=()=>o(null),u=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(TZ,window.innerWidth-16),i=Math.max(8,Math.min(t.right-n,window.innerWidth-n-8));o({top:t.bottom+EZ,left:i,width:n})};return b(()=>{if(!s)return;let e=e=>{let t=e.target;i.current?.contains(t)||r.current?.contains(t)||l()},t=e=>{e.key===`Escape`&&l()};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[s]),c(P,{children:[v(`button`,{ref:r,type:`button`,title:t,"aria-label":t,"aria-haspopup":`dialog`,"aria-expanded":s,onClick:e=>{e.stopPropagation(),s?l():u()},className:$(`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`,s&&`bg-surface-hover text-foreground`),children:v(e,{className:`h-3 w-3`})}),a&&Oo(v(`div`,{ref:i,style:{position:`fixed`,top:a.top,left:a.left,width:a.width},className:`z-[9999] rounded-lg border border-border bg-surface shadow-lg shadow-black/30 p-2`,onClick:e=>e.stopPropagation(),children:n}),document.body)]})}var OZ={kind:`binary`,field:`on`,onLabel:`Low`,offLabel:`Normal`,getSliceHandle:e=>e.binary};function kZ(e){return e===`battery-sensor`}function AZ(e,t){if(!MZ(e))return!1;let n=e[t];if(typeof n!=`number`)return!1;let r=e.lastFetchedAt;return!(n===0&&r===0)}var jZ={"temperature-sensor":{kind:`numeric`,field:`temperature`,quantity:`temperature`,getSliceHandle:e=>e.temperatureSensor},"humidity-sensor":{kind:`numeric`,field:`humidity`,quantity:`humidity`,getSliceHandle:e=>e.humiditySensor},"ambient-light-sensor":{kind:`numeric`,field:`illuminance`,quantity:`illuminance`,getSliceHandle:e=>e.ambientLightSensor},"pressure-sensor":{kind:`numeric`,field:`pressure`,quantity:`pressure`,getSliceHandle:e=>e.pressureSensor},"numeric-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"wind-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"rain-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"uv-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"solar-radiation-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"soil-moisture-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"power-sensor":{kind:`numeric`,field:`power`,quantity:`power`,getSliceHandle:e=>e.powerMeter},"energy-sensor":{kind:`numeric`,field:`energy`,quantity:`energy`,getSliceHandle:e=>e.powerMeter},"voltage-sensor":{kind:`numeric`,field:`voltage`,quantity:`voltage`,getSliceHandle:e=>e.powerMeter},"current-sensor":{kind:`numeric`,field:`current`,quantity:`current`,getSliceHandle:e=>e.powerMeter},"battery-sensor":{kind:`numeric`,field:`value`,quantity:`percentage`,getSliceHandle:e=>e.numericSensor},"generic-sensor":{kind:`numeric`,field:`value`,quantity:`device`,getSliceHandle:e=>e.numericSensor},"motion-sensor":{kind:`binary`,field:`detected`,onLabel:`Detected`,offLabel:`Clear`,getSliceHandle:e=>e.motion},"pir-sensor":{kind:`binary`,field:`detected`,onLabel:`Detected`,offLabel:`Clear`,getSliceHandle:e=>e.motion},"contact-sensor":{kind:`binary`,field:`entryOpen`,onLabel:`Open`,offLabel:`Closed`,getSliceHandle:e=>e.contact},"smoke-sensor":{kind:`binary`,field:`detected`,onLabel:`Smoke!`,offLabel:`Clear`,getSliceHandle:e=>e.smoke},"leak-sensor":{kind:`binary`,field:`flooded`,onLabel:`Leak!`,offLabel:`Dry`,getSliceHandle:e=>e.flood},"co-sensor":{kind:`binary`,field:`detected`,onLabel:`CO!`,offLabel:`Clear`,getSliceHandle:e=>e.carbonMonoxide},"binary-sensor":{kind:`binary`,field:`on`,onLabel:`On`,offLabel:`Off`,getSliceHandle:e=>e.binary},presence:{kind:`presence`,getSliceHandle:e=>e.presence},"enum-sensor":{kind:`string`,getSliceHandle:e=>e.enumSensor},"datetime-sensor":{kind:`datetime`,format:`datetime`,getSliceHandle:e=>e.enumSensor}};function MZ(e){return typeof e==`object`&&!!e}function NZ(e){return typeof e==`object`&&!!e}function PZ(e){return typeof e==`object`&&!!e&&`state`in e&&typeof e.state==`string`}function FZ(e){return typeof e==`object`&&!!e&&`value`in e&&typeof e.value==`string`}function IZ(e){if(typeof e!=`object`||!e)return;let t=e.format;if(t===`date`||t===`time`||t===`datetime`)return t}function LZ(e,t){return e===`home`?t(`uiLibrary.sensor.presence.home`,`Home`):e===`not_home`?t(`uiLibrary.sensor.presence.away`,`Away`):e.charAt(0).toUpperCase()+e.slice(1)}function RZ({trpc:e,device:t}){let n=q(),r=t.role==null?void 0:jZ[t.role],i=kZ(t.role),{data:a}=Gp({},{staleTime:6e4}),o=Ge(e,t.id),s=Be(o!==null&&r!==void 0?r.getSliceHandle(o.state):void 0),l=Be(o!==null&&r?.kind===`numeric`?o.state.enumSensor:void 0),u=Be(o!==null&&i?o.state.binary:void 0),d=i&&r?.kind===`numeric`&&!AZ(s,r.field)&&u!==void 0,f=d?OZ:r,p=d?u:s;if(f===void 0||p===void 0)return null;if(f.kind===`numeric`){if(!MZ(p))return null;let e=p[f.field];if(typeof e!=`number`)return null;let n=p.lastFetchedAt,r=e===0&&n===0;if(r&&FZ(l)&&l.value!==``)return v(`span`,{className:$(`inline-flex items-baseline text-xs text-foreground`),children:l.value});if(r)return null;let i=t.sourceInfo?.quantity,o=lZ({display:t.display,capName:t.role===`numeric-sensor`?`numeric-sensor`:void 0,roleDefault:t.role==null?void 0:a?.defaults[t.role],quantity:f.quantity??`device`,deviceQuantity:i===`device`?void 0:i}).format(e),s=o.unit,u=o.text;return c(`span`,{className:$(`inline-flex items-baseline gap-0.5 tabular-nums text-xs text-foreground`),children:[v(`span`,{children:u}),s&&v(`span`,{className:`text-foreground-subtle`,children:s})]})}if(f.kind===`binary`){if(!NZ(p))return null;let e=!!p[f.field],t=e?f.onLabel:f.offLabel;return v(`span`,{className:$(`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium`,e?`bg-warning/15 text-warning`:`bg-surface-subtle text-foreground-subtle`),children:t})}if(f.kind===`string`)return!FZ(p)||p.value===``?null:v(`span`,{className:$(`inline-flex items-baseline text-xs text-foreground`),children:p.value});if(f.kind===`datetime`){if(!FZ(p)||p.value===``)return null;let e=t.sourceInfo?.dateTimeShape??IZ(p)??f.format,n=hZ(p.value,e);return v(`span`,{className:$(`inline-flex items-baseline text-xs text-foreground`),children:n})}if(!PZ(p))return null;let m=LZ(p.state,n);return v(`span`,{className:$(`inline-flex items-center rounded px-1.5 py-0.5 text-xs font-medium`,p.state===`home`?`bg-success/15 text-success`:`bg-surface-subtle text-foreground-subtle`),children:m})}function zZ(e){switch(e){case`opening`:return{up:`accent`,stop:`neutral`,down:`neutral`};case`closing`:return{up:`neutral`,stop:`neutral`,down:`accent`};case`open`:return{up:`filled`,stop:`neutral`,down:`neutral`};case`closed`:return{up:`neutral`,stop:`neutral`,down:`filled`};default:return{up:`neutral`,stop:`neutral`,down:`neutral`}}}function BZ(e){switch(e){case`accent`:return`bg-primary text-primary-foreground`;case`filled`:return`bg-primary/15 text-primary`;case`neutral`:return``}}function VZ({label:e,busy:t,variant:n,onClick:r,children:i}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),r()},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,BZ(n),t&&`opacity-40 cursor-not-allowed`),children:i})}function HZ({trpc:e,deviceId:t,optimistic:n}){let r=q(),{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.cover,slice:e=>e.state.cover}),{display:s,applyOptimistic:l}=FX(a,{enabled:n??!0});if(i===void 0)return null;let u=zZ(s?.state),d=!o,f=(e,t)=>{d||!e||(t!==void 0&&l(t),e({}))};return c(`div`,{className:`inline-flex items-center gap-1`,children:[v(VZ,{label:r(`uiLibrary.coverInline.open`,`Open`),busy:d,variant:u.up,onClick:()=>f(i?.open,{state:`opening`}),children:v(Ei,{className:`h-3.5 w-3.5`})}),v(VZ,{label:r(`uiLibrary.coverInline.stop`,`Stop`),busy:d,variant:u.stop,onClick:()=>f(i?.stop,{state:`stopped`}),children:v(pi,{className:`h-3 w-3`})}),v(VZ,{label:r(`uiLibrary.coverInline.close`,`Close`),busy:d,variant:u.down,onClick:()=>f(i?.close,{state:`closing`}),children:v(de,{className:`h-3.5 w-3.5`})}),s!==void 0&&s.position!==null&&c(`span`,{className:`tabular-nums text-xs text-foreground-subtle ml-1`,children:[s.position,`%`]})]})}E();function UZ({label:e,busy:t,variant:n,onClick:r,children:i}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),r()},className:$(`inline-flex h-10 w-10 items-center justify-center rounded-md text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,n===`accent`&&`bg-primary text-primary-foreground hover:bg-primary/90`,n===`filled`&&`bg-primary/15 text-primary`,t&&`opacity-40 cursor-not-allowed`),children:i})}function WZ(){return c(P,{children:[v(`div`,{"aria-hidden":`true`,className:`absolute inset-y-0 left-1/2 w-px -translate-x-px bg-white/60`}),v(`div`,{"aria-hidden":`true`,className:`absolute inset-x-0 top-1/2 h-px -translate-y-px bg-white/60`})]})}function GZ({position:e,interactive:t,onSetPosition:n}){let r=q(),i=(1-e/100)*100,a=f(null),o=f(!1),s=f(null),l=t=>{let n=a.current;if(n===null)return e;let r=n.getBoundingClientRect();if(r.height<=0)return e;let i=(t-r.top)/r.height,o=Math.round(100-i*100);return Math.min(100,Math.max(0,o))},u=e=>{if(n===void 0)return;let t=l(e);s.current!==t&&(s.current=t,n(t))},d=e=>{t&&(e.stopPropagation(),e.preventDefault(),o.current=!0,s.current=null,e.currentTarget.setPointerCapture(e.pointerId),u(e.clientY))},p=e=>{!t||!o.current||(e.stopPropagation(),u(e.clientY))},m=e=>{!t||!o.current||(e.stopPropagation(),o.current=!1,s.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return c(`div`,{ref:a,"data-testid":`cover-window`,...t?{"aria-label":r(`uiLibrary.coverHeroCard.dragToSet`,`Drag to set position`),role:`slider`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e}:{"aria-hidden":`true`},onPointerDown:t?d:void 0,onPointerMove:t?p:void 0,onPointerUp:t?m:void 0,onPointerCancel:t?m:void 0,className:$(`relative w-28 h-36 rounded border-2 border-amber-700/60 bg-gradient-to-b from-sky-200 to-sky-50 overflow-hidden flex-shrink-0`,t&&`cursor-ns-resize touch-none select-none`),style:{boxShadow:`inset 0 0 0 2px rgba(255,255,255,.5)`},children:[v(WZ,{}),v(`div`,{className:`absolute inset-x-0 top-0 transition-all duration-200`,style:{height:`${i}%`,background:`repeating-linear-gradient(#c9cdd2, #c9cdd2 6px, #b7bcc2 6px, #b7bcc2 8px)`,borderBottom:i>0?`1px solid #9aa`:`none`}}),c(`div`,{"data-testid":`cover-lever`,className:$(`absolute inset-x-0 h-4 flex items-center justify-center gap-1 z-10 transition-all duration-200`,t&&`cursor-grab active:cursor-grabbing`),style:{top:`calc(${i}% - 8px)`},children:[v(`div`,{className:`absolute -inset-x-1.5 h-full rounded-lg bg-slate-600 shadow-md`}),v(`span`,{className:`h-1 w-1 rounded-full bg-white/70 relative z-10`,"aria-hidden":`true`}),v(`span`,{className:`h-1 w-1 rounded-full bg-white/70 relative z-10`,"aria-hidden":`true`}),v(`span`,{className:`h-1 w-1 rounded-full bg-white/70 relative z-10`,"aria-hidden":`true`}),c(`span`,{"data-testid":`cover-position-pct`,className:`absolute left-full ml-2 text-xs font-semibold text-foreground tabular-nums whitespace-nowrap`,children:[e,`%`]})]})]})}function cae({isOpen:e}){return c(`div`,{"data-testid":`cover-window`,"aria-hidden":`true`,className:`relative w-28 h-36 rounded border-2 border-amber-700/60 bg-gradient-to-b from-sky-200 to-sky-50 overflow-hidden flex-shrink-0`,style:{boxShadow:`inset 0 0 0 2px rgba(255,255,255,.5)`},children:[v(WZ,{}),!e&&v(`div`,{className:`absolute inset-0`,style:{background:`repeating-linear-gradient(#c9cdd2, #c9cdd2 6px, #b7bcc2 6px, #b7bcc2 8px)`}})]})}function KZ({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.cover,slice:e=>e.state.cover}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(a===void 0)return null;let d=!s,f=(n??[]).includes(Oa.CoverPositionable),p=(n??[]).includes(Oa.CoverTilt),m=zZ(l?.state),h=l?.position??null,g=h!==null,_=l?.state===`open`||l?.state===`opening`,y=(e,t)=>{d||!e||(t!==void 0&&u(t),e({}))},b=e=>{d||(u({position:e}),a?.setPosition({position:e}))};return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex items-center gap-6`,children:[g?v(GZ,{position:h,interactive:f,onSetPosition:f?b:void 0}):v(cae,{isOpen:_}),c(`div`,{className:`flex flex-col gap-3 flex-1`,children:[g&&c(`div`,{className:`flex items-baseline gap-1`,children:[v(`span`,{className:`text-3xl font-semibold tabular-nums text-foreground`,children:h}),v(`span`,{className:`text-base text-foreground-subtle`,children:`%`}),v(`span`,{className:`text-xs text-foreground-subtle ml-1`,children:i(`uiLibrary.coverHeroCard.openWord`,`open`)})]}),!g&&v(`div`,{className:`flex items-baseline gap-1`,children:v(`span`,{className:`text-3xl font-semibold capitalize text-foreground`,children:l?.state??`—`})}),c(`div`,{className:`flex items-center gap-2`,children:[v(UZ,{label:i(`uiLibrary.coverHeroCard.open`,`Open`),busy:d,variant:m.up,onClick:()=>y(a?.open,{state:`opening`}),children:v(Ei,{className:`h-5 w-5`})}),v(UZ,{label:i(`uiLibrary.coverHeroCard.stop`,`Stop`),busy:d,variant:m.stop,onClick:()=>y(a?.stop,{state:`stopped`}),children:v(pi,{className:`h-4 w-4`})}),v(UZ,{label:i(`uiLibrary.coverHeroCard.close`,`Close`),busy:d,variant:m.down,onClick:()=>y(a?.close,{state:`closing`}),children:v(de,{className:`h-5 w-5`})})]})]})]}),f&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`w-12 shrink-0`,children:i(`uiLibrary.coverHeroCard.position`,`Position`)}),v(`input`,{"aria-label":i(`uiLibrary.coverHeroCard.position`,`Position`),type:`range`,min:0,max:100,step:1,value:h??0,disabled:d,className:`flex-1`,onChange:e=>{b(Number(e.target.value))}}),c(`span`,{className:`w-8 text-right tabular-nums`,children:[h??`—`,`%`]})]}),!f&&h!==null&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`w-12 shrink-0`,children:i(`uiLibrary.coverHeroCard.position`,`Position`)}),v(`input`,{"aria-label":i(`uiLibrary.coverHeroCard.position`,`Position`),type:`range`,min:0,max:100,step:1,value:h,disabled:!0,readOnly:!0,className:`flex-1 opacity-60`}),c(`span`,{className:`w-8 text-right tabular-nums`,children:[h,`%`]})]}),p&&c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`w-12 shrink-0`,children:i(`uiLibrary.coverHeroCard.tilt`,`Tilt`)}),v(`input`,{"aria-label":i(`uiLibrary.coverHeroCard.tiltPosition`,`Tilt position`),type:`range`,min:0,max:100,step:1,value:l?.tiltPosition??0,disabled:d,className:`flex-1`,onChange:e=>{let t=Number(e.target.value);u({tiltPosition:t}),d||a?.setTiltPosition({tiltPosition:t})}}),c(`span`,{className:`w-8 text-right tabular-nums`,children:[l?.tiltPosition??`—`,`%`]})]})]})}function qZ(e){return v(`span`,{className:`text-foreground-subtle text-xs select-none`,"aria-hidden":`true`,children:`—`})}function JZ(e){return v(`div`,{className:`rounded border border-border bg-surface-subtle px-3 py-2 text-xs text-foreground-subtle`,children:q()(`uiLibrary.dummyHeroCard.comingSoon`,`Controls coming soon`)})}function YZ(e){return{id:e.id,stableId:e.stableId,addonId:e.addonId,type:e.type,name:e.name,online:e.online,disabled:e.disabled,parentDeviceId:e.parentDeviceId,role:e.role??void 0,features:e.features}}function XZ({trpc:e,deviceId:t}){let{data:n}=fm({deviceId:t},{staleTime:6e4});return n===void 0?null:v(RZ,{trpc:e,device:YZ(n)})}var ZZ={"temperature-sensor":`temperature-sensor`,"humidity-sensor":`humidity-sensor`,"ambient-light-sensor":`ambient-light-sensor`,"pressure-sensor":`pressure-sensor`,"numeric-sensor":`numeric-sensor`,"wind-sensor":`numeric-sensor`,"rain-sensor":`numeric-sensor`,"uv-sensor":`numeric-sensor`,"solar-radiation-sensor":`numeric-sensor`,"soil-moisture-sensor":`numeric-sensor`,"power-sensor":`power-meter`,"energy-sensor":`power-meter`,"voltage-sensor":`power-meter`,"current-sensor":`power-meter`,"battery-sensor":`numeric-sensor`,"generic-sensor":`numeric-sensor`,"motion-sensor":`motion`,"pir-sensor":`motion`,"contact-sensor":`contact`,"smoke-sensor":`smoke`,"leak-sensor":`flood`,"co-sensor":`carbon-monoxide`,"binary-sensor":`binary`,presence:`presence`,"enum-sensor":`enum-sensor`,"datetime-sensor":`enum-sensor`};function QZ(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function $Z(e,t){if(!QZ(t))return!1;if(e.kind===`presence`)return typeof t.state==`string`;if(e.kind===`string`||e.kind===`datetime`)return typeof t.value==`string`&&t.value!==``;let n=t[e.field];return e.kind===`numeric`?typeof n==`number`:typeof n==`boolean`}function eQ(e,t){if(!(t===void 0||!QZ(e)))return e[t]}function tQ(e){let t=eQ(e,`battery`);if(!(!QZ(t)||typeof t.level!=`number`))return{...t,value:t.level}}function nQ(e){let t=eQ(e.snapshotCaps,e.capName);if(e.descriptor!==void 0&&$Z(e.descriptor,t))return t;if(e.role===`battery-sensor`&&e.descriptor?.kind===`numeric`)return tQ(e.snapshotCaps)}function rQ(e){let t=e.descriptor;if(t!==void 0&&$Z(t,e.live))return{kind:`value`,slice:e.live};let n=nQ(e);return t!==void 0&&$Z(t,n)?{kind:`value`,slice:n}:e.addonId===`composer`&&e.snapshotStatus===`success`?{kind:`quiet`}:{kind:`awaiting`}}function iQ(e){return typeof e==`object`&&!!e}function aQ(e){return typeof e==`object`&&!!e}function oQ(e){return typeof e==`object`&&!!e&&`state`in e&&typeof e.state==`string`}function sQ(e,t){return e===`home`?t(`uiLibrary.sensor.presence.home`,`Home`):e===`not_home`?t(`uiLibrary.sensor.presence.away`,`Away`):e.charAt(0).toUpperCase()+e.slice(1)}var cQ={low:`bg-danger`,medium:`bg-warning`,high:`bg-success`};function lQ(e){return e<=20?`low`:e<=50?`medium`:`high`}function uQ({percent:e}){let t=Math.min(100,Math.max(0,e)),n=lQ(t);return v(`div`,{"data-testid":`battery-bar`,"data-band":n,className:`h-2 w-24 overflow-hidden rounded-full bg-border`,children:v(`div`,{className:$(`h-full rounded-full transition-all`,cQ[n]),style:{width:`${t}%`}})})}function dQ({trpc:e,device:t}){let n=q(),r=t.role==null?jZ[`temperature-sensor`]:jZ[t.role],i=kZ(t.role),{data:a}=Gp({},{staleTime:6e4}),o=Ge(e,t.id),s=Be(o!==null&&r!==void 0?r.getSliceHandle(o.state):void 0),l=Be(o!==null&&i?o.state.binary:void 0),u=Be(o!==null&&!i?o.state.binary:void 0),d=i&&r?.kind===`numeric`&&!AZ(s,r.field)&&l!==void 0,f=d?OZ:r,p=d?l:s,m=Eh({deviceId:t.id},{staleTime:5e3}),h=d?`binary`:t.role==null?ZZ[`temperature-sensor`]:ZZ[t.role],g=m.status===`success`||m.status===`error`?m.status:`pending`,_=rQ({addonId:t.addonId,role:t.role,descriptor:f,capName:h,live:p,snapshotStatus:g,snapshotCaps:m.data});if(_.kind===`quiet`)return v(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4 min-h-[96px]`,"data-testid":`sensor-hero-quiet`,children:v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})});let y=_.kind===`value`?_.slice:void 0;if(f===void 0||y===void 0)return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4 min-h-[96px]`,children:[v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`}),v(`span`,{className:`text-xs text-foreground-subtle italic`,children:n(`uiLibrary.sensorHeroCard.awaiting`,`Awaiting state…`)})]});if(f.kind===`numeric`){if(!iQ(y))return null;let e=y[f.field];if(typeof e!=`number`)return null;let r=t.sourceInfo?.quantity,o=lZ({display:t.display,capName:t.role===`numeric-sensor`?`numeric-sensor`:void 0,roleDefault:t.role==null?a?.defaults?.[`temperature-sensor`]:a?.defaults?.[t.role],quantity:f.quantity??`device`,deviceQuantity:r===`device`?void 0:r}).format(e),s=o.unit,l=o.text,d=u!==void 0&&aQ(u)&&typeof u.on==`boolean`?!!u.on:null;return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex items-baseline gap-1`,children:[v(`span`,{className:`text-3xl font-semibold tabular-nums text-foreground`,children:l}),s&&v(`span`,{className:`text-base text-foreground-subtle`,children:s})]}),i&&v(uQ,{percent:e}),d!==null&&v(`span`,{className:$(`inline-flex items-center rounded px-2 py-0.5 text-xs font-medium`,d?`bg-warning/15 text-warning`:`bg-surface-subtle text-foreground-subtle`),"data-testid":`sensor-hero-occupancy`,children:d?n(`uiLibrary.sensorHeroCard.occupied`,`Occupied`):n(`uiLibrary.sensorHeroCard.clear`,`Clear`)}),v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})]})}if(f.kind===`binary`){if(!aQ(y))return null;let e=!!y[f.field],n=e?f.onLabel:f.offLabel;return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[v(`span`,{className:$(`inline-flex items-center rounded px-3 py-1.5 text-lg font-semibold`,e?`bg-warning/15 text-warning`:`bg-surface-subtle text-foreground-subtle`),children:n}),v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})]})}if(f.kind===`datetime`){if(!FZ(y))return null;if(y.value===``)return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4 min-h-[96px]`,children:[v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`}),v(`span`,{className:`text-xs text-foreground-subtle italic`,children:n(`uiLibrary.sensorHeroCard.awaiting`,`Awaiting state…`)})]});let e=t.sourceInfo?.dateTimeShape??IZ(y)??f.format;return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[v(`span`,{className:`text-3xl font-semibold tabular-nums text-foreground`,children:hZ(y.value,e)}),v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})]})}if(f.kind===`string`)return!FZ(y)||y.value===``?null:c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[v(`span`,{className:`text-xl font-semibold text-foreground`,children:y.value}),v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})]});if(!oQ(y))return null;let b=sQ(y.state,n);return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[v(`span`,{className:$(`inline-flex items-center rounded px-3 py-1.5 text-lg font-semibold`,y.state===`home`?`bg-success/15 text-success`:`bg-surface-subtle text-foreground-subtle`),children:b}),v(bj,{device:t,form:`full`,className:`text-sm text-foreground-subtle`})]})}function fQ({trpc:e,deviceId:t}){let{data:n}=fm({deviceId:t},{staleTime:6e4});return n===void 0?null:v(dQ,{trpc:e,device:n})}function pQ(e){return e===void 0||e.inProgress?!1:e.availableVersion!==null&&e.currentVersion!==null&&e.availableVersion!==e.currentVersion}function mQ(e,t){return Zj({trpc:e,deviceId:t,cap:e=>e.update,slice:e=>e.state.update})}function hQ({trpc:e,deviceId:t}){let n=q(),{cap:r,slice:i}=mQ(e,t);return r===void 0?null:i?.inProgress?c(`span`,{className:`inline-flex items-center gap-1 text-xs text-foreground-subtle`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),n(`uiLibrary.updateControl.updating`,`Updating…`)]}):pQ(i)?c(`span`,{className:`inline-flex items-center gap-1 rounded bg-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-warning`,children:[v(nn,{className:`h-3 w-3`}),n(`uiLibrary.updateControl.update`,`Update`)]}):c(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[v(dt,{className:`h-3 w-3 text-success`}),i?.currentVersion??n(`uiLibrary.updateControl.upToDate`,`Up to date`)]})}function gQ({trpc:e,deviceId:t}){let n=q(),{cap:r,slice:i,available:a}=mQ(e,t);if(r===void 0)return null;let o=i?.inProgress===!0,s=pQ(i),l=i?.currentVersion??`—`,u=()=>{!a||r===void 0||!s||r.installUpdate({})};return c(`div`,{className:`flex flex-col items-center justify-center gap-2 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex items-baseline gap-1.5`,children:[v(`span`,{className:`text-3xl font-semibold tabular-nums text-foreground`,children:l}),s&&i?.availableVersion!=null&&c(P,{children:[v(`span`,{className:`text-base text-foreground-subtle`,children:`→`}),v(`span`,{className:`text-base font-medium text-warning tabular-nums`,children:i.availableVersion})]})]}),o?c(`span`,{className:`inline-flex items-center gap-1.5 rounded px-3 py-1.5 text-sm font-medium text-foreground-subtle`,children:[v(Gn,{className:`h-4 w-4 animate-spin`}),n(`uiLibrary.updateControl.installing`,`Installing…`)]}):s?c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u()},disabled:!a,className:`inline-flex items-center gap-1.5 rounded-lg bg-primary px-4 py-1.5 text-sm font-medium text-primary-foreground shadow-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:[v(nn,{className:`h-4 w-4`}),n(`uiLibrary.updateControl.install`,`Install update`)]}):c(`span`,{className:`inline-flex items-center gap-1.5 rounded bg-success/15 px-3 py-1 text-sm font-medium text-success`,children:[v(dt,{className:`h-4 w-4`}),n(`uiLibrary.updateControl.upToDate`,`Up to date`)]}),i?.state!=null&&i.state!==``&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i.state})]})}function _Q(e,t=Fn){switch(e){case`cleaning`:return{label:t(`uiLibrary.vacuum.cleaning`,`Cleaning`),tone:`text-primary`};case`paused`:return{label:t(`uiLibrary.vacuum.paused`,`Paused`),tone:`text-warning`};case`returning`:return{label:t(`uiLibrary.vacuum.returning`,`Returning`),tone:`text-primary`};case`docked`:return{label:t(`uiLibrary.vacuum.docked`,`Docked`),tone:`text-success`};case`drying`:return{label:t(`uiLibrary.vacuum.drying`,`Drying`),tone:`text-warning`};case`idle`:return{label:t(`uiLibrary.vacuum.idle`,`Idle`),tone:`text-foreground-subtle`};case`error`:return{label:t(`uiLibrary.vacuum.error`,`Error`),tone:`text-destructive`};case void 0:return{label:t(`uiLibrary.vacuum.unknown`,`Unknown`),tone:`text-foreground-subtle`}}}function vQ(e,t){return Zj({trpc:e,deviceId:t,cap:e=>e.vacuumControl,slice:e=>e.state.vacuumControl})}function yQ({label:e,busy:t,active:n,onClick:r,children:i}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),r()},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,n&&`bg-primary text-primary-foreground`,t&&`opacity-40 cursor-not-allowed`),children:i})}function bQ(e){switch(e){case`cleaning`:return{glow:`bg-primary/15`,accent:`text-primary`,docked:!1,active:!0};case`returning`:return{glow:`bg-primary/10`,accent:`text-primary`,docked:!1,active:!0};case`docked`:return{glow:`bg-success/10`,accent:`text-success`,docked:!0,active:!1};case`drying`:return{glow:`bg-warning/10`,accent:`text-warning`,docked:!0,active:!1};case`paused`:return{glow:`bg-warning/10`,accent:`text-warning`,docked:!1,active:!1};case`error`:return{glow:`bg-destructive/10`,accent:`text-destructive`,docked:!1,active:!1};case`idle`:return{glow:`bg-transparent`,accent:`text-foreground-subtle`,docked:!1,active:!1};case void 0:return{glow:`bg-transparent`,accent:`text-foreground-subtle`,docked:!1,active:!1}}}var xQ=`
|
|
@@ -35,7 +35,7 @@ import{r as e}from"./rolldown-runtime-Cyuzqnbw.js";import{a as t,i as n,o as r,r
|
|
|
35
35
|
@media (prefers-reduced-motion: reduce) {
|
|
36
36
|
.acv-streak, .acv-fan, .acv-sway-wrap, .acv-glow, .acv-swing { animation: none !important; }
|
|
37
37
|
}
|
|
38
|
-
`;function m1({trpc:e,deviceId:t,layout:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(a===void 0||l===void 0)return null;let d=!s;if(n===`compact`)return c(`div`,{"data-mode":l.mode,className:`inline-flex items-center gap-1`,children:[v(`span`,{className:$(`text-xs tabular-nums font-medium`,XX[l.mode]),children:l.target===null?l.currentTemp===null?null:c(`span`,{className:`text-foreground-subtle`,children:[l.currentTemp,`°`]}):c(P,{children:[l.target,`°`,l.currentTemp!==null&&c(`span`,{className:`text-foreground-subtle font-normal`,children:[` `,`(`,l.currentTemp,`°)`]})]})}),l.target!==null&&c(P,{children:[v(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.decrease`,`Decrease target`),disabled:d,onClick:e=>{if(e.stopPropagation(),!d&&l.target!==null){let e=JX(l.target,-1,l);u({target:e}),a.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,d&&`opacity-40 cursor-not-allowed`),children:`−`}),v(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.increase`,`Increase target`),disabled:d,onClick:e=>{if(e.stopPropagation(),!d&&l.target!==null){let e=JX(l.target,1,l);u({target:e}),a.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,d&&`opacity-40 cursor-not-allowed`),children:`+`})]}),v(`select`,{"aria-label":i(`uiLibrary.acPanel.mode`,`Mode`),value:l.mode,disabled:d,onChange:e=>{e.stopPropagation();let t=l.availableModes.find(t=>t===e.target.value);!d&&t&&(u({mode:t}),a.setMode({mode:t}))},className:$(`bg-transparent px-0.5 text-xs text-foreground-subtle hover:text-foreground cursor-pointer`,d&&`opacity-40 cursor-not-allowed`),children:l.availableModes.map(e=>v(`option`,{value:e,children:s1(i,e)},e))})]});let f=l1[l.mode],p=l.mode!==`off`,m=!i1(l.availableModes),h=a1(l),g=d1(l.preset),_=l.preset===`turbo`,y=Math.max(.55,f1(l.fanMode)*(_?.6:1)),b=l.swingVertical!==null,x=l.swingHorizontal!==null,S=p&&(l.swingVertical===!0||l.swingHorizontal===!0);return c(`div`,{"data-mode":l.mode,className:$(`relative flex flex-col items-stretch gap-2.5 overflow-hidden rounded-lg border p-3 transition-colors`,YX[l.mode]),children:[v(`style`,{children:p1}),c(`div`,{className:`relative z-10 flex flex-col items-center justify-center gap-1 overflow-hidden rounded-lg border border-border/50 bg-surface/30 px-3 py-3`,children:[v(`div`,{className:`pointer-events-none absolute inset-0 opacity-60`,children:m&&!p?v(x1,{}):v(b1,{mode:l.mode,accent:f,periodSec:y,swaying:S,forceRising:m})}),v(`div`,{className:`pointer-events-none absolute inset-0 bg-gradient-to-b from-surface/50 via-transparent to-surface/50`}),p&&v(`span`,{"aria-hidden":!0,className:`acv-glow pointer-events-none absolute left-1/2 top-1/2 h-16 w-16 -translate-x-1/2 -translate-y-1/2 rounded-full blur-2xl`,style:{background:f,animation:`acv-glow 3.2s ease-in-out infinite`}}),c(`div`,{className:`relative z-10 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide`,style:{color:f},children:[v(g1,{mode:l.mode,heatingOnly:m,className:`h-3.5 w-3.5`}),s1(i,l.mode),l.currentTemp!==null&&v(`span`,{className:`normal-case text-foreground-subtle`,children:i(`uiLibrary.acPanel.now`,`· {{temp}}° now`,{temp:l.currentTemp})}),l.currentHumidity!==null&&c(`span`,{className:`inline-flex items-center gap-0.5 normal-case text-foreground-subtle`,children:[v(Ue,{className:`h-3 w-3`}),l.currentHumidity,`%`]})]}),l.target===null?c(`div`,{className:`relative z-10 flex items-baseline gap-0.5`,children:[v(`span`,{className:$(`text-4xl font-bold leading-none tabular-nums text-foreground`,qX(l)),children:l.currentTemp??`—`}),v(`span`,{className:`text-lg text-foreground-subtle`,children:`°`})]}):c(P,{children:[c(`div`,{className:`relative z-10 flex items-center gap-3`,children:[v(v1,{label:i(`uiLibrary.acPanel.decrease`,`Decrease target`),symbol:`−`,disabled:d,onClick:()=>{if(d||l.target===null)return;let e=JX(l.target,-1,l);u({target:e}),a.setTarget({target:e})}}),c(`div`,{className:`flex items-baseline gap-0.5`,children:[v(`span`,{className:$(`text-4xl font-bold leading-none tabular-nums`,qX(l)),style:{color:f},children:l.target}),v(`span`,{className:`text-lg text-foreground-subtle`,children:`°`})]}),v(v1,{label:i(`uiLibrary.acPanel.increase`,`Increase target`),symbol:`+`,disabled:d,onClick:()=>{if(d||l.target===null)return;let e=JX(l.target,1,l);u({target:e}),a.setTarget({target:e})}})]}),h!==null&&v(`div`,{className:`relative z-10 w-full px-1`,children:v(y1,{value:l.target,min:h.min,max:h.max,step:l.tempStep,accent:f,disabled:d,label:i(`uiLibrary.acPanel.setpoint`,`Setpoint`),onPreview:e=>{u({target:e})},onCommit:e=>{u({target:e}),a.setTarget({target:e})}})})]})]}),c(`div`,{className:`relative z-10 grid grid-cols-3 gap-2`,children:[v(_1,{label:i(`uiLibrary.acPanel.mode`,`Mode`),icon:v(`span`,{style:{color:f},className:`flex`,children:v(g1,{mode:l.mode,heatingOnly:m,className:`h-4 w-4`})}),value:l.mode,options:l.availableModes.map(e=>({value:e,label:s1(i,e)})),disabled:d,onChange:e=>{let t=l.availableModes.find(t=>t===e);t&&(u({mode:t}),a.setMode({mode:t}))}}),l.availableFanModes.length>0&&v(_1,{label:i(`uiLibrary.acPanel.fan`,`Fan`),icon:v(Fi,{className:`h-4 w-4 text-sky-500`}),value:l.fanMode,options:l.availableFanModes.map(e=>({value:e,label:u1(e)})),disabled:d,onChange:e=>{u({fanMode:e}),a.setFanMode({fanMode:e})}}),l.availablePresets.length>0&&v(_1,{label:i(`uiLibrary.acPanel.preset`,`Preset`),icon:v(g,{className:`h-4 w-4 text-emerald-500`}),value:l.preset,options:l.availablePresets.map(e=>({value:e,label:u1(e)})),disabled:d,onChange:e=>{u({preset:e}),a.setPreset({preset:e})}})]}),(b||x)&&v(h1,{label:i(`uiLibrary.acPanel.swing`,`Swing`),children:c(`div`,{className:`grid grid-cols-2 gap-1`,children:[b&&v(C1,{axis:`vertical`,on:l.swingVertical??!1,busy:d,onToggle:e=>{u({swingVertical:e}),a.setSwingVertical({on:e})}}),x&&v(C1,{axis:`horizontal`,on:l.swingHorizontal??!1,busy:d,onToggle:e=>{u({swingHorizontal:e}),a.setSwingHorizontal({on:e})}})]})})]})}function h1({label:e,children:t}){return c(`div`,{className:`relative z-10 flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e}),t]})}function g1({mode:e,heatingOnly:t=!1,className:n}){return v(t&&e===`heat`?ve:c1[e],{className:n,"aria-hidden":!0})}function _1({label:e,icon:t,value:n,options:r,disabled:i,onChange:a}){return c(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e}),c(`div`,{className:$(`flex items-center gap-1 overflow-hidden rounded-lg border border-border/60 bg-surface-subtle px-1.5 py-1.5 has-[:focus-visible]:border-primary`,i&&`opacity-40`),children:[v(`span`,{className:`flex shrink-0`,children:t}),v(`select`,{"aria-label":e,value:n,disabled:i,onChange:e=>{e.stopPropagation(),i||a(e.target.value)},className:`min-w-0 flex-1 cursor-pointer appearance-none truncate bg-transparent text-xs font-medium text-foreground outline-none`,children:r.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(de,{className:`h-3 w-3 shrink-0 text-foreground-subtle`})]})]})}function v1({label:e,symbol:t,disabled:n,onClick:r}){return v(`button`,{type:`button`,"aria-label":e,disabled:n,onClick:r,className:$(`flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-border bg-surface text-lg leading-none text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground active:scale-95`,n&&`opacity-40 cursor-not-allowed`),children:t})}function y1({value:e,min:t,max:n,step:r,accent:i,disabled:a,label:o,onPreview:s,onCommit:l}){let u=f(null),d=f(!1),[p,m]=C(null),h=p??e,g=`${Math.min(1,Math.max(0,(h-t)/(n-t)))*100}%`,_=i=>{let a=u.current;if(a===null)return e;let o=a.getBoundingClientRect();return o.width<=0?e:o1((i-o.left)/o.width,{min:t,max:n},r)},y=e=>{if(a)return;e.stopPropagation(),e.preventDefault(),d.current=!0,typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=_(e.clientX);m(t),s(t)},b=e=>{if(a||!d.current)return;e.stopPropagation();let t=_(e.clientX);m(t),s(t)},x=e=>{if(!d.current)return;e.stopPropagation(),d.current=!1;let t=_(e.clientX);m(null),e.currentTarget.hasPointerCapture?.(e.pointerId)===!0&&e.currentTarget.releasePointerCapture(e.pointerId),l(t)};return c(`div`,{ref:u,role:`slider`,"aria-label":o,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":h,"aria-disabled":a,tabIndex:a?-1:0,onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,onKeyDown:i=>{if(a)return;let o=p??e;i.key===`ArrowRight`||i.key===`ArrowUp`?(i.preventDefault(),l(JX(o,1,{tempStep:r,minTemp:t,maxTemp:n}))):i.key===`ArrowLeft`||i.key===`ArrowDown`?(i.preventDefault(),l(JX(o,-1,{tempStep:r,minTemp:t,maxTemp:n}))):i.key===`Home`?(i.preventDefault(),l(t)):i.key===`End`&&(i.preventDefault(),l(n))},className:$(`mt-1 w-full touch-none select-none py-2`,a?`cursor-not-allowed opacity-40`:`cursor-ew-resize`),children:[c(`div`,{className:`relative h-1.5 w-full rounded-full bg-surface-subtle`,children:[v(`div`,{className:`absolute inset-y-0 left-0 rounded-full`,style:{width:g,background:i}}),v(`div`,{className:`absolute top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-surface shadow`,style:{left:g,background:i}})]}),c(`div`,{className:`mt-0.5 flex justify-between text-[9px] tabular-nums text-foreground-subtle`,children:[c(`span`,{children:[t,`°`]}),c(`span`,{children:[n,`°`]})]})]})}function b1({mode:e,accent:t,periodSec:n,swaying:r,forceRising:i=!1}){let a=[0,1,2,3,4,5],o=i||e===`heat`,s=e===`dry`;return v(`div`,{"aria-hidden":!0,className:`absolute inset-0 overflow-hidden`,children:e===`off`?v(`div`,{className:`flex h-full items-center justify-center gap-2 opacity-30`,children:a.map(e=>v(`span`,{className:`h-8 w-1 rounded-full bg-foreground-subtle opacity-40`},e))}):e===`fan_only`?v(`div`,{className:`flex h-full items-center justify-center`,children:v(S1,{color:t,periodSec:Math.max(.5,n*.7),size:56})}):v(`div`,{"data-testid":i?`climate-heat-rise`:void 0,className:$(`acv-sway-wrap absolute inset-0`,r&&`acv-sway`),style:r?{animation:`acv-sway 2.6s ease-in-out infinite`}:void 0,children:a.map(e=>v(`span`,{className:`acv-streak absolute rounded-full`,style:{left:`${8+e*15}%`,width:s?`0.4rem`:`0.3rem`,height:s?`0.4rem`:`1.9rem`,background:t,boxShadow:`0 0 6px ${t}`,animationName:o?`acv-rise`:`acv-fall`,animationTimingFunction:`linear`,animationIterationCount:`infinite`,animationDuration:`${n}s`,animationDelay:`${e%3*(n/3)+e*.05}s`}},e))})})}function x1(){return v(`div`,{"data-testid":`climate-radiator`,"aria-hidden":!0,className:`flex h-full items-end justify-center gap-1.5 px-8 pb-3 opacity-40`,children:[0,1,2,3,4,5,6].map(e=>v(`span`,{className:`h-10 w-1.5 rounded-t-full bg-foreground-subtle`},e))})}function S1({color:e,periodSec:t,size:n}){return c(`svg`,{width:n,height:n,viewBox:`0 0 100 100`,className:`acv-fan`,style:{animation:`acv-spin ${t}s linear infinite`,transformOrigin:`50% 50%`},"aria-hidden":!0,children:[[0,120,240].map(t=>v(`path`,{d:`M50 50 C 58 30, 78 26, 84 12 C 66 20, 54 34, 50 50 Z`,fill:e,opacity:.85,transform:`rotate(${t} 50 50)`},t)),v(`circle`,{cx:`50`,cy:`50`,r:`7`,fill:e})]})}function C1({axis:e,on:t,busy:n,onToggle:r}){let i=q(),a=e===`vertical`?i(`uiLibrary.acPanel.vertical`,`Vertical`):i(`uiLibrary.acPanel.horizontal`,`Horizontal`),o=e===`vertical`?sn:tn,s=e===`vertical`?`acv-swing-v`:`acv-swing-h`;return c(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.swingAxis`,`{{axis}} swing`,{axis:a}),"aria-pressed":t,disabled:n,onClick:()=>{n||r(!t)},className:$(`flex items-center justify-center gap-2 rounded-lg border px-2 py-1.5 text-xs font-medium transition-colors`,t?`border-transparent bg-indigo-400 text-indigo-950 shadow-sm`:`border-border/60 bg-surface-subtle text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,n&&`opacity-40 cursor-not-allowed`),children:[v(o,{className:`acv-swing h-4 w-4`,"aria-hidden":!0,style:t?{animation:`${s} 1.4s ease-in-out infinite`}:void 0}),a]})}var w1=5,T1=35;function E1(e,t,n){return n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))}function D1(e,t,n){return Math.round(t+e*(n-t))}var O1=176,k1=76,A1=2*Math.PI*k1,j1=270/360*A1,M1=O1/2-k1-10;function N1(e){let t=O1/2,n=O1/2,r=A1-j1,i=e.mode===`band`?(()=>{let t=e.band.from*j1,n=Math.max(0,(e.band.to-e.band.from)*j1);return{dasharray:`${n} ${A1-n}`,dashoffset:-t}})():(()=>{let t=e.fraction*j1;return{dasharray:`${t} ${A1-t}`,dashoffset:void 0}})();return c(`svg`,{width:O1,height:O1,viewBox:`0 0 ${O1} ${O1}`,"aria-hidden":`true`,className:`absolute inset-0`,style:{transform:`rotate(135deg)`},children:[v(`circle`,{cx:t,cy:n,r:k1,fill:`none`,stroke:`var(--color-border)`,strokeWidth:12,strokeDasharray:`${j1} ${r}`,strokeLinecap:`round`}),v(`circle`,{cx:t,cy:n,r:k1,fill:`none`,stroke:e.color,strokeWidth:12,strokeDasharray:i.dasharray,...i.dashoffset===void 0?{}:{strokeDashoffset:i.dashoffset},strokeLinecap:`round`})]})}var P1={heat:`#f59e0b`,cool:`#60a5fa`,auto:`#c084fc`,heat_cool:`#e879f9`,fan_only:`#94a3b8`,dry:`#22d3ee`,off:`#d4d4d8`};function F1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl}),o=Zj({trpc:e,deviceId:t,cap:e=>e.heatingValve,slice:e=>e.state.heatingValve}),{display:s,applyOptimistic:l}=FX(a.slice,{enabled:r??!0}),u=a.cap!==void 0&&s!==void 0,d=o.cap!==void 0;if(!u&&!d)return null;if(!u&&d)return v(`div`,{className:`flex flex-col items-stretch gap-3 rounded-lg border border-border bg-surface p-4`,children:v(n1,{trpc:e,deviceId:t,layout:`full`})});if(a.cap===void 0||s===void 0)return null;let f=a.cap,p=!a.available,m=P1[s.mode],h=s.mode===`heat_cool`||s.targetLow!==null&&s.targetHigh!==null,g=w1,_=T1,y=!h&&s.target!==null?E1(s.target,g,_):0,b=h&&s.targetLow!==null?E1(s.targetLow,g,_):0,x=h&&s.targetHigh!==null?E1(s.targetHigh,g,_):0;return c(`div`,{"data-mode":s.mode,className:$(`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4 transition-colors`,YX[s.mode]),children:[c(`div`,{className:`flex flex-col items-center gap-3`,children:[c(`div`,{className:`relative`,style:{width:O1,height:O1},children:[h?v(N1,{mode:`band`,band:{from:b,to:x},color:m}):v(N1,{mode:`fill`,fraction:y,color:m}),h?c(P,{children:[v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:b,color:m,knobTopPx:M1,onDragFraction:e=>{if(p||s.targetHigh===null)return;let t=Math.min(D1(e,g,_),s.targetHigh);l({targetLow:t}),f.setTargetRange({targetLow:t,targetHigh:s.targetHigh})}})}),v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:x,color:m,knobTopPx:M1,onDragFraction:e=>{if(p||s.targetLow===null)return;let t=Math.max(D1(e,g,_),s.targetLow);l({targetHigh:t}),f.setTargetRange({targetLow:s.targetLow,targetHigh:t})}})})]}):v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:y,color:m,knobTopPx:M1,onDragFraction:e=>{if(p)return;let t=D1(e,g,_);l({target:t}),f.setTarget({target:t})}})}),c(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-0.5 pointer-events-none`,children:[c(`div`,{"data-testid":`current-temp`,className:`text-4xl font-bold tabular-nums text-foreground leading-none`,children:[s.currentTemp===null?`—`:s.currentTemp,v(`span`,{className:`text-lg text-foreground-subtle font-normal ml-0.5`,children:`°`})]}),!h&&s.target!==null&&v(`div`,{className:`text-xs font-semibold`,style:{color:m},children:i(`uiLibrary.thermostatHeroCard.setTo`,`set {{value}}°`,{value:s.target})}),h&&s.targetLow!==null&&s.targetHigh!==null&&c(`div`,{className:`text-xs font-semibold`,style:{color:m},children:[s.targetLow,`° – `,s.targetHigh,`°`]})]})]}),!h&&s.target!==null&&v(`div`,{className:`w-[200px]`,children:v(mX,{value:`${s.target}°`,onDelta:e=>{if(p||s.target===null)return;let t=s.target+e;l({target:t}),f.setTarget({target:t})}})})]}),d?v(n1,{trpc:e,deviceId:t,layout:`full`}):null,v(`select`,{"aria-label":i(`uiLibrary.thermostatHeroCard.mode`,`Mode`),value:s.mode,disabled:p,onChange:e=>{e.stopPropagation();let t=e.target.value;!p&&t&&(l({mode:s.availableModes.find(e=>e===t)??s.mode}),f.setMode({mode:s.availableModes.find(e=>e===t)??s.mode}))},className:$(`w-full rounded border border-border bg-surface px-3 py-1.5 text-sm`,p&&`opacity-40 cursor-not-allowed`),children:s.availableModes.map(e=>v(`option`,{value:e,children:e},e))})]})}function I1(e){return e===`locked`||e===`locking`}function L1(e){return e===`jammed`}var R1={locked:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`locked`},locking:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`locked`},unlocked:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`open`},unlocking:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`open`},jammed:{colorClass:`border-danger/30 bg-danger/10 text-danger`,icon:`locked`}};function z1({state:e}){let t=R1[e];return v(`div`,{"data-testid":`lock-glyph`,"data-state":e,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,t.colorClass),children:t.icon===`locked`?v(Cr,{className:`h-8 w-8`,"aria-hidden":`true`}):v(yi,{className:`h-8 w-8`,"aria-hidden":`true`})})}function B1({state:e}){return v(`span`,{className:$(`text-sm font-medium capitalize`,L1(e)?`text-danger`:`text-foreground-muted`),children:e})}function V1({busy:e,onOpen:t}){let n=q();return c(`button`,{type:`button`,"aria-label":n(`uiLibrary.lockHeroCard.openUnlatch`,`Open (unlatch)`),title:n(`uiLibrary.lockHeroCard.openUnlatch`,`Open (unlatch)`),disabled:e,onClick:e=>{e.stopPropagation(),t()},className:$(`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium`,`text-foreground-muted hover:bg-surface-hover transition-colors`,e&&`opacity-40 cursor-not-allowed`),children:[v(pn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),n(`uiLibrary.lockHeroCard.open`,`Open`)]})}function H1({trpc:e,deviceId:t,features:n,optimistic:r}){let{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.lockControl,slice:e=>e.state.lockControl}),{display:s,applyOptimistic:l}=FX(a,{enabled:r??!0});if(i===void 0||s===void 0||!(s.state in R1))return null;let u=I1(s.state),d=L1(s.state)||!o,f=n?.includes(Oa.LockOpen)===!0,p=()=>{d||(u?(l({state:`unlocking`}),i.unlock({})):(l({state:`locking`}),i.lock({})))},m=()=>{d||i.open({})},h=u?`Unlock`:`Lock`;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(z1,{state:s.state}),v(B1,{state:s.state})]}),v(`div`,{className:$(d&&`pointer-events-none opacity-40`),children:v(hX,{on:u,targetLabel:h,onConfirm:p})}),f&&v(`div`,{className:`flex justify-center`,children:v(V1,{busy:d,onOpen:m})})]})}var U1=500,W1=150,G1=`linear-gradient(90deg, #9ec9ff, #ffffff, #ffb24d)`;function K1(e,t,n){return n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))}function q1(e){return K1(e,W1,U1)}var J1=`#f4b740`,Y1=`#d4d4d8`;function X1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),o=Zj({trpc:e,deviceId:t,cap:e=>e.brightness,slice:e=>e.state.brightness}),s=Zj({trpc:e,deviceId:t,cap:e=>e.color,slice:e=>e.state.color}),l=FX(a.slice,{enabled:r??!0}),u=FX(o.slice,{enabled:r??!0}),d=FX(s.slice,{enabled:r??!0});if(a.cap===void 0||l.display===void 0)return null;let f=l.display.on===!0,p=!a.available,m=u.display?.level??0,h=!o.available,g=f?m/100:0,_=f?J1:Y1,y=(n?.includes(Oa.LightColorMired)??!1)&&s.cap!==void 0,b=d.display?.colorTemperature,x=!s.available;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex flex-col items-center gap-3`,children:[c(DX,{fraction:g,color:_,children:[c(`div`,{"data-testid":`brightness-readout`,className:`text-3xl font-bold tabular-nums text-foreground leading-none`,children:[m,v(`span`,{className:`text-base text-foreground-subtle font-normal ml-0.5`,children:`%`})]}),v(Xn,{className:`h-5 w-5 text-foreground-subtle`,"aria-hidden":`true`})]}),o.cap!==void 0&&c(`label`,{className:`flex w-full items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`w-16`,children:i(`uiLibrary.lightHeroCard.brightness`,`Brightness`)}),v(`input`,{"aria-label":i(`uiLibrary.lightHeroCard.brightness`,`Brightness`),type:`range`,min:0,max:100,step:1,className:`flex-1`,value:m,disabled:h||!f,onChange:e=>{let t=Number(e.target.value);u.applyOptimistic({level:t}),h||o.cap?.setBrightness({level:t})}}),c(`span`,{className:`tabular-nums w-9 text-right`,children:[m,`%`]})]})]}),c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:f?i(`uiLibrary.lightHeroCard.on`,`On`):i(`uiLibrary.lightHeroCard.off`,`Off`)}),v(OX,{on:f,busy:p,onToggle:()=>{if(p)return;let e=!f;l.applyOptimistic({on:e}),a.cap?.setState({on:e})}})]}),y&&c(`div`,{className:`flex items-center gap-2`,"data-testid":`color-temp-strip`,children:[v(We,{className:`h-4 w-4 text-foreground-subtle`,"aria-hidden":`true`}),c(`label`,{className:`flex-1`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.lightHeroCard.colourTemperature`,`Colour temperature`)}),v(`input`,{"aria-label":i(`uiLibrary.lightHeroCard.colourTemperature`,`Colour temperature`),type:`range`,min:W1,max:U1,step:1,className:`w-full`,value:b??U1,disabled:x||!f,onChange:e=>{let t=Number(e.target.value);d.applyOptimistic({mode:`mired`,colorTemperature:t}),x||s.cap?.setColor({color:{mode:`mired`,colorTemperature:t}})}}),v(`div`,{className:`pointer-events-none mt-1`,children:v(xX,{fraction:b===void 0?.5:q1(b),color:G1})})]})]})]})}var Z1=`#3aa6a0`,Q1=`#d4d4d8`;function $1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),o=Zj({trpc:e,deviceId:t,cap:e=>e.fanControl,slice:e=>e.state.fanControl}),s=FX(a.slice,{enabled:r??!0}),l=FX(o.slice,{enabled:r??!0});if(a.cap===void 0||s.display===void 0)return null;let u=s.display.on===!0,d=!a.available,f=l.display?.speed??0,p=!o.available,m=u?f/100:0,h=u?Z1:Q1,g=n?.includes(Oa.FanSpeed)??!1,_=(n?.includes(Oa.FanOscillating)??!1)&&o.cap!==void 0,y=l.display?.availablePresets??[],b=(n?.includes(Oa.FanPreset)??!1)&&o.cap!==void 0&&y.length>0,x=l.display?.preset??``,S=l.display?.oscillating===!0,C=()=>{if(d)return;let e=!u;s.applyOptimistic({on:e}),a.cap?.setState({on:e})},w=()=>{if(p)return;let e=!S;l.applyOptimistic({oscillating:e}),o.cap?.setOscillating({oscillating:e})},T=e=>{if(p)return;let t=l.display;if(t===void 0)return;let n=t.percentageStep!==void 0&&t.percentageStep>0?t.percentageStep:1,r=Math.min(100,Math.max(0,Math.round(e*100/n)*n));l.applyOptimistic({speed:r}),o.cap?.setPercentage({speed:r})},E=e=>{p||e===``||(l.applyOptimistic({preset:e}),o.cap?.setPreset({preset:e}))};return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[v(`div`,{className:`flex flex-col items-center gap-3`,children:g?c(DX,{fraction:m,color:h,onDragFraction:T,children:[c(`div`,{"data-testid":`speed-readout`,className:`text-3xl font-bold tabular-nums text-foreground leading-none`,children:[f,v(`span`,{className:`text-base text-foreground-subtle font-normal ml-0.5`,children:`%`})]}),v(Ht,{className:`h-5 w-5 text-foreground-subtle`,"aria-hidden":`true`})]}):v(`div`,{"data-testid":`fan-onoff-icon`,className:`flex h-[150px] w-[150px] items-center justify-center`,children:v(Ht,{className:`h-16 w-16`,style:{color:h},"aria-hidden":`true`})})}),b&&v(`div`,{className:`flex justify-center`,children:c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:i(`uiLibrary.fanHeroCard.preset`,`Preset`)}),c(`select`,{"aria-label":i(`uiLibrary.fanHeroCard.fanPreset`,`Fan preset`),value:x,disabled:p,onChange:e=>{e.stopPropagation(),E(e.target.value)},className:$(`bg-surface border border-border rounded px-1 py-0.5`,p&&`opacity-40 cursor-not-allowed`),children:[v(`option`,{value:``,disabled:!0,children:`—`}),y.map(e=>v(`option`,{value:e,children:e},e))]})]})}),c(`div`,{className:`flex items-center justify-between gap-2`,children:[_?c(`button`,{type:`button`,"aria-label":i(`uiLibrary.fanHeroCard.oscillate`,`Oscillate`),"aria-pressed":S,disabled:p,onClick:e=>{e.stopPropagation(),w()},className:$(`inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors`,S?`border-success/50 bg-success/10 text-success`:`border-border text-foreground-muted hover:bg-surface-hover`,p&&`opacity-40 cursor-not-allowed`),children:[v(_e,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),i(`uiLibrary.fanHeroCard.oscillate`,`Oscillate`)]}):v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:u?i(`uiLibrary.fanHeroCard.on`,`On`):i(`uiLibrary.fanHeroCard.off`,`Off`)}),v(OX,{on:u,busy:d,onToggle:C})]})]})}function e0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),{display:s,applyOptimistic:l}=FX(a,{enabled:n??!0});if(i===void 0||s===void 0)return null;let u=s.on===!0,d=!o;return c(`div`,{className:`flex flex-col items-center gap-4 rounded-lg border border-border bg-surface p-6`,children:[v(`div`,{"data-testid":`switch-glyph`,"data-state":u?`on`:`off`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2 transition-colors`,u?`border-success/30 bg-success/10 text-success`:`border-border bg-surface-subtle text-foreground-subtle`),children:v(nt,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:u?r(`uiLibrary.switchHeroCard.on`,`On`):r(`uiLibrary.switchHeroCard.off`,`Off`)}),v(OX,{on:u,busy:d,onToggle:()=>{if(d)return;let e=!u;l({on:e}),i.setState({on:e})}})]})}function t0(e){return e===`playing`||e===`buffering`?`pause`:`play`}function n0(e,t){return e===null||t===null||t<=0?0:Math.min(1,Math.max(0,e/t))}function r0(e){if(e===null)return`--:--`;let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function i0({title:e,subtitle:t}){let n=q();return c(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[v(Yr,{className:`h-6 w-6 text-foreground-subtle`,"aria-hidden":`true`}),v(`span`,{className:`text-base font-semibold text-foreground line-clamp-1`,children:e??n(`uiLibrary.mediaPlayerHero.nothing`,`Nothing playing`)}),t&&v(`span`,{className:`text-xs text-foreground-subtle line-clamp-1`,children:t})]})}function a0({label:e,busy:t,onPress:n,children:r,primary:i}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),t||n()},className:$(`inline-flex items-center justify-center rounded-full transition-colors`,i?`h-12 w-12 bg-primary text-primary-foreground hover:bg-primary/90 shadow-md`:`h-10 w-10 text-foreground-muted hover:bg-surface-hover`,t&&`opacity-40 cursor-not-allowed`),children:r})}function o0({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.mediaPlayer,slice:e=>e.state.mediaPlayer}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(a===void 0||l===void 0)return null;let d=!s,f=t0(l.state),p=(n?.includes(Oa.MediaPlayerSeek)??!1)&&l.duration!==null&&l.duration>0,m=n?.includes(Oa.MediaPlayerNext)??!1,h=n?.includes(Oa.MediaPlayerPrevious)??!1,g=(n?.includes(Oa.MediaPlayerVolume)??!1)&&l.volumeLevel!==null,_=()=>{d||(f===`play`?(u({state:`playing`}),a.play({})):(u({state:`paused`}),a.pause({})))},y=l.currentMedia?.artist??l.currentMedia?.album??null,b=n0(l.position,l.duration),x=l.volumeLevel??0;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[v(i0,{title:l.currentMedia?.title??null,subtitle:y}),p&&c(`div`,{"data-testid":`media-seek`,className:`flex flex-col gap-1`,children:[c(`label`,{className:`relative block`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.mediaPlayerHero.seek`,`Seek`)}),v(`input`,{"aria-label":i(`uiLibrary.mediaPlayerHero.seek`,`Seek`),type:`range`,min:0,max:l.duration??0,step:1e3,className:`absolute inset-0 h-4 w-full cursor-pointer opacity-0`,value:l.position??0,disabled:d,onChange:e=>{if(d)return;let t=Number(e.target.value);u({position:t}),a.seek({position:t})}}),v(`div`,{className:`pointer-events-none`,children:v(xX,{fraction:b})})]}),c(`div`,{className:`flex justify-between text-[11px] tabular-nums text-foreground-subtle`,children:[v(`span`,{children:r0(l.position)}),v(`span`,{children:r0(l.duration)})]})]}),c(`div`,{className:`flex items-center justify-center gap-4`,children:[h&&v(a0,{label:i(`uiLibrary.mediaPlayerHero.previous`,`Previous`),busy:d,onPress:()=>void a.previous({}),children:v(nee,{className:`h-5 w-5`,"aria-hidden":`true`})}),v(a0,{label:f===`play`?i(`uiLibrary.mediaPlayerHero.play`,`Play`):i(`uiLibrary.mediaPlayerHero.pause`,`Pause`),busy:d,onPress:_,primary:!0,children:v(f===`play`?Le:Vt,{className:`h-6 w-6`,"aria-hidden":`true`})}),m&&v(a0,{label:i(`uiLibrary.mediaPlayerHero.next`,`Next`),busy:d,onPress:()=>void a.next({}),children:v(si,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),g&&c(`div`,{"data-testid":`media-volume`,className:`flex items-center gap-2`,children:[v(`button`,{type:`button`,"aria-label":l.isMuted===!0?i(`uiLibrary.mediaPlayerHero.unmute`,`Unmute`):i(`uiLibrary.mediaPlayerHero.mute`,`Mute`),title:l.isMuted===!0?i(`uiLibrary.mediaPlayerHero.unmute`,`Unmute`):i(`uiLibrary.mediaPlayerHero.mute`,`Mute`),disabled:d,onClick:e=>{if(e.stopPropagation(),d||l.isMuted===null)return;let t=!l.isMuted;u({isMuted:t}),a.setMute({muted:t})},className:$(`inline-flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,d&&`opacity-40 cursor-not-allowed`),children:l.isMuted===!0?v(me,{className:`h-4 w-4`,"aria-hidden":`true`}):v(mt,{className:`h-4 w-4`,"aria-hidden":`true`})}),c(`label`,{className:`relative block flex-1`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.mediaPlayerHero.volume`,`Volume`)}),v(`input`,{"aria-label":i(`uiLibrary.mediaPlayerHero.volume`,`Volume`),type:`range`,min:0,max:100,step:1,className:`absolute inset-0 h-4 w-full cursor-pointer opacity-0`,value:x,disabled:d,onChange:e=>{if(d)return;let t=Number(e.target.value);u({volumeLevel:t}),a.setVolume({volumeLevel:t})}}),v(`div`,{className:`pointer-events-none`,children:v(xX,{fraction:x/100})})]}),c(`span`,{className:`w-9 text-right text-[11px] tabular-nums text-foreground-subtle`,children:[x,`%`]})]})]})}E();var s0={disarmed:{colorClass:`border-border bg-surface-subtle text-foreground-subtle`,icon:`disarmed`},armed_home:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_away:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_night:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_vacation:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_custom_bypass:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},arming:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},disarming:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},pending:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},triggered:{colorClass:`border-danger/30 bg-danger/10 text-danger`,icon:`triggered`}};function c0(e,t){switch(e){case`home`:return t(`uiLibrary.alarmHeroCard.modeHome`,`Home`);case`away`:return t(`uiLibrary.alarmHeroCard.modeAway`,`Away`);case`night`:return t(`uiLibrary.alarmHeroCard.modeNight`,`Night`);case`vacation`:return t(`uiLibrary.alarmHeroCard.modeVacation`,`Vacation`);case`custom_bypass`:return t(`uiLibrary.alarmHeroCard.modeBypass`,`Bypass`)}}function l0(e,t){switch(e){case`disarmed`:return t(`uiLibrary.alarmHeroCard.stateDisarmed`,`Disarmed`);case`armed_home`:return t(`uiLibrary.alarmHeroCard.stateArmedHome`,`Armed Home`);case`armed_away`:return t(`uiLibrary.alarmHeroCard.stateArmedAway`,`Armed Away`);case`armed_night`:return t(`uiLibrary.alarmHeroCard.stateArmedNight`,`Armed Night`);case`armed_vacation`:return t(`uiLibrary.alarmHeroCard.stateArmedVacation`,`Armed Vacation`);case`armed_custom_bypass`:return t(`uiLibrary.alarmHeroCard.stateArmedBypass`,`Armed (Bypass)`);case`arming`:return t(`uiLibrary.alarmHeroCard.stateArming`,`Arming…`);case`disarming`:return t(`uiLibrary.alarmHeroCard.stateDisarming`,`Disarming…`);case`pending`:return t(`uiLibrary.alarmHeroCard.statePending`,`Pending`);case`triggered`:return t(`uiLibrary.alarmHeroCard.stateTriggered`,`Triggered`)}}function u0(e){return e.startsWith(`armed_`)}function d0(e){return e===`arming`||e===`disarming`}function f0({icon:e,sizeClass:t=`h-8 w-8`}){return v(e===`disarmed`?Wn:e===`triggered`?Dr:e===`pending`?Ln:Wr,{className:t,"aria-hidden":`true`})}function p0({label:e,active:t,busy:n,onSelect:r}){return v(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,disabled:n,onClick:e=>{e.stopPropagation(),n||r()},className:$(`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors`,t?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-muted hover:bg-surface-hover`,n&&`opacity-40 cursor-not-allowed`),children:e})}function m0({state:e,availableModes:t,busy:n,onDisarm:r,onArm:i}){let a=q(),o=u0(e),s=d0(e);return c(`div`,{className:$(`flex min-w-0 items-stretch gap-1 rounded-lg border border-border bg-surface-subtle p-1`),children:[v(p0,{label:a(`uiLibrary.alarmHeroCard.disarm`,`Disarm`),active:!o&&!s,busy:n,onSelect:r}),t.map(t=>v(p0,{label:c0(t,a),active:!s&&e===`armed_${t}`,busy:n,onSelect:()=>i(t)},t))]})}function h0(e){return e instanceof Error?e.message:String(e)}function g0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.alarmPanel,slice:e=>e.state.alarmPanel}),{display:o,applyOptimistic:s,rollback:c}=FX(i,{enabled:n??!0}),[l,u]=C(null),d=()=>u(null),p=f(0);b(()=>{u(null)},[i]);let m=!a;return{display:o,capPresent:r!==void 0,busy:m,handleDisarm:()=>{if(r===void 0||m)return;let e=++p.current;s({state:`disarming`}),r.disarm({}).catch(t=>{p.current===e&&(c(),u(h0(t)))})},handleArm:e=>{if(r===void 0||m)return;let t=++p.current;s({state:`arming`}),r.arm({mode:e}).catch(e=>{p.current===t&&(c(),u(h0(e)))})},error:l,clearError:d}}function _0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,handleDisarm:s,handleArm:l,error:u}=g0(e,t,n);if(!a||i===void 0)return null;let d=s0[i.state],f=u0(i.state)?i.state.replace(`armed_`,``):``;return c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[c(`span`,{className:$(`inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium whitespace-nowrap`,d.colorClass,d0(i.state)&&`animate-pulse`),children:[v(f0,{icon:d.icon,sizeClass:`h-3 w-3`}),l0(i.state,r)]}),c(`select`,{"aria-label":r(`uiLibrary.alarmHeroCard.alarmMode`,`Alarm mode`),disabled:o,value:f,onClick:e=>e.stopPropagation(),onChange:e=>{e.stopPropagation();let t=e.target.value;t===``?s():l(t)},className:$(`min-w-0 shrink rounded-md border border-border bg-surface-subtle px-1.5 py-0.5 text-xs text-foreground-muted`,o&&`cursor-not-allowed opacity-40`),children:[v(`option`,{value:``,children:r(`uiLibrary.alarmHeroCard.disarm`,`Disarm`)}),i.availableModes.map(e=>v(`option`,{value:e,children:c0(e,r)},e))]}),u!==null&&v(`span`,{"data-testid":`alarm-inline-error`,role:`alert`,title:u,className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-danger/10 text-danger`,children:v(Dr,{className:`h-3 w-3`,"aria-hidden":`true`})})]})}function v0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,handleDisarm:s,handleArm:l,error:u,clearError:d}=g0(e,t,n);if(!a||i===void 0)return null;let f=s0[i.state];return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`alarm-state`,"data-state":i.state,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,f.colorClass,d0(i.state)&&`animate-pulse`),children:v(f0,{icon:f.icon})}),v(`span`,{className:$(`text-sm font-medium`,f.colorClass,`border-0 bg-transparent`),children:l0(i.state,r)})]}),v(m0,{state:i.state,availableModes:i.availableModes,busy:o,onDisarm:s,onArm:l}),u!==null&&c(`div`,{"data-testid":`alarm-error`,role:`alert`,className:`flex items-start justify-between gap-2 rounded-md border border-danger/30 bg-danger/10 px-3 py-2 text-sm text-danger`,children:[v(`span`,{children:u}),v(`button`,{type:`button`,"aria-label":r(`uiLibrary.alarmHeroCard.dismiss`,`Dismiss`),onClick:e=>{e.stopPropagation(),d()},className:`shrink-0 font-medium text-danger/80 hover:text-danger`,children:`×`})]})]})}function y0(e,t,n=Fn){if(e<=0)return null;let r=Math.max(0,Math.round((t-e)/1e3));return r<60?n(`uiLibrary.scriptAutomationControls.justNow`,`just now`):r<3600?n(`uiLibrary.scriptAutomationControls.minAgo`,`{{count}} min ago`,{count:Math.floor(r/60)}):r<86400?n(`uiLibrary.scriptAutomationControls.hAgo`,`{{count}} h ago`,{count:Math.floor(r/3600)}):new Date(e).toLocaleDateString()}function b0({atMs:e,neverLabel:t}){let n=q(),r=y0(e,Date.now(),n);return v(`span`,{className:`text-xs text-foreground-subtle`,"data-testid":`last-run`,children:r===null?t:r})}function x0({error:e}){return e===null||e===``?null:c(`span`,{className:`inline-flex items-center gap-1 text-xs text-danger`,title:e,"data-testid":`last-error`,children:[v(zi,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}),v(`span`,{className:`truncate`,children:e})]})}function S0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.scriptRunner,slice:e=>e.state.scriptRunner}),{display:o,applyOptimistic:s}=FX(i,{enabled:n??!0}),c=!a,l=o?.isRunning===!0;return{display:o,capPresent:r!==void 0,busy:c,running:l,run:()=>{r===void 0||c||l||(s({isRunning:!0}),r.run({}))},stop:()=>{r===void 0||c||!l||(s({isRunning:!1}),r.stop({}))}}}function C0({running:e,busy:t,large:n,onRun:r,onStop:i}){let a=q(),o=e?a(`uiLibrary.scriptAutomationControls.stop`,`Stop`):a(`uiLibrary.scriptAutomationControls.run`,`Run`);return c(`button`,{type:`button`,"aria-label":o,title:o,disabled:t,"data-testid":`script-run`,"data-running":e?`true`:`false`,onClick:t=>{t.stopPropagation(),e?i():r()},className:$(`inline-flex items-center gap-1 rounded transition-colors`,n?`h-10 px-4 text-sm`:`h-5 px-1.5 text-xs`,e?`bg-danger text-danger-foreground hover:bg-danger/90`:`bg-primary text-primary-foreground hover:bg-primary/90`,t&&`cursor-not-allowed opacity-40`),children:[v(e?Er:Le,{className:n?`h-4 w-4`:`h-3 w-3`,"aria-hidden":`true`}),v(`span`,{children:o})]})}function w0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,running:s,run:l,stop:u}=S0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v(C0,{running:s,busy:o,large:!1,onRun:l,onStop:u}),v(b0,{atMs:i.lastRunAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverRun`,`never run`)})]})}function T0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,running:s,run:l,stop:u}=S0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`script-state`,"data-running":s?`true`:`false`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,s?`border-primary text-primary animate-pulse`:`border-border text-foreground-subtle`),children:v(Le,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium`,children:s?r(`uiLibrary.scriptAutomationControls.running`,`Running`):r(`uiLibrary.scriptAutomationControls.idle`,`Idle`)}),v(b0,{atMs:i.lastRunAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverRun`,`never run`)}),v(x0,{error:i.lastError})]}),v(`div`,{className:`flex justify-center`,children:v(C0,{running:s,busy:o,large:!0,onRun:l,onStop:u})})]})}function E0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.automationControl,slice:e=>e.state.automationControl}),{display:o,applyOptimistic:s}=FX(i,{enabled:n??!0}),c=!a;return{display:o,capPresent:r!==void 0,busy:c,setEnabled:e=>{r===void 0||c||(s({enabled:e}),e?r.enable({}):r.disable({}))},trigger:()=>{r===void 0||c||r.trigger({})}}}function D0({enabled:e,busy:t,onToggle:n}){let r=q();return v(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r(`uiLibrary.scriptAutomationControls.automationEnabled`,`Automation enabled`),disabled:t,"data-testid":`automation-enabled`,onClick:t=>{t.stopPropagation(),n(!e)},className:$(`inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5`,`text-[11px] font-medium whitespace-nowrap transition-colors`,e?`border-success/40 bg-success/10 text-success`:`border-border bg-surface-subtle text-foreground-subtle`,t&&`cursor-not-allowed opacity-40`),children:e?r(`uiLibrary.scriptAutomationControls.enabled`,`Enabled`):r(`uiLibrary.scriptAutomationControls.disabled`,`Disabled`)})}function O0({busy:e,large:t,onTrigger:n}){let r=q();return c(`button`,{type:`button`,"aria-label":r(`uiLibrary.scriptAutomationControls.trigger`,`Trigger`),title:r(`uiLibrary.scriptAutomationControls.runNow`,`Run this automation now`),disabled:e,"data-testid":`automation-trigger`,onClick:e=>{e.stopPropagation(),n()},className:$(`inline-flex items-center gap-1 rounded transition-colors`,t?`h-10 px-4 text-sm`:`h-5 px-1.5 text-xs`,`bg-primary text-primary-foreground hover:bg-primary/90`,e&&`cursor-not-allowed opacity-40`),children:[v(nr,{className:t?`h-4 w-4`:`h-3 w-3`,"aria-hidden":`true`}),v(`span`,{children:r(`uiLibrary.scriptAutomationControls.trigger`,`Trigger`)})]})}function k0({trpc:e,deviceId:t,optimistic:n}){let{display:r,capPresent:i,busy:a,setEnabled:o,trigger:s}=E0(e,t,n);return!i||r===void 0?null:c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v(D0,{enabled:r.enabled,busy:a,onToggle:o}),v(O0,{busy:a,large:!1,onTrigger:s})]})}function A0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,setEnabled:s,trigger:l}=E0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`automation-state`,"data-enabled":i.enabled?`true`:`false`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,i.enabled?`border-success text-success`:`border-border text-foreground-subtle`),children:v(nr,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium`,children:i.enabled?r(`uiLibrary.scriptAutomationControls.enabled`,`Enabled`):r(`uiLibrary.scriptAutomationControls.disabled`,`Disabled`)}),v(b0,{atMs:i.lastTriggeredAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverTriggered`,`never triggered`)}),v(x0,{error:i.lastError})]}),c(`div`,{className:`flex items-center justify-center gap-3`,children:[v(D0,{enabled:i.enabled,busy:o,onToggle:s}),v(O0,{busy:o,large:!0,onTrigger:l})]})]})}function j0({children:e}){return v(`div`,{className:`flex flex-col items-stretch gap-3 rounded-lg border border-border bg-surface p-4`,children:e})}function M0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch});return n!==void 0}function N0({trpc:e,deviceId:t,features:n,optimistic:r}){return M0(e,t)?v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function P0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.lockControl,slice:e=>e.state.lockControl});return n!==void 0}function F0({trpc:e,deviceId:t,features:n,optimistic:r}){return P0(e,t)?v(LX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function I0({trpc:e,deviceId:t,features:n,optimistic:r}){return M0(e,t)?c(`div`,{className:`inline-flex items-center gap-2`,children:[v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}),v(zX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r})]}):null}function L0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.fanControl,slice:e=>e.state.fanControl});return n!==void 0}function R0({trpc:e,deviceId:t,features:n,optimistic:r}){return L0(e,t)?c(`div`,{className:`inline-flex items-center gap-2`,children:[v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}),v(BX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r})]}):null}function z0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl});return n!==void 0}function B0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.heatingValve,slice:e=>e.state.heatingValve});return n!==void 0}function V0({trpc:e,deviceId:t,features:n,optimistic:r}){let i=z0(e,t),a=B0(e,t);return!i&&!a?null:c(`span`,{className:`inline-flex items-center gap-2`,children:[i?v(QX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null,a?v(n1,{trpc:e,deviceId:t,layout:`compact`}):null]})}function H0({trpc:e,deviceId:t,features:n,optimistic:r}){return z0(e,t)?v(m1,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function U0({trpc:e,deviceId:t,features:n,optimistic:r}){return z0(e,t)?v(m1,{trpc:e,deviceId:t,features:n,layout:`full`,optimistic:r}):null}function W0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.mediaPlayer,slice:e=>e.state.mediaPlayer});return n!==void 0}function G0({trpc:e,deviceId:t,features:n,optimistic:r}){return W0(e,t)?v(aZ,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function K0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.control,slice:e=>e.state.control});return n!==void 0}function q0({trpc:e,deviceId:t,features:n,optimistic:r}){return K0(e,t)?v(CZ,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function J0({trpc:e,deviceId:t,features:n,optimistic:r}){return K0(e,t)?v(j0,{children:v(CZ,{trpc:e,deviceId:t,features:n,layout:`full`,optimistic:r})}):null}var Y0={cover:{InlineControl:HZ,HeroCard:KZ},valve:{InlineControl:WQ,HeroCard:YQ},humidifier:{InlineControl:QQ,HeroCard:e$},"water-heater":{InlineControl:i$,HeroCard:o$},switch:{InlineControl:N0,HeroCard:e0},light:{InlineControl:I0,HeroCard:X1},fan:{InlineControl:R0,HeroCard:$1},sensor:{InlineControl:XZ,HeroCard:fQ},thermostat:{InlineControl:V0,HeroCard:F1},climate:{InlineControl:H0,HeroCard:U0},button:{InlineControl:kX,HeroCard:AX},update:{InlineControl:hQ,HeroCard:gQ},lock:{InlineControl:F0,HeroCard:H1},"media-player":{InlineControl:G0,HeroCard:o0},alarm:{InlineControl:_0,HeroCard:v0},control:{InlineControl:q0,HeroCard:J0},weather:{InlineControl:f$,HeroCard:_$},vacuum:{InlineControl:wQ,HeroCard:EQ},"lawn-mower":{InlineControl:LQ,HeroCard:zQ},image:{InlineControl:w$,HeroCard:T$},"pet-feeder":{InlineControl:B$,HeroCard:V$},dishwasher:{InlineControl:$$,HeroCard:e1},script:{InlineControl:w0,HeroCard:T0},automation:{InlineControl:k0,HeroCard:A0},dummy:{InlineControl:qZ,HeroCard:JZ}},X0=Object.fromEntries(Object.values(J).map(e=>[e,Y0[ea[e]]])),Z0={[J.Cover]:!0,[J.Valve]:!0,[J.Thermostat]:!0,[J.Climate]:!0,[J.Control]:!0,[J.Button]:!0,[J.MediaPlayer]:!0,[J.AlarmPanel]:!0,[J.Lock]:!1,[J.Vacuum]:!1,[J.LawnMower]:!1,[J.Humidifier]:!1,[J.Switch]:!1,[J.Siren]:!1,[J.Light]:!1,[J.Fan]:!1,[J.WaterHeater]:!1,[J.Sensor]:!1,[J.Presence]:!1,[J.EventEmitter]:!1,[J.Notifier]:!1,[J.Script]:!1,[J.Automation]:!1,[J.Camera]:!1,[J.Hub]:!1,[J.Update]:!1,[J.Generic]:!1,[J.Weather]:!1,[J.Container]:!1,[J.Image]:!1,[J.PetFeeder]:!1,[J.Dishwasher]:!1,[J.Washer]:!1,[J.Dryer]:!1},Q0=new Set(Object.values(J));function $0(e){let t=$a(e);return t?Y0[t]:null}function e2(e,t){return t===`table`?`fit`:Q0.has(e)&&Z0[e]?lX:t===`center`?dX:uX}var t2=1e3,n2=60*t2,r2=60*n2,i2=24*r2,a2=30*t2,o2=Date.UTC(2e3,0,1);function s2(e,t=Fn){if(e==null||e<o2)return null;let n=Date.now()-e;return n<a2?t(`uiLibrary.lastSeen.justNow`,`just now`):n<r2?t(`uiLibrary.lastSeen.minutes`,`{{count}}m ago`,{count:Math.floor(n/n2)}):n<i2?t(`uiLibrary.lastSeen.hours`,`{{count}}h ago`,{count:Math.floor(n/r2)}):t(`uiLibrary.lastSeen.days`,`{{count}}d ago`,{count:Math.floor(n/i2)})}function c2({lastChangedAt:e,className:t}){let n=q(),r=s2(e),i=n(`uiLibrary.offlineBadge.unavailable`,`Unavailable`),a=r===null?null:n(`uiLibrary.offlineBadge.lastSeen`,`last seen {{when}}`,{when:r});return c(`span`,{title:a===null?i:`${i} · ${a}`,className:$(`inline-flex items-center gap-1 rounded-full px-2 py-0.5`,`bg-surface-hover text-foreground-subtle text-[10px] font-medium`,`border border-border`,t),children:[v(Pt,{className:`h-3 w-3 flex-shrink-0`,"aria-hidden":`true`}),v(`span`,{children:i}),a===null?null:v(`span`,{className:`text-foreground-subtle/70`,children:`· ${a}`})]})}var l2=la;function u2(e,t,n){let r=io(e.map(e=>({id:e.id,stableId:e.entityId,type:e.type,...e.role===void 0?{}:{role:e.role},...e.name===void 0?{}:{name:e.name}})),t,n);return r===null?null:e.find(e=>e.id===r.id)??null}function d2(e){return e.sourceInfo?.id??e.stableId}function f2(e){return{id:e.id,entityId:d2(e),type:e.type,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.name===void 0?{}:{name:e.name}}}function p2(e,t){if(t==null)return;let n=e.find(e=>e.id===t);return n===void 0?void 0:d2(n)}function m2(e,t,n){return u2(e.map(f2),n!=null&&n!==``?n:p2(e,t))}function h2({trpc:e,children:t,linkDeviceId:n,primaryChildEntityId:r}){let i=q(),a=m2(t,n,r),o=a===null?void 0:t.find(e=>e.id===a.id);return o===void 0?v(`div`,{className:`flex h-full w-full items-center justify-center p-4 text-[11px] italic text-foreground-subtle`,children:i(`uiLibrary.containerPrimaryHero.empty`,`No child entities to display.`)}):v(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:v($0(o.type)?.HeroCard??JZ,{trpc:e,deviceId:o.id,features:o.features})})}var g2=`rounded-md border border-border bg-surface px-1.5 py-0.5 text-[11px] text-foreground`;function _2({childrenList:e,selectedId:t,onSetPrimary:n,disabled:r,className:i}){return v(`select`,{value:t,disabled:r,onChange:r=>{let i=Number(r.target.value);if(!Number.isFinite(i)||i===t)return;let a=e.find(e=>e.id===i);a!==void 0&&n(a.stableId)},className:i===void 0?g2:`${g2} ${i}`,children:e.map(e=>c(`option`,{value:e.id,children:[e.name,` (`,e.type,`)`]},e.id))})}function v2({selectedIds:e,onClear:t,remove:n,disable:r,enable:i}){let a=q(),o=li();if(e.size===0)return null;let s=[...e],l=s.length,u=()=>{for(let e of s)r({deviceId:e});t()},d=()=>{for(let e of s)i({deviceId:e});t()},f=async()=>{if(await o({title:a(`uiLibrary.batchToolbar.deleteTitle`,`Delete {{count}} devices?`,{count:l}),message:a(`uiLibrary.batchToolbar.deleteMessage`,`{{count}} selected devices will be deleted. This cannot be undone.`,{count:l}),confirmLabel:a(`uiLibrary.batchToolbar.delete`,`Delete`),variant:`danger`})){for(let e of s)n({deviceId:e});t()}};return c(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-border bg-surface-hover`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle shrink-0`,children:a(`uiLibrary.batchToolbar.selectedCount`,`{{count}} selected`,{count:l})}),v(`div`,{className:`h-3.5 w-px bg-border shrink-0`,"aria-hidden":`true`}),c(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[v(`button`,{type:`button`,onClick:u,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.disable`,`Disable`)}),v(`button`,{type:`button`,onClick:d,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.enable`,`Enable`)}),v(`button`,{type:`button`,onClick:()=>void f(),className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-danger/40 bg-danger/10 text-danger hover:bg-danger/20`),children:a(`uiLibrary.batchToolbar.delete`,`Delete`)}),v(`button`,{type:`button`,onClick:t,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.clear`,`Clear`)})]})]})}E();function y2(e){let t=q(),[n,r]=C(!1),i=f(null),a=e.selectedIds.size;return b(()=>{if(!n)return;let e=e=>{let t=e.target instanceof Node?e.target:null;t&&i.current&&!i.current.contains(t)&&r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[n]),a===0?null:c(P,{children:[v(`div`,{className:`hidden sm:block`,children:v(v2,{...e})}),c(`div`,{ref:i,"data-testid":`batch-actions-compact`,className:`relative sm:hidden`,children:[c(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-haspopup":`menu`,"aria-expanded":n,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border border-primary/40 bg-primary/15 text-[10.5px] font-medium text-primary`,children:[v(`span`,{children:t(`uiLibrary.deviceBatchActionsBar.actions`,`Actions · {{count}}`,{count:a})}),v(de,{className:`h-3 w-3 transition-transform ${n?`rotate-180`:``}`})]}),n&&v(`div`,{role:`menu`,className:`absolute left-0 top-full mt-1 z-30 rounded-lg border border-border bg-surface shadow-md`,children:v(v2,{...e})})]})]})}E();function b2(e,t,n){if(e===null||typeof window>`u`)return n;try{let r=window.localStorage.getItem(e);if(r===null)return n;let i=Number.parseInt(r,10);return Number.isFinite(i)&&t.includes(i)?i:n}catch{return n}}function x2(e,t){if(!(e===null||typeof window>`u`))try{window.localStorage.setItem(e,String(t))}catch{}}function S2({storageKey:e,options:t,defaultSize:n}){let r=t.includes(n)?n:t[0]??n,[i,a]=C(()=>b2(e,t,r));return[i,_(n=>{t.includes(n)&&(a(n),x2(e,n))},[t,e])]}function C2(e,t){return e===0?Math.max(1,t):e}var w2=[25,50,100,200],T2=`camstack.device-list.pageSize`;function E2(e){return S2({storageKey:T2,options:w2,defaultSize:w2.includes(e)?e:50})}function D2(e){return e.parentDeviceId===null?`top-level`:e.role?`accessory`:`adopted`}var O2={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 k2(e){let t=O2[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}}function A2(e,t){if(e.display?.icon){let t=ds(e.display.icon);if(t)return t}if(e.role){let n=t?.[e.role]?.icon;if(n!==void 0){let e=ds(n);if(e)return e}return Xo(e.role).icon}return Yo(e.type).icon}var j2=[` — `,` `];function M2(e,t){if(t.length===0)return e;for(let n of j2){let r=`${t}${n}`;if(e.startsWith(r))return e.slice(r.length)}return e}function N2(e,t){return e.display?.label?e.display.label:M2(e.name,t)}var P2={"native-snapshot":Nt,"two-way-audio":Pr,"pan-tilt-zoom":fi,"ptz-autotrack":iee,"doorbell-button":pn,"motion-trigger":ai,"battery-operated":Ee,rebootable:Di},F2={"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`},I2={"native-snapshot":`snapshot`,rebootable:`reboot`,"pan-tilt-zoom":`ptz`,"ptz-autotrack":`ptz-autotrack`,"two-way-audio":`intercom`,"motion-trigger":`motion-trigger`},L2=new Set([`camera`,`hub`,`nvr`]);function R2(e){return!L2.has(e.type.toLowerCase())}function z2(e){return e.role?!0:!L2.has(e.type.toLowerCase())}function B2(e){return(e.features??[]).includes(`motion-trigger`)}function V2(e,t){if(e.type!==J.Container)return e.online;let n=t??[];if(n.length===0)return e.online;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);if(r===null)return e.online;let i=n.find(e=>e.id===r.id);return i===void 0?e.online:i.online}function H2(e,t){if(e.type!==J.Container)return e.type;let n=t??[];if(n.length===0)return e.type;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);if(r===null)return e.type;let i=n.find(e=>e.id===r.id);return i===void 0?e.type:i.type}function U2(e,t){if(e.type!==J.Container||e.display?.icon!==void 0&&Ka(e.display.icon)!==void 0)return e;let n=t??[];if(n.length===0)return e;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);return r===null?e:n.find(e=>e.id===r.id)??e}function W2(e){if(e.length<=24)return e;let t=e.lastIndexOf(`:`);if(t>=0&&t<e.length-4)return e.slice(t+1);let n=e.split(`-`);if(n.length>2){let e=n.slice(-2).join(`-`);if(e.length>=6)return e}return`…${e.slice(-18)}`}var G2=[`name`,`icon`,`type`,`manufacturer`,`features`,`previewActions`],K2={devices:[`name`,`icon`,`type`,`manufacturer`,`features`,`previewActions`],"integration-detail":[`name`,`manufacturer`,`features`,`previewActions`]};function q2(e){return K2[e]}var J2={name:0,previewActions:1,icon:2,features:3,type:4,manufacturer:5},Y2={name:``,previewActions:``,icon:``,features:`hidden md:table-cell`,type:`hidden lg:table-cell`,manufacturer:`hidden xl:table-cell`},X2=`md:sticky md:left-0 md:z-[1]`,Z2=`md:w-64 md:max-w-[16rem]`,Q2=`whitespace-nowrap md:truncate`,$2=`manufacturer`,e4=`model`;function t4(e){if(typeof e==`string`){let t=e.trim();return t===``?null:t}return typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`?String(e):null}function n4(e,t){return e==null?null:t4(e[t])}function r4(e){let t=n4(e.metadata,$2),n=n4(e.metadata,e4);return t!==null&&n!==null?`${t} · ${n}`:t??n??null}function i4(e){if(e==null)return[];let t=[];for(let n of Object.keys(e)){let r=t4(e[n]);r!==null&&t.push({key:n,value:r})}return t}function a4(e){return n4(e.metadata,$2)!==null}function o4(e){return(n4(e.metadata,$2)??``).toLowerCase()}function s4(e){return(n4(e.metadata,e4)??``).toLowerCase()}function c4(e,t){let n=o4(e).localeCompare(o4(t));return n===0?s4(e).localeCompare(s4(t)):n}function l4({device:e}){let t=r4(e),n=i4(e.metadata);if(t===null&&n.length===0)return v(`span`,{className:`text-xs text-foreground-subtle/60`,children:`—`});let r=t??`—`;return n.length===0?v(`span`,{className:`block truncate text-xs text-foreground-subtle`,children:r}):c(Ul,{className:`block w-full min-w-0`,children:[v(Wl,{className:`block w-full min-w-0`,children:v(`span`,{className:`block truncate text-xs text-foreground-subtle`,children:r})}),v(Gl,{className:`whitespace-normal text-left max-w-xs`,children:v(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5`,children:n.map(e=>c(`div`,{className:`contents`,children:[v(`dt`,{className:`font-medium opacity-70`,children:e.key}),v(`dd`,{className:`break-words`,children:e.value})]},e.key))})})]})}E();function u4(e,t){let{dev:n,cap:r,online:i}=Zj({trpc:e,deviceId:t,cap:e=>e.deviceAdminLink,slice:()=>void 0}),a=n!==null&&r!=null&&(n.binding?.entries.some(e=>e.capName===`device-admin-link`)??!0),[o,s]=C({kind:`pending`});return b(()=>{if(!a||r==null){s({kind:`none`});return}let e=!0;try{r.getAdminLink({}).then(t=>{e&&s(t==null?{kind:`none`}:{kind:`link`,link:t})}).catch(()=>{e&&s({kind:`failed`})})}catch{s({kind:`failed`})}return()=>{e=!1}},[a,r,t]),o.kind!==`link`||o.link.target===`device`&&!i?null:o.link}function d4({trpc:e,deviceId:t,className:n,iconClassName:r}){let i=q(),a=u4(e,t);return a===null?null:v(`a`,{href:a.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation()},className:$(`inline-flex items-center justify-center rounded text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,n),title:`${a.label} — ${a.host}`,"aria-label":i(`uiLibrary.adminLinkQuickAction.open`,`Open {{label}} for this device`,{label:a.label}),children:v(Je,{className:$(`h-3 w-3`,r)})})}E();function f4(e){return e instanceof Error?e.message:String(e)}function p4({trpc:e,deviceId:t,deviceName:n}){let r=q(),{dev:i,cap:a}=Zj({trpc:e,deviceId:t,cap:e=>e.reboot,slice:()=>void 0}),[o,s]=C(!1),[l,u]=C(!1),[d,f]=C(null);if(i===null||a==null)return null;let p=e=>{e.stopPropagation(),f(null),s(!0)},m=async()=>{if(!l){f(null),u(!0);try{await a.reboot({}),s(!1)}catch(e){f(f4(e))}finally{u(!1)}}};return c(P,{children:[v(`button`,{type:`button`,onClick:p,className:$(`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`,o&&`bg-surface-hover text-foreground`),title:r(`uiLibrary.rebootQuickAction.rebootDevice`,`Reboot device`),"aria-label":r(`uiLibrary.rebootQuickAction.rebootDevice`,`Reboot device`),"aria-haspopup":`dialog`,"aria-expanded":o,children:v(Di,{className:`h-3 w-3`})}),v(SL,{open:o,onOpenChange:e=>{l||s(e)},children:c(TL,{width:`sm`,onClick:e=>e.stopPropagation(),children:[c(EL,{children:[c(kL,{className:`flex items-center gap-2`,children:[v(Di,{className:`h-4 w-4 text-amber-400`}),r(`uiLibrary.rebootQuickAction.rebootDeviceQuestion`,`Reboot device?`)]}),v(AL,{children:r(`uiLibrary.rebootQuickAction.description`,`This will restart {{deviceName}}. It may be unavailable for a moment.`,{deviceName:n})})]}),d!==null&&v(`div`,{className:`mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10 text-xs text-danger`,children:d}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:l,onClick:()=>{l||s(!1)},children:r(`uiLibrary.rebootQuickAction.cancel`,`Cancel`)}),c(_A,{type:`button`,variant:`danger`,size:`sm`,disabled:l,onClick:()=>{m()},children:[l&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),r(`uiLibrary.rebootQuickAction.reboot`,`Reboot`)]})]})]})})]})}E();var m4=[],h4=O(null);function g4({value:e,children:t}){return v(h4.Provider,{value:e,children:t})}function _4(e){return I(h4)?.get(e)??m4}E(),Do();var v4=new Set([J.Sensor,J.Presence]);function y4({trpc:e,device:t,controlPlacement:n}){let r=_4(t.id),i=vj(t,`compact`),a=n??`right`;if(t.disabled)return null;if(t.type===J.Container){let n=m2(r,t.linkDeviceId,t.primaryChildEntityId),i=n===null?void 0:r.find(e=>e.id===n.id);return i===void 0?null:v(b4,{trpc:e,child:i,placement:a})}let o=v4.has(t.type),s=(o?null:$0(t.type))?.InlineControl??null,l=e2(t.type,a),u=B2(t),d=(t.features??[]).includes(`rebootable`),f=(t.features??[]).includes(`pan-tilt-zoom`);return c(P,{children:[o&&c(fX,{align:e2(t.type,a),children:[u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),v(RZ,{trpc:e,device:t})]}),s!==null&&c(fX,{align:l,onClick:e=>e.stopPropagation(),children:[u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),v(s,{trpc:e,deviceId:t.id,features:t.features})]}),!o&&s===null&&u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),f&&v(w4,{trpc:e,deviceId:t.id}),d&&v(p4,{trpc:e,deviceId:t.id,deviceName:i}),v(d4,{trpc:e,deviceId:t.id})]})}function b4({trpc:e,child:t,placement:n}){if(v4.has(t.type))return v(fX,{align:e2(t.type,n),children:v(RZ,{trpc:e,device:t})});let r=$0(t.type)?.InlineControl??null;return r===null?null:v(fX,{align:e2(t.type,n),onClick:e=>e.stopPropagation(),children:v(r,{trpc:e,deviceId:t.id,features:t.features})})}function x4({trpc:e,deviceId:t,features:n}){let r=q(),{dev:i,cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.motionTrigger,slice:e=>e.state.motionTrigger,requireFeature:`motion-trigger`,deviceFeatures:n}),[c,l]=C(!1);if(i!==null&&!a)return null;let u=o?.enabled===!0,d=async e=>{if(e.stopPropagation(),!(c||!s||!a)){l(!0);try{await a.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:c||!s,className:$(`inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0`,u?`text-primary bg-primary/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,(c||!s)&&`opacity-50`),title:s?u?r(`uiLibrary.deviceItemActions.motionOn`,`Motion-trigger: on (click to disable)`):r(`uiLibrary.deviceItemActions.motionOff`,`Motion-trigger: off (click to enable)`):r(`uiLibrary.deviceItemActions.awaiting`,`Awaiting state…`),"aria-pressed":u,children:v(ai,{className:`h-2.5 w-2.5`})})}var S4=4,C4=300;function w4({trpc:e,deviceId:t}){let n=q(),r=f(null),i=f(null),[a,o]=C(null),s=a!==null,l=MI(e,t,{enabled:s}),u=()=>o(null),d=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(C4,window.innerWidth-16),i=Math.max(8,Math.min(t.right-n,window.innerWidth-n-8)),a=t.bottom+S4;o({top:a,left:i,width:n,maxHeight:Math.max(160,window.innerHeight-a-8)})};return b(()=>{if(!s)return;let e=e=>{let t=r.current,n=i.current,a=e.target;a!==null&&(t&&t.contains(a)||n&&n.contains(a)||u())},t=e=>{e.key===`Escape`&&(e.stopPropagation(),u())};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[s]),c(P,{children:[v(`button`,{ref:r,type:`button`,onClick:e=>{e.stopPropagation(),s?u():d()},className:$(`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`,s&&`bg-surface-hover text-foreground`),title:n(`uiLibrary.deviceItemActions.ptz`,`PTZ controls`),"aria-label":n(`uiLibrary.deviceItemActions.ptz`,`PTZ controls`),"aria-haspopup":`dialog`,"aria-expanded":s,children:v(Ce,{className:`h-3 w-3`})}),a&&Oo(v(`div`,{ref:i,style:{position:`fixed`,top:a.top,left:a.left,width:a.width,maxHeight:a.maxHeight},className:`z-[9999] overflow-y-auto rounded-lg border border-border bg-surface shadow-lg shadow-black/30`,onClick:e=>e.stopPropagation(),children:v(II,{mode:`panel`,controls:l})}),document.body)]})}E();var T4={},E4=O(T4);function D4({value:e,children:t}){return v(E4.Provider,{value:e,children:t})}function O4(){return I(E4)}function k4({children:e}){let{data:t}=Gp({},{staleTime:6e4});return v(D4,{value:t?.defaults??T4,children:e})}E();function A4({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r,parentName:i}){let a=q();return c(`div`,{className:`border-t border-border-subtle/50`,children:[n.length>0&&v(j4,{trpc:e,label:a(`uiLibrary.childrenAccordion.adoptedDevices`,`Adopted devices`),rows:n,onNavigate:r,parentName:i}),t.length>0&&v(j4,{trpc:e,label:a(`uiLibrary.childrenAccordion.accessories`,`Accessories`),rows:t,onNavigate:r,parentName:i})]})}function j4({trpc:e,label:t,rows:n,onNavigate:r,parentName:i}){return c(`div`,{children:[v(`div`,{className:`px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:t}),v(`ul`,{children:n.map(t=>v(M4,{trpc:e,child:t,onNavigate:r,parentName:i},t.id))})]})}function M4({trpc:e,child:t,onNavigate:n,parentName:r}){let i=q(),a=!t.disabled,o=a&&R2(t),s=a&&B2(t),l=O4();ms();let u=A2(t,l),d=qr(e,t.id,e=>e.runningState);return v(`li`,{children:c(`div`,{onClick:e=>{e.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:[v(bV,{running:d===void 0||d.running===null?null:d.running,children:v(u,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`})}),v(bj,{device:t,form:`nested`,parent:{id:t.parentDeviceId??0,name:r,type:`unknown`,stableId:``},className:`text-[10.5px] text-foreground flex-1 truncate`}),s&&v(P4,{trpc:e,deviceId:t.id,features:t.features}),o&&v(N4,{trpc:e,deviceId:t.id}),v(`span`,{className:$(`h-1.5 w-1.5 rounded-full flex-shrink-0`,t.online?`bg-success`:`bg-foreground-subtle/40`),title:t.online?i(`uiLibrary.childrenAccordion.online`,`Online`):i(`uiLibrary.childrenAccordion.offline`,`Offline`)})]})})}function N4({trpc:e,deviceId:t}){let n=q(),{dev:r,cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),[s,c]=C(!1);if(r!==null&&!i)return null;let l=a?.on===!0,u={transform:l?`translateX(14px)`:`translateX(2px)`},d=async e=>{if(e.stopPropagation(),!(s||!o||!i)){c(!0);try{await i.setState({on:!l})}finally{c(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:s||!o,className:$(`relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0`,l?`bg-success/30 border-success/50`:`bg-surface-hover border-border`,s&&`opacity-60`,!o&&`opacity-40 cursor-not-allowed`),title:o?l?n(`uiLibrary.childrenAccordion.turnOff`,`Turn off`):n(`uiLibrary.childrenAccordion.turnOn`,`Turn on`):n(`uiLibrary.childrenAccordion.awaitingState`,`Awaiting state…`),"aria-pressed":l,children:v(`span`,{className:$(`absolute h-3 w-3 rounded-full transition-all`,l?`bg-success`:`bg-foreground-subtle`),style:u})})}function P4({trpc:e,deviceId:t,features:n}){let r=q(),{dev:i,cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.motionTrigger,slice:e=>e.state.motionTrigger,requireFeature:`motion-trigger`,deviceFeatures:n}),[c,l]=C(!1);if(i!==null&&!a)return null;let u=o?.enabled===!0,d=async e=>{if(e.stopPropagation(),!(c||!s||!a)){l(!0);try{await a.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:c||!s,className:$(`inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0`,u?`text-primary bg-primary/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,(c||!s)&&`opacity-50`),title:s?u?r(`uiLibrary.childrenAccordion.motionTriggerOn`,`Motion-trigger: on (click to disable)`):r(`uiLibrary.childrenAccordion.motionTriggerOff`,`Motion-trigger: off (click to enable)`):r(`uiLibrary.childrenAccordion.awaitingState`,`Awaiting state…`),"aria-pressed":u,children:v(ai,{className:`h-2.5 w-2.5`})})}function F4({icon:e,label:t,onClick:n,danger:r=!1}){return v(`button`,{type:`button`,"aria-label":t,title:t,onClick:n,className:$(`inline-flex h-6 w-6 items-center justify-center rounded transition-colors flex-shrink-0`,r?`text-danger hover:bg-danger/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),children:v(e,{className:`h-3.5 w-3.5`})})}function I4({device:e,onDelete:t}){let n=q(),r=li(),i=vj(e,`full`),a=async()=>{let a=i.trim()===``?`#${String(e.id)}`:i;await r({title:n(`uiLibrary.deviceDeleteAction.title`,`Delete device?`),message:n(`uiLibrary.deviceDeleteAction.message`,`This will remove "{{label}}" and all its settings. This action cannot be undone.`,{label:a}),confirmLabel:n(`uiLibrary.deviceDeleteAction.confirm`,`Delete`),variant:`danger`})&&t(e)};return v(`span`,{onClick:e=>e.stopPropagation(),children:v(F4,{icon:Pe,label:n(`uiLibrary.deviceDeleteAction.deleteDevice`,`Delete device`),danger:!0,onClick:()=>{a()}})})}E();var L4=Object.freeze([]);function R4(e){return e===`native`?`native`:`enhanced`}function z4(e){return e.map(e=>({kind:`marker`,feature:e}))}function B4(e,t){let n=new Map,r=t.entries??[];for(let e of r)n.set(e.capName,e);let i=[];for(let t of e){let e=I2[t];if(e===void 0){i.push({kind:`marker`,feature:t});continue}let r=n.get(e);r&&i.push({kind:R4(r.kind),feature:t,capName:e})}return i}function V4(e,t,n){let[r,i]=C(null),[a,o]=C(!1),[s,c]=C(!0);return b(()=>{if(t===null){i(null),o(!1),c(!1);return}let n=!1;c(!0),o(!1);let r=async()=>{try{let r=await e.deviceManager.getBindings.query({deviceId:t});if(n)return;i(r),c(!1)}catch{if(n)return;o(!0),c(!1)}};r();let a=e.live?.onEvent.subscribe({category:`capability.binding-changed`},{onData:e=>{let n=e.data?.source;if(!n){r();return}n.type===`device`&&n.id===t&&r()}});return()=>{n=!0,a?.unsubscribe()}},[e,t]),n.length===0?{loading:s,resolved:L4}:s||a||!r?{loading:s,resolved:z4(n)}:{loading:!1,resolved:B4(n,r)}}E(),Do();var H4=[];function U4({trpc:e,device:t,flags:n,accessoryCount:r,adoptedCount:i,showFeatureRow:a=!1}){let o=r+i,s=n.showChildrenAccordion&&o>0,l=t.features??H4,u=a&&l.length>0,{resolved:d}=V4(e,u?t.id:null,l),f=u&&d.length>0;return!s&&!f?null:c(`div`,{className:`flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0`,children:[s&&v(W4,{accessoryCount:r,adoptedCount:i}),f&&v(q4,{resolved:d})]})}function W4({accessoryCount:e,adoptedCount:t}){let n=q(),r=e+t;return r===0?null:c(`span`,{className:`text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0`,title:t>0&&e>0?n(`uiLibrary.deviceItemFeatures.adoptedAndAccessories`,{one:`{{adopted}} adopted · {{count}} accessory`,other:`{{adopted}} adopted · {{count}} accessories`},{adopted:t,count:e}):t>0?n(`uiLibrary.deviceItemFeatures.adopted`,`{{count}} adopted`,{count:t}):n(`uiLibrary.deviceItemFeatures.accessories`,{one:`{{count}} accessory`,other:`{{count}} accessories`},{count:e}),children:[`+`,r]})}var G4=240,K4=200;function q4({resolved:e}){let t=f(null),[n,r]=C(null);return c(`span`,{ref:t,className:`relative inline-flex items-center gap-1 cursor-help`,onMouseEnter:()=>{let e=t.current;if(!e)return;let n=e.getBoundingClientRect();r({top:window.innerHeight-n.bottom>=K4?n.bottom+4:n.top-K4-4,left:Math.max(8,Math.min(n.left,window.innerWidth-G4-8))})},onMouseLeave:()=>r(null),children:[e.map(e=>{let t=P2[e.feature];return t?v(`span`,{className:`inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle`,title:F2[e.feature]??e.feature,children:v(t,{className:`h-2.5 w-2.5`})},e.feature):null}),n&&Oo(v(J4,{resolved:e,position:n}),document.body)]})}function J4({resolved:e,position:t}){let n=q();return c(`div`,{style:{position:`fixed`,top:t.top,left:t.left,width:G4,pointerEvents:`none`},className:`z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2`,children:[v(`h5`,{className:`text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:n(`uiLibrary.deviceItemFeatures.features`,`Features`)}),v(`ul`,{className:`space-y-0.5`,children:e.map(e=>v(Y4,{entry:e},e.feature))})]})}function Y4({entry:e}){let t=P2[e.feature],n=F2[e.feature]??e.feature;return c(`li`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[c(`span`,{className:`flex items-center gap-1.5 text-foreground`,children:[t&&v(t,{className:`h-3 w-3 text-foreground-subtle`}),v(`span`,{children:n})]}),v(X4,{kind:e.kind})]})}function X4({kind:e}){let t=q();return e===`marker`?v(`span`,{className:`text-[8.5px] px-1 rounded text-foreground-subtle`,title:t(`uiLibrary.deviceItemFeatures.markerTitle`,`Informational marker (no cap registered)`),children:t(`uiLibrary.deviceItemFeatures.marker`,`marker`)}):v(`span`,{className:$(`text-[8.5px] px-1 rounded`,e===`native`?`bg-success/15 text-success`:`bg-primary/15 text-primary`),children:e})}var Z4={horizontal:`h-3.5 w-3.5`,stacked:`h-4 w-4 mt-0.5`};function Q4({trpc:e,device:t,variant:n,flags:r,parent:i,integrationIcon:a,hasChildren:o,expanded:s,onToggleExpand:l,onNavigateToParent:u,stacked:d=!1,nameOverflow:f=`truncate`,nameForm:p=`compact`}){let m=q(),h=_4(t.id),g=O4();ms();let _=A2(U2(t,h),g),y=qr(e,t.id,e=>e.runningState),b=y===void 0||y.running===null?null:y.running,x=d?Z4.stacked:Z4.horizontal,S=$(`text-foreground-subtle flex-shrink-0`,d?`h-4 w-4 mt-0.5`:n===`minimal`?`h-3 w-3`:`h-3.5 w-3.5`),C=f===`scroll`?Q2:`truncate`,w=p===`nested`&&i!==null?{id:i.id,name:i.name,type:i.type??`unknown`,stableId:``}:void 0,T=yj(i?.id??0,`compact`,i?.name);return c(`div`,{className:$(d?`flex items-start gap-2 w-full min-w-0`:`flex items-center gap-2 flex-1 min-w-0`),children:[r.showChildrenAccordion&&o?v(`button`,{type:`button`,"data-testid":`chevron-slot`,onClick:e=>{e.stopPropagation(),l()},className:$(`flex items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,x),"aria-label":s?m(`uiLibrary.deviceItemHeader.collapseChildren`,`Collapse children`):m(`uiLibrary.deviceItemHeader.expandChildren`,`Expand children`),"aria-expanded":s,children:v(s?de:It,{className:`h-3 w-3`})}):r.showChildrenAccordion?v(`span`,{"data-testid":`chevron-slot`,className:$(`flex-shrink-0`,x)}):null,v(bV,{running:b,children:v(_,{className:S})}),c(`div`,{className:`flex-1 min-w-0`,children:[c(`div`,{className:$(`min-w-0`,d?`flex flex-col gap-1`:`flex items-center gap-1.5`),children:[r.showIntegrationIcon&&a&&v(`span`,{className:`flex-shrink-0`,children:a}),v(bj,{device:t,form:p,...w===void 0?{}:{parent:w},testId:`device-name`,className:$(`font-semibold text-foreground`,d?`text-[13px] leading-snug line-clamp-2 break-words`:$(C,n===`minimal`?`text-[10.5px]`:`text-[11px]`))})]}),(r.showId||r.showStableId)&&c(`div`,{className:$(`mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono`,C),title:r.showStableId?`stableId: ${t.stableId}`:void 0,children:[r.showId&&c(`span`,{className:`flex-shrink-0 tabular-nums`,children:[`#`,String(t.id)]}),r.showId&&r.showStableId&&v(`span`,{className:`flex-shrink-0 opacity-50`,children:`·`}),r.showStableId&&v(`span`,{className:C,children:W2(t.stableId)})]}),r.showParentBadge&&i&&c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u(i.id)},className:$(`mt-0.5 inline-flex items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors`,f===`scroll`?`md:max-w-full`:`max-w-full`),title:m(`uiLibrary.deviceItemHeader.openParent`,`Open parent: {{name}} (#{{id}})`,{name:T,id:i.id}),children:[v(De,{className:`h-2.5 w-2.5 shrink-0`}),v(`span`,{className:C,children:m(`uiLibrary.deviceItemHeader.under`,`Under: {{name}}`,{name:T})})]})]})]})}function $4(e,t){return qr(e,t,e=>e.battery)??null}function e3(e,t){return qr(e,t,e=>e.networkLink)??null}E(),Do();var t3=288,n3=196,r3=`h-7 w-7 rounded`,i3=8,a3=8;function o3({src:e,alt:t,caption:n,placeholder:r=`No image`,thumbClassName:i=r3,expandedWidth:a=t3,expandedHeight:o=n3}){let s=f(null),[l,u]=C(null),[d,p]=C(!1);b(()=>{p(!1)},[e]);let m=e!==null&&!d,h=e??void 0,g=_(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.top,r=window.innerHeight-t.bottom,i=n<o+i3&&r>n?t.bottom+i3:t.top-o-i3,c=t.right-a;u({top:i,left:Math.max(a3,Math.min(c,window.innerWidth-a-a3))})},[a,o]),y=_(()=>u(null),[]);return c(P,{children:[v(`button`,{ref:s,type:`button`,onClick:e=>e.stopPropagation(),onMouseEnter:g,onMouseLeave:y,onFocus:g,onBlur:y,"aria-label":t,className:`flex flex-shrink-0 items-center justify-center overflow-hidden border border-border bg-background text-foreground-subtle transition-colors hover:bg-surface-hover ${i}`,children:m?v(`img`,{src:h,alt:``,onError:()=>p(!0),className:`h-full w-full object-cover`}):v(ce,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),l&&Oo(c(`div`,{"aria-hidden":`true`,style:{position:`fixed`,top:l.top,left:l.left,width:a,pointerEvents:`none`},className:`z-[9999] overflow-hidden rounded-lg border border-border bg-surface shadow-lg shadow-black/30`,children:[v(`div`,{className:`flex h-40 items-center justify-center bg-background`,children:m?v(`img`,{src:h,alt:t,className:`h-full w-full object-cover`}):v(`span`,{className:`text-xs text-foreground-subtle`,children:r})}),v(`div`,{className:`px-3 py-2`,children:v(`p`,{className:`truncate text-xs font-semibold text-foreground`,children:n??t})})]}),document.body)]})}var s3=480;function c3({trpc:e,device:t,status:n,enabled:r,showStatusPills:i=!1}){let a=r&&t.online,o=vj(t,`compact`),s=Te(a?t.id:null,{width:s3}),l=(t.features??[]).includes(`battery-operated`),u=i&&l&&!t.disabled,d=$4(e,u?t.id:null),f=i&&!t.disabled,p=e3(e,f?t.id:null);if(!r&&!u&&!(f&&p))return null;let m=n===`offline`||n===`disabled`,h=n===`offline`?`Offline — no snapshot`:n===`disabled`?`Disabled`:`No snapshot yet`;return c(`span`,{className:`inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap`,children:[u&&d&&v(gV,{status:d}),f&&v(wV,{status:p}),r&&v(o3,{src:m?null:s.src,alt:o,placeholder:h,thumbClassName:`h-7 w-7 rounded`})]})}E();var l3=Kn(`camstack:device-quick-detail`,null);function u3({open:e,children:t}){return v(l3.Provider,{value:e,children:t})}function d3(){return I(l3)}function f3({deviceId:e,className:t}){let n=q(),r=d3();return r===null?null:v(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},className:$(`inline-flex items-center justify-center rounded text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,t),title:n(`uiLibrary.deviceQuickDetail.label`,`Quick detail`),"aria-label":n(`uiLibrary.deviceQuickDetail.label`,`Quick detail`),"data-testid":`device-quick-detail`,children:v(Yn,{className:`h-3 w-3`})})}function p3(e){return e===`online`||e===`recording-continuous`||e===`recording-events`}function m3(e,t,n){switch(e){case`disabled`:return n(`uiLibrary.statusDot.disabled`,`Disabled`);case`online`:return n(`uiLibrary.statusDot.online`,`Online`);case`recording-continuous`:return n(`uiLibrary.statusDot.recordingAlways`,`Recording · always`);case`recording-events`:return n(`uiLibrary.statusDot.recordingMotion`,`Recording · on motion`);case`offline`:{let e=s2(t,n);return e===null?n(`uiLibrary.statusDot.offline`,`Offline`):n(`uiLibrary.statusDot.offlineLastSeen`,`Offline · last seen {{lastSeen}}`,{lastSeen:e})}}}function h3(e){switch(e){case`disabled`:return`bg-black ring-1 ring-foreground-subtle/60`;case`offline`:return`bg-foreground-subtle`;case`recording-continuous`:return`bg-danger`;case`recording-events`:return`bg-info`;case`online`:return`bg-success`}}function g3({status:e,lastChangedAt:t}){let n=q();return v(`span`,{className:$(`h-1.5 w-1.5 rounded-full flex-shrink-0`,h3(e),p3(e)&&`animate-pulse`),title:m3(e,t,n)})}var _3=`Disabled`;function v3(e,t,n){let r=t.filter(e=>e.disabled!==!0),i=y3(t.filter(e=>e.disabled===!0));if(n===void 0||n.length===0)return{sections:[],ungrouped:r,disabledSection:i};let a=new Map;for(let e of r)a.set(e.stableId,e);let o=[],s=new Map,c=new Set;for(let t of n){let n=`${e}-${t.childKey}`,r=a.get(n);if(r===void 0)continue;let i=s.get(t.section);i===void 0&&(i={title:t.section,entries:[],collapsed:!1},s.set(t.section,i),o.push(t.section)),i.entries.push({child:r,order:t.order??2**53-1}),t.collapsed===!0&&(i.collapsed=!0),c.add(r.id)}return{sections:o.map(e=>{let t=s.get(e),n=[...t===void 0?[]:t.entries].toSorted((e,t)=>e.order===t.order?e.child.name.localeCompare(t.child.name):e.order-t.order),r=t===void 0?!0:!t.collapsed;return{title:e,children:n.map(e=>e.child),defaultOpen:r}}),ungrouped:r.filter(e=>!c.has(e.id)),disabledSection:i}}function y3(e){if(e.length!==0)return{title:_3,children:[...e].toSorted((e,t)=>e.name.localeCompare(t.name)),defaultOpen:!1,muted:!0}}E();function b3({title:e,count:t,children:n,defaultOpen:r=!0}){let[i,a]=C(r);return c(`div`,{className:`rounded-md border border-border-subtle/50`,children:[c(`button`,{type:`button`,onClick:()=>a(e=>!e),className:$(`w-full flex items-center gap-1.5 px-2 py-1.5 text-left transition-colors`,`hover:bg-surface-hover`),"aria-expanded":i,children:[v(i?de:It,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle flex-1 truncate`,children:e}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle/70 tabular-nums`,children:t})]}),i&&v(`div`,{className:`space-y-1 px-1 pb-1.5`,children:n})]})}E();function x3(e){let t=q(),{trpc:n,device:r,parent:i,integrationIcon:a,onNavigate:o,className:s,renderRowAction:l,onDelete:u,selection:d}=e,f=k2(e),p=e.variant??`compact`,m=e.view??`card`,h=e.isAccessoryRow?`nested`:`compact`,g=h===`nested`&&i?{id:i.id,name:i.name,type:i.type??`unknown`,stableId:``}:void 0,_=vj(r,h,g===void 0?void 0:{parent:g}),y=!r.disabled,b=r.isCamera??r.type.toLowerCase()===`camera`,x=e.children??[],S=x.filter(z2),w=x.filter(e=>!z2(e)),T=x.length>0,[E,D]=C(!1),O=e.expanded??E,k=e.onToggleExpand??(()=>D(e=>!e)),A=e=>{o?.(e)},j=e.rowClickSelects===!0&&d!==void 0,M=()=>{if(j&&d!==void 0){d.onToggle();return}A(r.id)},N=e.indentLevel??(e.isAccessoryRow?2:0),P=V2(r,x),F=y?P?`online`:`offline`:`disabled`;return m===`table`?v(C3,{trpc:n,device:r,variant:p,flags:f,parent:i??null,integrationIcon:a??null,accessoryCount:S.length,adoptedCount:w.length,hasChildren:T,expanded:O,onToggleExpand:k,onRowClick:M,rowSelects:j,rowSelected:d?.selected??!1,onNavigate:A,displayStatus:F,isCamera:b,showSnapshot:f.showSnapshot&&b,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:N,className:s,renderRowAction:l??null,onDelete:u??null,selection:d,showTypeCell:e.showTypeCell??!0,showManufacturerCell:e.showManufacturerCell??!0,showFeaturesCell:e.showFeaturesCell??!0}):p===`minimal`?c(`div`,{className:$(`rounded-lg border border-border bg-surface transition-colors`,!y&&`opacity-60`,s),children:[c(`div`,{"data-testid":`device-card-body`,onClick:M,...j?{role:`button`,"aria-pressed":d?.selected??!1,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M())}}:{},className:$(`flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full px-2.5 py-1.5`,d?.selected&&`bg-primary/10`),children:[d&&v(`input`,{type:`checkbox`,checked:d.selected,onChange:d.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:_}),className:`flex-shrink-0`}),v(Q4,{trpc:n,device:r,variant:p,flags:f,parent:i??null,nameForm:h,integrationIcon:a??null,hasChildren:T,expanded:O,onToggleExpand:k,onNavigateToParent:A}),v(U4,{trpc:n,device:r,flags:f,accessoryCount:S.length,adoptedCount:w.length,showFeatureRow:!1}),v(c3,{trpc:n,device:r,status:F,enabled:f.showSnapshot&&b,showStatusPills:!0}),v(y4,{trpc:n,device:r,flags:f,controlPlacement:`right`}),v(f3,{deviceId:r.id}),l&&v(`span`,{onClick:e=>e.stopPropagation(),children:l(r)}),v(g3,{status:F})]}),O&&T&&v(A4,{trpc:n,accessoryChildren:S,adoptedChildren:w,onNavigate:A,parentName:r.name})]}):c(`div`,{className:$(`group rounded-xl border border-border bg-surface transition-colors`,`hover:border-foreground-subtle/30`,!y&&`opacity-60`,s),children:[c(`div`,{"data-testid":`device-card-body`,onClick:M,...j?{role:`button`,"aria-pressed":d?.selected??!1,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M())}}:{},className:$(`flex flex-col gap-2 cursor-pointer w-full p-3 rounded-xl`,d?.selected&&`bg-primary/10`),children:[c(`div`,{className:`flex items-start justify-between gap-2`,children:[d&&v(`input`,{type:`checkbox`,checked:d.selected,onChange:d.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:_}),className:`flex-shrink-0 mt-0.5`}),v(Q4,{trpc:n,device:r,variant:p,flags:f,parent:i??null,nameForm:h,integrationIcon:a??null,hasChildren:T,expanded:O,onToggleExpand:k,onNavigateToParent:A,stacked:!0}),v(g3,{status:F})]}),v(U4,{trpc:n,device:r,flags:f,accessoryCount:S.length,adoptedCount:w.length,showFeatureRow:!1}),c(`div`,{className:`flex items-center justify-end gap-1.5`,children:[v(c3,{trpc:n,device:r,status:F,enabled:f.showSnapshot&&b,showStatusPills:!0}),v(y4,{trpc:n,device:r,flags:f,controlPlacement:`right`}),v(f3,{deviceId:r.id}),l&&v(`span`,{onClick:e=>e.stopPropagation(),children:l(r)})]})]}),O&&T&&v(A4,{trpc:n,accessoryChildren:S,adoptedChildren:w,onNavigate:A,parentName:r.name})]})}var S3={0:`pl-2`,1:`pl-6`,2:`pl-8`};function C3(e){let t=q(),{trpc:n,device:r,variant:i,flags:a,parent:o,integrationIcon:s,accessoryCount:l,adoptedCount:u,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:m,onRowClick:h,rowSelects:g,rowSelected:_,displayStatus:y,isCamera:b,showSnapshot:x,isAccessoryRow:S,indentLevel:C,className:w,renderRowAction:T,onDelete:E,selection:D,showTypeCell:O,showManufacturerCell:k,showFeaturesCell:A}=e,j=_4(r.id),M=S?`nested`:`compact`,N=M===`nested`&&o?{id:o.id,name:o.name,type:o.type??`unknown`,stableId:``}:void 0,P=vj(r,M,N===void 0?void 0:{parent:N});return c(`tr`,{onClick:h,...g?{role:`button`,"aria-pressed":_,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),h())}}:{},className:$(`group cursor-pointer hover:bg-surface-hover transition-colors`,!d&&`border-b border-border-subtle/40`,S&&`bg-foreground-subtle/[0.03]`,_&&`bg-primary/10`,w),children:[v(`td`,{className:$(X2,`py-1.5 align-middle pr-2 transition-colors`,_?`bg-primary/10 group-hover:bg-surface-hover`:S?`bg-surface-subtle group-hover:bg-surface-hover`:`bg-surface group-hover:bg-surface-hover`,Z2,`min-w-0 overflow-hidden`,S3[C]),children:c(`div`,{className:`flex items-center gap-1.5`,children:[D&&v(`input`,{type:`checkbox`,checked:D.selected,onChange:D.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:P}),className:`flex-shrink-0`}),v(Q4,{trpc:n,device:r,variant:i,flags:a,parent:o,nameForm:M,integrationIcon:s,hasChildren:d,expanded:f,onToggleExpand:p,onNavigateToParent:m,nameOverflow:`scroll`})]})}),O&&v(`td`,{className:$(Y2.type,`px-2 py-1.5 align-middle text-[10px] text-foreground-subtle whitespace-nowrap`),children:H2(r,j)}),k&&v(`td`,{className:$(Y2.manufacturer,`px-2 py-1.5 align-middle w-40 max-w-[10rem] min-w-0 overflow-hidden`),children:v(l4,{device:r})}),A&&v(`td`,{className:$(Y2.features,`px-2 py-1.5 align-middle`),children:v(U4,{trpc:n,device:r,flags:a,accessoryCount:l,adoptedCount:u,showFeatureRow:!0})}),v(`td`,{className:`px-2 py-1.5 align-middle text-right whitespace-nowrap`,children:c(`span`,{className:`inline-flex items-center justify-end gap-1.5`,children:[v(y4,{trpc:n,device:r,flags:a,controlPlacement:`table`}),v(c3,{trpc:n,device:r,status:y,enabled:x&&b,showStatusPills:!0}),v(f3,{deviceId:r.id}),T&&v(`span`,{onClick:e=>e.stopPropagation(),children:T(r)}),E&&v(I4,{device:r,onDelete:E}),v(g3,{status:y})]})})]})}function w3(e){let t=new Map;for(let n of e)t.set(n.id,n);return e.filter(e=>{if(e.parentDeviceId===null||e.parentDeviceId===void 0)return!0;let n=t.get(e.parentDeviceId);return n?T3.has(n.type.toLowerCase()):!0})}var T3=new Set([`hub`,`nvr`]);function E3(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=[];for(let i of e){let e=i.parentDeviceId;if(e!=null&&e!==i.id&&t.has(e)){let t=n.get(e);t?t.push(i):n.set(e,[i]);continue}r.push(i)}let i=[],a=new Set,o=e=>{if(a.has(e.id))return;a.add(e.id),i.push(e);let t=n.get(e.id);if(t)for(let e of t)o(e)};for(let e of r)o(e);for(let t of e)o(t);return i}function D3(e,t){let n=t?.includeHidden??!1,r=new Map;for(let t of e)r.set(t.id,t);let i=[],a=new Map;for(let t of e){if(!n&&t.display?.hidden===!0)continue;let e=t.parentDeviceId;if(e==null){i.push(t);continue}let o=r.get(e);if(!o){i.push(t);continue}let s=t.role!==null&&t.role!==void 0;if(T3.has(o.type)&&!s){i.push(t);continue}let c=a.get(e);c?c.push(t):a.set(e,[t])}return{topLevel:E3(i),accessoriesByParent:a}}function O3(e,t=Fn){return e===0?t(`uiLibrary.pageSizeSelect.all`,`All`):String(e)}function k3({value:e,options:t,onChange:n,ariaLabel:r}){let i=q();return c(`div`,{className:`inline-flex items-center gap-1.5`,children:[v(`span`,{"aria-hidden":`true`,children:i(`uiLibrary.pageSizeSelect.perPage`,`Per page`)}),v(`select`,{"aria-label":r,value:e,onChange:e=>n(Number.parseInt(e.target.value,10)),className:`h-7 px-1.5 rounded-md border border-border bg-surface text-[11px] text-foreground focus:outline-none focus:ring-1 focus:ring-primary/40`,children:t.map(e=>v(`option`,{value:e,children:O3(e,i)},e))})]})}E();function A3({label:e,options:t,selected:n,onChange:r}){let i=f(null),[a,o]=C(null);b(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0];t&&o(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let s=new Set(n),l=e=>{let n=new Set(s);n.has(e)?n.delete(e):n.add(e),r(t.filter(e=>n.has(e.id)).map(e=>e.id))},u=56+t.length*88;return v(`div`,{ref:i,className:`min-w-0 flex-1`,children:a!==null&&a>=u?c(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[v(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-foreground-subtle`,children:e}),t.map(e=>{let t=s.has(e.id),n=e.icon;return c(`button`,{type:`button`,onClick:()=>l(e.id),"aria-pressed":t,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors ${t?`border-primary/40 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[n&&v(n,{className:`h-3 w-3 shrink-0`}),e.label]},e.id)})]}):v(AG,{label:e,options:t,selected:n,onChange:r})})}E();function j3({typeOptions:e,selectedTypes:t,onTypesChange:n,addons:r,selectedAddons:i,onAddonsChange:a,hideAddons:o=!1,query:s=``,onClearFilters:l}){let u=q(),d=t.length>0||i.length>0||s.trim().length>0;return c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e&&e.length>0&&v(A3,{label:u(`uiLibrary.filterChips.type`,`Type`),options:e,selected:t,onChange:n}),!o&&r&&r.length>0&&v(M3,{addons:r,selected:i,onChange:a}),l!==void 0&&d&&c(`button`,{type:`button`,onClick:l,className:`inline-flex items-center gap-1 h-7 rounded-md border border-border bg-surface px-2 text-[10.5px] text-foreground-subtle transition-colors hover:text-foreground hover:border-foreground-subtle/40`,children:[v(Zn,{className:`h-3 w-3`}),u(`uiLibrary.filterChips.clearFilters`,`Clear filters`)]})]})}function M3({addons:e,selected:t,onChange:n}){let r=q(),[i,a]=C(!1),o=f(null);b(()=>{if(!i)return;let e=e=>{let t=e.target;t&&o.current&&!o.current.contains(t)&&a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=new Set(t),l=t.length,u=t=>{let r=new Set(s);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e.id)).map(e=>e.id))};return c(`div`,{ref:o,className:`relative`,children:[c(`button`,{type:`button`,onClick:()=>a(e=>!e),className:$(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors`,l>0?`border-primary/40 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),"aria-haspopup":`listbox`,"aria-expanded":i,children:[v(`span`,{children:l>0?r(`uiLibrary.filterChips.integrationCount`,`Integration · {{count}}`,{count:l}):r(`uiLibrary.filterChips.integration`,`Integration`)}),v(de,{className:$(`h-3 w-3 transition-transform`,i&&`rotate-180`)})]}),i&&c(`div`,{role:`listbox`,className:`absolute left-0 top-full mt-1 z-30 min-w-[180px] max-h-72 overflow-y-auto rounded-lg border border-border bg-surface shadow-xl py-1`,children:[l>0&&v(`button`,{type:`button`,onClick:()=>n([]),className:`flex w-full items-center px-3 py-1.5 text-left text-[10.5px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:r(`uiLibrary.filterChips.clearSelection`,`Clear selection`)}),e.map(e=>{let t=s.has(e.id);return c(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>u(e.id),className:$(`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[10.5px] transition-colors`,t?`text-primary`:`text-foreground hover:bg-surface-hover`),children:[v(`span`,{className:$(`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,t?`border-primary bg-primary/20`:`border-border`),children:t&&v(dt,{className:`h-2.5 w-2.5`})}),e.icon&&v(`span`,{className:`inline-flex items-center`,children:e.icon}),v(`span`,{className:`truncate`,children:e.name})]},e.id)})]})]})}function N3(e,t){switch(e){case`nofilter`:return t(`uiLibrary.deviceListEmptyState.noDevices`,`No devices yet`);case`filtered`:return t(`uiLibrary.deviceListEmptyState.noMatch`,`No devices match the current filters`);case`pending`:return t(`uiLibrary.deviceListEmptyState.loadingIntegrations`,`Loading integrations…`)}}function P3({variant:e,onClearFilters:t}){let n=q();return c(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[v(dee,{className:`h-8 w-8 text-foreground-subtle/40 mb-3`}),v(`p`,{className:`text-sm font-medium text-foreground-subtle`,children:N3(e,n)}),e===`filtered`&&t&&v(`button`,{type:`button`,onClick:t,className:`mt-2 text-[11px] text-primary hover:underline`,children:n(`uiLibrary.deviceListEmptyState.clearFilters`,`Clear filters`)})]})}E();function F3(e){return e?e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0):[]}function I3(e,t){if(e===`root`)return t===`addons`?`addon`:t===`types`?`type`:t;switch(t){case`view`:return`deviceView`;case`page`:return`devicePage`;case`types`:return`deviceType`;case`q`:return`deviceQ`;case`addons`:return`deviceAddon`}}function L3(e){try{let t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};let n=JSON.parse(t);return typeof n!=`object`||!n?{}:n}catch{return{}}}function R3(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function z3(e,t){let n=new URLSearchParams(window.location.search),r=n.get(I3(e,`page`)),i=r?parseInt(r,10):1;return{page:Number.isFinite(i)&&i>=1?i:1,addons:F3(n.get(I3(e,`addons`))??t.addon??null),types:F3(n.get(I3(e,`types`))??t.type??null),q:n.get(I3(e,`q`))??t.q??``}}function B3(e,t){let n=new URLSearchParams(window.location.search),r=(e,t)=>{t===null||t===``?n.delete(e):n.set(e,t)};r(I3(e,`view`),null),r(I3(e,`page`),t.page===1?null:String(t.page)),r(I3(e,`addons`),t.addons.length>0?t.addons.join(`,`):null),r(I3(e,`types`),t.types.length>0?t.types.join(`,`):null),r(I3(e,`q`),t.q||null);let i=n.toString(),a=i?`${window.location.pathname}?${i}`:window.location.pathname;window.history.replaceState(null,``,a)}function V3(e){let{scope:t,lsKey:n}=e,[r,i]=C(()=>z3(t,L3(n))),a=f(r);a.current=r,b(()=>{let e=()=>{let e=z3(t,L3(n));a.current=e,i(e)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[t,n]);let o=_(e=>{let r=e(a.current);a.current=r,i(r),B3(t,r),R3(n,{addon:r.addons.length>0?r.addons.join(`,`):null,type:r.types.length>0?r.types.join(`,`):null,q:r.q})},[t,n]);return{state:r,setPage:_(e=>o(t=>({...t,page:e})),[o]),setAddons:_(e=>o(t=>({...t,addons:e,page:1})),[o]),setTypes:_(e=>o(t=>({...t,types:e,page:1})),[o]),setQ:_(e=>o(t=>({...t,q:e,page:1})),[o]),clearFilters:_(()=>o(e=>({...e,addons:[],types:[],q:``,page:1})),[o])}}function H3({columnId:e,label:t,sort:n,onSort:r}){let i=n!==null&&n.columnId===e;return v(cU,{label:v(`span`,{className:`uppercase tracking-wider`,children:t}),active:i,dir:i?n.dir:`asc`,onSort:()=>r(e)})}E();function U3(e,t){return e===null||e.columnId!==t?`none`:e.dir===`asc`?`ascending`:`descending`}var W3=new Set([`hub`,`nvr`]);function G3(e,t){return e.parentDeviceId===null||t===null?0:+!!W3.has(t.toLowerCase())}function lae({rows:e,accessoriesByParent:t,expandedParents:n,onToggleExpand:r,devices:i,visibleColumns:a,trpc:o,resolveIntegrationIcon:s,resolveParent:l,onNavigate:u,renderRowAction:d,onDeleteDevice:f,selectable:m,rowClickSelects:h,activeSelected:g,onToggleSelection:_,sort:y,onSort:b}){let x=q(),S=a.includes(`type`),C=a.includes(`features`),w=a.includes(`manufacturer`),T=a.includes(`icon`),E=p(()=>{let e=new Map;for(let t of i)e.set(t.id,t.type);return e},[i]);return v(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:c(`table`,{className:`w-full border-collapse`,children:[v(`thead`,{children:c(`tr`,{className:`border-b border-border`,children:[v(`th`,{"aria-sort":U3(y,`name`),className:$(X2,Z2,`bg-surface text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle`),children:v(H3,{columnId:`name`,label:x(`uiLibrary.deviceTable.name`,`Name`),sort:y,onSort:b})}),S&&v(`th`,{"aria-sort":U3(y,`type`),className:$(Y2.type,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24`),children:v(H3,{columnId:`type`,label:x(`uiLibrary.deviceTable.type`,`Type`),sort:y,onSort:b})}),w&&v(`th`,{"aria-sort":U3(y,`manufacturer`),className:$(Y2.manufacturer,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-40`),children:v(H3,{columnId:`manufacturer`,label:x(`uiLibrary.deviceTable.hardware`,`Hardware`),sort:y,onSort:b})}),C&&v(`th`,{className:$(Y2.features,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32`),children:x(`uiLibrary.deviceTable.features`,`Features`)}),v(`th`,{className:`text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32`,children:x(`uiLibrary.deviceTable.preview`,`Preview`)})]})}),v(`tbody`,{children:e.map(e=>{let i=t.get(e.id)??[],a=i.length>0,c=e.parentDeviceId===null?null:l?.(e.parentDeviceId)??null,p=e.parentDeviceId===null?null:E.get(e.parentDeviceId)??null,y=m?{selected:g.has(e.id),onToggle:()=>_(e.id)}:void 0;return v(uae,{parent:e,accessories:i,hasAccessories:a,expanded:n.has(e.id),onToggleExpand:()=>r(e.id),trpc:o,integrationIcon:T?s?.(e)??null:null,showType:S,showManufacturer:w,showFeatures:C,parentRowParent:c,indentLevel:G3(e,p),onNavigate:u??null,renderRowAction:d??null,onDeleteDevice:f,selection:y,rowClickSelects:h},e.id)})})]})})}function uae({parent:e,accessories:t,hasAccessories:n,expanded:r,onToggleExpand:i,trpc:a,integrationIcon:o,showType:s,showManufacturer:l,showFeatures:u,parentRowParent:d,indentLevel:f,onNavigate:m,renderRowAction:h,onDeleteDevice:g,selection:_,rowClickSelects:y}){let b=n&&r,x=p(()=>v3(e.stableId,t,e.childLayout),[e.stableId,e.childLayout,t]),[S,w]=C(()=>{let e=x.sections.filter(e=>!e.defaultOpen).map(e=>e.title);return x.disabledSection!==void 0&&!x.disabledSection.defaultOpen&&e.push(x.disabledSection.title),new Set(e)}),T=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),E=2+ +!!s+ +!!l+ +!!u,D=x.disabledSection;return c(P,{children:[v(x3,{trpc:a,device:e,view:`table`,integrationIcon:o,parent:d,children:t,onNavigate:m??void 0,showChildrenAccordion:!0,expanded:r,onToggleExpand:i,indentLevel:f,renderRowAction:h??void 0,onDelete:g??void 0,selection:_,rowClickSelects:y,showTypeCell:s,showManufacturerCell:l,showFeaturesCell:u}),b&&x.ungrouped.map(t=>v(K3,{trpc:a,accessory:t,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m},t.id)),b&&x.sections.map(t=>{let n=!S.has(t.title);return v(q3,{title:t.title,count:t.children.length,open:n,colSpan:E,onToggle:()=>T(t.title),rows:t.children,trpc:a,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m},t.title)}),b&&D!==void 0&&v(q3,{title:D.title,count:D.children.length,open:!S.has(D.title),colSpan:E,onToggle:()=>T(D.title),rows:D.children,trpc:a,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m,muted:!0},D.title)]})}function K3({trpc:e,accessory:t,parentName:n,showType:r,showManufacturer:i,showFeatures:a,onNavigate:o,muted:s}){return v(x3,{trpc:e,device:t,view:`table`,integrationIcon:null,parent:t.parentDeviceId===null?null:{id:t.parentDeviceId,name:n},isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:o??void 0,showTypeCell:r,showManufacturerCell:i,showFeaturesCell:a,className:s===!0?`opacity-60`:void 0})}function q3({title:e,count:t,open:n,colSpan:r,onToggle:i,rows:a,trpc:o,parentName:s,showType:l,showManufacturer:u,showFeatures:d,onNavigate:f,muted:p}){return c(P,{children:[v(`tr`,{className:$(`border-b border-border-subtle/40 bg-surface`,p===!0&&`opacity-60`),children:v(`td`,{colSpan:r,className:`p-0`,children:c(`button`,{type:`button`,onClick:i,className:`w-full flex items-center gap-1.5 pl-8 pr-2 py-1 text-left hover:bg-surface-hover transition-colors`,"aria-expanded":n,children:[v(n?de:It,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle flex-1 truncate`,children:e}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle/70 tabular-nums`,children:t})]})})}),n&&a.map(e=>v(K3,{trpc:o,accessory:e,parentName:s,showType:l,showManufacturer:u,showFeatures:d,onNavigate:f,muted:p},e.id))]})}function J3(e){return Yo(e.type).label.toLowerCase()}function Y3(e){return e.name.toLowerCase()}function dae(e){return e===`name`?(e,t)=>Y3(e).localeCompare(Y3(t)):e===`type`?(e,t)=>J3(e).localeCompare(J3(t)):c4}function X3(e,t){let n=lU(e!==null&&e.columnId===t,e===null?null:e.dir);return n===null?null:{columnId:t,dir:n}}function Z3(e,t){if(t===null)return[...e];let n=dae(t.columnId),r=t.dir===`asc`?1:-1;return E3([...e].toSorted((e,i)=>{if(t.columnId===`manufacturer`){let t=a4(e);if(t!==a4(i))return t?-1:1}return r*n(e,i)}))}E();var fae={cards:24,table:50};function pae(e){let t=q(),{devices:n,trpc:r,context:i=`devices`,filters:a,forceIntegrationId:o,integrationOf:s,resolveIntegrationIcon:l,resolveParent:u,onNavigate:d,pageSize:f=fae,urlScope:m=`root`,lsKey:h=m===`root`?`devices`:`integrations:nested`,renderRowAction:g,onDeleteDevice:y,selectable:x=!1,selectedIds:S,onSelectionChange:w,batchActions:T}=e,[E,D]=C(!1),[O,k]=C(new Set),A=S??O,j=e=>{let t=new Set(A);t.has(e)?t.delete(e):t.add(e),S===void 0&&k(t),w?.(t)},M=()=>{S===void 0?k(new Set):w?.(new Set)},N=()=>{M(),D(!1)},P=x||T!==void 0&&E,F=T!==void 0&&E,I=p(()=>q2(i),[i]),[L,R]=C(null),z=e=>R(t=>X3(t,e)),B=a?.typeOptions,V=p(()=>B??es(t),[B,t]),H=V3({scope:m,lsKey:h}),[U,ee]=E2(f.table),W=U,[G,te]=C(H.state.q),ne=HJ(G,300);b(()=>{ne!==H.state.q&&H.setQ(ne)},[ne]);let re=p(()=>o===void 0?H.state.addons:[o],[o,H.state.addons]),K=_(e=>s===void 0?{kind:`unknown`}:s(e),[s]),ie=p(()=>{let e=new Map;for(let t of n){if(t.parentDeviceId===null||t.parentDeviceId===void 0)continue;let n=e.get(t.parentDeviceId);n?n.push(t):e.set(t.parentDeviceId,[t])}return e},[n]),ae=p(()=>{let e=H.state.q,t=re.length>0?new Set(re):null,r=H.state.types.length>0?new Set(H.state.types):null;return n.filter(n=>!(t&&!mae(K(n),t)||r&&!r.has(H2(n,ie.get(n.id)))||e.trim()!==``&&!SG(e,n.name)&&!SG(e,n.stableId)))},[n,ie,re,K,H.state.types,H.state.q]),oe=p(()=>D3(ae),[ae]),se=p(()=>l===void 0?null:e=>l(e,K(e)),[l,K]),ce=p(()=>Z3(oe.topLevel,L),[oe.topLevel,L]),[le,ue]=C(()=>new Set),de=_(e=>{ue(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),fe=oe.topLevel.length,pe=Math.max(1,Math.ceil(fe/W)),me=Math.min(H.state.page,pe),he=(me-1)*W,ge=ce.slice(he,he+W);b(()=>{me!==H.state.page&&H.setPage(me)},[me]),hae();let _e=re.length>0||H.state.types.length>0||H.state.q!==``,ve=fe===0,ye=p(()=>re.length>0&&n.some(e=>K(e).kind===`unknown`),[re,n,K]);return c(`div`,{className:`flex flex-col gap-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[v(j3,{typeOptions:V,selectedTypes:H.state.types,onTypesChange:H.setTypes,addons:a?.integrations,selectedAddons:H.state.addons,query:H.state.q,onClearFilters:()=>{te(``),H.clearFilters()},onAddonsChange:H.setAddons,hideAddons:o!==void 0}),c(`div`,{className:`flex items-center gap-2`,children:[T!==void 0&&(E?c(`button`,{type:`button`,onClick:N,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border bg-surface text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[v(Zn,{className:`h-3 w-3`}),t(`uiLibrary.deviceModeList.done`,`Done`)]}):c(`button`,{type:`button`,onClick:()=>D(!0),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border bg-surface text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[v(Or,{className:`h-3 w-3`}),t(`uiLibrary.deviceModeList.select`,`Select`)]})),c(`div`,{className:`relative`,children:[v(Ci,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none`}),v(`input`,{type:`text`,value:G,onChange:e=>te(e.target.value),placeholder:t(`uiLibrary.deviceModeList.searchPlaceholder`,`Search by name or stableId`),"aria-label":t(`uiLibrary.deviceModeList.searchAria`,`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`})]})]})]}),T!==void 0&&E&&v(y2,{selectedIds:A,onClear:M,remove:T.remove,disable:T.disable,enable:T.enable}),ve?v(P3,{variant:ye?`pending`:_e?`filtered`:`nofilter`,onClearFilters:_e&&!ye?H.clearFilters:void 0}):v(g4,{value:oe.accessoriesByParent,children:v(lae,{rows:ge,accessoriesByParent:oe.accessoriesByParent,expandedParents:le,onToggleExpand:de,visibleColumns:I,sort:L,onSort:z,devices:ae,trpc:r,resolveIntegrationIcon:se,resolveParent:u??null,onNavigate:d??null,renderRowAction:g??null,onDeleteDevice:y??null,selectable:P,rowClickSelects:F,activeSelected:A,onToggleSelection:j})}),!ve&&c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[c(`div`,{className:`inline-flex items-center gap-2`,children:[fe<=U&&v(`span`,{children:t(`uiLibrary.deviceModeList.deviceCount`,{one:`{{count}} device`,other:`{{count}} devices`},{count:fe})}),v(k3,{ariaLabel:t(`uiLibrary.deviceModeList.devicesPerPage`,`Devices per page`),value:U,options:w2,onChange:ee})]}),v(ZM,{currentPage:me,totalItems:fe,pageSize:W,onPageChange:H.setPage})]}),o===void 0&&_e&&fe>0&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:re.length>0?v(gi,{uiKey:`uiLibrary.deviceModeList.showingFiltered`,fallback:{one:`Showing {{shown}} of {{count}} device · filtered by <0>{{names}}</0>`,other:`Showing {{shown}} of {{count}} devices · filtered by <0>{{names}}</0>`},components:[v(`strong`,{className:`text-primary`},`names`)],values:{shown:fe,count:w3(n).length,names:re.map(e=>a?.integrations?.find(t=>t.id===e)?.name??e).join(`, `)}}):t(`uiLibrary.deviceModeList.showing`,{one:`Showing {{shown}} of {{count}} device`,other:`Showing {{shown}} of {{count}} devices`},{shown:fe,count:w3(n).length})})]})}function mae(e,t){return e.kind===`resolved`&&t.has(e.integration.id)}function hae(){k()}E();var gae=100;function _ae(e){let t=q(),{items:n,getKey:r,getSearchText:i,renderItem:a,getFilterType:o,mapFilterOption:s,filterOptions:l,filterLabel:u=`Type`,initialTypeFilters:m=[],columns:h,renderExpanded:g,isExpanded:_,rowClassName:y,onRowClick:x,isLoading:S=!1,searchPlaceholder:w=`Search`,emptyLabel:T=`No items found.`,pageSize:E=gae,pageSizeSelector:D,toolbar:O}=e,[k,A]=S2(D??{storageKey:null,options:[E],defaultSize:E}),[j,M]=C(``),N=f(null);As(N);let P=HJ(j,300),[F,I]=C(()=>[...m]),[L,R]=C(1);b(()=>{R(1)},[P,F]);let z=p(()=>{if(!o)return[];if(l)return l;let e=new Set;for(let t of n){let n=o(t);n!==null&&n!==``&&e.add(n)}return[...e].toSorted().map(e=>{let t=s?.(e);return{id:e,label:t?.label??e,...t?.icon?{icon:t.icon}:{}}})},[n,o,s,l]),B=p(()=>new Set(F),[F]),V=p(()=>{let e=P;return n.filter(t=>{if(B.size>0&&o){let e=o(t);if(e===null||!B.has(e))return!1}return!(e.trim()!==``&&!SG(e,i(t)))})},[n,P,i,B,o]),H=V.length,U=D?C2(k,H):E,ee=Math.max(1,Math.ceil(H/U)),W=Math.min(L,ee),G=(W-1)*U,te=V.slice(G,G+U);return b(()=>{W!==L&&R(W)},[W,L]),c(`div`,{className:`flex flex-col gap-3 h-full min-h-0`,children:[c(`div`,{className:`flex items-center justify-between gap-3 flex-wrap shrink-0`,children:[o&&z.length>0?v(A3,{label:u,options:z,selected:F,onChange:I}):v(`span`,{}),c(`div`,{className:`flex items-center gap-2`,children:[c(`div`,{className:`relative`,children:[v(Ci,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none`}),v(`input`,{ref:N,type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:w,"aria-label":w,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`})]}),typeof O==`function`?O({filtered:V}):O]})]}),v(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:S&&H===0?v(`div`,{className:`flex items-center justify-center py-12 text-xs text-foreground-subtle`,children:t(`uiLibrary.genericModeList.loading`,`Loading…`)}):H===0?v(`div`,{className:`flex items-center justify-center py-12 text-xs text-foreground-subtle`,children:T}):h?v(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:c(`table`,{className:`w-full border-collapse`,children:[v(`thead`,{children:v(`tr`,{className:`border-b border-border`,children:h.map(e=>v(`th`,{className:`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle ${e.headerClassName??``}`,children:e.header},e.key))})}),v(`tbody`,{children:te.map(e=>c(d,{children:[v(`tr`,{className:`border-b border-border/60 ${x?`cursor-pointer hover:bg-surface-hover transition-colors`:``} ${y?.(e)??``}`,...x?{onClick:()=>x(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e))}}:{},children:h.map(t=>v(`td`,{className:`px-2 py-2 align-middle ${t.cellClassName??``}`,children:t.cell(e)},t.key))}),g&&_?.(e)&&v(`tr`,{className:`border-b border-border/60 bg-surface/40`,children:v(`td`,{colSpan:h.length,className:`px-2 pb-2 pt-0`,children:g(e)})})]},r(e)))})]})}):v(`div`,{className:`space-y-1.5`,children:te.map(e=>v(d,{children:a?.(e)},r(e)))})}),v(`div`,{className:`shrink-0`,children:D&&H>0?c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[c(`div`,{className:`inline-flex items-center gap-2`,children:[H<=U&&v(`span`,{children:t(`uiLibrary.genericModeList.total`,`{{count}} total`,{count:H})}),v(k3,{ariaLabel:t(`uiLibrary.genericModeList.rowsPerPage`,`Rows per page`),value:k,options:D.options,onChange:A})]}),v(ZM,{currentPage:W,totalItems:H,pageSize:U,onPageChange:R})]}):v(ZM,{currentPage:W,totalItems:H,pageSize:U,onPageChange:R})})]})}function Q3(e){return typeof e==`string`&&e.length>0}function $3(e,t){return e6(t)(e)}function e6(e){if(e==null)return()=>({kind:`unknown`});let t=new Map,n=new Map;for(let r of e)t.has(r.id)||t.set(r.id,r),n.has(r.addonId)||n.set(r.addonId,r);return e=>{if(Q3(e.integrationId)){let n=t.get(e.integrationId);return n===void 0?{kind:`orphan`}:{kind:`resolved`,integration:n}}if(Q3(e.addonId)){let t=n.get(e.addonId);return t===void 0?{kind:`orphan`}:{kind:`resolved`,integration:t}}return{kind:`unlinked`}}}function t6(e){return`mode`in e&&e.mode===`generic`?v(_ae,{...e}):v(pae,{...e})}var vae=`(none)`,yae={roles:[],providers:[]};function n6(e){let t=e.role;return t==null||t===``?vae:t}function bae(e,t){let n=new Set(t.roles),r=new Set(t.providers);return e.filter(e=>(n.size===0||n.has(n6(e)))&&(r.size===0||r.has(e.addonId)))}function r6(e){return[...new Set(e)].toSorted().map(e=>({id:e,label:e}))}function xae(e){return r6(e.map(n6))}function Sae(e){return r6(e.map(e=>e.addonId))}function Cae(e,t){return new Set([...e,...t.map(e=>String(e.id))])}function wae(e,t){let n=new Set(t.map(e=>String(e.id)));return new Set([...e].filter(e=>!n.has(e)))}E();var Tae=go(Wa),Eae=uo({id:co(),stableId:lo(),addonId:lo(),type:lo(),name:lo(),online:_o(),disabled:_o(),parentDeviceId:co().nullable(),role:lo().nullable().optional(),features:go(lo()).optional(),isCamera:_o().optional()}),Dae=go(lo()),i6=1e4,a6=`camstack.device-export.pageSize`,Oae={options:[10,25,50,100,0],defaultSize:25,storageKey:a6},kae=3e4;function Aae(e){return e===`linked`?`success`:e===`error`?`danger`:`warning`}function jae(e,t){return t===`linked`?e(`uiLibrary.deviceExport.linked`,`Linked`):t===`unlinked`?e(`uiLibrary.deviceExport.unlinked`,`Unlinked`):t===`error`?e(`uiLibrary.deviceExport.error`,`Error`):t}function Mae({field:e}){let t=q(),[n,r]=C(!1),i=e.secret===!0,a=i&&!n?`•`.repeat(Math.min(e.value.length,24)):e.value;return v(_U,{label:e.label,valueClassName:`font-mono`,actions:c(P,{children:[i&&v(_A,{size:`sm`,variant:`ghost`,type:`button`,"aria-label":n?t(`uiLibrary.deviceExport.hideValue`,`Hide value`):t(`uiLibrary.deviceExport.revealValue`,`Reveal value`),onClick:()=>r(e=>!e),children:v(n?Oe:Zt,{className:`h-3.5 w-3.5`})}),v(bG,{value:e.value,srLabel:e.label})]}),children:a||`—`})}function o6({setup:e}){let t=q(),n=e.fields??[];return c(`div`,{className:`border-b border-border bg-surface-hover/10`,children:[c(`div`,{className:`flex items-center gap-2 px-2 sm:px-4 py-2 border-b border-border`,children:[v(ee,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}),v(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`uiLibrary.deviceExport.setup`,`Setup`)})]}),c(`div`,{className:`flex flex-col gap-3 p-2 sm:p-4 sm:flex-row sm:items-start`,children:[e.qr&&v(`div`,{className:`shrink-0`,children:v(NR,{value:e.qr,alt:t(`uiLibrary.deviceExport.qr`,`Pairing QR code`)})}),c(`div`,{className:`flex-1 min-w-0`,children:[e.note&&v(`p`,{className:`text-xs text-foreground-muted whitespace-pre-line mb-2`,children:e.note}),n.length>0&&v(`div`,{className:`divide-y divide-border-subtle`,children:n.map(e=>v(Mae,{field:e},e.label))})]})]})]})}function s6(e){let t=La.safeParse(e);return t.success?t.data:null}function c6({addonId:e}){let t=ip({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),n=p(()=>s6(t.data),[t.data]);return!n?.error&&!n?.setup?null:c(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n.error&&v(`div`,{className:`px-2 sm:px-4 py-3 border-b border-border`,children:v(eN,{message:n.error})}),n.setup&&v(o6,{setup:n.setup})]})}function Nae({device:e,checked:t,onToggle:n}){return v(`input`,{type:`checkbox`,checked:t,onChange:n,onClick:e=>e.stopPropagation(),"aria-label":q()(`uiLibrary.deviceExport.select`,`Select {{name}}`,{name:vj(e,`compact`)})})}function Pae({addonId:e,device:t,exposed:n,busy:r,onToggle:i}){let a=q(),o=vj(t,`compact`);return v(_A,{size:`sm`,variant:n?`ghost`:`primary`,disabled:r,onClick:e=>{e.stopPropagation(),!r&&i(t,n?`unexpose`:`expose`)},"aria-label":n?a(`uiLibrary.deviceExport.unexposeDevice`,`Unexpose {{name}}`,{name:o}):a(`uiLibrary.deviceExport.exposeDevice`,`Expose {{name}}`,{name:o}),title:n?a(`uiLibrary.deviceExport.stopTitle`,`Stop exposing to "{{addon}}"`,{addon:e}):a(`uiLibrary.deviceExport.exposeTitle`,`Expose to "{{addon}}"`,{addon:e}),children:n?c(P,{children:[v(we,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.deviceExport.exposed`,`Exposed`)]}):c(P,{children:[v(er,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.deviceExport.expose`,`Expose`)]})})}function Fae({outcome:e,onDismiss:t}){let n=q();return c(`div`,{"data-testid":`export-bulk-summary`,className:`flex flex-col gap-1 px-2 sm:px-4 py-2 border-b border-border text-[11px] ${e.failed.length===0?`text-foreground-subtle`:`text-danger`}`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`span`,{className:`font-medium`,children:e.action===`expose`?n(`uiLibrary.deviceExport.bulkExposed`,{one:`Exposed {{done}} of {{count}} selected device.`,other:`Exposed {{done}} of {{count}} selected devices.`},{done:e.succeeded.length,count:e.total}):n(`uiLibrary.deviceExport.bulkUnexposed`,{one:`Unexposed {{done}} of {{count}} selected device.`,other:`Unexposed {{done}} of {{count}} selected devices.`},{done:e.succeeded.length,count:e.total})}),v(_A,{size:`sm`,variant:`ghost`,onClick:t,"aria-label":n(`uiLibrary.deviceExport.dismissAria`,`Dismiss export result`),children:n(`uiLibrary.deviceExport.dismiss`,`Dismiss`)})]}),e.succeeded.length>0&&v(`span`,{className:`text-foreground-subtle`,children:n(`uiLibrary.deviceExport.succeeded`,`Succeeded: {{devices}}`,{devices:e.succeeded.join(`, `)})}),e.failed.map(e=>v(`span`,{children:n(`uiLibrary.deviceExport.failed`,`Failed: {{device}} — {{message}}`,{device:e.label,message:e.message})},e.label))]})}function l6({addonId:e,onOpenDevice:t,showSetup:n=!0}){let r=q(),i=k(),a=ip({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),o=op({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),s=ap({nodeId:`hub`,addonId:e},{retry:!1}),l=dm({projection:`slim`},{refetchInterval:kae}),u=_(()=>{i.invalidateQueries({queryKey:[[`deviceExport`]]})},[i]),d=sp({onSuccess:u}),f=cp({onSuccess:u}),m=p(()=>s6(a.data),[a.data]),h=p(()=>{let e=Tae.safeParse(o.data);return e.success?e.data:[]},[o.data]),g=p(()=>new Set(h.map(e=>e.deviceId)),[h]),y=p(()=>{let e=Dae.safeParse(s.data);return new Set(e.success?e.data:[])},[s.data]),b=p(()=>[...y].toSorted(),[y]),x=p(()=>b.map(e=>{let t=Yo(e,r);return{id:e,label:t.label,icon:t.icon}}),[b,r]),S=p(()=>{let e=l.data;if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=Eae.safeParse(n);e.success&&y.has(e.data.type)&&t.push(e.data)}return t},[l.data,y]),w=m?.linkState??`unlinked`,T=a.isLoading||o.isLoading||s.isLoading||l.isLoading,E=m?.exposedDeviceCount??g.size,D=d.isPending||f.isPending,[O,A]=C(()=>new Set),[j,M]=C(null),[N,F]=C(!1),I=_(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=_(()=>A(new Set),[]),R=_(()=>M(null),[]),z=_(e=>S.find(t=>String(t.id)===e)?.name??`#${e}`,[S]),B=_(async(t,n)=>{if(n.length===0||N)return;F(!0),M(null);let r=[],i=[],a=t===`expose`?d:f;(await Promise.allSettled(n.map(t=>a.mutateAsync({deviceId:t,nodeId:`hub`,addonId:e})))).forEach((a,o)=>{let s=n[o]??``,c=z(s);if(a.status===`fulfilled`){r.push(c);return}let l=a.reason instanceof Error?a.reason.message:String(a.reason);console.error(`[device-export] ${t} failed`,{tags:{deviceId:Number.parseInt(s,10)},addonId:e,error:l}),i.push({label:c,message:l})}),M({action:t,total:n.length,succeeded:r,failed:i}),A(new Set),F(!1)},[e,d,f,z,N]),[V,H]=C(yae),U=p(()=>xae(S),[S]),ee=p(()=>Sae(S),[S]),W=p(()=>bae(S,V),[S,V]),G=_(e=>H(t=>({...t,roles:e})),[]),te=_(e=>H(t=>({...t,providers:e})),[]),ne=p(()=>[...O],[O]),re=_(()=>{B(`expose`,ne)},[B,ne]),K=_(()=>{B(`unexpose`,ne)},[B,ne]),ie=_((e,t)=>{B(t,[String(e.id)])},[B]),ae=_(e=>t?.(String(e.id)),[t]),oe=_(e=>String(e.id),[]),se=_(e=>`${e.name} ${e.stableId}`,[]),ce=_(e=>e.type,[]),le=p(()=>[{key:`select`,header:``,headerClassName:`w-8`,cell:e=>v(Nae,{device:e,checked:O.has(String(e.id)),onToggle:()=>I(String(e.id))})},{key:`type`,header:r(`uiLibrary.deviceExport.colType`,`Type`),headerClassName:`w-32`,cell:e=>{let t=Yo(e.type,r),n=t.icon;return c(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[v(n,{className:`h-3.5 w-3.5 shrink-0`}),t.label]})}},{key:`name`,header:r(`uiLibrary.deviceExport.colName`,`Name`),cell:e=>v(bj,{device:e,form:`compact`,className:`text-xs font-medium text-foreground`})},{key:`export`,header:r(`uiLibrary.deviceExport.colExport`,`Export`),headerClassName:`w-32 text-right`,cellClassName:`text-right`,cell:t=>v(Pae,{addonId:e,device:t,exposed:g.has(String(t.id)),busy:D,onToggle:ie})}],[e,D,g,ie,O,I,r]),ue=_(({filtered:e})=>c(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[v(AG,{label:r(`uiLibrary.deviceExport.filterRole`,`Role`),options:U,selected:V.roles,onChange:G}),v(AG,{label:r(`uiLibrary.deviceExport.filterProvider`,`Provider`),options:ee,selected:V.providers,onChange:te}),v(_A,{size:`sm`,variant:`secondary`,disabled:e.length===0,onClick:()=>A(t=>Cae(t,e)),children:r(`uiLibrary.deviceExport.selectShown`,`Select {{count}} shown`,{count:e.length})}),O.size>0&&c(P,{children:[v(_A,{size:`sm`,variant:`ghost`,onClick:()=>A(t=>wae(t,e)),children:r(`uiLibrary.deviceExport.deselectShown`,`Deselect shown`)}),v(`span`,{"data-testid":`export-selection-count`,className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.deviceExport.selected`,`{{count}} selected`,{count:O.size})}),v(_A,{size:`sm`,variant:`primary`,disabled:D,onClick:re,children:r(`uiLibrary.deviceExport.exposeN`,`Expose {{count}}`,{count:O.size})}),v(_A,{size:`sm`,variant:`secondary`,disabled:D,onClick:K,children:r(`uiLibrary.deviceExport.unexposeN`,`Unexpose {{count}}`,{count:O.size})}),v(_A,{size:`sm`,variant:`ghost`,onClick:L,children:r(`uiLibrary.deviceExport.clear`,`Clear`)})]})]}),[r,U,ee,V,G,te,O.size,D,re,K,L]),de=b.length>0;return c(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[c(`div`,{className:`flex items-center justify-between gap-3 px-2 sm:px-4 py-2.5 border-b border-border bg-surface-hover/20`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(er,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}),v(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:r(`uiLibrary.deviceExport.title`,`Exported devices`)}),v(Bk,{variant:Aae(w),children:jae(r,w)}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.deviceExport.exposedCount`,`{{count}} exposed`,{count:E})})]}),T&&v(Gn,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`})]}),n&&m?.error&&v(`div`,{className:`px-2 sm:px-4 py-3 border-b border-border`,children:v(eN,{message:m.error})}),n&&m?.setup&&v(o6,{setup:m.setup}),j!==null&&v(Fae,{outcome:j,onDismiss:R}),v(`div`,{className:`p-2 sm:p-3`,children:T&&S.length===0?c(`div`,{className:`flex items-center gap-2 px-1 py-6 text-xs text-foreground-subtle`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),r(`uiLibrary.deviceExport.loading`,`Loading exportable devices…`)]}):de&&S.length>0?v(t6,{mode:`generic`,items:W,getKey:oe,getSearchText:se,getFilterType:ce,filterOptions:x,columns:le,onRowClick:t?ae:void 0,toolbar:ue,pageSizeSelector:Oae,searchPlaceholder:r(`uiLibrary.deviceExport.search`,`Search by name or stableId`),emptyLabel:r(`uiLibrary.deviceExport.noMatch`,`No device matches this search.`)}):v(QM,{icon:er,title:r(`uiLibrary.deviceExport.emptyTitle`,`No exportable devices`),description:de?r(`uiLibrary.deviceExport.emptyKinds`,`No devices of the supported kinds ({{kinds}}) are available to expose to "{{addon}}".`,{kinds:b.join(`, `),addon:e}):r(`uiLibrary.deviceExport.emptyNoKinds`,`"{{addon}}" reports no exportable device kinds yet.`,{addon:e})})})]})}function Iae({children:e,minCardWidth:t=220,gap:n=3,className:r}){return v(`div`,{className:$(`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})}E();function u6(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function d6(e){return e.kind}function Lae(e){switch(e){case`all`:return{kind:`all`};case`types`:return{kind:`types`,types:[]};case`locations`:return{kind:`locations`,locations:[]};case`ids`:return{kind:`ids`,ids:[]}}}function f6({value:e,onChange:t,includeLinked:n,onIncludeLinkedChange:r,clampToDeviceIds:i,dense:a=!1}){let o=q(),{data:s}=dm({}),[l,u]=C(``),d=f(null);As(d);let m=p(()=>{let e=(s??[]).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location,parentDeviceId:e.parentDeviceId}));if(i==null)return e;let t=new Set(i);return e.filter(e=>t.has(e.id))},[s,i]),h=p(()=>{let t=new Map;for(let e of m)t.set(e.type,(t.get(e.type)??0)+1);if(e.kind===`types`)for(let n of e.types)t.has(n)||t.set(n,0);return[...t.entries()].map(([e,t])=>({value:e,label:u6(e),count:t})).sort((e,t)=>e.label.localeCompare(t.label))},[m,e]),g=p(()=>{let t=new Map;for(let e of m)e.location===null||e.location.length===0||t.set(e.location,(t.get(e.location)??0)+1);if(e.kind===`locations`)for(let n of e.locations)t.has(n)||t.set(n,0);return[...t.entries()].map(([e,t])=>({value:e,label:e,count:t})).sort((e,t)=>e.label.localeCompare(t.label))},[m,e]),_=g.length>0,y=p(()=>{let e=l.trim().toLowerCase();return[...e.length===0?m:m.filter(t=>t.name.toLowerCase().includes(e)||String(t.id).includes(e)||(t.location??``).toLowerCase().includes(e))].sort((e,t)=>e.name.localeCompare(t.name))},[m,l]),b=d6(e),x=[{id:`all`,label:o(`uiLibrary.deviceSelectorPicker.tabAll`,`All`)},{id:`types`,label:o(`uiLibrary.deviceSelectorPicker.tabTypes`,`By type`)},..._||b===`locations`?[{id:`locations`,label:o(`uiLibrary.deviceSelectorPicker.tabRooms`,`By room`)}]:[],{id:`ids`,label:o(`uiLibrary.deviceSelectorPicker.tabChosen`,`Chosen`)}],S=n=>{let r=e.kind===`types`?e.types:[];t({kind:`types`,types:r.some(e=>String(e)===n)?r.filter(e=>String(e)!==n):[...r,...Rae(n)]})},w=n=>{let r=e.kind===`locations`?e.locations:[];t({kind:`locations`,locations:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},T=n=>{let r=e.kind===`ids`?e.ids:[];t({kind:`ids`,ids:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},E=a?`p-2`:`p-3`;return c(`div`,{className:`space-y-2`,children:[v(`div`,{className:`flex flex-wrap gap-1 border-b border-border pb-1`,children:x.map(e=>v(`button`,{type:`button`,onClick:()=>t(Lae(e.id)),className:`shrink-0 whitespace-nowrap rounded px-2 py-1 text-[11px] transition-colors ${b===e.id?`bg-primary/15 text-primary font-medium`:`text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground`}`,children:e.label},e.id))}),b===`all`&&c(`div`,{className:`rounded border border-border bg-surface ${E}`,children:[v(`p`,{className:`text-[11px] text-foreground`,children:o(`uiLibrary.deviceSelectorPicker.everyDevice`,`Every device in this deployment — {{count}} right now.`,{count:m.length})}),v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:o(`uiLibrary.deviceSelectorPicker.laterCovered`,`Devices added later are covered automatically.`)})]}),b===`types`&&v(p6,{options:h,selected:e.kind===`types`?e.types.map(e=>String(e)):[],onToggle:S,emptyLabel:o(`uiLibrary.deviceSelectorPicker.noTypes`,`No devices to pick a type from.`),footnote:o(`uiLibrary.deviceSelectorPicker.typesFootnote`,`Devices of a checked type are covered automatically as they are added.`),pad:E}),b===`locations`&&v(p6,{options:g,selected:e.kind===`locations`?[...e.locations]:[],onToggle:w,emptyLabel:o(`uiLibrary.deviceSelectorPicker.noRooms`,`No device has a room assigned yet.`),footnote:o(`uiLibrary.deviceSelectorPicker.roomsFootnote`,`A device with no room set is never covered by a room rule.`),pad:E}),b===`ids`&&c(`div`,{className:`rounded border border-border bg-surface ${E} space-y-2`,children:[c(`div`,{className:`relative`,children:[v(Ci,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),v(`input`,{ref:d,type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:o(`uiLibrary.deviceSelectorPicker.search`,`Search devices…`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),c(`div`,{className:`max-h-56 overflow-auto rounded border border-border`,children:[y.length===0&&v(`p`,{className:`px-2 py-3 text-[10px] italic text-foreground-subtle`,children:o(`uiLibrary.deviceSelectorPicker.noMatch`,`No device matches.`)}),y.map(t=>c(`label`,{className:`flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[11px] hover:bg-foreground-subtle/10`,children:[v(`input`,{type:`checkbox`,checked:e.kind===`ids`&&e.ids.includes(t.id),onChange:()=>T(t.id),className:`rounded border-border focus:ring-primary`}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.name}),c(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:[`#`,t.id,t.location!==null&&t.location.length>0?` · ${t.location}`:``]})]},t.id))]}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:v(gi,{uiKey:`uiLibrary.deviceSelectorPicker.fixedList`,fallback:`A fixed list — a device added later is <0>not</0> covered until you edit this.`,components:[v(`span`,{className:`font-medium`},`n`)]})})]}),n!==void 0&&r!==void 0&&v(zae,{value:n,onChange:r,pad:E})]})}function Rae(e){return Object.values(J).filter(t=>String(t)===e)}function p6({options:e,selected:t,onToggle:n,emptyLabel:r,footnote:i,pad:a}){return c(`div`,{className:`rounded border border-border bg-surface ${a} space-y-2`,children:[e.length===0?v(`p`,{className:`text-[10px] italic text-foreground-subtle`,children:r}):v(`div`,{className:`grid max-h-56 grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-1 overflow-auto`,children:e.map(e=>c(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 text-[11px] hover:bg-foreground-subtle/10`,children:[v(`input`,{type:`checkbox`,checked:t.includes(e.value),onChange:()=>n(e.value),className:`rounded border-border focus:ring-primary`}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.label}),v(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:e.count})]},e.value))}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function zae({value:e,onChange:t,pad:n}){let r=q();return v(`div`,{className:`rounded border border-border bg-surface ${n}`,children:c(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[v(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5 rounded border-border focus:ring-primary`}),c(`span`,{className:`min-w-0`,children:[c(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[v(tr,{className:`h-3 w-3`}),r(`uiLibrary.deviceSelectorPicker.includeLinked`,`Include linked devices`)]}),v(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e?v(P,{children:r(`uiLibrary.deviceSelectorPicker.linkedOn`,`Accessories attached to a granted camera — siren, floodlight, PIR — are covered too.`)}):v(P,{children:v(gi,{uiKey:`uiLibrary.deviceSelectorPicker.linkedOff`,fallback:`Only the devices selected above. An operator granted a camera will <0>not</0> be able to trigger the siren or light attached to it.`,components:[v(`span`,{className:`font-medium text-foreground`},`n`)]})})})]})]})})}function m6(e,t=Fn){switch(e.kind){case`all`:return t(`uiLibrary.deviceSelectorPicker.allDevices`,`All devices`);case`ids`:return e.ids.length===0?t(`uiLibrary.deviceSelectorPicker.noDevice`,`No device chosen`):t(`uiLibrary.deviceSelectorPicker.deviceCount`,{one:`{{count}} device`,other:`{{count}} devices`},{count:e.ids.length});case`types`:return e.types.length===0?t(`uiLibrary.deviceSelectorPicker.noType`,`No type chosen`):e.types.map(e=>u6(String(e))).join(`, `);case`locations`:return e.locations.length===0?t(`uiLibrary.deviceSelectorPicker.noRoom`,`No room chosen`):e.locations.join(`, `)}}function h6(e){return e.deviceKey===void 0?e.agentNodeId:`${e.agentNodeId}::${e.deviceKey}`}function g6(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.agentNodeId===n.agentNodeId){let r=[...e.columns,n];t[t.length-1]={...e,columns:r,grouped:r.length>1}}else t.push({agentNodeId:n.agentNodeId,engineLabel:n.engineLabel,columns:[n],grouped:!1})}return t}function Bae(e){let t=[],n=(e,r)=>{for(let i of e)t.push({node:i,depth:r}),n(i.children,r+1)};return n(e,0),t}function _6(e,t,n,r=208,i=t){return e<=0?!1:t<=1?e<n+r*i:e<n+r*2}var v6={detector:{labelKey:`uiLibrary.pipelineMatrix.slotDetector`,labelFallback:`detector`,className:`text-emerald-500`},cropper:{labelKey:`uiLibrary.pipelineMatrix.slotCropper`,labelFallback:`cropper`,className:`text-blue-500`},classifier:{labelKey:`uiLibrary.pipelineMatrix.slotClassifier`,labelFallback:`classifier`,className:`text-violet-500`},refiner:{labelKey:`uiLibrary.pipelineMatrix.slotRefiner`,labelFallback:`refiner`,className:`text-amber-500`},"audio-classifier":{labelKey:`uiLibrary.pipelineMatrix.slotAudioClassifier`,labelFallback:`audio classifier`,className:`text-pink-500`}};function Vae({slot:e}){let t=q(),n=v6[e]??v6.classifier;return v(`span`,{className:$(`text-[9px] font-semibold uppercase tracking-widest leading-none`,n.className),children:t(n.labelKey,n.labelFallback)})}var y6=`inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle`;function Hae({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:c(`span`,{className:`inline-flex items-center gap-1 flex-wrap`,children:[e.map(e=>v(`span`,{className:$(y6,`bg-blue-500/10 text-blue-500`),children:e},`in-${e}`)),e.length>0&&t.length>0&&v(`span`,{className:`text-foreground-subtle/60 text-[9px]`,children:`→`}),t.map(e=>v(`span`,{className:$(y6,`bg-emerald-500/10 text-emerald-500`),children:e},`out-${e}`))]})}function b6({column:e}){let t=q(),n=e.deviceLabel??e.deviceKey;return c(P,{children:[(n!==void 0||e.disabled===!0)&&c(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n!==void 0&&v(`span`,{className:`truncate text-[10px] font-medium text-foreground/90`,children:n}),e.disabled===!0&&v(`span`,{className:`shrink-0 rounded bg-muted px-1 text-[8px] font-semibold uppercase text-foreground-subtle`,children:t(`uiLibrary.pipelineMatrixShared.offWord`,`off`)})]}),v(`div`,{className:`truncate text-[9px] text-foreground-subtle`,children:e.engineLabel}),e.detail!==void 0&&v(`div`,{className:`truncate font-mono text-[9px] text-foreground-subtle`,title:e.detail,children:e.detail})]})}function Uae({group:e}){let t=e.columns[0]?.nodeLabel??e.agentNodeId;return c(`div`,{role:`columnheader`,className:`sticky top-0 z-10 min-w-0 border-b border-l border-border bg-muted/60`,style:{gridColumn:`span ${e.columns.length}`},children:[v(`div`,{className:`truncate px-3 pt-2 pb-1 text-xs font-semibold text-foreground`,children:t}),v(`div`,{className:`mt-1 flex border-t border-border/50`,children:e.columns.map((e,t)=>v(`div`,{className:$(`min-w-0 flex-1 px-3 py-1`,t>0&&`border-l border-border/50`,e.disabled===!0&&`opacity-70`),title:`${e.deviceLabel??e.deviceKey} · ${e.engineLabel}${e.detail?` · ${e.detail}`:``}`,children:v(b6,{column:e})},h6(e)))})]})}function Wae({node:e}){return c(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[v(Vae,{slot:e.slot}),c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[v(`span`,{className:`font-semibold truncate`,children:e.addonName}),v(Hae,{inputs:e.inputClasses,outputs:e.outputClasses})]})]})}function Gae(e,t){return t.kind===`enabled`?c(`span`,{className:`flex min-w-0 items-center gap-1`,title:t.overridden?e(`uiLibrary.pipelineMatrix.override`,`override`):void 0,children:[v(`span`,{className:$(`h-1.5 w-1.5 rounded-full shrink-0`,t.overridden?`bg-amber-500`:`bg-emerald-500`)}),v(`span`,{className:`font-mono text-foreground truncate`,children:t.modelId}),t.suppliedByRoot!==void 0&&v(`span`,{className:`ml-auto shrink-0 truncate rounded bg-primary/10 px-1 text-[8px] font-semibold uppercase text-primary`,title:e(`uiLibrary.pipelineMatrix.rootModelTitle`,`Uses the root model {{model}} — this step's own model does not run here`,{model:t.suppliedByRoot}),children:e(`uiLibrary.pipelineMatrix.root`,`root`)}),t.clusterWide===!0&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-primary`,title:e(`uiLibrary.pipelineMatrix.clusterTitle`,`One value for the whole cluster — this step writes into a shared vector index`),children:e(`uiLibrary.pipelineMatrix.cluster`,`cluster`)}),t.jumpTo!==void 0&&c(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold text-sky-500`,title:e(`uiLibrary.pipelineMatrix.runsOn`,`runs on {{target}}`,{target:t.jumpTo}),children:[`→ `,t.jumpTo]}),t.overridden&&t.jumpTo===void 0&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-amber-500`,children:e(`uiLibrary.pipelineMatrix.ovr`,`ovr`)})]}):t.kind===`disabled`?c(`span`,{className:`flex min-w-0 items-center gap-1 text-foreground-subtle`,title:t.overridden?e(`uiLibrary.pipelineMatrix.override`,`override`):void 0,children:[v(`span`,{className:$(`h-1.5 w-1.5 rounded-full shrink-0`,t.overridden?`bg-amber-500`:`border border-foreground-subtle/60`)}),v(`span`,{className:`truncate`,children:e(`uiLibrary.pipelineMatrix.off`,`off`)}),t.overridden&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-amber-500`,children:e(`uiLibrary.pipelineMatrix.ovr`,`ovr`)})]}):t.kind===`skip`?t.jumpTo===void 0?c(`span`,{className:`flex min-w-0 items-center gap-1 text-amber-500`,title:e(`uiLibrary.pipelineMatrix.skipTitle`,`Gated on for this camera, but no compatible model on this node — click to provision`),children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0`}),v(`span`,{className:`truncate font-medium`,children:e(`uiLibrary.pipelineMatrix.skip`,`⚠ skip`)})]}):c(`span`,{className:`flex min-w-0 items-center gap-1 text-sky-500`,title:e(`uiLibrary.pipelineMatrix.autoJump`,`no build for this device — auto-jumps to {{target}}`,{target:t.jumpTo}),children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-sky-500 shrink-0`}),c(`span`,{className:`truncate font-medium`,children:[`→ `,t.jumpTo]})]}):c(`span`,{className:`flex min-w-0 items-center gap-1 text-foreground-subtle/70`,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted shrink-0`}),v(`span`,{className:`truncate`,children:`—`})]})}function Kae(e,t,n){return $(`text-left text-xs hover:bg-muted/40`,e.kind===`enabled`&&`bg-emerald-500/5`,e.kind===`skip`&&`bg-amber-500/5`,e.kind===`na`&&`bg-muted/30`,t&&`ring-2 ring-primary ring-inset`,n)}E();var x6=18,qae=x6*16,Jae=11;function S6(e,t,n,r){let i=(e,t)=>({r:Math.max(0,Math.min(n-1,e)),c:Math.max(0,Math.min(r-1,t))});switch(e){case`ArrowRight`:return i(t.r,t.c+1);case`ArrowLeft`:return i(t.r,t.c-1);case`ArrowDown`:return i(t.r+1,t.c);case`ArrowUp`:return i(t.r-1,t.c);case`Home`:return i(t.r,0);case`End`:return i(t.r,r-1);case`PageDown`:return i(n-1,t.c);case`PageUp`:return i(0,t.c);default:return null}}function Yae({node:e,depth:t,r:n,tabbable:r,selected:i,badge:a,onClick:o,sticky:s}){return v(`div`,{role:`rowheader`,className:$(`min-w-0 border-b border-border bg-surface`,s&&`sticky left-0 z-10`),children:c(`button`,{type:`button`,"data-r":n,"data-c":0,"data-step":e.addonId,"data-col":``,tabIndex:r?0:-1,"aria-current":i?`true`:void 0,onClick:o?e=>o(e.detail===0):void 0,className:$(`flex h-full w-full min-w-0 items-start gap-2 px-3 py-2 text-left text-xs outline-none`,`hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,i&&`bg-primary/10 shadow-[inset_3px_0_0_var(--color-primary)]`),style:{paddingLeft:`${12+t*14}px`},children:[v(Wae,{node:e}),a]})})}function Xae({nodes:e,selected:t,onSelect:n}){let r=q();return c(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`tablist`,"aria-label":r(`uiLibrary.deviceStepMatrix.node`,`Node`),children:[v(_n,{className:`h-3.5 w-3.5 text-foreground-subtle`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`uiLibrary.deviceStepMatrix.node`,`Node`)}),v(`div`,{className:`flex overflow-hidden rounded-md border border-border text-[11px] font-medium`,children:e.map((e,r)=>{let i=e.agentNodeId===t;return v(`button`,{type:`button`,role:`tab`,"aria-selected":i,onClick:()=>n(e.agentNodeId),title:`${e.columns[0]?.nodeLabel??e.agentNodeId} · ${e.engineLabel}`,className:$(`px-2.5 py-1 transition-colors`,i?`bg-primary/15 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,r>0&&`border-l border-border`),children:e.columns[0]?.nodeLabel??e.agentNodeId},e.agentNodeId)})})]})}var Zae=D(function({tree:e,agents:t,getCellState:n,onCellClick:r,onStepClick:i,stepBadge:a,selectedCell:o,single:s,reserveRightPx:l,label:d},m){let h=q(),g=p(()=>Bae(e),[e]),_=p(()=>g6(t),[t]),y=f(null),S=s?Jae:x6,w=`${S}rem repeat(${t.length}, 13rem)`,T=t.length+1,[E,D]=C(!0);u(()=>{let e=y.current;if(!e||l<=0){D(!0);return}let t=()=>{let t=e.getBoundingClientRect().left;D(window.innerWidth-l-t>=S*16+208+24)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[l,S]);let O=p(()=>{if(o===null)return null;let e=g.findIndex(e=>e.node.addonId===o.addonId);if(e<0)return null;let n=t.findIndex(e=>h6(e)===h6(o));return{r:e,c:n<0?0:n+1}},[o,g,t]),[k,A]=C({r:0,c:0});b(()=>{O!==null&&A(O)},[O]);let j=k.r<g.length&&k.c<T?k:{r:0,c:0},M=(e,t)=>{y.current?.querySelector(`[data-r="${e}"][data-c="${t}"]`)?.focus()};return x(m,()=>({focusCell:(e,n)=>{let r=g.findIndex(t=>t.node.addonId===e);if(r<0)return;let i=n===null?-1:t.findIndex(e=>h6(e)===n),a=i<0?0:i+1;A({r,c:a}),M(r,a)}}),[g,t]),u(()=>{if(O===null)return;let e=y.current,t=e?.querySelector(`[data-r="${O.r}"][data-c="${O.c}"]`);if(!e||!t||(typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`nearest`,inline:`nearest`}),l<=0))return;let n=window.innerWidth-l-12,r=t.getBoundingClientRect().right;r>n&&(e.scrollLeft+=r-n)},[O,l,E]),v(`div`,{ref:y,className:`overflow-auto rounded border border-border`,children:c(`div`,{className:`flex w-max`,children:[c(`div`,{role:`grid`,"aria-label":d,"aria-rowcount":g.length+1,className:`grid w-max`,style:{gridTemplateColumns:w},onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.dataset.r===void 0)return;let t={r:Number(e.target.dataset.r),c:Number(e.target.dataset.c)},n=S6(e.key,t,g.length,T);n!==null&&(e.preventDefault(),A(n),M(n.r,n.c))},children:[c(`div`,{role:`row`,className:`contents`,children:[v(`div`,{role:`columnheader`,className:$(`top-0 z-20 border-b border-border bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle`,E?`sticky left-0`:`sticky`),children:h(`uiLibrary.deviceStepMatrix.step`,`Step`)}),_.map(e=>e.grouped?v(Uae,{group:e},e.agentNodeId):e.columns.map(e=>c(`div`,{role:`columnheader`,className:$(`sticky top-0 z-10 min-w-0 border-b border-l border-border bg-muted/60 px-3 py-2`,e.disabled===!0&&`opacity-70`),children:[v(`div`,{className:`truncate text-xs font-semibold text-foreground`,children:e.nodeLabel??e.agentNodeId}),v(b6,{column:e})]},h6(e))))]}),g.map(({node:e,depth:s},l)=>c(`div`,{role:`row`,className:`contents`,children:[v(Yae,{node:e,depth:s,r:l,tabbable:j.r===l&&j.c===0,selected:o?.addonId===e.addonId,badge:a?.(e.addonId),onClick:i?t=>i(e.addonId,t):void 0,sticky:E}),t.map((t,i)=>{let a=n(e.addonId,t),s=o!==null&&o.addonId===e.addonId&&h6(o)===h6(t),c=a.kind===`enabled`||a.kind===`skip`;return v(`div`,{role:`gridcell`,className:`min-w-0 border-b border-l border-border`,children:v(`button`,{type:`button`,"data-r":l,"data-c":i+1,"data-step":e.addonId,"data-col":h6(t),tabIndex:j.r===l&&j.c===i+1?0:-1,"aria-disabled":!c,"aria-selected":s,onClick:n=>{c&&r(e.addonId,t,n.detail===0)},className:Kae(a,s,$(`h-full w-full min-w-0 overflow-hidden px-3 py-2 outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,!c&&`cursor-default hover:bg-transparent`,t.disabled===!0&&`opacity-70`)),children:Gae(h,a)})},h6(t))})]},e.addonId))]}),l>0&&v(`div`,{"aria-hidden":!0,style:{width:l},className:`shrink-0`})]})})}),C6=D(function({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:i,fallbackNodeId:a,onFallbackNodeChange:o,onStepClick:s,stepBadge:l,reserveRightPx:d=0,label:m=`Detection steps`},h){let g=f(null),[_,y]=C(0);u(()=>{let e=g.current;if(!e)return;let t=()=>y(e.getBoundingClientRect().width);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),()=>n?.disconnect()},[]);let x=p(()=>g6(t),[t]),S=_6(_,x.length,qae,208,t.length),w=p(()=>x.length===0?null:x.find(e=>e.agentNodeId===a)??x[0]??null,[x,a]),T=i?.agentNodeId;b(()=>{S&&T!==void 0&&T!==a&&o(T)},[S,T,a,o]);let E=S&&w?w.columns:t;return c(`div`,{ref:g,className:`w-full space-y-2`,children:[S&&w&&x.length>1&&v(Xae,{nodes:x,selected:w.agentNodeId,onSelect:o}),v(Zae,{ref:h,tree:e,agents:E,getCellState:n,onCellClick:r,onStepClick:s,stepBadge:l,selectedCell:i,single:S&&w!==null,reserveRightPx:d,label:m})]})});E();function w6({deviceId:e,className:t=``,onOpenChild:n}){let r=q(),i=X.useUtils(),a=X.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),o=X.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),s=X.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),i.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=X.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),u=X.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=C(null),{available:m,adopted:h}=p(()=>{let e=a.data??[],t=e=>typeof e.metadata.rtspChannel==`number`?e.metadata.rtspChannel:1/0,n=(e,n)=>{let r=t(e),i=t(n);return r===i?e.name.localeCompare(n.name):r-i};return{available:e.filter(e=>!e.alreadyAdopted).toSorted(n),adopted:e.filter(e=>e.alreadyAdopted).toSorted(n)}},[a.data]),g=o.data,_=g?.lastError??null,y=g?.lastDiscoveryAt??null;async function b(){await s.mutateAsync({deviceId:e}).catch(()=>{})}async function x(t){f(t.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:t.childNativeId})}finally{f(null)}}async function S(t){if(t.adoptedDeviceId!=null){f(t.childNativeId);try{await u.mutateAsync({deviceId:e,childDeviceId:t.adoptedDeviceId})}finally{f(null)}}}return c(`div`,{className:`rounded-xl border border-border bg-surface ${t}`,children:[c(`div`,{className:`flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3`,children:[c(`div`,{className:`min-w-0`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`uiLibrary.discoveryPanel.title`,`Discovered devices`)}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:v(gi,{uiKey:`uiLibrary.discoveryPanel.intro`,fallback:`Channels behind this hub. Click <0>Add</0> to promote a channel to a managed device, or <1>Remove</1> to detach.`,components:[v(`span`,{className:`font-medium`},`a`),v(`span`,{className:`font-medium`},`r`)]})})]}),c(`button`,{type:`button`,onClick:b,disabled:s.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:[s.isPending?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(_e,{className:`h-3.5 w-3.5`}),v(`span`,{className:`hidden sm:inline`,children:r(`uiLibrary.discoveryPanel.refresh`,`Refresh`)})]})]}),_?c(`div`,{className:`flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive`,children:[v(zi,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),v(`span`,{children:r(`uiLibrary.discoveryPanel.refreshFailed`,`Last refresh failed: {{error}}`,{error:_})})]}):null,a.isLoading?v(`div`,{className:`flex items-center justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):m.length===0&&h.length===0?v(`div`,{className:`px-5 py-8 text-center text-xs text-foreground-subtle`,children:r(`uiLibrary.discoveryPanel.empty`,`No channels reported by the hub yet. Click Refresh to enumerate.`)}):c(P,{children:[m.length>0?v(T6,{title:r(`uiLibrary.discoveryPanel.available`,`Available to add`),count:m.length,tone:`primary`,children:m.map(e=>v(E6,{child:e,busy:d===e.childNativeId,onAdopt:x,onRelease:S,onOpenChild:n},e.childNativeId))}):null,h.length>0?v(T6,{title:r(`uiLibrary.discoveryPanel.adopted`,`Already adopted`),count:h.length,tone:`muted`,children:h.map(e=>v(E6,{child:e,busy:d===e.childNativeId,onAdopt:x,onRelease:S,onOpenChild:n},e.childNativeId))}):null]}),y==null?null:v(`div`,{className:`border-t border-border px-5 py-2 text-[10px] text-foreground-subtle`,children:r(`uiLibrary.discoveryPanel.lastRefreshed`,`Last refreshed {{when}}`,{when:new Date(y).toLocaleString()})})]})}function T6({title:e,count:t,tone:n,children:r}){return c(`div`,{className:`border-t border-border`,children:[c(`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:[v(`span`,{className:`font-semibold`,children:e}),v(`span`,{className:`font-mono`,children:t})]}),v(`div`,{className:`divide-y divide-border`,children:r})]})}function E6({child:e,busy:t,onAdopt:n,onRelease:r,onOpenChild:i}){let a=q();return c(`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:[c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[v(Qae,{status:e.status}),v(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),e.metadata.isDoorbell?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.doorbell`,`Doorbell`)}):null,e.metadata.isBattery?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.battery`,`Battery`)}):null,e.metadata.isMultifocal?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.multifocal`,`Multifocal`)}):null]}),c(`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`?c(`span`,{children:[`ch `,v(`span`,{className:`font-mono`,children:e.metadata.rtspChannel})]}):null,e.metadata.model?v(`span`,{className:`truncate max-w-[160px]`,children:e.metadata.model}):null,e.metadata.uid?c(`span`,{className:`font-mono truncate max-w-[140px]`,children:[e.metadata.uid.slice(0,12),`…`]}):null]})]}),e.alreadyAdopted?c(`div`,{className:`flex items-center gap-2`,children:[i&&e.adoptedDeviceId!==null?c(`button`,{type:`button`,onClick:()=>i(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:a(`uiLibrary.discoveryPanel.openTitle`,`Open device detail`),children:[v(Je,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.open`,`Open`)]}):null,c(`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?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(Pe,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.remove`,`Remove`)]})]}):c(`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?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(Se,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.add`,`Add`)]})]})}function Qae({status:e}){let t=q();switch(e){case`online`:return c(`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:[v(An,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.online`,`online`)]});case`sleeping`:return c(`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:[v(St,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.sleeping`,`sleeping`)]});case`offline`:return c(`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:[v(Pt,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.offline`,`offline`)]});default:return c(`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:[v($n,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.unknown`,`unknown`)]})}}function $ae(e,t){let n=Date.now()-e;return n<6e4?t(`uiLibrary.doorbellRecentPanel.justNow`,`just now`):n<36e5?t(`uiLibrary.doorbellRecentPanel.minutesAgo`,`{{count}}m ago`,{count:Math.floor(n/6e4)}):n<864e5?t(`uiLibrary.doorbellRecentPanel.hoursAgo`,`{{count}}h ago`,{count:Math.floor(n/36e5)}):t(`uiLibrary.doorbellRecentPanel.daysAgo`,`{{count}}d ago`,{count:Math.floor(n/864e5)})}function D6({history:e,limit:t=5,latestIsFresh:n,className:r}){let i=q();if(e.length===0)return null;let a=n?Yt:Bt,o=e.slice(0,t);return c(`div`,{className:$(`rounded-lg border border-border bg-surface px-3 py-2`,r),children:[c(`div`,{className:`flex items-center gap-2 mb-2`,children:[v(a,{className:$(`h-4 w-4 text-amber-400`,n&&`animate-pulse`)}),v(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:i(`uiLibrary.doorbellRecentPanel.recentPresses`,`Recent presses`)}),v(`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})]}),v(`ul`,{className:`space-y-1`,children:o.map(e=>c(`li`,{className:`flex items-center justify-between text-[11px]`,title:new Date(e.timestamp).toLocaleString(),children:[v(`span`,{className:`text-foreground`,children:$ae(e.timestamp,i)}),v(`span`,{className:`text-foreground-subtle font-mono text-[10px]`,children:new Date(e.timestamp).toLocaleTimeString()})]},`${e.deviceId}-${e.timestamp}`))})]})}E();function eoe({filters:e,values:t,onChange:n,className:r}){let i=q(),a=dl(),[o,s]=C(!1),l=(e,r)=>{n({...t,[e]:r})},u=Object.values(t).filter(e=>e!==void 0&&e!==``).length;if(a){let n=e.find(e=>e.type===`search`),a=e.some(e=>e.type!==`search`);return c(`div`,{className:$(`flex items-center gap-2`,r),children:[n&&v(Bl,{placeholder:n.placeholder??i(`uiLibrary.filterBar.search`,`Search...`),value:t[n.key]??``,onChange:e=>l(n.key,e.target.value),searchHotkey:!0,leftSlot:v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),className:`flex-1`}),a&&c(P,{children:[c(`button`,{onClick:()=>s(!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:[v(zr,{className:`h-3.5 w-3.5`}),i(`uiLibrary.filterBar.filters`,`Filters`),u>0&&v(Bk,{variant:`info`,className:`ml-1 text-[10px] px-1 py-0`,children:u})]}),v(pl,{open:o,onClose:()=>s(!1),title:i(`uiLibrary.filterBar.filters`,`Filters`),children:v(`div`,{className:`flex flex-col gap-3`,children:e.filter(e=>e.type!==`search`).map(e=>{switch(e.type){case`select`:return c(`div`,{children:[v(`label`,{className:`text-xs text-foreground-muted mb-1 block`,children:e.label}),v(Yl,{options:e.options,value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),className:`w-full`})]},e.key);case`badge-toggle`:return v(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.options.map(n=>{let r=t[e.key]===n.value;return v(`button`,{type:`button`,onClick:()=>l(e.key,r?void 0:n.value),children:v(Bk,{variant:r?`info`:`default`,className:`cursor-pointer`,children:n.label})},n.value)})},e.key);default:return null}})})})]})]})}return v(`div`,{className:$(`flex items-center gap-2 flex-wrap`,r),children:e.map(e=>{switch(e.type){case`search`:return v(Bl,{placeholder:e.placeholder??i(`uiLibrary.filterBar.search`,`Search...`),value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),searchHotkey:!0,leftSlot:v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),className:`w-48`},e.key);case`select`:return v(Yl,{options:e.options,value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),className:`w-36`},e.key);case`badge-toggle`:return v(`div`,{className:`flex items-center gap-1`,children:e.options.map(n=>{let r=t[e.key]===n.value;return v(`button`,{type:`button`,onClick:()=>l(e.key,r?void 0:n.value),children:v(Bk,{variant:r?`info`:`default`,className:`cursor-pointer`,children:n.label})},n.value)})},e.key);default:return null}})})}function O6({label:e,description:t,error:n,required:r,children:i,orientation:a=`vertical`,className:o}){let s=a===`horizontal`;return c(`div`,{className:$(`flex gap-2`,s?`flex-row items-center justify-between`:`flex-col`,o),children:[c(`div`,{className:$(s?`flex-1`:``),children:[c(LB,{children:[e,r&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),t&&v(`p`,{className:`text-foreground-subtle text-xs mt-0.5`,children:t})]}),v(`div`,{className:$(s?`shrink-0`:``),children:i}),n&&v(`p`,{className:`text-danger text-xs`,children:n})]})}E();function k6({groups:e,onPick:t,emptyMessage:n}){let[r,i]=C(null),a=r===null?null:e.flatMap(e=>e.tiles).find(e=>e.key===r)??null;return c(`div`,{className:`space-y-4`,children:[e.length===0&&v(`p`,{className:`text-xs text-foreground-subtle`,children:n}),e.map(e=>c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.label}),v(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.tiles.map(e=>c(`div`,{className:`relative`,children:[c(`button`,{type:`button`,"data-testid":e.testId,onClick:()=>t(e.key),className:`flex h-full w-full flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[e.icon,v(`span`,{className:`text-center font-medium text-foreground`,children:e.label})]}),e.detail!==void 0&&e.detailLabel!==void 0&&v(`div`,{className:`absolute top-1 right-1`,children:v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:kn,"aria-label":e.detailLabel,onClick:()=>i(t=>t===e.key?null:e.key)})})]},e.key))})]},e.id)),a?.detail!==void 0&&v(pl,{open:!0,onClose:()=>i(null),children:a.detail})]})}function toe(e,t,n=Fn){return e.name!==void 0&&e.name.length>0?e.name:e.height!==void 0&&e.height>0?`${e.height}p`:e.bitrate!==void 0&&e.bitrate>0?`${Math.round(e.bitrate/1e3)} kbps`:n(`uiLibrary.hlsQuality.level`,`Level {{n}}`,{n:t+1})}function noe(e,t=Fn){return[{value:-1,label:t(`uiLibrary.hlsQuality.auto`,`Auto`)},...e.map((e,n)=>({value:n,label:toe(e,n,t)}))]}E();function roe(e){return{height:e.height>0?e.height:void 0,bitrate:e.bitrate>0?e.bitrate:void 0,name:e.name.length>0?e.name:void 0}}function A6({url:e,format:t=`hls`,authToken:n,posterUrl:r,autoPlay:i=!0,className:o,onQualityOptions:s,selectedLevel:l=-1}){let u=f(null),d=f(null),p=q(),m=f(p);m.current=p;let[h,g]=C(null),[_,y]=C(!0);return b(()=>{let r=u.current;if(!r||!e)return;g(null),y(!0),s?.([]);let o=()=>y(!1);if(r.addEventListener(`playing`,o),t===`mp4`){r.src=e;let t=()=>{i&&r.play().catch(()=>{})},n=()=>g(`Could not load this clip.`);return r.addEventListener(`loadedmetadata`,t),r.addEventListener(`error`,n),s?.([]),()=>{r.removeEventListener(`loadedmetadata`,t),r.removeEventListener(`error`,n),r.removeEventListener(`playing`,o),r.removeAttribute(`src`),r.load()}}if(!(`MediaSource`in window)&&r.canPlayType(`application/vnd.apple.mpegurl`)){r.src=e;let t=()=>{i&&r.play().catch(()=>{})};return r.addEventListener(`loadedmetadata`,t),r.addEventListener(`error`,()=>g(`Could not load this recording.`)),()=>{r.removeEventListener(`loadedmetadata`,t),r.removeEventListener(`playing`,o),r.removeAttribute(`src`),r.load()}}let c=!1;return a(async()=>{let{default:e}=await import(`./hls-IujbK-0_.js`);return{default:e}},[],import.meta.url).then(({default:t})=>{if(c)return;if(!t.isSupported()){r.canPlayType(`application/vnd.apple.mpegurl`)?(r.src=e,r.addEventListener(`loadedmetadata`,()=>{i&&r.play().catch(()=>{})}),r.addEventListener(`error`,()=>g(`Could not load this recording.`))):(y(!1),g(`HLS playback is not supported in this browser.`));return}let a=new t({enableWorker:!0,lowLatencyMode:!1,xhrSetup:e=>{e.withCredentials=!0,n&&e.setRequestHeader(`Authorization`,`Bearer ${n}`)}});d.current=a,a.loadSource(e),a.attachMedia(r),a.on(t.Events.MANIFEST_PARSED,(e,t)=>{let n=t.levels.map(roe);s?.(n.length>1?noe(n,m.current):[]),i&&r.play().catch(()=>{})}),a.on(t.Events.ERROR,(e,t)=>{t.fatal&&(y(!1),g(`Playback error (${t.type}).`))})}),()=>{c=!0,r.removeEventListener(`playing`,o),d.current?.destroy(),d.current=null}},[e,t,n,i,s]),b(()=>{let e=d.current;e!==null&&(e.currentLevel=l)},[l]),c(`div`,{className:`relative h-full w-full bg-black ${o??``}`,children:[v(`video`,{ref:u,controls:!0,playsInline:!0,className:`h-full w-full`,...r?{poster:r}:{}}),_&&!h?v(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:v(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-white/20 border-t-white/60`})}):null,h?v(`div`,{className:`absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-amber-400`,children:h}):null]})}function ioe({images:e,selectedFilename:t,uploadedName:n,onSelect:r,onUpload:i,className:a,accept:o=`image/*`,uploadLabel:s=`Upload...`}){return c(`div`,{className:`flex flex-wrap items-center gap-2 ${a??``}`,children:[e.map(e=>v(`button`,{onClick:()=>r(e.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===e.filename?`bg-primary text-primary-foreground border-primary`:`bg-surface border-border text-foreground hover:border-primary/50`}`,children:e.id??e.filename.replace(/\.[^.]+$/,``)},e.filename)),v(`button`,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=o,e.addEventListener(`change`,()=>{let t=e.files?.[0];if(!t)return;let n=new FileReader;n.addEventListener(`load`,()=>{let e=n.result,r=e.split(`,`)[1];r&&i(r,t.name,e)}),n.readAsDataURL(t)}),e.click()},className:`px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors`,children:s}),n&&v(`span`,{className:`text-xs text-foreground-subtle`,children:n})]})}var j6=`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 aoe({runtime:e,backend:t,modelId:n,agentId:r=`hub`,runtimes:i,backends:a,models:o,agents:s=[],onRuntimeChange:l,onBackendChange:u,onModelChange:d,onAgentChange:f,layout:p=`grid`,className:m,showAgent:h=!1}){let g=q();return c(`div`,{className:`${p===`grid`?`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`:p===`horizontal`?`flex flex-wrap items-end gap-4`:`space-y-3`} ${m??``}`,children:[h&&s.length>0&&c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.agent`,`Agent`)}),v(`select`,{value:r,onChange:e=>f?.(e.target.value),className:j6,children:s.map(e=>c(`option`,{value:e.id,children:[e.name,` (`,e.status,`)`]},e.id))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.runtime`,`Runtime`)}),v(`select`,{value:e,onChange:e=>{e.target.value===`python`&&l(`python`)},className:j6,children:i.map(e=>v(`option`,{value:e.value,disabled:!e.available,children:e.available?e.label:g(`uiLibrary.inferenceConfig.unavailable`,`{{label}} (unavailable)`,{label:e.label})},e.value))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.backend`,`Backend`)}),v(`select`,{value:t,onChange:e=>u(e.target.value),className:j6,children:a.map(e=>v(`option`,{value:e.id,disabled:!e.available,children:e.available?e.label:g(`uiLibrary.inferenceConfig.unavailable`,`{{label}} (unavailable)`,{label:e.label})},e.id))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.model`,`Model`)}),v(`select`,{value:n,onChange:e=>d(e.target.value),className:j6,children:o.length===0?v(`option`,{value:``,children:g(`uiLibrary.inferenceConfig.noModels`,`No compatible models`)}):o.map(e=>c(`option`,{value:e.id,children:[e.name,e.downloaded?` ✓`:``]},e.id))})]})]})}E();function M6({items:e,header:t,triggerClassName:n,title:r=`More actions`}){let[i,a]=C(!1),o=e.filter(e=>!e.hidden);return o.length===0?null:c(gl,{open:i,onOpenChange:a,children:[v(_l,{title:r,className:$(`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:v(Xr,{className:`h-4 w-4`})}),c(bl,{align:`end`,className:`min-w-[200px] p-1`,children:[t&&v(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t}),v(`ul`,{className:`space-y-0.5`,children:o.map((e,t)=>c(`li`,{children:[e.separatorBefore&&t>0&&v(`div`,{className:`my-1 h-px bg-border`}),c(`button`,{type:`button`,disabled:e.disabled,onClick:()=>{e.disabled||(e.onClick(),a(!1))},className:$(`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`,e.danger?`text-foreground hover:bg-danger/10 hover:text-danger`:`text-foreground hover:bg-surface-hover`),children:[e.icon&&v(e.icon,{className:$(`h-3.5 w-3.5 shrink-0 mt-0.5`,e.danger&&`text-danger/80`)}),c(`span`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`block leading-tight`,children:e.label}),e.description&&v(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:e.description})]})]})]},e.id))})]})]})}E();function ooe(e,t={}){let{serverUrl:n=`https://localhost:4443`,title:r,rootId:i=`root`}=t,a=document.getElementById(i);if(!a){console.error(`[mountAddonPage] Element #${i} not found`);return}Ao(a).render(s(Ts,null,s(BJ,{serverUrl:n,title:r,children:({trpc:t,theme:n})=>s(e,{trpc:t,theme:{isDark:n.resolvedMode===`dark`},navigate:e=>{console.log(`[dev] navigate:`,e)}})})))}E();function N6({selectedNodeId:e,onSelect:t,label:n=`Node`,hideIcon:r=!1,alwaysShow:i=!1,allowOffline:a=!1}){let o=q(),{nodes:s}=Lo(),l=qS(void 0),u=p(()=>MV(l.data),[l.data]);return!i&&s.length<=1?null:c(`div`,{className:`flex h-7 items-center gap-1.5`,children:[!r&&v(_n,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),n?v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:n}):null,v(`div`,{className:`flex h-7 overflow-hidden rounded-md border border-border text-xs font-medium`,children:s.map((n,r)=>{let i=e===n.id,s=NV(u,n.id),c=!a&&!n.isOnline;return v(`button`,{type:`button`,onClick:()=>t(n.id),disabled:c,title:n.isOnline?n.name:o(`uiLibrary.nodePicker.offline`,`{{name}} (offline)`,{name:n.name}),className:$(`inline-flex h-7 items-center px-2.5 transition-colors`,i?$(AV(s),kV(s)):$(`bg-transparent hover:bg-surface-hover`,kV(s),!c&&`opacity-70 hover:opacity-100`),r>0&&`border-l border-border`,c&&`cursor-not-allowed opacity-50`),children:n.shortName},n.id)})})]})}function soe({title:e,subtitle:t,actions:n,className:r}){return c(`div`,{className:$(`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,r),children:[c(`div`,{className:`min-w-0`,children:[v(`h1`,{className:`text-lg font-semibold text-foreground`,children:e}),t!==void 0&&t!==``&&v(`p`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:t})]}),n!==void 0&&v(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]})}function P6({icon:e,title:t,subtitle:n,actions:r,nav:i,fill:a=!1,className:o,children:s}){let l=!!t||n!=null||r!=null,u=l||i!=null;return c(`div`,{className:$(`overflow-x-clip p-2 sm:p-4`,a?`flex h-full min-h-0 flex-col gap-4`:`space-y-4`,o),children:[u&&c(`div`,{className:`shrink-0 space-y-3`,children:[l&&c(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[c(`div`,{className:`min-w-0`,children:[t!==void 0&&t!==``&&c(`h1`,{className:`flex items-center gap-2 text-lg font-semibold text-foreground`,children:[e!==void 0&&v(e,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),t]}),n!=null&&v(`p`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:n})]}),r!=null&&v(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r})]}),i]}),a?v(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:s}):s]})}E();var coe=1500;function F6({tabKey:e,children:t,className:n,fill:r=!1}){let i=f(null),a=f(0),[o,s]=C(null),c=f(e),l=()=>{let e=i.current?.offsetHeight??0;e>0&&(a.current=e),s(t=>t!==null&&e>=t?null:t)};return u(()=>{if(c.current===e)return;c.current=e;let t=a.current;t>0&&s(t)},[e]),b(l),b(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(l);return t.observe(e),()=>t.disconnect()},[]),b(()=>{if(o===null)return;let e=setTimeout(()=>s(null),coe);return()=>clearTimeout(e)},[o]),v(`div`,{className:r?`flex min-h-0 flex-1 flex-col ${n??``}`:n,style:o===null?void 0:{minHeight:o},children:v(`div`,{ref:i,className:r?`flex h-full min-h-0 flex-1 flex-col`:void 0,children:t})})}E();function I6(){return new URLSearchParams(window.location.search)}function loe(e){let t=I6();e(t);let n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.replaceState(null,``,r)}function L6({icon:e,title:t,subtitle:n,actions:r,sections:i,defaultSection:a,paramName:o=`tab`,sectionsLabel:s,className:l,sectionsOnly:u=!1,activeSection:d,onSectionChange:f,fill:p=!1}){let m=d!==void 0&&f!==void 0,h=a??i[0]?.id??``,[g,y]=C(()=>m?null:I6().get(o));b(()=>{if(m)return;let e=()=>y(I6().get(o));return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,o]);let x=m?d:g,S=i.some(e=>e.id===x)?x??h:h,w=i.find(e=>e.id===S)??i[0],T=_(e=>{let t=e===S?[]:w?.ownedParams??[];if(m){f(e,t);return}loe(n=>{for(let e of t)n.delete(e);n.set(o,e)}),y(e)},[w?.ownedParams,S,m,f,o]),E=s??(t!==void 0&&t!==``?`${t} sections`:`Sections`),D=v(YB,{value:S,onValueChange:T,className:p?`shrink-0`:void 0,children:v(XB,{"aria-label":E,children:i.map(e=>v(ZB,{value:e.id,"data-testid":`section-${e.id}`,children:e.label},e.id))})}),O=v(F6,{tabKey:S,fill:p,children:p?v(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:w?.content}):w?.content}),k=p?c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[D,O]}):c(P,{children:[D,O]});return u?v(`div`,{className:p?`flex h-full min-h-0 flex-col gap-3 ${l??``}`:l?`space-y-3 ${l}`:`space-y-3`,"data-testid":`sectioned-page-sections-only`,children:k}):v(P6,{icon:e,title:t??``,subtitle:n,actions:r,fill:p,className:l,children:k})}function uoe({start:e,end:t,className:n,testId:r}){return c(`div`,{className:$(`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,n),"data-testid":r,children:[e!=null&&v(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:e}),t!=null&&v(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 sm:justify-end`,children:t})]})}function R6({open:e,onClose:t,title:n,icon:r,error:i,width:a=`lg`,children:o,beforeBody:s,footer:l,testId:u}){return e?v(SL,{open:!0,onOpenChange:e=>!e&&t(),children:c(TL,{width:a,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":u,children:[v(`div`,{className:`mb-3 flex shrink-0 items-center gap-2 pr-10`,children:c(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground`,children:[r!==void 0&&v(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),v(`span`,{className:`truncate`,children:n})]})}),i!=null&&i!==``&&v(`div`,{className:`mb-3 shrink-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:i}),s!=null&&v(`div`,{className:`mb-3 shrink-0`,children:s}),v(DL,{className:`space-y-3 px-1`,children:o}),l!=null&&v(OL,{className:`mt-3 shrink-0`,children:l})]})}):null}E();var z6=`camstack:url-query`;function B6(e){return new URLSearchParams(window.location.search).get(e)}function V6(){window.dispatchEvent(new Event(z6))}function doe(e,t){let n=new URLSearchParams(window.location.search);t===null||t===``?n.delete(e):n.set(e,t);let r=n.toString(),i=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,``,i)}var H6=!1;function foe(){if(H6||typeof window>`u`)return;H6=!0;let e=window.history.replaceState.bind(window.history),t=window.history.pushState.bind(window.history);window.history.replaceState=(...t)=>{e(...t),V6()},window.history.pushState=(...e)=>{t(...e),V6()}}function U6(e){foe();let[t,n]=C(()=>B6(e));return b(()=>{let t=()=>n(B6(e));return window.addEventListener(`popstate`,t),window.addEventListener(z6,t),()=>{window.removeEventListener(`popstate`,t),window.removeEventListener(z6,t)}},[e]),[t,_(t=>{doe(e,t),n(t)},[e])]}E();function W6(e={}){let t=e.newKey??`new`,n=e.editKey??`edit`,[r,i]=U6(t),[a,o]=U6(n);return{state:p(()=>a!==null&&a!==``?{mode:`edit`,id:a}:r===`1`?{mode:`new`}:{mode:`closed`},[a,r]),openNew:_(()=>{o(null),i(`1`)},[o,i]),openEdit:_(e=>{i(null),o(e)},[o,i]),close:_(()=>{i(null),o(null)},[o,i])}}function poe({children:e,selected:t=!1,onSelect:n,label:r,className:i,testId:a}){let o=n!==void 0;return v(`div`,{role:o?`button`:void 0,tabIndex:o?0:void 0,"aria-pressed":o?t:void 0,"aria-label":r,"data-testid":a,onClick:n,onKeyDown:e=>{o&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:$(`relative aspect-square min-w-0 overflow-hidden rounded-md border bg-surface`,t?`border-primary ring-1 ring-primary`:`border-border`,o&&`cursor-pointer hover:border-foreground-subtle`,i),children:e})}function G6({status:e,children:t,pendingMessage:n=`Loading…`,emptyMessage:r=`Nothing to show`,className:i,testId:a}){return e===`pending`?v(`p`,{className:`animate-pulse py-8 text-center text-xs text-foreground-subtle`,"data-testid":a,children:n}):e===`empty`?v(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,"data-testid":a,children:r}):v(`div`,{className:$(he,ki,i),"data-testid":a,children:t})}var moe={Activity:ai,Eye:Zt,AlertTriangle:zi,PauseCircle:gn,PowerOff:st};function K6({phase:e,...t}){let n=moe[QG(e).icon];return v(n,{...t})}E();function hoe(e){let t=new Map;for(let n of e.slots)for(let e of n.addons)t.set(e.id,e);return t}function q6(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function J6({addon:e,onClick:t}){return v(`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:c(`div`,{className:`flex items-center gap-3`,children:[v(Jn,{className:`h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0`}),c(`div`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate`,children:e.name}),c(`div`,{className:`flex items-center gap-1 mt-0.5 flex-wrap`,children:[e.inputClasses.map(e=>v(`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:e},e)),e.inputClasses.length>0&&e.outputClasses.length>0&&v(`span`,{className:`text-foreground-subtle/25 text-[10px]`,children:`→`}),e.outputClasses.map(e=>v(`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:e},e))]})]})]})})}function goe({schema:e,steps:t,onChange:n,readOnly:r=!1,excludeAddons:i=[],showOnlyEnabled:a=!1,showSlotLabels:o=!1}){let s=q(),l=p(()=>new Set(i),[i]),u=p(()=>hoe(e),[e]);function d(e){n(t.map(t=>t.addonId===e.addonId?f(e):t))}function f(e){let t=e.children.some(e=>e.enabled||e.children.some(e=>e.enabled));return{...e,enabled:e.enabled||t,children:e.children.map(e=>{let t=e.children.some(e=>e.enabled);return{...e,enabled:e.enabled||t}})}}function m(e,r){let i=q6(r);n(t.map(t=>t.addonId===e?{...t,children:[...t.children,i]}:t))}function h(e){let t=new Set;for(let n of e){t.add(n.addonId);for(let e of n.children)t.add(e.addonId);let e=h(n.children);for(let n of e)t.add(n)}return t}let g=h(t);function _(t){let n=u.get(t.addonId);if(!n)return[];let r=e.slots.find(e=>e.id===n.slot)?.parentSlot==null,i=n.childSlots,a=new Set(t.children.map(e=>e.addonId)),o=[];for(let n of e.slots)if(i.includes(n.id))for(let e of n.addons){if(a.has(e.id)||l.has(e.id))continue;let n=e.inputClasses.length===0;n&&!r||(n||e.inputClasses.some(e=>t.outputClasses.includes(e)))&&o.push(e)}return o}function y(e){let i=a?{...e,children:e.children.filter(e=>e.enabled).map(e=>({...e,children:e.children.filter(e=>e.enabled)}))}:e,l=a?[]:_(i);return c(`div`,{className:`space-y-1.5`,children:[v(pB,{step:i,schema:u.get(i.addonId)??null,allSchemas:u,onChange:d,onDelete:r?void 0:e=>n(t.filter(t=>t.addonId!==e)),readOnly:r}),(i.children.length>0||l.length>0)&&c(`div`,{className:`ml-4 pl-3 border-l border-border/60 space-y-1.5`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40`,children:s(`uiLibrary.pipelineBuilder.slotCropper`,`Slot: Cropper / Classifier`)}),i.children.map(e=>{let t=_(e);return c(`div`,{className:`space-y-1.5`,children:[v(pB,{step:e,schema:u.get(e.addonId)??null,allSchemas:u,depth:1,onChange:e=>{d({...i,children:i.children.map(t=>t.addonId===e.addonId?e:t)})},onDelete:r?void 0:e=>{d({...i,children:i.children.filter(t=>t.addonId!==e)})},readOnly:r}),(e.children.length>0||t.length>0)&&c(`div`,{className:`ml-4 pl-3 border-l border-border/40 space-y-1.5`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30`,children:s(`uiLibrary.pipelineBuilder.slotRecognizer`,`Slot: Recognizer`)}),e.children.map(t=>v(pB,{step:t,schema:u.get(t.addonId)??null,allSchemas:u,depth:2,onChange:t=>{d({...i,children:i.children.map(n=>n.addonId===e.addonId?{...n,children:n.children.map(e=>e.addonId===t.addonId?t:e)}:n)})},onDelete:r?void 0:t=>{d({...i,children:i.children.map(n=>n.addonId===e.addonId?{...n,children:n.children.filter(e=>e.addonId!==t)}:n)})},readOnly:r},t.addonId)),!r&&t.map(t=>v(J6,{addon:t,onClick:()=>{let n=q6(t);d({...i,children:i.children.map(t=>t.addonId===e.addonId?{...t,children:[...t.children,n]}:t)})}},t.id))]})]},e.addonId)}),!r&&l.map(e=>v(J6,{addon:e,onClick:()=>m(i.addonId,e)},e.id))]})]},i.addonId)}return v(`div`,{className:`space-y-4`,children:e.slots.filter(e=>e.parentSlot===null).toSorted((e,t)=>e.priority-t.priority).map(e=>{let i=t.filter(t=>t.slot===e.id&&!l.has(t.addonId)),u=a?i.filter(e=>e.enabled):i,d=a?[]:e.addons.filter(e=>!g.has(e.id)&&!l.has(e.id)),f=new Map,p=[];for(let e of u)e.group?(f.has(e.group)||f.set(e.group,[]),f.get(e.group).push(e)):p.push(e);return c(`div`,{className:`space-y-2`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50`,children:s(`uiLibrary.pipelineBuilder.slotLabel`,`Slot: {{label}}`,{label:e.label})}),p.map(e=>y(e)),[...f.entries()].map(([e,t])=>c(`div`,{className:`space-y-2 rounded-lg border border-border/40 p-2`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1`,children:e}),t.map(e=>y(e))]},e)),!r&&d.map(e=>v(J6,{addon:e,onClick:()=>{n([...t,q6(e)])}},e.id))]},e.id)})})}function _oe({options:e,value:t,onChange:n}){let r=q();return v(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>{let i=e.id===t;return c(`button`,{onClick:()=>e.available&&n(e.id),disabled:!e.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${i?`border-primary/40 bg-primary/10 text-primary`:e.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:[v(Mr,{className:`h-3.5 w-3.5 shrink-0`}),e.label,e.isBest&&c(`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:[v(see,{className:`h-2.5 w-2.5`}),r(`uiLibrary.pipelineRuntimeSelector.best`,`Best`)]}),e.platformScore!=null&&c(`span`,{className:`text-[10px] text-foreground-subtle/60`,children:[`(`,e.platformScore,`)`]}),v(`span`,{className:`h-1.5 w-1.5 rounded-full ${e.available?`bg-success`:`bg-danger`}`})]},e.id)})})}var voe={onvif:{colorClass:`bg-provider-onvif`,label:`ONVIF`},hikvision:{colorClass:`bg-provider-hikvision`,label:`Hikvision`},reolink:{colorClass:`bg-provider-reolink`,label:`Reolink`},homeAssistant:{colorClass:`bg-provider-homeAssistant`,label:`Home Assistant`},rtsp:{colorClass:`bg-provider-rtsp`,label:`RTSP`}};function yoe({provider:e,showLabel:t=!0,className:n}){let r=voe[e];return c(`span`,{className:$(`inline-flex items-center gap-1.5 text-xs`,n),children:[v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-sm`,r.colorClass),"aria-hidden":`true`}),t&&v(`span`,{className:`text-foreground`,children:r.label})]})}E();function boe({open:e,onOpenChange:t,types:n,onCreate:r,submitting:i=!1,title:a,description:o}){let s=q(),l=a??s(`uiLibrary.addProviderEntryDialog.title`,`Add provider entry`),u=o??s(`uiLibrary.addProviderEntryDialog.description`,`Pick a provider type and name this credential set.`),d=y(),f=y(),[p,m]=C(``),[h,g]=C(``);b(()=>{e&&(m(n[0]?.typeId??``),g(``))},[e,n]);let _=p!==``&&h.trim().length>0&&!i&&n.length>0,x=()=>{_&&r({typeId:p,name:h.trim()})};return v(SL,{open:e,onOpenChange:e=>!i&&t(e),children:c(TL,{width:`sm`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(EL,{children:[v(kL,{children:l}),v(AL,{children:u})]}),v(DL,{className:`space-y-3`,children:n.length===0?v(`p`,{className:`text-xs text-foreground-subtle`,children:s(`uiLibrary.addProviderEntryDialog.noTypes`,`No provider types are available yet. Install a training provider addon first.`)}):c(P,{children:[c(`div`,{className:`space-y-1`,children:[v(LB,{htmlFor:d,children:s(`uiLibrary.addProviderEntryDialog.providerType`,`Provider type`)}),c(`div`,{className:`flex items-center gap-2`,children:[v(xoe,{url:n.find(e=>e.typeId===p)?.iconUrl??null}),v(Yl,{id:d,"aria-label":s(`uiLibrary.addProviderEntryDialog.providerType`,`Provider type`),className:`flex-1`,value:p,onChange:e=>m(e.target.value),options:n.map(e=>({value:e.typeId,label:e.label})),disabled:i})]})]}),c(`div`,{className:`space-y-1`,children:[v(LB,{htmlFor:f,children:s(`uiLibrary.addProviderEntryDialog.name`,`Name`)}),v(Bl,{id:f,"aria-label":s(`uiLibrary.addProviderEntryDialog.name`,`Name`),value:h,onChange:e=>g(e.target.value),placeholder:s(`uiLibrary.addProviderEntryDialog.namePlaceholder`,`Production`),disabled:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())}})]})]})}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>t(!1),children:s(`uiLibrary.addProviderEntryDialog.cancel`,`Cancel`)}),c(_A,{type:`button`,size:`sm`,disabled:!_,onClick:x,children:[i&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`uiLibrary.addProviderEntryDialog.create`,`Create`)]})]})]})})}function xoe({url:e}){return e===null?v(`span`,{className:$(`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,`border border-border bg-surface text-[10px] text-foreground-subtle`),"aria-hidden":!0,children:`?`}):v(`img`,{src:e,alt:``,className:`h-7 w-7 shrink-0 rounded-md border border-border bg-surface object-contain p-0.5`})}var Y6=$(Mi,`min-w-0 max-w-full gap-1.5 py-1 pl-1 pr-2.5 text-xs font-normal`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),Soe=$(xi,`font-medium`),Coe=En,woe={ok:`bg-success`,warning:`bg-warning`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`},X6={ok:{key:`uiLibrary.providerEntryPills.status.ok`,fallback:`OK`},warning:{key:`uiLibrary.providerEntryPills.status.warning`,fallback:`Warning`},error:{key:`uiLibrary.providerEntryPills.status.error`,fallback:`Error`},unknown:{key:`uiLibrary.providerEntryPills.status.unknown`,fallback:`Unknown`}};function Toe({label:e,entries:t,selectedEntryId:n,onSelect:r,onAdd:i,addLabel:a}){let o=q(),s=a??o(`uiLibrary.providerEntryPills.addProvider`,`Add provider`);return v(`nav`,{"aria-label":e,className:`min-w-0`,children:c(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.map(e=>v(Eoe,{entry:e,current:e.entryId===n,onSelect:r},e.entryId)),i!==void 0&&c(`button`,{type:`button`,onClick:i,className:$(Y6,`border-dashed border-border pl-2 text-foreground-subtle`,`hover:border-primary/50 hover:text-foreground`),children:[v(Se,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`span`,{className:`truncate`,children:s})]})]})})}function Eoe({entry:e,current:t,onSelect:n}){let r=q(),i=e.status===`ok`;return c(`button`,{type:`button`,"aria-current":t?`true`:void 0,"data-testid":`provider-entry-pill-${e.entryId}`,onClick:()=>n(e.entryId),className:$(Y6,t?Soe:Coe),children:[v(Doe,{url:e.iconUrl}),v(`span`,{className:`truncate`,children:e.name}),v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,woe[e.status]),"aria-hidden":!0}),v(`span`,{className:i?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:r(X6[e.status].key,X6[e.status].fallback)})]})}function Doe({url:e}){return e===null?v(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-surface text-[9px] text-foreground-subtle`,"aria-hidden":!0,children:`?`}):v(`img`,{src:e,alt:``,className:`h-5 w-5 shrink-0 rounded-full object-contain`})}function Z6(e){return e===Na}function Ooe(e){return Z6(e)?``:typeof e==`string`?e:``}function koe(e,t){return Z6(t)&&e.length===0?Na:e}function Q6(e,t,n){return n.secret===!0?!0:t.includes(e)}function $6(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Aoe(e,t){let n=t.description;return typeof n==`string`&&n.length>0?n:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function e8(e){return typeof e==`string`?e:``}function joe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Moe(e){return e===!0}function Noe(e){try{let t=JSON.parse(e);return $6(t)?t:null}catch{return null}}function Poe(e){return ha(e)||Bi(e)?e:Z6(e)?{$secret:null,v:1,set:!0}:null}function Foe({name:e,label:t,required:n,value:r,disabled:i,onPatch:a}){return v(O6,{label:t,required:n,children:v(au,{field:{type:`password`,key:e,label:t,required:n},value:Poe(r),onChange:a,disabled:i})})}function t8(e){let{path:t,name:n,node:r,value:i,secretPaths:a,required:o,disabled:s,onPatch:l}=e,u=Aoe(n,r),d=q();if(Q6(t,a,r))return v(Foe,{name:n,label:u,required:o,value:i,disabled:s,onPatch:e=>l(t,e)});let f=r.enum;if(Array.isArray(f)&&f.every(e=>typeof e==`string`))return v(O6,{label:u,required:o,children:v(Yl,{value:e8(i),onChange:e=>l(t,e.target.value),disabled:s,options:f.map(e=>({value:e,label:e}))})});let p=r.type;if(p===`boolean`)return v(O6,{label:u,required:o,children:v(VB,{checked:Moe(i),onCheckedChange:e=>l(t,e),disabled:s})});if(p===`integer`||p===`number`)return v(O6,{label:u,required:o,children:v(Bl,{type:`number`,value:joe(i)??``,onChange:e=>{let n=e.target.value;l(t,n===``?void 0:Number(n))},disabled:s})});if(p===`object`){let e=r.properties;if($6(e)){let n=$6(i)?i:{},o=Array.isArray(r.required)?r.required.filter(e=>typeof e==`string`):[];return c(`fieldset`,{className:`space-y-3 rounded-lg border border-border-subtle p-3`,children:[v(`legend`,{className:`px-1 text-xs font-medium text-foreground-muted`,children:u}),Object.entries(e).map(([e,r])=>$6(r)?v(t8,{path:`${t}.${e}`,name:e,node:r,value:n[e],secretPaths:a,required:o.includes(e),disabled:s,onPatch:l},e):null)]})}let n=$6(i)?JSON.stringify(i,null,2):`{}`;return v(O6,{label:u,required:o,description:d(`uiLibrary.recordEntries.jsonObject`,`JSON object`),children:v(`textarea`,{className:$(`min-h-[8rem] w-full resize-y rounded-md border border-border bg-surface px-2.5 py-2 font-mono text-xs text-foreground`,`placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary`,`disabled:cursor-not-allowed disabled:opacity-50`),rows:6,defaultValue:n,disabled:s,onBlur:e=>{let n=Noe(e.target.value);n!==null&&l(t,n)}})})}return p===`string`||p===void 0?v(O6,{label:u,required:o,children:v(Bl,{value:e8(i),onChange:e=>l(t,e.target.value),disabled:s})}):null}function n8(e,t,n){let r=t.split(`.`);if(r.length===1)return{...e,[r[0]]:n};let[i,...a]=r,o=i,s=$6(e[o])?e[o]:{};return{...e,[o]:n8(s,a.join(`.`),n)}}function r8({schema:e,secretPaths:t,value:n,onChange:r,disabled:i}){let a=e.properties;if(!$6(a))return null;let o=Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[],s=(e,t)=>{r(n8(n,e,t))};return v(`div`,{className:`space-y-3`,children:Object.entries(a).map(([e,r])=>$6(r)?v(t8,{path:e,name:e,node:r,value:n[e],secretPaths:t,required:o.includes(e),disabled:i,onPatch:s},e):null)})}E();function i8(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ioe(e){let t=e.properties;if(!i8(t))return{};let n={};for(let[e,r]of Object.entries(t))if(i8(r)){if(r.default!==void 0){n[e]=r.default;continue}r.type===`boolean`?n[e]=!1:r.type===`object`&&(n[e]={})}return n}function a8({kind:e,rowActions:t,extraColumns:n=[],showUpdated:r=!0,minWidthPx:i}){let a=q(),o=k(),s=li(),l=W6({newKey:`entryNew`,editKey:`entryEdit`}),u=Gw({owner:e.owner,kind:e.kind},{staleTime:15e3}),d=Kw({onSuccess:async()=>{await o.invalidateQueries({queryKey:[[`recordEntries`]]}),l.close()}}),f=qw({onSuccess:async()=>{await o.invalidateQueries({queryKey:[[`recordEntries`]]})}}),m=u.data?.entries??[],h=p(()=>{let e=l.state;return e.mode===`edit`?m.find(t=>t.id===e.id)??null:null},[m,l.state]),[g,y]=C({}),[b,x]=C(null),S=_(()=>{y(Ioe(e.fields)),x(null),l.openNew()},[l,e.fields]),w=_(e=>{y({...e.data}),x(null),l.openEdit(e.id)},[l]),T=_(async t=>{await s({title:a(`uiLibrary.recordEntries.deleteTitle`,`Delete entry`),message:a(`uiLibrary.recordEntries.deleteDescription`,`Remove "{{name}}" permanently?`,{name:t.name}),confirmLabel:a(`uiLibrary.recordEntries.deleteConfirm`,`Delete`),variant:`danger`})&&await f.mutateAsync({owner:e.owner,kind:e.kind,id:t.id})},[s,f,e.kind,e.owner,a]),E=p(()=>[{key:`name`,header:a(`uiLibrary.recordEntries.colName`,`Name`),render:e=>v(_A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto max-w-full justify-start px-0 py-0 font-medium hover:underline`,onClick:()=>w(e),children:v(`span`,{className:`truncate`,children:e.name})})},...r?[{key:`updated`,header:a(`uiLibrary.recordEntries.colUpdated`,`Updated`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,title:new Date(e.updatedAt).toLocaleString(),children:new Date(e.updatedAt).toLocaleDateString()})}]:[],...n,{key:`actions`,header:``,align:`right`,nowrap:!0,width:`w-px`,render:e=>c(`span`,{className:`flex justify-end gap-1`,children:[t?.(e),v(_A,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>w(e),children:v(Gt,{className:`h-3.5 w-3.5`})}),v(_A,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void T(e),children:v(Pe,{className:`h-3.5 w-3.5 text-danger`})})]})}],[n,T,w,t,r,a]),D=l.state.mode!==`closed`,O=l.state.mode===`new`?a(`uiLibrary.recordEntries.addTitle`,`Add entry`):a(`uiLibrary.recordEntries.editTitle`,`Edit entry`),A=async()=>{x(null);try{if(l.state.mode===`new`)await d.mutateAsync({owner:e.owner,kind:e.kind,data:g});else if(l.state.mode===`edit`&&h!==null)await d.mutateAsync({owner:e.owner,kind:e.kind,id:h.id,data:g,ifRev:h.rev});else{x(a(`uiLibrary.recordEntries.saveUnavailable`,`Nothing to save`));return}}catch(e){x(e instanceof Error?e.message:a(`uiLibrary.recordEntries.saveFailed`,`Save failed`))}};return c(`div`,{className:`space-y-3`,children:[v(`div`,{className:`flex justify-end`,children:c(_A,{type:`button`,size:`sm`,onClick:S,children:[v(Se,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.recordEntries.add`,`Add`)]})}),u.isError&&v(eN,{message:u.error instanceof Error?u.error.message:a(`uiLibrary.recordEntries.loadFailed`,`Could not load entries`)}),u.isPending?v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):m.length===0?v(QM,{title:a(`uiLibrary.recordEntries.emptyTitle`,`No entries yet`),description:a(`uiLibrary.recordEntries.emptyDescription`,`Add the first row for this kind.`)}):v(gU,{...i===void 0?{}:{minWidthPx:i},columns:E,rows:m,rowKey:e=>e.id,maxBodyHeight:mU,emptyMessage:a(`uiLibrary.recordEntries.emptyTitle`,`No entries yet`)}),v(R6,{open:D,onClose:l.close,title:O,error:b,footer:v(_A,{type:`button`,size:`sm`,disabled:d.isPending,onClick:()=>void A(),children:d.isPending?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):a(`uiLibrary.recordEntries.save`,`Save`)}),children:v(r8,{schema:e.fields,secretPaths:e.secretPaths,value:g,onChange:y,disabled:d.isPending})})]})}E();function o8({kind:e}){let t=q(),[n,r]=C(null),i=X.storageAdmin.readRecords.useQuery({owner:e.owner,kind:e.kind,limit:100,desc:!0},{staleTime:15e3}),a=i.data?.records??[],o=p(()=>[{key:`id`,header:t(`uiLibrary.storageRecords.colId`,`Id`),render:e=>v(_A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto max-w-full justify-start px-0 py-0 font-mono text-xs hover:underline`,onClick:()=>r(e),children:v(`span`,{className:`truncate`,children:e.id})})},{key:`deviceId`,header:t(`uiLibrary.storageRecords.colDevice`,`Device`),nowrap:!0,render:e=>e.deviceId===null?v(`span`,{className:`text-foreground-subtle`,children:`—`}):v(`span`,{className:`font-mono text-xs`,children:e.deviceId})},{key:`at`,header:t(`uiLibrary.storageRecords.colAt`,`At`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.at===null?`—`:new Date(e.at).toLocaleString()})},{key:`updatedAt`,header:t(`uiLibrary.storageRecords.colUpdated`,`Updated`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,children:new Date(e.updatedAt).toLocaleString()})}],[t]);return c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:`${e.owner}/${e.kind}`}),v(Bk,{variant:`neutral`,style:`outline`,children:e.database}),v(Bk,{variant:`neutral`,style:`outline`,children:e.class}),v(Bk,{variant:e.state===`declared`?`default`:`neutral`,children:e.state}),e.entry?v(Bk,{variant:`info`,children:t(`uiLibrary.storageRecords.entryKind`,`Entry`)}):null]}),i.isError?v(eN,{message:i.error instanceof Error?i.error.message:t(`uiLibrary.storageRecords.loadFailed`,`Could not load records`)}):i.isPending?v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):a.length===0?v(QM,{title:t(`uiLibrary.storageRecords.emptyTitle`,`No rows`),description:t(`uiLibrary.storageRecords.emptyDescription`,`This kind has no stored records yet.`)}):v(gU,{columns:o,rows:a,rowKey:e=>e.id,maxBodyHeight:mU,emptyMessage:t(`uiLibrary.storageRecords.emptyTitle`,`No rows`)}),v(SL,{open:n!==null,onOpenChange:e=>!e&&r(null),children:c(TL,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(EL,{children:[v(kL,{children:t(`uiLibrary.storageRecords.inspectTitle`,`Record`)}),n===null?null:v(AL,{className:`font-mono`,children:n.id})]}),v(DL,{children:n===null?null:v(_G,{maxHeight:480,children:JSON.stringify(n,null,2)})})]})})]})}function s8(e){return`${e.owner}/${e.kind}`}function c8(e){return e.entry?`entry`:`record`}function l8(e){return e.rows===null?`unknown`:e.rows>0?`has-rows`:`empty`}function u8(e,t){let n=new Map;for(let e of t??[])n.set(s8(e),e.title);return e.map(e=>({kind:e,entryTitle:e.entry?n.get(s8(e))??null:null}))}var d8=[{id:`kind`,value:e=>s8(e.kind)},{id:`owner`,value:e=>e.kind.owner},{id:`type`,value:e=>c8(e.kind)},{id:`database`,value:e=>e.kind.database},{id:`class`,value:e=>e.kind.class},{id:`state`,value:e=>e.kind.state},{id:`contents`,value:e=>l8(e.kind)}];function f8(e){let{kind:t}=e;return[t.owner,t.kind,t.class,t.database,t.state,e.entryTitle??``]}E();var p8=`recordsOwner`,m8=`recordsKind`;function Loe(e){return e===null?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function Roe(e,t){switch(e){case`kind`:return t(`uiLibrary.dataRecords.facetKind`,`Kind`);case`owner`:return t(`uiLibrary.dataRecords.facetOwner`,`Owner`);case`type`:return t(`uiLibrary.dataRecords.facetType`,`Type`);case`database`:return t(`uiLibrary.dataRecords.facetDatabase`,`Database`);case`class`:return t(`uiLibrary.dataRecords.facetClass`,`Class`);case`state`:return t(`uiLibrary.dataRecords.facetState`,`State`);default:return t(`uiLibrary.dataRecords.facetContents`,`Contents`)}}function zoe(e,t,n){return e===`type`?t===`entry`?n(`uiLibrary.dataRecords.typeEntry`,`Entries (editable)`):n(`uiLibrary.dataRecords.typeRecord`,`Records (read-only)`):e===`contents`?t===`has-rows`?n(`uiLibrary.dataRecords.contentsHasRows`,`Has rows`):t===`empty`?n(`uiLibrary.dataRecords.contentsEmpty`,`Empty`):n(`uiLibrary.dataRecords.contentsUnknown`,`Count unknown`):t}function Boe({kind:e,entryKinds:t,entryKindsPending:n,entryKindsError:r}){let i=q();if(!e.entry)return v(o8,{kind:e});if(n)return v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})});if(r!==null)return v(eN,{message:r});let a=t?.find(t=>s8(t)===s8(e));return a===void 0?v(eN,{message:i(`uiLibrary.dataRecords.entryKindMissing`,`This entry kind is not served by the entries service.`)}):c(`div`,{className:`space-y-2`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:a.title}),v(a8,{kind:a})]})}function h8(){let e=q(),t=X.storageAdmin.listKinds.useQuery({},{staleTime:3e4}),n=Ww({},{staleTime:3e4}),[r,i]=U6(p8),[a,o]=U6(m8),s=n.data?.kinds,l=p(()=>u8(t.data?.kinds??[],s),[s,t.data?.kinds]),u=PG(l,{searchText:f8,facetGroups:d8}),d=p(()=>l.find(e=>e.kind.owner===r&&e.kind.kind===a)?.kind??null,[a,r,l]),f=_(e=>{i(e.owner),o(e.kind)},[o,i]),m=p(()=>[{key:`kind`,header:e(`uiLibrary.dataRecords.colKind`,`Kind`),render:e=>c(`span`,{className:`flex flex-col`,children:[v(`span`,{className:`font-mono text-xs`,children:s8(e.kind)}),e.entryTitle===null?null:v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.entryTitle})]}),sortValue:e=>s8(e.kind)},{key:`type`,header:e(`uiLibrary.dataRecords.colType`,`Type`),nowrap:!0,render:t=>t.kind.entry?v(Bk,{variant:`info`,children:e(`uiLibrary.dataRecords.badgeEntry`,`Entry`)}):v(Bk,{variant:`neutral`,children:e(`uiLibrary.dataRecords.badgeRecord`,`Record`)}),sortValue:e=>e.kind.entry?`entry`:`record`},{key:`database`,header:e(`uiLibrary.dataRecords.colDatabase`,`DB`),nowrap:!0,render:e=>v(Bk,{variant:`neutral`,style:`outline`,children:e.kind.database}),sortValue:e=>e.kind.database},{key:`class`,header:e(`uiLibrary.dataRecords.colClass`,`Class`),nowrap:!0,render:e=>v(`span`,{className:`text-xs text-foreground-muted`,children:e.kind.class}),sortValue:e=>e.kind.class},{key:`state`,header:e(`uiLibrary.dataRecords.colState`,`State`),nowrap:!0,render:e=>v(Bk,{variant:e.kind.state===`declared`?`default`:`neutral`,children:e.kind.state}),sortValue:e=>e.kind.state},{key:`rows`,header:e(`uiLibrary.dataRecords.colRows`,`Rows`),align:`right`,nowrap:!0,render:e=>v(`span`,{className:`font-mono text-xs tabular-nums`,children:e.kind.rows===null?`—`:e.kind.rows}),sortValue:e=>e.kind.rows??-1},{key:`bytes`,header:e(`uiLibrary.dataRecords.colSize`,`Est. size`),align:`right`,nowrap:!0,render:e=>v(`span`,{className:`text-xs text-foreground-subtle`,children:Loe(e.kind.bytesEstimate)}),sortValue:e=>e.kind.bytesEstimate??-1},{key:`open`,header:``,align:`right`,nowrap:!0,render:t=>v(_A,{type:`button`,size:`sm`,variant:d!==null&&s8(d)===s8(t.kind)?`primary`:`outline`,onClick:()=>f(t.kind),children:t.kind.entry?e(`uiLibrary.dataRecords.manage`,`Manage`):e(`uiLibrary.dataRecords.viewRows`,`View rows`)}),notSortableReason:e(`uiLibrary.dataRecords.actionColumn`,`Actions`)}],[d,f,e]);return t.isError?v(eN,{message:t.error instanceof Error?t.error.message:e(`uiLibrary.dataRecords.kindsFailed`,`Could not load record kinds`)}):t.isPending?v(`div`,{className:`flex justify-center py-10 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):l.length===0?v(QM,{title:e(`uiLibrary.dataRecords.noKindsTitle`,`No record kinds`),description:e(`uiLibrary.dataRecords.noKindsDescription`,`No addon has declared a record kind on this hub yet.`)}):c(`div`,{className:`space-y-4`,children:[v(NG,{state:u.state,facets:u.facets,groups:u.groups.map(t=>({...t,label:Roe(t.id,e),display:`menu`,facetLabel:n=>zoe(t.id,n,e)})),labels:{searchPlaceholder:e(`uiLibrary.dataRecords.search`,`Search kinds…`),searchLabel:e(`uiLibrary.dataRecords.searchLabel`,`Search record kinds`),facetsLabel:e(`uiLibrary.dataRecords.facetsLabel`,`Filter record kinds`),clearLabel:e(`uiLibrary.dataRecords.clearFilters`,`Clear filters`)},onSearch:u.setSearch,onToggleFacet:u.toggleFacet,onToggleGroupFacet:u.toggleGroupFacet,onClear:u.clear}),v(gU,{columns:m,rows:u.rows,rowKey:e=>s8(e.kind),maxBodyHeight:mU,defaultSort:{columnKey:`kind`,dir:`asc`},emptyMessage:e(`uiLibrary.dataRecords.noMatch`,`No kinds match the filter`)}),d===null?null:v(Boe,{kind:d,entryKinds:s,entryKindsPending:n.isPending,entryKindsError:n.isError?n.error instanceof Error?n.error.message:e(`uiLibrary.dataRecords.entryKindsFailed`,`Could not load entry kinds`):null})]})}E();function Voe({data:e,label:t=`Response`,className:n=``}){let r=q(),[i,a]=C(!1);if(!e)return null;let o=JSON.stringify(e,null,2);return c(`div`,{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[c(`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:()=>a(e=>!e),children:[c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i?`▼`:`▶`}),v(`h3`,{className:`text-xs font-medium text-foreground`,children:t})]}),v(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:o.length>1e3?r(`uiLibrary.responseLog.kb`,`{{size}} KB`,{size:(o.length/1024).toFixed(1)}):r(`uiLibrary.responseLog.bytes`,`{{count}} bytes`,{count:o.length})})]}),i&&v(`div`,{className:`max-h-80 overflow-y-auto overflow-x-auto`,children:v(`pre`,{className:`p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre`,children:o})})]})}E();var Hoe={"":void 0,yes:!0,no:!1},Uoe=[{value:`view`,labelKey:`uiLibrary.scopePicker.accessView`,labelFallback:`View`,icon:Zt,hintKey:`uiLibrary.scopePicker.accessViewHint`,hintFallback:`Read-only — queries + subscriptions`},{value:`create`,labelKey:`uiLibrary.scopePicker.accessCreate`,labelFallback:`Create`,icon:Gt,hintKey:`uiLibrary.scopePicker.accessCreateHint`,hintFallback:`Mutations that create or update`},{value:`delete`,labelKey:`uiLibrary.scopePicker.accessDelete`,labelFallback:`Delete`,icon:Pe,hintKey:`uiLibrary.scopePicker.accessDeleteHint`,hintFallback:`Destructive ops (delete/revoke/reset/…)`}],Woe=[`device`,`system`];function Goe(){return{type:`capability`,target:``,access:[`view`]}}function Koe(e,t){if(e==null)return[];let n=new Set;for(let r of[`view`,`create`,`delete`])for(let i of Fa(e,t,r))n.add(i);return[...n]}function qoe(e,t,n,r){let i;switch(e){case`addon`:i=n;break;case`capability`:i=r;break;case`category`:i=Woe.map(e=>({value:e,label:e}));break}if(t==null)return i;let a=new Set(t.filter(t=>t.type!==`device`&&t.type===e).map(e=>e.target));return i.filter(e=>a.has(e.value))}function Joe(e,t){if(t==null)return[`view`,`create`,`delete`];let n=t.filter(t=>t.type===e.type?t.type===`device`&&e.type===`device`?!0:t.type!==`device`&&e.type!==`device`?t.target===e.target:!1:!1);if(n.length===0)return[];let r=new Set;for(let e of n)for(let t of e.access)r.add(t);return[...r]}function g8({value:e,onChange:t,clampToParent:n,emptyHint:r}){let i=q(),{data:a}=Cu(),{data:o}=dm({}),s=p(()=>(a??[]).map(e=>({value:e.manifest.id,label:e.manifest.id})).sort((e,t)=>e.label.localeCompare(t.label)),[a]),l=p(()=>[...ba].toSorted().map(e=>({value:e,label:e})),[]),u=p(()=>(o??[]).map(e=>({id:e.id,type:e.type,location:e.location,parentDeviceId:e.parentDeviceId})),[o]),d=p(()=>n==null?null:Koe(n,u),[n,u]),f=(e,t)=>{let n=[...t];switch(e){case`category`:return{type:`category`,target:`device`,access:n};case`capability`:return{type:`capability`,target:``,access:n};case`addon`:return{type:`addon`,target:``,access:n};case`device`:return{type:`device`,selector:{kind:`ids`,ids:[]},access:n}}},m=(n,r)=>{t(e.map((e,t)=>{if(t!==n)return e;if(r.type!==void 0&&r.type!==e.type)return f(r.type,r.access??e.access);let i=[...r.access??e.access];if(e.type===`device`){let t={type:`device`,selector:r.selector??e.selector,access:i},n=`includeLinked`in r?r.includeLinked:e.includeLinked;return n===void 0?t:{...t,includeLinked:n}}return e.type===`category`?{type:`category`,target:r.target??e.target,access:i}:e.type===`capability`?{type:`capability`,target:r.target??e.target,access:i}:{type:`addon`,target:r.target??e.target,access:i}}))},h=n=>{t(e.filter((e,t)=>t!==n))};return c(`div`,{className:`space-y-2`,children:[e.length===0&&r&&v(`div`,{className:`text-[10px] text-foreground-subtle italic px-2 py-2`,children:r}),e.map((e,t)=>{let r=Joe(e,n);return c(`div`,{className:`flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5`,children:[c(`select`,{value:e.type,onChange:e=>m(t,{type:e.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:[v(`option`,{value:`category`,children:`category`}),v(`option`,{value:`capability`,children:`capability`}),v(`option`,{value:`addon`,children:`addon`}),v(`option`,{value:`device`,children:`device`})]}),e.type===`device`?c(`div`,{className:`min-w-[200px] flex-1 space-y-1.5`,children:[v(f6,{dense:!0,value:e.selector,onChange:e=>m(t,{selector:e}),clampToDeviceIds:d}),c(`label`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(`uiLibrary.scopePicker.linkedDevices`,`Linked devices`),c(`select`,{value:e.includeLinked===void 0?``:e.includeLinked?`yes`:`no`,onChange:e=>m(t,{includeLinked:Hoe[e.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:[v(`option`,{value:``,children:i(`uiLibrary.scopePicker.automatic`,`Automatic (view inherits)`)}),v(`option`,{value:`yes`,children:i(`uiLibrary.scopePicker.alwaysIncluded`,`Always included`)}),v(`option`,{value:`no`,children:i(`uiLibrary.scopePicker.neverIncluded`,`Never included`)})]})]})]}):c(`select`,{value:e.target,onChange:e=>m(t,{target:e.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:[v(`option`,{value:``,children:i(`uiLibrary.scopePicker.pickType`,`— pick {{type}} —`,{type:e.type})}),qoe(e.type,n,s,l).map(e=>v(`option`,{value:e.value,children:e.label},e.value))]}),v(`div`,{className:`flex items-center gap-1`,children:Uoe.map(({value:a,labelKey:o,labelFallback:s,icon:l,hintKey:u,hintFallback:d})=>{let f=i(o,s),p=i(u,d),h=e.access.includes(a),g=n!=null&&!r.includes(a)&&!h;return c(`label`,{title:g?i(`uiLibrary.scopePicker.notGranted`,`{{hint}} — not granted by your scope`,{hint:p}):p,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${h?`bg-primary/15 text-primary font-medium`:`text-foreground-subtle hover:bg-foreground-subtle/10`} ${g?`opacity-40 cursor-not-allowed`:``}`,children:[v(`input`,{type:`checkbox`,checked:h,disabled:g,onChange:n=>{let r=new Set(e.access);n.target.checked?r.add(a):r.delete(a),m(t,{access:[...r]})},className:`sr-only`}),v(l,{className:`h-3 w-3`}),f]},a)})}),v(`button`,{type:`button`,onClick:()=>h(t),className:`rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors`,title:i(`uiLibrary.scopePicker.removeScope`,`Remove scope`),children:v(Zn,{className:`h-3 w-3`})})]},t)}),c(`button`,{type:`button`,onClick:()=>{t([...e,Goe()])},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:[v(Se,{className:`h-3 w-3`}),i(`uiLibrary.scopePicker.addScope`,`Add scope`)]})]})}function _8(e,t=Fn){for(let n of e){if(n.type===`device`){let e=Yoe(n.selector,t);if(e!==null)return e}else if(n.target.trim().length===0)return t(`uiLibrary.scopePicker.pickTarget`,`Scope {{type}}: pick a target`,{type:n.type});if(n.access.length===0){let e=n.type===`device`?m6(n.selector):n.target;return t(`uiLibrary.scopePicker.pickAccess`,`Scope {{type}}:{{target}}: pick at least one access`,{type:n.type,target:e})}}return null}function Yoe(e,t){switch(e.kind){case`all`:return null;case`ids`:return e.ids.length===0?t(`uiLibrary.scopePicker.pickDevice`,`Scope device: pick at least one device`):null;case`types`:return e.types.length===0?t(`uiLibrary.scopePicker.pickDeviceType`,`Scope device: pick at least one device type`):null;case`locations`:return e.locations.length===0?t(`uiLibrary.scopePicker.pickRoom`,`Scope device: pick at least one room`):null}}E();function Xoe(e,t){let n=document.createElement(`a`);n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Zoe({trpc:e,deviceId:t,deviceName:n,size:r=`sm`,className:i}){let a=q(),[o,s]=C(!1),[l,u]=C(!1),[d,f]=C(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,`_`),m=_(async n=>{s(!0),f(null),u(!1);try{let r=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!r)throw Error(`No snapshot available`);let i=`data:${r.contentType};base64,${r.base64}`;if(n===`copy`)try{await navigator.clipboard.writeText(i)}catch{throw Error(`Clipboard unavailable`)}else{let e=r.contentType.includes(`png`)?`png`:`jpg`;Xoe(`${p}-${new Date().toISOString().replace(/[:.]/g,`-`)}.${e}`,i)}u(!0),setTimeout(()=>u(!1),1500)}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t,p]),h=r===`md`?`h-9 px-3 text-sm gap-2`:`h-7 px-2.5 text-[11px] gap-1.5`,[g,y]=C(null),[b,x]=C(!1),S=()=>{x(!1),y(setTimeout(()=>{x(!0),m(`copy`)},600))},w=()=>{g&&(clearTimeout(g),y(null)),b||m(`download`)},T=()=>{g&&(clearTimeout(g),y(null))};return c(`button`,{type:`button`,title:a(`uiLibrary.snapshotButton.title`,`Click to download · long-press to copy`),disabled:o,onPointerDown:S,onPointerUp:w,onPointerLeave:T,onPointerCancel:T,className:$(`inline-flex items-center justify-center rounded-lg font-medium border border-border`,`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,`disabled:opacity-50 transition-colors`,h,d&&`border-danger/40 text-danger`,i),children:[o?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):l?v(dt,{className:`h-3.5 w-3.5 text-success`}):v(ot,{className:`h-3.5 w-3.5`}),a(`uiLibrary.snapshotButton.snapshot`,`Snapshot`)]})}function v8({value:e,label:t,icon:n,subtext:r,valueClassName:i,trend:a,className:o}){return c(`div`,{className:$(`rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0`,o),children:[c(`div`,{className:`flex items-center gap-1.5 mb-0.5 min-w-0`,children:[n&&v(n,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,title:t,children:t})]}),c(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[v(`p`,{className:$(`text-lg font-semibold leading-tight whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,i??`text-foreground`),title:String(e),children:e}),a&&c(`span`,{className:$(`inline-flex items-center gap-0.5 text-xs font-medium shrink-0`,a.direction===`up`?`text-success`:`text-danger`),children:[a.direction===`up`?v(qt,{className:`h-3 w-3`}):v(ie,{className:`h-3 w-3`}),a.value,`%`]})]}),r&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,title:r,children:r})]})}var Qoe={online:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.online`,labelFallback:`Online`},offline:{colorClass:`bg-danger`,labelKey:`uiLibrary.statusBadge.offline`,labelFallback:`Offline`},degraded:{colorClass:`bg-warning`,labelKey:`uiLibrary.statusBadge.degraded`,labelFallback:`Degraded`},unknown:{colorClass:`bg-foreground-subtle`,labelKey:`uiLibrary.statusBadge.unknown`,labelFallback:`Unknown`},running:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.running`,labelFallback:`Running`},stopped:{colorClass:`bg-foreground-subtle`,labelKey:`uiLibrary.statusBadge.stopped`,labelFallback:`Stopped`},error:{colorClass:`bg-danger`,labelKey:`uiLibrary.statusBadge.error`,labelFallback:`Error`},idle:{colorClass:`bg-info`,labelKey:`uiLibrary.statusBadge.idle`,labelFallback:`Idle`},enabled:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.enabled`,labelFallback:`Enabled`},disabled:{colorClass:`bg-warning`,labelKey:`uiLibrary.statusBadge.disabled`,labelFallback:`Disabled`}};function y8({status:e,label:t,showDot:n=!0,showLabel:r=!0,size:i=`sm`,className:a}){let o=q(),s=Qoe[e];return c(`span`,{className:$(`inline-flex items-center gap-1.5`,i===`sm`?`text-xs`:`text-sm`,a),children:[n&&v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,s.colorClass),"aria-hidden":`true`}),r&&v(`span`,{className:`text-foreground`,children:t??o(s.labelKey,s.labelFallback)})]})}function $oe({timings:e,totalMs:t,className:n}){let r=q(),i=Object.entries(e);return i.length===0&&t===void 0?null:c(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??``}`,children:[v(`div`,{className:`text-xs font-medium text-foreground-subtle uppercase tracking-wide`,children:r(`uiLibrary.stepTimings.timings`,`Timings`)}),c(`div`,{className:`space-y-1 text-xs`,children:[i.map(([e,t])=>c(`div`,{className:`flex justify-between`,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),c(`span`,{className:`font-mono text-foreground`,children:[t.toFixed(1),`ms`]})]},e)),t!==void 0&&c(`div`,{className:`flex justify-between pt-1 border-t border-border font-medium text-foreground`,children:[v(`span`,{children:r(`uiLibrary.stepTimings.total`,`Total`)}),c(`span`,{className:`font-mono`,children:[t.toFixed(1),`ms`]})]})]})]})}function ese(e){return e.explicit?e.effectiveOn?`on`:`off`:`auto`}function b8({gate:e,busy:t=!1,onSet:n}){let r=q();if(e.kind===`zone-driven`)return v(`span`,{className:`inline-flex items-center rounded-md border border-violet-500/40 bg-violet-500/10 px-2 py-1 text-[11px] font-medium text-violet-400`,title:r(`uiLibrary.gateControl.zoneDrivenTitle`,`Runs where this camera has package zones — set on the Zones tab`),children:r(`uiLibrary.gateControl.zones`,`Zones`)});let i=ese(e),a=(e,r,a,o)=>v(`button`,{type:`button`,role:`radio`,"aria-checked":i===e,disabled:t,onClick:()=>n(a),className:$(`h-9 min-w-12 px-3 text-xs font-medium transition-colors md:h-8`,i===e?o:`text-foreground-subtle hover:bg-muted/60`,t&&`cursor-not-allowed opacity-50`),children:r});return c(`div`,{className:`flex items-center gap-2`,children:[c(`div`,{role:`radiogroup`,"aria-label":r(`uiLibrary.gateControl.runsOnCamera`,`Runs on this camera`),title:r(`uiLibrary.gateControl.catalogDefault`,`Catalog default: {{state}}`,{state:e.defaultOn?r(`uiLibrary.gateControl.on`,`on`):r(`uiLibrary.gateControl.off`,`off`)}),className:`inline-flex overflow-hidden rounded-md border border-border`,children:[a(`auto`,r(`uiLibrary.gateControl.autoLabel`,`Auto`),null,`bg-primary/15 text-primary`),v(`span`,{className:`w-px self-stretch bg-border`,"aria-hidden":!0}),a(`on`,r(`uiLibrary.gateControl.onLabel`,`On`),!0,`bg-emerald-500 text-white`),v(`span`,{className:`w-px self-stretch bg-border`,"aria-hidden":!0}),a(`off`,r(`uiLibrary.gateControl.offLabel`,`Off`),!1,`bg-foreground-subtle/70 text-white`)]}),v(`span`,{className:`hidden text-[10px] text-foreground-subtle @3xl/inspector:inline`,children:r(`uiLibrary.gateControl.defaultState`,`default: {{state}}`,{state:e.defaultOn?r(`uiLibrary.gateControl.on`,`on`):r(`uiLibrary.gateControl.off`,`off`)})})]})}function tse({gate:e}){let t=q();if(e.kind===`zone-driven`)return v(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase text-violet-400`,children:t(`uiLibrary.gateControl.zonesBadge`,`zones`)});let n=e.effectiveOn;return v(`span`,{className:$(`shrink-0 rounded px-1.5 py-px text-[9px] font-semibold uppercase`,n?`bg-emerald-500/15 text-emerald-500`:`bg-muted text-foreground-subtle`,e.explicit&&`ring-1 ring-inset ring-current`),title:e.explicit?t(`uiLibrary.gateControl.setForCamera`,`Set for this camera`):t(`uiLibrary.gateControl.catalogDefaultTitle`,`Catalog default`),children:n?t(`uiLibrary.gateControl.on`,`on`):t(`uiLibrary.gateControl.off`,`off`)})}function x8({label:e,options:t,value:n,onChange:r}){return v(`div`,{role:`radiogroup`,"aria-label":e,className:`flex flex-wrap items-center gap-1`,children:t.map(e=>v(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.value,disabled:e.disabled===!0,title:e.disabled===!0?e.reason:void 0,onClick:()=>r(e.value),className:$(`h-9 rounded-md border px-2.5 text-[11px] font-medium transition-colors md:h-7`,n===e.value?`border-primary/50 bg-primary/15 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,e.disabled===!0&&`cursor-not-allowed opacity-50 hover:bg-transparent hover:text-foreground-subtle`),children:e.label},e.value))})}E();var nse=432;function S8(e){let t=Math.max(0,e.viewportWidth-e.scroller.right),n=Math.min(e.widthPx,e.scroller.right);return{top:Math.max(0,e.scroller.top),height:Math.max(0,e.scroller.bottom-Math.max(0,e.scroller.top)),right:t,width:n}}function rse(e){for(let t=e?.parentElement??null;t!==null;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`)return t}return null}function ise(e,t){let[n,r]=C(null);return u(()=>{if(!t)return;let n=rse(e.current),i=()=>{r(S8({scroller:n?.getBoundingClientRect()??{top:0,bottom:window.innerHeight,right:window.innerWidth},viewportWidth:window.innerWidth,widthPx:432}))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return n&&a?.observe(n),window.addEventListener(`resize`,i),()=>{a?.disconnect(),window.removeEventListener(`resize`,i)}},[e,t]),n}function C8({open:e,anchor:t,onClose:n,label:r,children:i}){let a=dl(),o=ise(t,e&&!a);return a?v(SL,{open:e,onOpenChange:e=>!e&&n(),children:v(TL,{placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,className:`h-[100dvh] max-h-none w-full max-w-full rounded-none border-0 p-0 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:e&&i})}):e?v(`aside`,{"aria-label":r,"data-step-dock":!0,className:`fixed z-30 flex flex-col border-l border-border bg-surface shadow-2xl`,style:o===null?{top:0,bottom:0,right:0,width:432}:{top:o.top,height:o.height,right:o.right,width:o.width},children:i}):null}function w8({onClick:e}){let t=q();return c(`button`,{type:`button`,onClick:e,className:`inline-flex h-9 items-center gap-0.5 rounded-md border border-border px-2 text-xs text-foreground hover:bg-surface-hover`,children:[v(ge,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`uiLibrary.stepDetailDock.steps`,`Steps`)]})}E();function ase({dirtyCount:e,saving:t,status:n,error:r,onSave:i,onDiscard:a,scope:o}){let s=q(),l=e>0,u=t?s(`uiLibrary.stepInspector.saving`,`Saving…`):l?s(`uiLibrary.stepInspector.unsaved`,{one:`{{count}} unsaved change`,other:`{{count}} unsaved changes`},{count:e}):n===`saved`?s(`uiLibrary.stepInspector.saved`,`Saved`):n===`error`?r??s(`uiLibrary.stepInspector.saveFailed`,`Save failed`):s(`uiLibrary.stepInspector.noChanges`,`No unsaved changes`);return c(`footer`,{className:`shrink-0 space-y-2 border-t border-border bg-surface px-4 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] md:pb-2`,children:[o!==void 0&&v(`div`,{"data-save-scope":!0,children:o}),c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{role:`status`,className:$(`min-w-0 flex-1 truncate text-[11px]`,n===`error`&&!l?`text-danger`:l?`text-amber-500`:`text-foreground-subtle`),children:u}),v(_A,{variant:`outline`,size:`md`,disabled:!l||t,onClick:a,children:s(`uiLibrary.stepInspector.discard`,`Discard`)}),v(_A,{variant:`primary`,size:`md`,disabled:!l||t,onClick:i,children:s(`uiLibrary.stepInspector.save`,`Save`)})]})]})}var T8=D(function({title:e,subtitle:t,headerActions:n,headerExtra:r,leading:i,saveBar:a,onEscape:o,children:s,className:l},u){let d=y();return c(`section`,{"aria-labelledby":d,onKeyDown:e=>{e.key!==`Escape`||o===void 0||(e.stopPropagation(),o())},className:$(`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface`,l),children:[c(`header`,{className:`shrink-0 space-y-2 border-b border-border px-4 py-2.5`,children:[c(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2`,children:[i,c(`div`,{className:`min-w-[9rem] flex-1`,children:[v(`h2`,{id:d,ref:u,tabIndex:-1,title:e,className:`line-clamp-2 break-words text-sm font-semibold leading-snug text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary rounded`,children:e}),t!==void 0&&v(`div`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t})]}),n]}),r]}),v(`div`,{"data-inspector-body":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3`,children:s}),a!==void 0&&v(ase,{...a})]})}),ose={camera:`border-primary/40 bg-primary/10 text-primary`,node:`border-border bg-muted/40 text-foreground`,default:`border-border/60 text-foreground-subtle`,cluster:`border-primary/40 bg-primary/5 text-primary`};function E8({label:e,format:t,modelId:n,source:r,sourceLabel:i,models:a,defaultModelId:o,expanded:s,onToggle:l,onChangeModel:u,onReset:d,resetLabel:f,note:p,extra:m,changed:h=!1,disabled:g=!1}){let _=q(),y=a.length>0&&p===void 0,b=y||m!==void 0;return c(`div`,{className:$(`rounded-md border border-border`,s&&`bg-muted/10`),children:[c(`div`,{className:$(Ft,`space-y-1`),children:[c(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[v(`span`,{className:`font-medium text-foreground`,children:e}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:t}),v(`span`,{className:$(`ml-auto rounded border px-1.5 py-px text-[10px] font-medium`,ose[r]),children:i})]}),c(`div`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:[n??`—`,h&&v(`span`,{className:`ml-1 text-amber-500`,children:`•`})]}),d!==void 0&&v(`button`,{type:`button`,className:`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`,disabled:g,onClick:d,children:f??_(`uiLibrary.stepModelRow.reset`,`Reset`)}),b&&v(`button`,{type:`button`,className:$(`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`,`min-h-9 md:min-h-0`),"aria-expanded":s,"aria-label":_(`uiLibrary.stepModelRow.changeModelFor`,`Change model for {{label}}`,{label:e}),disabled:g,onClick:l,children:s?_(`uiLibrary.stepModelRow.done`,`Done`):y?_(`uiLibrary.stepModelRow.change`,`Change`):_(`uiLibrary.stepModelRow.route`,`Route`)})]})]}),p!==void 0&&v(`div`,{className:`border-t border-border/60 px-3 py-1.5 text-[10px] leading-snug text-foreground-subtle`,children:p}),s&&b&&c(`div`,{className:`space-y-3 border-t border-border/60 px-3 py-3`,children:[y&&v(Yz,{models:a,value:n??``,defaultModelId:o,disabled:g,onChange:u}),m]})]})}function D8(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e))}function O8(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e.map(e=>({addonId:e.addonId}));let r=[];for(let t of e){if(D8(t.name,n)){r.push({addonId:t.addonId});continue}let e=t.fieldLabels.find(e=>D8(e,n));e!==void 0&&r.push({addonId:t.addonId,matchedField:e})}return r}function k8(e){let t=[],n=[],r=new Map;for(let i of e.slots)for(let e of i.addons){let i={addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:e.inputClasses,outputClasses:e.outputClasses,children:[]};e.slot===`audio-classifier`?t.push(i):(n.push(i),r.set(e.id,i))}let i=[];for(let e of n){if(e.inputClasses.length===0){i.push(e);continue}let t=n.find(t=>t.addonId!==e.addonId&&t.outputClasses.some(t=>e.inputClasses.includes(t)));t&&t.children.push(e)}return[...i,...t]}E();function sse(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cse({deviceId:e,value:t,onChange:n,disabled:r,label:i,className:a}){let o=q(),s=y(),l=cf({deviceId:e},{refetchOnWindowFocus:!1}),[u,d]=C([]);b(()=>{if(!l.data)return;let t=`${e}/`,n=[];for(let e of l.data){if(!e.enabled)continue;let r=e.brokerId.startsWith(t)?e.brokerId.slice(t.length):e.brokerId;n.push(r)}d(n)},[l.data,e]);let f=p(()=>[{value:`auto`,label:o(`uiLibrary.streamBrokerSelector.auto`,`Auto (best available)`)},...u.map(e=>({value:e,label:sse(e)}))],[u,o]),m=i??o(`uiLibrary.streamBrokerSelector.preferred`,`Preferred stream`),h=l.isLoading?o(`uiLibrary.streamBrokerSelector.loading`,`Loading available streams…`):l.isError?o(`uiLibrary.streamBrokerSelector.loadFailed`,`Could not load streams — only Auto available.`):f.length===1?o(`uiLibrary.streamBrokerSelector.noneEnabled`,`No enabled streams found — only Auto available.`):null;return c(`div`,{className:a,children:[v(`label`,{id:s,className:`text-xs font-medium text-foreground-muted block mb-1`,children:m}),v(Yl,{"aria-labelledby":s,options:f,value:t,disabled:r,onChange:e=>n(e.target.value)}),h!==null&&v(`p`,{className:`text-foreground-subtle text-[10px] mt-1`,children:h})]})}E();function lse(e){return e===`streaming`?`bg-emerald-500`:e===`connecting`?`bg-amber-500`:e===`error`?`bg-rose-500`:`bg-zinc-500`}function use(e){let 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 A8({className:e}){return v(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}function dse({className:e}){return v(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`1`})})}function fse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z`}),v(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),v(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),v(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]})}function pse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,children:[v(`circle`,{cx:`5`,cy:`12`,r:`2`}),v(`circle`,{cx:`12`,cy:`12`,r:`2`}),v(`circle`,{cx:`19`,cy:`12`,r:`2`})]})}function j8({label:e,active:t,onClick:n}){return c(`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:[v(`span`,{children:e}),v(`span`,{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?`bg-primary`:`bg-foreground-subtle/30`} relative`,children:v(`span`,{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?`left-2.5`:`left-0.5`}`})})]})}function mse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`circle`,{cx:`12`,cy:`12`,r:`2`,fill:`currentColor`}),v(`path`,{d:`M16.24 7.76a6 6 0 0 1 0 8.49M7.76 16.24a6 6 0 0 1 0-8.49M19.07 4.93a10 10 0 0 1 0 14.14M4.93 19.07a10 10 0 0 1 0-14.14`})]})}function M8({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`polyline`,{points:`23 4 23 10 17 10`}),v(`polyline`,{points:`1 20 1 14 7 14`}),v(`path`,{d:`M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15`})]})}function hse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`}),v(`path`,{d:`M10.41 10.41a2 2 0 11-2.83-2.83`}),v(`line`,{x1:`13.5`,y1:`13.5`,x2:`6`,y2:`21`}),v(`path`,{d:`M18 12l-1.5-1.5`}),v(`path`,{d:`M21 15V5a2 2 0 00-2-2H5`}),v(`path`,{d:`M21 21H5a2 2 0 01-2-2V11`})]})}function N8({serverUrl:e,createSession:t,sendAnswer:n,handleOffer:r,getIceServers:i,addIceCandidate:a,getIceCandidates:o,closeSession:s,getSessionState:l,getSessionDebug:u,applyDownlinkProbe:d,playbackUrl:m,playbackFormat:h,playbackAuthToken:g,onExitPlayback:y,posterUrl:x,streams:S,activeStreamId:w,onStreamChange:T,deviceName:E,phase:D,pipelineMetrics:O,detections:k,stationaryObjects:A,defaultShowDetections:j=!0,defaultShowMotion:M=!1,streamStats:N,autoPlay:F=!1,showPlayStop:I=!1,snapshotSrc:L,snapshotLoading:R=!1,onRefreshSnapshot:z,showStreamStats:B=!1,children:V,extraOverlay:H,ptzAvailable:U=!1,ptzShown:ee=!1,ptzOverlay:W,onPtzToggle:G,intercomAvailable:te=!1,intercomShown:ne=!1,onIntercomToggle:re,chromeless:K=!1,className:ie}){let ae=q(),oe=bn(),se=dL(),[ce,le]=C(F),[ue,de]=C(j),[fe,pe]=C(!0),[me,he]=C(!0),[ge,_e]=C(M),[ve,ye]=C(null),[be,xe]=C([]),[Se,Ce]=C(-1),[we,Te]=C(!1),Ee=f(null);b(()=>{if(!we)return;function e(e){Ee.current&&!Ee.current.contains(e.target)&&Te(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[we]),b(()=>{Ce(-1)},[m]);let De=_(e=>{xe(e)},[]),Oe=w??ve??S?.[0]?.id??``,ke=S?.find(e=>e.id===Oe)??S?.[0],Ae=ke?.inputFps==null?null:{status:ke.status??`unknown`,inputFps:ke.inputFps,bitrateKbps:ke.bitrateKbps??0},je=e=>{ye(e),T?.(e),ce&&I&&(le(!1),setTimeout(()=>le(!0),50))},Me=p(()=>{let e=ke?.target;if(!(!e||!t))return n=>t(e,n)},[t,ke]),Ne=p(()=>{let e=ke?.target;if(!(!e||!r))return(t,n)=>r(e,t,n)},[r,ke]),Pe=p(()=>{if(r)return(e,t,n)=>r(n,t,e)},[r]),Fe=S,Ie=()=>le(!0),Le=()=>le(!1),Re=O?.phase??D,ze=Re===`active`,Be=!!k,Ve=Be&&(ue||ge),He=U&&ee&&!!W,Ue=!!m,We=Ue||(I?ce:!0);return c(`div`,{className:`overflow-hidden ${K?``:`rounded-xl border border-border bg-surface`} ${ie??``}`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-border`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(N??Ae)&&v(`span`,{className:`shrink-0 w-2 h-2 rounded-full ${lse((N??Ae).status)}`}),E&&v(`span`,{className:`text-xs font-medium text-foreground truncate`,children:E}),!Ue&&Fe&&Fe.length>1&&c(`div`,{className:`relative`,children:[v(`select`,{"data-testid":`stream-profile-select`,value:Oe,onChange:e=>je(e.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:Fe.map(e=>v(`option`,{value:e.id,children:e.label},e.id))}),v(`span`,{className:`pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle`,children:v(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polyline`,{points:`3 4.5 6 7.5 9 4.5`})})})]}),Ue&&be.length>1&&c(`div`,{className:`relative`,children:[v(`select`,{"data-testid":`vod-quality-select`,value:Se,onChange:e=>Ce(Number(e.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:be.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(`span`,{className:`pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle`,children:v(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polyline`,{points:`3 4.5 6 7.5 9 4.5`})})})]})]}),c(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[te&&!Ue&&c(`button`,{"data-testid":`stream-intercom-toggle`,"data-intercom-shown":ne?`true`:`false`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${ne?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,title:ne?ae(`uiLibrary.streamPanel.closeIntercom`,`Close intercom`):ae(`uiLibrary.streamPanel.openIntercom`,`Open intercom`),children:[v(fse,{className:`h-3 w-3`}),v(`span`,{className:`hidden xl:inline`,children:ae(`uiLibrary.streamPanel.intercom`,`Intercom`)})]}),oe.map(e=>{let t=e.tone===`primary`?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary`;return c(`button`,{type:`button`,"data-toolbar-button-id":e.id,"data-toolbar-button-active":e.active?`true`:`false`,onClick:e.onClick,disabled:e.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${e.active?t:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,title:e.title??e.label,children:[e.icon,v(`span`,{className:`hidden xl:inline`,children:e.label})]},e.id)}),I&&c(`button`,{"data-testid":`stream-play-toggle`,"data-stream-playing":We?`true`:`false`,"data-vod":Ue?`true`:`false`,onClick:Ue?y:We?Le:Ie,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${Ue?`bg-primary/10 text-primary hover:bg-primary/20`:We?`bg-danger/10 text-danger hover:bg-danger/20`:`bg-primary/10 text-primary hover:bg-primary/20`}`,title:Ue?ae(`uiLibrary.streamPanel.returnToLive`,`Return to live`):We?ae(`uiLibrary.streamPanel.stopStream`,`Stop stream`):ae(`uiLibrary.streamPanel.startStream`,`Start stream`),children:[v(Ue?mse:We?dse:A8,{className:`h-3 w-3`}),v(`span`,{className:`hidden xl:inline`,children:Ue?ae(`uiLibrary.streamPanel.live`,`Live`):We?ae(`uiLibrary.streamPanel.stop`,`Stop`):ae(`uiLibrary.streamPanel.play`,`Play`)})]}),z&&!Ue&&c(`button`,{"data-testid":`stream-snapshot-refresh`,onClick:z,disabled:R,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:ae(`uiLibrary.streamPanel.forceRefresh`,`Force snapshot refresh`),children:[v(M8,{className:`h-3 w-3 ${R?`animate-spin`:``}`}),v(`span`,{className:`hidden xl:inline`,children:ae(`uiLibrary.streamPanel.snapshot`,`Snapshot`)})]}),(Be||U||O||Re||N||Ae&&Ae.inputFps>0)&&c(`div`,{ref:Ee,className:`relative`,children:[v(`button`,{onClick:()=>Te(e=>!e),title:ae(`uiLibrary.streamPanel.moreControls`,`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:v(pse,{className:`h-3.5 w-3.5`})}),we&&c(`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:[B&&N&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.input`,`Input`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[N.inputFps.toFixed(1),` fps`]})]}),c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.uptime`,`Uptime`)}),v(`span`,{className:`tabular-nums text-foreground`,children:use(N.uptimeMs)})]})]}),!B&&Ae&&Ae.inputFps>0&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.input`,`Input`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[Ae.inputFps.toFixed(1),` fps`]})]}),Ae.bitrateKbps>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.bitrate`,`Bitrate`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[Ae.bitrateKbps,` kbps`]})]})]}),(O||Be&&Re)&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3 items-center`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.phase`,`Phase`)}),c(`span`,{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${ze?`text-red-400`:`text-emerald-400`}`,children:[v(`span`,{className:`w-1.5 h-1.5 rounded-full ${ze?`bg-red-500 animate-pulse`:`bg-emerald-500`}`}),ze?ae(`uiLibrary.streamPanel.active`,`Active`):ae(`uiLibrary.streamPanel.watching`,`Watching`)]})]}),O&&O.detectionFps>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.detection`,`Detection`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[O.detectionFps.toFixed(1),` det/s`]})]}),O&&O.avgInferenceMs>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.inference`,`Inference`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[O.avgInferenceMs.toFixed(0),` ms`]})]})]}),Be&&c(P,{children:[v(j8,{label:ae(`uiLibrary.streamPanel.showDetections`,`Show detections`),active:ue,onClick:()=>de(e=>!e)}),ue&&c(P,{children:[v(j8,{label:ae(`uiLibrary.streamPanel.moving`,`…moving`),active:fe,onClick:()=>pe(e=>!e)}),v(j8,{label:ae(`uiLibrary.streamPanel.stationary`,`…stationary`),active:me,onClick:()=>he(e=>!e)})]}),v(j8,{label:ae(`uiLibrary.streamPanel.showMotion`,`Show motion`),active:ge,onClick:()=>_e(e=>!e)})]}),U&&v(j8,{label:ae(`uiLibrary.streamPanel.ptzControls`,`PTZ controls`),active:ee,onClick:()=>{G?.(),Te(!1)}})]})]})]})]}),m?c(`div`,{className:`aspect-video relative`,children:[v(A6,{url:m,...h?{format:h}:{},authToken:g??null,onQualityOptions:De,selectedLevel:Se,...x?{posterUrl:x}:{}}),H||He?c(P,{children:[H,He&&W]}):null]}):We&&e?v(`div`,{className:`aspect-video relative`,children:v(QH,{serverUrl:e,streamKey:Oe,autoPlay:!0,className:`w-full h-full`,createSession:Me,sendAnswer:n,handleOffer:Ne,reoffer:Pe,getSessionState:l,...u?{getSessionDebug:u}:{},...d?{applyDownlinkProbe:d}:{},getIceServers:i,addIceCandidate:a,getIceCandidates:o,closeSession:s,...se.bindControlChannel?{onControlChannel:se.bindControlChannel}:{},...x?{posterUrl:x}:{},overlay:Ve||H||He?c(P,{children:[Ve&&v(eK,{detections:k,showPhaseIndicator:!1,showMotionZones:ge,showMotionRaw:ge,showDetections:ue,showMoving:fe,showStationary:me,...A===void 0?{}:{stationaryObjects:A}}),H,He&&W]}):void 0})}):v(gse,{src:L??null,isLoading:R,onPlay:Ie,onRetry:z,extraOverlay:H||He?c(P,{children:[H,He&&W]}):null,suppressPlayHover:!!H||He}),V]})}function gse({src:e,isLoading:t,onPlay:n,onRetry:r,extraOverlay:i,suppressPlayHover:a=!1}){let o=q();return e?c(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:[v(`img`,{src:e,alt:o(`uiLibrary.streamPanel.cameraSnapshot`,`Camera snapshot`),className:`w-full h-full object-contain`}),!a&&v(`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:v(`div`,{className:`h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center`,children:v(A8,{className:`h-7 w-7 text-white ml-0.5`})})}),i]}):t?v(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:v(`div`,{className:`h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin`})}):v(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:c(`div`,{className:`flex flex-col items-center gap-2 text-white/40`,children:[v(hse,{className:`h-8 w-8`}),v(`span`,{className:`text-xs`,children:o(`uiLibrary.streamPanel.noSnapshot`,`No snapshot available`)}),c(`div`,{className:`flex items-center gap-2 mt-1`,children:[r&&c(`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:[v(M8,{className:`h-3 w-3`}),o(`uiLibrary.streamPanel.retry`,`Retry`)]}),c(`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:[v(A8,{className:`h-3 w-3`}),o(`uiLibrary.streamPanel.playLive`,`Play Live`)]})]})]})})}E();var _se={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 P8({children:e,variant:t=`neutral`,mono:n,className:r}){return v(`span`,{className:$(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight`,n&&`font-mono`,_se[t],r),children:e})}function vse({version:e,preRelease:t,className:n}){return v(P8,{variant:t??/-(alpha|beta|rc|dev|canary|next)/i.test(e)?`warning`:`success`,mono:!0,className:n,children:e})}function F8(e,t){return typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t))}function I8(e){return`${[e.name,e.location??``,e.type??``,e.detail??``].join(` `)} ${String(e.id)}`.toLowerCase()}function L8(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0)}function R8(e,t){let n=L8(t);return n.length===0?e:e.filter(e=>{let t=I8(e);return n.every(e=>t.includes(e))})}function z8(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function B8(e){return e==null||e.trim()===``?null:e}function V8(e,t){return`${e??``}|${t??``}`}function H8(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=B8(t.type),n=B8(t.location),i=V8(e,n),a=r.get(i);a===void 0?r.set(i,{type:e,location:n,devices:[t]}):a.devices.push(t)}let i=[];for(let[e,t]of r){let r=[...t.devices].sort((e,t)=>e.name.localeCompare(t.name)||F8(e.id,t.id));i.push({key:e,type:t.type,location:t.location,devices:r,selectedCount:r.filter(e=>n.has(e.id)).length})}return i.sort((e,t)=>z8(e.type,t.type)||z8(e.location,t.location))}function U8(e,t,n){let r=t.get(e.key);return r===void 0?n||e.selectedCount>0?!0:e.devices.length<=8:r}function W8(e,t,n,r){let i=new Set(t),a=[];for(let t of e){let e=U8(t,n,r);if(a.push({kind:`header`,key:`h:${t.key}`,group:t,expanded:e}),e)for(let e of t.devices)a.push({kind:`device`,key:`d:${String(e.id)}`,device:e,groupKey:t.key,selected:i.has(e.id)})}return a}function G8(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function K8(e,t){let n=[...e],r=new Set(e);for(let e of t.devices)r.has(e.id)||n.push(e.id);return n}function q8(e,t){let n=new Set(t.devices.map(e=>e.id));return e.filter(e=>!n.has(e))}function J8(e,t){return t||e.length<=6?{shown:e,hidden:0}:{shown:e.slice(0,6),hidden:e.length-6}}function Y8(e,t){let n=Math.max(0,Math.min(e.length,t));return{rows:e.slice(0,n),remaining:e.length-n}}var X8=[`zone`,`location`,`none`],Z8=`zone`;function Q8(e){return e===`zone`||e===`location`||e===`none`?e:Z8}function $8(e){return e.trim().toLowerCase()}var yse=1,bse=2;function xse(e,t){return e.name.localeCompare(t.name)||F8(e.id,t.id)}function e5(e){return e.kind===`zone`||e.kind===`location`?e.label:``}var t5={key:`-location`,heading:{kind:`no-location`},rank:bse},Sse={key:`-zone`,heading:{kind:`no-zone`},rank:yse};function n5(e){let t=new Map;for(let n of e)for(let e of n.locationKeys){let r=$8(e);t.has(r)||t.set(r,n)}return t}function Cse(e){return e===null?t5:{key:`l:${$8(e)}`,heading:{kind:`location`,label:e.trim()},rank:0}}function wse(e,t){if(e===null)return t5;let n=t.get($8(e));return n===void 0?Sse:{key:`z:${n.zoneKey}`,heading:{kind:`zone`,label:n.label},rank:0}}function r5(e,t,n,r){let i=new Set(t),a=[...e].sort(xse),o=e=>e.filter(e=>i.has(e.id)).length;if(n===`none`)return{groupBy:n,fallback:null,flat:!0,groups:[{key:`all`,type:null,location:null,devices:a,selectedCount:o(a)}]};let s=n===`zone`&&r.state!==`answered`?r.state:null,c=s===null?n:`location`,l=r.state===`answered`?n5(r.zones):new Map,u=new Map;for(let e of a){let t=B8(e.location),n=c===`zone`?wse(t,l):Cse(t),r=u.get(n.key);r===void 0?u.set(n.key,{heading:n.heading,rank:n.rank,devices:[e]}):r.devices.push(e)}return{groupBy:c,fallback:s,flat:!1,groups:[...u].sort(([,e],[,t])=>e.rank-t.rank||e5(e.heading).localeCompare(e5(t.heading))).map(([e,t])=>({key:e,type:null,location:t.heading.kind===`location`?t.heading.label:null,devices:t.devices,selectedCount:o(t.devices),heading:t.heading}))}}function i5(e,t,n,r){if(!e.flat)return W8(e.groups,t,n,r);let i=new Set(t),a=[];for(let t of e.groups)for(let e of t.devices)a.push({kind:`device`,key:`d:${String(e.id)}`,device:e,groupKey:t.key,selected:i.has(e.id)});return a}function a5(e,t){return{location:t===`location`?null:B8(e.location),type:B8(e.type)}}var o5=`(none)`,s5={query:``,types:[],zones:[],locations:[]},c5={key:o5,label:null};function l5(e,t,n){if(t===`type`){let t=B8(e.type);return t===null?c5:{key:t,label:t}}let r=B8(e.location);if(r===null)return c5;if(t===`location`)return{key:$8(r),label:r.trim()};if(n.state!==`answered`)return c5;let i=n5(n.zones).get($8(r));return i===void 0?c5:{key:i.zoneKey,label:i.label}}function u5(e,t,n){return l5(e,t,n).key}function Tse(e,t){return e.key===`(none)`||t.key===`(none)`?e.key===t.key?0:e.key===`(none)`?1:-1:(e.label??``).localeCompare(t.label??``)}function d5(e,t,n,r){if(t===`zone`&&r.state!==`answered`)return[];let i=new Map;for(let n of e){let e=l5(n,t,r),a=i.get(e.key);a===void 0?i.set(e.key,{label:e.label,count:1}):a.count++}for(let e of n)i.has(e)||i.set(e,{label:e===`(none)`?null:e,count:0});let a=[];for(let[e,t]of i)a.push({key:e,label:t.label,count:t.count});return a.sort(Tse)}function f5(e,t){return e.zones.length>0&&t.state!==`answered`}function p5(e,t,n,r){return n.length===0?e:e.filter(e=>n.includes(u5(e,t,r)))}function m5(e,t,n){let r=p5(R8(e,t.query),`type`,t.types,n);return p5(n.state===`answered`?p5(r,`zone`,t.zones,n):r,`location`,t.locations,n)}function h5(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function g5(e){return e.query.trim()!==``||e.types.length>0||e.zones.length>0||e.locations.length>0}function _5(){return s5}function v5(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set(n.map(e=>e.id));return e.filter(e=>r.has(e)&&!i.has(e)).length}function y5(e,t){return e.length>=2||t.length>0}E();function b5(e,t=Fn){if(e===null)return t(`uiLibrary.deviceFilterBar.noType`,`No type`);let n=e.replaceAll(`-`,` `);return n.charAt(0).toUpperCase()+n.slice(1)}function Ese(e,t){switch(e){case`zone`:return t(`uiLibrary.deviceFilterBar.zone`,`Zone`);case`location`:return t(`uiLibrary.deviceFilterBar.location`,`Location`);case`none`:return t(`uiLibrary.deviceFilterBar.none`,`None`)}}function Dse(e,t){switch(e){case`type`:return t(`uiLibrary.deviceFilterBar.type`,`Type`);case`zone`:return t(`uiLibrary.deviceFilterBar.zone`,`Zone`);case`location`:return t(`uiLibrary.deviceFilterBar.location`,`Location`)}}function Ose(e,t){switch(e){case`type`:return t(`uiLibrary.deviceFilterBar.noType`,`No type`);case`zone`:return t(`uiLibrary.deviceFilterBar.noZone`,`No zone`);case`location`:return t(`uiLibrary.deviceFilterBar.noLocation`,`No location`)}}function kse(e,t,n){return t.key===`(none)`||t.label===null?Ose(e,n):e===`type`?b5(t.label,n):t.label}function Ase({grouping:e}){let t=q();return c(`div`,{className:`mb-1.5`,children:[c(`div`,{role:`radiogroup`,"aria-label":t(`uiLibrary.deviceFilterBar.groupBy`,`Group by`),className:`flex flex-wrap items-center gap-1 text-[10px] text-foreground-subtle`,children:[v(`span`,{className:`mr-1 font-semibold uppercase tracking-wide`,children:t(`uiLibrary.deviceFilterBar.groupBy`,`Group by`)}),X8.map(n=>{let r=n===e.groupBy;return v(`button`,{type:`button`,role:`radio`,"aria-checked":r,onClick:()=>e.onGroupByChange(n),className:r?`rounded-md border border-primary bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:Ese(n,t)},n)})]}),e.fallback!==null&&v(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,"data-testid":`picker-zones-note`,children:e.fallback===`pending`?t(`uiLibrary.deviceFilterBar.zonesLoadingNote`,`Loading zones — grouped by location for now`):t(`uiLibrary.deviceFilterBar.zonesUnavailableNote`,`Zones unavailable — grouped by location`)})]})}function x5({facet:e,options:t,chosen:n,onChange:r,unavailable:i,disabled:a}){let o=q(),s=Dse(e,o),l=i===void 0?n.length===0?o(`uiLibrary.deviceFilterBar.all`,`All`):o(`uiLibrary.deviceFilterBar.nSelected`,`{{count}} selected`,{count:n.length}):i;return v(`div`,{"data-testid":`picker-filter-${e}`,children:c(gl,{children:[c(_l,{disabled:a||i!==void 0,className:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[s,`: `,l]}),v(bl,{className:`min-w-[200px] max-h-[40vh] overflow-y-auto p-1`,children:t.map(t=>{let i=kse(e,t,o);return c(`label`,{className:`flex cursor-pointer items-center gap-2 px-2 py-1 text-xs text-foreground hover:bg-surface-hover`,children:[v(BB,{checked:n.includes(t.key),onChange:()=>r(h5(n,t.key)),"aria-label":i}),v(`span`,{className:`min-w-0 flex-1 truncate`,children:i}),c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.count,`)`]})]},t.key)})})]})})}function jse(e,t){if(e.state===`pending`)return t(`uiLibrary.deviceFilterBar.loadingZones`,`loading zones…`);if(e.state===`failed`)return t(`uiLibrary.deviceFilterBar.zonesUnavailable`,`zones unavailable`)}function S5({filters:e,onFiltersChange:t,typeOptions:n,zoneOptions:r,locationOptions:i,zones:a,grouping:o,searchPlaceholder:s,searchLabel:l,disabled:u=!1}){let d=f(null);As(d);let p=q(),[m,h]=C(e.query),g=f({filters:e,onFiltersChange:t});g.current={filters:e,onFiltersChange:t},b(()=>{if(m===g.current.filters.query)return;let e=setTimeout(()=>g.current.onFiltersChange({...g.current.filters,query:m}),200);return()=>clearTimeout(e)},[m]);let _=jse(a,p),y=_!==void 0||y5(r,e.zones),x=g5(e)||m.trim()!==``;return c(`div`,{className:`space-y-1.5`,"data-testid":`device-filter-bar`,children:[o!==void 0&&v(Ase,{grouping:o}),c(`div`,{className:Gk,children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:d,type:`text`,value:m,placeholder:s,"aria-label":l,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,onChange:e=>h(e.target.value)})]}),c(`div`,{className:`flex flex-wrap items-center gap-1`,children:[y5(n,e.types)&&v(x5,{facet:`type`,options:n,chosen:e.types,onChange:n=>t({...e,types:n}),disabled:u}),y&&v(x5,{facet:`zone`,options:r,chosen:e.zones,onChange:n=>t({...e,zones:n}),..._===void 0?{}:{unavailable:_},disabled:u}),y5(i,e.locations)&&v(x5,{facet:`location`,options:i,chosen:e.locations,onChange:n=>t({...e,locations:n}),disabled:u}),x&&v(_A,{variant:`ghost`,"data-testid":`picker-reset-filters`,onClick:()=>{h(``),t(_5())},children:p(`uiLibrary.deviceFilterBar.resetFilters`,`Reset filters`)})]}),f5(e,a)&&v(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`picker-zone-filter-paused`,children:p(`uiLibrary.deviceFilterBar.zoneFilterPaused`,`Zone filter paused — zones not loaded`)})]})}function C5(e){let t=new Map;for(let n of e)t.set(n.id,n.name);let n=new Map;for(let r of e){let e=r.parentDeviceId;e!==null&&e!==r.id&&n.set(r.id,t.get(e)??`#${String(e)}`)}return n}function w5(e,t=Fn){if(!(e===void 0||e.length===0))return t(`uiLibrary.devicePicker.parentDetail`,`in {{parent}}`,{parent:e})}function T5(e){let t=e.filter(e=>typeof e.id==`number`);if(t.length===0)return e;let n=C5(t.map(e=>({id:e.id,name:e.name,parentDeviceId:e.parentDeviceId??null}))),r=!1,i=e.map(e=>{if(e.detail!==void 0||typeof e.id!=`number`)return e;let t=w5(n.get(e.id));return t===void 0?e:(r=!0,{...e,detail:t})});return r?i:e}E();function Mse(e,t){let n=t?.trim()??``;return n===``||n===e?e:`${e} (${n})`}function Nse(e,t,n){let r=new Map;for(let e of t)e.name!==void 0&&e.name!==``&&r.set(e.id,e.name);let i=new Map(n.map(e=>[e.id,e.name])),a=new Map;for(let t of e){let e=r.get(t.addonId);if(e===void 0)continue;let n=t.integrationId===void 0?null:i.get(t.integrationId)??null;a.set(t.id,Mse(e,n))}return a}var Pse=new Map,Fse=6e4;function Ise(e){let t=Rn().trpcClient,n=w({queryKey:[`ui-library`,`device-provider-labels`],enabled:e,staleTime:Fse,queryFn:async()=>{let[e,n,r]=await Promise.all([t.deviceManager.listAll.query({projection:`slim`}),t.addons.list.query(),t.integrations.list.query()]);return Nse(e,n.map(e=>({id:e.manifest.id,name:e.manifest.name})),r)}});return p(()=>n.data??Pse,[n.data])}E();var E5=`camstack.admin.device-picker.group-by`,Lse=[[`deviceManager`,`listSiteZones`],`device-picker`],Rse=6e4;function D5(){try{let e=globalThis.localStorage?.getItem(`camstack.admin.device-picker.group-by`)??null;return e===null?Z8:Q8(e)}catch{return Z8}}function O5(e){try{globalThis.localStorage?.setItem(E5,e)}catch{}}function k5(){let[e,t]=C(D5);return{groupBy:e,setGroupBy:e=>{t(e),O5(e)}}}function A5(e){let t=Rn().trpcClient,{data:n,isError:r}=w({queryKey:Lse,enabled:e,staleTime:Rse,queryFn:()=>t.deviceManager.listSiteZones.query()});return p(()=>n===void 0?r?{state:`failed`}:{state:`pending`}:{state:`answered`,zones:n},[n,r])}function j5(e){return e.data===void 0?e.isError?`failed`:`pending`:`answered`}function M5(e,t,n){if(n!==`answered`||t===void 0)return e.map(e=>({id:e,removed:!1}));let r=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>{let t=r.get(e);return t===void 0?{id:e,removed:!0}:{id:e,name:t,removed:!1}})}function N5(e,t,n,r){let i=new Set((t??[]).map(e=>e.id));return M5(e.filter(e=>!i.has(e)),n,r)}function P5(e,t,n){return e===`answered`&&t===0&&n===0}function F5(e,t,n){return e&&t===0&&n}var I5={camera:`cameras`,device:`devices`,node:`nodes`,package:`packages`,class:`classes`,zone:`zones`,face:`faces`,calendar:`calendars`};function L5(e,t){switch(e){case`camera`:return t(`uiLibrary.devicePicker.nounCamera`,`camera`);case`device`:return t(`uiLibrary.devicePicker.nounDevice`,`device`);case`node`:return t(`uiLibrary.devicePicker.nounNode`,`node`);case`package`:return t(`uiLibrary.devicePicker.nounPackage`,`package`);case`class`:return t(`uiLibrary.devicePicker.nounClass`,`class`);case`zone`:return t(`uiLibrary.devicePicker.nounZone`,`zone`);case`face`:return t(`uiLibrary.devicePicker.nounFace`,`face`);case`calendar`:return t(`uiLibrary.devicePicker.nounCalendar`,`calendar`)}}function R5(e,t){switch(e){case`camera`:return t(`uiLibrary.devicePicker.pluralCameras`,`cameras`);case`device`:return t(`uiLibrary.devicePicker.pluralDevices`,`devices`);case`node`:return t(`uiLibrary.devicePicker.pluralNodes`,`nodes`);case`package`:return t(`uiLibrary.devicePicker.pluralPackages`,`packages`);case`class`:return t(`uiLibrary.devicePicker.pluralClasses`,`classes`);case`zone`:return t(`uiLibrary.devicePicker.pluralZones`,`zones`);case`face`:return t(`uiLibrary.devicePicker.pluralFaces`,`faces`);case`calendar`:return t(`uiLibrary.devicePicker.pluralCalendars`,`calendars`)}}function z5(e,t){switch(e){case I5.camera:return R5(`camera`,t);case I5.device:return R5(`device`,t);case I5.node:return R5(`node`,t);case I5.package:return R5(`package`,t);case I5.class:return R5(`class`,t);case I5.zone:return R5(`zone`,t);case I5.face:return R5(`face`,t);case I5.calendar:return R5(`calendar`,t);default:return e}}function B5(e,t=`device`,n=Fn){let r=String(e.id);switch(t){case`node`:return e.removed?n(`uiLibrary.devicePicker.nodeUnknown`,`Node {{id}} — unknown to the hub`,{id:r}):e.name??n(`uiLibrary.devicePicker.nodeId`,`Node {{id}}`,{id:r});case`package`:return e.removed?n(`uiLibrary.devicePicker.packageNotInstalled`,`{{id}} — not installed`,{id:r}):e.name??r;case`class`:return e.removed?n(`uiLibrary.devicePicker.classNotListed`,`{{id}} — not in the class list`,{id:r}):e.name??r;case`zone`:return e.removed?n(`uiLibrary.devicePicker.zoneNotFound`,`{{id}} — zone not found`,{id:r}):e.name??n(`uiLibrary.devicePicker.zoneUnavailable`,`{{id}} — zone unavailable`,{id:r});case`face`:return e.removed?n(`uiLibrary.devicePicker.faceNotInGallery`,`{{id}} — not in the face gallery`,{id:r}):e.name??r;case`calendar`:return e.removed?n(`uiLibrary.devicePicker.calendarNotFound`,`{{id}} — calendar not found`,{id:r}):e.name??r;case`camera`:case`device`:return e.removed?n(`uiLibrary.devicePicker.deviceRemoved`,`Device #{{id}} — removed`,{id:r}):e.name??n(`uiLibrary.devicePicker.deviceId`,`Device #{{id}}`,{id:r})}}function V5({noun:e=`camera`}){let t=q();return v(`p`,{className:`mt-1 text-[11px] text-warning`,"data-testid":`devices-widen-warning`,children:t(`uiLibrary.devicePicker.widenWarning`,`No {{noun}} selected: the rule will apply to ALL {{plural}}.`,{noun:L5(e,t),plural:R5(e,t)})})}function H5({noun:e=`cameras`}){let t=q();return v(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.devicePicker.loading`,`Loading {{noun}}…`,{noun:z5(e,t)})})}function U5({noun:e=`devices`}){let t=q();return v(`p`,{className:`text-[11px] text-warning`,children:t(`uiLibrary.devicePicker.failed`,`The hub did not return its {{noun}} — selected ones are listed by id so they can still be removed.`,{noun:z5(e,t)})})}E();function zse(e,t){switch(e.kind){case`zone`:case`location`:return e.label;case`no-zone`:return t(`uiLibrary.devicePicker.noZone`,`No zone`);case`no-location`:return t(`uiLibrary.devicePicker.noLocation`,`No location`)}}function Bse(e,t=Fn){return e.heading===void 0?`${b5(e.type,t)} · ${e.location??t(`uiLibrary.devicePicker.noRoom`,`No room`)}`:zse(e.heading,t)}function W5(e){return e===`camera`||e===`device`}function G5(e,t){let n=yj(typeof e==`number`?e:0,`compact`,t);return typeof e==`number`?n:t}function Vse({id:e,stored:t,className:n}){return v(`span`,{className:n,children:G5(e,t)})}function Hse({id:e,stored:t,removed:n,onRemove:r}){let i=G5(e,t);return v(Kk,{testId:`picker-chip-${String(e)}`,label:i,warning:n,...r===void 0?{}:{onRemove:r}})}function Use(e,t,n,r,i){let a=new Map(t.map(e=>[e.id,e.name])),o=new Map(N5(e,t,n.devices,n.state).map(e=>[e.id,e]));return e.map(e=>{let t=a.get(e);if(t!==void 0)return{id:e,label:t,removed:!1};let n=o.get(e)??{id:e,removed:!1};return{id:e,label:B5(n,r,i),removed:n.removed}})}function Wse(e,t,n){let r=R5(e,n);return t?e===`camera`||e===`device`?n(`uiLibrary.devicePicker.noCamerasAvailable`,`No cameras available — the rule applies to all devices.`):n(`uiLibrary.devicePicker.noneAvailableAll`,`No {{plural}} available — the rule applies to every {{noun}}.`,{plural:r,noun:L5(e,n)}):n(`uiLibrary.devicePicker.noneAvailable`,`No {{plural}} available.`,{plural:r})}function K5({devices:e,listState:t,fleet:n,value:r,onChange:i,selection:a=`multiple`,groupBy:o,emptyMeansAll:s=!1,savedHadDevices:l=!1,noun:u=`camera`,groupTitle:d,emptyLabel:f,annotate:m,disabled:h=!1,testId:g,showAll:_=!1,lockedIds:y,lockedNote:b}){let x=q(),S=d??(e=>Bse(e,x)),w=b??x(`uiLibrary.devicePicker.alreadyAdded`,`Already added`),T=p(()=>W5(u)?e:T5(e),[e,u]),E=n??{state:t,devices:t===`answered`?T:void 0},D=p(()=>new Set(y??[]),[y]),O=e=>i(D.size===0?e:e.filter(e=>!D.has(e))),[k,A]=C(!1),[j,M]=C(!1),[N,P]=C(l||r.length>0);r.length>0&&!N&&P(!0);let F=Use(r,T,E,u,x),I=J8(F,j||_),L=k||_,R=F5(s,r.length,N),z=I5[u];return t===`answered`&&P5(t,T.length,r.length)?c(`div`,{"data-testid":g,children:[v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Wse(u,s,x)}),R&&v(V5,{noun:u})]}):c(`div`,{className:`mt-1 space-y-1.5`,"data-testid":g,children:[t===`pending`&&v(H5,{noun:z}),t===`failed`&&v(U5,{noun:u===`camera`?`devices`:z}),!(a===`single`&&F.length===0&&_)&&c(`div`,{className:`flex flex-wrap items-center gap-1`,children:[F.length===0?v(`span`,{className:`text-[11px] text-foreground-subtle`,children:f??(s?x(`uiLibrary.devicePicker.everyNoRestriction`,`Every {{noun}} — no restriction`,{noun:L5(u,x)}):x(`uiLibrary.devicePicker.noneSelected`,`None selected`))}):I.shown.map(e=>v(Hse,{id:e.id,stored:e.label,removed:e.removed,...h?{}:{onRemove:()=>i(r.filter(t=>t!==e.id))}},e.id)),I.hidden>0&&v(`button`,{type:`button`,className:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground-subtle hover:bg-surface-hover`,onClick:()=>M(!0),children:x(`uiLibrary.devicePicker.moreChips`,`+{{count}} more`,{count:I.hidden})}),j&&F.length>6&&v(`button`,{type:`button`,className:`text-[11px] text-foreground-subtle underline`,onClick:()=>M(!1),children:x(`uiLibrary.devicePicker.showFewer`,`Show fewer`)}),t!==`pending`&&!_&&v(`button`,{type:`button`,disabled:h,"aria-expanded":k,onClick:()=>A(e=>!e),className:`rounded-md border border-dashed border-border px-1.5 py-0.5 text-[11px] text-foreground hover:bg-surface-hover disabled:opacity-50`,children:k?x(`uiLibrary.devicePicker.done`,`Done`):r.length===0?x(`uiLibrary.devicePicker.addPlural`,`Add {{plural}}…`,{plural:R5(u,x)}):x(`uiLibrary.devicePicker.edit`,`Edit…`)})]}),L&&t===`answered`&&(W5(u)?v(Kse,{devices:T,value:r,onChange:O,locked:D,lockedNote:w,annotate:m,groupTitle:S,noun:u,disabled:h,showAll:_,selection:a,...o===void 0?{}:{pinnedGroupBy:o}}):v(q5,{devices:T,value:r,onChange:O,locked:D,lockedNote:w,annotate:m,groupTitle:S,noun:u,disabled:h,showAll:_,selection:a})),R&&v(V5,{noun:u})]})}var Gse=new Map;function Kse(e){let t=k5(),[n,r]=C(null),i=e.pinnedGroupBy,a=i===void 0?t.groupBy:n??i,o=e=>{if(i!==void 0){r(e);return}t.setGroupBy(e)},s=A5(!0),c=Ise(!0);return v(q5,{...e,providers:c,grouping:{groupBy:a,onGroupByChange:o,zones:s}})}function qse(e,t){return e===`camera`||e===`device`?t(`uiLibrary.devicePicker.searchDevice`,`Search by name, room or type…`):e===`class`?t(`uiLibrary.devicePicker.searchClass`,`Search by class or category…`):e===`zone`?t(`uiLibrary.devicePicker.searchZone`,`Search by camera or zone…`):t(`uiLibrary.devicePicker.searchDefault`,`Search by name or id…`)}var Jse={state:`answered`,zones:[]};function q5({devices:e,value:t,onChange:n,annotate:r,groupTitle:i,noun:a,disabled:o,locked:s,lockedNote:l,showAll:u,selection:d,grouping:f,providers:m=Gse}){let h=q(),g=y(),[_,b]=C(s5),[x,S]=C(new Map),[w,T]=C(60),E=u||L8(_.query).length>0,D=f?.groupBy,O=f?.zones??Jse,k=p(()=>m5(e,_,O),[e,_,O]),A=p(()=>D===void 0?null:r5(k,t,D,O),[k,t,D,O]),j=p(()=>A===null?W8(H8(k,t),t,x,E):i5(A,t,x,E),[A,k,t,x,E]),M=A?.groupBy??null,N=p(()=>d5(e,`type`,_.types,O),[e,_.types,O]),P=p(()=>d5(e,`zone`,_.zones,O),[e,_.zones,O]),F=p(()=>f===void 0?[]:d5(e,`location`,_.locations,O),[e,_.locations,O,f]),I=p(()=>v5(t,e,k),[e,t,k]),L=Y8(j,u?j.length:w),R=(e,t)=>S(n=>new Map([...n,[e.key,!t]]));return c(`div`,{className:`rounded-md border border-border bg-surface p-2`,"data-testid":`device-picker-panel`,children:[v(S5,{filters:_,onFiltersChange:e=>{b(e),T(60)},typeOptions:N,zoneOptions:P,locationOptions:F,zones:O,...f===void 0?{}:{grouping:{groupBy:f.groupBy,onGroupByChange:f.onGroupByChange,fallback:A?.fallback??null}},searchPlaceholder:qse(a,h),searchLabel:a===`camera`||a===`device`?h(`uiLibrary.devicePicker.searchDevices`,`Search devices`):h(`uiLibrary.devicePicker.searchPlural`,`Search {{plural}}`,{plural:R5(a,h)}),disabled:o}),v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:d===`single`?h(`uiLibrary.devicePicker.shownOfSingle`,`{{shown}} of {{total}} shown`,{shown:k.length,total:e.length}):h(`uiLibrary.devicePicker.shownOf`,`{{shown}} of {{total}} shown · {{selected}} selected`,{shown:k.length,total:e.length,selected:t.length})}),j.length===0?v(`p`,{className:`py-2 text-[11px] text-foreground-subtle italic`,children:a===`camera`||a===`device`?h(`uiLibrary.devicePicker.noDeviceMatches`,`No device matches.`):h(`uiLibrary.devicePicker.noNounMatches`,`No {{noun}} matches.`,{noun:L5(a,h)})}):c(`div`,{className:u?`mt-1`:`mt-1 max-h-72 overflow-y-auto`,"data-testid":`device-picker-rows`,children:[L.rows.map(e=>v(Xse,{row:e,value:t,onChange:n,onToggleGroup:R,annotate:r,groupTitle:i,groupBy:M,disabled:o,locked:s,lockedNote:l,selection:d,radioName:g,providers:m},e.key)),L.remaining>0&&v(`button`,{type:`button`,className:`mt-1 w-full rounded border border-border py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,onClick:()=>T(e=>e+60),children:h(`uiLibrary.devicePicker.showMore`,`Show {{count}} more ({{left}} left)`,{count:Math.min(L.remaining,60),left:L.remaining})})]}),I>0&&v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,"data-testid":`picker-hidden-selected`,children:h(`uiLibrary.devicePicker.hiddenSelected`,`{{count}} selected hidden by filters`,{count:I})})]})}function Yse(e,t){if(t===null)return e.detail;let n=a5(e,t),r=[n.location,n.type===null?null:b5(n.type),e.detail??null].filter(e=>e!==null);return r.length>0?r.join(` · `):void 0}function Xse({row:e,value:t,onChange:n,onToggleGroup:r,annotate:i,groupTitle:a,groupBy:o,disabled:s,locked:l,lockedNote:u,selection:d,radioName:f,providers:p}){let m=q(),h=d===`single`;if(e.kind===`header`){let{group:i,expanded:o}=e;return c(`div`,{className:`flex items-center gap-2 border-b border-border px-1 py-1`,"data-testid":`device-picker-group`,children:[c(`button`,{type:`button`,"aria-expanded":o,onClick:()=>r(i,o),className:`flex min-w-0 flex-1 items-center gap-1 text-left text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[v(`span`,{children:o?`▾`:`▸`}),v(`span`,{className:`truncate`,children:a(i)}),!h&&c(`span`,{className:`font-normal normal-case`,children:[`(`,i.selectedCount,`/`,i.devices.length,`)`]})]}),!h&&v(`button`,{type:`button`,disabled:s,className:`text-[10px] text-primary hover:underline disabled:opacity-50`,onClick:()=>n(K8(t,i)),children:m(`uiLibrary.devicePicker.all`,`All`)}),!h&&v(`button`,{type:`button`,disabled:s,className:`text-[10px] text-foreground-subtle hover:underline disabled:opacity-50`,onClick:()=>n(q8(t,i)),children:m(`uiLibrary.devicePicker.clear`,`Clear`)})]})}let g=l.has(e.device.id),_=g?u:i?.(e.device.id),y=Yse(e.device,o),b=e.device.id,x=typeof b==`number`?p.get(b):void 0;return c(`label`,{className:`flex cursor-pointer items-center gap-2.5 px-3 py-1 text-xs text-foreground hover:bg-surface-hover`,"data-testid":`device-picker-row`,children:[v(`input`,{type:h?`radio`:`checkbox`,...h?{name:f}:{},checked:e.selected||g,disabled:s||g,onChange:()=>n(h?[e.device.id]:G8(t,e.device.id)),className:`accent-primary`,"data-device-id":String(e.device.id)}),c(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[v(Vse,{id:e.device.id,stored:e.device.name,className:`truncate`}),y!==void 0&&v(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:y}),x!==void 0&&v(`span`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`device-picker-provider`,children:x}),_!==void 0&&v(`span`,{className:g?`text-[10px] text-foreground-subtle`:`text-[10px] text-warning`,children:_})]})]})}function J5(e){return{state:j5(e),devices:e.data}}var Zse=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`;function Y5({dimension:e,value:t,onChange:n,disabled:r=!1,emptyReason:i,inheritLabel:a,className:o,id:s,"aria-label":l}){let u=e===void 0?[]:Oee(e),d=e===void 0;return c(`div`,{className:`flex flex-col gap-0.5 min-w-0 w-full`,children:[c(`select`,{id:s,className:o??Zse,"aria-label":l,value:t,onChange:e=>{let t=e.target.value;if(t===``){n(``);return}n(ua(t)??t)},disabled:r||d,children:[a!==void 0&&v(`option`,{value:``,children:a}),u.map(e=>v(`option`,{value:e,children:e},e))]}),d&&i!==void 0&&i!==``&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}E();var Qse=`block text-[11px] font-medium text-foreground mb-1`,$se=`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`;function X5(e,t,n){let r=e.slice(0,t.start);return{value:`${r}${n}${e.slice(t.end)}`,cursor:r.length+n.length}}function ece({label:e,value:t,onChange:n,chips:r,multiline:i=!1,placeholder:a,disabled:o=!1,testId:s,maxLength:l}){let u=f(null),d=f(null),p=e=>{let r=i?d.current:u.current,a=X5(t,{start:r?.selectionStart??t.length,end:r?.selectionEnd??t.length},e);n(a.value),requestAnimationFrame(()=>{r?.focus(),r?.setSelectionRange(a.cursor,a.cursor)})},m=e=>n(e.target.value);return c(`div`,{className:`space-y-1`,"data-testid":s,children:[v(`label`,{className:Qse,children:e}),i?v(`textarea`,{ref:d,value:t,rows:2,disabled:o,placeholder:a,maxLength:l,onChange:m,className:$se,"data-testid":`${s}-input`}):v(Bl,{ref:u,value:t,disabled:o,placeholder:a,maxLength:l,onChange:m,"data-testid":`${s}-input`}),r!==void 0&&r.length>0&&v(`div`,{className:`flex flex-wrap gap-1 pt-0.5`,"data-testid":`${s}-chips`,children:r.map(e=>v(`button`,{type:`button`,disabled:o,className:`rounded-md bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary hover:bg-primary/20 disabled:opacity-50`,onClick:()=>p(e.token),"data-testid":`${s}-chip-${e.id}`,children:e.label},e.id))})]})}var tce={added:{variant:`success`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.added`,labelFallback:`Added`,className:``},removed:{variant:`danger`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.removed`,labelFallback:`Removed`,className:``},reclassified:{variant:`warning`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.reclassified`,labelFallback:`Reclassified`,className:``},adjusted:{variant:`info`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.adjusted`,labelFallback:`Adjusted`,className:``},unchanged:{variant:`neutral`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.unchanged`,labelFallback:`Unchanged`,className:``},"model-error":{variant:`danger`,style:`outline`,labelKey:`uiLibrary.retrainReviewBadge.modelError`,labelFallback:`Model error`,className:`border-danger text-danger`},draft:{variant:`primary`,style:`outline`,labelKey:`uiLibrary.retrainReviewBadge.draft`,labelFallback:`Draft`,className:`border-primary text-primary`}};function Z5(e,t=Fn){let{labelKey:n,labelFallback:r,...i}=tce[e];return{...i,label:t(n,r)}}function nce({kind:e,approximate:t=!1,className:n,...r}){let i=q(),a=Z5(e,i),o=a.style===`outline`;return c(Bk,{...r,variant:a.variant,style:a.style,dashed:t&&o,className:$(a.className,n),title:t?i(`uiLibrary.retrainReviewBadge.approximate`,`{{label}} (approximate)`,{label:a.label}):a.label,children:[a.label,t&&!o?` ~`:``]})}function Q5({options:e,value:t,onChange:n,ariaLabel:r,className:i,testId:a}){return e.length<2?null:v(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":a,className:$(`inline-flex shrink-0 items-center gap-0.5 rounded-md border border-border bg-background p-0.5`,i),children:e.map(e=>{let r=t===e.id,i=e.icon;return c(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":a===void 0?void 0:`${a}-${e.id}`,onClick:()=>n(e.id),className:$(`inline-flex h-7 items-center gap-1 whitespace-nowrap rounded px-2 text-xs font-medium transition-colors`,r?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`),children:[i===void 0?null:v(i,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e.label]},e.id)})})}function $5(e){return e??``}function e7(e){let t=[];for(let n of e){let e=$5(n.unit);t.includes(e)||t.push(e)}return t}function t7(e,t){let n=gN(e.map(e=>({points:e.points,gapMs:e.gapMs}))),r=n.ys;if(t){let t=e.flatMap((e,t)=>e.compare?[]:[t]),i=xN(t.map(e=>n.ys[e]??[]));r=n.ys.map((e,n)=>{let r=t.indexOf(n);return r>=0?i[r]??e:e})}let i=!n.ys.some(e=>e.some(e=>typeof e==`number`));return{xs:n.xs,raw:n.ys,drawn:r,mins:n.mins,maxs:n.maxs,units:e7(e),gaps:vN(e.filter(e=>!e.compare).map(e=>({points:e.points,gapMs:e.gapMs}))),empty:i}}function n7(e,t){let n=t??e.xs.length-1;return e.raw.map(t=>n<0?null:SN(e.xs,t,n))}function rce(e){return n7(e,null)}E();var ice=120;function ace(e,t){return e===void 0?t.length<2?0:(t[t.length-1]??0)-(t[0]??0):e.to-e.from}function oce(e){let t=ace(e.range,e.model.xs);return{xMin:e.range?.from??e.model.xs[0]??0,xMax:e.range?.to??e.model.xs.at(-1)??0,stops:e.model.xs,resolve:n=>{let r=vP(e.model.xs,n);if(r===null)return null;let i=e.model.xs[r];if(i===void 0)return null;let a=n7(e.model,r);return PP({timeLabel:FN(i,t),preference:e.preference,series:e.series.map((e,t)=>({id:e.id,label:e.label,value:a[t]??null,quantity:e.quantity,unit:e.unit??null}))})},onDataX:e.onDataX}}function r7({title:e,series:t,range:n,height:r=ice,stacked:i=!1,area:a=!1,syncKey:o,formatValue:s,displayPreference:l,axisFor:u,emptyMessage:d,pending:m=!1,actions:h,footer:g,windowToggle:y,className:b}){let x=q(),S=p(()=>t7(t,i),[t,i]),[w,T]=C(null),E=f(S);E.current=S;let D=f(n);D.current=n;let O=_((e,t)=>(s??lP)(e,t),[s]),k=()=>{let e=D.current;if(e)return e.to-e.from;let t=E.current.xs;return t.length>1?(t.at(-1)??0)-(t[0]??0):0},A=e=>e.unit??null,j=_(e=>(u??aP)(e===``?null:e),[u]),M=[t.map(e=>`${e.id}|${$5(e.unit)}|${e.colorIndex}|${e.interpolation??``}|${+!!e.band}|${+!!e.compare}`).join(`,`),i?`S`:``,a?`A`:``,o??``,n?`R`:``].join(`#`),N=p(()=>{let e=[];return t.forEach((t,n)=>{e.push([...S.drawn[n]??[]]),t.band&&(e.push([...S.mins[n]??[]]),e.push([...S.maxs[n]??[]]))}),[[...S.xs],...e]},[S,t]),F=_((e,n)=>{let r=E.current.units,s={x:{time:!0,...D.current?{range:()=>[D.current?.from??0,D.current?.to??1]}:{}}},c=[YN(k)];r.forEach((e,t)=>{let n=`y:${e}`,r=j(e);s[n]={range:e=>{let t=[];e.series.forEach((r,i)=>{if(!(i===0||r.scale!==n))for(let n of e.data[i]??[])t.push(n)});let i=XN(t,r);return[i[0],i[1]]}};let i=e===``?null:e,a=$N(n,t%2==0?3:1,e=>O(e,i),t===0);c.push({...a,splits:(e,t,n,i)=>QN([n,i],r)})});let l=[{}],u=[],d=t,f=d.filter(e=>!e.compare).length,p=1,m=null;return d.forEach(e=>{let t=rN(e.colorIndex),r=()=>cN(t.token),o=e.interpolation===`step`?n.paths.stepped?.({align:1}):n.paths.linear?.(),s=i&&!e.compare,c=!i&&a&&f===1&&!e.compare,d={label:e.label,scale:`y:${$5(e.unit)}`,stroke:e.compare?()=>uN(r(),.6):r,width:e.compare?1.25:2,dash:e.compare?[4,4]:t.dash.length>0?[...t.dash]:void 0,spanGaps:!1,points:{show:!1},...o?{paths:o}:{},...s&&m===null?{fill:()=>uN(r(),.85),fillTo:0}:{},...c?{fill:()=>uN(r(),.15)}:{}};l.push(d);let h=p;if(s&&m!==null&&u.push({series:[h,m],fill:()=>uN(r(),.85)}),s&&(m=h),p+=1,e.band){let t={scale:`y:${$5(e.unit)}`,stroke:()=>`transparent`,width:0,points:{show:!1},spanGaps:!1,...o?{paths:o}:{}};l.push({...t,label:`${e.label} min`},{...t,label:`${e.label} max`}),u.push({series:[p+1,p],fill:()=>uN(r(),.15)}),p+=2}}),{ms:1,legend:{show:!1},padding:[8,30,0,0],scales:s,axes:c,series:l,bands:u,cursor:eP(o),hooks:{drawClear:[tP(()=>E.current.gaps)],setCursor:[e=>T(e.cursor.idx??null)]}}},[M,O,j]),I=p(()=>oce({model:S,series:t,range:n,preference:l,onDataX:e=>{T(e===null?null:vP(S.xs,e))}}),[S,t,n,l]),L=n7(S,w),R=t.map((e,t)=>{let n=rN(e.colorIndex),r=L[t];return{id:e.id,label:e.label,token:n.token,dashed:e.compare===!0||n.dash.length>0,muted:e.compare===!0,value:r==null?S.empty?void 0:`—`:O(r,A(e))}}),z=w!==null&&S.xs[w]!==void 0?FN(S.xs[w]??0,k()):null,B=p(()=>{let r=rce(S),i=n?.from??S.xs[0],a=n?.to??S.xs.at(-1),o=t.map((e,t)=>{let n=r[t];return`${e.label} ${n==null?x(`uiLibrary.charts.unknown`,`unknown`):O(n,A(e))}`}).join(`; `);return i===void 0||a===void 0||!(a>i)?x(`uiLibrary.charts.seriesSummaryNoRange`,`{{title}}: {{parts}}`,{title:e,parts:o}):x(`uiLibrary.charts.seriesSummary`,`{{title}}, {{from}} to {{to}}: {{parts}}`,{title:e,from:PN(i,a-i),to:PN(a,a-i),parts:o})},[S,t,n,e,x,O]),V=c(P,{children:[y&&v(uP,{...y}),h]}),H=r<=64?`sm`:r<=120?`md`:`lg`;return v(dN,{title:e,actions:V,readoutTime:z,legend:R,summary:B,footer:g,placeholder:m?v(hN,{message:x(`uiLibrary.charts.loading`,`Loading…`),height:H}):S.empty?v(hN,{message:d??x(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`),height:H}):void 0,className:b,children:v(eF,{optionsKey:M,buildOptions:F,data:N,height:r,tooltip:I,kind:`lines`,label:e})})}E();var sce=20,cce=22;function lce(e,t,n){let r=new Set([t]);for(let i of e)for(let e of i.segments)e.from>=t&&e.from<n&&r.add(e.from);return[...r].sort((e,t)=>e-t)}function uce(e,t){let n=t.to-t.from;return{xMin:t.from,xMax:t.to,stops:lce(e,t.from,t.to),resolve:t=>LP({timeLabel:FN(t,n),rows:e.map(e=>{let n=FP(e.segments,t),r=n?.state??null,i=r===null?null:e.stateLabel?.(r)??r;return{id:e.id,label:e.label,stateLabel:i,spanMs:r===null?null:n?.spanMs??null}})})}}function i7(e,t){let n=e.colorIndex??0;return e.kind===`boolean`?t===e.states[1]?{token:rN(n).token}:{token:`border`}:{token:rN(n+Math.max(0,e.states.indexOf(t))).token}}function a7({title:e,rows:t,range:n,syncKey:r,pending:i=!1,emptyMessage:a,actions:o,className:s}){let l=q(),[u,d]=C(null),m=f(t);m.current=t;let h=f(n);h.current=n;let g=n.to-n.from,y=t.every(e=>e.segments.length===0),b=(e,t)=>e.stateLabel?.(t)??t,x=`${t.map(e=>`${e.id}:${e.states.join(`|`)}`).join(`,`)}#${r??``}`,S=p(()=>[[n.from,n.to],[null,null]],[n.from,n.to]),w=_(()=>({ms:1,legend:{show:!1},padding:[0,30,0,40],scales:{x:{time:!0,range:()=>[h.current.from,h.current.to]},y:{range:()=>[0,1]}},axes:[YN(()=>h.current.to-h.current.from),{show:!1,scale:`y`}],series:[{},{scale:`y`,stroke:()=>`transparent`,points:{show:!1}}],cursor:{...eP(r),points:{show:!1}},hooks:{draw:[e=>{let t=e.ctx,n=m.current,r=e.bbox.height/Math.max(1,n.length);t.save(),n.forEach((n,i)=>{let a=e.bbox.top+i*r;t.fillStyle=uN(cN(`foreground-subtle`),.06),t.fillRect(e.bbox.left,a+2,e.bbox.width,r-4);for(let i of n.segments){if(i.state===null)continue;let o=e.valToPos(Math.max(i.from,h.current.from),`x`,!0),s=e.valToPos(Math.min(i.to,h.current.to),`x`,!0);s>o&&(t.fillStyle=cN(i7(n,i.state).token),t.fillRect(o,a+2,Math.max(1,s-o),r-4))}}),t.restore()}],setCursor:[e=>{let t=e.cursor.left??-1;d(t<0?null:e.posToVal(t,`x`))}]}}),[x]),T=p(()=>({...uce(t,n),onDataX:e=>d(e)}),[t,n]),E=p(()=>t.map(e=>e.totals??wN(e.segments)),[t]),D=t.map((e,t)=>{let n=e.states.map(n=>{let r=E[t]?.get(n)??0;return r>0?`${b(e,n)} ${kN(r)}`:null}).filter(e=>e!==null).join(`, `);return`${e.label}: ${n.length>0?n:l(`uiLibrary.charts.noState`,`nothing recorded`)}`}).join(`; `),O=l(`uiLibrary.charts.stateSummary`,`{{title}}, {{from}} to {{to}}: {{parts}}`,{title:e,from:PN(n.from,g),to:PN(n.to,g),parts:D}),k=t.length>1,A=i?l(`uiLibrary.charts.loading`,`Loading…`):y?a??l(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`):null;return c(`figure`,{className:$(`min-w-0 m-0`,s),"data-chart-frame":``,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1 min-w-0`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate min-w-0`,children:e}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:[u!==null&&v(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:FN(u,g)}),o]})]}),A===null?c(`div`,{role:`img`,"aria-label":O,className:`flex min-w-0`,children:[k&&v(`div`,{className:`w-20 sm:w-28 shrink-0 pr-2`,"aria-hidden":`true`,children:t.map(e=>v(`div`,{className:`h-5 flex items-center text-[10px] text-foreground-muted truncate`,children:e.label},e.id))}),v(`div`,{className:`flex-1 min-w-0`,children:v(eF,{optionsKey:x,buildOptions:w,data:S,height:t.length*sce+cce,tooltip:T,kind:`states`,label:e})})]}):v(hN,{message:A,height:`sm`}),v(`p`,{className:`sr-only`,children:O}),A===null&&v(`ul`,{className:`mt-1 space-y-0.5 list-none p-0 m-0`,children:t.map((e,t)=>{let n=u===null?null:TN(e.segments,u);return c(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5 min-w-0`,children:[k&&v(`span`,{className:`text-[10px] text-foreground-muted`,children:e.label}),e.states.map(r=>{let i=E[t]?.get(r)??0;return i===0?null:c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px]`,n===r?`text-foreground`:`text-foreground-muted`),children:[v(fN,{token:i7(e,r).token}),v(`span`,{children:b(e,r)}),v(`span`,{className:`tabular-nums text-foreground`,children:kN(i)})]},r)})]},e.id)})})]})}E();function dce({points:e,ariaLabel:t,token:n=`chart-series-a`,height:r=32,widthClassName:i=`w-40`,zeroBased:a=!0,unit:o=null,quantity:s,displayPreference:c,className:l}){let u=p(()=>{let n=e.map(e=>e.x);return{xMin:n[0]??0,xMax:n.at(-1)??0,stops:n,resolve:r=>{let i=vP(n,r);if(i===null)return null;let a=e[i];return a===void 0?null:PP({timeLabel:String(a.x),preference:c,series:[{id:`value`,label:t,value:a.v,unit:o,quantity:s}]})}}},[e,t,o,s,c]),d=p(()=>[e.map(e=>e.x),e.map(e=>e.v)],[e]),f=_((e,t)=>({legend:{show:!1},cursor:{show:!1},padding:[2,1,2,1],scales:{x:{time:!1},y:{range:(e,t,n)=>{let r=a?Math.min(0,t):t;return[r,n>r?n:r+1]}}},axes:[{show:!1},{show:!1}],series:[{},{stroke:()=>cN(n),width:1.5,points:{show:!1},spanGaps:!1,...t.paths.linear?{paths:t.paths.linear()}:{}}]}),[n,a]);return v(`span`,{role:`img`,"aria-label":t,className:$(`inline-block align-middle`,i,l),children:v(eF,{optionsKey:`${n}#${a?`z`:``}`,buildOptions:f,data:d,height:r,inline:!0,tooltip:u,kind:`spark`,label:t})})}var o7=[`24h`,`7d`,`30d`,`1y`,`custom`],s7=36e5,c7=24*s7,l7={"24h":c7,"7d":7*c7,"30d":30*c7,"1y":365*c7};function u7(e){return e!=null&&o7.includes(e)}function d7(e,t,n){return e===`custom`?n&&n.to>n.from?{from:n.from,to:n.to}:{from:t-l7[`24h`],to:t}:{from:t-l7[e],to:t}}function f7(e){let t=e.to-e.from;return{window:{from:e.from-t,to:e.to-t},shiftMs:t}}function p7(e){return`${String(Math.round(e.from))}-${String(Math.round(e.to))}`}function m7(e){if(!e)return null;let t=/^(\d+)-(\d+)$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return r>n?{from:n,to:r}:null}var h7={"5m":5*6e4,"1h":s7,"1d":c7},g7=`addon:pipeline-analytics/occupancy`;function _7(e){if(!e.startsWith(`cap:`))return null;let t=e.slice(4),n=t.indexOf(`.`);return n<=0?null:{cap:t.slice(0,n),field:t.slice(n+1)}}function v7(e){if(!e.startsWith(`addon:`))return null;let t=e.slice(6),n=t.indexOf(`/`);return n<=0?null:{addonId:t.slice(0,n),name:t.slice(n+1)}}var y7=Object.keys(ca);function b7(e){let t=y7.indexOf(e);return t<0?y7.length:t}function x7(e,t){let n=Object.keys(ca[e]??{}),r=n.indexOf(t);return r<0?n.length:r}var S7=e=>e.kind===`boolean`||e.kind===`enum`;function C7(e,t,n){let r=[],i=new Map;for(let t of n){if(t.key===`derived:energy.kwh`){r.push({type:`energy`,id:`${e}:energy`,title:t.displayName,series:t});continue}if(S7(t))continue;let n=t.unit??``;i.set(n,[...i.get(n)??[],t])}let a=[...i.entries()].map(([n,r])=>{let i=[...new Set(r.map(e=>e.displayName))];return{type:`lines`,id:`${e}:unit:${n}`,title:i.length===1?i[0]??t:n===``?t:`${t} (${n})`,unit:n===``?null:n,series:r}}),o=n.filter(S7).map(t=>({type:`states`,id:`${e}:state:${t.key}:${t.scope}`,title:t.displayName,series:t}));return[...a,...r,...o]}function w7(e,t){let n=new Map,r=new Map,i=[],a=null;for(let t of e){if(t.key===`derived:energy.kwh`){a=t;continue}if(t.key===`addon:pipeline-analytics/occupancy`){i.push(t);continue}let e=_7(t.key);if(e){n.set(e.cap,[...n.get(e.cap)??[],t]);continue}let o=v7(t.key)?.addonId??`other`;r.set(o,[...r.get(o)??[],t])}a!==null&&(n.has(`power-meter`)?n.set(`power-meter`,[...n.get(`power-meter`)??[],a]):n.set(`energy`,[a]));let o=[...n.entries()].sort(([e],[t])=>b7(e)-b7(t)||e.localeCompare(t)).map(([e,n])=>{let r=[...n].sort((t,n)=>{let r=_7(t.key)?.field??``,i=_7(n.key)?.field??``;return x7(e,r)-x7(e,i)||t.scope.localeCompare(n.scope)}),i=`cap:${e}`;return{id:i,kind:`cap`,name:e,charts:C7(i,t(e),r)}});if(i.length>0){let e=r.get(`pipeline-analytics`)??[];r.set(`pipeline-analytics`,e)}let s=[...r.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{let r=`addon:${e}`,a=C7(r,t(e),n);return{id:r,kind:`producer`,name:e,charts:[...e===`pipeline-analytics`&&i.length>0?[{type:`occupancy`,id:`${r}:occupancy`,title:i[0]?.displayName??`Occupancy`,series:[...i].sort((e,t)=>e.scope.localeCompare(t.scope))}]:[],...a]}});return[...o,...s].filter(e=>e.charts.length>0)}function T7(e){let t=new Set;for(let n of e)if(n.type===`lines`||n.type===`occupancy`)for(let e of n.series)t.add(e.key);else t.add(n.series.key);return[...t]}function E7(e,t){return e?.series.find(e=>e.scope===t)}function fce(e,t){return t===`counter`?e.last:e.twMean??e.mean??e.last}function D7(e,t,n){let r=E7(t,e.scope),i=t!==void 0&&t.resolution!==`raw`,a=e.source===`cap`,o=(r?.points??[]).map(t=>({t:t.t,v:fce(t,e.kind),...i&&e.kind===`gauge`?{min:t.min,max:t.max}:{}}));return a&&r?.before&&r.before.value!==null&&(o[0]?.t??1/0)>n&&o.unshift({t:n,v:r.before.value}),{points:o,gapMs:a||t===void 0?void 0:KN(t.resolution===`raw`?1e4:h7[t.resolution]),held:a}}function O7(e,t){return e.map(e=>({...e,t:e.t+t}))}var k7=[`false`,`true`];function A7(e,t,n,r){let i=e.kind===`boolean`?k7:e.values??[],a=E7(t,e.scope),o=t=>e.kind===`boolean`?t.last===null?null:t.last>=.5?`true`:`false`:t.state;if(t===void 0||a===void 0)return{segments:[],totals:new Map,states:i};let s=a.before===null?null:e.kind===`boolean`?a.before.value===null?null:a.before.value>=.5?`true`:`false`:a.before.state;if(t.resolution===`raw`){let e=CN(a.points.map(e=>({t:e.t,state:o(e)})),n,r,s),t=new Map;for(let n of e)n.state!==null&&t.set(n.state,(t.get(n.state)??0)+(n.to-n.from));return{segments:e,totals:t,states:i}}let c=h7[t.resolution],l=new Map,u=[];for(let t of a.points){let i=Math.min(r,t.t+c),a=Math.max(n,t.t);if(!(i>a))continue;let o=pce(t,e,c),s=null,d=-1;for(let[e,t]of o)l.set(e,(l.get(e)??0)+t*((i-a)/c)),t>d&&(d=t,s=e);let f=u.at(-1);f&&f.state===s&&f.to===a?u[u.length-1]={...f,to:i}:u.push({from:a,to:i,state:s})}return{segments:u.filter(e=>e.state!==null),totals:l,states:i}}function pce(e,t,n){if(t.kind===`boolean`){let t=e.twMean??e.mean;return t===null?e.last===null?new Map:new Map([[e.last>=.5?`true`:`false`,n]]):new Map([[`true`,t*n],[`false`,(1-t)*n]])}return e.states?new Map(Object.entries(e.states)):e.state===null?new Map:new Map([[e.state,n]])}function j7(e){let t=e?.series[0],n=e===void 0||e.resolution===`raw`?h7[`1h`]:h7[e.resolution];return{buckets:(t?.points??[]).map(e=>({t:e.t,values:[e.delta]})),bucketMs:n}}function M7(e){return e.map(e=>{let t=eo(e.scope);return{scope:e.scope,zoneId:t.zoneId,className:t.className}})}function N7(e){return{zones:[...new Set(e.map(e=>e.zoneId))].sort(),classes:[...new Set(e.flatMap(e=>e.className===void 0?[]:[e.className]))].sort()}}function P7(e,t){return e.filter(e=>(t.zone===null||e.zoneId===t.zone)&&(t.className===null?e.className===void 0:e.className===t.className))}E();var F7=`__all__`;function I7(e,t){let n=e.split(`.`).at(-1)??``;return/open/i.test(n)?{on:t(`uiLibrary.history.state.open`,`open`),off:t(`uiLibrary.history.state.closed`,`closed`)}:/online|connected/i.test(n)?{on:t(`uiLibrary.history.state.online`,`online`),off:t(`uiLibrary.history.state.offline`,`offline`)}:/detected|tampered/i.test(n)?{on:t(`uiLibrary.history.state.detected`,`detected`),off:t(`uiLibrary.history.state.clear`,`clear`)}:{on:t(`uiLibrary.history.state.on`,`on`),off:t(`uiLibrary.history.state.off`,`off`)}}function L7(e){return e!==void 0&&!e.ok?e.error:null}function R7({spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}){let s=q(),c=n===null;if(e.type===`states`){let n=t(e.series.key,!1),i=L7(n);if(i)return v(B7,{title:e.title,error:i,actions:o});let l=n?.ok?n.result:void 0,u=A7(e.series,l,r.from,r.to),d=I7(e.series.key,s);return v(a7,{title:e.title,range:r,syncKey:a,pending:c,actions:o,rows:[{id:e.id,label:e.title,kind:e.series.kind===`boolean`?`boolean`:`enum`,states:u.states,segments:u.segments,totals:u.totals,stateLabel:e.series.kind===`boolean`?e=>e===`true`?d.on:d.off:void 0}]})}if(e.type===`energy`){let n=t(e.series.key,!1),i=L7(n);if(i)return v(B7,{title:e.title,error:i,actions:o});let{buckets:s,bucketMs:l}=j7(n?.ok?n.result:void 0);return v(tF,{title:e.title,layers:[{id:`kwh`,label:e.title,colorIndex:4}],buckets:s,bucketMs:l,range:r,unit:e.series.unit??`kWh`,showTotal:!0,syncKey:a,pending:c,actions:o})}return e.type===`occupancy`?v(hce,{spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}):v(z7,{title:e.title,series:e.series,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o,labelOf:t=>e.series.length>1||t.scope!==``?mce(t):e.title})}function mce(e){return e.scope===``?e.displayName:`${e.displayName} · ${e.scope}`}function z7({title:e,series:t,entryFor:n,reads:r,window:i,compare:a,syncKey:o,actions:s,labelOf:l,toolbar:u,colorOf:d}){let f=q(),m=[...new Set(t.map(e=>L7(n(e.key,!1))).filter(e=>e!==null))],h=p(()=>{let e=[];return t.forEach((o,s)=>{let c=n(o.key,!1),u=c?.ok?c.result:void 0,p=D7(o,u,i.from),m=d?.(o,s)??s,h=p.held&&u?.resolution===`raw`?`step`:`linear`;if(e.push({id:`${o.key}|${o.scope}`,label:l(o),unit:o.unit,colorIndex:m,points:p.points,gapMs:p.gapMs,interpolation:h,band:t.length===1&&u!==void 0&&u.resolution!==`raw`}),a&&r?.previous){let t=n(o.key,!0),a=t?.ok?t.result:void 0;if(a){let t=D7(o,a,i.from-r.shiftMs);e.push({id:`${o.key}|${o.scope}|previous`,label:f(`uiLibrary.history.previousOf`,`{{label}} (previous period)`,{label:l(o)}),unit:o.unit,colorIndex:m,points:O7(t.points,r.shiftMs),gapMs:t.gapMs,interpolation:h,compare:!0})}}}),e},[t,n,i.from,a,r,l,d,f]);return m.length>0?v(B7,{title:e,error:m.join(`; `),actions:s}):v(r7,{title:e,series:h,range:i,syncKey:o,pending:r===null,actions:c(P,{children:[u,s]})})}function hce({spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}){let s=q(),[l,u]=C(F7),[d,f]=C(F7),m=p(()=>M7(e.series),[e.series]),h=p(()=>N7(m),[m]),g=new Set(P7(m,{zone:l===F7?null:l,className:d===F7?null:d}).map(e=>e.scope)),_=e.series.filter(e=>g.has(e.scope)),y=e=>e===``?s(`uiLibrary.history.wholeFrame`,`Whole frame`):e,b=e=>{let t=m.find(t=>t.scope===e.scope);return t?t.className===void 0?y(t.zoneId):`${y(t.zoneId)} · ${t.className}`:e.scope},x=e=>{let t=m.find(t=>t.scope===e.scope),n=m.filter(e=>e.className===t?.className);return Math.max(0,n.findIndex(t=>t.scope===e.scope))},S=c(P,{children:[h.zones.length>1&&v(Yl,{"aria-label":s(`uiLibrary.history.filterZone`,`Zone`),value:l,onChange:e=>u(e.target.value),className:`h-6 text-[10px] py-0`,options:[{value:F7,label:s(`uiLibrary.history.allZones`,`All zones`)},...h.zones.map(e=>({value:e,label:y(e)}))]}),h.classes.length>0&&v(Yl,{"aria-label":s(`uiLibrary.history.filterClass`,`Class`),value:d,onChange:e=>f(e.target.value),className:`h-6 text-[10px] py-0`,options:[{value:F7,label:s(`uiLibrary.history.allClasses`,`All classes`)},...h.classes.map(e=>({value:e,label:e}))]})]});return v(z7,{title:e.title,series:_,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o,toolbar:S,labelOf:b,colorOf:x})}function B7({title:e,error:t,actions:n}){let r=q();return c(`figure`,{className:`min-w-0 m-0`,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate`,children:e}),n]}),v(hN,{height:`md`,message:r(`uiLibrary.history.readFailed`,`This history could not be read: {{error}}`,{error:t})})]})}var gce=uo({subject:fo(`kind`,[uo({kind:po(`device`),deviceId:co().int()}),uo({kind:po(`node`),nodeId:lo().min(1)})]),key:lo().min(1),scope:lo()}),_ce=24;function V7(e){return`${e.subject.kind===`device`?`d:${String(e.subject.deviceId)}`:`n:${e.subject.nodeId}`}|${e.key}|${e.scope}`}function H7(e){return[...e.subject.kind===`device`?[`d`,String(e.subject.deviceId)]:[`n`,e.subject.nodeId],e.key,e.scope].map(e=>encodeURIComponent(e)).join(`,`)}function U7(e){let t=e.split(`,`);if(t.length!==4)return null;let n;try{n=t.map(e=>decodeURIComponent(e))}catch{return null}let[r,i,a,o]=n;if(a===void 0||a===``||o===void 0||i===void 0)return null;if(r===`d`){let e=Number(i);return Number.isInteger(e)?{subject:{kind:`device`,deviceId:e},key:a,scope:o}:null}return r===`n`&&i!==``?{subject:{kind:`node`,nodeId:i},key:a,scope:o}:null}function W7(e){let t=new Set,n=[];for(let r of e){let e=V7(r);if(!t.has(e)&&(t.add(e),n.push(r),n.length>=24))break}return n}function G7(e,t){let n=new URLSearchParams;for(let t of W7(e))n.append(`s`,H7(t));return t!==void 0&&t!==`custom`&&n.set(`window`,t),`${K7}?${n.toString()}`}var K7=`/system/history`,q7=`admin.history-panels`,vce=ho(o7),yce=uo({id:lo().min(1),name:lo().min(1).max(80),window:vce,selection:go(gce).max(24)}),bce=uo({version:po(1),panels:go(yce).max(50),hidden:mo(lo(),go(lo()).max(200))}),J7={version:1,panels:[],hidden:{}};function Y7(e){if(e==null)return{value:J7,parsed:!0};let t=bce.safeParse(e);return t.success?{value:t.data,parsed:!0}:{value:J7,parsed:!1}}function X7(e,t,n,r){let i=String(t),a=e.hidden[i]??[],o=r?a.includes(n)?a:[...a,n]:a.filter(e=>e!==n),s=Object.fromEntries(Object.entries(e.hidden).filter(([e])=>e!==i));return{...e,hidden:o.length>0?{...s,[i]:o}:s}}function Z7(e,t){let n=e.panels.filter(e=>e.id!==t.id);return{...e,panels:[...n,t]}}function Q7(e,t){return{...e,panels:e.panels.filter(e=>e.id!==t)}}function $7(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${String(t.getFullYear())}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function e9(e){let t=new Date(e).getTime();return Number.isFinite(t)?t:null}function t9({value:e,onChange:t,custom:n,onCustomChange:r,compare:i,onCompareChange:a}){let o=q(),s=Date.now(),l=n??{from:s-864e5,to:s};return c(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 min-w-0`,children:[v(uP,{ariaLabel:o(`uiLibrary.history.window`,`Time window`),value:e,onChange:t,options:[{id:`24h`,label:o(`uiLibrary.history.window24h`,`24 h`)},{id:`7d`,label:o(`uiLibrary.history.window7d`,`7 d`)},{id:`30d`,label:o(`uiLibrary.history.window30d`,`30 d`)},{id:`1y`,label:o(`uiLibrary.history.window1y`,`1 y`)},{id:`custom`,label:o(`uiLibrary.history.windowCustom`,`Custom`)}]}),e===`custom`&&c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(Bl,{type:`datetime-local`,"aria-label":o(`uiLibrary.history.from`,`From`),className:`h-7 w-auto text-xs`,value:$7(l.from),onChange:e=>{let t=e9(e.target.value);t!==null&&t<l.to&&r({from:t,to:l.to})}}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:`–`}),v(Bl,{type:`datetime-local`,"aria-label":o(`uiLibrary.history.to`,`To`),className:`h-7 w-auto text-xs`,value:$7(l.to),onChange:e=>{let t=e9(e.target.value);t!==null&&t>l.from&&r({from:l.from,to:t})}})]}),i!==void 0&&a&&c(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-muted cursor-pointer select-none`,children:[v(BB,{checked:i,onChange:e=>a(e.target.checked)}),o(`uiLibrary.history.compare`,`Compare with previous period`)]})]})}var xce=800;function n9(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function r9(e){if(typeof e!=`object`||!e)return!1;let t=`data`in e?e.data:void 0,n=typeof t==`object`&&t&&`code`in t?t.code:void 0;return n===`FORBIDDEN`||n===`UNAUTHORIZED`}function i9(e){return e instanceof Error?e.message:String(e)}async function a9(e,t,n){let r=n.maxPoints??xce,i=[];for(let a of n9(t,24))try{let t=await e.queryMany({items:[...a],from:n.from,to:n.to,resolution:`auto`,maxPoints:r});a.forEach((e,n)=>{i.push(t.results[n]??{ok:!1,error:`no answer for this item`})})}catch(t){if(!r9(t)){let e=i9(t);for(let t of a)i.push({ok:!1,error:e});continue}i.push(...await Sce(e,a,n.from,n.to,r,i9(t)))}return i}async function Sce(e,t,n,r,i,a){return Promise.all(t.map(async t=>{if(!(`deviceId`in t))return{ok:!1,error:a};try{return{ok:!0,result:await e.query({deviceId:t.deviceId,key:t.key,...t.scope===void 0?{}:{scope:t.scope},from:n,to:r,resolution:`auto`,maxPoints:i})}}catch(e){return{ok:!1,error:i9(e)}}}))}E();var o9=6e4;function s9(e,t){let n=t<=l7[`24h`]?o9:t<=l7[`7d`]?5*o9:t<=l7[`30d`]?15*o9:60*o9;return Math.ceil(e/n)*n}function c9(){let e=Rn().trpcClient;return p(()=>({queryMany:t=>e.deviceHistory.queryMany.query(t),query:t=>e.deviceHistory.query.query(t)}),[e])}function l9(e){let t=IM(`device-history`),n=Rn().trpcClient,r=w({queryKey:[`device-history`,`listSeries`,e],queryFn:()=>n.deviceHistory.listSeries.query({deviceId:e}),enabled:t===`present`,staleTime:6e4});return{presence:t,list:r.status===`success`?{status:`ok`,data:r.data}:r.status===`error`?{status:`error`,error:r.error.message}:{status:`pending`}}}function u9(e){return`${`deviceId`in e?`d:${String(e.deviceId)}`:`n:${e.forNodeId}`}|${e.key}|${e.scope??`*`}`}function d9(e,t,n,r=!0){let i=c9(),a=e.map(u9),o=w({queryKey:[`device-history`,`reads`,a,t.from,t.to,n],queryFn:async()=>{let r=f7(t),[o,s]=await Promise.all([a9(i,e,t),n?a9(i,e,r.window):Promise.resolve(null)]),c=e=>new Map(e.map((e,t)=>[a[t]??String(t),e]));return{current:c(o),previous:s===null?null:c(s),shiftMs:r.shiftMs}},enabled:r&&e.length>0,staleTime:3e4,placeholderData:e=>e});return o.status===`success`?{status:`ok`,data:o.data}:o.status===`error`?{status:`error`,error:o.error.message}:{status:`pending`}}E();var f9=[`preferences`,q7];function p9(){let e=Rn().trpcClient,t=k(),n=w({queryKey:f9,queryFn:async()=>{let t=(await e.preferences.get.query({namespaces:[q7]})).rows.find(e=>e.namespace===q7);return t===void 0?null:{value:t.value,revision:t.revision}},staleTime:3e4}),r=n.data??null,i=Y7(r?.value),a=_(async n=>{let i=async(r,a)=>{let o=Y7(r?.value);if(!o.parsed)throw Error(`history-panels: stored row is not readable`);let s=n(o.value),c=await e.preferences.put.mutate({namespace:q7,value:{...s},baseRevision:r?.revision??0});if(c.status===`saved`){t.setQueryData(f9,{value:c.row.value,revision:c.row.revision});return}let l=c.current===null?null:{value:c.current.value,revision:c.current.revision};if(t.setQueryData(f9,l),!a)throw Error(`history-panels: the row changed while saving`);await i(l,!1)};await i(r,!0)},[e,t,r]);return{status:n.status===`success`?`ok`:n.status===`error`?`error`:`pending`,value:n.status===`success`?i.value:J7,writable:n.status===`success`&&i.parsed,update:a}}E();function m9(e){let t=e.replace(/[-_]/g,` `).trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}function Cce(e,t){return(t.type===`lines`||t.type===`occupancy`?t.series:[t.series]).map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function h9({deviceId:e,fixedWindow:t,onNavigate:n}){let r=q(),[i,a]=U6(`hw`),[o,s]=U6(`hr`),[l,u]=U6(`hc`),d=t??(u7(i)?i:`24h`),f=t?null:m7(o),m=t===void 0&&l===`1`,h=d7(d,Date.now(),f),g=d7(d,s9(Date.now(),h.to-h.from),f),{presence:y,list:b}=l9(e),x=p9(),S=p(()=>new Set(x.value.hidden[String(e)]??[]),[x.value.hidden,e]),[w,T]=C(new Set),E=p(()=>b.status===`ok`?w7(b.data,m9):[],[b]),D=p(()=>E.map(e=>({...e,charts:e.charts.filter(e=>!S.has(e.id))})).filter(e=>e.charts.length>0),[E,S]),O=E.reduce((e,t)=>e+t.charts.filter(e=>S.has(e.id)).length,0),k=d9(p(()=>T7(D.flatMap(e=>e.charts)).map(t=>({deviceId:e,key:t})),[D,e]),g,m,b.status===`ok`),A=k.status===`ok`?k.data:null,j=_((t,n)=>{let r=u9({deviceId:e,key:t});return k.status===`error`?{ok:!1,error:k.error}:(n?A?.previous:A?.current)?.get(r)},[e,k,A]),M=_(e=>{n?n(e):globalThis.location.assign(`${ri()}${e}`)},[n]),N=(t,n)=>{x.writable&&x.update(r=>X7(r,e,t,n))},P=()=>{x.writable&&x.update(t=>{let n=t;for(let t of S)n=X7(n,e,t,!1);return n})};if(y===`pending`)return v(g9,{});if(y===`unknown`)return v(eN,{title:r(`uiLibrary.history.presenceUnknownTitle`,`Could not reach the hub`),message:r(`uiLibrary.history.presenceUnknown`,`The hub did not say whether device history is installed. Try again in a moment.`)});if(y===`absent`)return v(QM,{icon:eee,title:r(`uiLibrary.history.absentTitle`,`Device history is not running on this hub`),description:r(`uiLibrary.history.absent`,`Nothing is recorded until the device-history system addon is enabled.`)});if(b.status===`pending`)return v(g9,{});if(b.status===`error`)return v(eN,{title:r(`uiLibrary.history.listFailedTitle`,`History could not be read`),message:b.error});if(E.length===0)return v(QM,{icon:hr,title:r(`uiLibrary.history.emptyTitle`,`Nothing recorded for this device yet`),description:r(`uiLibrary.history.empty`,`A value appears here once it changes, or at the next five-minute check.`)});let F=`device-history:${String(e)}`;return c(`div`,{className:Xe,children:[t===void 0&&c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[v(t9,{value:d,onChange:e=>a(e===`24h`?null:e),custom:f,onCustomChange:e=>s(p7(e)),compare:m,onCompareChange:e=>u(e?`1`:null)}),O>0&&c(_A,{variant:`ghost`,size:`sm`,onClick:P,disabled:!x.writable,children:[v(Oe,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r(`uiLibrary.history.showHidden`,{one:`Show {{count}} hidden chart`,other:`Show {{count}} hidden charts`},{count:O})]})]}),D.map(n=>v(dB,{expanded:!w.has(n.id),onExpandedChange:e=>T(t=>{let r=new Set(t);return e?r.delete(n.id):r.add(n.id),r}),header:c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:m9(n.name)}),v(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:r(`uiLibrary.history.chartCount`,{one:`{{count}} chart`,other:`{{count}} charts`},{count:n.charts.length})})]}),children:v(`div`,{className:`grid grid-cols-1 gap-4 2xl:grid-cols-2`,children:n.charts.map(n=>v(R7,{spec:n,entryFor:j,reads:A,window:g,compare:m,syncKey:F,actions:v(M6,{title:r(`uiLibrary.history.chartMenu`,`Chart actions`),items:[{id:`open`,label:r(`uiLibrary.history.openInHistory`,`Open in History`),icon:hr,onClick:()=>M(G7(Cce(e,n),d))},{id:`hide`,label:r(`uiLibrary.history.hide`,`Hide`),icon:Oe,hidden:t!==void 0,disabled:!x.writable,onClick:()=>N(n.id,!0)}]})},n.id))})},n.id))]})}function g9(){return c(`div`,{className:Xe,"aria-busy":`true`,children:[v(hM,{className:`h-7 w-72`}),v(hM,{className:`h-40 w-full`}),v(hM,{className:`h-40 w-full`})]})}E();var _9=Kn(`camstack:zone-editing`,null);function v9({children:e}){let[t,n]=C(!1),[r,i]=C(null),[a,o]=C(null),[s,c]=C(null),l=_(e=>{n(e),e||(i(null),o(null),c(null))},[]),u=_(e=>{i(e)},[]),d=_(e=>{o(e)},[]),f=_(e=>{n(!0),o(null),i(e),c(null)},[]),m=_(()=>{n(!1),i(null),o(null),c(null)},[]),h=_(e=>{o(e.id),c(e)},[]),g=_(e=>{c(t=>t===null?t:{...t,...e})},[]),y=_(()=>{c(null)},[]),b=p(()=>({editing:t,drawingKind:r,selectedZoneId:a,editingDraft:s,setEditing:l,setDrawingKind:u,setSelectedZoneId:d,startDrawing:f,exitEditing:m,enterDraft:h,updateDraft:g,discardDraft:y}),[t,r,a,s,l,u,d,f,m,h,g,y]);return v(_9.Provider,{value:b,children:e})}function wce(){return I(_9)}E();function y9(e,t,n){let r=f(null),i=f(null);(r.current===null||i.current!==e)&&(r.current=wa(e),i.current=e);let a=f(void 0),o=f(null),s=o.current;return t===null?(a.current=void 0,o.current=null):(a.current===void 0||s===null||s.source!==r.current||s.deviceId!==t||s.capName!==n)&&(a.current=na(r.current,t,n),o.current={source:r.current,deviceId:t,capName:n}),Be(a.current)}E();var b9=500,x9=800;function S9(e,t,n){try{let r=e.live;if(!r)return null;let i=r.onEvent;return!i||typeof i.subscribe!=`function`?null:i.subscribe({category:t},{onData:n})}catch{return null}}function C9(e,t){return e?.id===t}function w9(e,t){let[n,r]=C(null),[i,a]=C(null),[o,s]=C(null),[c,l]=C(`watching`),u=f(void 0),d=f(void 0),p=f(void 0),m=f(0);return b(()=>{if(t===null)return;let n=S9(e,`detection.motion-analysis`,e=>{let n=e;if(!C9(n?.source,t))return;let i=n.data;!i?.regions||i.regions.length===0||(r({zones:i.regions.map(e=>({...e.bbox,intensity:e.intensity})),frameWidth:i.frameWidth,frameHeight:i.frameHeight}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>r(null),b9))});return()=>{n?.unsubscribe(),u.current&&clearTimeout(u.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.motion-zones-raw`,e=>{let n=e;if(!C9(n?.source,t))return;let r=n.data;r?.zones&&(a({boxes:r.zones.map(e=>({bbox:e.bbox,changeScore:e.changeScore})),frameWidth:r.frameSize?.width??0,frameHeight:r.frameSize?.height??0,motionScore:r.zones.length>0?r.zones.reduce((e,t)=>e+t.changeScore,0)/r.zones.length:0}),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(null),b9))});return()=>{n?.unsubscribe(),d.current&&clearTimeout(d.current)}},[e,t]),b(()=>{if(m.current=0,t===null)return;let n=S9(e,`pipeline-analytics.frame-tracked`,e=>{let n=e?.data;!n||n.deviceId!==t||n.detections?.length&&typeof n.detections[0]?.kind==`string`&&(m.current=Date.now(),s({detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(null),x9))});return()=>{n?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.result`,e=>{let n=e;if(!C9(n?.source,t)||Date.now()-m.current<x9)return;let r=n.data?.frame;r?.detections?.length&&(s({detections:r.detections,frameWidth:r.width,frameHeight:r.height}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(null),x9))});return()=>{n?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.phase-transition`,e=>{let n=e;C9(n?.source,t)&&n.data?.to&&l(n.data.to)});return()=>{n?.unsubscribe()}},[e,t]),{motion:n,motionRaw:i,detection:o,phase:c}}var T9=3e4;function E9(e){return!(e.frameWidth>0)||!(e.frameHeight>0)?null:{id:e.id,className:e.className,x1:e.bbox.x/e.frameWidth,y1:e.bbox.y/e.frameHeight,x2:(e.bbox.x+e.bbox.w)/e.frameWidth,y2:(e.bbox.y+e.bbox.h)/e.frameHeight,becameStationaryAt:e.becameStationaryAt,...e.label===void 0?{}:{label:e.label}}}function Tce(e,t){let n=w({queryKey:[`zone-analytics`,t,`stationaryOverlay`],enabled:t!==null,refetchInterval:T9,staleTime:T9/2,queryFn:async()=>{let n=(await e.zoneAnalytics.getCurrentSnapshot.query({deviceId:t}))?.stationaryObjects??[],r=[];for(let e of n){let t=E9(e);t!==null&&r.push(t)}return r}});return n.isError?void 0:n.data}E();function D9(e){let t=e?.deviceId??null,n=e?.historyLimit??20,r=Po(`doorbell.onPressed`,t===null?void 0:e=>e.deviceId===t),[i,a]=C([]);return b(()=>{r&&a(e=>{if(e.length>0&&e[0].deviceId===r.deviceId&&e[0].timestamp===r.timestamp)return e;let t=[r,...e];return t.length>n?t.slice(0,n):t})},[r,n]),{latest:r??null,history:i}}E();var Ece=1e3;function O9(e,t){let n=Rn(),r=k(),[i,a]=C(n.connectionVersion);b(()=>n.subscribeConnectionEvents((e,t)=>{e===`connected`&&a(t)}),[n]);let o=t.join(`|`),s=JSON.stringify(e);b(()=>{let e=[],t=null,i=()=>{let e=JSON.parse(s),t=e.length===1&&Array.isArray(e[0])?e:[e];r.invalidateQueries({queryKey:t})},a=()=>{t===null&&(t=setTimeout(()=>{t=null,i()},Ece))};i();for(let t of o.split(`|`))if(t)try{e.push(n.subscribeEvent(t,a))}catch{}return()=>{t!==null&&clearTimeout(t);for(let t of e)t()}},[n,r,o,s,i])}function Dce(e,t,n){let r=Rn();return w({queryKey:e,queryFn:()=>t(r)(),...n})}function Oce(e,t){let n=Rn();return j({mutationFn:t=>e(n)(t),...t})}var k9=`en`,A9=new Map,j9=new Set,M9=0;function N9(e){let t=(e??``).trim().toLowerCase().split(/[-_]/)[0]??``;return t===``?k9:t}function P9(){if(typeof document<`u`){let e=document.documentElement.lang;if(e.trim()!==``)return N9(e)}return typeof navigator<`u`&&typeof navigator.language==`string`?N9(navigator.language):k9}function F9(e,t,n){let r=N9(t),i=A9.get(e)??new Map;i.set(r,n),A9.set(e,i),M9+=1;for(let e of j9)e()}function kce(e){j9.add(e);let t=null;return typeof document<`u`&&typeof MutationObserver<`u`&&(t=new MutationObserver(e),t.observe(document.documentElement,{attributes:!0,attributeFilter:[`lang`]})),()=>{j9.delete(e),t?.disconnect()}}function I9(){return`${P9()}#${M9}`}function L9(e,t){let n=e;for(let e of t){if(n===void 0||typeof n==`string`)return;n=n[e]}return typeof n==`string`?n:void 0}function Ace(e,t){try{return new Intl.PluralRules(e).select(t)}catch{return`other`}}function R9(e,t,n,r){let i=A9.get(e)?.get(t);if(i===void 0)return;let a=n.split(`.`);if(r!==void 0){let e=a[a.length-1]??n,o=a.slice(0,-1),s=L9(i,[...o,`${e}_${Ace(t,r)}`]);if(s!==void 0)return s;let c=L9(i,[...o,`${e}_other`]);if(c!==void 0)return c}return L9(i,a)}var jce=/\{\{\s*([\w.]+)\s*\}\}/g;function z9(e,t){return t===void 0?e:e.replace(jce,(e,n)=>{let r=t[n];return r===void 0?e:String(r)})}function B9(e,t,n,r){let i=r?.count,a=typeof i==`number`?i:void 0;return z9(R9(e,t,n,a)??R9(e,k9,n,a)??n,r)}E();function Mce(){return S(kce,I9,I9)}function V9(e,t){let n=Mce(),r=n.slice(0,n.indexOf(`#`)),i=t===void 0?r:N9(t);return{t:_((t,n)=>B9(e,i,t,n),[e,i,n]),lang:i}}var Nce=/<(\/?)([A-Za-z][\w-]*)(\s*\/)?>/g;function H9(e,t,n,r){let i=e[t];return i===void 0?v(d,{children:n},r):h(i,{key:r},...n)}function U9(e,t,n){let r={name:``,children:[]},i=[r],a=0,o=0,s=()=>i[i.length-1]??r,c=e=>{e!==``&&s().children.push(z9(e,n))};for(let n of e.matchAll(Nce)){c(e.slice(a,n.index)),a=n.index+n[0].length;let r=n[1]===`/`,l=n[2]??``;if(o+=1,n[3]!==void 0)s().children.push(H9(t,l,[],`k${o}`));else if(!r)i.push({name:l,children:[]});else if(i.length>1&&s().name===l){let e=i.pop();e&&s().children.push(H9(t,l,e.children,`k${o}`))}}for(c(e.slice(a));i.length>1;){let e=i.pop();e&&s().children.push(...e.children)}return r.children}function Pce(e,t){for(let[n,r]of Object.entries(t))F9(e,n,r);return{ns:e,useT:t=>V9(e,t),Trans:t=>{let{t:n}=V9(e),r=t.values?.count;return v(P,{children:U9(n(t.i18nKey,typeof r==`number`?{count:r}:void 0),t.components??{},t.values)})},translate:(t,n)=>B9(e,P9(),t,n)}}var Fce={onvif:vi,hikvision:Ln,reolink:fe,homeAssistant:Oi,rtsp:ur},Ice={online:Ni,offline:Ur,degraded:Ai,unknown:$n},W9={onvif:`#3b82f6`,hikvision:`#a855f7`,reolink:`#06b6d4`,homeAssistant:`#22d3ee`,rtsp:`#78716c`},G9={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`,successFill:`#4ade80`,successOn:`#0c0a09`,warningFill:`#fbbf24`,warningOn:`#0c0a09`,dangerFill:`#f87171`,dangerOn:`#0c0a09`,infoFill:`#60a5fa`,infoOn:`#0c0a09`,primaryFill:`#f59e42`,primaryOn:`#0c0a09`,neutralFill:`#44403c`,neutralOn:`#fafaf9`,provider:W9},K9={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`,successFill:`#15803d`,successOn:`#ffffff`,warningFill:`#b45309`,warningOn:`#ffffff`,dangerFill:`#dc2626`,dangerOn:`#ffffff`,infoFill:`#2563eb`,infoOn:`#ffffff`,primaryFill:`#c2410c`,primaryOn:`#ffffff`,neutralFill:`#57534e`,neutralOn:`#ffffff`,provider:W9},q9={colors:{dark:G9,light:K9},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 J9(e,t){let n={...e};for(let r in t){let i=t[r],a=e[r];i!==void 0&&typeof i==`object`&&i&&!Array.isArray(i)&&typeof a==`object`&&a?n[r]=J9(a,i):i!==void 0&&(n[r]=i)}return n}function Lce(e){return e?J9(structuredClone(q9),e):structuredClone(q9)}function Y9(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Rce(e){return`--color-${Y9(e)}`}function X9(e){let t=[];for(let[n,r]of Object.entries(e))n!==`provider`&&t.push(` ${Rce(n)}: ${r};`);return t.join(`
|
|
38
|
+
`;function m1({trpc:e,deviceId:t,layout:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(a===void 0||l===void 0)return null;let d=!s;if(n===`compact`)return c(`div`,{"data-mode":l.mode,className:`inline-flex items-center gap-1`,children:[v(`span`,{className:$(`text-xs tabular-nums font-medium`,XX[l.mode]),children:l.target===null?l.currentTemp===null?null:c(`span`,{className:`text-foreground-subtle`,children:[l.currentTemp,`°`]}):c(P,{children:[l.target,`°`,l.currentTemp!==null&&c(`span`,{className:`text-foreground-subtle font-normal`,children:[` `,`(`,l.currentTemp,`°)`]})]})}),l.target!==null&&c(P,{children:[v(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.decrease`,`Decrease target`),disabled:d,onClick:e=>{if(e.stopPropagation(),!d&&l.target!==null){let e=JX(l.target,-1,l);u({target:e}),a.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,d&&`opacity-40 cursor-not-allowed`),children:`−`}),v(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.increase`,`Increase target`),disabled:d,onClick:e=>{if(e.stopPropagation(),!d&&l.target!==null){let e=JX(l.target,1,l);u({target:e}),a.setTarget({target:e})}},className:$(`inline-flex h-5 w-5 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors text-xs`,d&&`opacity-40 cursor-not-allowed`),children:`+`})]}),v(`select`,{"aria-label":i(`uiLibrary.acPanel.mode`,`Mode`),value:l.mode,disabled:d,onChange:e=>{e.stopPropagation();let t=l.availableModes.find(t=>t===e.target.value);!d&&t&&(u({mode:t}),a.setMode({mode:t}))},className:$(`bg-transparent px-0.5 text-xs text-foreground-subtle hover:text-foreground cursor-pointer`,d&&`opacity-40 cursor-not-allowed`),children:l.availableModes.map(e=>v(`option`,{value:e,children:s1(i,e)},e))})]});let f=l1[l.mode],p=l.mode!==`off`,m=!i1(l.availableModes),h=a1(l),g=d1(l.preset),_=l.preset===`turbo`,y=Math.max(.55,f1(l.fanMode)*(_?.6:1)),b=l.swingVertical!==null,x=l.swingHorizontal!==null,S=p&&(l.swingVertical===!0||l.swingHorizontal===!0);return c(`div`,{"data-mode":l.mode,className:$(`relative flex flex-col items-stretch gap-2.5 overflow-hidden rounded-lg border p-3 transition-colors`,YX[l.mode]),children:[v(`style`,{children:p1}),c(`div`,{className:`relative z-10 flex flex-col items-center justify-center gap-1 overflow-hidden rounded-lg border border-border/50 bg-surface/30 px-3 py-3`,children:[v(`div`,{className:`pointer-events-none absolute inset-0 opacity-60`,children:m&&!p?v(x1,{}):v(b1,{mode:l.mode,accent:f,periodSec:y,swaying:S,forceRising:m})}),v(`div`,{className:`pointer-events-none absolute inset-0 bg-gradient-to-b from-surface/50 via-transparent to-surface/50`}),p&&v(`span`,{"aria-hidden":!0,className:`acv-glow pointer-events-none absolute left-1/2 top-1/2 h-16 w-16 -translate-x-1/2 -translate-y-1/2 rounded-full blur-2xl`,style:{background:f,animation:`acv-glow 3.2s ease-in-out infinite`}}),c(`div`,{className:`relative z-10 flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wide`,style:{color:f},children:[v(g1,{mode:l.mode,heatingOnly:m,className:`h-3.5 w-3.5`}),s1(i,l.mode),l.currentTemp!==null&&v(`span`,{className:`normal-case text-foreground-subtle`,children:i(`uiLibrary.acPanel.now`,`· {{temp}}° now`,{temp:l.currentTemp})}),l.currentHumidity!==null&&c(`span`,{className:`inline-flex items-center gap-0.5 normal-case text-foreground-subtle`,children:[v(Ue,{className:`h-3 w-3`}),l.currentHumidity,`%`]})]}),l.target===null?c(`div`,{className:`relative z-10 flex items-baseline gap-0.5`,children:[v(`span`,{className:$(`text-4xl font-bold leading-none tabular-nums text-foreground`,qX(l)),children:l.currentTemp??`—`}),v(`span`,{className:`text-lg text-foreground-subtle`,children:`°`})]}):c(P,{children:[c(`div`,{className:`relative z-10 flex items-center gap-3`,children:[v(v1,{label:i(`uiLibrary.acPanel.decrease`,`Decrease target`),symbol:`−`,disabled:d,onClick:()=>{if(d||l.target===null)return;let e=JX(l.target,-1,l);u({target:e}),a.setTarget({target:e})}}),c(`div`,{className:`flex items-baseline gap-0.5`,children:[v(`span`,{className:$(`text-4xl font-bold leading-none tabular-nums`,qX(l)),style:{color:f},children:l.target}),v(`span`,{className:`text-lg text-foreground-subtle`,children:`°`})]}),v(v1,{label:i(`uiLibrary.acPanel.increase`,`Increase target`),symbol:`+`,disabled:d,onClick:()=>{if(d||l.target===null)return;let e=JX(l.target,1,l);u({target:e}),a.setTarget({target:e})}})]}),h!==null&&v(`div`,{className:`relative z-10 w-full px-1`,children:v(y1,{value:l.target,min:h.min,max:h.max,step:l.tempStep,accent:f,disabled:d,label:i(`uiLibrary.acPanel.setpoint`,`Setpoint`),onPreview:e=>{u({target:e})},onCommit:e=>{u({target:e}),a.setTarget({target:e})}})})]})]}),c(`div`,{className:`relative z-10 grid grid-cols-3 gap-2`,children:[v(_1,{label:i(`uiLibrary.acPanel.mode`,`Mode`),icon:v(`span`,{style:{color:f},className:`flex`,children:v(g1,{mode:l.mode,heatingOnly:m,className:`h-4 w-4`})}),value:l.mode,options:l.availableModes.map(e=>({value:e,label:s1(i,e)})),disabled:d,onChange:e=>{let t=l.availableModes.find(t=>t===e);t&&(u({mode:t}),a.setMode({mode:t}))}}),l.availableFanModes.length>0&&v(_1,{label:i(`uiLibrary.acPanel.fan`,`Fan`),icon:v(Fi,{className:`h-4 w-4 text-sky-500`}),value:l.fanMode,options:l.availableFanModes.map(e=>({value:e,label:u1(e)})),disabled:d,onChange:e=>{u({fanMode:e}),a.setFanMode({fanMode:e})}}),l.availablePresets.length>0&&v(_1,{label:i(`uiLibrary.acPanel.preset`,`Preset`),icon:v(g,{className:`h-4 w-4 text-emerald-500`}),value:l.preset,options:l.availablePresets.map(e=>({value:e,label:u1(e)})),disabled:d,onChange:e=>{u({preset:e}),a.setPreset({preset:e})}})]}),(b||x)&&v(h1,{label:i(`uiLibrary.acPanel.swing`,`Swing`),children:c(`div`,{className:`grid grid-cols-2 gap-1`,children:[b&&v(C1,{axis:`vertical`,on:l.swingVertical??!1,busy:d,onToggle:e=>{u({swingVertical:e}),a.setSwingVertical({on:e})}}),x&&v(C1,{axis:`horizontal`,on:l.swingHorizontal??!1,busy:d,onToggle:e=>{u({swingHorizontal:e}),a.setSwingHorizontal({on:e})}})]})})]})}function h1({label:e,children:t}){return c(`div`,{className:`relative z-10 flex flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e}),t]})}function g1({mode:e,heatingOnly:t=!1,className:n}){return v(t&&e===`heat`?ve:c1[e],{className:n,"aria-hidden":!0})}function _1({label:e,icon:t,value:n,options:r,disabled:i,onChange:a}){return c(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e}),c(`div`,{className:$(`flex items-center gap-1 overflow-hidden rounded-lg border border-border/60 bg-surface-subtle px-1.5 py-1.5 has-[:focus-visible]:border-primary`,i&&`opacity-40`),children:[v(`span`,{className:`flex shrink-0`,children:t}),v(`select`,{"aria-label":e,value:n,disabled:i,onChange:e=>{e.stopPropagation(),i||a(e.target.value)},className:`min-w-0 flex-1 cursor-pointer appearance-none truncate bg-transparent text-xs font-medium text-foreground outline-none`,children:r.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(de,{className:`h-3 w-3 shrink-0 text-foreground-subtle`})]})]})}function v1({label:e,symbol:t,disabled:n,onClick:r}){return v(`button`,{type:`button`,"aria-label":e,disabled:n,onClick:r,className:$(`flex h-8 w-8 shrink-0 items-center justify-center rounded-full border border-border bg-surface text-lg leading-none text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground active:scale-95`,n&&`opacity-40 cursor-not-allowed`),children:t})}function y1({value:e,min:t,max:n,step:r,accent:i,disabled:a,label:o,onPreview:s,onCommit:l}){let u=f(null),d=f(!1),[p,m]=C(null),h=p??e,g=`${Math.min(1,Math.max(0,(h-t)/(n-t)))*100}%`,_=i=>{let a=u.current;if(a===null)return e;let o=a.getBoundingClientRect();return o.width<=0?e:o1((i-o.left)/o.width,{min:t,max:n},r)},y=e=>{if(a)return;e.stopPropagation(),e.preventDefault(),d.current=!0,typeof e.currentTarget.setPointerCapture==`function`&&e.currentTarget.setPointerCapture(e.pointerId);let t=_(e.clientX);m(t),s(t)},b=e=>{if(a||!d.current)return;e.stopPropagation();let t=_(e.clientX);m(t),s(t)},x=e=>{if(!d.current)return;e.stopPropagation(),d.current=!1;let t=_(e.clientX);m(null),e.currentTarget.hasPointerCapture?.(e.pointerId)===!0&&e.currentTarget.releasePointerCapture(e.pointerId),l(t)};return c(`div`,{ref:u,role:`slider`,"aria-label":o,"aria-valuemin":t,"aria-valuemax":n,"aria-valuenow":h,"aria-disabled":a,tabIndex:a?-1:0,onPointerDown:y,onPointerMove:b,onPointerUp:x,onPointerCancel:x,onKeyDown:i=>{if(a)return;let o=p??e;i.key===`ArrowRight`||i.key===`ArrowUp`?(i.preventDefault(),l(JX(o,1,{tempStep:r,minTemp:t,maxTemp:n}))):i.key===`ArrowLeft`||i.key===`ArrowDown`?(i.preventDefault(),l(JX(o,-1,{tempStep:r,minTemp:t,maxTemp:n}))):i.key===`Home`?(i.preventDefault(),l(t)):i.key===`End`&&(i.preventDefault(),l(n))},className:$(`mt-1 w-full touch-none select-none py-2`,a?`cursor-not-allowed opacity-40`:`cursor-ew-resize`),children:[c(`div`,{className:`relative h-1.5 w-full rounded-full bg-surface-subtle`,children:[v(`div`,{className:`absolute inset-y-0 left-0 rounded-full`,style:{width:g,background:i}}),v(`div`,{className:`absolute top-1/2 h-3.5 w-3.5 -translate-x-1/2 -translate-y-1/2 rounded-full border-2 border-surface shadow`,style:{left:g,background:i}})]}),c(`div`,{className:`mt-0.5 flex justify-between text-[9px] tabular-nums text-foreground-subtle`,children:[c(`span`,{children:[t,`°`]}),c(`span`,{children:[n,`°`]})]})]})}function b1({mode:e,accent:t,periodSec:n,swaying:r,forceRising:i=!1}){let a=[0,1,2,3,4,5],o=i||e===`heat`,s=e===`dry`;return v(`div`,{"aria-hidden":!0,className:`absolute inset-0 overflow-hidden`,children:e===`off`?v(`div`,{className:`flex h-full items-center justify-center gap-2 opacity-30`,children:a.map(e=>v(`span`,{className:`h-8 w-1 rounded-full bg-foreground-subtle opacity-40`},e))}):e===`fan_only`?v(`div`,{className:`flex h-full items-center justify-center`,children:v(S1,{color:t,periodSec:Math.max(.5,n*.7),size:56})}):v(`div`,{"data-testid":i?`climate-heat-rise`:void 0,className:$(`acv-sway-wrap absolute inset-0`,r&&`acv-sway`),style:r?{animation:`acv-sway 2.6s ease-in-out infinite`}:void 0,children:a.map(e=>v(`span`,{className:`acv-streak absolute rounded-full`,style:{left:`${8+e*15}%`,width:s?`0.4rem`:`0.3rem`,height:s?`0.4rem`:`1.9rem`,background:t,boxShadow:`0 0 6px ${t}`,animationName:o?`acv-rise`:`acv-fall`,animationTimingFunction:`linear`,animationIterationCount:`infinite`,animationDuration:`${n}s`,animationDelay:`${e%3*(n/3)+e*.05}s`}},e))})})}function x1(){return v(`div`,{"data-testid":`climate-radiator`,"aria-hidden":!0,className:`flex h-full items-end justify-center gap-1.5 px-8 pb-3 opacity-40`,children:[0,1,2,3,4,5,6].map(e=>v(`span`,{className:`h-10 w-1.5 rounded-t-full bg-foreground-subtle`},e))})}function S1({color:e,periodSec:t,size:n}){return c(`svg`,{width:n,height:n,viewBox:`0 0 100 100`,className:`acv-fan`,style:{animation:`acv-spin ${t}s linear infinite`,transformOrigin:`50% 50%`},"aria-hidden":!0,children:[[0,120,240].map(t=>v(`path`,{d:`M50 50 C 58 30, 78 26, 84 12 C 66 20, 54 34, 50 50 Z`,fill:e,opacity:.85,transform:`rotate(${t} 50 50)`},t)),v(`circle`,{cx:`50`,cy:`50`,r:`7`,fill:e})]})}function C1({axis:e,on:t,busy:n,onToggle:r}){let i=q(),a=e===`vertical`?i(`uiLibrary.acPanel.vertical`,`Vertical`):i(`uiLibrary.acPanel.horizontal`,`Horizontal`),o=e===`vertical`?sn:tn,s=e===`vertical`?`acv-swing-v`:`acv-swing-h`;return c(`button`,{type:`button`,"aria-label":i(`uiLibrary.acPanel.swingAxis`,`{{axis}} swing`,{axis:a}),"aria-pressed":t,disabled:n,onClick:()=>{n||r(!t)},className:$(`flex items-center justify-center gap-2 rounded-lg border px-2 py-1.5 text-xs font-medium transition-colors`,t?`border-transparent bg-indigo-400 text-indigo-950 shadow-sm`:`border-border/60 bg-surface-subtle text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,n&&`opacity-40 cursor-not-allowed`),children:[v(o,{className:`acv-swing h-4 w-4`,"aria-hidden":!0,style:t?{animation:`${s} 1.4s ease-in-out infinite`}:void 0}),a]})}var w1=5,T1=35;function E1(e,t,n){return n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))}function D1(e,t,n){return Math.round(t+e*(n-t))}var O1=176,k1=76,A1=2*Math.PI*k1,j1=270/360*A1,M1=O1/2-k1-10;function N1(e){let t=O1/2,n=O1/2,r=A1-j1,i=e.mode===`band`?(()=>{let t=e.band.from*j1,n=Math.max(0,(e.band.to-e.band.from)*j1);return{dasharray:`${n} ${A1-n}`,dashoffset:-t}})():(()=>{let t=e.fraction*j1;return{dasharray:`${t} ${A1-t}`,dashoffset:void 0}})();return c(`svg`,{width:O1,height:O1,viewBox:`0 0 ${O1} ${O1}`,"aria-hidden":`true`,className:`absolute inset-0`,style:{transform:`rotate(135deg)`},children:[v(`circle`,{cx:t,cy:n,r:k1,fill:`none`,stroke:`var(--color-border)`,strokeWidth:12,strokeDasharray:`${j1} ${r}`,strokeLinecap:`round`}),v(`circle`,{cx:t,cy:n,r:k1,fill:`none`,stroke:e.color,strokeWidth:12,strokeDasharray:i.dasharray,...i.dashoffset===void 0?{}:{strokeDashoffset:i.dashoffset},strokeLinecap:`round`})]})}var P1={heat:`#f59e0b`,cool:`#60a5fa`,auto:`#c084fc`,heat_cool:`#e879f9`,fan_only:`#94a3b8`,dry:`#22d3ee`,off:`#d4d4d8`};function F1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl}),o=Zj({trpc:e,deviceId:t,cap:e=>e.heatingValve,slice:e=>e.state.heatingValve}),{display:s,applyOptimistic:l}=FX(a.slice,{enabled:r??!0}),u=a.cap!==void 0&&s!==void 0,d=o.cap!==void 0;if(!u&&!d)return null;if(!u&&d)return v(`div`,{className:`flex flex-col items-stretch gap-3 rounded-lg border border-border bg-surface p-4`,children:v(n1,{trpc:e,deviceId:t,layout:`full`})});if(a.cap===void 0||s===void 0)return null;let f=a.cap,p=!a.available,m=P1[s.mode],h=s.mode===`heat_cool`||s.targetLow!==null&&s.targetHigh!==null,g=w1,_=T1,y=!h&&s.target!==null?E1(s.target,g,_):0,b=h&&s.targetLow!==null?E1(s.targetLow,g,_):0,x=h&&s.targetHigh!==null?E1(s.targetHigh,g,_):0;return c(`div`,{"data-mode":s.mode,className:$(`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4 transition-colors`,YX[s.mode]),children:[c(`div`,{className:`flex flex-col items-center gap-3`,children:[c(`div`,{className:`relative`,style:{width:O1,height:O1},children:[h?v(N1,{mode:`band`,band:{from:b,to:x},color:m}):v(N1,{mode:`fill`,fraction:y,color:m}),h?c(P,{children:[v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:b,color:m,knobTopPx:M1,onDragFraction:e=>{if(p||s.targetHigh===null)return;let t=Math.min(D1(e,g,_),s.targetHigh);l({targetLow:t}),f.setTargetRange({targetLow:t,targetHigh:s.targetHigh})}})}),v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:x,color:m,knobTopPx:M1,onDragFraction:e=>{if(p||s.targetLow===null)return;let t=Math.max(D1(e,g,_),s.targetLow);l({targetHigh:t}),f.setTargetRange({targetLow:s.targetLow,targetHigh:t})}})})]}):v(`div`,{"data-testid":`arc-knob`,children:v(bX,{fraction:y,color:m,knobTopPx:M1,onDragFraction:e=>{if(p)return;let t=D1(e,g,_);l({target:t}),f.setTarget({target:t})}})}),c(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-0.5 pointer-events-none`,children:[c(`div`,{"data-testid":`current-temp`,className:`text-4xl font-bold tabular-nums text-foreground leading-none`,children:[s.currentTemp===null?`—`:s.currentTemp,v(`span`,{className:`text-lg text-foreground-subtle font-normal ml-0.5`,children:`°`})]}),!h&&s.target!==null&&v(`div`,{className:`text-xs font-semibold`,style:{color:m},children:i(`uiLibrary.thermostatHeroCard.setTo`,`set {{value}}°`,{value:s.target})}),h&&s.targetLow!==null&&s.targetHigh!==null&&c(`div`,{className:`text-xs font-semibold`,style:{color:m},children:[s.targetLow,`° – `,s.targetHigh,`°`]})]})]}),!h&&s.target!==null&&v(`div`,{className:`w-[200px]`,children:v(mX,{value:`${s.target}°`,onDelta:e=>{if(p||s.target===null)return;let t=s.target+e;l({target:t}),f.setTarget({target:t})}})})]}),d?v(n1,{trpc:e,deviceId:t,layout:`full`}):null,v(`select`,{"aria-label":i(`uiLibrary.thermostatHeroCard.mode`,`Mode`),value:s.mode,disabled:p,onChange:e=>{e.stopPropagation();let t=e.target.value;!p&&t&&(l({mode:s.availableModes.find(e=>e===t)??s.mode}),f.setMode({mode:s.availableModes.find(e=>e===t)??s.mode}))},className:$(`w-full rounded border border-border bg-surface px-3 py-1.5 text-sm`,p&&`opacity-40 cursor-not-allowed`),children:s.availableModes.map(e=>v(`option`,{value:e,children:e},e))})]})}function I1(e){return e===`locked`||e===`locking`}function L1(e){return e===`jammed`}var R1={locked:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`locked`},locking:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`locked`},unlocked:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`open`},unlocking:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`open`},jammed:{colorClass:`border-danger/30 bg-danger/10 text-danger`,icon:`locked`}};function z1({state:e}){let t=R1[e];return v(`div`,{"data-testid":`lock-glyph`,"data-state":e,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,t.colorClass),children:t.icon===`locked`?v(Cr,{className:`h-8 w-8`,"aria-hidden":`true`}):v(yi,{className:`h-8 w-8`,"aria-hidden":`true`})})}function B1({state:e}){return v(`span`,{className:$(`text-sm font-medium capitalize`,L1(e)?`text-danger`:`text-foreground-muted`),children:e})}function V1({busy:e,onOpen:t}){let n=q();return c(`button`,{type:`button`,"aria-label":n(`uiLibrary.lockHeroCard.openUnlatch`,`Open (unlatch)`),title:n(`uiLibrary.lockHeroCard.openUnlatch`,`Open (unlatch)`),disabled:e,onClick:e=>{e.stopPropagation(),t()},className:$(`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium`,`text-foreground-muted hover:bg-surface-hover transition-colors`,e&&`opacity-40 cursor-not-allowed`),children:[v(pn,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),n(`uiLibrary.lockHeroCard.open`,`Open`)]})}function H1({trpc:e,deviceId:t,features:n,optimistic:r}){let{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.lockControl,slice:e=>e.state.lockControl}),{display:s,applyOptimistic:l}=FX(a,{enabled:r??!0});if(i===void 0||s===void 0||!(s.state in R1))return null;let u=I1(s.state),d=L1(s.state)||!o,f=n?.includes(Oa.LockOpen)===!0,p=()=>{d||(u?(l({state:`unlocking`}),i.unlock({})):(l({state:`locking`}),i.lock({})))},m=()=>{d||i.open({})},h=u?`Unlock`:`Lock`;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(z1,{state:s.state}),v(B1,{state:s.state})]}),v(`div`,{className:$(d&&`pointer-events-none opacity-40`),children:v(hX,{on:u,targetLabel:h,onConfirm:p})}),f&&v(`div`,{className:`flex justify-center`,children:v(V1,{busy:d,onOpen:m})})]})}var U1=500,W1=150,G1=`linear-gradient(90deg, #9ec9ff, #ffffff, #ffb24d)`;function K1(e,t,n){return n<=t?0:Math.min(1,Math.max(0,(e-t)/(n-t)))}function q1(e){return K1(e,W1,U1)}var J1=`#f4b740`,Y1=`#d4d4d8`;function X1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),o=Zj({trpc:e,deviceId:t,cap:e=>e.brightness,slice:e=>e.state.brightness}),s=Zj({trpc:e,deviceId:t,cap:e=>e.color,slice:e=>e.state.color}),l=FX(a.slice,{enabled:r??!0}),u=FX(o.slice,{enabled:r??!0}),d=FX(s.slice,{enabled:r??!0});if(a.cap===void 0||l.display===void 0)return null;let f=l.display.on===!0,p=!a.available,m=u.display?.level??0,h=!o.available,g=f?m/100:0,_=f?J1:Y1,y=(n?.includes(Oa.LightColorMired)??!1)&&s.cap!==void 0,b=d.display?.colorTemperature,x=!s.available;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[c(`div`,{className:`flex flex-col items-center gap-3`,children:[c(DX,{fraction:g,color:_,children:[c(`div`,{"data-testid":`brightness-readout`,className:`text-3xl font-bold tabular-nums text-foreground leading-none`,children:[m,v(`span`,{className:`text-base text-foreground-subtle font-normal ml-0.5`,children:`%`})]}),v(Xn,{className:`h-5 w-5 text-foreground-subtle`,"aria-hidden":`true`})]}),o.cap!==void 0&&c(`label`,{className:`flex w-full items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{className:`w-16`,children:i(`uiLibrary.lightHeroCard.brightness`,`Brightness`)}),v(`input`,{"aria-label":i(`uiLibrary.lightHeroCard.brightness`,`Brightness`),type:`range`,min:0,max:100,step:1,className:`flex-1`,value:m,disabled:h||!f,onChange:e=>{let t=Number(e.target.value);u.applyOptimistic({level:t}),h||o.cap?.setBrightness({level:t})}}),c(`span`,{className:`tabular-nums w-9 text-right`,children:[m,`%`]})]})]}),c(`div`,{className:`flex items-center justify-between`,children:[v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:f?i(`uiLibrary.lightHeroCard.on`,`On`):i(`uiLibrary.lightHeroCard.off`,`Off`)}),v(OX,{on:f,busy:p,onToggle:()=>{if(p)return;let e=!f;l.applyOptimistic({on:e}),a.cap?.setState({on:e})}})]}),y&&c(`div`,{className:`flex items-center gap-2`,"data-testid":`color-temp-strip`,children:[v(We,{className:`h-4 w-4 text-foreground-subtle`,"aria-hidden":`true`}),c(`label`,{className:`flex-1`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.lightHeroCard.colourTemperature`,`Colour temperature`)}),v(`input`,{"aria-label":i(`uiLibrary.lightHeroCard.colourTemperature`,`Colour temperature`),type:`range`,min:W1,max:U1,step:1,className:`w-full`,value:b??U1,disabled:x||!f,onChange:e=>{let t=Number(e.target.value);d.applyOptimistic({mode:`mired`,colorTemperature:t}),x||s.cap?.setColor({color:{mode:`mired`,colorTemperature:t}})}}),v(`div`,{className:`pointer-events-none mt-1`,children:v(xX,{fraction:b===void 0?.5:q1(b),color:G1})})]})]})]})}var Z1=`#3aa6a0`,Q1=`#d4d4d8`;function $1({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),a=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),o=Zj({trpc:e,deviceId:t,cap:e=>e.fanControl,slice:e=>e.state.fanControl}),s=FX(a.slice,{enabled:r??!0}),l=FX(o.slice,{enabled:r??!0});if(a.cap===void 0||s.display===void 0)return null;let u=s.display.on===!0,d=!a.available,f=l.display?.speed??0,p=!o.available,m=u?f/100:0,h=u?Z1:Q1,g=n?.includes(Oa.FanSpeed)??!1,_=(n?.includes(Oa.FanOscillating)??!1)&&o.cap!==void 0,y=l.display?.availablePresets??[],b=(n?.includes(Oa.FanPreset)??!1)&&o.cap!==void 0&&y.length>0,x=l.display?.preset??``,S=l.display?.oscillating===!0,C=()=>{if(d)return;let e=!u;s.applyOptimistic({on:e}),a.cap?.setState({on:e})},w=()=>{if(p)return;let e=!S;l.applyOptimistic({oscillating:e}),o.cap?.setOscillating({oscillating:e})},T=e=>{if(p)return;let t=l.display;if(t===void 0)return;let n=t.percentageStep!==void 0&&t.percentageStep>0?t.percentageStep:1,r=Math.min(100,Math.max(0,Math.round(e*100/n)*n));l.applyOptimistic({speed:r}),o.cap?.setPercentage({speed:r})},E=e=>{p||e===``||(l.applyOptimistic({preset:e}),o.cap?.setPreset({preset:e}))};return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-4`,children:[v(`div`,{className:`flex flex-col items-center gap-3`,children:g?c(DX,{fraction:m,color:h,onDragFraction:T,children:[c(`div`,{"data-testid":`speed-readout`,className:`text-3xl font-bold tabular-nums text-foreground leading-none`,children:[f,v(`span`,{className:`text-base text-foreground-subtle font-normal ml-0.5`,children:`%`})]}),v(Ht,{className:`h-5 w-5 text-foreground-subtle`,"aria-hidden":`true`})]}):v(`div`,{"data-testid":`fan-onoff-icon`,className:`flex h-[150px] w-[150px] items-center justify-center`,children:v(Ht,{className:`h-16 w-16`,style:{color:h},"aria-hidden":`true`})})}),b&&v(`div`,{className:`flex justify-center`,children:c(`label`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[v(`span`,{children:i(`uiLibrary.fanHeroCard.preset`,`Preset`)}),c(`select`,{"aria-label":i(`uiLibrary.fanHeroCard.fanPreset`,`Fan preset`),value:x,disabled:p,onChange:e=>{e.stopPropagation(),E(e.target.value)},className:$(`bg-surface border border-border rounded px-1 py-0.5`,p&&`opacity-40 cursor-not-allowed`),children:[v(`option`,{value:``,disabled:!0,children:`—`}),y.map(e=>v(`option`,{value:e,children:e},e))]})]})}),c(`div`,{className:`flex items-center justify-between gap-2`,children:[_?c(`button`,{type:`button`,"aria-label":i(`uiLibrary.fanHeroCard.oscillate`,`Oscillate`),"aria-pressed":S,disabled:p,onClick:e=>{e.stopPropagation(),w()},className:$(`inline-flex items-center gap-1.5 rounded-md border px-3 py-1.5 text-xs font-medium transition-colors`,S?`border-success/50 bg-success/10 text-success`:`border-border text-foreground-muted hover:bg-surface-hover`,p&&`opacity-40 cursor-not-allowed`),children:[v(_e,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),i(`uiLibrary.fanHeroCard.oscillate`,`Oscillate`)]}):v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:u?i(`uiLibrary.fanHeroCard.on`,`On`):i(`uiLibrary.fanHeroCard.off`,`Off`)}),v(OX,{on:u,busy:d,onToggle:C})]})]})}function e0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),{display:s,applyOptimistic:l}=FX(a,{enabled:n??!0});if(i===void 0||s===void 0)return null;let u=s.on===!0,d=!o;return c(`div`,{className:`flex flex-col items-center gap-4 rounded-lg border border-border bg-surface p-6`,children:[v(`div`,{"data-testid":`switch-glyph`,"data-state":u?`on`:`off`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2 transition-colors`,u?`border-success/30 bg-success/10 text-success`:`border-border bg-surface-subtle text-foreground-subtle`),children:v(nt,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium text-foreground-muted`,children:u?r(`uiLibrary.switchHeroCard.on`,`On`):r(`uiLibrary.switchHeroCard.off`,`Off`)}),v(OX,{on:u,busy:d,onToggle:()=>{if(d)return;let e=!u;l({on:e}),i.setState({on:e})}})]})}function t0(e){return e===`playing`||e===`buffering`?`pause`:`play`}function n0(e,t){return e===null||t===null||t<=0?0:Math.min(1,Math.max(0,e/t))}function r0(e){if(e===null)return`--:--`;let t=Math.floor(e/1e3);return`${Math.floor(t/60)}:${(t%60).toString().padStart(2,`0`)}`}function i0({title:e,subtitle:t}){let n=q();return c(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[v(Yr,{className:`h-6 w-6 text-foreground-subtle`,"aria-hidden":`true`}),v(`span`,{className:`text-base font-semibold text-foreground line-clamp-1`,children:e??n(`uiLibrary.mediaPlayerHero.nothing`,`Nothing playing`)}),t&&v(`span`,{className:`text-xs text-foreground-subtle line-clamp-1`,children:t})]})}function a0({label:e,busy:t,onPress:n,children:r,primary:i}){return v(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:e=>{e.stopPropagation(),t||n()},className:$(`inline-flex items-center justify-center rounded-full transition-colors`,i?`h-12 w-12 bg-primary text-primary-foreground hover:bg-primary/90 shadow-md`:`h-10 w-10 text-foreground-muted hover:bg-surface-hover`,t&&`opacity-40 cursor-not-allowed`),children:r})}function o0({trpc:e,deviceId:t,features:n,optimistic:r}){let i=q(),{cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.mediaPlayer,slice:e=>e.state.mediaPlayer}),{display:l,applyOptimistic:u}=FX(o,{enabled:r??!0});if(a===void 0||l===void 0)return null;let d=!s,f=t0(l.state),p=(n?.includes(Oa.MediaPlayerSeek)??!1)&&l.duration!==null&&l.duration>0,m=n?.includes(Oa.MediaPlayerNext)??!1,h=n?.includes(Oa.MediaPlayerPrevious)??!1,g=(n?.includes(Oa.MediaPlayerVolume)??!1)&&l.volumeLevel!==null,_=()=>{d||(f===`play`?(u({state:`playing`}),a.play({})):(u({state:`paused`}),a.pause({})))},y=l.currentMedia?.artist??l.currentMedia?.album??null,b=n0(l.position,l.duration),x=l.volumeLevel??0;return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[v(i0,{title:l.currentMedia?.title??null,subtitle:y}),p&&c(`div`,{"data-testid":`media-seek`,className:`flex flex-col gap-1`,children:[c(`label`,{className:`relative block`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.mediaPlayerHero.seek`,`Seek`)}),v(`input`,{"aria-label":i(`uiLibrary.mediaPlayerHero.seek`,`Seek`),type:`range`,min:0,max:l.duration??0,step:1e3,className:`absolute inset-0 h-4 w-full cursor-pointer opacity-0`,value:l.position??0,disabled:d,onChange:e=>{if(d)return;let t=Number(e.target.value);u({position:t}),a.seek({position:t})}}),v(`div`,{className:`pointer-events-none`,children:v(xX,{fraction:b})})]}),c(`div`,{className:`flex justify-between text-[11px] tabular-nums text-foreground-subtle`,children:[v(`span`,{children:r0(l.position)}),v(`span`,{children:r0(l.duration)})]})]}),c(`div`,{className:`flex items-center justify-center gap-4`,children:[h&&v(a0,{label:i(`uiLibrary.mediaPlayerHero.previous`,`Previous`),busy:d,onPress:()=>void a.previous({}),children:v(nee,{className:`h-5 w-5`,"aria-hidden":`true`})}),v(a0,{label:f===`play`?i(`uiLibrary.mediaPlayerHero.play`,`Play`):i(`uiLibrary.mediaPlayerHero.pause`,`Pause`),busy:d,onPress:_,primary:!0,children:v(f===`play`?Le:Vt,{className:`h-6 w-6`,"aria-hidden":`true`})}),m&&v(a0,{label:i(`uiLibrary.mediaPlayerHero.next`,`Next`),busy:d,onPress:()=>void a.next({}),children:v(si,{className:`h-5 w-5`,"aria-hidden":`true`})})]}),g&&c(`div`,{"data-testid":`media-volume`,className:`flex items-center gap-2`,children:[v(`button`,{type:`button`,"aria-label":l.isMuted===!0?i(`uiLibrary.mediaPlayerHero.unmute`,`Unmute`):i(`uiLibrary.mediaPlayerHero.mute`,`Mute`),title:l.isMuted===!0?i(`uiLibrary.mediaPlayerHero.unmute`,`Unmute`):i(`uiLibrary.mediaPlayerHero.mute`,`Mute`),disabled:d,onClick:e=>{if(e.stopPropagation(),d||l.isMuted===null)return;let t=!l.isMuted;u({isMuted:t}),a.setMute({muted:t})},className:$(`inline-flex h-7 w-7 items-center justify-center rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,d&&`opacity-40 cursor-not-allowed`),children:l.isMuted===!0?v(me,{className:`h-4 w-4`,"aria-hidden":`true`}):v(mt,{className:`h-4 w-4`,"aria-hidden":`true`})}),c(`label`,{className:`relative block flex-1`,children:[v(`span`,{className:`sr-only`,children:i(`uiLibrary.mediaPlayerHero.volume`,`Volume`)}),v(`input`,{"aria-label":i(`uiLibrary.mediaPlayerHero.volume`,`Volume`),type:`range`,min:0,max:100,step:1,className:`absolute inset-0 h-4 w-full cursor-pointer opacity-0`,value:x,disabled:d,onChange:e=>{if(d)return;let t=Number(e.target.value);u({volumeLevel:t}),a.setVolume({volumeLevel:t})}}),v(`div`,{className:`pointer-events-none`,children:v(xX,{fraction:x/100})})]}),c(`span`,{className:`w-9 text-right text-[11px] tabular-nums text-foreground-subtle`,children:[x,`%`]})]})]})}E();var s0={disarmed:{colorClass:`border-border bg-surface-subtle text-foreground-subtle`,icon:`disarmed`},armed_home:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_away:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_night:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_vacation:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},armed_custom_bypass:{colorClass:`border-success/30 bg-success/10 text-success`,icon:`armed`},arming:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},disarming:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},pending:{colorClass:`border-warning/30 bg-warning/10 text-warning`,icon:`pending`},triggered:{colorClass:`border-danger/30 bg-danger/10 text-danger`,icon:`triggered`}};function c0(e,t){switch(e){case`home`:return t(`uiLibrary.alarmHeroCard.modeHome`,`Home`);case`away`:return t(`uiLibrary.alarmHeroCard.modeAway`,`Away`);case`night`:return t(`uiLibrary.alarmHeroCard.modeNight`,`Night`);case`vacation`:return t(`uiLibrary.alarmHeroCard.modeVacation`,`Vacation`);case`custom_bypass`:return t(`uiLibrary.alarmHeroCard.modeBypass`,`Bypass`)}}function l0(e,t){switch(e){case`disarmed`:return t(`uiLibrary.alarmHeroCard.stateDisarmed`,`Disarmed`);case`armed_home`:return t(`uiLibrary.alarmHeroCard.stateArmedHome`,`Armed Home`);case`armed_away`:return t(`uiLibrary.alarmHeroCard.stateArmedAway`,`Armed Away`);case`armed_night`:return t(`uiLibrary.alarmHeroCard.stateArmedNight`,`Armed Night`);case`armed_vacation`:return t(`uiLibrary.alarmHeroCard.stateArmedVacation`,`Armed Vacation`);case`armed_custom_bypass`:return t(`uiLibrary.alarmHeroCard.stateArmedBypass`,`Armed (Bypass)`);case`arming`:return t(`uiLibrary.alarmHeroCard.stateArming`,`Arming…`);case`disarming`:return t(`uiLibrary.alarmHeroCard.stateDisarming`,`Disarming…`);case`pending`:return t(`uiLibrary.alarmHeroCard.statePending`,`Pending`);case`triggered`:return t(`uiLibrary.alarmHeroCard.stateTriggered`,`Triggered`)}}function u0(e){return e.startsWith(`armed_`)}function d0(e){return e===`arming`||e===`disarming`}function f0({icon:e,sizeClass:t=`h-8 w-8`}){return v(e===`disarmed`?Wn:e===`triggered`?Dr:e===`pending`?Ln:Wr,{className:t,"aria-hidden":`true`})}function p0({label:e,active:t,busy:n,onSelect:r}){return v(`button`,{type:`button`,"aria-label":e,"aria-pressed":t,disabled:n,onClick:e=>{e.stopPropagation(),n||r()},className:$(`flex-1 rounded-md px-3 py-2 text-sm font-medium transition-colors`,t?`bg-primary text-primary-foreground shadow-sm`:`text-foreground-muted hover:bg-surface-hover`,n&&`opacity-40 cursor-not-allowed`),children:e})}function m0({state:e,availableModes:t,busy:n,onDisarm:r,onArm:i}){let a=q(),o=u0(e),s=d0(e);return c(`div`,{className:$(`flex min-w-0 items-stretch gap-1 rounded-lg border border-border bg-surface-subtle p-1`),children:[v(p0,{label:a(`uiLibrary.alarmHeroCard.disarm`,`Disarm`),active:!o&&!s,busy:n,onSelect:r}),t.map(t=>v(p0,{label:c0(t,a),active:!s&&e===`armed_${t}`,busy:n,onSelect:()=>i(t)},t))]})}function h0(e){return e instanceof Error?e.message:String(e)}function g0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.alarmPanel,slice:e=>e.state.alarmPanel}),{display:o,applyOptimistic:s,rollback:c}=FX(i,{enabled:n??!0}),[l,u]=C(null),d=()=>u(null),p=f(0);b(()=>{u(null)},[i]);let m=!a;return{display:o,capPresent:r!==void 0,busy:m,handleDisarm:()=>{if(r===void 0||m)return;let e=++p.current;s({state:`disarming`}),r.disarm({}).catch(t=>{p.current===e&&(c(),u(h0(t)))})},handleArm:e=>{if(r===void 0||m)return;let t=++p.current;s({state:`arming`}),r.arm({mode:e}).catch(e=>{p.current===t&&(c(),u(h0(e)))})},error:l,clearError:d}}function _0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,handleDisarm:s,handleArm:l,error:u}=g0(e,t,n);if(!a||i===void 0)return null;let d=s0[i.state],f=u0(i.state)?i.state.replace(`armed_`,``):``;return c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[c(`span`,{className:$(`inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5 text-[11px] font-medium whitespace-nowrap`,d.colorClass,d0(i.state)&&`animate-pulse`),children:[v(f0,{icon:d.icon,sizeClass:`h-3 w-3`}),l0(i.state,r)]}),c(`select`,{"aria-label":r(`uiLibrary.alarmHeroCard.alarmMode`,`Alarm mode`),disabled:o,value:f,onClick:e=>e.stopPropagation(),onChange:e=>{e.stopPropagation();let t=e.target.value;t===``?s():l(t)},className:$(`min-w-0 shrink rounded-md border border-border bg-surface-subtle px-1.5 py-0.5 text-xs text-foreground-muted`,o&&`cursor-not-allowed opacity-40`),children:[v(`option`,{value:``,children:r(`uiLibrary.alarmHeroCard.disarm`,`Disarm`)}),i.availableModes.map(e=>v(`option`,{value:e,children:c0(e,r)},e))]}),u!==null&&v(`span`,{"data-testid":`alarm-inline-error`,role:`alert`,title:u,className:`inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full bg-danger/10 text-danger`,children:v(Dr,{className:`h-3 w-3`,"aria-hidden":`true`})})]})}function v0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,handleDisarm:s,handleArm:l,error:u,clearError:d}=g0(e,t,n);if(!a||i===void 0)return null;let f=s0[i.state];return c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`alarm-state`,"data-state":i.state,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,f.colorClass,d0(i.state)&&`animate-pulse`),children:v(f0,{icon:f.icon})}),v(`span`,{className:$(`text-sm font-medium`,f.colorClass,`border-0 bg-transparent`),children:l0(i.state,r)})]}),v(m0,{state:i.state,availableModes:i.availableModes,busy:o,onDisarm:s,onArm:l}),u!==null&&c(`div`,{"data-testid":`alarm-error`,role:`alert`,className:`flex items-start justify-between gap-2 rounded-md border border-danger/30 bg-danger/10 px-3 py-2 text-sm text-danger`,children:[v(`span`,{children:u}),v(`button`,{type:`button`,"aria-label":r(`uiLibrary.alarmHeroCard.dismiss`,`Dismiss`),onClick:e=>{e.stopPropagation(),d()},className:`shrink-0 font-medium text-danger/80 hover:text-danger`,children:`×`})]})]})}function y0(e,t,n=Fn){if(e<=0)return null;let r=Math.max(0,Math.round((t-e)/1e3));return r<60?n(`uiLibrary.scriptAutomationControls.justNow`,`just now`):r<3600?n(`uiLibrary.scriptAutomationControls.minAgo`,`{{count}} min ago`,{count:Math.floor(r/60)}):r<86400?n(`uiLibrary.scriptAutomationControls.hAgo`,`{{count}} h ago`,{count:Math.floor(r/3600)}):new Date(e).toLocaleDateString()}function b0({atMs:e,neverLabel:t}){let n=q(),r=y0(e,Date.now(),n);return v(`span`,{className:`text-xs text-foreground-subtle`,"data-testid":`last-run`,children:r===null?t:r})}function x0({error:e}){return e===null||e===``?null:c(`span`,{className:`inline-flex items-center gap-1 text-xs text-danger`,title:e,"data-testid":`last-error`,children:[v(zi,{className:`h-3 w-3 shrink-0`,"aria-hidden":`true`}),v(`span`,{className:`truncate`,children:e})]})}function S0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.scriptRunner,slice:e=>e.state.scriptRunner}),{display:o,applyOptimistic:s}=FX(i,{enabled:n??!0}),c=!a,l=o?.isRunning===!0;return{display:o,capPresent:r!==void 0,busy:c,running:l,run:()=>{r===void 0||c||l||(s({isRunning:!0}),r.run({}))},stop:()=>{r===void 0||c||!l||(s({isRunning:!1}),r.stop({}))}}}function C0({running:e,busy:t,large:n,onRun:r,onStop:i}){let a=q(),o=e?a(`uiLibrary.scriptAutomationControls.stop`,`Stop`):a(`uiLibrary.scriptAutomationControls.run`,`Run`);return c(`button`,{type:`button`,"aria-label":o,title:o,disabled:t,"data-testid":`script-run`,"data-running":e?`true`:`false`,onClick:t=>{t.stopPropagation(),e?i():r()},className:$(`inline-flex items-center gap-1 rounded transition-colors`,n?`h-10 px-4 text-sm`:`h-5 px-1.5 text-xs`,e?`bg-danger text-danger-foreground hover:bg-danger/90`:`bg-primary text-primary-foreground hover:bg-primary/90`,t&&`cursor-not-allowed opacity-40`),children:[v(e?Er:Le,{className:n?`h-4 w-4`:`h-3 w-3`,"aria-hidden":`true`}),v(`span`,{children:o})]})}function w0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,running:s,run:l,stop:u}=S0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v(C0,{running:s,busy:o,large:!1,onRun:l,onStop:u}),v(b0,{atMs:i.lastRunAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverRun`,`never run`)})]})}function T0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,running:s,run:l,stop:u}=S0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`script-state`,"data-running":s?`true`:`false`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,s?`border-primary text-primary animate-pulse`:`border-border text-foreground-subtle`),children:v(Le,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium`,children:s?r(`uiLibrary.scriptAutomationControls.running`,`Running`):r(`uiLibrary.scriptAutomationControls.idle`,`Idle`)}),v(b0,{atMs:i.lastRunAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverRun`,`never run`)}),v(x0,{error:i.lastError})]}),v(`div`,{className:`flex justify-center`,children:v(C0,{running:s,busy:o,large:!0,onRun:l,onStop:u})})]})}function E0(e,t,n){let{cap:r,slice:i,available:a}=Zj({trpc:e,deviceId:t,cap:e=>e.automationControl,slice:e=>e.state.automationControl}),{display:o,applyOptimistic:s}=FX(i,{enabled:n??!0}),c=!a;return{display:o,capPresent:r!==void 0,busy:c,setEnabled:e=>{r===void 0||c||(s({enabled:e}),e?r.enable({}):r.disable({}))},trigger:()=>{r===void 0||c||r.trigger({})}}}function D0({enabled:e,busy:t,onToggle:n}){let r=q();return v(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r(`uiLibrary.scriptAutomationControls.automationEnabled`,`Automation enabled`),disabled:t,"data-testid":`automation-enabled`,onClick:t=>{t.stopPropagation(),n(!e)},className:$(`inline-flex shrink-0 items-center gap-1 rounded-md border px-1.5 py-0.5`,`text-[11px] font-medium whitespace-nowrap transition-colors`,e?`border-success/40 bg-success/10 text-success`:`border-border bg-surface-subtle text-foreground-subtle`,t&&`cursor-not-allowed opacity-40`),children:e?r(`uiLibrary.scriptAutomationControls.enabled`,`Enabled`):r(`uiLibrary.scriptAutomationControls.disabled`,`Disabled`)})}function O0({busy:e,large:t,onTrigger:n}){let r=q();return c(`button`,{type:`button`,"aria-label":r(`uiLibrary.scriptAutomationControls.trigger`,`Trigger`),title:r(`uiLibrary.scriptAutomationControls.runNow`,`Run this automation now`),disabled:e,"data-testid":`automation-trigger`,onClick:e=>{e.stopPropagation(),n()},className:$(`inline-flex items-center gap-1 rounded transition-colors`,t?`h-10 px-4 text-sm`:`h-5 px-1.5 text-xs`,`bg-primary text-primary-foreground hover:bg-primary/90`,e&&`cursor-not-allowed opacity-40`),children:[v(nr,{className:t?`h-4 w-4`:`h-3 w-3`,"aria-hidden":`true`}),v(`span`,{children:r(`uiLibrary.scriptAutomationControls.trigger`,`Trigger`)})]})}function k0({trpc:e,deviceId:t,optimistic:n}){let{display:r,capPresent:i,busy:a,setEnabled:o,trigger:s}=E0(e,t,n);return!i||r===void 0?null:c(`div`,{className:`flex min-w-0 items-center gap-2`,children:[v(D0,{enabled:r.enabled,busy:a,onToggle:o}),v(O0,{busy:a,large:!1,onTrigger:s})]})}function A0({trpc:e,deviceId:t,optimistic:n}){let r=q(),{display:i,capPresent:a,busy:o,setEnabled:s,trigger:l}=E0(e,t,n);return!a||i===void 0?null:c(`div`,{className:`flex flex-col items-stretch gap-4 rounded-lg border border-border bg-surface p-6`,children:[c(`div`,{className:`flex flex-col items-center gap-2`,children:[v(`div`,{"data-testid":`automation-state`,"data-enabled":i.enabled?`true`:`false`,className:$(`flex h-16 w-16 items-center justify-center rounded-full border-2`,i.enabled?`border-success text-success`:`border-border text-foreground-subtle`),children:v(nr,{className:`h-8 w-8`,"aria-hidden":`true`})}),v(`span`,{className:`text-sm font-medium`,children:i.enabled?r(`uiLibrary.scriptAutomationControls.enabled`,`Enabled`):r(`uiLibrary.scriptAutomationControls.disabled`,`Disabled`)}),v(b0,{atMs:i.lastTriggeredAt,neverLabel:r(`uiLibrary.scriptAutomationControls.neverTriggered`,`never triggered`)}),v(x0,{error:i.lastError})]}),c(`div`,{className:`flex items-center justify-center gap-3`,children:[v(D0,{enabled:i.enabled,busy:o,onToggle:s}),v(O0,{busy:o,large:!0,onTrigger:l})]})]})}function j0({children:e}){return v(`div`,{className:`flex flex-col items-stretch gap-3 rounded-lg border border-border bg-surface p-4`,children:e})}function M0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch});return n!==void 0}function N0({trpc:e,deviceId:t,features:n,optimistic:r}){return M0(e,t)?v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function P0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.lockControl,slice:e=>e.state.lockControl});return n!==void 0}function F0({trpc:e,deviceId:t,features:n,optimistic:r}){return P0(e,t)?v(LX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function I0({trpc:e,deviceId:t,features:n,optimistic:r}){return M0(e,t)?c(`div`,{className:`inline-flex items-center gap-2`,children:[v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}),v(zX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r})]}):null}function L0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.fanControl,slice:e=>e.state.fanControl});return n!==void 0}function R0({trpc:e,deviceId:t,features:n,optimistic:r}){return L0(e,t)?c(`div`,{className:`inline-flex items-center gap-2`,children:[v(RX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}),v(BX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r})]}):null}function z0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.climateControl,slice:e=>e.state.climateControl});return n!==void 0}function B0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.heatingValve,slice:e=>e.state.heatingValve});return n!==void 0}function V0({trpc:e,deviceId:t,features:n,optimistic:r}){let i=z0(e,t),a=B0(e,t);return!i&&!a?null:c(`span`,{className:`inline-flex items-center gap-2`,children:[i?v(QX,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null,a?v(n1,{trpc:e,deviceId:t,layout:`compact`}):null]})}function H0({trpc:e,deviceId:t,features:n,optimistic:r}){return z0(e,t)?v(m1,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function U0({trpc:e,deviceId:t,features:n,optimistic:r}){return z0(e,t)?v(m1,{trpc:e,deviceId:t,features:n,layout:`full`,optimistic:r}):null}function W0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.mediaPlayer,slice:e=>e.state.mediaPlayer});return n!==void 0}function G0({trpc:e,deviceId:t,features:n,optimistic:r}){return W0(e,t)?v(aZ,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function K0(e,t){let{cap:n}=Zj({trpc:e,deviceId:t,cap:e=>e.control,slice:e=>e.state.control});return n!==void 0}function q0({trpc:e,deviceId:t,features:n,optimistic:r}){return K0(e,t)?v(CZ,{trpc:e,deviceId:t,features:n,layout:`compact`,optimistic:r}):null}function J0({trpc:e,deviceId:t,features:n,optimistic:r}){return K0(e,t)?v(j0,{children:v(CZ,{trpc:e,deviceId:t,features:n,layout:`full`,optimistic:r})}):null}var Y0={cover:{InlineControl:HZ,HeroCard:KZ},valve:{InlineControl:WQ,HeroCard:YQ},humidifier:{InlineControl:QQ,HeroCard:e$},"water-heater":{InlineControl:i$,HeroCard:o$},switch:{InlineControl:N0,HeroCard:e0},light:{InlineControl:I0,HeroCard:X1},fan:{InlineControl:R0,HeroCard:$1},sensor:{InlineControl:XZ,HeroCard:fQ},thermostat:{InlineControl:V0,HeroCard:F1},climate:{InlineControl:H0,HeroCard:U0},button:{InlineControl:kX,HeroCard:AX},update:{InlineControl:hQ,HeroCard:gQ},lock:{InlineControl:F0,HeroCard:H1},"media-player":{InlineControl:G0,HeroCard:o0},alarm:{InlineControl:_0,HeroCard:v0},control:{InlineControl:q0,HeroCard:J0},weather:{InlineControl:f$,HeroCard:_$},vacuum:{InlineControl:wQ,HeroCard:EQ},"lawn-mower":{InlineControl:LQ,HeroCard:zQ},image:{InlineControl:w$,HeroCard:T$},"pet-feeder":{InlineControl:B$,HeroCard:V$},dishwasher:{InlineControl:$$,HeroCard:e1},script:{InlineControl:w0,HeroCard:T0},automation:{InlineControl:k0,HeroCard:A0},dummy:{InlineControl:qZ,HeroCard:JZ}},X0=Object.fromEntries(Object.values(J).map(e=>[e,Y0[ea[e]]])),Z0={[J.Cover]:!0,[J.Valve]:!0,[J.Thermostat]:!0,[J.Climate]:!0,[J.Control]:!0,[J.Button]:!0,[J.MediaPlayer]:!0,[J.AlarmPanel]:!0,[J.Lock]:!1,[J.Vacuum]:!1,[J.LawnMower]:!1,[J.Humidifier]:!1,[J.Switch]:!1,[J.Siren]:!1,[J.Light]:!1,[J.Fan]:!1,[J.WaterHeater]:!1,[J.Sensor]:!1,[J.Presence]:!1,[J.EventEmitter]:!1,[J.Notifier]:!1,[J.Script]:!1,[J.Automation]:!1,[J.Camera]:!1,[J.Hub]:!1,[J.Update]:!1,[J.Generic]:!1,[J.Weather]:!1,[J.Container]:!1,[J.Image]:!1,[J.PetFeeder]:!1,[J.Dishwasher]:!1,[J.Washer]:!1,[J.Dryer]:!1},Q0=new Set(Object.values(J));function $0(e){let t=$a(e);return t?Y0[t]:null}function e2(e,t){return t===`table`?`fit`:Q0.has(e)&&Z0[e]?lX:t===`center`?dX:uX}var t2=1e3,n2=60*t2,r2=60*n2,i2=24*r2,a2=30*t2,o2=Date.UTC(2e3,0,1);function s2(e,t=Fn){if(e==null||e<o2)return null;let n=Date.now()-e;return n<a2?t(`uiLibrary.lastSeen.justNow`,`just now`):n<r2?t(`uiLibrary.lastSeen.minutes`,`{{count}}m ago`,{count:Math.floor(n/n2)}):n<i2?t(`uiLibrary.lastSeen.hours`,`{{count}}h ago`,{count:Math.floor(n/r2)}):t(`uiLibrary.lastSeen.days`,`{{count}}d ago`,{count:Math.floor(n/i2)})}function c2({lastChangedAt:e,className:t}){let n=q(),r=s2(e),i=n(`uiLibrary.offlineBadge.unavailable`,`Unavailable`),a=r===null?null:n(`uiLibrary.offlineBadge.lastSeen`,`last seen {{when}}`,{when:r});return c(`span`,{title:a===null?i:`${i} · ${a}`,className:$(`inline-flex items-center gap-1 rounded-full px-2 py-0.5`,`bg-surface-hover text-foreground-subtle text-[10px] font-medium`,`border border-border`,t),children:[v(Pt,{className:`h-3 w-3 flex-shrink-0`,"aria-hidden":`true`}),v(`span`,{children:i}),a===null?null:v(`span`,{className:`text-foreground-subtle/70`,children:`· ${a}`})]})}var l2=la;function u2(e,t,n){let r=io(e.map(e=>({id:e.id,stableId:e.entityId,type:e.type,...e.role===void 0?{}:{role:e.role},...e.name===void 0?{}:{name:e.name}})),t,n);return r===null?null:e.find(e=>e.id===r.id)??null}function d2(e){return e.sourceInfo?.id??e.stableId}function f2(e){return{id:e.id,entityId:d2(e),type:e.type,...e.role!==void 0&&e.role!==null?{role:e.role}:{},...e.name===void 0?{}:{name:e.name}}}function p2(e,t){if(t==null)return;let n=e.find(e=>e.id===t);return n===void 0?void 0:d2(n)}function m2(e,t,n){return u2(e.map(f2),n!=null&&n!==``?n:p2(e,t))}function h2({trpc:e,children:t,linkDeviceId:n,primaryChildEntityId:r}){let i=q(),a=m2(t,n,r),o=a===null?void 0:t.find(e=>e.id===a.id);return o===void 0?v(`div`,{className:`flex h-full w-full items-center justify-center p-4 text-[11px] italic text-foreground-subtle`,children:i(`uiLibrary.containerPrimaryHero.empty`,`No child entities to display.`)}):v(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:v($0(o.type)?.HeroCard??JZ,{trpc:e,deviceId:o.id,features:o.features})})}var g2=`rounded-md border border-border bg-surface px-1.5 py-0.5 text-[11px] text-foreground`;function _2({childrenList:e,selectedId:t,onSetPrimary:n,disabled:r,className:i}){return v(`select`,{value:t,disabled:r,onChange:r=>{let i=Number(r.target.value);if(!Number.isFinite(i)||i===t)return;let a=e.find(e=>e.id===i);a!==void 0&&n(a.stableId)},className:i===void 0?g2:`${g2} ${i}`,children:e.map(e=>c(`option`,{value:e.id,children:[e.name,` (`,e.type,`)`]},e.id))})}function v2({selectedIds:e,onClear:t,remove:n,disable:r,enable:i}){let a=q(),o=li();if(e.size===0)return null;let s=[...e],l=s.length,u=()=>{for(let e of s)r({deviceId:e});t()},d=()=>{for(let e of s)i({deviceId:e});t()},f=async()=>{if(await o({title:a(`uiLibrary.batchToolbar.deleteTitle`,`Delete {{count}} devices?`,{count:l}),message:a(`uiLibrary.batchToolbar.deleteMessage`,`{{count}} selected devices will be deleted. This cannot be undone.`,{count:l}),confirmLabel:a(`uiLibrary.batchToolbar.delete`,`Delete`),variant:`danger`})){for(let e of s)n({deviceId:e});t()}};return c(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-border bg-surface-hover`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle shrink-0`,children:a(`uiLibrary.batchToolbar.selectedCount`,`{{count}} selected`,{count:l})}),v(`div`,{className:`h-3.5 w-px bg-border shrink-0`,"aria-hidden":`true`}),c(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[v(`button`,{type:`button`,onClick:u,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.disable`,`Disable`)}),v(`button`,{type:`button`,onClick:d,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.enable`,`Enable`)}),v(`button`,{type:`button`,onClick:()=>void f(),className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-danger/40 bg-danger/10 text-danger hover:bg-danger/20`),children:a(`uiLibrary.batchToolbar.delete`,`Delete`)}),v(`button`,{type:`button`,onClick:t,className:$(`inline-flex items-center h-6 px-2.5 rounded-md border text-[10.5px] font-medium transition-colors`,`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface`),children:a(`uiLibrary.batchToolbar.clear`,`Clear`)})]})]})}E();function y2(e){let t=q(),[n,r]=C(!1),i=f(null),a=e.selectedIds.size;return b(()=>{if(!n)return;let e=e=>{let t=e.target instanceof Node?e.target:null;t&&i.current&&!i.current.contains(t)&&r(!1)},t=e=>{e.key===`Escape`&&r(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[n]),a===0?null:c(P,{children:[v(`div`,{className:`hidden sm:block`,children:v(v2,{...e})}),c(`div`,{ref:i,"data-testid":`batch-actions-compact`,className:`relative sm:hidden`,children:[c(`button`,{type:`button`,onClick:()=>r(e=>!e),"aria-haspopup":`menu`,"aria-expanded":n,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border border-primary/40 bg-primary/15 text-[10.5px] font-medium text-primary`,children:[v(`span`,{children:t(`uiLibrary.deviceBatchActionsBar.actions`,`Actions · {{count}}`,{count:a})}),v(de,{className:`h-3 w-3 transition-transform ${n?`rotate-180`:``}`})]}),n&&v(`div`,{role:`menu`,className:`absolute left-0 top-full mt-1 z-30 rounded-lg border border-border bg-surface shadow-md`,children:v(v2,{...e})})]})]})}E();function b2(e,t,n){if(e===null||typeof window>`u`)return n;try{let r=window.localStorage.getItem(e);if(r===null)return n;let i=Number.parseInt(r,10);return Number.isFinite(i)&&t.includes(i)?i:n}catch{return n}}function x2(e,t){if(!(e===null||typeof window>`u`))try{window.localStorage.setItem(e,String(t))}catch{}}function S2({storageKey:e,options:t,defaultSize:n}){let r=t.includes(n)?n:t[0]??n,[i,a]=C(()=>b2(e,t,r));return[i,_(n=>{t.includes(n)&&(a(n),x2(e,n))},[t,e])]}function C2(e,t){return e===0?Math.max(1,t):e}var w2=[25,50,100,200],T2=`camstack.device-list.pageSize`;function E2(e){return S2({storageKey:T2,options:w2,defaultSize:w2.includes(e)?e:50})}function D2(e){return e.parentDeviceId===null?`top-level`:e.role?`accessory`:`adopted`}var O2={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 k2(e){let t=O2[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}}function A2(e,t){if(e.display?.icon){let t=ds(e.display.icon);if(t)return t}if(e.role){let n=t?.[e.role]?.icon;if(n!==void 0){let e=ds(n);if(e)return e}return Xo(e.role).icon}return Yo(e.type).icon}var j2=[` — `,` `];function M2(e,t){if(t.length===0)return e;for(let n of j2){let r=`${t}${n}`;if(e.startsWith(r))return e.slice(r.length)}return e}function N2(e,t){return e.display?.label?e.display.label:M2(e.name,t)}var P2={"native-snapshot":Nt,"two-way-audio":Pr,"pan-tilt-zoom":fi,"ptz-autotrack":iee,"doorbell-button":pn,"motion-trigger":ai,"battery-operated":Ee,rebootable:Di},F2={"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`},I2={"native-snapshot":`snapshot`,rebootable:`reboot`,"pan-tilt-zoom":`ptz`,"ptz-autotrack":`ptz-autotrack`,"two-way-audio":`intercom`,"motion-trigger":`motion-trigger`},L2=new Set([`camera`,`hub`,`nvr`]);function R2(e){return!L2.has(e.type.toLowerCase())}function z2(e){return e.role?!0:!L2.has(e.type.toLowerCase())}function B2(e){return(e.features??[]).includes(`motion-trigger`)}function V2(e,t){if(e.type!==J.Container)return e.online;let n=t??[];if(n.length===0)return e.online;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);if(r===null)return e.online;let i=n.find(e=>e.id===r.id);return i===void 0?e.online:i.online}function H2(e,t){if(e.type!==J.Container)return e.type;let n=t??[];if(n.length===0)return e.type;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);if(r===null)return e.type;let i=n.find(e=>e.id===r.id);return i===void 0?e.type:i.type}function U2(e,t){if(e.type!==J.Container||e.display?.icon!==void 0&&Ka(e.display.icon)!==void 0)return e;let n=t??[];if(n.length===0)return e;let r=m2(n,e.linkDeviceId,e.primaryChildEntityId);return r===null?e:n.find(e=>e.id===r.id)??e}function W2(e){if(e.length<=24)return e;let t=e.lastIndexOf(`:`);if(t>=0&&t<e.length-4)return e.slice(t+1);let n=e.split(`-`);if(n.length>2){let e=n.slice(-2).join(`-`);if(e.length>=6)return e}return`…${e.slice(-18)}`}var G2=[`name`,`icon`,`type`,`manufacturer`,`features`,`previewActions`],K2={devices:[`name`,`icon`,`type`,`manufacturer`,`features`,`previewActions`],"integration-detail":[`name`,`manufacturer`,`features`,`previewActions`]};function q2(e){return K2[e]}var J2={name:0,previewActions:1,icon:2,features:3,type:4,manufacturer:5},Y2={name:``,previewActions:``,icon:``,features:`hidden md:table-cell`,type:`hidden lg:table-cell`,manufacturer:`hidden xl:table-cell`},X2=`md:sticky md:left-0 md:z-[1]`,Z2=`md:w-64 md:max-w-[16rem]`,Q2=`whitespace-nowrap md:truncate`,$2=`manufacturer`,e4=`model`;function t4(e){if(typeof e==`string`){let t=e.trim();return t===``?null:t}return typeof e==`number`&&Number.isFinite(e)||typeof e==`boolean`?String(e):null}function n4(e,t){return e==null?null:t4(e[t])}function r4(e){let t=n4(e.metadata,$2),n=n4(e.metadata,e4);return t!==null&&n!==null?`${t} · ${n}`:t??n??null}function i4(e){if(e==null)return[];let t=[];for(let n of Object.keys(e)){let r=t4(e[n]);r!==null&&t.push({key:n,value:r})}return t}function a4(e){return n4(e.metadata,$2)!==null}function o4(e){return(n4(e.metadata,$2)??``).toLowerCase()}function s4(e){return(n4(e.metadata,e4)??``).toLowerCase()}function c4(e,t){let n=o4(e).localeCompare(o4(t));return n===0?s4(e).localeCompare(s4(t)):n}function l4({device:e}){let t=r4(e),n=i4(e.metadata);if(t===null&&n.length===0)return v(`span`,{className:`text-xs text-foreground-subtle/60`,children:`—`});let r=t??`—`;return n.length===0?v(`span`,{className:`block truncate text-xs text-foreground-subtle`,children:r}):c(Ul,{className:`block w-full min-w-0`,children:[v(Wl,{className:`block w-full min-w-0`,children:v(`span`,{className:`block truncate text-xs text-foreground-subtle`,children:r})}),v(Gl,{className:`whitespace-normal text-left max-w-xs`,children:v(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-2 gap-y-0.5`,children:n.map(e=>c(`div`,{className:`contents`,children:[v(`dt`,{className:`font-medium opacity-70`,children:e.key}),v(`dd`,{className:`break-words`,children:e.value})]},e.key))})})]})}E();function u4(e,t){let{dev:n,cap:r,online:i}=Zj({trpc:e,deviceId:t,cap:e=>e.deviceAdminLink,slice:()=>void 0}),a=n!==null&&r!=null&&(n.binding?.entries.some(e=>e.capName===`device-admin-link`)??!0),[o,s]=C({kind:`pending`});return b(()=>{if(!a||r==null){s({kind:`none`});return}let e=!0;try{r.getAdminLink({}).then(t=>{e&&s(t==null?{kind:`none`}:{kind:`link`,link:t})}).catch(()=>{e&&s({kind:`failed`})})}catch{s({kind:`failed`})}return()=>{e=!1}},[a,r,t]),o.kind!==`link`||o.link.target===`device`&&!i?null:o.link}function d4({trpc:e,deviceId:t,className:n,iconClassName:r}){let i=q(),a=u4(e,t);return a===null?null:v(`a`,{href:a.url,target:`_blank`,rel:`noopener noreferrer`,onClick:e=>{e.stopPropagation()},className:$(`inline-flex items-center justify-center rounded text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,n),title:`${a.label} — ${a.host}`,"aria-label":i(`uiLibrary.adminLinkQuickAction.open`,`Open {{label}} for this device`,{label:a.label}),children:v(Je,{className:$(`h-3 w-3`,r)})})}E();function f4(e){return e instanceof Error?e.message:String(e)}function p4({trpc:e,deviceId:t,deviceName:n}){let r=q(),{dev:i,cap:a}=Zj({trpc:e,deviceId:t,cap:e=>e.reboot,slice:()=>void 0}),[o,s]=C(!1),[l,u]=C(!1),[d,f]=C(null);if(i===null||a==null)return null;let p=e=>{e.stopPropagation(),f(null),s(!0)},m=async()=>{if(!l){f(null),u(!0);try{await a.reboot({}),s(!1)}catch(e){f(f4(e))}finally{u(!1)}}};return c(P,{children:[v(`button`,{type:`button`,onClick:p,className:$(`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`,o&&`bg-surface-hover text-foreground`),title:r(`uiLibrary.rebootQuickAction.rebootDevice`,`Reboot device`),"aria-label":r(`uiLibrary.rebootQuickAction.rebootDevice`,`Reboot device`),"aria-haspopup":`dialog`,"aria-expanded":o,children:v(Di,{className:`h-3 w-3`})}),v(SL,{open:o,onOpenChange:e=>{l||s(e)},children:c(TL,{width:`sm`,onClick:e=>e.stopPropagation(),children:[c(EL,{children:[c(kL,{className:`flex items-center gap-2`,children:[v(Di,{className:`h-4 w-4 text-amber-400`}),r(`uiLibrary.rebootQuickAction.rebootDeviceQuestion`,`Reboot device?`)]}),v(AL,{children:r(`uiLibrary.rebootQuickAction.description`,`This will restart {{deviceName}}. It may be unavailable for a moment.`,{deviceName:n})})]}),d!==null&&v(`div`,{className:`mt-2 px-3 py-2 rounded border border-danger/40 bg-danger/10 text-xs text-danger`,children:d}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:l,onClick:()=>{l||s(!1)},children:r(`uiLibrary.rebootQuickAction.cancel`,`Cancel`)}),c(_A,{type:`button`,variant:`danger`,size:`sm`,disabled:l,onClick:()=>{m()},children:[l&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),r(`uiLibrary.rebootQuickAction.reboot`,`Reboot`)]})]})]})})]})}E();var m4=[],h4=O(null);function g4({value:e,children:t}){return v(h4.Provider,{value:e,children:t})}function _4(e){return I(h4)?.get(e)??m4}E(),Do();var v4=new Set([J.Sensor,J.Presence]);function y4({trpc:e,device:t,controlPlacement:n}){let r=_4(t.id),i=vj(t,`compact`),a=n??`right`;if(t.disabled)return null;if(t.type===J.Container){let n=m2(r,t.linkDeviceId,t.primaryChildEntityId),i=n===null?void 0:r.find(e=>e.id===n.id);return i===void 0?null:v(b4,{trpc:e,child:i,placement:a})}let o=v4.has(t.type),s=(o?null:$0(t.type))?.InlineControl??null,l=e2(t.type,a),u=B2(t),d=(t.features??[]).includes(`rebootable`),f=(t.features??[]).includes(`pan-tilt-zoom`);return c(P,{children:[o&&c(fX,{align:e2(t.type,a),children:[u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),v(RZ,{trpc:e,device:t})]}),s!==null&&c(fX,{align:l,onClick:e=>e.stopPropagation(),children:[u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),v(s,{trpc:e,deviceId:t.id,features:t.features})]}),!o&&s===null&&u&&v(x4,{trpc:e,deviceId:t.id,features:t.features}),f&&v(w4,{trpc:e,deviceId:t.id}),d&&v(p4,{trpc:e,deviceId:t.id,deviceName:i}),v(d4,{trpc:e,deviceId:t.id})]})}function b4({trpc:e,child:t,placement:n}){if(v4.has(t.type))return v(fX,{align:e2(t.type,n),children:v(RZ,{trpc:e,device:t})});let r=$0(t.type)?.InlineControl??null;return r===null?null:v(fX,{align:e2(t.type,n),onClick:e=>e.stopPropagation(),children:v(r,{trpc:e,deviceId:t.id,features:t.features})})}function x4({trpc:e,deviceId:t,features:n}){let r=q(),{dev:i,cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.motionTrigger,slice:e=>e.state.motionTrigger,requireFeature:`motion-trigger`,deviceFeatures:n}),[c,l]=C(!1);if(i!==null&&!a)return null;let u=o?.enabled===!0,d=async e=>{if(e.stopPropagation(),!(c||!s||!a)){l(!0);try{await a.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:c||!s,className:$(`inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0`,u?`text-primary bg-primary/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,(c||!s)&&`opacity-50`),title:s?u?r(`uiLibrary.deviceItemActions.motionOn`,`Motion-trigger: on (click to disable)`):r(`uiLibrary.deviceItemActions.motionOff`,`Motion-trigger: off (click to enable)`):r(`uiLibrary.deviceItemActions.awaiting`,`Awaiting state…`),"aria-pressed":u,children:v(ai,{className:`h-2.5 w-2.5`})})}var S4=4,C4=300;function w4({trpc:e,deviceId:t}){let n=q(),r=f(null),i=f(null),[a,o]=C(null),s=a!==null,l=MI(e,t,{enabled:s}),u=()=>o(null),d=()=>{let e=r.current;if(!e)return;let t=e.getBoundingClientRect(),n=Math.min(C4,window.innerWidth-16),i=Math.max(8,Math.min(t.right-n,window.innerWidth-n-8)),a=t.bottom+S4;o({top:a,left:i,width:n,maxHeight:Math.max(160,window.innerHeight-a-8)})};return b(()=>{if(!s)return;let e=e=>{let t=r.current,n=i.current,a=e.target;a!==null&&(t&&t.contains(a)||n&&n.contains(a)||u())},t=e=>{e.key===`Escape`&&(e.stopPropagation(),u())};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[s]),c(P,{children:[v(`button`,{ref:r,type:`button`,onClick:e=>{e.stopPropagation(),s?u():d()},className:$(`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`,s&&`bg-surface-hover text-foreground`),title:n(`uiLibrary.deviceItemActions.ptz`,`PTZ controls`),"aria-label":n(`uiLibrary.deviceItemActions.ptz`,`PTZ controls`),"aria-haspopup":`dialog`,"aria-expanded":s,children:v(Ce,{className:`h-3 w-3`})}),a&&Oo(v(`div`,{ref:i,style:{position:`fixed`,top:a.top,left:a.left,width:a.width,maxHeight:a.maxHeight},className:`z-[9999] overflow-y-auto rounded-lg border border-border bg-surface shadow-lg shadow-black/30`,onClick:e=>e.stopPropagation(),children:v(II,{mode:`panel`,controls:l})}),document.body)]})}E();var T4={},E4=O(T4);function D4({value:e,children:t}){return v(E4.Provider,{value:e,children:t})}function O4(){return I(E4)}function k4({children:e}){let{data:t}=Gp({},{staleTime:6e4});return v(D4,{value:t?.defaults??T4,children:e})}E();function A4({trpc:e,accessoryChildren:t,adoptedChildren:n,onNavigate:r,parentName:i}){let a=q();return c(`div`,{className:`border-t border-border-subtle/50`,children:[n.length>0&&v(j4,{trpc:e,label:a(`uiLibrary.childrenAccordion.adoptedDevices`,`Adopted devices`),rows:n,onNavigate:r,parentName:i}),t.length>0&&v(j4,{trpc:e,label:a(`uiLibrary.childrenAccordion.accessories`,`Accessories`),rows:t,onNavigate:r,parentName:i})]})}function j4({trpc:e,label:t,rows:n,onNavigate:r,parentName:i}){return c(`div`,{children:[v(`div`,{className:`px-3 pt-1.5 pb-1 text-[9px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:t}),v(`ul`,{children:n.map(t=>v(M4,{trpc:e,child:t,onNavigate:r,parentName:i},t.id))})]})}function M4({trpc:e,child:t,onNavigate:n,parentName:r}){let i=q(),a=!t.disabled,o=a&&R2(t),s=a&&B2(t),l=O4();ms();let u=A2(t,l),d=qr(e,t.id,e=>e.runningState);return v(`li`,{children:c(`div`,{onClick:e=>{e.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:[v(bV,{running:d===void 0||d.running===null?null:d.running,children:v(u,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`})}),v(bj,{device:t,form:`nested`,parent:{id:t.parentDeviceId??0,name:r,type:`unknown`,stableId:``},className:`text-[10.5px] text-foreground flex-1 truncate`}),s&&v(P4,{trpc:e,deviceId:t.id,features:t.features}),o&&v(N4,{trpc:e,deviceId:t.id}),v(`span`,{className:$(`h-1.5 w-1.5 rounded-full flex-shrink-0`,t.online?`bg-success`:`bg-foreground-subtle/40`),title:t.online?i(`uiLibrary.childrenAccordion.online`,`Online`):i(`uiLibrary.childrenAccordion.offline`,`Offline`)})]})})}function N4({trpc:e,deviceId:t}){let n=q(),{dev:r,cap:i,slice:a,available:o}=Zj({trpc:e,deviceId:t,cap:e=>e.switch,slice:e=>e.state.switch}),[s,c]=C(!1);if(r!==null&&!i)return null;let l=a?.on===!0,u={transform:l?`translateX(14px)`:`translateX(2px)`},d=async e=>{if(e.stopPropagation(),!(s||!o||!i)){c(!0);try{await i.setState({on:!l})}finally{c(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:s||!o,className:$(`relative inline-flex h-4 w-7 items-center rounded-full border transition-colors flex-shrink-0`,l?`bg-success/30 border-success/50`:`bg-surface-hover border-border`,s&&`opacity-60`,!o&&`opacity-40 cursor-not-allowed`),title:o?l?n(`uiLibrary.childrenAccordion.turnOff`,`Turn off`):n(`uiLibrary.childrenAccordion.turnOn`,`Turn on`):n(`uiLibrary.childrenAccordion.awaitingState`,`Awaiting state…`),"aria-pressed":l,children:v(`span`,{className:$(`absolute h-3 w-3 rounded-full transition-all`,l?`bg-success`:`bg-foreground-subtle`),style:u})})}function P4({trpc:e,deviceId:t,features:n}){let r=q(),{dev:i,cap:a,slice:o,available:s}=Zj({trpc:e,deviceId:t,cap:e=>e.motionTrigger,slice:e=>e.state.motionTrigger,requireFeature:`motion-trigger`,deviceFeatures:n}),[c,l]=C(!1);if(i!==null&&!a)return null;let u=o?.enabled===!0,d=async e=>{if(e.stopPropagation(),!(c||!s||!a)){l(!0);try{await a.setMotionTrigger({enabled:!u})}finally{l(!1)}}};return v(`button`,{type:`button`,onClick:e=>{d(e)},disabled:c||!s,className:$(`inline-flex h-4 w-4 items-center justify-center rounded transition-colors flex-shrink-0`,u?`text-primary bg-primary/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,(c||!s)&&`opacity-50`),title:s?u?r(`uiLibrary.childrenAccordion.motionTriggerOn`,`Motion-trigger: on (click to disable)`):r(`uiLibrary.childrenAccordion.motionTriggerOff`,`Motion-trigger: off (click to enable)`):r(`uiLibrary.childrenAccordion.awaitingState`,`Awaiting state…`),"aria-pressed":u,children:v(ai,{className:`h-2.5 w-2.5`})})}function F4({icon:e,label:t,onClick:n,danger:r=!1}){return v(`button`,{type:`button`,"aria-label":t,title:t,onClick:n,className:$(`inline-flex h-6 w-6 items-center justify-center rounded transition-colors flex-shrink-0`,r?`text-danger hover:bg-danger/10`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),children:v(e,{className:`h-3.5 w-3.5`})})}function I4({device:e,onDelete:t}){let n=q(),r=li(),i=vj(e,`full`),a=async()=>{let a=i.trim()===``?`#${String(e.id)}`:i;await r({title:n(`uiLibrary.deviceDeleteAction.title`,`Delete device?`),message:n(`uiLibrary.deviceDeleteAction.message`,`This will remove "{{label}}" and all its settings. This action cannot be undone.`,{label:a}),confirmLabel:n(`uiLibrary.deviceDeleteAction.confirm`,`Delete`),variant:`danger`})&&t(e)};return v(`span`,{onClick:e=>e.stopPropagation(),children:v(F4,{icon:Pe,label:n(`uiLibrary.deviceDeleteAction.deleteDevice`,`Delete device`),danger:!0,onClick:()=>{a()}})})}E();var L4=Object.freeze([]);function R4(e){return e===`native`?`native`:`enhanced`}function z4(e){return e.map(e=>({kind:`marker`,feature:e}))}function B4(e,t){let n=new Map,r=t.entries??[];for(let e of r)n.set(e.capName,e);let i=[];for(let t of e){let e=I2[t];if(e===void 0){i.push({kind:`marker`,feature:t});continue}let r=n.get(e);r&&i.push({kind:R4(r.kind),feature:t,capName:e})}return i}function V4(e,t,n){let[r,i]=C(null),[a,o]=C(!1),[s,c]=C(!0);return b(()=>{if(t===null){i(null),o(!1),c(!1);return}let n=!1;c(!0),o(!1);let r=async()=>{try{let r=await e.deviceManager.getBindings.query({deviceId:t});if(n)return;i(r),c(!1)}catch{if(n)return;o(!0),c(!1)}};r();let a=e.live?.onEvent.subscribe({category:`capability.binding-changed`},{onData:e=>{let n=e.data?.source;if(!n){r();return}n.type===`device`&&n.id===t&&r()}});return()=>{n=!0,a?.unsubscribe()}},[e,t]),n.length===0?{loading:s,resolved:L4}:s||a||!r?{loading:s,resolved:z4(n)}:{loading:!1,resolved:B4(n,r)}}E(),Do();var H4=[];function U4({trpc:e,device:t,flags:n,accessoryCount:r,adoptedCount:i,showFeatureRow:a=!1}){let o=r+i,s=n.showChildrenAccordion&&o>0,l=t.features??H4,u=a&&l.length>0,{resolved:d}=V4(e,u?t.id:null,l),f=u&&d.length>0;return!s&&!f?null:c(`div`,{className:`flex items-center gap-1.5 flex-nowrap whitespace-nowrap min-w-0`,children:[s&&v(W4,{accessoryCount:r,adoptedCount:i}),f&&v(q4,{resolved:d})]})}function W4({accessoryCount:e,adoptedCount:t}){let n=q(),r=e+t;return r===0?null:c(`span`,{className:`text-[9px] font-medium text-foreground-subtle bg-surface-elevated/60 rounded px-1.5 py-0.5 flex-shrink-0`,title:t>0&&e>0?n(`uiLibrary.deviceItemFeatures.adoptedAndAccessories`,{one:`{{adopted}} adopted · {{count}} accessory`,other:`{{adopted}} adopted · {{count}} accessories`},{adopted:t,count:e}):t>0?n(`uiLibrary.deviceItemFeatures.adopted`,`{{count}} adopted`,{count:t}):n(`uiLibrary.deviceItemFeatures.accessories`,{one:`{{count}} accessory`,other:`{{count}} accessories`},{count:e}),children:[`+`,r]})}var G4=240,K4=200;function q4({resolved:e}){let t=f(null),[n,r]=C(null);return c(`span`,{ref:t,className:`relative inline-flex items-center gap-1 cursor-help`,onMouseEnter:()=>{let e=t.current;if(!e)return;let n=e.getBoundingClientRect();r({top:window.innerHeight-n.bottom>=K4?n.bottom+4:n.top-K4-4,left:Math.max(8,Math.min(n.left,window.innerWidth-G4-8))})},onMouseLeave:()=>r(null),children:[e.map(e=>{let t=P2[e.feature];return t?v(`span`,{className:`inline-flex items-center justify-center h-4 w-4 rounded bg-surface-elevated/60 text-foreground-subtle`,title:F2[e.feature]??e.feature,children:v(t,{className:`h-2.5 w-2.5`})},e.feature):null}),n&&Oo(v(J4,{resolved:e,position:n}),document.body)]})}function J4({resolved:e,position:t}){let n=q();return c(`div`,{style:{position:`fixed`,top:t.top,left:t.left,width:G4,pointerEvents:`none`},className:`z-[9999] rounded-md border border-border bg-surface shadow-lg shadow-black/30 p-2`,children:[v(`h5`,{className:`text-[9px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:n(`uiLibrary.deviceItemFeatures.features`,`Features`)}),v(`ul`,{className:`space-y-0.5`,children:e.map(e=>v(Y4,{entry:e},e.feature))})]})}function Y4({entry:e}){let t=P2[e.feature],n=F2[e.feature]??e.feature;return c(`li`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[c(`span`,{className:`flex items-center gap-1.5 text-foreground`,children:[t&&v(t,{className:`h-3 w-3 text-foreground-subtle`}),v(`span`,{children:n})]}),v(X4,{kind:e.kind})]})}function X4({kind:e}){let t=q();return e===`marker`?v(`span`,{className:`text-[8.5px] px-1 rounded text-foreground-subtle`,title:t(`uiLibrary.deviceItemFeatures.markerTitle`,`Informational marker (no cap registered)`),children:t(`uiLibrary.deviceItemFeatures.marker`,`marker`)}):v(`span`,{className:$(`text-[8.5px] px-1 rounded`,e===`native`?`bg-success/15 text-success`:`bg-primary/15 text-primary`),children:e})}var Z4={horizontal:`h-3.5 w-3.5`,stacked:`h-4 w-4 mt-0.5`};function Q4({trpc:e,device:t,variant:n,flags:r,parent:i,integrationIcon:a,hasChildren:o,expanded:s,onToggleExpand:l,onNavigateToParent:u,stacked:d=!1,nameOverflow:f=`truncate`,nameForm:p=`compact`}){let m=q(),h=_4(t.id),g=O4();ms();let _=A2(U2(t,h),g),y=qr(e,t.id,e=>e.runningState),b=y===void 0||y.running===null?null:y.running,x=d?Z4.stacked:Z4.horizontal,S=$(`text-foreground-subtle flex-shrink-0`,d?`h-4 w-4 mt-0.5`:n===`minimal`?`h-3 w-3`:`h-3.5 w-3.5`),C=f===`scroll`?Q2:`truncate`,w=p===`nested`&&i!==null?{id:i.id,name:i.name,type:i.type??`unknown`,stableId:``}:void 0,T=yj(i?.id??0,`compact`,i?.name);return c(`div`,{className:$(d?`flex items-start gap-2 w-full min-w-0`:`flex items-center gap-2 flex-1 min-w-0`),children:[r.showChildrenAccordion&&o?v(`button`,{type:`button`,"data-testid":`chevron-slot`,onClick:e=>{e.stopPropagation(),l()},className:$(`flex items-center justify-center text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,x),"aria-label":s?m(`uiLibrary.deviceItemHeader.collapseChildren`,`Collapse children`):m(`uiLibrary.deviceItemHeader.expandChildren`,`Expand children`),"aria-expanded":s,children:v(s?de:It,{className:`h-3 w-3`})}):r.showChildrenAccordion?v(`span`,{"data-testid":`chevron-slot`,className:$(`flex-shrink-0`,x)}):null,v(bV,{running:b,children:v(_,{className:S})}),c(`div`,{className:`flex-1 min-w-0`,children:[c(`div`,{className:$(`min-w-0`,d?`flex flex-col gap-1`:`flex items-center gap-1.5`),children:[r.showIntegrationIcon&&a&&v(`span`,{className:`flex-shrink-0`,children:a}),v(bj,{device:t,form:p,...w===void 0?{}:{parent:w},testId:`device-name`,className:$(`font-semibold text-foreground`,d?`text-[13px] leading-snug line-clamp-2 break-words`:$(C,n===`minimal`?`text-[10.5px]`:`text-[11px]`))})]}),(r.showId||r.showStableId)&&c(`div`,{className:$(`mt-0.5 flex items-center gap-1 text-[9px] text-foreground-subtle font-mono`,C),title:r.showStableId?`stableId: ${t.stableId}`:void 0,children:[r.showId&&c(`span`,{className:`flex-shrink-0 tabular-nums`,children:[`#`,String(t.id)]}),r.showId&&r.showStableId&&v(`span`,{className:`flex-shrink-0 opacity-50`,children:`·`}),r.showStableId&&v(`span`,{className:C,children:W2(t.stableId)})]}),r.showParentBadge&&i&&c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),u(i.id)},className:$(`mt-0.5 inline-flex items-center gap-1 text-[9px] text-foreground-subtle hover:text-primary transition-colors`,f===`scroll`?`md:max-w-full`:`max-w-full`),title:m(`uiLibrary.deviceItemHeader.openParent`,`Open parent: {{name}} (#{{id}})`,{name:T,id:i.id}),children:[v(De,{className:`h-2.5 w-2.5 shrink-0`}),v(`span`,{className:C,children:m(`uiLibrary.deviceItemHeader.under`,`Under: {{name}}`,{name:T})})]})]})]})}function $4(e,t){return qr(e,t,e=>e.battery)??null}function e3(e,t){return qr(e,t,e=>e.networkLink)??null}E(),Do();var t3=288,n3=196,r3=`h-7 w-7 rounded`,i3=8,a3=8;function o3({src:e,alt:t,caption:n,placeholder:r=`No image`,thumbClassName:i=r3,expandedWidth:a=t3,expandedHeight:o=n3}){let s=f(null),[l,u]=C(null),[d,p]=C(!1);b(()=>{p(!1)},[e]);let m=e!==null&&!d,h=e??void 0,g=_(()=>{let e=s.current;if(!e)return;let t=e.getBoundingClientRect(),n=t.top,r=window.innerHeight-t.bottom,i=n<o+i3&&r>n?t.bottom+i3:t.top-o-i3,c=t.right-a;u({top:i,left:Math.max(a3,Math.min(c,window.innerWidth-a-a3))})},[a,o]),y=_(()=>u(null),[]);return c(P,{children:[v(`button`,{ref:s,type:`button`,onClick:e=>e.stopPropagation(),onMouseEnter:g,onMouseLeave:y,onFocus:g,onBlur:y,"aria-label":t,className:`flex flex-shrink-0 items-center justify-center overflow-hidden border border-border bg-background text-foreground-subtle transition-colors hover:bg-surface-hover ${i}`,children:m?v(`img`,{src:h,alt:``,onError:()=>p(!0),className:`h-full w-full object-cover`}):v(ce,{className:`h-3.5 w-3.5`,"aria-hidden":`true`})}),l&&Oo(c(`div`,{"aria-hidden":`true`,style:{position:`fixed`,top:l.top,left:l.left,width:a,pointerEvents:`none`},className:`z-[9999] overflow-hidden rounded-lg border border-border bg-surface shadow-lg shadow-black/30`,children:[v(`div`,{className:`flex h-40 items-center justify-center bg-background`,children:m?v(`img`,{src:h,alt:t,className:`h-full w-full object-cover`}):v(`span`,{className:`text-xs text-foreground-subtle`,children:r})}),v(`div`,{className:`px-3 py-2`,children:v(`p`,{className:`truncate text-xs font-semibold text-foreground`,children:n??t})})]}),document.body)]})}var s3=480;function c3({trpc:e,device:t,status:n,enabled:r,showStatusPills:i=!1}){let a=r&&t.online,o=vj(t,`compact`),s=Te(a?t.id:null,{width:s3}),l=(t.features??[]).includes(`battery-operated`),u=i&&l&&!t.disabled,d=$4(e,u?t.id:null),f=i&&!t.disabled,p=e3(e,f?t.id:null);if(!r&&!u&&!(f&&p))return null;let m=n===`offline`||n===`disabled`,h=n===`offline`?`Offline — no snapshot`:n===`disabled`?`Disabled`:`No snapshot yet`;return c(`span`,{className:`inline-flex items-center gap-1.5 flex-nowrap whitespace-nowrap`,children:[u&&d&&v(gV,{status:d}),f&&v(wV,{status:p}),r&&v(o3,{src:m?null:s.src,alt:o,placeholder:h,thumbClassName:`h-7 w-7 rounded`})]})}E();var l3=Kn(`camstack:device-quick-detail`,null);function u3({open:e,children:t}){return v(l3.Provider,{value:e,children:t})}function d3(){return I(l3)}function f3({deviceId:e,className:t}){let n=q(),r=d3();return r===null?null:v(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r(e)},className:$(`inline-flex items-center justify-center rounded text-foreground-subtle hover:text-foreground transition-colors flex-shrink-0`,t),title:n(`uiLibrary.deviceQuickDetail.label`,`Quick detail`),"aria-label":n(`uiLibrary.deviceQuickDetail.label`,`Quick detail`),"data-testid":`device-quick-detail`,children:v(Yn,{className:`h-3 w-3`})})}function p3(e){return e===`online`||e===`recording-continuous`||e===`recording-events`}function m3(e,t,n){switch(e){case`disabled`:return n(`uiLibrary.statusDot.disabled`,`Disabled`);case`online`:return n(`uiLibrary.statusDot.online`,`Online`);case`recording-continuous`:return n(`uiLibrary.statusDot.recordingAlways`,`Recording · always`);case`recording-events`:return n(`uiLibrary.statusDot.recordingMotion`,`Recording · on motion`);case`offline`:{let e=s2(t,n);return e===null?n(`uiLibrary.statusDot.offline`,`Offline`):n(`uiLibrary.statusDot.offlineLastSeen`,`Offline · last seen {{lastSeen}}`,{lastSeen:e})}}}function h3(e){switch(e){case`disabled`:return`bg-black ring-1 ring-foreground-subtle/60`;case`offline`:return`bg-foreground-subtle`;case`recording-continuous`:return`bg-danger`;case`recording-events`:return`bg-info`;case`online`:return`bg-success`}}function g3({status:e,lastChangedAt:t}){let n=q();return v(`span`,{className:$(`h-1.5 w-1.5 rounded-full flex-shrink-0`,h3(e),p3(e)&&`animate-pulse`),title:m3(e,t,n)})}var _3=`Disabled`;function v3(e,t,n){let r=t.filter(e=>e.disabled!==!0),i=y3(t.filter(e=>e.disabled===!0));if(n===void 0||n.length===0)return{sections:[],ungrouped:r,disabledSection:i};let a=new Map;for(let e of r)a.set(e.stableId,e);let o=[],s=new Map,c=new Set;for(let t of n){let n=`${e}-${t.childKey}`,r=a.get(n);if(r===void 0)continue;let i=s.get(t.section);i===void 0&&(i={title:t.section,entries:[],collapsed:!1},s.set(t.section,i),o.push(t.section)),i.entries.push({child:r,order:t.order??2**53-1}),t.collapsed===!0&&(i.collapsed=!0),c.add(r.id)}return{sections:o.map(e=>{let t=s.get(e),n=[...t===void 0?[]:t.entries].toSorted((e,t)=>e.order===t.order?e.child.name.localeCompare(t.child.name):e.order-t.order),r=t===void 0?!0:!t.collapsed;return{title:e,children:n.map(e=>e.child),defaultOpen:r}}),ungrouped:r.filter(e=>!c.has(e.id)),disabledSection:i}}function y3(e){if(e.length!==0)return{title:_3,children:[...e].toSorted((e,t)=>e.name.localeCompare(t.name)),defaultOpen:!1,muted:!0}}E();function b3({title:e,count:t,children:n,defaultOpen:r=!0}){let[i,a]=C(r);return c(`div`,{className:`rounded-md border border-border-subtle/50`,children:[c(`button`,{type:`button`,onClick:()=>a(e=>!e),className:$(`w-full flex items-center gap-1.5 px-2 py-1.5 text-left transition-colors`,`hover:bg-surface-hover`),"aria-expanded":i,children:[v(i?de:It,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle flex-1 truncate`,children:e}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle/70 tabular-nums`,children:t})]}),i&&v(`div`,{className:`space-y-1 px-1 pb-1.5`,children:n})]})}E();function x3(e){let t=q(),{trpc:n,device:r,parent:i,integrationIcon:a,onNavigate:o,className:s,renderRowAction:l,onDelete:u,selection:d}=e,f=k2(e),p=e.variant??`compact`,m=e.view??`card`,h=e.isAccessoryRow?`nested`:`compact`,g=h===`nested`&&i?{id:i.id,name:i.name,type:i.type??`unknown`,stableId:``}:void 0,_=vj(r,h,g===void 0?void 0:{parent:g}),y=!r.disabled,b=r.isCamera??r.type.toLowerCase()===`camera`,x=e.children??[],S=x.filter(z2),w=x.filter(e=>!z2(e)),T=x.length>0,[E,D]=C(!1),O=e.expanded??E,k=e.onToggleExpand??(()=>D(e=>!e)),A=e=>{o?.(e)},j=e.rowClickSelects===!0&&d!==void 0,M=()=>{if(j&&d!==void 0){d.onToggle();return}A(r.id)},N=e.indentLevel??(e.isAccessoryRow?2:0),P=V2(r,x),F=y?P?`online`:`offline`:`disabled`;return m===`table`?v(C3,{trpc:n,device:r,variant:p,flags:f,parent:i??null,integrationIcon:a??null,accessoryCount:S.length,adoptedCount:w.length,hasChildren:T,expanded:O,onToggleExpand:k,onRowClick:M,rowSelects:j,rowSelected:d?.selected??!1,onNavigate:A,displayStatus:F,isCamera:b,showSnapshot:f.showSnapshot&&b,isAccessoryRow:e.isAccessoryRow??!1,indentLevel:N,className:s,renderRowAction:l??null,onDelete:u??null,selection:d,showTypeCell:e.showTypeCell??!0,showManufacturerCell:e.showManufacturerCell??!0,showFeaturesCell:e.showFeaturesCell??!0}):p===`minimal`?c(`div`,{className:$(`rounded-lg border border-border bg-surface transition-colors`,!y&&`opacity-60`,s),children:[c(`div`,{"data-testid":`device-card-body`,onClick:M,...j?{role:`button`,"aria-pressed":d?.selected??!1,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M())}}:{},className:$(`flex items-center gap-2 cursor-pointer hover:border-foreground-subtle/30 w-full px-2.5 py-1.5`,d?.selected&&`bg-primary/10`),children:[d&&v(`input`,{type:`checkbox`,checked:d.selected,onChange:d.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:_}),className:`flex-shrink-0`}),v(Q4,{trpc:n,device:r,variant:p,flags:f,parent:i??null,nameForm:h,integrationIcon:a??null,hasChildren:T,expanded:O,onToggleExpand:k,onNavigateToParent:A}),v(U4,{trpc:n,device:r,flags:f,accessoryCount:S.length,adoptedCount:w.length,showFeatureRow:!1}),v(c3,{trpc:n,device:r,status:F,enabled:f.showSnapshot&&b,showStatusPills:!0}),v(y4,{trpc:n,device:r,flags:f,controlPlacement:`right`}),v(f3,{deviceId:r.id}),l&&v(`span`,{onClick:e=>e.stopPropagation(),children:l(r)}),v(g3,{status:F})]}),O&&T&&v(A4,{trpc:n,accessoryChildren:S,adoptedChildren:w,onNavigate:A,parentName:r.name})]}):c(`div`,{className:$(`group rounded-xl border border-border bg-surface transition-colors`,`hover:border-foreground-subtle/30`,!y&&`opacity-60`,s),children:[c(`div`,{"data-testid":`device-card-body`,onClick:M,...j?{role:`button`,"aria-pressed":d?.selected??!1,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),M())}}:{},className:$(`flex flex-col gap-2 cursor-pointer w-full p-3 rounded-xl`,d?.selected&&`bg-primary/10`),children:[c(`div`,{className:`flex items-start justify-between gap-2`,children:[d&&v(`input`,{type:`checkbox`,checked:d.selected,onChange:d.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:_}),className:`flex-shrink-0 mt-0.5`}),v(Q4,{trpc:n,device:r,variant:p,flags:f,parent:i??null,nameForm:h,integrationIcon:a??null,hasChildren:T,expanded:O,onToggleExpand:k,onNavigateToParent:A,stacked:!0}),v(g3,{status:F})]}),v(U4,{trpc:n,device:r,flags:f,accessoryCount:S.length,adoptedCount:w.length,showFeatureRow:!1}),c(`div`,{className:`flex items-center justify-end gap-1.5`,children:[v(c3,{trpc:n,device:r,status:F,enabled:f.showSnapshot&&b,showStatusPills:!0}),v(y4,{trpc:n,device:r,flags:f,controlPlacement:`right`}),v(f3,{deviceId:r.id}),l&&v(`span`,{onClick:e=>e.stopPropagation(),children:l(r)})]})]}),O&&T&&v(A4,{trpc:n,accessoryChildren:S,adoptedChildren:w,onNavigate:A,parentName:r.name})]})}var S3={0:`pl-2`,1:`pl-6`,2:`pl-8`};function C3(e){let t=q(),{trpc:n,device:r,variant:i,flags:a,parent:o,integrationIcon:s,accessoryCount:l,adoptedCount:u,hasChildren:d,expanded:f,onToggleExpand:p,onNavigate:m,onRowClick:h,rowSelects:g,rowSelected:_,displayStatus:y,isCamera:b,showSnapshot:x,isAccessoryRow:S,indentLevel:C,className:w,renderRowAction:T,onDelete:E,selection:D,showTypeCell:O,showManufacturerCell:k,showFeaturesCell:A}=e,j=_4(r.id),M=S?`nested`:`compact`,N=M===`nested`&&o?{id:o.id,name:o.name,type:o.type??`unknown`,stableId:``}:void 0,P=vj(r,M,N===void 0?void 0:{parent:N});return c(`tr`,{onClick:h,...g?{role:`button`,"aria-pressed":_,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),h())}}:{},className:$(`group cursor-pointer hover:bg-surface-hover transition-colors`,!d&&`border-b border-border-subtle/40`,S&&`bg-foreground-subtle/[0.03]`,_&&`bg-primary/10`,w),children:[v(`td`,{className:$(X2,`py-1.5 align-middle pr-2 transition-colors`,_?`bg-primary/10 group-hover:bg-surface-hover`:S?`bg-surface-subtle group-hover:bg-surface-hover`:`bg-surface group-hover:bg-surface-hover`,Z2,`min-w-0 overflow-hidden`,S3[C]),children:c(`div`,{className:`flex items-center gap-1.5`,children:[D&&v(`input`,{type:`checkbox`,checked:D.selected,onChange:D.onToggle,onClick:e=>e.stopPropagation(),"aria-label":t(`uiLibrary.deviceItem.select`,`Select {{name}}`,{name:P}),className:`flex-shrink-0`}),v(Q4,{trpc:n,device:r,variant:i,flags:a,parent:o,nameForm:M,integrationIcon:s,hasChildren:d,expanded:f,onToggleExpand:p,onNavigateToParent:m,nameOverflow:`scroll`})]})}),O&&v(`td`,{className:$(Y2.type,`px-2 py-1.5 align-middle text-[10px] text-foreground-subtle whitespace-nowrap`),children:H2(r,j)}),k&&v(`td`,{className:$(Y2.manufacturer,`px-2 py-1.5 align-middle w-40 max-w-[10rem] min-w-0 overflow-hidden`),children:v(l4,{device:r})}),A&&v(`td`,{className:$(Y2.features,`px-2 py-1.5 align-middle`),children:v(U4,{trpc:n,device:r,flags:a,accessoryCount:l,adoptedCount:u,showFeatureRow:!0})}),v(`td`,{className:`px-2 py-1.5 align-middle text-right whitespace-nowrap`,children:c(`span`,{className:`inline-flex items-center justify-end gap-1.5`,children:[v(y4,{trpc:n,device:r,flags:a,controlPlacement:`table`}),v(c3,{trpc:n,device:r,status:y,enabled:x&&b,showStatusPills:!0}),v(f3,{deviceId:r.id}),T&&v(`span`,{onClick:e=>e.stopPropagation(),children:T(r)}),E&&v(I4,{device:r,onDelete:E}),v(g3,{status:y})]})})]})}function w3(e){let t=new Map;for(let n of e)t.set(n.id,n);return e.filter(e=>{if(e.parentDeviceId===null||e.parentDeviceId===void 0)return!0;let n=t.get(e.parentDeviceId);return n?T3.has(n.type.toLowerCase()):!0})}var T3=new Set([`hub`,`nvr`]);function E3(e){let t=new Set(e.map(e=>e.id)),n=new Map,r=[];for(let i of e){let e=i.parentDeviceId;if(e!=null&&e!==i.id&&t.has(e)){let t=n.get(e);t?t.push(i):n.set(e,[i]);continue}r.push(i)}let i=[],a=new Set,o=e=>{if(a.has(e.id))return;a.add(e.id),i.push(e);let t=n.get(e.id);if(t)for(let e of t)o(e)};for(let e of r)o(e);for(let t of e)o(t);return i}function D3(e,t){let n=t?.includeHidden??!1,r=new Map;for(let t of e)r.set(t.id,t);let i=[],a=new Map;for(let t of e){if(!n&&t.display?.hidden===!0)continue;let e=t.parentDeviceId;if(e==null){i.push(t);continue}let o=r.get(e);if(!o){i.push(t);continue}let s=t.role!==null&&t.role!==void 0;if(T3.has(o.type)&&!s){i.push(t);continue}let c=a.get(e);c?c.push(t):a.set(e,[t])}return{topLevel:E3(i),accessoriesByParent:a}}function O3(e,t=Fn){return e===0?t(`uiLibrary.pageSizeSelect.all`,`All`):String(e)}function k3({value:e,options:t,onChange:n,ariaLabel:r}){let i=q();return c(`div`,{className:`inline-flex items-center gap-1.5`,children:[v(`span`,{"aria-hidden":`true`,children:i(`uiLibrary.pageSizeSelect.perPage`,`Per page`)}),v(`select`,{"aria-label":r,value:e,onChange:e=>n(Number.parseInt(e.target.value,10)),className:`h-7 px-1.5 rounded-md border border-border bg-surface text-[11px] text-foreground focus:outline-none focus:ring-1 focus:ring-primary/40`,children:t.map(e=>v(`option`,{value:e,children:O3(e,i)},e))})]})}E();function A3({label:e,options:t,selected:n,onChange:r}){let i=f(null),[a,o]=C(null);b(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0];t&&o(t.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let s=new Set(n),l=e=>{let n=new Set(s);n.has(e)?n.delete(e):n.add(e),r(t.filter(e=>n.has(e.id)).map(e=>e.id))},u=56+t.length*88;return v(`div`,{ref:i,className:`min-w-0 flex-1`,children:a!==null&&a>=u?c(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[v(`span`,{className:`text-[10px] font-medium uppercase tracking-wider text-foreground-subtle`,children:e}),t.map(e=>{let t=s.has(e.id),n=e.icon;return c(`button`,{type:`button`,onClick:()=>l(e.id),"aria-pressed":t,className:`inline-flex items-center gap-1 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors ${t?`border-primary/40 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[n&&v(n,{className:`h-3 w-3 shrink-0`}),e.label]},e.id)})]}):v(AG,{label:e,options:t,selected:n,onChange:r})})}E();function j3({typeOptions:e,selectedTypes:t,onTypesChange:n,addons:r,selectedAddons:i,onAddonsChange:a,hideAddons:o=!1,query:s=``,onClearFilters:l}){let u=q(),d=t.length>0||i.length>0||s.trim().length>0;return c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[e&&e.length>0&&v(A3,{label:u(`uiLibrary.filterChips.type`,`Type`),options:e,selected:t,onChange:n}),!o&&r&&r.length>0&&v(M3,{addons:r,selected:i,onChange:a}),l!==void 0&&d&&c(`button`,{type:`button`,onClick:l,className:`inline-flex items-center gap-1 h-7 rounded-md border border-border bg-surface px-2 text-[10.5px] text-foreground-subtle transition-colors hover:text-foreground hover:border-foreground-subtle/40`,children:[v(Zn,{className:`h-3 w-3`}),u(`uiLibrary.filterChips.clearFilters`,`Clear filters`)]})]})}function M3({addons:e,selected:t,onChange:n}){let r=q(),[i,a]=C(!1),o=f(null);b(()=>{if(!i)return;let e=e=>{let t=e.target;t&&o.current&&!o.current.contains(t)&&a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`touchstart`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`touchstart`,e),document.removeEventListener(`keydown`,t)}},[i]);let s=new Set(t),l=t.length,u=t=>{let r=new Set(s);r.has(t)?r.delete(t):r.add(t),n(e.filter(e=>r.has(e.id)).map(e=>e.id))};return c(`div`,{ref:o,className:`relative`,children:[c(`button`,{type:`button`,onClick:()=>a(e=>!e),className:$(`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-full border text-[10.5px] font-medium transition-colors`,l>0?`border-primary/40 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground hover:bg-surface-hover`),"aria-haspopup":`listbox`,"aria-expanded":i,children:[v(`span`,{children:l>0?r(`uiLibrary.filterChips.integrationCount`,`Integration · {{count}}`,{count:l}):r(`uiLibrary.filterChips.integration`,`Integration`)}),v(de,{className:$(`h-3 w-3 transition-transform`,i&&`rotate-180`)})]}),i&&c(`div`,{role:`listbox`,className:`absolute left-0 top-full mt-1 z-30 min-w-[180px] max-h-72 overflow-y-auto rounded-lg border border-border bg-surface shadow-xl py-1`,children:[l>0&&v(`button`,{type:`button`,onClick:()=>n([]),className:`flex w-full items-center px-3 py-1.5 text-left text-[10.5px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:r(`uiLibrary.filterChips.clearSelection`,`Clear selection`)}),e.map(e=>{let t=s.has(e.id);return c(`button`,{type:`button`,role:`option`,"aria-selected":t,onClick:()=>u(e.id),className:$(`flex w-full items-center gap-2 px-3 py-1.5 text-left text-[10.5px] transition-colors`,t?`text-primary`:`text-foreground hover:bg-surface-hover`),children:[v(`span`,{className:$(`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border`,t?`border-primary bg-primary/20`:`border-border`),children:t&&v(dt,{className:`h-2.5 w-2.5`})}),e.icon&&v(`span`,{className:`inline-flex items-center`,children:e.icon}),v(`span`,{className:`truncate`,children:e.name})]},e.id)})]})]})}function N3(e,t){switch(e){case`nofilter`:return t(`uiLibrary.deviceListEmptyState.noDevices`,`No devices yet`);case`filtered`:return t(`uiLibrary.deviceListEmptyState.noMatch`,`No devices match the current filters`);case`pending`:return t(`uiLibrary.deviceListEmptyState.loadingIntegrations`,`Loading integrations…`)}}function P3({variant:e,onClearFilters:t}){let n=q();return c(`div`,{className:`flex flex-col items-center justify-center py-12 text-center`,children:[v(dee,{className:`h-8 w-8 text-foreground-subtle/40 mb-3`}),v(`p`,{className:`text-sm font-medium text-foreground-subtle`,children:N3(e,n)}),e===`filtered`&&t&&v(`button`,{type:`button`,onClick:t,className:`mt-2 text-[11px] text-primary hover:underline`,children:n(`uiLibrary.deviceListEmptyState.clearFilters`,`Clear filters`)})]})}E();function F3(e){return e?e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0):[]}function I3(e,t){if(e===`root`)return t===`addons`?`addon`:t===`types`?`type`:t;switch(t){case`view`:return`deviceView`;case`page`:return`devicePage`;case`types`:return`deviceType`;case`q`:return`deviceQ`;case`addons`:return`deviceAddon`}}function L3(e){try{let t=localStorage.getItem(`camstack:${e}:lastFilters`);if(!t)return{};let n=JSON.parse(t);return typeof n!=`object`||!n?{}:n}catch{return{}}}function R3(e,t){try{localStorage.setItem(`camstack:${e}:lastFilters`,JSON.stringify(t))}catch{}}function z3(e,t){let n=new URLSearchParams(window.location.search),r=n.get(I3(e,`page`)),i=r?parseInt(r,10):1;return{page:Number.isFinite(i)&&i>=1?i:1,addons:F3(n.get(I3(e,`addons`))??t.addon??null),types:F3(n.get(I3(e,`types`))??t.type??null),q:n.get(I3(e,`q`))??t.q??``}}function B3(e,t){let n=new URLSearchParams(window.location.search),r=(e,t)=>{t===null||t===``?n.delete(e):n.set(e,t)};r(I3(e,`view`),null),r(I3(e,`page`),t.page===1?null:String(t.page)),r(I3(e,`addons`),t.addons.length>0?t.addons.join(`,`):null),r(I3(e,`types`),t.types.length>0?t.types.join(`,`):null),r(I3(e,`q`),t.q||null);let i=n.toString(),a=i?`${window.location.pathname}?${i}`:window.location.pathname;window.history.replaceState(null,``,a)}function V3(e){let{scope:t,lsKey:n}=e,[r,i]=C(()=>z3(t,L3(n))),a=f(r);a.current=r,b(()=>{let e=()=>{let e=z3(t,L3(n));a.current=e,i(e)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[t,n]);let o=_(e=>{let r=e(a.current);a.current=r,i(r),B3(t,r),R3(n,{addon:r.addons.length>0?r.addons.join(`,`):null,type:r.types.length>0?r.types.join(`,`):null,q:r.q})},[t,n]);return{state:r,setPage:_(e=>o(t=>({...t,page:e})),[o]),setAddons:_(e=>o(t=>({...t,addons:e,page:1})),[o]),setTypes:_(e=>o(t=>({...t,types:e,page:1})),[o]),setQ:_(e=>o(t=>({...t,q:e,page:1})),[o]),clearFilters:_(()=>o(e=>({...e,addons:[],types:[],q:``,page:1})),[o])}}function H3({columnId:e,label:t,sort:n,onSort:r}){let i=n!==null&&n.columnId===e;return v(cU,{label:v(`span`,{className:`uppercase tracking-wider`,children:t}),active:i,dir:i?n.dir:`asc`,onSort:()=>r(e)})}E();function U3(e,t){return e===null||e.columnId!==t?`none`:e.dir===`asc`?`ascending`:`descending`}var W3=new Set([`hub`,`nvr`]);function G3(e,t){return e.parentDeviceId===null||t===null?0:+!!W3.has(t.toLowerCase())}function lae({rows:e,accessoriesByParent:t,expandedParents:n,onToggleExpand:r,devices:i,visibleColumns:a,trpc:o,resolveIntegrationIcon:s,resolveParent:l,onNavigate:u,renderRowAction:d,onDeleteDevice:f,selectable:m,rowClickSelects:h,activeSelected:g,onToggleSelection:_,sort:y,onSort:b}){let x=q(),S=a.includes(`type`),C=a.includes(`features`),w=a.includes(`manufacturer`),T=a.includes(`icon`),E=p(()=>{let e=new Map;for(let t of i)e.set(t.id,t.type);return e},[i]);return v(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:c(`table`,{className:`w-full border-collapse`,children:[v(`thead`,{children:c(`tr`,{className:`border-b border-border`,children:[v(`th`,{"aria-sort":U3(y,`name`),className:$(X2,Z2,`bg-surface text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle`),children:v(H3,{columnId:`name`,label:x(`uiLibrary.deviceTable.name`,`Name`),sort:y,onSort:b})}),S&&v(`th`,{"aria-sort":U3(y,`type`),className:$(Y2.type,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-24`),children:v(H3,{columnId:`type`,label:x(`uiLibrary.deviceTable.type`,`Type`),sort:y,onSort:b})}),w&&v(`th`,{"aria-sort":U3(y,`manufacturer`),className:$(Y2.manufacturer,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-40`),children:v(H3,{columnId:`manufacturer`,label:x(`uiLibrary.deviceTable.hardware`,`Hardware`),sort:y,onSort:b})}),C&&v(`th`,{className:$(Y2.features,`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32`),children:x(`uiLibrary.deviceTable.features`,`Features`)}),v(`th`,{className:`text-right px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle w-32`,children:x(`uiLibrary.deviceTable.preview`,`Preview`)})]})}),v(`tbody`,{children:e.map(e=>{let i=t.get(e.id)??[],a=i.length>0,c=e.parentDeviceId===null?null:l?.(e.parentDeviceId)??null,p=e.parentDeviceId===null?null:E.get(e.parentDeviceId)??null,y=m?{selected:g.has(e.id),onToggle:()=>_(e.id)}:void 0;return v(uae,{parent:e,accessories:i,hasAccessories:a,expanded:n.has(e.id),onToggleExpand:()=>r(e.id),trpc:o,integrationIcon:T?s?.(e)??null:null,showType:S,showManufacturer:w,showFeatures:C,parentRowParent:c,indentLevel:G3(e,p),onNavigate:u??null,renderRowAction:d??null,onDeleteDevice:f,selection:y,rowClickSelects:h},e.id)})})]})})}function uae({parent:e,accessories:t,hasAccessories:n,expanded:r,onToggleExpand:i,trpc:a,integrationIcon:o,showType:s,showManufacturer:l,showFeatures:u,parentRowParent:d,indentLevel:f,onNavigate:m,renderRowAction:h,onDeleteDevice:g,selection:_,rowClickSelects:y}){let b=n&&r,x=p(()=>v3(e.stableId,t,e.childLayout),[e.stableId,e.childLayout,t]),[S,w]=C(()=>{let e=x.sections.filter(e=>!e.defaultOpen).map(e=>e.title);return x.disabledSection!==void 0&&!x.disabledSection.defaultOpen&&e.push(x.disabledSection.title),new Set(e)}),T=e=>w(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),E=2+ +!!s+ +!!l+ +!!u,D=x.disabledSection;return c(P,{children:[v(x3,{trpc:a,device:e,view:`table`,integrationIcon:o,parent:d,children:t,onNavigate:m??void 0,showChildrenAccordion:!0,expanded:r,onToggleExpand:i,indentLevel:f,renderRowAction:h??void 0,onDelete:g??void 0,selection:_,rowClickSelects:y,showTypeCell:s,showManufacturerCell:l,showFeaturesCell:u}),b&&x.ungrouped.map(t=>v(K3,{trpc:a,accessory:t,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m},t.id)),b&&x.sections.map(t=>{let n=!S.has(t.title);return v(q3,{title:t.title,count:t.children.length,open:n,colSpan:E,onToggle:()=>T(t.title),rows:t.children,trpc:a,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m},t.title)}),b&&D!==void 0&&v(q3,{title:D.title,count:D.children.length,open:!S.has(D.title),colSpan:E,onToggle:()=>T(D.title),rows:D.children,trpc:a,parentName:e.name,showType:s,showManufacturer:l,showFeatures:u,onNavigate:m,muted:!0},D.title)]})}function K3({trpc:e,accessory:t,parentName:n,showType:r,showManufacturer:i,showFeatures:a,onNavigate:o,muted:s}){return v(x3,{trpc:e,device:t,view:`table`,integrationIcon:null,parent:t.parentDeviceId===null?null:{id:t.parentDeviceId,name:n},isAccessoryRow:!0,showChildrenAccordion:!1,onNavigate:o??void 0,showTypeCell:r,showManufacturerCell:i,showFeaturesCell:a,className:s===!0?`opacity-60`:void 0})}function q3({title:e,count:t,open:n,colSpan:r,onToggle:i,rows:a,trpc:o,parentName:s,showType:l,showManufacturer:u,showFeatures:d,onNavigate:f,muted:p}){return c(P,{children:[v(`tr`,{className:$(`border-b border-border-subtle/40 bg-surface`,p===!0&&`opacity-60`),children:v(`td`,{colSpan:r,className:`p-0`,children:c(`button`,{type:`button`,onClick:i,className:`w-full flex items-center gap-1.5 pl-8 pr-2 py-1 text-left hover:bg-surface-hover transition-colors`,"aria-expanded":n,children:[v(n?de:It,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle flex-1 truncate`,children:e}),v(`span`,{className:`text-[10px] font-medium text-foreground-subtle/70 tabular-nums`,children:t})]})})}),n&&a.map(e=>v(K3,{trpc:o,accessory:e,parentName:s,showType:l,showManufacturer:u,showFeatures:d,onNavigate:f,muted:p},e.id))]})}function J3(e){return Yo(e.type).label.toLowerCase()}function Y3(e){return e.name.toLowerCase()}function dae(e){return e===`name`?(e,t)=>Y3(e).localeCompare(Y3(t)):e===`type`?(e,t)=>J3(e).localeCompare(J3(t)):c4}function X3(e,t){let n=lU(e!==null&&e.columnId===t,e===null?null:e.dir);return n===null?null:{columnId:t,dir:n}}function Z3(e,t){if(t===null)return[...e];let n=dae(t.columnId),r=t.dir===`asc`?1:-1;return E3([...e].toSorted((e,i)=>{if(t.columnId===`manufacturer`){let t=a4(e);if(t!==a4(i))return t?-1:1}return r*n(e,i)}))}E();var fae={cards:24,table:50};function pae(e){let t=q(),{devices:n,trpc:r,context:i=`devices`,filters:a,forceIntegrationId:o,integrationOf:s,resolveIntegrationIcon:l,resolveParent:u,onNavigate:d,pageSize:f=fae,urlScope:m=`root`,lsKey:h=m===`root`?`devices`:`integrations:nested`,renderRowAction:g,onDeleteDevice:y,selectable:x=!1,selectedIds:S,onSelectionChange:w,batchActions:T}=e,[E,D]=C(!1),[O,k]=C(new Set),A=S??O,j=e=>{let t=new Set(A);t.has(e)?t.delete(e):t.add(e),S===void 0&&k(t),w?.(t)},M=()=>{S===void 0?k(new Set):w?.(new Set)},N=()=>{M(),D(!1)},P=x||T!==void 0&&E,F=T!==void 0&&E,I=p(()=>q2(i),[i]),[L,R]=C(null),z=e=>R(t=>X3(t,e)),B=a?.typeOptions,V=p(()=>B??es(t),[B,t]),H=V3({scope:m,lsKey:h}),[U,ee]=E2(f.table),W=U,[G,te]=C(H.state.q),ne=HJ(G,300);b(()=>{ne!==H.state.q&&H.setQ(ne)},[ne]);let re=p(()=>o===void 0?H.state.addons:[o],[o,H.state.addons]),K=_(e=>s===void 0?{kind:`unknown`}:s(e),[s]),ie=p(()=>{let e=new Map;for(let t of n){if(t.parentDeviceId===null||t.parentDeviceId===void 0)continue;let n=e.get(t.parentDeviceId);n?n.push(t):e.set(t.parentDeviceId,[t])}return e},[n]),ae=p(()=>{let e=H.state.q,t=re.length>0?new Set(re):null,r=H.state.types.length>0?new Set(H.state.types):null;return n.filter(n=>!(t&&!mae(K(n),t)||r&&!r.has(H2(n,ie.get(n.id)))||e.trim()!==``&&!SG(e,n.name)&&!SG(e,n.stableId)))},[n,ie,re,K,H.state.types,H.state.q]),oe=p(()=>D3(ae),[ae]),se=p(()=>l===void 0?null:e=>l(e,K(e)),[l,K]),ce=p(()=>Z3(oe.topLevel,L),[oe.topLevel,L]),[le,ue]=C(()=>new Set),de=_(e=>{ue(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),fe=oe.topLevel.length,pe=Math.max(1,Math.ceil(fe/W)),me=Math.min(H.state.page,pe),he=(me-1)*W,ge=ce.slice(he,he+W);b(()=>{me!==H.state.page&&H.setPage(me)},[me]),hae();let _e=re.length>0||H.state.types.length>0||H.state.q!==``,ve=fe===0,ye=p(()=>re.length>0&&n.some(e=>K(e).kind===`unknown`),[re,n,K]);return c(`div`,{className:`flex flex-col gap-3`,children:[c(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[v(j3,{typeOptions:V,selectedTypes:H.state.types,onTypesChange:H.setTypes,addons:a?.integrations,selectedAddons:H.state.addons,query:H.state.q,onClearFilters:()=>{te(``),H.clearFilters()},onAddonsChange:H.setAddons,hideAddons:o!==void 0}),c(`div`,{className:`flex items-center gap-2`,children:[T!==void 0&&(E?c(`button`,{type:`button`,onClick:N,className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border bg-surface text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[v(Zn,{className:`h-3 w-3`}),t(`uiLibrary.deviceModeList.done`,`Done`)]}):c(`button`,{type:`button`,onClick:()=>D(!0),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md border border-border bg-surface text-[11px] font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:[v(Or,{className:`h-3 w-3`}),t(`uiLibrary.deviceModeList.select`,`Select`)]})),c(`div`,{className:`relative`,children:[v(Ci,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none`}),v(`input`,{type:`text`,value:G,onChange:e=>te(e.target.value),placeholder:t(`uiLibrary.deviceModeList.searchPlaceholder`,`Search by name or stableId`),"aria-label":t(`uiLibrary.deviceModeList.searchAria`,`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`})]})]})]}),T!==void 0&&E&&v(y2,{selectedIds:A,onClear:M,remove:T.remove,disable:T.disable,enable:T.enable}),ve?v(P3,{variant:ye?`pending`:_e?`filtered`:`nofilter`,onClearFilters:_e&&!ye?H.clearFilters:void 0}):v(g4,{value:oe.accessoriesByParent,children:v(lae,{rows:ge,accessoriesByParent:oe.accessoriesByParent,expandedParents:le,onToggleExpand:de,visibleColumns:I,sort:L,onSort:z,devices:ae,trpc:r,resolveIntegrationIcon:se,resolveParent:u??null,onNavigate:d??null,renderRowAction:g??null,onDeleteDevice:y??null,selectable:P,rowClickSelects:F,activeSelected:A,onToggleSelection:j})}),!ve&&c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[c(`div`,{className:`inline-flex items-center gap-2`,children:[fe<=U&&v(`span`,{children:t(`uiLibrary.deviceModeList.deviceCount`,{one:`{{count}} device`,other:`{{count}} devices`},{count:fe})}),v(k3,{ariaLabel:t(`uiLibrary.deviceModeList.devicesPerPage`,`Devices per page`),value:U,options:w2,onChange:ee})]}),v(ZM,{currentPage:me,totalItems:fe,pageSize:W,onPageChange:H.setPage})]}),o===void 0&&_e&&fe>0&&v(`p`,{className:`text-[11px] text-foreground-subtle`,children:re.length>0?v(gi,{uiKey:`uiLibrary.deviceModeList.showingFiltered`,fallback:{one:`Showing {{shown}} of {{count}} device · filtered by <0>{{names}}</0>`,other:`Showing {{shown}} of {{count}} devices · filtered by <0>{{names}}</0>`},components:[v(`strong`,{className:`text-primary`},`names`)],values:{shown:fe,count:w3(n).length,names:re.map(e=>a?.integrations?.find(t=>t.id===e)?.name??e).join(`, `)}}):t(`uiLibrary.deviceModeList.showing`,{one:`Showing {{shown}} of {{count}} device`,other:`Showing {{shown}} of {{count}} devices`},{shown:fe,count:w3(n).length})})]})}function mae(e,t){return e.kind===`resolved`&&t.has(e.integration.id)}function hae(){k()}E();var gae=100;function _ae(e){let t=q(),{items:n,getKey:r,getSearchText:i,renderItem:a,getFilterType:o,mapFilterOption:s,filterOptions:l,filterLabel:u=`Type`,initialTypeFilters:m=[],columns:h,renderExpanded:g,isExpanded:_,rowClassName:y,onRowClick:x,isLoading:S=!1,searchPlaceholder:w=`Search`,emptyLabel:T=`No items found.`,pageSize:E=gae,pageSizeSelector:D,toolbar:O}=e,[k,A]=S2(D??{storageKey:null,options:[E],defaultSize:E}),[j,M]=C(``),N=f(null);As(N);let P=HJ(j,300),[F,I]=C(()=>[...m]),[L,R]=C(1);b(()=>{R(1)},[P,F]);let z=p(()=>{if(!o)return[];if(l)return l;let e=new Set;for(let t of n){let n=o(t);n!==null&&n!==``&&e.add(n)}return[...e].toSorted().map(e=>{let t=s?.(e);return{id:e,label:t?.label??e,...t?.icon?{icon:t.icon}:{}}})},[n,o,s,l]),B=p(()=>new Set(F),[F]),V=p(()=>{let e=P;return n.filter(t=>{if(B.size>0&&o){let e=o(t);if(e===null||!B.has(e))return!1}return!(e.trim()!==``&&!SG(e,i(t)))})},[n,P,i,B,o]),H=V.length,U=D?C2(k,H):E,ee=Math.max(1,Math.ceil(H/U)),W=Math.min(L,ee),G=(W-1)*U,te=V.slice(G,G+U);return b(()=>{W!==L&&R(W)},[W,L]),c(`div`,{className:`flex flex-col gap-3 h-full min-h-0`,children:[c(`div`,{className:`flex items-center justify-between gap-3 flex-wrap shrink-0`,children:[o&&z.length>0?v(A3,{label:u,options:z,selected:F,onChange:I}):v(`span`,{}),c(`div`,{className:`flex items-center gap-2`,children:[c(`div`,{className:`relative`,children:[v(Ci,{className:`absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle pointer-events-none`}),v(`input`,{ref:N,type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:w,"aria-label":w,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`})]}),typeof O==`function`?O({filtered:V}):O]})]}),v(`div`,{className:`flex-1 min-h-0 overflow-y-auto`,children:S&&H===0?v(`div`,{className:`flex items-center justify-center py-12 text-xs text-foreground-subtle`,children:t(`uiLibrary.genericModeList.loading`,`Loading…`)}):H===0?v(`div`,{className:`flex items-center justify-center py-12 text-xs text-foreground-subtle`,children:T}):h?v(`div`,{className:`rounded-lg border border-border bg-surface overflow-x-auto`,children:c(`table`,{className:`w-full border-collapse`,children:[v(`thead`,{children:v(`tr`,{className:`border-b border-border`,children:h.map(e=>v(`th`,{className:`text-left px-2 py-2 text-[9.5px] font-medium uppercase tracking-wider text-foreground-subtle ${e.headerClassName??``}`,children:e.header},e.key))})}),v(`tbody`,{children:te.map(e=>c(d,{children:[v(`tr`,{className:`border-b border-border/60 ${x?`cursor-pointer hover:bg-surface-hover transition-colors`:``} ${y?.(e)??``}`,...x?{onClick:()=>x(e),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e))}}:{},children:h.map(t=>v(`td`,{className:`px-2 py-2 align-middle ${t.cellClassName??``}`,children:t.cell(e)},t.key))}),g&&_?.(e)&&v(`tr`,{className:`border-b border-border/60 bg-surface/40`,children:v(`td`,{colSpan:h.length,className:`px-2 pb-2 pt-0`,children:g(e)})})]},r(e)))})]})}):v(`div`,{className:`space-y-1.5`,children:te.map(e=>v(d,{children:a?.(e)},r(e)))})}),v(`div`,{className:`shrink-0`,children:D&&H>0?c(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[c(`div`,{className:`inline-flex items-center gap-2`,children:[H<=U&&v(`span`,{children:t(`uiLibrary.genericModeList.total`,`{{count}} total`,{count:H})}),v(k3,{ariaLabel:t(`uiLibrary.genericModeList.rowsPerPage`,`Rows per page`),value:k,options:D.options,onChange:A})]}),v(ZM,{currentPage:W,totalItems:H,pageSize:U,onPageChange:R})]}):v(ZM,{currentPage:W,totalItems:H,pageSize:U,onPageChange:R})})]})}function Q3(e){return typeof e==`string`&&e.length>0}function $3(e,t){return e6(t)(e)}function e6(e){if(e==null)return()=>({kind:`unknown`});let t=new Map,n=new Map;for(let r of e)t.has(r.id)||t.set(r.id,r),n.has(r.addonId)||n.set(r.addonId,r);return e=>{if(Q3(e.integrationId)){let n=t.get(e.integrationId);return n===void 0?{kind:`orphan`}:{kind:`resolved`,integration:n}}if(Q3(e.addonId)){let t=n.get(e.addonId);return t===void 0?{kind:`orphan`}:{kind:`resolved`,integration:t}}return{kind:`unlinked`}}}function t6(e){return`mode`in e&&e.mode===`generic`?v(_ae,{...e}):v(pae,{...e})}var vae=`(none)`,yae={roles:[],providers:[]};function n6(e){let t=e.role;return t==null||t===``?vae:t}function bae(e,t){let n=new Set(t.roles),r=new Set(t.providers);return e.filter(e=>(n.size===0||n.has(n6(e)))&&(r.size===0||r.has(e.addonId)))}function r6(e){return[...new Set(e)].toSorted().map(e=>({id:e,label:e}))}function xae(e){return r6(e.map(n6))}function Sae(e){return r6(e.map(e=>e.addonId))}function Cae(e,t){return new Set([...e,...t.map(e=>String(e.id))])}function wae(e,t){let n=new Set(t.map(e=>String(e.id)));return new Set([...e].filter(e=>!n.has(e)))}E();var Tae=go(Wa),Eae=uo({id:co(),stableId:lo(),addonId:lo(),type:lo(),name:lo(),online:_o(),disabled:_o(),parentDeviceId:co().nullable(),role:lo().nullable().optional(),features:go(lo()).optional(),isCamera:_o().optional()}),Dae=go(lo()),i6=1e4,a6=`camstack.device-export.pageSize`,Oae={options:[10,25,50,100,0],defaultSize:25,storageKey:a6},kae=3e4;function Aae(e){return e===`linked`?`success`:e===`error`?`danger`:`warning`}function jae(e,t){return t===`linked`?e(`uiLibrary.deviceExport.linked`,`Linked`):t===`unlinked`?e(`uiLibrary.deviceExport.unlinked`,`Unlinked`):t===`error`?e(`uiLibrary.deviceExport.error`,`Error`):t}function Mae({field:e}){let t=q(),[n,r]=C(!1),i=e.secret===!0,a=i&&!n?`•`.repeat(Math.min(e.value.length,24)):e.value;return v(_U,{label:e.label,valueClassName:`font-mono`,actions:c(P,{children:[i&&v(_A,{size:`sm`,variant:`ghost`,type:`button`,"aria-label":n?t(`uiLibrary.deviceExport.hideValue`,`Hide value`):t(`uiLibrary.deviceExport.revealValue`,`Reveal value`),onClick:()=>r(e=>!e),children:v(n?Oe:Zt,{className:`h-3.5 w-3.5`})}),v(bG,{value:e.value,srLabel:e.label})]}),children:a||`—`})}function o6({setup:e}){let t=q(),n=e.fields??[];return c(`div`,{className:`border-b border-border bg-surface-hover/10`,children:[c(`div`,{className:`flex items-center gap-2 px-2 sm:px-4 py-2 border-b border-border`,children:[v(ee,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}),v(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:t(`uiLibrary.deviceExport.setup`,`Setup`)})]}),c(`div`,{className:`flex flex-col gap-3 p-2 sm:p-4 sm:flex-row sm:items-start`,children:[e.qr&&v(`div`,{className:`shrink-0`,children:v(NR,{value:e.qr,alt:t(`uiLibrary.deviceExport.qr`,`Pairing QR code`)})}),c(`div`,{className:`flex-1 min-w-0`,children:[e.note&&v(`p`,{className:`text-xs text-foreground-muted whitespace-pre-line mb-2`,children:e.note}),n.length>0&&v(`div`,{className:`divide-y divide-border-subtle`,children:n.map(e=>v(Mae,{field:e},e.label))})]})]})]})}function s6(e){let t=La.safeParse(e);return t.success?t.data:null}function c6({addonId:e}){let t=ip({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),n=p(()=>s6(t.data),[t.data]);return!n?.error&&!n?.setup?null:c(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n.error&&v(`div`,{className:`px-2 sm:px-4 py-3 border-b border-border`,children:v(eN,{message:n.error})}),n.setup&&v(o6,{setup:n.setup})]})}function Nae({device:e,checked:t,onToggle:n}){return v(`input`,{type:`checkbox`,checked:t,onChange:n,onClick:e=>e.stopPropagation(),"aria-label":q()(`uiLibrary.deviceExport.select`,`Select {{name}}`,{name:vj(e,`compact`)})})}function Pae({addonId:e,device:t,exposed:n,busy:r,onToggle:i}){let a=q(),o=vj(t,`compact`);return v(_A,{size:`sm`,variant:n?`ghost`:`primary`,disabled:r,onClick:e=>{e.stopPropagation(),!r&&i(t,n?`unexpose`:`expose`)},"aria-label":n?a(`uiLibrary.deviceExport.unexposeDevice`,`Unexpose {{name}}`,{name:o}):a(`uiLibrary.deviceExport.exposeDevice`,`Expose {{name}}`,{name:o}),title:n?a(`uiLibrary.deviceExport.stopTitle`,`Stop exposing to "{{addon}}"`,{addon:e}):a(`uiLibrary.deviceExport.exposeTitle`,`Expose to "{{addon}}"`,{addon:e}),children:n?c(P,{children:[v(we,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.deviceExport.exposed`,`Exposed`)]}):c(P,{children:[v(er,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.deviceExport.expose`,`Expose`)]})})}function Fae({outcome:e,onDismiss:t}){let n=q();return c(`div`,{"data-testid":`export-bulk-summary`,className:`flex flex-col gap-1 px-2 sm:px-4 py-2 border-b border-border text-[11px] ${e.failed.length===0?`text-foreground-subtle`:`text-danger`}`,children:[c(`div`,{className:`flex items-center justify-between gap-2`,children:[v(`span`,{className:`font-medium`,children:e.action===`expose`?n(`uiLibrary.deviceExport.bulkExposed`,{one:`Exposed {{done}} of {{count}} selected device.`,other:`Exposed {{done}} of {{count}} selected devices.`},{done:e.succeeded.length,count:e.total}):n(`uiLibrary.deviceExport.bulkUnexposed`,{one:`Unexposed {{done}} of {{count}} selected device.`,other:`Unexposed {{done}} of {{count}} selected devices.`},{done:e.succeeded.length,count:e.total})}),v(_A,{size:`sm`,variant:`ghost`,onClick:t,"aria-label":n(`uiLibrary.deviceExport.dismissAria`,`Dismiss export result`),children:n(`uiLibrary.deviceExport.dismiss`,`Dismiss`)})]}),e.succeeded.length>0&&v(`span`,{className:`text-foreground-subtle`,children:n(`uiLibrary.deviceExport.succeeded`,`Succeeded: {{devices}}`,{devices:e.succeeded.join(`, `)})}),e.failed.map(e=>v(`span`,{children:n(`uiLibrary.deviceExport.failed`,`Failed: {{device}} — {{message}}`,{device:e.label,message:e.message})},e.label))]})}function l6({addonId:e,onOpenDevice:t,showSetup:n=!0}){let r=q(),i=k(),a=ip({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),o=op({nodeId:`hub`,addonId:e},{refetchInterval:i6,retry:!1}),s=ap({nodeId:`hub`,addonId:e},{retry:!1}),l=dm({projection:`slim`},{refetchInterval:kae}),u=_(()=>{i.invalidateQueries({queryKey:[[`deviceExport`]]})},[i]),d=sp({onSuccess:u}),f=cp({onSuccess:u}),m=p(()=>s6(a.data),[a.data]),h=p(()=>{let e=Tae.safeParse(o.data);return e.success?e.data:[]},[o.data]),g=p(()=>new Set(h.map(e=>e.deviceId)),[h]),y=p(()=>{let e=Dae.safeParse(s.data);return new Set(e.success?e.data:[])},[s.data]),b=p(()=>[...y].toSorted(),[y]),x=p(()=>b.map(e=>{let t=Yo(e,r);return{id:e,label:t.label,icon:t.icon}}),[b,r]),S=p(()=>{let e=l.data;if(!Array.isArray(e))return[];let t=[];for(let n of e){let e=Eae.safeParse(n);e.success&&y.has(e.data.type)&&t.push(e.data)}return t},[l.data,y]),w=m?.linkState??`unlinked`,T=a.isLoading||o.isLoading||s.isLoading||l.isLoading,E=m?.exposedDeviceCount??g.size,D=d.isPending||f.isPending,[O,A]=C(()=>new Set),[j,M]=C(null),[N,F]=C(!1),I=_(e=>{A(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),L=_(()=>A(new Set),[]),R=_(()=>M(null),[]),z=_(e=>S.find(t=>String(t.id)===e)?.name??`#${e}`,[S]),B=_(async(t,n)=>{if(n.length===0||N)return;F(!0),M(null);let r=[],i=[],a=t===`expose`?d:f;(await Promise.allSettled(n.map(t=>a.mutateAsync({deviceId:t,nodeId:`hub`,addonId:e})))).forEach((a,o)=>{let s=n[o]??``,c=z(s);if(a.status===`fulfilled`){r.push(c);return}let l=a.reason instanceof Error?a.reason.message:String(a.reason);console.error(`[device-export] ${t} failed`,{tags:{deviceId:Number.parseInt(s,10)},addonId:e,error:l}),i.push({label:c,message:l})}),M({action:t,total:n.length,succeeded:r,failed:i}),A(new Set),F(!1)},[e,d,f,z,N]),[V,H]=C(yae),U=p(()=>xae(S),[S]),ee=p(()=>Sae(S),[S]),W=p(()=>bae(S,V),[S,V]),G=_(e=>H(t=>({...t,roles:e})),[]),te=_(e=>H(t=>({...t,providers:e})),[]),ne=p(()=>[...O],[O]),re=_(()=>{B(`expose`,ne)},[B,ne]),K=_(()=>{B(`unexpose`,ne)},[B,ne]),ie=_((e,t)=>{B(t,[String(e.id)])},[B]),ae=_(e=>t?.(String(e.id)),[t]),oe=_(e=>String(e.id),[]),se=_(e=>`${e.name} ${e.stableId}`,[]),ce=_(e=>e.type,[]),le=p(()=>[{key:`select`,header:``,headerClassName:`w-8`,cell:e=>v(Nae,{device:e,checked:O.has(String(e.id)),onToggle:()=>I(String(e.id))})},{key:`type`,header:r(`uiLibrary.deviceExport.colType`,`Type`),headerClassName:`w-32`,cell:e=>{let t=Yo(e.type,r),n=t.icon;return c(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[v(n,{className:`h-3.5 w-3.5 shrink-0`}),t.label]})}},{key:`name`,header:r(`uiLibrary.deviceExport.colName`,`Name`),cell:e=>v(bj,{device:e,form:`compact`,className:`text-xs font-medium text-foreground`})},{key:`export`,header:r(`uiLibrary.deviceExport.colExport`,`Export`),headerClassName:`w-32 text-right`,cellClassName:`text-right`,cell:t=>v(Pae,{addonId:e,device:t,exposed:g.has(String(t.id)),busy:D,onToggle:ie})}],[e,D,g,ie,O,I,r]),ue=_(({filtered:e})=>c(`span`,{className:`inline-flex flex-wrap items-center gap-1.5`,children:[v(AG,{label:r(`uiLibrary.deviceExport.filterRole`,`Role`),options:U,selected:V.roles,onChange:G}),v(AG,{label:r(`uiLibrary.deviceExport.filterProvider`,`Provider`),options:ee,selected:V.providers,onChange:te}),v(_A,{size:`sm`,variant:`secondary`,disabled:e.length===0,onClick:()=>A(t=>Cae(t,e)),children:r(`uiLibrary.deviceExport.selectShown`,`Select {{count}} shown`,{count:e.length})}),O.size>0&&c(P,{children:[v(_A,{size:`sm`,variant:`ghost`,onClick:()=>A(t=>wae(t,e)),children:r(`uiLibrary.deviceExport.deselectShown`,`Deselect shown`)}),v(`span`,{"data-testid":`export-selection-count`,className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.deviceExport.selected`,`{{count}} selected`,{count:O.size})}),v(_A,{size:`sm`,variant:`primary`,disabled:D,onClick:re,children:r(`uiLibrary.deviceExport.exposeN`,`Expose {{count}}`,{count:O.size})}),v(_A,{size:`sm`,variant:`secondary`,disabled:D,onClick:K,children:r(`uiLibrary.deviceExport.unexposeN`,`Unexpose {{count}}`,{count:O.size})}),v(_A,{size:`sm`,variant:`ghost`,onClick:L,children:r(`uiLibrary.deviceExport.clear`,`Clear`)})]})]}),[r,U,ee,V,G,te,O.size,D,re,K,L]),de=b.length>0;return c(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[c(`div`,{className:`flex items-center justify-between gap-3 px-2 sm:px-4 py-2.5 border-b border-border bg-surface-hover/20`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(er,{className:`h-3.5 w-3.5 text-foreground-subtle shrink-0`}),v(`span`,{className:`text-[11px] font-semibold text-foreground-subtle uppercase tracking-wide`,children:r(`uiLibrary.deviceExport.title`,`Exported devices`)}),v(Bk,{variant:Aae(w),children:jae(r,w)}),v(`span`,{className:`text-[11px] text-foreground-subtle`,children:r(`uiLibrary.deviceExport.exposedCount`,`{{count}} exposed`,{count:E})})]}),T&&v(Gn,{className:`h-3.5 w-3.5 animate-spin text-foreground-subtle`})]}),n&&m?.error&&v(`div`,{className:`px-2 sm:px-4 py-3 border-b border-border`,children:v(eN,{message:m.error})}),n&&m?.setup&&v(o6,{setup:m.setup}),j!==null&&v(Fae,{outcome:j,onDismiss:R}),v(`div`,{className:`p-2 sm:p-3`,children:T&&S.length===0?c(`div`,{className:`flex items-center gap-2 px-1 py-6 text-xs text-foreground-subtle`,children:[v(Gn,{className:`h-3.5 w-3.5 animate-spin`}),r(`uiLibrary.deviceExport.loading`,`Loading exportable devices…`)]}):de&&S.length>0?v(t6,{mode:`generic`,items:W,getKey:oe,getSearchText:se,getFilterType:ce,filterOptions:x,columns:le,onRowClick:t?ae:void 0,toolbar:ue,pageSizeSelector:Oae,searchPlaceholder:r(`uiLibrary.deviceExport.search`,`Search by name or stableId`),emptyLabel:r(`uiLibrary.deviceExport.noMatch`,`No device matches this search.`)}):v(QM,{icon:er,title:r(`uiLibrary.deviceExport.emptyTitle`,`No exportable devices`),description:de?r(`uiLibrary.deviceExport.emptyKinds`,`No devices of the supported kinds ({{kinds}}) are available to expose to "{{addon}}".`,{kinds:b.join(`, `),addon:e}):r(`uiLibrary.deviceExport.emptyNoKinds`,`"{{addon}}" reports no exportable device kinds yet.`,{addon:e})})})]})}function Iae({children:e,minCardWidth:t=220,gap:n=3,className:r}){return v(`div`,{className:$(`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})}E();function u6(e){let t=e.replaceAll(`-`,` `);return t.charAt(0).toUpperCase()+t.slice(1)}function d6(e){return e.kind}function Lae(e){switch(e){case`all`:return{kind:`all`};case`types`:return{kind:`types`,types:[]};case`locations`:return{kind:`locations`,locations:[]};case`ids`:return{kind:`ids`,ids:[]}}}function f6({value:e,onChange:t,includeLinked:n,onIncludeLinkedChange:r,clampToDeviceIds:i,dense:a=!1}){let o=q(),{data:s}=dm({}),[l,u]=C(``),d=f(null);As(d);let m=p(()=>{let e=(s??[]).map(e=>({id:e.id,name:e.name,type:e.type,location:e.location,parentDeviceId:e.parentDeviceId}));if(i==null)return e;let t=new Set(i);return e.filter(e=>t.has(e.id))},[s,i]),h=p(()=>{let t=new Map;for(let e of m)t.set(e.type,(t.get(e.type)??0)+1);if(e.kind===`types`)for(let n of e.types)t.has(n)||t.set(n,0);return[...t.entries()].map(([e,t])=>({value:e,label:u6(e),count:t})).sort((e,t)=>e.label.localeCompare(t.label))},[m,e]),g=p(()=>{let t=new Map;for(let e of m)e.location===null||e.location.length===0||t.set(e.location,(t.get(e.location)??0)+1);if(e.kind===`locations`)for(let n of e.locations)t.has(n)||t.set(n,0);return[...t.entries()].map(([e,t])=>({value:e,label:e,count:t})).sort((e,t)=>e.label.localeCompare(t.label))},[m,e]),_=g.length>0,y=p(()=>{let e=l.trim().toLowerCase();return[...e.length===0?m:m.filter(t=>t.name.toLowerCase().includes(e)||String(t.id).includes(e)||(t.location??``).toLowerCase().includes(e))].sort((e,t)=>e.name.localeCompare(t.name))},[m,l]),b=d6(e),x=[{id:`all`,label:o(`uiLibrary.deviceSelectorPicker.tabAll`,`All`)},{id:`types`,label:o(`uiLibrary.deviceSelectorPicker.tabTypes`,`By type`)},..._||b===`locations`?[{id:`locations`,label:o(`uiLibrary.deviceSelectorPicker.tabRooms`,`By room`)}]:[],{id:`ids`,label:o(`uiLibrary.deviceSelectorPicker.tabChosen`,`Chosen`)}],S=n=>{let r=e.kind===`types`?e.types:[];t({kind:`types`,types:r.some(e=>String(e)===n)?r.filter(e=>String(e)!==n):[...r,...Rae(n)]})},w=n=>{let r=e.kind===`locations`?e.locations:[];t({kind:`locations`,locations:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},T=n=>{let r=e.kind===`ids`?e.ids:[];t({kind:`ids`,ids:r.includes(n)?r.filter(e=>e!==n):[...r,n]})},E=a?`p-2`:`p-3`;return c(`div`,{className:`space-y-2`,children:[v(`div`,{className:`flex flex-wrap gap-1 border-b border-border pb-1`,children:x.map(e=>v(`button`,{type:`button`,onClick:()=>t(Lae(e.id)),className:`shrink-0 whitespace-nowrap rounded px-2 py-1 text-[11px] transition-colors ${b===e.id?`bg-primary/15 text-primary font-medium`:`text-foreground-subtle hover:bg-foreground-subtle/10 hover:text-foreground`}`,children:e.label},e.id))}),b===`all`&&c(`div`,{className:`rounded border border-border bg-surface ${E}`,children:[v(`p`,{className:`text-[11px] text-foreground`,children:o(`uiLibrary.deviceSelectorPicker.everyDevice`,`Every device in this deployment — {{count}} right now.`,{count:m.length})}),v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:o(`uiLibrary.deviceSelectorPicker.laterCovered`,`Devices added later are covered automatically.`)})]}),b===`types`&&v(p6,{options:h,selected:e.kind===`types`?e.types.map(e=>String(e)):[],onToggle:S,emptyLabel:o(`uiLibrary.deviceSelectorPicker.noTypes`,`No devices to pick a type from.`),footnote:o(`uiLibrary.deviceSelectorPicker.typesFootnote`,`Devices of a checked type are covered automatically as they are added.`),pad:E}),b===`locations`&&v(p6,{options:g,selected:e.kind===`locations`?[...e.locations]:[],onToggle:w,emptyLabel:o(`uiLibrary.deviceSelectorPicker.noRooms`,`No device has a room assigned yet.`),footnote:o(`uiLibrary.deviceSelectorPicker.roomsFootnote`,`A device with no room set is never covered by a room rule.`),pad:E}),b===`ids`&&c(`div`,{className:`rounded border border-border bg-surface ${E} space-y-2`,children:[c(`div`,{className:`relative`,children:[v(Ci,{className:`pointer-events-none absolute left-2 top-1/2 h-3 w-3 -translate-y-1/2 text-foreground-subtle`}),v(`input`,{ref:d,type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:o(`uiLibrary.deviceSelectorPicker.search`,`Search devices…`),className:`w-full rounded border border-border bg-background py-1 pl-7 pr-2 text-[11px] text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),c(`div`,{className:`max-h-56 overflow-auto rounded border border-border`,children:[y.length===0&&v(`p`,{className:`px-2 py-3 text-[10px] italic text-foreground-subtle`,children:o(`uiLibrary.deviceSelectorPicker.noMatch`,`No device matches.`)}),y.map(t=>c(`label`,{className:`flex cursor-pointer items-center gap-2 px-2 py-1.5 text-[11px] hover:bg-foreground-subtle/10`,children:[v(`input`,{type:`checkbox`,checked:e.kind===`ids`&&e.ids.includes(t.id),onChange:()=>T(t.id),className:`rounded border-border focus:ring-primary`}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.name}),c(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:[`#`,t.id,t.location!==null&&t.location.length>0?` · ${t.location}`:``]})]},t.id))]}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:v(gi,{uiKey:`uiLibrary.deviceSelectorPicker.fixedList`,fallback:`A fixed list — a device added later is <0>not</0> covered until you edit this.`,components:[v(`span`,{className:`font-medium`},`n`)]})})]}),n!==void 0&&r!==void 0&&v(zae,{value:n,onChange:r,pad:E})]})}function Rae(e){return Object.values(J).filter(t=>String(t)===e)}function p6({options:e,selected:t,onToggle:n,emptyLabel:r,footnote:i,pad:a}){return c(`div`,{className:`rounded border border-border bg-surface ${a} space-y-2`,children:[e.length===0?v(`p`,{className:`text-[10px] italic text-foreground-subtle`,children:r}):v(`div`,{className:`grid max-h-56 grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-1 overflow-auto`,children:e.map(e=>c(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1.5 py-1 text-[11px] hover:bg-foreground-subtle/10`,children:[v(`input`,{type:`checkbox`,checked:t.includes(e.value),onChange:()=>n(e.value),className:`rounded border-border focus:ring-primary`}),v(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.label}),v(`span`,{className:`shrink-0 font-mono text-[10px] text-foreground-subtle`,children:e.count})]},e.value))}),v(`p`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}function zae({value:e,onChange:t,pad:n}){let r=q();return v(`div`,{className:`rounded border border-border bg-surface ${n}`,children:c(`label`,{className:`flex cursor-pointer items-start gap-2`,children:[v(`input`,{type:`checkbox`,checked:e,onChange:e=>t(e.target.checked),className:`mt-0.5 rounded border-border focus:ring-primary`}),c(`span`,{className:`min-w-0`,children:[c(`span`,{className:`flex items-center gap-1.5 text-[11px] font-medium text-foreground`,children:[v(tr,{className:`h-3 w-3`}),r(`uiLibrary.deviceSelectorPicker.includeLinked`,`Include linked devices`)]}),v(`span`,{className:`mt-0.5 block text-[10px] text-foreground-subtle`,children:e?v(P,{children:r(`uiLibrary.deviceSelectorPicker.linkedOn`,`Accessories attached to a granted camera — siren, floodlight, PIR — are covered too.`)}):v(P,{children:v(gi,{uiKey:`uiLibrary.deviceSelectorPicker.linkedOff`,fallback:`Only the devices selected above. An operator granted a camera will <0>not</0> be able to trigger the siren or light attached to it.`,components:[v(`span`,{className:`font-medium text-foreground`},`n`)]})})})]})]})})}function m6(e,t=Fn){switch(e.kind){case`all`:return t(`uiLibrary.deviceSelectorPicker.allDevices`,`All devices`);case`ids`:return e.ids.length===0?t(`uiLibrary.deviceSelectorPicker.noDevice`,`No device chosen`):t(`uiLibrary.deviceSelectorPicker.deviceCount`,{one:`{{count}} device`,other:`{{count}} devices`},{count:e.ids.length});case`types`:return e.types.length===0?t(`uiLibrary.deviceSelectorPicker.noType`,`No type chosen`):e.types.map(e=>u6(String(e))).join(`, `);case`locations`:return e.locations.length===0?t(`uiLibrary.deviceSelectorPicker.noRoom`,`No room chosen`):e.locations.join(`, `)}}function h6(e){return e.deviceKey===void 0?e.agentNodeId:`${e.agentNodeId}::${e.deviceKey}`}function g6(e){let t=[];for(let n of e){let e=t[t.length-1];if(e&&e.agentNodeId===n.agentNodeId){let r=[...e.columns,n];t[t.length-1]={...e,columns:r,grouped:r.length>1}}else t.push({agentNodeId:n.agentNodeId,engineLabel:n.engineLabel,columns:[n],grouped:!1})}return t}function Bae(e){let t=[],n=(e,r)=>{for(let i of e)t.push({node:i,depth:r}),n(i.children,r+1)};return n(e,0),t}function _6(e,t,n,r=208,i=t){return e<=0?!1:t<=1?e<n+r*i:e<n+r*2}var v6={detector:{labelKey:`uiLibrary.pipelineMatrix.slotDetector`,labelFallback:`detector`,className:`text-emerald-500`},cropper:{labelKey:`uiLibrary.pipelineMatrix.slotCropper`,labelFallback:`cropper`,className:`text-blue-500`},classifier:{labelKey:`uiLibrary.pipelineMatrix.slotClassifier`,labelFallback:`classifier`,className:`text-violet-500`},refiner:{labelKey:`uiLibrary.pipelineMatrix.slotRefiner`,labelFallback:`refiner`,className:`text-amber-500`},"audio-classifier":{labelKey:`uiLibrary.pipelineMatrix.slotAudioClassifier`,labelFallback:`audio classifier`,className:`text-pink-500`}};function Vae({slot:e}){let t=q(),n=v6[e]??v6.classifier;return v(`span`,{className:$(`text-[9px] font-semibold uppercase tracking-widest leading-none`,n.className),children:t(n.labelKey,n.labelFallback)})}var y6=`inline-flex items-center rounded bg-muted px-1.5 py-px text-[9px] font-medium text-foreground-subtle`;function Hae({inputs:e,outputs:t}){return e.length===0&&t.length===0?null:c(`span`,{className:`inline-flex items-center gap-1 flex-wrap`,children:[e.map(e=>v(`span`,{className:$(y6,`bg-blue-500/10 text-blue-500`),children:e},`in-${e}`)),e.length>0&&t.length>0&&v(`span`,{className:`text-foreground-subtle/60 text-[9px]`,children:`→`}),t.map(e=>v(`span`,{className:$(y6,`bg-emerald-500/10 text-emerald-500`),children:e},`out-${e}`))]})}function b6({column:e}){let t=q(),n=e.deviceLabel??e.deviceKey;return c(P,{children:[(n!==void 0||e.disabled===!0)&&c(`div`,{className:`flex min-w-0 items-center gap-1`,children:[n!==void 0&&v(`span`,{className:`truncate text-[10px] font-medium text-foreground/90`,children:n}),e.disabled===!0&&v(`span`,{className:`shrink-0 rounded bg-muted px-1 text-[8px] font-semibold uppercase text-foreground-subtle`,children:t(`uiLibrary.pipelineMatrixShared.offWord`,`off`)})]}),v(`div`,{className:`truncate text-[9px] text-foreground-subtle`,children:e.engineLabel}),e.detail!==void 0&&v(`div`,{className:`truncate font-mono text-[9px] text-foreground-subtle`,title:e.detail,children:e.detail})]})}function Uae({group:e}){let t=e.columns[0]?.nodeLabel??e.agentNodeId;return c(`div`,{role:`columnheader`,className:`sticky top-0 z-10 min-w-0 border-b border-l border-border bg-muted/60`,style:{gridColumn:`span ${e.columns.length}`},children:[v(`div`,{className:`truncate px-3 pt-2 pb-1 text-xs font-semibold text-foreground`,children:t}),v(`div`,{className:`mt-1 flex border-t border-border/50`,children:e.columns.map((e,t)=>v(`div`,{className:$(`min-w-0 flex-1 px-3 py-1`,t>0&&`border-l border-border/50`,e.disabled===!0&&`opacity-70`),title:`${e.deviceLabel??e.deviceKey} · ${e.engineLabel}${e.detail?` · ${e.detail}`:``}`,children:v(b6,{column:e})},h6(e)))})]})}function Wae({node:e}){return c(`div`,{className:`flex flex-col gap-1 min-w-0 flex-1`,children:[v(Vae,{slot:e.slot}),c(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[v(`span`,{className:`font-semibold truncate`,children:e.addonName}),v(Hae,{inputs:e.inputClasses,outputs:e.outputClasses})]})]})}function Gae(e,t){return t.kind===`enabled`?c(`span`,{className:`flex min-w-0 items-center gap-1`,title:t.overridden?e(`uiLibrary.pipelineMatrix.override`,`override`):void 0,children:[v(`span`,{className:$(`h-1.5 w-1.5 rounded-full shrink-0`,t.overridden?`bg-amber-500`:`bg-emerald-500`)}),v(`span`,{className:`font-mono text-foreground truncate`,children:t.modelId}),t.suppliedByRoot!==void 0&&v(`span`,{className:`ml-auto shrink-0 truncate rounded bg-primary/10 px-1 text-[8px] font-semibold uppercase text-primary`,title:e(`uiLibrary.pipelineMatrix.rootModelTitle`,`Uses the root model {{model}} — this step's own model does not run here`,{model:t.suppliedByRoot}),children:e(`uiLibrary.pipelineMatrix.root`,`root`)}),t.clusterWide===!0&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-primary`,title:e(`uiLibrary.pipelineMatrix.clusterTitle`,`One value for the whole cluster — this step writes into a shared vector index`),children:e(`uiLibrary.pipelineMatrix.cluster`,`cluster`)}),t.jumpTo!==void 0&&c(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold text-sky-500`,title:e(`uiLibrary.pipelineMatrix.runsOn`,`runs on {{target}}`,{target:t.jumpTo}),children:[`→ `,t.jumpTo]}),t.overridden&&t.jumpTo===void 0&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-amber-500`,children:e(`uiLibrary.pipelineMatrix.ovr`,`ovr`)})]}):t.kind===`disabled`?c(`span`,{className:`flex min-w-0 items-center gap-1 text-foreground-subtle`,title:t.overridden?e(`uiLibrary.pipelineMatrix.override`,`override`):void 0,children:[v(`span`,{className:$(`h-1.5 w-1.5 rounded-full shrink-0`,t.overridden?`bg-amber-500`:`border border-foreground-subtle/60`)}),v(`span`,{className:`truncate`,children:e(`uiLibrary.pipelineMatrix.off`,`off`)}),t.overridden&&v(`span`,{className:`ml-auto shrink-0 text-[8px] font-semibold uppercase text-amber-500`,children:e(`uiLibrary.pipelineMatrix.ovr`,`ovr`)})]}):t.kind===`skip`?t.jumpTo===void 0?c(`span`,{className:`flex min-w-0 items-center gap-1 text-amber-500`,title:e(`uiLibrary.pipelineMatrix.skipTitle`,`Gated on for this camera, but no compatible model on this node — click to provision`),children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-amber-500 shrink-0`}),v(`span`,{className:`truncate font-medium`,children:e(`uiLibrary.pipelineMatrix.skip`,`⚠ skip`)})]}):c(`span`,{className:`flex min-w-0 items-center gap-1 text-sky-500`,title:e(`uiLibrary.pipelineMatrix.autoJump`,`no build for this device — auto-jumps to {{target}}`,{target:t.jumpTo}),children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-sky-500 shrink-0`}),c(`span`,{className:`truncate font-medium`,children:[`→ `,t.jumpTo]})]}):c(`span`,{className:`flex min-w-0 items-center gap-1 text-foreground-subtle/70`,children:[v(`span`,{className:`h-1.5 w-1.5 rounded-full bg-muted shrink-0`}),v(`span`,{className:`truncate`,children:`—`})]})}function Kae(e,t,n){return $(`text-left text-xs hover:bg-muted/40`,e.kind===`enabled`&&`bg-emerald-500/5`,e.kind===`skip`&&`bg-amber-500/5`,e.kind===`na`&&`bg-muted/30`,t&&`ring-2 ring-primary ring-inset`,n)}E();var x6=18,qae=x6*16,Jae=11;function S6(e,t,n,r){let i=(e,t)=>({r:Math.max(0,Math.min(n-1,e)),c:Math.max(0,Math.min(r-1,t))});switch(e){case`ArrowRight`:return i(t.r,t.c+1);case`ArrowLeft`:return i(t.r,t.c-1);case`ArrowDown`:return i(t.r+1,t.c);case`ArrowUp`:return i(t.r-1,t.c);case`Home`:return i(t.r,0);case`End`:return i(t.r,r-1);case`PageDown`:return i(n-1,t.c);case`PageUp`:return i(0,t.c);default:return null}}function Yae({node:e,depth:t,r:n,tabbable:r,selected:i,badge:a,onClick:o,sticky:s}){return v(`div`,{role:`rowheader`,className:$(`min-w-0 border-b border-border bg-surface`,s&&`sticky left-0 z-10`),children:c(`button`,{type:`button`,"data-r":n,"data-c":0,"data-step":e.addonId,"data-col":``,tabIndex:r?0:-1,"aria-current":i?`true`:void 0,onClick:o?e=>o(e.detail===0):void 0,className:$(`flex h-full w-full min-w-0 items-start gap-2 px-3 py-2 text-left text-xs outline-none`,`hover:bg-muted/40 focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,i&&`bg-primary/10 shadow-[inset_3px_0_0_var(--color-primary)]`),style:{paddingLeft:`${12+t*14}px`},children:[v(Wae,{node:e}),a]})})}function Xae({nodes:e,selected:t,onSelect:n}){let r=q();return c(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`tablist`,"aria-label":r(`uiLibrary.deviceStepMatrix.node`,`Node`),children:[v(_n,{className:`h-3.5 w-3.5 text-foreground-subtle`}),v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:r(`uiLibrary.deviceStepMatrix.node`,`Node`)}),v(`div`,{className:`flex overflow-hidden rounded-md border border-border text-[11px] font-medium`,children:e.map((e,r)=>{let i=e.agentNodeId===t;return v(`button`,{type:`button`,role:`tab`,"aria-selected":i,onClick:()=>n(e.agentNodeId),title:`${e.columns[0]?.nodeLabel??e.agentNodeId} · ${e.engineLabel}`,className:$(`px-2.5 py-1 transition-colors`,i?`bg-primary/15 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,r>0&&`border-l border-border`),children:e.columns[0]?.nodeLabel??e.agentNodeId},e.agentNodeId)})})]})}var Zae=D(function({tree:e,agents:t,getCellState:n,onCellClick:r,onStepClick:i,stepBadge:a,selectedCell:o,single:s,reserveRightPx:l,label:d},m){let h=q(),g=p(()=>Bae(e),[e]),_=p(()=>g6(t),[t]),y=f(null),S=s?Jae:x6,w=`${S}rem repeat(${t.length}, 13rem)`,T=t.length+1,[E,D]=C(!0);u(()=>{let e=y.current;if(!e||l<=0){D(!0);return}let t=()=>{let t=e.getBoundingClientRect().left;D(window.innerWidth-l-t>=S*16+208+24)};return t(),window.addEventListener(`resize`,t),()=>window.removeEventListener(`resize`,t)},[l,S]);let O=p(()=>{if(o===null)return null;let e=g.findIndex(e=>e.node.addonId===o.addonId);if(e<0)return null;let n=t.findIndex(e=>h6(e)===h6(o));return{r:e,c:n<0?0:n+1}},[o,g,t]),[k,A]=C({r:0,c:0});b(()=>{O!==null&&A(O)},[O]);let j=k.r<g.length&&k.c<T?k:{r:0,c:0},M=(e,t)=>{y.current?.querySelector(`[data-r="${e}"][data-c="${t}"]`)?.focus()};return x(m,()=>({focusCell:(e,n)=>{let r=g.findIndex(t=>t.node.addonId===e);if(r<0)return;let i=n===null?-1:t.findIndex(e=>h6(e)===n),a=i<0?0:i+1;A({r,c:a}),M(r,a)}}),[g,t]),u(()=>{if(O===null)return;let e=y.current,t=e?.querySelector(`[data-r="${O.r}"][data-c="${O.c}"]`);if(!e||!t||(typeof t.scrollIntoView==`function`&&t.scrollIntoView({block:`nearest`,inline:`nearest`}),l<=0))return;let n=window.innerWidth-l-12,r=t.getBoundingClientRect().right;r>n&&(e.scrollLeft+=r-n)},[O,l,E]),v(`div`,{ref:y,className:`overflow-auto rounded border border-border`,children:c(`div`,{className:`flex w-max`,children:[c(`div`,{role:`grid`,"aria-label":d,"aria-rowcount":g.length+1,className:`grid w-max`,style:{gridTemplateColumns:w},onKeyDown:e=>{if(!(e.target instanceof HTMLElement)||e.target.dataset.r===void 0)return;let t={r:Number(e.target.dataset.r),c:Number(e.target.dataset.c)},n=S6(e.key,t,g.length,T);n!==null&&(e.preventDefault(),A(n),M(n.r,n.c))},children:[c(`div`,{role:`row`,className:`contents`,children:[v(`div`,{role:`columnheader`,className:$(`top-0 z-20 border-b border-border bg-muted/60 px-3 py-2 text-[10px] uppercase tracking-widest text-foreground-subtle`,E?`sticky left-0`:`sticky`),children:h(`uiLibrary.deviceStepMatrix.step`,`Step`)}),_.map(e=>e.grouped?v(Uae,{group:e},e.agentNodeId):e.columns.map(e=>c(`div`,{role:`columnheader`,className:$(`sticky top-0 z-10 min-w-0 border-b border-l border-border bg-muted/60 px-3 py-2`,e.disabled===!0&&`opacity-70`),children:[v(`div`,{className:`truncate text-xs font-semibold text-foreground`,children:e.nodeLabel??e.agentNodeId}),v(b6,{column:e})]},h6(e))))]}),g.map(({node:e,depth:s},l)=>c(`div`,{role:`row`,className:`contents`,children:[v(Yae,{node:e,depth:s,r:l,tabbable:j.r===l&&j.c===0,selected:o?.addonId===e.addonId,badge:a?.(e.addonId),onClick:i?t=>i(e.addonId,t):void 0,sticky:E}),t.map((t,i)=>{let a=n(e.addonId,t),s=o!==null&&o.addonId===e.addonId&&h6(o)===h6(t),c=a.kind===`enabled`||a.kind===`skip`;return v(`div`,{role:`gridcell`,className:`min-w-0 border-b border-l border-border`,children:v(`button`,{type:`button`,"data-r":l,"data-c":i+1,"data-step":e.addonId,"data-col":h6(t),tabIndex:j.r===l&&j.c===i+1?0:-1,"aria-disabled":!c,"aria-selected":s,onClick:n=>{c&&r(e.addonId,t,n.detail===0)},className:Kae(a,s,$(`h-full w-full min-w-0 overflow-hidden px-3 py-2 outline-none`,`focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-primary`,!c&&`cursor-default hover:bg-transparent`,t.disabled===!0&&`opacity-70`)),children:Gae(h,a)})},h6(t))})]},e.addonId))]}),l>0&&v(`div`,{"aria-hidden":!0,style:{width:l},className:`shrink-0`})]})})}),C6=D(function({tree:e,agents:t,getCellState:n,onCellClick:r,selectedCell:i,fallbackNodeId:a,onFallbackNodeChange:o,onStepClick:s,stepBadge:l,reserveRightPx:d=0,label:m=`Detection steps`},h){let g=f(null),[_,y]=C(0);u(()=>{let e=g.current;if(!e)return;let t=()=>y(e.getBoundingClientRect().width);t();let n=typeof ResizeObserver<`u`?new ResizeObserver(t):null;return n?.observe(e),()=>n?.disconnect()},[]);let x=p(()=>g6(t),[t]),S=_6(_,x.length,qae,208,t.length),w=p(()=>x.length===0?null:x.find(e=>e.agentNodeId===a)??x[0]??null,[x,a]),T=i?.agentNodeId;b(()=>{S&&T!==void 0&&T!==a&&o(T)},[S,T,a,o]);let E=S&&w?w.columns:t;return c(`div`,{ref:g,className:`w-full space-y-2`,children:[S&&w&&x.length>1&&v(Xae,{nodes:x,selected:w.agentNodeId,onSelect:o}),v(Zae,{ref:h,tree:e,agents:E,getCellState:n,onCellClick:r,onStepClick:s,stepBadge:l,selectedCell:i,single:S&&w!==null,reserveRightPx:d,label:m})]})});E();function w6({deviceId:e,className:t=``,onOpenChild:n}){let r=q(),i=X.useUtils(),a=X.deviceDiscovery.listDiscovered.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),o=X.deviceDiscovery.getStatus.useQuery({deviceId:e},{refetchInterval:1e4,retry:!1}),s=X.deviceDiscovery.refreshDiscovery.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e}),i.deviceDiscovery.getStatus.invalidate({deviceId:e})}}),l=X.deviceDiscovery.adoptDevice.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),u=X.deviceDiscovery.releaseDevice.useMutation({onSuccess:()=>{i.deviceDiscovery.listDiscovered.invalidate({deviceId:e})}}),[d,f]=C(null),{available:m,adopted:h}=p(()=>{let e=a.data??[],t=e=>typeof e.metadata.rtspChannel==`number`?e.metadata.rtspChannel:1/0,n=(e,n)=>{let r=t(e),i=t(n);return r===i?e.name.localeCompare(n.name):r-i};return{available:e.filter(e=>!e.alreadyAdopted).toSorted(n),adopted:e.filter(e=>e.alreadyAdopted).toSorted(n)}},[a.data]),g=o.data,_=g?.lastError??null,y=g?.lastDiscoveryAt??null;async function b(){await s.mutateAsync({deviceId:e}).catch(()=>{})}async function x(t){f(t.childNativeId);try{await l.mutateAsync({deviceId:e,childNativeId:t.childNativeId})}finally{f(null)}}async function S(t){if(t.adoptedDeviceId!=null){f(t.childNativeId);try{await u.mutateAsync({deviceId:e,childDeviceId:t.adoptedDeviceId})}finally{f(null)}}}return c(`div`,{className:`rounded-xl border border-border bg-surface ${t}`,children:[c(`div`,{className:`flex items-start justify-between gap-2 border-b border-border px-3 py-2 sm:px-5 sm:py-3`,children:[c(`div`,{className:`min-w-0`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:r(`uiLibrary.discoveryPanel.title`,`Discovered devices`)}),v(`p`,{className:`text-[11px] text-foreground-subtle`,children:v(gi,{uiKey:`uiLibrary.discoveryPanel.intro`,fallback:`Channels behind this hub. Click <0>Add</0> to promote a channel to a managed device, or <1>Remove</1> to detach.`,components:[v(`span`,{className:`font-medium`},`a`),v(`span`,{className:`font-medium`},`r`)]})})]}),c(`button`,{type:`button`,onClick:b,disabled:s.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:[s.isPending?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(_e,{className:`h-3.5 w-3.5`}),v(`span`,{className:`hidden sm:inline`,children:r(`uiLibrary.discoveryPanel.refresh`,`Refresh`)})]})]}),_?c(`div`,{className:`flex items-start gap-2 border-b border-border bg-destructive/10 px-5 py-2 text-[11px] text-destructive`,children:[v(zi,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),v(`span`,{children:r(`uiLibrary.discoveryPanel.refreshFailed`,`Last refresh failed: {{error}}`,{error:_})})]}):null,a.isLoading?v(`div`,{className:`flex items-center justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):m.length===0&&h.length===0?v(`div`,{className:`px-5 py-8 text-center text-xs text-foreground-subtle`,children:r(`uiLibrary.discoveryPanel.empty`,`No channels reported by the hub yet. Click Refresh to enumerate.`)}):c(P,{children:[m.length>0?v(T6,{title:r(`uiLibrary.discoveryPanel.available`,`Available to add`),count:m.length,tone:`primary`,children:m.map(e=>v(E6,{child:e,busy:d===e.childNativeId,onAdopt:x,onRelease:S,onOpenChild:n},e.childNativeId))}):null,h.length>0?v(T6,{title:r(`uiLibrary.discoveryPanel.adopted`,`Already adopted`),count:h.length,tone:`muted`,children:h.map(e=>v(E6,{child:e,busy:d===e.childNativeId,onAdopt:x,onRelease:S,onOpenChild:n},e.childNativeId))}):null]}),y==null?null:v(`div`,{className:`border-t border-border px-5 py-2 text-[10px] text-foreground-subtle`,children:r(`uiLibrary.discoveryPanel.lastRefreshed`,`Last refreshed {{when}}`,{when:new Date(y).toLocaleString()})})]})}function T6({title:e,count:t,tone:n,children:r}){return c(`div`,{className:`border-t border-border`,children:[c(`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:[v(`span`,{className:`font-semibold`,children:e}),v(`span`,{className:`font-mono`,children:t})]}),v(`div`,{className:`divide-y divide-border`,children:r})]})}function E6({child:e,busy:t,onAdopt:n,onRelease:r,onOpenChild:i}){let a=q();return c(`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:[c(`div`,{className:`min-w-0 flex-1`,children:[c(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[v(Qae,{status:e.status}),v(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),e.metadata.isDoorbell?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.doorbell`,`Doorbell`)}):null,e.metadata.isBattery?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.battery`,`Battery`)}):null,e.metadata.isMultifocal?v(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-foreground-subtle`,children:a(`uiLibrary.discoveryPanel.multifocal`,`Multifocal`)}):null]}),c(`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`?c(`span`,{children:[`ch `,v(`span`,{className:`font-mono`,children:e.metadata.rtspChannel})]}):null,e.metadata.model?v(`span`,{className:`truncate max-w-[160px]`,children:e.metadata.model}):null,e.metadata.uid?c(`span`,{className:`font-mono truncate max-w-[140px]`,children:[e.metadata.uid.slice(0,12),`…`]}):null]})]}),e.alreadyAdopted?c(`div`,{className:`flex items-center gap-2`,children:[i&&e.adoptedDeviceId!==null?c(`button`,{type:`button`,onClick:()=>i(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:a(`uiLibrary.discoveryPanel.openTitle`,`Open device detail`),children:[v(Je,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.open`,`Open`)]}):null,c(`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?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(Pe,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.remove`,`Remove`)]})]}):c(`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?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):v(Se,{className:`h-3.5 w-3.5`}),a(`uiLibrary.discoveryPanel.add`,`Add`)]})]})}function Qae({status:e}){let t=q();switch(e){case`online`:return c(`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:[v(An,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.online`,`online`)]});case`sleeping`:return c(`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:[v(St,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.sleeping`,`sleeping`)]});case`offline`:return c(`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:[v(Pt,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.offline`,`offline`)]});default:return c(`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:[v($n,{className:`h-2.5 w-2.5`}),` `,t(`uiLibrary.discoveryPanel.unknown`,`unknown`)]})}}function $ae(e,t){let n=Date.now()-e;return n<6e4?t(`uiLibrary.doorbellRecentPanel.justNow`,`just now`):n<36e5?t(`uiLibrary.doorbellRecentPanel.minutesAgo`,`{{count}}m ago`,{count:Math.floor(n/6e4)}):n<864e5?t(`uiLibrary.doorbellRecentPanel.hoursAgo`,`{{count}}h ago`,{count:Math.floor(n/36e5)}):t(`uiLibrary.doorbellRecentPanel.daysAgo`,`{{count}}d ago`,{count:Math.floor(n/864e5)})}function D6({history:e,limit:t=5,latestIsFresh:n,className:r}){let i=q();if(e.length===0)return null;let a=n?Yt:Bt,o=e.slice(0,t);return c(`div`,{className:$(`rounded-lg border border-border bg-surface px-3 py-2`,r),children:[c(`div`,{className:`flex items-center gap-2 mb-2`,children:[v(a,{className:$(`h-4 w-4 text-amber-400`,n&&`animate-pulse`)}),v(`span`,{className:`text-[11px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:i(`uiLibrary.doorbellRecentPanel.recentPresses`,`Recent presses`)}),v(`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})]}),v(`ul`,{className:`space-y-1`,children:o.map(e=>c(`li`,{className:`flex items-center justify-between text-[11px]`,title:new Date(e.timestamp).toLocaleString(),children:[v(`span`,{className:`text-foreground`,children:$ae(e.timestamp,i)}),v(`span`,{className:`text-foreground-subtle font-mono text-[10px]`,children:new Date(e.timestamp).toLocaleTimeString()})]},`${e.deviceId}-${e.timestamp}`))})]})}E();function eoe({filters:e,values:t,onChange:n,className:r}){let i=q(),a=dl(),[o,s]=C(!1),l=(e,r)=>{n({...t,[e]:r})},u=Object.values(t).filter(e=>e!==void 0&&e!==``).length;if(a){let n=e.find(e=>e.type===`search`),a=e.some(e=>e.type!==`search`);return c(`div`,{className:$(`flex items-center gap-2`,r),children:[n&&v(Bl,{placeholder:n.placeholder??i(`uiLibrary.filterBar.search`,`Search...`),value:t[n.key]??``,onChange:e=>l(n.key,e.target.value),searchHotkey:!0,leftSlot:v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),className:`flex-1`}),a&&c(P,{children:[c(`button`,{onClick:()=>s(!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:[v(zr,{className:`h-3.5 w-3.5`}),i(`uiLibrary.filterBar.filters`,`Filters`),u>0&&v(Bk,{variant:`info`,className:`ml-1 text-[10px] px-1 py-0`,children:u})]}),v(pl,{open:o,onClose:()=>s(!1),title:i(`uiLibrary.filterBar.filters`,`Filters`),children:v(`div`,{className:`flex flex-col gap-3`,children:e.filter(e=>e.type!==`search`).map(e=>{switch(e.type){case`select`:return c(`div`,{children:[v(`label`,{className:`text-xs text-foreground-muted mb-1 block`,children:e.label}),v(Yl,{options:e.options,value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),className:`w-full`})]},e.key);case`badge-toggle`:return v(`div`,{className:`flex items-center gap-1 flex-wrap`,children:e.options.map(n=>{let r=t[e.key]===n.value;return v(`button`,{type:`button`,onClick:()=>l(e.key,r?void 0:n.value),children:v(Bk,{variant:r?`info`:`default`,className:`cursor-pointer`,children:n.label})},n.value)})},e.key);default:return null}})})})]})]})}return v(`div`,{className:$(`flex items-center gap-2 flex-wrap`,r),children:e.map(e=>{switch(e.type){case`search`:return v(Bl,{placeholder:e.placeholder??i(`uiLibrary.filterBar.search`,`Search...`),value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),searchHotkey:!0,leftSlot:v(Ci,{className:`h-3 w-3 text-foreground-subtle`}),className:`w-48`},e.key);case`select`:return v(Yl,{options:e.options,value:t[e.key]??``,onChange:t=>l(e.key,t.target.value),className:`w-36`},e.key);case`badge-toggle`:return v(`div`,{className:`flex items-center gap-1`,children:e.options.map(n=>{let r=t[e.key]===n.value;return v(`button`,{type:`button`,onClick:()=>l(e.key,r?void 0:n.value),children:v(Bk,{variant:r?`info`:`default`,className:`cursor-pointer`,children:n.label})},n.value)})},e.key);default:return null}})})}function O6({label:e,description:t,error:n,required:r,children:i,orientation:a=`vertical`,className:o}){let s=a===`horizontal`;return c(`div`,{className:$(`flex gap-2`,s?`flex-row items-center justify-between`:`flex-col`,o),children:[c(`div`,{className:$(s?`flex-1`:``),children:[c(LB,{children:[e,r&&v(`span`,{className:`text-danger ml-0.5`,children:`*`})]}),t&&v(`p`,{className:`text-foreground-subtle text-xs mt-0.5`,children:t})]}),v(`div`,{className:$(s?`shrink-0`:``),children:i}),n&&v(`p`,{className:`text-danger text-xs`,children:n})]})}E();function k6({groups:e,onPick:t,emptyMessage:n}){let[r,i]=C(null),a=r===null?null:e.flatMap(e=>e.tiles).find(e=>e.key===r)??null;return c(`div`,{className:`space-y-4`,children:[e.length===0&&v(`p`,{className:`text-xs text-foreground-subtle`,children:n}),e.map(e=>c(`div`,{children:[v(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.label}),v(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.tiles.map(e=>c(`div`,{className:`relative`,children:[c(`button`,{type:`button`,"data-testid":e.testId,onClick:()=>t(e.key),className:`flex h-full w-full flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[e.icon,v(`span`,{className:`text-center font-medium text-foreground`,children:e.label})]}),e.detail!==void 0&&e.detailLabel!==void 0&&v(`div`,{className:`absolute top-1 right-1`,children:v(Rl,{type:`button`,variant:`ghost`,size:`sm`,icon:kn,"aria-label":e.detailLabel,onClick:()=>i(t=>t===e.key?null:e.key)})})]},e.key))})]},e.id)),a?.detail!==void 0&&v(pl,{open:!0,onClose:()=>i(null),children:a.detail})]})}function toe(e,t,n=Fn){return e.name!==void 0&&e.name.length>0?e.name:e.height!==void 0&&e.height>0?`${e.height}p`:e.bitrate!==void 0&&e.bitrate>0?`${Math.round(e.bitrate/1e3)} kbps`:n(`uiLibrary.hlsQuality.level`,`Level {{n}}`,{n:t+1})}function noe(e,t=Fn){return[{value:-1,label:t(`uiLibrary.hlsQuality.auto`,`Auto`)},...e.map((e,n)=>({value:n,label:toe(e,n,t)}))]}E();function roe(e){return{height:e.height>0?e.height:void 0,bitrate:e.bitrate>0?e.bitrate:void 0,name:e.name.length>0?e.name:void 0}}function A6({url:e,format:t=`hls`,authToken:n,posterUrl:r,autoPlay:i=!0,className:o,onQualityOptions:s,selectedLevel:l=-1}){let u=f(null),d=f(null),p=q(),m=f(p);m.current=p;let[h,g]=C(null),[_,y]=C(!0);return b(()=>{let r=u.current;if(!r||!e)return;g(null),y(!0),s?.([]);let o=()=>y(!1);if(r.addEventListener(`playing`,o),t===`mp4`){r.src=e;let t=()=>{i&&r.play().catch(()=>{})},n=()=>g(`Could not load this clip.`);return r.addEventListener(`loadedmetadata`,t),r.addEventListener(`error`,n),s?.([]),()=>{r.removeEventListener(`loadedmetadata`,t),r.removeEventListener(`error`,n),r.removeEventListener(`playing`,o),r.removeAttribute(`src`),r.load()}}if(!(`MediaSource`in window)&&r.canPlayType(`application/vnd.apple.mpegurl`)){r.src=e;let t=()=>{i&&r.play().catch(()=>{})};return r.addEventListener(`loadedmetadata`,t),r.addEventListener(`error`,()=>g(`Could not load this recording.`)),()=>{r.removeEventListener(`loadedmetadata`,t),r.removeEventListener(`playing`,o),r.removeAttribute(`src`),r.load()}}let c=!1;return a(async()=>{let{default:e}=await import(`./hls-IujbK-0_.js`);return{default:e}},[],import.meta.url).then(({default:t})=>{if(c)return;if(!t.isSupported()){r.canPlayType(`application/vnd.apple.mpegurl`)?(r.src=e,r.addEventListener(`loadedmetadata`,()=>{i&&r.play().catch(()=>{})}),r.addEventListener(`error`,()=>g(`Could not load this recording.`))):(y(!1),g(`HLS playback is not supported in this browser.`));return}let a=new t({enableWorker:!0,lowLatencyMode:!1,xhrSetup:e=>{e.withCredentials=!0,n&&e.setRequestHeader(`Authorization`,`Bearer ${n}`)}});d.current=a,a.loadSource(e),a.attachMedia(r),a.on(t.Events.MANIFEST_PARSED,(e,t)=>{let n=t.levels.map(roe);s?.(n.length>1?noe(n,m.current):[]),i&&r.play().catch(()=>{})}),a.on(t.Events.ERROR,(e,t)=>{t.fatal&&(y(!1),g(`Playback error (${t.type}).`))})}),()=>{c=!0,r.removeEventListener(`playing`,o),d.current?.destroy(),d.current=null}},[e,t,n,i,s]),b(()=>{let e=d.current;e!==null&&(e.currentLevel=l)},[l]),c(`div`,{className:`relative h-full w-full bg-black ${o??``}`,children:[v(`video`,{ref:u,controls:!0,playsInline:!0,className:`h-full w-full`,...r?{poster:r}:{}}),_&&!h?v(`div`,{className:`pointer-events-none absolute inset-0 flex items-center justify-center`,children:v(`div`,{className:`h-8 w-8 animate-spin rounded-full border-2 border-white/20 border-t-white/60`})}):null,h?v(`div`,{className:`absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-amber-400`,children:h}):null]})}function ioe({images:e,selectedFilename:t,uploadedName:n,onSelect:r,onUpload:i,className:a,accept:o=`image/*`,uploadLabel:s=`Upload...`}){return c(`div`,{className:`flex flex-wrap items-center gap-2 ${a??``}`,children:[e.map(e=>v(`button`,{onClick:()=>r(e.filename),className:`px-3 py-1.5 text-xs rounded-md border transition-colors ${t===e.filename?`bg-primary text-primary-foreground border-primary`:`bg-surface border-border text-foreground hover:border-primary/50`}`,children:e.id??e.filename.replace(/\.[^.]+$/,``)},e.filename)),v(`button`,{onClick:()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=o,e.addEventListener(`change`,()=>{let t=e.files?.[0];if(!t)return;let n=new FileReader;n.addEventListener(`load`,()=>{let e=n.result,r=e.split(`,`)[1];r&&i(r,t.name,e)}),n.readAsDataURL(t)}),e.click()},className:`px-3 py-1.5 text-xs rounded-md border border-border bg-surface text-foreground hover:bg-surface-hover transition-colors`,children:s}),n&&v(`span`,{className:`text-xs text-foreground-subtle`,children:n})]})}var j6=`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 aoe({runtime:e,backend:t,modelId:n,agentId:r=`hub`,runtimes:i,backends:a,models:o,agents:s=[],onRuntimeChange:l,onBackendChange:u,onModelChange:d,onAgentChange:f,layout:p=`grid`,className:m,showAgent:h=!1}){let g=q();return c(`div`,{className:`${p===`grid`?`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4`:p===`horizontal`?`flex flex-wrap items-end gap-4`:`space-y-3`} ${m??``}`,children:[h&&s.length>0&&c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.agent`,`Agent`)}),v(`select`,{value:r,onChange:e=>f?.(e.target.value),className:j6,children:s.map(e=>c(`option`,{value:e.id,children:[e.name,` (`,e.status,`)`]},e.id))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.runtime`,`Runtime`)}),v(`select`,{value:e,onChange:e=>{e.target.value===`python`&&l(`python`)},className:j6,children:i.map(e=>v(`option`,{value:e.value,disabled:!e.available,children:e.available?e.label:g(`uiLibrary.inferenceConfig.unavailable`,`{{label}} (unavailable)`,{label:e.label})},e.value))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.backend`,`Backend`)}),v(`select`,{value:t,onChange:e=>u(e.target.value),className:j6,children:a.map(e=>v(`option`,{value:e.id,disabled:!e.available,children:e.available?e.label:g(`uiLibrary.inferenceConfig.unavailable`,`{{label}} (unavailable)`,{label:e.label})},e.id))})]}),c(`label`,{className:`space-y-1`,children:[v(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:g(`uiLibrary.inferenceConfig.model`,`Model`)}),v(`select`,{value:n,onChange:e=>d(e.target.value),className:j6,children:o.length===0?v(`option`,{value:``,children:g(`uiLibrary.inferenceConfig.noModels`,`No compatible models`)}):o.map(e=>c(`option`,{value:e.id,children:[e.name,e.downloaded?` ✓`:``]},e.id))})]})]})}E();function M6({items:e,header:t,triggerClassName:n,title:r=`More actions`}){let[i,a]=C(!1),o=e.filter(e=>!e.hidden);return o.length===0?null:c(gl,{open:i,onOpenChange:a,children:[v(_l,{title:r,className:$(`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:v(Xr,{className:`h-4 w-4`})}),c(bl,{align:`end`,className:`min-w-[200px] p-1`,children:[t&&v(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:t}),v(`ul`,{className:`space-y-0.5`,children:o.map((e,t)=>c(`li`,{children:[e.separatorBefore&&t>0&&v(`div`,{className:`my-1 h-px bg-border`}),c(`button`,{type:`button`,disabled:e.disabled,onClick:()=>{e.disabled||(e.onClick(),a(!1))},className:$(`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`,e.danger?`text-foreground hover:bg-danger/10 hover:text-danger`:`text-foreground hover:bg-surface-hover`),children:[e.icon&&v(e.icon,{className:$(`h-3.5 w-3.5 shrink-0 mt-0.5`,e.danger&&`text-danger/80`)}),c(`span`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`block leading-tight`,children:e.label}),e.description&&v(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:e.description})]})]})]},e.id))})]})]})}E();function ooe(e,t={}){let{serverUrl:n=`https://localhost:4443`,title:r,rootId:i=`root`}=t,a=document.getElementById(i);if(!a){console.error(`[mountAddonPage] Element #${i} not found`);return}Ao(a).render(s(Ts,null,s(BJ,{serverUrl:n,title:r,children:({trpc:t,theme:n})=>s(e,{trpc:t,theme:{isDark:n.resolvedMode===`dark`},navigate:e=>{console.log(`[dev] navigate:`,e)}})})))}E();function N6({selectedNodeId:e,onSelect:t,label:n=`Node`,hideIcon:r=!1,alwaysShow:i=!1,allowOffline:a=!1}){let o=q(),{nodes:s}=Lo(),l=qS(void 0),u=p(()=>MV(l.data),[l.data]);return!i&&s.length<=1?null:c(`div`,{className:`flex h-7 items-center gap-1.5`,children:[!r&&v(_n,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),n?v(`span`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle`,children:n}):null,v(`div`,{className:`flex h-7 overflow-hidden rounded-md border border-border text-xs font-medium`,children:s.map((n,r)=>{let i=e===n.id,s=NV(u,n.id),c=!a&&!n.isOnline;return v(`button`,{type:`button`,onClick:()=>t(n.id),disabled:c,title:n.isOnline?n.name:o(`uiLibrary.nodePicker.offline`,`{{name}} (offline)`,{name:n.name}),className:$(`inline-flex h-7 items-center px-2.5 transition-colors`,i?$(AV(s),kV(s)):$(`bg-transparent hover:bg-surface-hover`,kV(s),!c&&`opacity-70 hover:opacity-100`),r>0&&`border-l border-border`,c&&`cursor-not-allowed opacity-50`),children:n.shortName},n.id)})})]})}function soe({title:e,subtitle:t,actions:n,className:r}){return c(`div`,{className:$(`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between`,r),children:[c(`div`,{className:`min-w-0`,children:[v(`h1`,{className:`text-lg font-semibold text-foreground`,children:e}),t!==void 0&&t!==``&&v(`p`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:t})]}),n!==void 0&&v(`div`,{className:`flex flex-wrap items-center gap-2`,children:n})]})}function P6({icon:e,title:t,subtitle:n,actions:r,nav:i,fill:a=!1,className:o,children:s}){let l=!!t||n!=null||r!=null,u=l||i!=null;return c(`div`,{className:$(`overflow-x-clip p-2 sm:p-4`,a?`flex h-full min-h-0 flex-col gap-4`:`space-y-4`,o),children:[u&&c(`div`,{className:`shrink-0 space-y-3`,children:[l&&c(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-4`,children:[c(`div`,{className:`min-w-0`,children:[t!==void 0&&t!==``&&c(`h1`,{className:`flex items-center gap-2 text-lg font-semibold text-foreground`,children:[e!==void 0&&v(e,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),t]}),n!=null&&v(`p`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:n})]}),r!=null&&v(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:r})]}),i]}),a?v(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:s}):s]})}E();var coe=1500;function F6({tabKey:e,children:t,className:n,fill:r=!1}){let i=f(null),a=f(0),[o,s]=C(null),c=f(e),l=()=>{let e=i.current?.offsetHeight??0;e>0&&(a.current=e),s(t=>t!==null&&e>=t?null:t)};return u(()=>{if(c.current===e)return;c.current=e;let t=a.current;t>0&&s(t)},[e]),b(l),b(()=>{let e=i.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(l);return t.observe(e),()=>t.disconnect()},[]),b(()=>{if(o===null)return;let e=setTimeout(()=>s(null),coe);return()=>clearTimeout(e)},[o]),v(`div`,{className:r?`flex min-h-0 flex-1 flex-col ${n??``}`:n,style:o===null?void 0:{minHeight:o},children:v(`div`,{ref:i,className:r?`flex h-full min-h-0 flex-1 flex-col`:void 0,children:t})})}E();function I6(){return new URLSearchParams(window.location.search)}function loe(e){let t=I6();e(t);let n=t.toString(),r=n?`${window.location.pathname}?${n}`:window.location.pathname;window.history.replaceState(null,``,r)}function L6({icon:e,title:t,subtitle:n,actions:r,sections:i,defaultSection:a,paramName:o=`tab`,sectionsLabel:s,className:l,sectionsOnly:u=!1,activeSection:d,onSectionChange:f,fill:p=!1}){let m=d!==void 0&&f!==void 0,h=a??i[0]?.id??``,[g,y]=C(()=>m?null:I6().get(o));b(()=>{if(m)return;let e=()=>y(I6().get(o));return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[m,o]);let x=m?d:g,S=i.some(e=>e.id===x)?x??h:h,w=i.find(e=>e.id===S)??i[0],T=_(e=>{let t=e===S?[]:w?.ownedParams??[];if(m){f(e,t);return}loe(n=>{for(let e of t)n.delete(e);n.set(o,e)}),y(e)},[w?.ownedParams,S,m,f,o]),E=s??(t!==void 0&&t!==``?`${t} sections`:`Sections`),D=v(YB,{value:S,onValueChange:T,className:p?`shrink-0`:void 0,children:v(XB,{"aria-label":E,children:i.map(e=>v(ZB,{value:e.id,"data-testid":`section-${e.id}`,children:e.label},e.id))})}),O=v(F6,{tabKey:S,fill:p,children:p?v(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:w?.content}):w?.content}),k=p?c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[D,O]}):c(P,{children:[D,O]});return u?v(`div`,{className:p?`flex h-full min-h-0 flex-col gap-3 ${l??``}`:l?`space-y-3 ${l}`:`space-y-3`,"data-testid":`sectioned-page-sections-only`,children:k}):v(P6,{icon:e,title:t??``,subtitle:n,actions:r,fill:p,className:l,children:k})}function uoe({start:e,end:t,className:n,testId:r}){return c(`div`,{className:$(`flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,n),"data-testid":r,children:[e!=null&&v(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-2`,children:e}),t!=null&&v(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 sm:justify-end`,children:t})]})}function R6({open:e,onClose:t,title:n,icon:r,error:i,width:a=`lg`,children:o,beforeBody:s,footer:l,testId:u,fill:d=!1}){return e?v(SL,{open:!0,onOpenChange:e=>!e&&t(),children:c(TL,{width:a,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":u,children:[v(`div`,{className:`mb-3 flex shrink-0 items-center gap-2 pr-10`,children:c(`h3`,{className:`flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground`,children:[r!==void 0&&v(r,{className:`h-4 w-4 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),v(`span`,{className:`truncate`,children:n})]})}),i!=null&&i!==``&&v(`div`,{className:`mb-3 shrink-0 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:i}),s!=null&&v(`div`,{className:`mb-3 shrink-0`,children:s}),v(DL,{className:d?`flex flex-col gap-3 px-1`:`space-y-3 px-1`,children:o}),l!=null&&v(OL,{className:`mt-3 shrink-0`,children:l})]})}):null}E();var z6=`camstack:url-query`;function B6(e){return new URLSearchParams(window.location.search).get(e)}function V6(){window.dispatchEvent(new Event(z6))}function doe(e,t){let n=new URLSearchParams(window.location.search);t===null||t===``?n.delete(e):n.set(e,t);let r=n.toString(),i=r?`${window.location.pathname}?${r}`:window.location.pathname;window.history.replaceState(null,``,i)}var H6=!1;function foe(){if(H6||typeof window>`u`)return;H6=!0;let e=window.history.replaceState.bind(window.history),t=window.history.pushState.bind(window.history);window.history.replaceState=(...t)=>{e(...t),V6()},window.history.pushState=(...e)=>{t(...e),V6()}}function U6(e){foe();let[t,n]=C(()=>B6(e));return b(()=>{let t=()=>n(B6(e));return window.addEventListener(`popstate`,t),window.addEventListener(z6,t),()=>{window.removeEventListener(`popstate`,t),window.removeEventListener(z6,t)}},[e]),[t,_(t=>{doe(e,t),n(t)},[e])]}E();function W6(e={}){let t=e.newKey??`new`,n=e.editKey??`edit`,[r,i]=U6(t),[a,o]=U6(n);return{state:p(()=>a!==null&&a!==``?{mode:`edit`,id:a}:r===`1`?{mode:`new`}:{mode:`closed`},[a,r]),openNew:_(()=>{o(null),i(`1`)},[o,i]),openEdit:_(e=>{i(null),o(e)},[o,i]),close:_(()=>{i(null),o(null)},[o,i])}}function poe({children:e,selected:t=!1,onSelect:n,label:r,className:i,testId:a}){let o=n!==void 0;return v(`div`,{role:o?`button`:void 0,tabIndex:o?0:void 0,"aria-pressed":o?t:void 0,"aria-label":r,"data-testid":a,onClick:n,onKeyDown:e=>{o&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n())},className:$(`relative aspect-square min-w-0 overflow-hidden rounded-md border bg-surface`,t?`border-primary ring-1 ring-primary`:`border-border`,o&&`cursor-pointer hover:border-foreground-subtle`,i),children:e})}function G6({status:e,children:t,pendingMessage:n=`Loading…`,emptyMessage:r=`Nothing to show`,className:i,testId:a}){return e===`pending`?v(`p`,{className:`animate-pulse py-8 text-center text-xs text-foreground-subtle`,"data-testid":a,children:n}):e===`empty`?v(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,"data-testid":a,children:r}):v(`div`,{className:$(he,ki,i),"data-testid":a,children:t})}var moe={Activity:ai,Eye:Zt,AlertTriangle:zi,PauseCircle:gn,PowerOff:st};function K6({phase:e,...t}){let n=moe[QG(e).icon];return v(n,{...t})}E();function hoe(e){let t=new Map;for(let n of e.slots)for(let e of n.addons)t.set(e.id,e);return t}function q6(e){return{addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:[...e.inputClasses],outputClasses:[...e.outputClasses],enabled:!0,modelId:e.defaultModelId,children:[]}}function J6({addon:e,onClick:t}){return v(`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:c(`div`,{className:`flex items-center gap-3`,children:[v(Jn,{className:`h-[18px] w-[18px] text-foreground-subtle/30 group-hover:text-primary/60 shrink-0`}),c(`div`,{className:`flex-1 min-w-0`,children:[v(`span`,{className:`text-[13px] font-medium text-foreground-subtle/50 group-hover:text-foreground-subtle block truncate`,children:e.name}),c(`div`,{className:`flex items-center gap-1 mt-0.5 flex-wrap`,children:[e.inputClasses.map(e=>v(`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:e},e)),e.inputClasses.length>0&&e.outputClasses.length>0&&v(`span`,{className:`text-foreground-subtle/25 text-[10px]`,children:`→`}),e.outputClasses.map(e=>v(`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:e},e))]})]})]})})}function goe({schema:e,steps:t,onChange:n,readOnly:r=!1,excludeAddons:i=[],showOnlyEnabled:a=!1,showSlotLabels:o=!1}){let s=q(),l=p(()=>new Set(i),[i]),u=p(()=>hoe(e),[e]);function d(e){n(t.map(t=>t.addonId===e.addonId?f(e):t))}function f(e){let t=e.children.some(e=>e.enabled||e.children.some(e=>e.enabled));return{...e,enabled:e.enabled||t,children:e.children.map(e=>{let t=e.children.some(e=>e.enabled);return{...e,enabled:e.enabled||t}})}}function m(e,r){let i=q6(r);n(t.map(t=>t.addonId===e?{...t,children:[...t.children,i]}:t))}function h(e){let t=new Set;for(let n of e){t.add(n.addonId);for(let e of n.children)t.add(e.addonId);let e=h(n.children);for(let n of e)t.add(n)}return t}let g=h(t);function _(t){let n=u.get(t.addonId);if(!n)return[];let r=e.slots.find(e=>e.id===n.slot)?.parentSlot==null,i=n.childSlots,a=new Set(t.children.map(e=>e.addonId)),o=[];for(let n of e.slots)if(i.includes(n.id))for(let e of n.addons){if(a.has(e.id)||l.has(e.id))continue;let n=e.inputClasses.length===0;n&&!r||(n||e.inputClasses.some(e=>t.outputClasses.includes(e)))&&o.push(e)}return o}function y(e){let i=a?{...e,children:e.children.filter(e=>e.enabled).map(e=>({...e,children:e.children.filter(e=>e.enabled)}))}:e,l=a?[]:_(i);return c(`div`,{className:`space-y-1.5`,children:[v(pB,{step:i,schema:u.get(i.addonId)??null,allSchemas:u,onChange:d,onDelete:r?void 0:e=>n(t.filter(t=>t.addonId!==e)),readOnly:r}),(i.children.length>0||l.length>0)&&c(`div`,{className:`ml-4 pl-3 border-l border-border/60 space-y-1.5`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/40`,children:s(`uiLibrary.pipelineBuilder.slotCropper`,`Slot: Cropper / Classifier`)}),i.children.map(e=>{let t=_(e);return c(`div`,{className:`space-y-1.5`,children:[v(pB,{step:e,schema:u.get(e.addonId)??null,allSchemas:u,depth:1,onChange:e=>{d({...i,children:i.children.map(t=>t.addonId===e.addonId?e:t)})},onDelete:r?void 0:e=>{d({...i,children:i.children.filter(t=>t.addonId!==e)})},readOnly:r}),(e.children.length>0||t.length>0)&&c(`div`,{className:`ml-4 pl-3 border-l border-border/40 space-y-1.5`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/30`,children:s(`uiLibrary.pipelineBuilder.slotRecognizer`,`Slot: Recognizer`)}),e.children.map(t=>v(pB,{step:t,schema:u.get(t.addonId)??null,allSchemas:u,depth:2,onChange:t=>{d({...i,children:i.children.map(n=>n.addonId===e.addonId?{...n,children:n.children.map(e=>e.addonId===t.addonId?t:e)}:n)})},onDelete:r?void 0:t=>{d({...i,children:i.children.map(n=>n.addonId===e.addonId?{...n,children:n.children.filter(e=>e.addonId!==t)}:n)})},readOnly:r},t.addonId)),!r&&t.map(t=>v(J6,{addon:t,onClick:()=>{let n=q6(t);d({...i,children:i.children.map(t=>t.addonId===e.addonId?{...t,children:[...t.children,n]}:t)})}},t.id))]})]},e.addonId)}),!r&&l.map(e=>v(J6,{addon:e,onClick:()=>m(i.addonId,e)},e.id))]})]},i.addonId)}return v(`div`,{className:`space-y-4`,children:e.slots.filter(e=>e.parentSlot===null).toSorted((e,t)=>e.priority-t.priority).map(e=>{let i=t.filter(t=>t.slot===e.id&&!l.has(t.addonId)),u=a?i.filter(e=>e.enabled):i,d=a?[]:e.addons.filter(e=>!g.has(e.id)&&!l.has(e.id)),f=new Map,p=[];for(let e of u)e.group?(f.has(e.group)||f.set(e.group,[]),f.get(e.group).push(e)):p.push(e);return c(`div`,{className:`space-y-2`,children:[o&&v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50`,children:s(`uiLibrary.pipelineBuilder.slotLabel`,`Slot: {{label}}`,{label:e.label})}),p.map(e=>y(e)),[...f.entries()].map(([e,t])=>c(`div`,{className:`space-y-2 rounded-lg border border-border/40 p-2`,children:[v(`span`,{className:`text-[10px] font-semibold uppercase tracking-widest text-foreground-subtle/50 px-1`,children:e}),t.map(e=>y(e))]},e)),!r&&d.map(e=>v(J6,{addon:e,onClick:()=>{n([...t,q6(e)])}},e.id))]},e.id)})})}function _oe({options:e,value:t,onChange:n}){let r=q();return v(`div`,{className:`flex flex-wrap gap-2`,children:e.map(e=>{let i=e.id===t;return c(`button`,{onClick:()=>e.available&&n(e.id),disabled:!e.available,className:`flex items-center gap-2 rounded-lg border px-3 py-2 text-xs font-medium transition-all ${i?`border-primary/40 bg-primary/10 text-primary`:e.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:[v(Mr,{className:`h-3.5 w-3.5 shrink-0`}),e.label,e.isBest&&c(`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:[v(see,{className:`h-2.5 w-2.5`}),r(`uiLibrary.pipelineRuntimeSelector.best`,`Best`)]}),e.platformScore!=null&&c(`span`,{className:`text-[10px] text-foreground-subtle/60`,children:[`(`,e.platformScore,`)`]}),v(`span`,{className:`h-1.5 w-1.5 rounded-full ${e.available?`bg-success`:`bg-danger`}`})]},e.id)})})}var voe={onvif:{colorClass:`bg-provider-onvif`,label:`ONVIF`},hikvision:{colorClass:`bg-provider-hikvision`,label:`Hikvision`},reolink:{colorClass:`bg-provider-reolink`,label:`Reolink`},homeAssistant:{colorClass:`bg-provider-homeAssistant`,label:`Home Assistant`},rtsp:{colorClass:`bg-provider-rtsp`,label:`RTSP`}};function yoe({provider:e,showLabel:t=!0,className:n}){let r=voe[e];return c(`span`,{className:$(`inline-flex items-center gap-1.5 text-xs`,n),children:[v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-sm`,r.colorClass),"aria-hidden":`true`}),t&&v(`span`,{className:`text-foreground`,children:r.label})]})}E();function boe({open:e,onOpenChange:t,types:n,onCreate:r,submitting:i=!1,title:a,description:o}){let s=q(),l=a??s(`uiLibrary.addProviderEntryDialog.title`,`Add provider entry`),u=o??s(`uiLibrary.addProviderEntryDialog.description`,`Pick a provider type and name this credential set.`),d=y(),f=y(),[p,m]=C(``),[h,g]=C(``);b(()=>{e&&(m(n[0]?.typeId??``),g(``))},[e,n]);let _=p!==``&&h.trim().length>0&&!i&&n.length>0,x=()=>{_&&r({typeId:p,name:h.trim()})};return v(SL,{open:e,onOpenChange:e=>!i&&t(e),children:c(TL,{width:`sm`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(EL,{children:[v(kL,{children:l}),v(AL,{children:u})]}),v(DL,{className:`space-y-3`,children:n.length===0?v(`p`,{className:`text-xs text-foreground-subtle`,children:s(`uiLibrary.addProviderEntryDialog.noTypes`,`No provider types are available yet. Install a training provider addon first.`)}):c(P,{children:[c(`div`,{className:`space-y-1`,children:[v(LB,{htmlFor:d,children:s(`uiLibrary.addProviderEntryDialog.providerType`,`Provider type`)}),c(`div`,{className:`flex items-center gap-2`,children:[v(xoe,{url:n.find(e=>e.typeId===p)?.iconUrl??null}),v(Yl,{id:d,"aria-label":s(`uiLibrary.addProviderEntryDialog.providerType`,`Provider type`),className:`flex-1`,value:p,onChange:e=>m(e.target.value),options:n.map(e=>({value:e.typeId,label:e.label})),disabled:i})]})]}),c(`div`,{className:`space-y-1`,children:[v(LB,{htmlFor:f,children:s(`uiLibrary.addProviderEntryDialog.name`,`Name`)}),v(Bl,{id:f,"aria-label":s(`uiLibrary.addProviderEntryDialog.name`,`Name`),value:h,onChange:e=>g(e.target.value),placeholder:s(`uiLibrary.addProviderEntryDialog.namePlaceholder`,`Production`),disabled:i,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),x())}})]})]})}),c(OL,{children:[v(_A,{type:`button`,variant:`ghost`,size:`sm`,disabled:i,onClick:()=>t(!1),children:s(`uiLibrary.addProviderEntryDialog.cancel`,`Cancel`)}),c(_A,{type:`button`,size:`sm`,disabled:!_,onClick:x,children:[i&&v(Gn,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),s(`uiLibrary.addProviderEntryDialog.create`,`Create`)]})]})]})})}function xoe({url:e}){return e===null?v(`span`,{className:$(`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-md`,`border border-border bg-surface text-[10px] text-foreground-subtle`),"aria-hidden":!0,children:`?`}):v(`img`,{src:e,alt:``,className:`h-7 w-7 shrink-0 rounded-md border border-border bg-surface object-contain p-0.5`})}var Y6=$(Mi,`min-w-0 max-w-full gap-1.5 py-1 pl-1 pr-2.5 text-xs font-normal`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`),Soe=$(xi,`font-medium`),Coe=En,woe={ok:`bg-success`,warning:`bg-warning`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`},X6={ok:{key:`uiLibrary.providerEntryPills.status.ok`,fallback:`OK`},warning:{key:`uiLibrary.providerEntryPills.status.warning`,fallback:`Warning`},error:{key:`uiLibrary.providerEntryPills.status.error`,fallback:`Error`},unknown:{key:`uiLibrary.providerEntryPills.status.unknown`,fallback:`Unknown`}};function Toe({label:e,entries:t,selectedEntryId:n,onSelect:r,onAdd:i,addLabel:a}){let o=q(),s=a??o(`uiLibrary.providerEntryPills.addProvider`,`Add provider`);return v(`nav`,{"aria-label":e,className:`min-w-0`,children:c(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[t.map(e=>v(Eoe,{entry:e,current:e.entryId===n,onSelect:r},e.entryId)),i!==void 0&&c(`button`,{type:`button`,onClick:i,className:$(Y6,`border-dashed border-border pl-2 text-foreground-subtle`,`hover:border-primary/50 hover:text-foreground`),children:[v(Se,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),v(`span`,{className:`truncate`,children:s})]})]})})}function Eoe({entry:e,current:t,onSelect:n}){let r=q(),i=e.status===`ok`;return c(`button`,{type:`button`,"aria-current":t?`true`:void 0,"data-testid":`provider-entry-pill-${e.entryId}`,onClick:()=>n(e.entryId),className:$(Y6,t?Soe:Coe),children:[v(Doe,{url:e.iconUrl}),v(`span`,{className:`truncate`,children:e.name}),v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,woe[e.status]),"aria-hidden":!0}),v(`span`,{className:i?`sr-only`:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:r(X6[e.status].key,X6[e.status].fallback)})]})}function Doe({url:e}){return e===null?v(`span`,{className:`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-surface text-[9px] text-foreground-subtle`,"aria-hidden":!0,children:`?`}):v(`img`,{src:e,alt:``,className:`h-5 w-5 shrink-0 rounded-full object-contain`})}function Z6(e){return e===Na}function Ooe(e){return Z6(e)?``:typeof e==`string`?e:``}function koe(e,t){return Z6(t)&&e.length===0?Na:e}function Q6(e,t,n){return n.secret===!0?!0:t.includes(e)}function $6(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Aoe(e,t){let n=t.description;return typeof n==`string`&&n.length>0?n:e.replace(/([A-Z])/g,` $1`).replace(/^./,e=>e.toUpperCase())}function e8(e){return typeof e==`string`?e:``}function joe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Moe(e){return e===!0}function Noe(e){try{let t=JSON.parse(e);return $6(t)?t:null}catch{return null}}function Poe(e){return ha(e)||Bi(e)?e:Z6(e)?{$secret:null,v:1,set:!0}:null}function Foe({name:e,label:t,required:n,value:r,disabled:i,onPatch:a}){return v(O6,{label:t,required:n,children:v(au,{field:{type:`password`,key:e,label:t,required:n},value:Poe(r),onChange:a,disabled:i})})}function t8(e){let{path:t,name:n,node:r,value:i,secretPaths:a,required:o,disabled:s,onPatch:l}=e,u=Aoe(n,r),d=q();if(Q6(t,a,r))return v(Foe,{name:n,label:u,required:o,value:i,disabled:s,onPatch:e=>l(t,e)});let f=r.enum;if(Array.isArray(f)&&f.every(e=>typeof e==`string`))return v(O6,{label:u,required:o,children:v(Yl,{value:e8(i),onChange:e=>l(t,e.target.value),disabled:s,options:f.map(e=>({value:e,label:e}))})});let p=r.type;if(p===`boolean`)return v(O6,{label:u,required:o,children:v(VB,{checked:Moe(i),onCheckedChange:e=>l(t,e),disabled:s})});if(p===`integer`||p===`number`)return v(O6,{label:u,required:o,children:v(Bl,{type:`number`,value:joe(i)??``,onChange:e=>{let n=e.target.value;l(t,n===``?void 0:Number(n))},disabled:s})});if(p===`object`){let e=r.properties;if($6(e)){let n=$6(i)?i:{},o=Array.isArray(r.required)?r.required.filter(e=>typeof e==`string`):[];return c(`fieldset`,{className:`space-y-3 rounded-lg border border-border-subtle p-3`,children:[v(`legend`,{className:`px-1 text-xs font-medium text-foreground-muted`,children:u}),Object.entries(e).map(([e,r])=>$6(r)?v(t8,{path:`${t}.${e}`,name:e,node:r,value:n[e],secretPaths:a,required:o.includes(e),disabled:s,onPatch:l},e):null)]})}let n=$6(i)?JSON.stringify(i,null,2):`{}`;return v(O6,{label:u,required:o,description:d(`uiLibrary.recordEntries.jsonObject`,`JSON object`),children:v(`textarea`,{className:$(`min-h-[8rem] w-full resize-y rounded-md border border-border bg-surface px-2.5 py-2 font-mono text-xs text-foreground`,`placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-inset focus:ring-primary`,`disabled:cursor-not-allowed disabled:opacity-50`),rows:6,defaultValue:n,disabled:s,onBlur:e=>{let n=Noe(e.target.value);n!==null&&l(t,n)}})})}return p===`string`||p===void 0?v(O6,{label:u,required:o,children:v(Bl,{value:e8(i),onChange:e=>l(t,e.target.value),disabled:s})}):null}function n8(e,t,n){let r=t.split(`.`);if(r.length===1)return{...e,[r[0]]:n};let[i,...a]=r,o=i,s=$6(e[o])?e[o]:{};return{...e,[o]:n8(s,a.join(`.`),n)}}function r8({schema:e,secretPaths:t,value:n,onChange:r,disabled:i}){let a=e.properties;if(!$6(a))return null;let o=Array.isArray(e.required)?e.required.filter(e=>typeof e==`string`):[],s=(e,t)=>{r(n8(n,e,t))};return v(`div`,{className:`space-y-3`,children:Object.entries(a).map(([e,r])=>$6(r)?v(t8,{path:e,name:e,node:r,value:n[e],secretPaths:t,required:o.includes(e),disabled:i,onPatch:s},e):null)})}E();function i8(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ioe(e){let t=e.properties;if(!i8(t))return{};let n={};for(let[e,r]of Object.entries(t))if(i8(r)){if(r.default!==void 0){n[e]=r.default;continue}r.type===`boolean`?n[e]=!1:r.type===`object`&&(n[e]={})}return n}function a8({kind:e,rowActions:t,extraColumns:n=[],showUpdated:r=!0,minWidthPx:i}){let a=q(),o=k(),s=li(),l=W6({newKey:`entryNew`,editKey:`entryEdit`}),u=Gw({owner:e.owner,kind:e.kind},{staleTime:15e3}),d=Kw({onSuccess:async()=>{await o.invalidateQueries({queryKey:[[`recordEntries`]]}),l.close()}}),f=qw({onSuccess:async()=>{await o.invalidateQueries({queryKey:[[`recordEntries`]]})}}),m=u.data?.entries??[],h=p(()=>{let e=l.state;return e.mode===`edit`?m.find(t=>t.id===e.id)??null:null},[m,l.state]),[g,y]=C({}),[b,x]=C(null),S=_(()=>{y(Ioe(e.fields)),x(null),l.openNew()},[l,e.fields]),w=_(e=>{y({...e.data}),x(null),l.openEdit(e.id)},[l]),T=_(async t=>{await s({title:a(`uiLibrary.recordEntries.deleteTitle`,`Delete entry`),message:a(`uiLibrary.recordEntries.deleteDescription`,`Remove "{{name}}" permanently?`,{name:t.name}),confirmLabel:a(`uiLibrary.recordEntries.deleteConfirm`,`Delete`),variant:`danger`})&&await f.mutateAsync({owner:e.owner,kind:e.kind,id:t.id})},[s,f,e.kind,e.owner,a]),E=p(()=>[{key:`name`,header:a(`uiLibrary.recordEntries.colName`,`Name`),render:e=>v(_A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto max-w-full justify-start px-0 py-0 font-medium hover:underline`,onClick:()=>w(e),children:v(`span`,{className:`truncate`,children:e.name})})},...r?[{key:`updated`,header:a(`uiLibrary.recordEntries.colUpdated`,`Updated`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,title:new Date(e.updatedAt).toLocaleString(),children:new Date(e.updatedAt).toLocaleDateString()})}]:[],...n,{key:`actions`,header:``,align:`right`,nowrap:!0,width:`w-px`,render:e=>c(`span`,{className:`flex justify-end gap-1`,children:[t?.(e),v(_A,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>w(e),children:v(Gt,{className:`h-3.5 w-3.5`})}),v(_A,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>void T(e),children:v(Pe,{className:`h-3.5 w-3.5 text-danger`})})]})}],[n,T,w,t,r,a]),D=l.state.mode!==`closed`,O=l.state.mode===`new`?a(`uiLibrary.recordEntries.addTitle`,`Add entry`):a(`uiLibrary.recordEntries.editTitle`,`Edit entry`),A=async()=>{x(null);try{if(l.state.mode===`new`)await d.mutateAsync({owner:e.owner,kind:e.kind,data:g});else if(l.state.mode===`edit`&&h!==null)await d.mutateAsync({owner:e.owner,kind:e.kind,id:h.id,data:g,ifRev:h.rev});else{x(a(`uiLibrary.recordEntries.saveUnavailable`,`Nothing to save`));return}}catch(e){x(e instanceof Error?e.message:a(`uiLibrary.recordEntries.saveFailed`,`Save failed`))}};return c(`div`,{className:`space-y-3`,children:[v(`div`,{className:`flex justify-end`,children:c(_A,{type:`button`,size:`sm`,onClick:S,children:[v(Se,{className:`mr-1 h-3.5 w-3.5`}),a(`uiLibrary.recordEntries.add`,`Add`)]})}),u.isError&&v(eN,{message:u.error instanceof Error?u.error.message:a(`uiLibrary.recordEntries.loadFailed`,`Could not load entries`)}),u.isPending?v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):m.length===0?v(QM,{title:a(`uiLibrary.recordEntries.emptyTitle`,`No entries yet`),description:a(`uiLibrary.recordEntries.emptyDescription`,`Add the first row for this kind.`)}):v(gU,{...i===void 0?{}:{minWidthPx:i},columns:E,rows:m,rowKey:e=>e.id,maxBodyHeight:mU,emptyMessage:a(`uiLibrary.recordEntries.emptyTitle`,`No entries yet`)}),v(R6,{open:D,onClose:l.close,title:O,error:b,footer:v(_A,{type:`button`,size:`sm`,disabled:d.isPending,onClick:()=>void A(),children:d.isPending?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):a(`uiLibrary.recordEntries.save`,`Save`)}),children:v(r8,{schema:e.fields,secretPaths:e.secretPaths,value:g,onChange:y,disabled:d.isPending})})]})}E();function o8({kind:e}){let t=q(),[n,r]=C(null),i=X.storageAdmin.readRecords.useQuery({owner:e.owner,kind:e.kind,limit:100,desc:!0},{staleTime:15e3}),a=i.data?.records??[],o=p(()=>[{key:`id`,header:t(`uiLibrary.storageRecords.colId`,`Id`),render:e=>v(_A,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto max-w-full justify-start px-0 py-0 font-mono text-xs hover:underline`,onClick:()=>r(e),children:v(`span`,{className:`truncate`,children:e.id})})},{key:`deviceId`,header:t(`uiLibrary.storageRecords.colDevice`,`Device`),nowrap:!0,render:e=>e.deviceId===null?v(`span`,{className:`text-foreground-subtle`,children:`—`}):v(`span`,{className:`font-mono text-xs`,children:e.deviceId})},{key:`at`,header:t(`uiLibrary.storageRecords.colAt`,`At`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.at===null?`—`:new Date(e.at).toLocaleString()})},{key:`updatedAt`,header:t(`uiLibrary.storageRecords.colUpdated`,`Updated`),nowrap:!0,render:e=>v(`span`,{className:`text-[11px] text-foreground-subtle`,children:new Date(e.updatedAt).toLocaleString()})}],[t]);return c(`div`,{className:`space-y-3`,children:[c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:`${e.owner}/${e.kind}`}),v(Bk,{variant:`neutral`,style:`outline`,children:e.database}),v(Bk,{variant:`neutral`,style:`outline`,children:e.class}),v(Bk,{variant:e.state===`declared`?`default`:`neutral`,children:e.state}),e.entry?v(Bk,{variant:`info`,children:t(`uiLibrary.storageRecords.entryKind`,`Entry`)}):null]}),i.isError?v(eN,{message:i.error instanceof Error?i.error.message:t(`uiLibrary.storageRecords.loadFailed`,`Could not load records`)}):i.isPending?v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):a.length===0?v(QM,{title:t(`uiLibrary.storageRecords.emptyTitle`,`No rows`),description:t(`uiLibrary.storageRecords.emptyDescription`,`This kind has no stored records yet.`)}):v(gU,{columns:o,rows:a,rowKey:e=>e.id,maxBodyHeight:mU,emptyMessage:t(`uiLibrary.storageRecords.emptyTitle`,`No rows`)}),v(SL,{open:n!==null,onOpenChange:e=>!e&&r(null),children:c(TL,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[c(EL,{children:[v(kL,{children:t(`uiLibrary.storageRecords.inspectTitle`,`Record`)}),n===null?null:v(AL,{className:`font-mono`,children:n.id})]}),v(DL,{children:n===null?null:v(_G,{maxHeight:480,children:JSON.stringify(n,null,2)})})]})})]})}function s8(e){return`${e.owner}/${e.kind}`}function c8(e){return e.entry?`entry`:`record`}function l8(e){return e.rows===null?`unknown`:e.rows>0?`has-rows`:`empty`}function u8(e,t){let n=new Map;for(let e of t??[])n.set(s8(e),e.title);return e.map(e=>({kind:e,entryTitle:e.entry?n.get(s8(e))??null:null}))}var d8=[{id:`kind`,value:e=>s8(e.kind)},{id:`owner`,value:e=>e.kind.owner},{id:`type`,value:e=>c8(e.kind)},{id:`database`,value:e=>e.kind.database},{id:`class`,value:e=>e.kind.class},{id:`state`,value:e=>e.kind.state},{id:`contents`,value:e=>l8(e.kind)}];function f8(e){let{kind:t}=e;return[t.owner,t.kind,t.class,t.database,t.state,e.entryTitle??``]}E();var p8=`recordsOwner`,m8=`recordsKind`;function Loe(e){return e===null?`—`:e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function Roe(e,t){switch(e){case`kind`:return t(`uiLibrary.dataRecords.facetKind`,`Kind`);case`owner`:return t(`uiLibrary.dataRecords.facetOwner`,`Owner`);case`type`:return t(`uiLibrary.dataRecords.facetType`,`Type`);case`database`:return t(`uiLibrary.dataRecords.facetDatabase`,`Database`);case`class`:return t(`uiLibrary.dataRecords.facetClass`,`Class`);case`state`:return t(`uiLibrary.dataRecords.facetState`,`State`);default:return t(`uiLibrary.dataRecords.facetContents`,`Contents`)}}function zoe(e,t,n){return e===`type`?t===`entry`?n(`uiLibrary.dataRecords.typeEntry`,`Entries (editable)`):n(`uiLibrary.dataRecords.typeRecord`,`Records (read-only)`):e===`contents`?t===`has-rows`?n(`uiLibrary.dataRecords.contentsHasRows`,`Has rows`):t===`empty`?n(`uiLibrary.dataRecords.contentsEmpty`,`Empty`):n(`uiLibrary.dataRecords.contentsUnknown`,`Count unknown`):t}function Boe({kind:e,entryKinds:t,entryKindsPending:n,entryKindsError:r}){let i=q();if(!e.entry)return v(o8,{kind:e});if(n)return v(`div`,{className:`flex justify-center py-8 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})});if(r!==null)return v(eN,{message:r});let a=t?.find(t=>s8(t)===s8(e));return a===void 0?v(eN,{message:i(`uiLibrary.dataRecords.entryKindMissing`,`This entry kind is not served by the entries service.`)}):c(`div`,{className:`space-y-2`,children:[v(`h3`,{className:`text-sm font-semibold text-foreground`,children:a.title}),v(a8,{kind:a})]})}function h8(){let e=q(),t=X.storageAdmin.listKinds.useQuery({},{staleTime:3e4}),n=Ww({},{staleTime:3e4}),[r,i]=U6(p8),[a,o]=U6(m8),s=n.data?.kinds,l=p(()=>u8(t.data?.kinds??[],s),[s,t.data?.kinds]),u=PG(l,{searchText:f8,facetGroups:d8}),d=p(()=>l.find(e=>e.kind.owner===r&&e.kind.kind===a)?.kind??null,[a,r,l]),f=_(e=>{i(e.owner),o(e.kind)},[o,i]),m=p(()=>[{key:`kind`,header:e(`uiLibrary.dataRecords.colKind`,`Kind`),render:e=>c(`span`,{className:`flex flex-col`,children:[v(`span`,{className:`font-mono text-xs`,children:s8(e.kind)}),e.entryTitle===null?null:v(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.entryTitle})]}),sortValue:e=>s8(e.kind)},{key:`type`,header:e(`uiLibrary.dataRecords.colType`,`Type`),nowrap:!0,render:t=>t.kind.entry?v(Bk,{variant:`info`,children:e(`uiLibrary.dataRecords.badgeEntry`,`Entry`)}):v(Bk,{variant:`neutral`,children:e(`uiLibrary.dataRecords.badgeRecord`,`Record`)}),sortValue:e=>e.kind.entry?`entry`:`record`},{key:`database`,header:e(`uiLibrary.dataRecords.colDatabase`,`DB`),nowrap:!0,render:e=>v(Bk,{variant:`neutral`,style:`outline`,children:e.kind.database}),sortValue:e=>e.kind.database},{key:`class`,header:e(`uiLibrary.dataRecords.colClass`,`Class`),nowrap:!0,render:e=>v(`span`,{className:`text-xs text-foreground-muted`,children:e.kind.class}),sortValue:e=>e.kind.class},{key:`state`,header:e(`uiLibrary.dataRecords.colState`,`State`),nowrap:!0,render:e=>v(Bk,{variant:e.kind.state===`declared`?`default`:`neutral`,children:e.kind.state}),sortValue:e=>e.kind.state},{key:`rows`,header:e(`uiLibrary.dataRecords.colRows`,`Rows`),align:`right`,nowrap:!0,render:e=>v(`span`,{className:`font-mono text-xs tabular-nums`,children:e.kind.rows===null?`—`:e.kind.rows}),sortValue:e=>e.kind.rows??-1},{key:`bytes`,header:e(`uiLibrary.dataRecords.colSize`,`Est. size`),align:`right`,nowrap:!0,render:e=>v(`span`,{className:`text-xs text-foreground-subtle`,children:Loe(e.kind.bytesEstimate)}),sortValue:e=>e.kind.bytesEstimate??-1},{key:`open`,header:``,align:`right`,nowrap:!0,render:t=>v(_A,{type:`button`,size:`sm`,variant:d!==null&&s8(d)===s8(t.kind)?`primary`:`outline`,onClick:()=>f(t.kind),children:t.kind.entry?e(`uiLibrary.dataRecords.manage`,`Manage`):e(`uiLibrary.dataRecords.viewRows`,`View rows`)}),notSortableReason:e(`uiLibrary.dataRecords.actionColumn`,`Actions`)}],[d,f,e]);return t.isError?v(eN,{message:t.error instanceof Error?t.error.message:e(`uiLibrary.dataRecords.kindsFailed`,`Could not load record kinds`)}):t.isPending?v(`div`,{className:`flex justify-center py-10 text-foreground-subtle`,children:v(Gn,{className:`h-5 w-5 animate-spin`})}):l.length===0?v(QM,{title:e(`uiLibrary.dataRecords.noKindsTitle`,`No record kinds`),description:e(`uiLibrary.dataRecords.noKindsDescription`,`No addon has declared a record kind on this hub yet.`)}):c(`div`,{className:`space-y-4`,children:[v(NG,{state:u.state,facets:u.facets,groups:u.groups.map(t=>({...t,label:Roe(t.id,e),display:`menu`,facetLabel:n=>zoe(t.id,n,e)})),labels:{searchPlaceholder:e(`uiLibrary.dataRecords.search`,`Search kinds…`),searchLabel:e(`uiLibrary.dataRecords.searchLabel`,`Search record kinds`),facetsLabel:e(`uiLibrary.dataRecords.facetsLabel`,`Filter record kinds`),clearLabel:e(`uiLibrary.dataRecords.clearFilters`,`Clear filters`)},onSearch:u.setSearch,onToggleFacet:u.toggleFacet,onToggleGroupFacet:u.toggleGroupFacet,onClear:u.clear}),v(gU,{columns:m,rows:u.rows,rowKey:e=>s8(e.kind),maxBodyHeight:mU,defaultSort:{columnKey:`kind`,dir:`asc`},emptyMessage:e(`uiLibrary.dataRecords.noMatch`,`No kinds match the filter`)}),d===null?null:v(Boe,{kind:d,entryKinds:s,entryKindsPending:n.isPending,entryKindsError:n.isError?n.error instanceof Error?n.error.message:e(`uiLibrary.dataRecords.entryKindsFailed`,`Could not load entry kinds`):null})]})}E();function Voe({data:e,label:t=`Response`,className:n=``}){let r=q(),[i,a]=C(!1);if(!e)return null;let o=JSON.stringify(e,null,2);return c(`div`,{className:`rounded-xl border border-border bg-surface overflow-hidden ${n}`,children:[c(`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:()=>a(e=>!e),children:[c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i?`▼`:`▶`}),v(`h3`,{className:`text-xs font-medium text-foreground`,children:t})]}),v(`span`,{className:`text-[10px] text-foreground-subtle font-mono`,children:o.length>1e3?r(`uiLibrary.responseLog.kb`,`{{size}} KB`,{size:(o.length/1024).toFixed(1)}):r(`uiLibrary.responseLog.bytes`,`{{count}} bytes`,{count:o.length})})]}),i&&v(`div`,{className:`max-h-80 overflow-y-auto overflow-x-auto`,children:v(`pre`,{className:`p-3 text-[10px] leading-4 font-mono text-foreground-subtle whitespace-pre`,children:o})})]})}E();var Hoe={"":void 0,yes:!0,no:!1},Uoe=[{value:`view`,labelKey:`uiLibrary.scopePicker.accessView`,labelFallback:`View`,icon:Zt,hintKey:`uiLibrary.scopePicker.accessViewHint`,hintFallback:`Read-only — queries + subscriptions`},{value:`create`,labelKey:`uiLibrary.scopePicker.accessCreate`,labelFallback:`Create`,icon:Gt,hintKey:`uiLibrary.scopePicker.accessCreateHint`,hintFallback:`Mutations that create or update`},{value:`delete`,labelKey:`uiLibrary.scopePicker.accessDelete`,labelFallback:`Delete`,icon:Pe,hintKey:`uiLibrary.scopePicker.accessDeleteHint`,hintFallback:`Destructive ops (delete/revoke/reset/…)`}],Woe=[`device`,`system`];function Goe(){return{type:`capability`,target:``,access:[`view`]}}function Koe(e,t){if(e==null)return[];let n=new Set;for(let r of[`view`,`create`,`delete`])for(let i of Fa(e,t,r))n.add(i);return[...n]}function qoe(e,t,n,r){let i;switch(e){case`addon`:i=n;break;case`capability`:i=r;break;case`category`:i=Woe.map(e=>({value:e,label:e}));break}if(t==null)return i;let a=new Set(t.filter(t=>t.type!==`device`&&t.type===e).map(e=>e.target));return i.filter(e=>a.has(e.value))}function Joe(e,t){if(t==null)return[`view`,`create`,`delete`];let n=t.filter(t=>t.type===e.type?t.type===`device`&&e.type===`device`?!0:t.type!==`device`&&e.type!==`device`?t.target===e.target:!1:!1);if(n.length===0)return[];let r=new Set;for(let e of n)for(let t of e.access)r.add(t);return[...r]}function g8({value:e,onChange:t,clampToParent:n,emptyHint:r}){let i=q(),{data:a}=Cu(),{data:o}=dm({}),s=p(()=>(a??[]).map(e=>({value:e.manifest.id,label:e.manifest.id})).sort((e,t)=>e.label.localeCompare(t.label)),[a]),l=p(()=>[...ba].toSorted().map(e=>({value:e,label:e})),[]),u=p(()=>(o??[]).map(e=>({id:e.id,type:e.type,location:e.location,parentDeviceId:e.parentDeviceId})),[o]),d=p(()=>n==null?null:Koe(n,u),[n,u]),f=(e,t)=>{let n=[...t];switch(e){case`category`:return{type:`category`,target:`device`,access:n};case`capability`:return{type:`capability`,target:``,access:n};case`addon`:return{type:`addon`,target:``,access:n};case`device`:return{type:`device`,selector:{kind:`ids`,ids:[]},access:n}}},m=(n,r)=>{t(e.map((e,t)=>{if(t!==n)return e;if(r.type!==void 0&&r.type!==e.type)return f(r.type,r.access??e.access);let i=[...r.access??e.access];if(e.type===`device`){let t={type:`device`,selector:r.selector??e.selector,access:i},n=`includeLinked`in r?r.includeLinked:e.includeLinked;return n===void 0?t:{...t,includeLinked:n}}return e.type===`category`?{type:`category`,target:r.target??e.target,access:i}:e.type===`capability`?{type:`capability`,target:r.target??e.target,access:i}:{type:`addon`,target:r.target??e.target,access:i}}))},h=n=>{t(e.filter((e,t)=>t!==n))};return c(`div`,{className:`space-y-2`,children:[e.length===0&&r&&v(`div`,{className:`text-[10px] text-foreground-subtle italic px-2 py-2`,children:r}),e.map((e,t)=>{let r=Joe(e,n);return c(`div`,{className:`flex flex-wrap items-start gap-1.5 rounded border border-border bg-surface px-2 py-1.5`,children:[c(`select`,{value:e.type,onChange:e=>m(t,{type:e.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:[v(`option`,{value:`category`,children:`category`}),v(`option`,{value:`capability`,children:`capability`}),v(`option`,{value:`addon`,children:`addon`}),v(`option`,{value:`device`,children:`device`})]}),e.type===`device`?c(`div`,{className:`min-w-[200px] flex-1 space-y-1.5`,children:[v(f6,{dense:!0,value:e.selector,onChange:e=>m(t,{selector:e}),clampToDeviceIds:d}),c(`label`,{className:`flex flex-wrap items-center gap-1.5 text-[10px] text-foreground-subtle`,children:[i(`uiLibrary.scopePicker.linkedDevices`,`Linked devices`),c(`select`,{value:e.includeLinked===void 0?``:e.includeLinked?`yes`:`no`,onChange:e=>m(t,{includeLinked:Hoe[e.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:[v(`option`,{value:``,children:i(`uiLibrary.scopePicker.automatic`,`Automatic (view inherits)`)}),v(`option`,{value:`yes`,children:i(`uiLibrary.scopePicker.alwaysIncluded`,`Always included`)}),v(`option`,{value:`no`,children:i(`uiLibrary.scopePicker.neverIncluded`,`Never included`)})]})]})]}):c(`select`,{value:e.target,onChange:e=>m(t,{target:e.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:[v(`option`,{value:``,children:i(`uiLibrary.scopePicker.pickType`,`— pick {{type}} —`,{type:e.type})}),qoe(e.type,n,s,l).map(e=>v(`option`,{value:e.value,children:e.label},e.value))]}),v(`div`,{className:`flex items-center gap-1`,children:Uoe.map(({value:a,labelKey:o,labelFallback:s,icon:l,hintKey:u,hintFallback:d})=>{let f=i(o,s),p=i(u,d),h=e.access.includes(a),g=n!=null&&!r.includes(a)&&!h;return c(`label`,{title:g?i(`uiLibrary.scopePicker.notGranted`,`{{hint}} — not granted by your scope`,{hint:p}):p,className:`inline-flex items-center gap-1 rounded px-1.5 py-1 text-[10px] cursor-pointer transition-colors ${h?`bg-primary/15 text-primary font-medium`:`text-foreground-subtle hover:bg-foreground-subtle/10`} ${g?`opacity-40 cursor-not-allowed`:``}`,children:[v(`input`,{type:`checkbox`,checked:h,disabled:g,onChange:n=>{let r=new Set(e.access);n.target.checked?r.add(a):r.delete(a),m(t,{access:[...r]})},className:`sr-only`}),v(l,{className:`h-3 w-3`}),f]},a)})}),v(`button`,{type:`button`,onClick:()=>h(t),className:`rounded p-1 text-foreground-subtle hover:bg-danger/10 hover:text-danger transition-colors`,title:i(`uiLibrary.scopePicker.removeScope`,`Remove scope`),children:v(Zn,{className:`h-3 w-3`})})]},t)}),c(`button`,{type:`button`,onClick:()=>{t([...e,Goe()])},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:[v(Se,{className:`h-3 w-3`}),i(`uiLibrary.scopePicker.addScope`,`Add scope`)]})]})}function _8(e,t=Fn){for(let n of e){if(n.type===`device`){let e=Yoe(n.selector,t);if(e!==null)return e}else if(n.target.trim().length===0)return t(`uiLibrary.scopePicker.pickTarget`,`Scope {{type}}: pick a target`,{type:n.type});if(n.access.length===0){let e=n.type===`device`?m6(n.selector):n.target;return t(`uiLibrary.scopePicker.pickAccess`,`Scope {{type}}:{{target}}: pick at least one access`,{type:n.type,target:e})}}return null}function Yoe(e,t){switch(e.kind){case`all`:return null;case`ids`:return e.ids.length===0?t(`uiLibrary.scopePicker.pickDevice`,`Scope device: pick at least one device`):null;case`types`:return e.types.length===0?t(`uiLibrary.scopePicker.pickDeviceType`,`Scope device: pick at least one device type`):null;case`locations`:return e.locations.length===0?t(`uiLibrary.scopePicker.pickRoom`,`Scope device: pick at least one room`):null}}E();function Xoe(e,t){let n=document.createElement(`a`);n.href=t,n.download=e,document.body.appendChild(n),n.click(),document.body.removeChild(n)}function Zoe({trpc:e,deviceId:t,deviceName:n,size:r=`sm`,className:i}){let a=q(),[o,s]=C(!1),[l,u]=C(!1),[d,f]=C(null),p=n.replace(/[^a-zA-Z0-9_.-]+/g,`_`),m=_(async n=>{s(!0),f(null),u(!1);try{let r=await e.snapshot.getSnapshot.query({deviceId:t,force:!0});if(!r)throw Error(`No snapshot available`);let i=`data:${r.contentType};base64,${r.base64}`;if(n===`copy`)try{await navigator.clipboard.writeText(i)}catch{throw Error(`Clipboard unavailable`)}else{let e=r.contentType.includes(`png`)?`png`:`jpg`;Xoe(`${p}-${new Date().toISOString().replace(/[:.]/g,`-`)}.${e}`,i)}u(!0),setTimeout(()=>u(!1),1500)}catch(e){f(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e,t,p]),h=r===`md`?`h-9 px-3 text-sm gap-2`:`h-7 px-2.5 text-[11px] gap-1.5`,[g,y]=C(null),[b,x]=C(!1),S=()=>{x(!1),y(setTimeout(()=>{x(!0),m(`copy`)},600))},w=()=>{g&&(clearTimeout(g),y(null)),b||m(`download`)},T=()=>{g&&(clearTimeout(g),y(null))};return c(`button`,{type:`button`,title:a(`uiLibrary.snapshotButton.title`,`Click to download · long-press to copy`),disabled:o,onPointerDown:S,onPointerUp:w,onPointerLeave:T,onPointerCancel:T,className:$(`inline-flex items-center justify-center rounded-lg font-medium border border-border`,`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`,`disabled:opacity-50 transition-colors`,h,d&&`border-danger/40 text-danger`,i),children:[o?v(Gn,{className:`h-3.5 w-3.5 animate-spin`}):l?v(dt,{className:`h-3.5 w-3.5 text-success`}):v(ot,{className:`h-3.5 w-3.5`}),a(`uiLibrary.snapshotButton.snapshot`,`Snapshot`)]})}function v8({value:e,label:t,icon:n,subtext:r,valueClassName:i,trend:a,className:o}){return c(`div`,{className:$(`rounded-lg border border-border bg-surface p-2 sm:p-2.5 min-w-0`,o),children:[c(`div`,{className:`flex items-center gap-1.5 mb-0.5 min-w-0`,children:[n&&v(n,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),v(`span`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,title:t,children:t})]}),c(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[v(`p`,{className:$(`text-lg font-semibold leading-tight whitespace-nowrap overflow-hidden text-ellipsis min-w-0`,i??`text-foreground`),title:String(e),children:e}),a&&c(`span`,{className:$(`inline-flex items-center gap-0.5 text-xs font-medium shrink-0`,a.direction===`up`?`text-success`:`text-danger`),children:[a.direction===`up`?v(qt,{className:`h-3 w-3`}):v(ie,{className:`h-3 w-3`}),a.value,`%`]})]}),r&&v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5 truncate`,title:r,children:r})]})}var Qoe={online:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.online`,labelFallback:`Online`},offline:{colorClass:`bg-danger`,labelKey:`uiLibrary.statusBadge.offline`,labelFallback:`Offline`},degraded:{colorClass:`bg-warning`,labelKey:`uiLibrary.statusBadge.degraded`,labelFallback:`Degraded`},unknown:{colorClass:`bg-foreground-subtle`,labelKey:`uiLibrary.statusBadge.unknown`,labelFallback:`Unknown`},running:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.running`,labelFallback:`Running`},stopped:{colorClass:`bg-foreground-subtle`,labelKey:`uiLibrary.statusBadge.stopped`,labelFallback:`Stopped`},error:{colorClass:`bg-danger`,labelKey:`uiLibrary.statusBadge.error`,labelFallback:`Error`},idle:{colorClass:`bg-info`,labelKey:`uiLibrary.statusBadge.idle`,labelFallback:`Idle`},enabled:{colorClass:`bg-success`,labelKey:`uiLibrary.statusBadge.enabled`,labelFallback:`Enabled`},disabled:{colorClass:`bg-warning`,labelKey:`uiLibrary.statusBadge.disabled`,labelFallback:`Disabled`}};function y8({status:e,label:t,showDot:n=!0,showLabel:r=!0,size:i=`sm`,className:a}){let o=q(),s=Qoe[e];return c(`span`,{className:$(`inline-flex items-center gap-1.5`,i===`sm`?`text-xs`:`text-sm`,a),children:[n&&v(`span`,{className:$(`h-1.5 w-1.5 shrink-0 rounded-full`,s.colorClass),"aria-hidden":`true`}),r&&v(`span`,{className:`text-foreground`,children:t??o(s.labelKey,s.labelFallback)})]})}function $oe({timings:e,totalMs:t,className:n}){let r=q(),i=Object.entries(e);return i.length===0&&t===void 0?null:c(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2 ${n??``}`,children:[v(`div`,{className:`text-xs font-medium text-foreground-subtle uppercase tracking-wide`,children:r(`uiLibrary.stepTimings.timings`,`Timings`)}),c(`div`,{className:`space-y-1 text-xs`,children:[i.map(([e,t])=>c(`div`,{className:`flex justify-between`,children:[v(`span`,{className:`text-foreground-subtle`,children:e}),c(`span`,{className:`font-mono text-foreground`,children:[t.toFixed(1),`ms`]})]},e)),t!==void 0&&c(`div`,{className:`flex justify-between pt-1 border-t border-border font-medium text-foreground`,children:[v(`span`,{children:r(`uiLibrary.stepTimings.total`,`Total`)}),c(`span`,{className:`font-mono`,children:[t.toFixed(1),`ms`]})]})]})]})}function ese(e){return e.explicit?e.effectiveOn?`on`:`off`:`auto`}function b8({gate:e,busy:t=!1,onSet:n}){let r=q();if(e.kind===`zone-driven`)return v(`span`,{className:`inline-flex items-center rounded-md border border-violet-500/40 bg-violet-500/10 px-2 py-1 text-[11px] font-medium text-violet-400`,title:r(`uiLibrary.gateControl.zoneDrivenTitle`,`Runs where this camera has package zones — set on the Zones tab`),children:r(`uiLibrary.gateControl.zones`,`Zones`)});let i=ese(e),a=(e,r,a,o)=>v(`button`,{type:`button`,role:`radio`,"aria-checked":i===e,disabled:t,onClick:()=>n(a),className:$(`h-9 min-w-12 px-3 text-xs font-medium transition-colors md:h-8`,i===e?o:`text-foreground-subtle hover:bg-muted/60`,t&&`cursor-not-allowed opacity-50`),children:r});return c(`div`,{className:`flex items-center gap-2`,children:[c(`div`,{role:`radiogroup`,"aria-label":r(`uiLibrary.gateControl.runsOnCamera`,`Runs on this camera`),title:r(`uiLibrary.gateControl.catalogDefault`,`Catalog default: {{state}}`,{state:e.defaultOn?r(`uiLibrary.gateControl.on`,`on`):r(`uiLibrary.gateControl.off`,`off`)}),className:`inline-flex overflow-hidden rounded-md border border-border`,children:[a(`auto`,r(`uiLibrary.gateControl.autoLabel`,`Auto`),null,`bg-primary/15 text-primary`),v(`span`,{className:`w-px self-stretch bg-border`,"aria-hidden":!0}),a(`on`,r(`uiLibrary.gateControl.onLabel`,`On`),!0,`bg-emerald-500 text-white`),v(`span`,{className:`w-px self-stretch bg-border`,"aria-hidden":!0}),a(`off`,r(`uiLibrary.gateControl.offLabel`,`Off`),!1,`bg-foreground-subtle/70 text-white`)]}),v(`span`,{className:`hidden text-[10px] text-foreground-subtle @3xl/inspector:inline`,children:r(`uiLibrary.gateControl.defaultState`,`default: {{state}}`,{state:e.defaultOn?r(`uiLibrary.gateControl.on`,`on`):r(`uiLibrary.gateControl.off`,`off`)})})]})}function tse({gate:e}){let t=q();if(e.kind===`zone-driven`)return v(`span`,{className:`shrink-0 text-[9px] font-semibold uppercase text-violet-400`,children:t(`uiLibrary.gateControl.zonesBadge`,`zones`)});let n=e.effectiveOn;return v(`span`,{className:$(`shrink-0 rounded px-1.5 py-px text-[9px] font-semibold uppercase`,n?`bg-emerald-500/15 text-emerald-500`:`bg-muted text-foreground-subtle`,e.explicit&&`ring-1 ring-inset ring-current`),title:e.explicit?t(`uiLibrary.gateControl.setForCamera`,`Set for this camera`):t(`uiLibrary.gateControl.catalogDefaultTitle`,`Catalog default`),children:n?t(`uiLibrary.gateControl.on`,`on`):t(`uiLibrary.gateControl.off`,`off`)})}function x8({label:e,options:t,value:n,onChange:r}){return v(`div`,{role:`radiogroup`,"aria-label":e,className:`flex flex-wrap items-center gap-1`,children:t.map(e=>v(`button`,{type:`button`,role:`radio`,"aria-checked":n===e.value,disabled:e.disabled===!0,title:e.disabled===!0?e.reason:void 0,onClick:()=>r(e.value),className:$(`h-9 rounded-md border px-2.5 text-[11px] font-medium transition-colors md:h-7`,n===e.value?`border-primary/50 bg-primary/15 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,e.disabled===!0&&`cursor-not-allowed opacity-50 hover:bg-transparent hover:text-foreground-subtle`),children:e.label},e.value))})}E();var nse=432;function S8(e){let t=Math.max(0,e.viewportWidth-e.scroller.right),n=Math.min(e.widthPx,e.scroller.right);return{top:Math.max(0,e.scroller.top),height:Math.max(0,e.scroller.bottom-Math.max(0,e.scroller.top)),right:t,width:n}}function rse(e){for(let t=e?.parentElement??null;t!==null;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if(e===`auto`||e===`scroll`)return t}return null}function ise(e,t){let[n,r]=C(null);return u(()=>{if(!t)return;let n=rse(e.current),i=()=>{r(S8({scroller:n?.getBoundingClientRect()??{top:0,bottom:window.innerHeight,right:window.innerWidth},viewportWidth:window.innerWidth,widthPx:432}))};i();let a=typeof ResizeObserver>`u`?null:new ResizeObserver(i);return n&&a?.observe(n),window.addEventListener(`resize`,i),()=>{a?.disconnect(),window.removeEventListener(`resize`,i)}},[e,t]),n}function C8({open:e,anchor:t,onClose:n,label:r,children:i}){let a=dl(),o=ise(t,e&&!a);return a?v(SL,{open:e,onOpenChange:e=>!e&&n(),children:v(TL,{placement:`sheet-on-mobile`,scroll:`body`,"aria-label":r,className:`h-[100dvh] max-h-none w-full max-w-full rounded-none border-0 p-0 pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:e&&i})}):e?v(`aside`,{"aria-label":r,"data-step-dock":!0,className:`fixed z-30 flex flex-col border-l border-border bg-surface shadow-2xl`,style:o===null?{top:0,bottom:0,right:0,width:432}:{top:o.top,height:o.height,right:o.right,width:o.width},children:i}):null}function w8({onClick:e}){let t=q();return c(`button`,{type:`button`,onClick:e,className:`inline-flex h-9 items-center gap-0.5 rounded-md border border-border px-2 text-xs text-foreground hover:bg-surface-hover`,children:[v(ge,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`uiLibrary.stepDetailDock.steps`,`Steps`)]})}E();function ase({dirtyCount:e,saving:t,status:n,error:r,onSave:i,onDiscard:a,scope:o}){let s=q(),l=e>0,u=t?s(`uiLibrary.stepInspector.saving`,`Saving…`):l?s(`uiLibrary.stepInspector.unsaved`,{one:`{{count}} unsaved change`,other:`{{count}} unsaved changes`},{count:e}):n===`saved`?s(`uiLibrary.stepInspector.saved`,`Saved`):n===`error`?r??s(`uiLibrary.stepInspector.saveFailed`,`Save failed`):s(`uiLibrary.stepInspector.noChanges`,`No unsaved changes`);return c(`footer`,{className:`shrink-0 space-y-2 border-t border-border bg-surface px-4 py-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] md:pb-2`,children:[o!==void 0&&v(`div`,{"data-save-scope":!0,children:o}),c(`div`,{className:`flex items-center gap-2`,children:[v(`span`,{role:`status`,className:$(`min-w-0 flex-1 truncate text-[11px]`,n===`error`&&!l?`text-danger`:l?`text-amber-500`:`text-foreground-subtle`),children:u}),v(_A,{variant:`outline`,size:`md`,disabled:!l||t,onClick:a,children:s(`uiLibrary.stepInspector.discard`,`Discard`)}),v(_A,{variant:`primary`,size:`md`,disabled:!l||t,onClick:i,children:s(`uiLibrary.stepInspector.save`,`Save`)})]})]})}var T8=D(function({title:e,subtitle:t,headerActions:n,headerExtra:r,leading:i,saveBar:a,onEscape:o,children:s,className:l},u){let d=y();return c(`section`,{"aria-labelledby":d,onKeyDown:e=>{e.key!==`Escape`||o===void 0||(e.stopPropagation(),o())},className:$(`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface`,l),children:[c(`header`,{className:`shrink-0 space-y-2 border-b border-border px-4 py-2.5`,children:[c(`div`,{className:`flex flex-wrap items-start gap-x-3 gap-y-2`,children:[i,c(`div`,{className:`min-w-[9rem] flex-1`,children:[v(`h2`,{id:d,ref:u,tabIndex:-1,title:e,className:`line-clamp-2 break-words text-sm font-semibold leading-snug text-foreground outline-none focus-visible:ring-2 focus-visible:ring-primary rounded`,children:e}),t!==void 0&&v(`div`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:t})]}),n]}),r]}),v(`div`,{"data-inspector-body":!0,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain px-4 py-3`,children:s}),a!==void 0&&v(ase,{...a})]})}),ose={camera:`border-primary/40 bg-primary/10 text-primary`,node:`border-border bg-muted/40 text-foreground`,default:`border-border/60 text-foreground-subtle`,cluster:`border-primary/40 bg-primary/5 text-primary`};function E8({label:e,format:t,modelId:n,source:r,sourceLabel:i,models:a,defaultModelId:o,expanded:s,onToggle:l,onChangeModel:u,onReset:d,resetLabel:f,note:p,extra:m,changed:h=!1,disabled:g=!1}){let _=q(),y=a.length>0&&p===void 0,b=y||m!==void 0;return c(`div`,{className:$(`rounded-md border border-border`,s&&`bg-muted/10`),children:[c(`div`,{className:$(Ft,`space-y-1`),children:[c(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-xs`,children:[v(`span`,{className:`font-medium text-foreground`,children:e}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:t}),v(`span`,{className:$(`ml-auto rounded border px-1.5 py-px text-[10px] font-medium`,ose[r]),children:i})]}),c(`div`,{className:`flex items-center gap-2`,children:[c(`span`,{className:`min-w-0 flex-1 truncate font-mono text-xs text-foreground`,children:[n??`—`,h&&v(`span`,{className:`ml-1 text-amber-500`,children:`•`})]}),d!==void 0&&v(`button`,{type:`button`,className:`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`,disabled:g,onClick:d,children:f??_(`uiLibrary.stepModelRow.reset`,`Reset`)}),b&&v(`button`,{type:`button`,className:$(`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`,`min-h-9 md:min-h-0`),"aria-expanded":s,"aria-label":_(`uiLibrary.stepModelRow.changeModelFor`,`Change model for {{label}}`,{label:e}),disabled:g,onClick:l,children:s?_(`uiLibrary.stepModelRow.done`,`Done`):y?_(`uiLibrary.stepModelRow.change`,`Change`):_(`uiLibrary.stepModelRow.route`,`Route`)})]})]}),p!==void 0&&v(`div`,{className:`border-t border-border/60 px-3 py-1.5 text-[10px] leading-snug text-foreground-subtle`,children:p}),s&&b&&c(`div`,{className:`space-y-3 border-t border-border/60 px-3 py-3`,children:[y&&v(Yz,{models:a,value:n??``,defaultModelId:o,disabled:g,onChange:u}),m]})]})}function D8(e,t){let n=e.toLowerCase();return t.every(e=>n.includes(e))}function O8(e,t){let n=t.trim().toLowerCase().split(/\s+/).filter(Boolean);if(n.length===0)return e.map(e=>({addonId:e.addonId}));let r=[];for(let t of e){if(D8(t.name,n)){r.push({addonId:t.addonId});continue}let e=t.fieldLabels.find(e=>D8(e,n));e!==void 0&&r.push({addonId:t.addonId,matchedField:e})}return r}function k8(e){let t=[],n=[],r=new Map;for(let i of e.slots)for(let e of i.addons){let i={addonId:e.id,addonName:e.name,slot:e.slot,inputClasses:e.inputClasses,outputClasses:e.outputClasses,children:[]};e.slot===`audio-classifier`?t.push(i):(n.push(i),r.set(e.id,i))}let i=[];for(let e of n){if(e.inputClasses.length===0){i.push(e);continue}let t=n.find(t=>t.addonId!==e.addonId&&t.outputClasses.some(t=>e.inputClasses.includes(t)));t&&t.children.push(e)}return[...i,...t]}E();function sse(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cse({deviceId:e,value:t,onChange:n,disabled:r,label:i,className:a}){let o=q(),s=y(),l=cf({deviceId:e},{refetchOnWindowFocus:!1}),[u,d]=C([]);b(()=>{if(!l.data)return;let t=`${e}/`,n=[];for(let e of l.data){if(!e.enabled)continue;let r=e.brokerId.startsWith(t)?e.brokerId.slice(t.length):e.brokerId;n.push(r)}d(n)},[l.data,e]);let f=p(()=>[{value:`auto`,label:o(`uiLibrary.streamBrokerSelector.auto`,`Auto (best available)`)},...u.map(e=>({value:e,label:sse(e)}))],[u,o]),m=i??o(`uiLibrary.streamBrokerSelector.preferred`,`Preferred stream`),h=l.isLoading?o(`uiLibrary.streamBrokerSelector.loading`,`Loading available streams…`):l.isError?o(`uiLibrary.streamBrokerSelector.loadFailed`,`Could not load streams — only Auto available.`):f.length===1?o(`uiLibrary.streamBrokerSelector.noneEnabled`,`No enabled streams found — only Auto available.`):null;return c(`div`,{className:a,children:[v(`label`,{id:s,className:`text-xs font-medium text-foreground-muted block mb-1`,children:m}),v(Yl,{"aria-labelledby":s,options:f,value:t,disabled:r,onChange:e=>n(e.target.value)}),h!==null&&v(`p`,{className:`text-foreground-subtle text-[10px] mt-1`,children:h})]})}E();function lse(e){return e===`streaming`?`bg-emerald-500`:e===`connecting`?`bg-amber-500`:e===`error`?`bg-rose-500`:`bg-zinc-500`}function use(e){let 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 A8({className:e}){return v(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polygon`,{points:`5 3 19 12 5 21 5 3`})})}function dse({className:e}){return v(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`rect`,{x:`6`,y:`6`,width:`12`,height:`12`,rx:`1`})})}function fse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`path`,{d:`M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3z`}),v(`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`}),v(`line`,{x1:`12`,y1:`19`,x2:`12`,y2:`23`}),v(`line`,{x1:`8`,y1:`23`,x2:`16`,y2:`23`})]})}function pse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`currentColor`,children:[v(`circle`,{cx:`5`,cy:`12`,r:`2`}),v(`circle`,{cx:`12`,cy:`12`,r:`2`}),v(`circle`,{cx:`19`,cy:`12`,r:`2`})]})}function j8({label:e,active:t,onClick:n}){return c(`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:[v(`span`,{children:e}),v(`span`,{className:`inline-block h-3 w-5 rounded-full transition-colors ${t?`bg-primary`:`bg-foreground-subtle/30`} relative`,children:v(`span`,{className:`absolute top-0.5 h-2 w-2 rounded-full bg-white transition-all ${t?`left-2.5`:`left-0.5`}`})})]})}function mse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`circle`,{cx:`12`,cy:`12`,r:`2`,fill:`currentColor`}),v(`path`,{d:`M16.24 7.76a6 6 0 0 1 0 8.49M7.76 16.24a6 6 0 0 1 0-8.49M19.07 4.93a10 10 0 0 1 0 14.14M4.93 19.07a10 10 0 0 1 0-14.14`})]})}function M8({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`polyline`,{points:`23 4 23 10 17 10`}),v(`polyline`,{points:`1 20 1 14 7 14`}),v(`path`,{d:`M3.51 9a9 9 0 0114.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0020.49 15`})]})}function hse({className:e}){return c(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[v(`line`,{x1:`2`,y1:`2`,x2:`22`,y2:`22`}),v(`path`,{d:`M10.41 10.41a2 2 0 11-2.83-2.83`}),v(`line`,{x1:`13.5`,y1:`13.5`,x2:`6`,y2:`21`}),v(`path`,{d:`M18 12l-1.5-1.5`}),v(`path`,{d:`M21 15V5a2 2 0 00-2-2H5`}),v(`path`,{d:`M21 21H5a2 2 0 01-2-2V11`})]})}function N8({serverUrl:e,createSession:t,sendAnswer:n,handleOffer:r,getIceServers:i,addIceCandidate:a,getIceCandidates:o,closeSession:s,getSessionState:l,getSessionDebug:u,applyDownlinkProbe:d,playbackUrl:m,playbackFormat:h,playbackAuthToken:g,onExitPlayback:y,posterUrl:x,streams:S,activeStreamId:w,onStreamChange:T,deviceName:E,phase:D,pipelineMetrics:O,detections:k,stationaryObjects:A,defaultShowDetections:j=!0,defaultShowMotion:M=!1,streamStats:N,autoPlay:F=!1,showPlayStop:I=!1,snapshotSrc:L,snapshotLoading:R=!1,onRefreshSnapshot:z,showStreamStats:B=!1,children:V,extraOverlay:H,ptzAvailable:U=!1,ptzShown:ee=!1,ptzOverlay:W,onPtzToggle:G,intercomAvailable:te=!1,intercomShown:ne=!1,onIntercomToggle:re,chromeless:K=!1,className:ie}){let ae=q(),oe=bn(),se=dL(),[ce,le]=C(F),[ue,de]=C(j),[fe,pe]=C(!0),[me,he]=C(!0),[ge,_e]=C(M),[ve,ye]=C(null),[be,xe]=C([]),[Se,Ce]=C(-1),[we,Te]=C(!1),Ee=f(null);b(()=>{if(!we)return;function e(e){Ee.current&&!Ee.current.contains(e.target)&&Te(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[we]),b(()=>{Ce(-1)},[m]);let De=_(e=>{xe(e)},[]),Oe=w??ve??S?.[0]?.id??``,ke=S?.find(e=>e.id===Oe)??S?.[0],Ae=ke?.inputFps==null?null:{status:ke.status??`unknown`,inputFps:ke.inputFps,bitrateKbps:ke.bitrateKbps??0},je=e=>{ye(e),T?.(e),ce&&I&&(le(!1),setTimeout(()=>le(!0),50))},Me=p(()=>{let e=ke?.target;if(!(!e||!t))return n=>t(e,n)},[t,ke]),Ne=p(()=>{let e=ke?.target;if(!(!e||!r))return(t,n)=>r(e,t,n)},[r,ke]),Pe=p(()=>{if(r)return(e,t,n)=>r(n,t,e)},[r]),Fe=S,Ie=()=>le(!0),Le=()=>le(!1),Re=O?.phase??D,ze=Re===`active`,Be=!!k,Ve=Be&&(ue||ge),He=U&&ee&&!!W,Ue=!!m,We=Ue||(I?ce:!0);return c(`div`,{className:`overflow-hidden ${K?``:`rounded-xl border border-border bg-surface`} ${ie??``}`,children:[c(`div`,{className:`flex flex-wrap items-center justify-between gap-2 px-3 py-2 border-b border-border`,children:[c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(N??Ae)&&v(`span`,{className:`shrink-0 w-2 h-2 rounded-full ${lse((N??Ae).status)}`}),E&&v(`span`,{className:`text-xs font-medium text-foreground truncate`,children:E}),!Ue&&Fe&&Fe.length>1&&c(`div`,{className:`relative`,children:[v(`select`,{"data-testid":`stream-profile-select`,value:Oe,onChange:e=>je(e.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:Fe.map(e=>v(`option`,{value:e.id,children:e.label},e.id))}),v(`span`,{className:`pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle`,children:v(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polyline`,{points:`3 4.5 6 7.5 9 4.5`})})})]}),Ue&&be.length>1&&c(`div`,{className:`relative`,children:[v(`select`,{"data-testid":`vod-quality-select`,value:Se,onChange:e=>Ce(Number(e.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:be.map(e=>v(`option`,{value:e.value,children:e.label},e.value))}),v(`span`,{className:`pointer-events-none absolute right-1.5 top-1/2 -translate-y-1/2 text-foreground-subtle`,children:v(`svg`,{className:`h-2.5 w-2.5`,viewBox:`0 0 12 12`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:v(`polyline`,{points:`3 4.5 6 7.5 9 4.5`})})})]})]}),c(`div`,{className:`flex items-center gap-1.5 shrink-0 ml-auto`,children:[te&&!Ue&&c(`button`,{"data-testid":`stream-intercom-toggle`,"data-intercom-shown":ne?`true`:`false`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${ne?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,title:ne?ae(`uiLibrary.streamPanel.closeIntercom`,`Close intercom`):ae(`uiLibrary.streamPanel.openIntercom`,`Open intercom`),children:[v(fse,{className:`h-3 w-3`}),v(`span`,{className:`hidden xl:inline`,children:ae(`uiLibrary.streamPanel.intercom`,`Intercom`)})]}),oe.map(e=>{let t=e.tone===`primary`?`bg-primary text-primary-foreground`:`bg-primary/15 text-primary`;return c(`button`,{type:`button`,"data-toolbar-button-id":e.id,"data-toolbar-button-active":e.active?`true`:`false`,onClick:e.onClick,disabled:e.disabled,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors disabled:opacity-50 ${e.active?t:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,title:e.title??e.label,children:[e.icon,v(`span`,{className:`hidden xl:inline`,children:e.label})]},e.id)}),I&&c(`button`,{"data-testid":`stream-play-toggle`,"data-stream-playing":We?`true`:`false`,"data-vod":Ue?`true`:`false`,onClick:Ue?y:We?Le:Ie,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors ${Ue?`bg-primary/10 text-primary hover:bg-primary/20`:We?`bg-danger/10 text-danger hover:bg-danger/20`:`bg-primary/10 text-primary hover:bg-primary/20`}`,title:Ue?ae(`uiLibrary.streamPanel.returnToLive`,`Return to live`):We?ae(`uiLibrary.streamPanel.stopStream`,`Stop stream`):ae(`uiLibrary.streamPanel.startStream`,`Start stream`),children:[v(Ue?mse:We?dse:A8,{className:`h-3 w-3`}),v(`span`,{className:`hidden xl:inline`,children:Ue?ae(`uiLibrary.streamPanel.live`,`Live`):We?ae(`uiLibrary.streamPanel.stop`,`Stop`):ae(`uiLibrary.streamPanel.play`,`Play`)})]}),z&&!Ue&&c(`button`,{"data-testid":`stream-snapshot-refresh`,onClick:z,disabled:R,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:ae(`uiLibrary.streamPanel.forceRefresh`,`Force snapshot refresh`),children:[v(M8,{className:`h-3 w-3 ${R?`animate-spin`:``}`}),v(`span`,{className:`hidden xl:inline`,children:ae(`uiLibrary.streamPanel.snapshot`,`Snapshot`)})]}),(Be||U||O||Re||N||Ae&&Ae.inputFps>0)&&c(`div`,{ref:Ee,className:`relative`,children:[v(`button`,{onClick:()=>Te(e=>!e),title:ae(`uiLibrary.streamPanel.moreControls`,`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:v(pse,{className:`h-3.5 w-3.5`})}),we&&c(`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:[B&&N&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.input`,`Input`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[N.inputFps.toFixed(1),` fps`]})]}),c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.uptime`,`Uptime`)}),v(`span`,{className:`tabular-nums text-foreground`,children:use(N.uptimeMs)})]})]}),!B&&Ae&&Ae.inputFps>0&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.input`,`Input`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[Ae.inputFps.toFixed(1),` fps`]})]}),Ae.bitrateKbps>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.bitrate`,`Bitrate`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[Ae.bitrateKbps,` kbps`]})]})]}),(O||Be&&Re)&&c(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle border-b border-border-subtle`,children:[c(`div`,{className:`flex justify-between gap-3 items-center`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.phase`,`Phase`)}),c(`span`,{className:`flex items-center gap-1 font-semibold uppercase tracking-wider ${ze?`text-red-400`:`text-emerald-400`}`,children:[v(`span`,{className:`w-1.5 h-1.5 rounded-full ${ze?`bg-red-500 animate-pulse`:`bg-emerald-500`}`}),ze?ae(`uiLibrary.streamPanel.active`,`Active`):ae(`uiLibrary.streamPanel.watching`,`Watching`)]})]}),O&&O.detectionFps>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.detection`,`Detection`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[O.detectionFps.toFixed(1),` det/s`]})]}),O&&O.avgInferenceMs>0&&c(`div`,{className:`flex justify-between gap-3`,children:[v(`span`,{children:ae(`uiLibrary.streamPanel.inference`,`Inference`)}),c(`span`,{className:`tabular-nums text-foreground`,children:[O.avgInferenceMs.toFixed(0),` ms`]})]})]}),Be&&c(P,{children:[v(j8,{label:ae(`uiLibrary.streamPanel.showDetections`,`Show detections`),active:ue,onClick:()=>de(e=>!e)}),ue&&c(P,{children:[v(j8,{label:ae(`uiLibrary.streamPanel.moving`,`…moving`),active:fe,onClick:()=>pe(e=>!e)}),v(j8,{label:ae(`uiLibrary.streamPanel.stationary`,`…stationary`),active:me,onClick:()=>he(e=>!e)})]}),v(j8,{label:ae(`uiLibrary.streamPanel.showMotion`,`Show motion`),active:ge,onClick:()=>_e(e=>!e)})]}),U&&v(j8,{label:ae(`uiLibrary.streamPanel.ptzControls`,`PTZ controls`),active:ee,onClick:()=>{G?.(),Te(!1)}})]})]})]})]}),m?c(`div`,{className:`aspect-video relative`,children:[v(A6,{url:m,...h?{format:h}:{},authToken:g??null,onQualityOptions:De,selectedLevel:Se,...x?{posterUrl:x}:{}}),H||He?c(P,{children:[H,He&&W]}):null]}):We&&e?v(`div`,{className:`aspect-video relative`,children:v(QH,{serverUrl:e,streamKey:Oe,autoPlay:!0,className:`w-full h-full`,createSession:Me,sendAnswer:n,handleOffer:Ne,reoffer:Pe,getSessionState:l,...u?{getSessionDebug:u}:{},...d?{applyDownlinkProbe:d}:{},getIceServers:i,addIceCandidate:a,getIceCandidates:o,closeSession:s,...se.bindControlChannel?{onControlChannel:se.bindControlChannel}:{},...x?{posterUrl:x}:{},overlay:Ve||H||He?c(P,{children:[Ve&&v(eK,{detections:k,showPhaseIndicator:!1,showMotionZones:ge,showMotionRaw:ge,showDetections:ue,showMoving:fe,showStationary:me,...A===void 0?{}:{stationaryObjects:A}}),H,He&&W]}):void 0})}):v(gse,{src:L??null,isLoading:R,onPlay:Ie,onRetry:z,extraOverlay:H||He?c(P,{children:[H,He&&W]}):null,suppressPlayHover:!!H||He}),V]})}function gse({src:e,isLoading:t,onPlay:n,onRetry:r,extraOverlay:i,suppressPlayHover:a=!1}){let o=q();return e?c(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:[v(`img`,{src:e,alt:o(`uiLibrary.streamPanel.cameraSnapshot`,`Camera snapshot`),className:`w-full h-full object-contain`}),!a&&v(`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:v(`div`,{className:`h-14 w-14 rounded-full bg-white/20 backdrop-blur-sm flex items-center justify-center`,children:v(A8,{className:`h-7 w-7 text-white ml-0.5`})})}),i]}):t?v(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:v(`div`,{className:`h-8 w-8 border-2 border-white/20 border-t-white/60 rounded-full animate-spin`})}):v(`div`,{className:`relative w-full aspect-video bg-black/90 flex items-center justify-center`,children:c(`div`,{className:`flex flex-col items-center gap-2 text-white/40`,children:[v(hse,{className:`h-8 w-8`}),v(`span`,{className:`text-xs`,children:o(`uiLibrary.streamPanel.noSnapshot`,`No snapshot available`)}),c(`div`,{className:`flex items-center gap-2 mt-1`,children:[r&&c(`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:[v(M8,{className:`h-3 w-3`}),o(`uiLibrary.streamPanel.retry`,`Retry`)]}),c(`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:[v(A8,{className:`h-3 w-3`}),o(`uiLibrary.streamPanel.playLive`,`Play Live`)]})]})]})})}E();var _se={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 P8({children:e,variant:t=`neutral`,mono:n,className:r}){return v(`span`,{className:$(`inline-flex items-center rounded-md px-2 py-0.5 text-[11px] font-bold leading-tight`,n&&`font-mono`,_se[t],r),children:e})}function vse({version:e,preRelease:t,className:n}){return v(P8,{variant:t??/-(alpha|beta|rc|dev|canary|next)/i.test(e)?`warning`:`success`,mono:!0,className:n,children:e})}function F8(e,t){return typeof e==`number`&&typeof t==`number`?e-t:String(e).localeCompare(String(t))}function I8(e){return`${[e.name,e.location??``,e.type??``,e.detail??``].join(` `)} ${String(e.id)}`.toLowerCase()}function L8(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e.length>0)}function R8(e,t){let n=L8(t);return n.length===0?e:e.filter(e=>{let t=I8(e);return n.every(e=>t.includes(e))})}function z8(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function B8(e){return e==null||e.trim()===``?null:e}function V8(e,t){return`${e??``}|${t??``}`}function H8(e,t){let n=new Set(t),r=new Map;for(let t of e){let e=B8(t.type),n=B8(t.location),i=V8(e,n),a=r.get(i);a===void 0?r.set(i,{type:e,location:n,devices:[t]}):a.devices.push(t)}let i=[];for(let[e,t]of r){let r=[...t.devices].sort((e,t)=>e.name.localeCompare(t.name)||F8(e.id,t.id));i.push({key:e,type:t.type,location:t.location,devices:r,selectedCount:r.filter(e=>n.has(e.id)).length})}return i.sort((e,t)=>z8(e.type,t.type)||z8(e.location,t.location))}function U8(e,t,n){let r=t.get(e.key);return r===void 0?n||e.selectedCount>0?!0:e.devices.length<=8:r}function W8(e,t,n,r){let i=new Set(t),a=[];for(let t of e){let e=U8(t,n,r);if(a.push({kind:`header`,key:`h:${t.key}`,group:t,expanded:e}),e)for(let e of t.devices)a.push({kind:`device`,key:`d:${String(e.id)}`,device:e,groupKey:t.key,selected:i.has(e.id)})}return a}function G8(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function K8(e,t){let n=[...e],r=new Set(e);for(let e of t.devices)r.has(e.id)||n.push(e.id);return n}function q8(e,t){let n=new Set(t.devices.map(e=>e.id));return e.filter(e=>!n.has(e))}function J8(e,t){return t||e.length<=6?{shown:e,hidden:0}:{shown:e.slice(0,6),hidden:e.length-6}}function Y8(e,t){let n=Math.max(0,Math.min(e.length,t));return{rows:e.slice(0,n),remaining:e.length-n}}var X8=[`zone`,`location`,`none`],Z8=`zone`;function Q8(e){return e===`zone`||e===`location`||e===`none`?e:Z8}function $8(e){return e.trim().toLowerCase()}var yse=1,bse=2;function xse(e,t){return e.name.localeCompare(t.name)||F8(e.id,t.id)}function e5(e){return e.kind===`zone`||e.kind===`location`?e.label:``}var t5={key:`-location`,heading:{kind:`no-location`},rank:bse},Sse={key:`-zone`,heading:{kind:`no-zone`},rank:yse};function n5(e){let t=new Map;for(let n of e)for(let e of n.locationKeys){let r=$8(e);t.has(r)||t.set(r,n)}return t}function Cse(e){return e===null?t5:{key:`l:${$8(e)}`,heading:{kind:`location`,label:e.trim()},rank:0}}function wse(e,t){if(e===null)return t5;let n=t.get($8(e));return n===void 0?Sse:{key:`z:${n.zoneKey}`,heading:{kind:`zone`,label:n.label},rank:0}}function r5(e,t,n,r){let i=new Set(t),a=[...e].sort(xse),o=e=>e.filter(e=>i.has(e.id)).length;if(n===`none`)return{groupBy:n,fallback:null,flat:!0,groups:[{key:`all`,type:null,location:null,devices:a,selectedCount:o(a)}]};let s=n===`zone`&&r.state!==`answered`?r.state:null,c=s===null?n:`location`,l=r.state===`answered`?n5(r.zones):new Map,u=new Map;for(let e of a){let t=B8(e.location),n=c===`zone`?wse(t,l):Cse(t),r=u.get(n.key);r===void 0?u.set(n.key,{heading:n.heading,rank:n.rank,devices:[e]}):r.devices.push(e)}return{groupBy:c,fallback:s,flat:!1,groups:[...u].sort(([,e],[,t])=>e.rank-t.rank||e5(e.heading).localeCompare(e5(t.heading))).map(([e,t])=>({key:e,type:null,location:t.heading.kind===`location`?t.heading.label:null,devices:t.devices,selectedCount:o(t.devices),heading:t.heading}))}}function i5(e,t,n,r){if(!e.flat)return W8(e.groups,t,n,r);let i=new Set(t),a=[];for(let t of e.groups)for(let e of t.devices)a.push({kind:`device`,key:`d:${String(e.id)}`,device:e,groupKey:t.key,selected:i.has(e.id)});return a}function a5(e,t){return{location:t===`location`?null:B8(e.location),type:B8(e.type)}}var o5=`(none)`,s5={query:``,types:[],zones:[],locations:[]},c5={key:o5,label:null};function l5(e,t,n){if(t===`type`){let t=B8(e.type);return t===null?c5:{key:t,label:t}}let r=B8(e.location);if(r===null)return c5;if(t===`location`)return{key:$8(r),label:r.trim()};if(n.state!==`answered`)return c5;let i=n5(n.zones).get($8(r));return i===void 0?c5:{key:i.zoneKey,label:i.label}}function u5(e,t,n){return l5(e,t,n).key}function Tse(e,t){return e.key===`(none)`||t.key===`(none)`?e.key===t.key?0:e.key===`(none)`?1:-1:(e.label??``).localeCompare(t.label??``)}function d5(e,t,n,r){if(t===`zone`&&r.state!==`answered`)return[];let i=new Map;for(let n of e){let e=l5(n,t,r),a=i.get(e.key);a===void 0?i.set(e.key,{label:e.label,count:1}):a.count++}for(let e of n)i.has(e)||i.set(e,{label:e===`(none)`?null:e,count:0});let a=[];for(let[e,t]of i)a.push({key:e,label:t.label,count:t.count});return a.sort(Tse)}function f5(e,t){return e.zones.length>0&&t.state!==`answered`}function p5(e,t,n,r){return n.length===0?e:e.filter(e=>n.includes(u5(e,t,r)))}function m5(e,t,n){let r=p5(R8(e,t.query),`type`,t.types,n);return p5(n.state===`answered`?p5(r,`zone`,t.zones,n):r,`location`,t.locations,n)}function h5(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function g5(e){return e.query.trim()!==``||e.types.length>0||e.zones.length>0||e.locations.length>0}function _5(){return s5}function v5(e,t,n){let r=new Set(t.map(e=>e.id)),i=new Set(n.map(e=>e.id));return e.filter(e=>r.has(e)&&!i.has(e)).length}function y5(e,t){return e.length>=2||t.length>0}E();function b5(e,t=Fn){if(e===null)return t(`uiLibrary.deviceFilterBar.noType`,`No type`);let n=e.replaceAll(`-`,` `);return n.charAt(0).toUpperCase()+n.slice(1)}function Ese(e,t){switch(e){case`zone`:return t(`uiLibrary.deviceFilterBar.zone`,`Zone`);case`location`:return t(`uiLibrary.deviceFilterBar.location`,`Location`);case`none`:return t(`uiLibrary.deviceFilterBar.none`,`None`)}}function Dse(e,t){switch(e){case`type`:return t(`uiLibrary.deviceFilterBar.type`,`Type`);case`zone`:return t(`uiLibrary.deviceFilterBar.zone`,`Zone`);case`location`:return t(`uiLibrary.deviceFilterBar.location`,`Location`)}}function Ose(e,t){switch(e){case`type`:return t(`uiLibrary.deviceFilterBar.noType`,`No type`);case`zone`:return t(`uiLibrary.deviceFilterBar.noZone`,`No zone`);case`location`:return t(`uiLibrary.deviceFilterBar.noLocation`,`No location`)}}function kse(e,t,n){return t.key===`(none)`||t.label===null?Ose(e,n):e===`type`?b5(t.label,n):t.label}function Ase({grouping:e}){let t=q();return c(`div`,{className:`mb-1.5`,children:[c(`div`,{role:`radiogroup`,"aria-label":t(`uiLibrary.deviceFilterBar.groupBy`,`Group by`),className:`flex flex-wrap items-center gap-1 text-[10px] text-foreground-subtle`,children:[v(`span`,{className:`mr-1 font-semibold uppercase tracking-wide`,children:t(`uiLibrary.deviceFilterBar.groupBy`,`Group by`)}),X8.map(n=>{let r=n===e.groupBy;return v(`button`,{type:`button`,role:`radio`,"aria-checked":r,onClick:()=>e.onGroupByChange(n),className:r?`rounded-md border border-primary bg-primary/10 px-1.5 py-0.5 text-[11px] text-primary`:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground-subtle hover:bg-surface-hover`,children:Ese(n,t)},n)})]}),e.fallback!==null&&v(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,"data-testid":`picker-zones-note`,children:e.fallback===`pending`?t(`uiLibrary.deviceFilterBar.zonesLoadingNote`,`Loading zones — grouped by location for now`):t(`uiLibrary.deviceFilterBar.zonesUnavailableNote`,`Zones unavailable — grouped by location`)})]})}function x5({facet:e,options:t,chosen:n,onChange:r,unavailable:i,disabled:a}){let o=q(),s=Dse(e,o),l=i===void 0?n.length===0?o(`uiLibrary.deviceFilterBar.all`,`All`):o(`uiLibrary.deviceFilterBar.nSelected`,`{{count}} selected`,{count:n.length}):i;return v(`div`,{"data-testid":`picker-filter-${e}`,children:c(gl,{children:[c(_l,{disabled:a||i!==void 0,className:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[s,`: `,l]}),v(bl,{className:`min-w-[200px] max-h-[40vh] overflow-y-auto p-1`,children:t.map(t=>{let i=kse(e,t,o);return c(`label`,{className:`flex cursor-pointer items-center gap-2 px-2 py-1 text-xs text-foreground hover:bg-surface-hover`,children:[v(BB,{checked:n.includes(t.key),onChange:()=>r(h5(n,t.key)),"aria-label":i}),v(`span`,{className:`min-w-0 flex-1 truncate`,children:i}),c(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.count,`)`]})]},t.key)})})]})})}function jse(e,t){if(e.state===`pending`)return t(`uiLibrary.deviceFilterBar.loadingZones`,`loading zones…`);if(e.state===`failed`)return t(`uiLibrary.deviceFilterBar.zonesUnavailable`,`zones unavailable`)}function S5({filters:e,onFiltersChange:t,typeOptions:n,zoneOptions:r,locationOptions:i,zones:a,grouping:o,searchPlaceholder:s,searchLabel:l,disabled:u=!1}){let d=f(null);As(d);let p=q(),[m,h]=C(e.query),g=f({filters:e,onFiltersChange:t});g.current={filters:e,onFiltersChange:t},b(()=>{if(m===g.current.filters.query)return;let e=setTimeout(()=>g.current.onFiltersChange({...g.current.filters,query:m}),200);return()=>clearTimeout(e)},[m]);let _=jse(a,p),y=_!==void 0||y5(r,e.zones),x=g5(e)||m.trim()!==``;return c(`div`,{className:`space-y-1.5`,"data-testid":`device-filter-bar`,children:[o!==void 0&&v(Ase,{grouping:o}),c(`div`,{className:Gk,children:[v(Ci,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),v(`input`,{ref:d,type:`text`,value:m,placeholder:s,"aria-label":l,className:`min-w-0 flex-1 bg-transparent text-xs text-foreground outline-none placeholder:text-foreground-disabled`,onChange:e=>h(e.target.value)})]}),c(`div`,{className:`flex flex-wrap items-center gap-1`,children:[y5(n,e.types)&&v(x5,{facet:`type`,options:n,chosen:e.types,onChange:n=>t({...e,types:n}),disabled:u}),y&&v(x5,{facet:`zone`,options:r,chosen:e.zones,onChange:n=>t({...e,zones:n}),..._===void 0?{}:{unavailable:_},disabled:u}),y5(i,e.locations)&&v(x5,{facet:`location`,options:i,chosen:e.locations,onChange:n=>t({...e,locations:n}),disabled:u}),x&&v(_A,{variant:`ghost`,"data-testid":`picker-reset-filters`,onClick:()=>{h(``),t(_5())},children:p(`uiLibrary.deviceFilterBar.resetFilters`,`Reset filters`)})]}),f5(e,a)&&v(`p`,{className:`text-[10px] text-foreground-subtle`,"data-testid":`picker-zone-filter-paused`,children:p(`uiLibrary.deviceFilterBar.zoneFilterPaused`,`Zone filter paused — zones not loaded`)})]})}function C5(e){let t=new Map;for(let n of e)t.set(n.id,n.name);let n=new Map;for(let r of e){let e=r.parentDeviceId;e!==null&&e!==r.id&&n.set(r.id,t.get(e)??`#${String(e)}`)}return n}function w5(e,t=Fn){if(!(e===void 0||e.length===0))return t(`uiLibrary.devicePicker.parentDetail`,`in {{parent}}`,{parent:e})}function T5(e){let t=e.filter(e=>typeof e.id==`number`);if(t.length===0)return e;let n=C5(t.map(e=>({id:e.id,name:e.name,parentDeviceId:e.parentDeviceId??null}))),r=!1,i=e.map(e=>{if(e.detail!==void 0||typeof e.id!=`number`)return e;let t=w5(n.get(e.id));return t===void 0?e:(r=!0,{...e,detail:t})});return r?i:e}E();function Mse(e,t){let n=t?.trim()??``;return n===``||n===e?e:`${e} (${n})`}function Nse(e,t,n){let r=new Map;for(let e of t)e.name!==void 0&&e.name!==``&&r.set(e.id,e.name);let i=new Map(n.map(e=>[e.id,e.name])),a=new Map;for(let t of e){let e=r.get(t.addonId);if(e===void 0)continue;let n=t.integrationId===void 0?null:i.get(t.integrationId)??null;a.set(t.id,Mse(e,n))}return a}var Pse=new Map,Fse=6e4;function Ise(e){let t=Rn().trpcClient,n=w({queryKey:[`ui-library`,`device-provider-labels`],enabled:e,staleTime:Fse,queryFn:async()=>{let[e,n,r]=await Promise.all([t.deviceManager.listAll.query({projection:`slim`}),t.addons.list.query(),t.integrations.list.query()]);return Nse(e,n.map(e=>({id:e.manifest.id,name:e.manifest.name})),r)}});return p(()=>n.data??Pse,[n.data])}E();var E5=`camstack.admin.device-picker.group-by`,Lse=[[`deviceManager`,`listSiteZones`],`device-picker`],Rse=6e4;function D5(){try{let e=globalThis.localStorage?.getItem(`camstack.admin.device-picker.group-by`)??null;return e===null?Z8:Q8(e)}catch{return Z8}}function O5(e){try{globalThis.localStorage?.setItem(E5,e)}catch{}}function k5(){let[e,t]=C(D5);return{groupBy:e,setGroupBy:e=>{t(e),O5(e)}}}function A5(e){let t=Rn().trpcClient,{data:n,isError:r}=w({queryKey:Lse,enabled:e,staleTime:Rse,queryFn:()=>t.deviceManager.listSiteZones.query()});return p(()=>n===void 0?r?{state:`failed`}:{state:`pending`}:{state:`answered`,zones:n},[n,r])}function j5(e){return e.data===void 0?e.isError?`failed`:`pending`:`answered`}function M5(e,t,n){if(n!==`answered`||t===void 0)return e.map(e=>({id:e,removed:!1}));let r=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>{let t=r.get(e);return t===void 0?{id:e,removed:!0}:{id:e,name:t,removed:!1}})}function N5(e,t,n,r){let i=new Set((t??[]).map(e=>e.id));return M5(e.filter(e=>!i.has(e)),n,r)}function P5(e,t,n){return e===`answered`&&t===0&&n===0}function F5(e,t,n){return e&&t===0&&n}var I5={camera:`cameras`,device:`devices`,node:`nodes`,package:`packages`,class:`classes`,zone:`zones`,face:`faces`,calendar:`calendars`};function L5(e,t){switch(e){case`camera`:return t(`uiLibrary.devicePicker.nounCamera`,`camera`);case`device`:return t(`uiLibrary.devicePicker.nounDevice`,`device`);case`node`:return t(`uiLibrary.devicePicker.nounNode`,`node`);case`package`:return t(`uiLibrary.devicePicker.nounPackage`,`package`);case`class`:return t(`uiLibrary.devicePicker.nounClass`,`class`);case`zone`:return t(`uiLibrary.devicePicker.nounZone`,`zone`);case`face`:return t(`uiLibrary.devicePicker.nounFace`,`face`);case`calendar`:return t(`uiLibrary.devicePicker.nounCalendar`,`calendar`)}}function R5(e,t){switch(e){case`camera`:return t(`uiLibrary.devicePicker.pluralCameras`,`cameras`);case`device`:return t(`uiLibrary.devicePicker.pluralDevices`,`devices`);case`node`:return t(`uiLibrary.devicePicker.pluralNodes`,`nodes`);case`package`:return t(`uiLibrary.devicePicker.pluralPackages`,`packages`);case`class`:return t(`uiLibrary.devicePicker.pluralClasses`,`classes`);case`zone`:return t(`uiLibrary.devicePicker.pluralZones`,`zones`);case`face`:return t(`uiLibrary.devicePicker.pluralFaces`,`faces`);case`calendar`:return t(`uiLibrary.devicePicker.pluralCalendars`,`calendars`)}}function z5(e,t){switch(e){case I5.camera:return R5(`camera`,t);case I5.device:return R5(`device`,t);case I5.node:return R5(`node`,t);case I5.package:return R5(`package`,t);case I5.class:return R5(`class`,t);case I5.zone:return R5(`zone`,t);case I5.face:return R5(`face`,t);case I5.calendar:return R5(`calendar`,t);default:return e}}function B5(e,t=`device`,n=Fn){let r=String(e.id);switch(t){case`node`:return e.removed?n(`uiLibrary.devicePicker.nodeUnknown`,`Node {{id}} — unknown to the hub`,{id:r}):e.name??n(`uiLibrary.devicePicker.nodeId`,`Node {{id}}`,{id:r});case`package`:return e.removed?n(`uiLibrary.devicePicker.packageNotInstalled`,`{{id}} — not installed`,{id:r}):e.name??r;case`class`:return e.removed?n(`uiLibrary.devicePicker.classNotListed`,`{{id}} — not in the class list`,{id:r}):e.name??r;case`zone`:return e.removed?n(`uiLibrary.devicePicker.zoneNotFound`,`{{id}} — zone not found`,{id:r}):e.name??n(`uiLibrary.devicePicker.zoneUnavailable`,`{{id}} — zone unavailable`,{id:r});case`face`:return e.removed?n(`uiLibrary.devicePicker.faceNotInGallery`,`{{id}} — not in the face gallery`,{id:r}):e.name??r;case`calendar`:return e.removed?n(`uiLibrary.devicePicker.calendarNotFound`,`{{id}} — calendar not found`,{id:r}):e.name??r;case`camera`:case`device`:return e.removed?n(`uiLibrary.devicePicker.deviceRemoved`,`Device #{{id}} — removed`,{id:r}):e.name??n(`uiLibrary.devicePicker.deviceId`,`Device #{{id}}`,{id:r})}}function V5({noun:e=`camera`}){let t=q();return v(`p`,{className:`mt-1 text-[11px] text-warning`,"data-testid":`devices-widen-warning`,children:t(`uiLibrary.devicePicker.widenWarning`,`No {{noun}} selected: the rule will apply to ALL {{plural}}.`,{noun:L5(e,t),plural:R5(e,t)})})}function H5({noun:e=`cameras`}){let t=q();return v(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`uiLibrary.devicePicker.loading`,`Loading {{noun}}…`,{noun:z5(e,t)})})}function U5({noun:e=`devices`}){let t=q();return v(`p`,{className:`text-[11px] text-warning`,children:t(`uiLibrary.devicePicker.failed`,`The hub did not return its {{noun}} — selected ones are listed by id so they can still be removed.`,{noun:z5(e,t)})})}E();function zse(e,t){switch(e.kind){case`zone`:case`location`:return e.label;case`no-zone`:return t(`uiLibrary.devicePicker.noZone`,`No zone`);case`no-location`:return t(`uiLibrary.devicePicker.noLocation`,`No location`)}}function Bse(e,t=Fn){return e.heading===void 0?`${b5(e.type,t)} · ${e.location??t(`uiLibrary.devicePicker.noRoom`,`No room`)}`:zse(e.heading,t)}function W5(e){return e===`camera`||e===`device`}function G5(e,t){let n=yj(typeof e==`number`?e:0,`compact`,t);return typeof e==`number`?n:t}function Vse({id:e,stored:t,className:n}){return v(`span`,{className:n,children:G5(e,t)})}function Hse({id:e,stored:t,removed:n,onRemove:r}){let i=G5(e,t);return v(Kk,{testId:`picker-chip-${String(e)}`,label:i,warning:n,...r===void 0?{}:{onRemove:r}})}function Use(e,t,n,r,i){let a=new Map(t.map(e=>[e.id,e.name])),o=new Map(N5(e,t,n.devices,n.state).map(e=>[e.id,e]));return e.map(e=>{let t=a.get(e);if(t!==void 0)return{id:e,label:t,removed:!1};let n=o.get(e)??{id:e,removed:!1};return{id:e,label:B5(n,r,i),removed:n.removed}})}function Wse(e,t,n){let r=R5(e,n);return t?e===`camera`||e===`device`?n(`uiLibrary.devicePicker.noCamerasAvailable`,`No cameras available — the rule applies to all devices.`):n(`uiLibrary.devicePicker.noneAvailableAll`,`No {{plural}} available — the rule applies to every {{noun}}.`,{plural:r,noun:L5(e,n)}):n(`uiLibrary.devicePicker.noneAvailable`,`No {{plural}} available.`,{plural:r})}function K5({devices:e,listState:t,fleet:n,value:r,onChange:i,selection:a=`multiple`,groupBy:o,emptyMeansAll:s=!1,savedHadDevices:l=!1,noun:u=`camera`,groupTitle:d,emptyLabel:f,annotate:m,disabled:h=!1,testId:g,showAll:_=!1,lockedIds:y,lockedNote:b}){let x=q(),S=d??(e=>Bse(e,x)),w=b??x(`uiLibrary.devicePicker.alreadyAdded`,`Already added`),T=p(()=>W5(u)?e:T5(e),[e,u]),E=n??{state:t,devices:t===`answered`?T:void 0},D=p(()=>new Set(y??[]),[y]),O=e=>i(D.size===0?e:e.filter(e=>!D.has(e))),[k,A]=C(!1),[j,M]=C(!1),[N,P]=C(l||r.length>0);r.length>0&&!N&&P(!0);let F=Use(r,T,E,u,x),I=J8(F,j||_),L=k||_,R=F5(s,r.length,N),z=I5[u];return t===`answered`&&P5(t,T.length,r.length)?c(`div`,{"data-testid":g,children:[v(`p`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:Wse(u,s,x)}),R&&v(V5,{noun:u})]}):c(`div`,{className:`mt-1 space-y-1.5`,"data-testid":g,children:[t===`pending`&&v(H5,{noun:z}),t===`failed`&&v(U5,{noun:u===`camera`?`devices`:z}),!(a===`single`&&F.length===0&&_)&&c(`div`,{className:`flex flex-wrap items-center gap-1`,children:[F.length===0?v(`span`,{className:`text-[11px] text-foreground-subtle`,children:f??(s?x(`uiLibrary.devicePicker.everyNoRestriction`,`Every {{noun}} — no restriction`,{noun:L5(u,x)}):x(`uiLibrary.devicePicker.noneSelected`,`None selected`))}):I.shown.map(e=>v(Hse,{id:e.id,stored:e.label,removed:e.removed,...h?{}:{onRemove:()=>i(r.filter(t=>t!==e.id))}},e.id)),I.hidden>0&&v(`button`,{type:`button`,className:`rounded-md border border-border px-1.5 py-0.5 text-[11px] text-foreground-subtle hover:bg-surface-hover`,onClick:()=>M(!0),children:x(`uiLibrary.devicePicker.moreChips`,`+{{count}} more`,{count:I.hidden})}),j&&F.length>6&&v(`button`,{type:`button`,className:`text-[11px] text-foreground-subtle underline`,onClick:()=>M(!1),children:x(`uiLibrary.devicePicker.showFewer`,`Show fewer`)}),t!==`pending`&&!_&&v(`button`,{type:`button`,disabled:h,"aria-expanded":k,onClick:()=>A(e=>!e),className:`rounded-md border border-dashed border-border px-1.5 py-0.5 text-[11px] text-foreground hover:bg-surface-hover disabled:opacity-50`,children:k?x(`uiLibrary.devicePicker.done`,`Done`):r.length===0?x(`uiLibrary.devicePicker.addPlural`,`Add {{plural}}…`,{plural:R5(u,x)}):x(`uiLibrary.devicePicker.edit`,`Edit…`)})]}),L&&t===`answered`&&(W5(u)?v(Kse,{devices:T,value:r,onChange:O,locked:D,lockedNote:w,annotate:m,groupTitle:S,noun:u,disabled:h,showAll:_,selection:a,...o===void 0?{}:{pinnedGroupBy:o}}):v(q5,{devices:T,value:r,onChange:O,locked:D,lockedNote:w,annotate:m,groupTitle:S,noun:u,disabled:h,showAll:_,selection:a})),R&&v(V5,{noun:u})]})}var Gse=new Map;function Kse(e){let t=k5(),[n,r]=C(null),i=e.pinnedGroupBy,a=i===void 0?t.groupBy:n??i,o=e=>{if(i!==void 0){r(e);return}t.setGroupBy(e)},s=A5(!0),c=Ise(!0);return v(q5,{...e,providers:c,grouping:{groupBy:a,onGroupByChange:o,zones:s}})}function qse(e,t){return e===`camera`||e===`device`?t(`uiLibrary.devicePicker.searchDevice`,`Search by name, room or type…`):e===`class`?t(`uiLibrary.devicePicker.searchClass`,`Search by class or category…`):e===`zone`?t(`uiLibrary.devicePicker.searchZone`,`Search by camera or zone…`):t(`uiLibrary.devicePicker.searchDefault`,`Search by name or id…`)}var Jse={state:`answered`,zones:[]};function q5({devices:e,value:t,onChange:n,annotate:r,groupTitle:i,noun:a,disabled:o,locked:s,lockedNote:l,showAll:u,selection:d,grouping:f,providers:m=Gse}){let h=q(),g=y(),[_,b]=C(s5),[x,S]=C(new Map),[w,T]=C(60),E=u||L8(_.query).length>0,D=f?.groupBy,O=f?.zones??Jse,k=p(()=>m5(e,_,O),[e,_,O]),A=p(()=>D===void 0?null:r5(k,t,D,O),[k,t,D,O]),j=p(()=>A===null?W8(H8(k,t),t,x,E):i5(A,t,x,E),[A,k,t,x,E]),M=A?.groupBy??null,N=p(()=>d5(e,`type`,_.types,O),[e,_.types,O]),P=p(()=>d5(e,`zone`,_.zones,O),[e,_.zones,O]),F=p(()=>f===void 0?[]:d5(e,`location`,_.locations,O),[e,_.locations,O,f]),I=p(()=>v5(t,e,k),[e,t,k]),L=Y8(j,u?j.length:w),R=(e,t)=>S(n=>new Map([...n,[e.key,!t]]));return c(`div`,{className:`rounded-md border border-border bg-surface p-2`,"data-testid":`device-picker-panel`,children:[v(S5,{filters:_,onFiltersChange:e=>{b(e),T(60)},typeOptions:N,zoneOptions:P,locationOptions:F,zones:O,...f===void 0?{}:{grouping:{groupBy:f.groupBy,onGroupByChange:f.onGroupByChange,fallback:A?.fallback??null}},searchPlaceholder:qse(a,h),searchLabel:a===`camera`||a===`device`?h(`uiLibrary.devicePicker.searchDevices`,`Search devices`):h(`uiLibrary.devicePicker.searchPlural`,`Search {{plural}}`,{plural:R5(a,h)}),disabled:o}),v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:d===`single`?h(`uiLibrary.devicePicker.shownOfSingle`,`{{shown}} of {{total}} shown`,{shown:k.length,total:e.length}):h(`uiLibrary.devicePicker.shownOf`,`{{shown}} of {{total}} shown · {{selected}} selected`,{shown:k.length,total:e.length,selected:t.length})}),j.length===0?v(`p`,{className:`py-2 text-[11px] text-foreground-subtle italic`,children:a===`camera`||a===`device`?h(`uiLibrary.devicePicker.noDeviceMatches`,`No device matches.`):h(`uiLibrary.devicePicker.noNounMatches`,`No {{noun}} matches.`,{noun:L5(a,h)})}):c(`div`,{className:u?`mt-1`:`mt-1 max-h-72 overflow-y-auto`,"data-testid":`device-picker-rows`,children:[L.rows.map(e=>v(Xse,{row:e,value:t,onChange:n,onToggleGroup:R,annotate:r,groupTitle:i,groupBy:M,disabled:o,locked:s,lockedNote:l,selection:d,radioName:g,providers:m},e.key)),L.remaining>0&&v(`button`,{type:`button`,className:`mt-1 w-full rounded border border-border py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover`,onClick:()=>T(e=>e+60),children:h(`uiLibrary.devicePicker.showMore`,`Show {{count}} more ({{left}} left)`,{count:Math.min(L.remaining,60),left:L.remaining})})]}),I>0&&v(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,"data-testid":`picker-hidden-selected`,children:h(`uiLibrary.devicePicker.hiddenSelected`,`{{count}} selected hidden by filters`,{count:I})})]})}function Yse(e,t){if(t===null)return e.detail;let n=a5(e,t),r=[n.location,n.type===null?null:b5(n.type),e.detail??null].filter(e=>e!==null);return r.length>0?r.join(` · `):void 0}function Xse({row:e,value:t,onChange:n,onToggleGroup:r,annotate:i,groupTitle:a,groupBy:o,disabled:s,locked:l,lockedNote:u,selection:d,radioName:f,providers:p}){let m=q(),h=d===`single`;if(e.kind===`header`){let{group:i,expanded:o}=e;return c(`div`,{className:`flex items-center gap-2 border-b border-border px-1 py-1`,"data-testid":`device-picker-group`,children:[c(`button`,{type:`button`,"aria-expanded":o,onClick:()=>r(i,o),className:`flex min-w-0 flex-1 items-center gap-1 text-left text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[v(`span`,{children:o?`▾`:`▸`}),v(`span`,{className:`truncate`,children:a(i)}),!h&&c(`span`,{className:`font-normal normal-case`,children:[`(`,i.selectedCount,`/`,i.devices.length,`)`]})]}),!h&&v(`button`,{type:`button`,disabled:s,className:`text-[10px] text-primary hover:underline disabled:opacity-50`,onClick:()=>n(K8(t,i)),children:m(`uiLibrary.devicePicker.all`,`All`)}),!h&&v(`button`,{type:`button`,disabled:s,className:`text-[10px] text-foreground-subtle hover:underline disabled:opacity-50`,onClick:()=>n(q8(t,i)),children:m(`uiLibrary.devicePicker.clear`,`Clear`)})]})}let g=l.has(e.device.id),_=g?u:i?.(e.device.id),y=Yse(e.device,o),b=e.device.id,x=typeof b==`number`?p.get(b):void 0;return c(`label`,{className:`flex cursor-pointer items-center gap-2.5 px-3 py-1 text-xs text-foreground hover:bg-surface-hover`,"data-testid":`device-picker-row`,children:[v(`input`,{type:h?`radio`:`checkbox`,...h?{name:f}:{},checked:e.selected||g,disabled:s||g,onChange:()=>n(h?[e.device.id]:G8(t,e.device.id)),className:`accent-primary`,"data-device-id":String(e.device.id)}),c(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[v(Vse,{id:e.device.id,stored:e.device.name,className:`truncate`}),y!==void 0&&v(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:y}),x!==void 0&&v(`span`,{className:`truncate text-[10px] text-foreground-subtle`,"data-testid":`device-picker-provider`,children:x}),_!==void 0&&v(`span`,{className:g?`text-[10px] text-foreground-subtle`:`text-[10px] text-warning`,children:_})]})]})}function J5(e){return{state:j5(e),devices:e.data}}var Zse=`w-full min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary disabled:opacity-50 disabled:cursor-not-allowed`;function Y5({dimension:e,value:t,onChange:n,disabled:r=!1,emptyReason:i,inheritLabel:a,className:o,id:s,"aria-label":l}){let u=e===void 0?[]:Oee(e),d=e===void 0;return c(`div`,{className:`flex flex-col gap-0.5 min-w-0 w-full`,children:[c(`select`,{id:s,className:o??Zse,"aria-label":l,value:t,onChange:e=>{let t=e.target.value;if(t===``){n(``);return}n(ua(t)??t)},disabled:r||d,children:[a!==void 0&&v(`option`,{value:``,children:a}),u.map(e=>v(`option`,{value:e,children:e},e))]}),d&&i!==void 0&&i!==``&&v(`span`,{className:`text-[10px] text-foreground-subtle`,children:i})]})}E();var Qse=`block text-[11px] font-medium text-foreground mb-1`,$se=`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`;function X5(e,t,n){let r=e.slice(0,t.start);return{value:`${r}${n}${e.slice(t.end)}`,cursor:r.length+n.length}}function ece({label:e,value:t,onChange:n,chips:r,multiline:i=!1,placeholder:a,disabled:o=!1,testId:s,maxLength:l}){let u=f(null),d=f(null),p=e=>{let r=i?d.current:u.current,a=X5(t,{start:r?.selectionStart??t.length,end:r?.selectionEnd??t.length},e);n(a.value),requestAnimationFrame(()=>{r?.focus(),r?.setSelectionRange(a.cursor,a.cursor)})},m=e=>n(e.target.value);return c(`div`,{className:`space-y-1`,"data-testid":s,children:[v(`label`,{className:Qse,children:e}),i?v(`textarea`,{ref:d,value:t,rows:2,disabled:o,placeholder:a,maxLength:l,onChange:m,className:$se,"data-testid":`${s}-input`}):v(Bl,{ref:u,value:t,disabled:o,placeholder:a,maxLength:l,onChange:m,"data-testid":`${s}-input`}),r!==void 0&&r.length>0&&v(`div`,{className:`flex flex-wrap gap-1 pt-0.5`,"data-testid":`${s}-chips`,children:r.map(e=>v(`button`,{type:`button`,disabled:o,className:`rounded-md bg-primary/10 px-1.5 py-0.5 text-[10px] text-primary hover:bg-primary/20 disabled:opacity-50`,onClick:()=>p(e.token),"data-testid":`${s}-chip-${e.id}`,children:e.label},e.id))})]})}var tce={added:{variant:`success`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.added`,labelFallback:`Added`,className:``},removed:{variant:`danger`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.removed`,labelFallback:`Removed`,className:``},reclassified:{variant:`warning`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.reclassified`,labelFallback:`Reclassified`,className:``},adjusted:{variant:`info`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.adjusted`,labelFallback:`Adjusted`,className:``},unchanged:{variant:`neutral`,style:`fill`,labelKey:`uiLibrary.retrainReviewBadge.unchanged`,labelFallback:`Unchanged`,className:``},"model-error":{variant:`danger`,style:`outline`,labelKey:`uiLibrary.retrainReviewBadge.modelError`,labelFallback:`Model error`,className:`border-danger text-danger`},draft:{variant:`primary`,style:`outline`,labelKey:`uiLibrary.retrainReviewBadge.draft`,labelFallback:`Draft`,className:`border-primary text-primary`}};function Z5(e,t=Fn){let{labelKey:n,labelFallback:r,...i}=tce[e];return{...i,label:t(n,r)}}function nce({kind:e,approximate:t=!1,className:n,...r}){let i=q(),a=Z5(e,i),o=a.style===`outline`;return c(Bk,{...r,variant:a.variant,style:a.style,dashed:t&&o,className:$(a.className,n),title:t?i(`uiLibrary.retrainReviewBadge.approximate`,`{{label}} (approximate)`,{label:a.label}):a.label,children:[a.label,t&&!o?` ~`:``]})}function Q5({options:e,value:t,onChange:n,ariaLabel:r,className:i,testId:a}){return e.length<2?null:v(`div`,{role:`radiogroup`,"aria-label":r,"data-testid":a,className:$(`inline-flex shrink-0 items-center gap-0.5 rounded-md border border-border bg-background p-0.5`,i),children:e.map(e=>{let r=t===e.id,i=e.icon;return c(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-testid":a===void 0?void 0:`${a}-${e.id}`,onClick:()=>n(e.id),className:$(`inline-flex h-7 items-center gap-1 whitespace-nowrap rounded px-2 text-xs font-medium transition-colors`,r?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`),children:[i===void 0?null:v(i,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),e.label]},e.id)})})}function $5(e){return e??``}function e7(e){let t=[];for(let n of e){let e=$5(n.unit);t.includes(e)||t.push(e)}return t}function t7(e,t){let n=gN(e.map(e=>({points:e.points,gapMs:e.gapMs}))),r=n.ys;if(t){let t=e.flatMap((e,t)=>e.compare?[]:[t]),i=xN(t.map(e=>n.ys[e]??[]));r=n.ys.map((e,n)=>{let r=t.indexOf(n);return r>=0?i[r]??e:e})}let i=!n.ys.some(e=>e.some(e=>typeof e==`number`));return{xs:n.xs,raw:n.ys,drawn:r,mins:n.mins,maxs:n.maxs,units:e7(e),gaps:vN(e.filter(e=>!e.compare).map(e=>({points:e.points,gapMs:e.gapMs}))),empty:i}}function n7(e,t){let n=t??e.xs.length-1;return e.raw.map(t=>n<0?null:SN(e.xs,t,n))}function rce(e){return n7(e,null)}E();var ice=120;function ace(e,t){return e===void 0?t.length<2?0:(t[t.length-1]??0)-(t[0]??0):e.to-e.from}function oce(e){let t=ace(e.range,e.model.xs);return{xMin:e.range?.from??e.model.xs[0]??0,xMax:e.range?.to??e.model.xs.at(-1)??0,stops:e.model.xs,resolve:n=>{let r=vP(e.model.xs,n);if(r===null)return null;let i=e.model.xs[r];if(i===void 0)return null;let a=n7(e.model,r);return PP({timeLabel:FN(i,t),preference:e.preference,series:e.series.map((e,t)=>({id:e.id,label:e.label,value:a[t]??null,quantity:e.quantity,unit:e.unit??null}))})},onDataX:e.onDataX}}function r7({title:e,series:t,range:n,height:r=ice,stacked:i=!1,area:a=!1,syncKey:o,formatValue:s,displayPreference:l,axisFor:u,emptyMessage:d,pending:m=!1,actions:h,footer:g,windowToggle:y,className:b}){let x=q(),S=p(()=>t7(t,i),[t,i]),[w,T]=C(null),E=f(S);E.current=S;let D=f(n);D.current=n;let O=_((e,t)=>(s??lP)(e,t),[s]),k=()=>{let e=D.current;if(e)return e.to-e.from;let t=E.current.xs;return t.length>1?(t.at(-1)??0)-(t[0]??0):0},A=e=>e.unit??null,j=_(e=>(u??aP)(e===``?null:e),[u]),M=[t.map(e=>`${e.id}|${$5(e.unit)}|${e.colorIndex}|${e.interpolation??``}|${+!!e.band}|${+!!e.compare}`).join(`,`),i?`S`:``,a?`A`:``,o??``,n?`R`:``].join(`#`),N=p(()=>{let e=[];return t.forEach((t,n)=>{e.push([...S.drawn[n]??[]]),t.band&&(e.push([...S.mins[n]??[]]),e.push([...S.maxs[n]??[]]))}),[[...S.xs],...e]},[S,t]),F=_((e,n)=>{let r=E.current.units,s={x:{time:!0,...D.current?{range:()=>[D.current?.from??0,D.current?.to??1]}:{}}},c=[YN(k)];r.forEach((e,t)=>{let n=`y:${e}`,r=j(e);s[n]={range:e=>{let t=[];e.series.forEach((r,i)=>{if(!(i===0||r.scale!==n))for(let n of e.data[i]??[])t.push(n)});let i=XN(t,r);return[i[0],i[1]]}};let i=e===``?null:e,a=$N(n,t%2==0?3:1,e=>O(e,i),t===0);c.push({...a,splits:(e,t,n,i)=>QN([n,i],r)})});let l=[{}],u=[],d=t,f=d.filter(e=>!e.compare).length,p=1,m=null;return d.forEach(e=>{let t=rN(e.colorIndex),r=()=>cN(t.token),o=e.interpolation===`step`?n.paths.stepped?.({align:1}):n.paths.linear?.(),s=i&&!e.compare,c=!i&&a&&f===1&&!e.compare,d={label:e.label,scale:`y:${$5(e.unit)}`,stroke:e.compare?()=>uN(r(),.6):r,width:e.compare?1.25:2,dash:e.compare?[4,4]:t.dash.length>0?[...t.dash]:void 0,spanGaps:!1,points:{show:!1},...o?{paths:o}:{},...s&&m===null?{fill:()=>uN(r(),.85),fillTo:0}:{},...c?{fill:()=>uN(r(),.15)}:{}};l.push(d);let h=p;if(s&&m!==null&&u.push({series:[h,m],fill:()=>uN(r(),.85)}),s&&(m=h),p+=1,e.band){let t={scale:`y:${$5(e.unit)}`,stroke:()=>`transparent`,width:0,points:{show:!1},spanGaps:!1,...o?{paths:o}:{}};l.push({...t,label:`${e.label} min`},{...t,label:`${e.label} max`}),u.push({series:[p+1,p],fill:()=>uN(r(),.15)}),p+=2}}),{ms:1,legend:{show:!1},padding:[8,30,0,0],scales:s,axes:c,series:l,bands:u,cursor:eP(o),hooks:{drawClear:[tP(()=>E.current.gaps)],setCursor:[e=>T(e.cursor.idx??null)]}}},[M,O,j]),I=p(()=>oce({model:S,series:t,range:n,preference:l,onDataX:e=>{T(e===null?null:vP(S.xs,e))}}),[S,t,n,l]),L=n7(S,w),R=t.map((e,t)=>{let n=rN(e.colorIndex),r=L[t];return{id:e.id,label:e.label,token:n.token,dashed:e.compare===!0||n.dash.length>0,muted:e.compare===!0,value:r==null?S.empty?void 0:`—`:O(r,A(e))}}),z=w!==null&&S.xs[w]!==void 0?FN(S.xs[w]??0,k()):null,B=p(()=>{let r=rce(S),i=n?.from??S.xs[0],a=n?.to??S.xs.at(-1),o=t.map((e,t)=>{let n=r[t];return`${e.label} ${n==null?x(`uiLibrary.charts.unknown`,`unknown`):O(n,A(e))}`}).join(`; `);return i===void 0||a===void 0||!(a>i)?x(`uiLibrary.charts.seriesSummaryNoRange`,`{{title}}: {{parts}}`,{title:e,parts:o}):x(`uiLibrary.charts.seriesSummary`,`{{title}}, {{from}} to {{to}}: {{parts}}`,{title:e,from:PN(i,a-i),to:PN(a,a-i),parts:o})},[S,t,n,e,x,O]),V=c(P,{children:[y&&v(uP,{...y}),h]}),H=r<=64?`sm`:r<=120?`md`:`lg`;return v(dN,{title:e,actions:V,readoutTime:z,legend:R,summary:B,footer:g,placeholder:m?v(hN,{message:x(`uiLibrary.charts.loading`,`Loading…`),height:H}):S.empty?v(hN,{message:d??x(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`),height:H}):void 0,className:b,children:v(eF,{optionsKey:M,buildOptions:F,data:N,height:r,tooltip:I,kind:`lines`,label:e})})}E();var sce=20,cce=22;function lce(e,t,n){let r=new Set([t]);for(let i of e)for(let e of i.segments)e.from>=t&&e.from<n&&r.add(e.from);return[...r].sort((e,t)=>e-t)}function uce(e,t){let n=t.to-t.from;return{xMin:t.from,xMax:t.to,stops:lce(e,t.from,t.to),resolve:t=>LP({timeLabel:FN(t,n),rows:e.map(e=>{let n=FP(e.segments,t),r=n?.state??null,i=r===null?null:e.stateLabel?.(r)??r;return{id:e.id,label:e.label,stateLabel:i,spanMs:r===null?null:n?.spanMs??null}})})}}function i7(e,t){let n=e.colorIndex??0;return e.kind===`boolean`?t===e.states[1]?{token:rN(n).token}:{token:`border`}:{token:rN(n+Math.max(0,e.states.indexOf(t))).token}}function a7({title:e,rows:t,range:n,syncKey:r,pending:i=!1,emptyMessage:a,actions:o,className:s}){let l=q(),[u,d]=C(null),m=f(t);m.current=t;let h=f(n);h.current=n;let g=n.to-n.from,y=t.every(e=>e.segments.length===0),b=(e,t)=>e.stateLabel?.(t)??t,x=`${t.map(e=>`${e.id}:${e.states.join(`|`)}`).join(`,`)}#${r??``}`,S=p(()=>[[n.from,n.to],[null,null]],[n.from,n.to]),w=_(()=>({ms:1,legend:{show:!1},padding:[0,30,0,40],scales:{x:{time:!0,range:()=>[h.current.from,h.current.to]},y:{range:()=>[0,1]}},axes:[YN(()=>h.current.to-h.current.from),{show:!1,scale:`y`}],series:[{},{scale:`y`,stroke:()=>`transparent`,points:{show:!1}}],cursor:{...eP(r),points:{show:!1}},hooks:{draw:[e=>{let t=e.ctx,n=m.current,r=e.bbox.height/Math.max(1,n.length);t.save(),n.forEach((n,i)=>{let a=e.bbox.top+i*r;t.fillStyle=uN(cN(`foreground-subtle`),.06),t.fillRect(e.bbox.left,a+2,e.bbox.width,r-4);for(let i of n.segments){if(i.state===null)continue;let o=e.valToPos(Math.max(i.from,h.current.from),`x`,!0),s=e.valToPos(Math.min(i.to,h.current.to),`x`,!0);s>o&&(t.fillStyle=cN(i7(n,i.state).token),t.fillRect(o,a+2,Math.max(1,s-o),r-4))}}),t.restore()}],setCursor:[e=>{let t=e.cursor.left??-1;d(t<0?null:e.posToVal(t,`x`))}]}}),[x]),T=p(()=>({...uce(t,n),onDataX:e=>d(e)}),[t,n]),E=p(()=>t.map(e=>e.totals??wN(e.segments)),[t]),D=t.map((e,t)=>{let n=e.states.map(n=>{let r=E[t]?.get(n)??0;return r>0?`${b(e,n)} ${kN(r)}`:null}).filter(e=>e!==null).join(`, `);return`${e.label}: ${n.length>0?n:l(`uiLibrary.charts.noState`,`nothing recorded`)}`}).join(`; `),O=l(`uiLibrary.charts.stateSummary`,`{{title}}, {{from}} to {{to}}: {{parts}}`,{title:e,from:PN(n.from,g),to:PN(n.to,g),parts:D}),k=t.length>1,A=i?l(`uiLibrary.charts.loading`,`Loading…`):y?a??l(`uiLibrary.charts.empty`,`Nothing was recorded in this window.`):null;return c(`figure`,{className:$(`min-w-0 m-0`,s),"data-chart-frame":``,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1 min-w-0`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate min-w-0`,children:e}),c(`div`,{className:`flex items-center gap-2 shrink-0`,children:[u!==null&&v(`span`,{className:`text-[10px] tabular-nums text-foreground-subtle`,children:FN(u,g)}),o]})]}),A===null?c(`div`,{role:`img`,"aria-label":O,className:`flex min-w-0`,children:[k&&v(`div`,{className:`w-20 sm:w-28 shrink-0 pr-2`,"aria-hidden":`true`,children:t.map(e=>v(`div`,{className:`h-5 flex items-center text-[10px] text-foreground-muted truncate`,children:e.label},e.id))}),v(`div`,{className:`flex-1 min-w-0`,children:v(eF,{optionsKey:x,buildOptions:w,data:S,height:t.length*sce+cce,tooltip:T,kind:`states`,label:e})})]}):v(hN,{message:A,height:`sm`}),v(`p`,{className:`sr-only`,children:O}),A===null&&v(`ul`,{className:`mt-1 space-y-0.5 list-none p-0 m-0`,children:t.map((e,t)=>{let n=u===null?null:TN(e.segments,u);return c(`li`,{className:`flex flex-wrap items-center gap-x-3 gap-y-0.5 min-w-0`,children:[k&&v(`span`,{className:`text-[10px] text-foreground-muted`,children:e.label}),e.states.map(r=>{let i=E[t]?.get(r)??0;return i===0?null:c(`span`,{className:$(`inline-flex items-center gap-1 text-[10px]`,n===r?`text-foreground`:`text-foreground-muted`),children:[v(fN,{token:i7(e,r).token}),v(`span`,{children:b(e,r)}),v(`span`,{className:`tabular-nums text-foreground`,children:kN(i)})]},r)})]},e.id)})})]})}E();function dce({points:e,ariaLabel:t,token:n=`chart-series-a`,height:r=32,widthClassName:i=`w-40`,zeroBased:a=!0,unit:o=null,quantity:s,displayPreference:c,className:l}){let u=p(()=>{let n=e.map(e=>e.x);return{xMin:n[0]??0,xMax:n.at(-1)??0,stops:n,resolve:r=>{let i=vP(n,r);if(i===null)return null;let a=e[i];return a===void 0?null:PP({timeLabel:String(a.x),preference:c,series:[{id:`value`,label:t,value:a.v,unit:o,quantity:s}]})}}},[e,t,o,s,c]),d=p(()=>[e.map(e=>e.x),e.map(e=>e.v)],[e]),f=_((e,t)=>({legend:{show:!1},cursor:{show:!1},padding:[2,1,2,1],scales:{x:{time:!1},y:{range:(e,t,n)=>{let r=a?Math.min(0,t):t;return[r,n>r?n:r+1]}}},axes:[{show:!1},{show:!1}],series:[{},{stroke:()=>cN(n),width:1.5,points:{show:!1},spanGaps:!1,...t.paths.linear?{paths:t.paths.linear()}:{}}]}),[n,a]);return v(`span`,{role:`img`,"aria-label":t,className:$(`inline-block align-middle`,i,l),children:v(eF,{optionsKey:`${n}#${a?`z`:``}`,buildOptions:f,data:d,height:r,inline:!0,tooltip:u,kind:`spark`,label:t})})}var o7=[`24h`,`7d`,`30d`,`1y`,`custom`],s7=36e5,c7=24*s7,l7={"24h":c7,"7d":7*c7,"30d":30*c7,"1y":365*c7};function u7(e){return e!=null&&o7.includes(e)}function d7(e,t,n){return e===`custom`?n&&n.to>n.from?{from:n.from,to:n.to}:{from:t-l7[`24h`],to:t}:{from:t-l7[e],to:t}}function f7(e){let t=e.to-e.from;return{window:{from:e.from-t,to:e.to-t},shiftMs:t}}function p7(e){return`${String(Math.round(e.from))}-${String(Math.round(e.to))}`}function m7(e){if(!e)return null;let t=/^(\d+)-(\d+)$/.exec(e);if(!t)return null;let n=Number(t[1]),r=Number(t[2]);return r>n?{from:n,to:r}:null}var h7={"5m":5*6e4,"1h":s7,"1d":c7},g7=`addon:pipeline-analytics/occupancy`;function _7(e){if(!e.startsWith(`cap:`))return null;let t=e.slice(4),n=t.indexOf(`.`);return n<=0?null:{cap:t.slice(0,n),field:t.slice(n+1)}}function v7(e){if(!e.startsWith(`addon:`))return null;let t=e.slice(6),n=t.indexOf(`/`);return n<=0?null:{addonId:t.slice(0,n),name:t.slice(n+1)}}var y7=Object.keys(ca);function b7(e){let t=y7.indexOf(e);return t<0?y7.length:t}function x7(e,t){let n=Object.keys(ca[e]??{}),r=n.indexOf(t);return r<0?n.length:r}var S7=e=>e.kind===`boolean`||e.kind===`enum`;function C7(e,t,n){let r=[],i=new Map;for(let t of n){if(t.key===`derived:energy.kwh`){r.push({type:`energy`,id:`${e}:energy`,title:t.displayName,series:t});continue}if(S7(t))continue;let n=t.unit??``;i.set(n,[...i.get(n)??[],t])}let a=[...i.entries()].map(([n,r])=>{let i=[...new Set(r.map(e=>e.displayName))];return{type:`lines`,id:`${e}:unit:${n}`,title:i.length===1?i[0]??t:n===``?t:`${t} (${n})`,unit:n===``?null:n,series:r}}),o=n.filter(S7).map(t=>({type:`states`,id:`${e}:state:${t.key}:${t.scope}`,title:t.displayName,series:t}));return[...a,...r,...o]}function w7(e,t){let n=new Map,r=new Map,i=[],a=null;for(let t of e){if(t.key===`derived:energy.kwh`){a=t;continue}if(t.key===`addon:pipeline-analytics/occupancy`){i.push(t);continue}let e=_7(t.key);if(e){n.set(e.cap,[...n.get(e.cap)??[],t]);continue}let o=v7(t.key)?.addonId??`other`;r.set(o,[...r.get(o)??[],t])}a!==null&&(n.has(`power-meter`)?n.set(`power-meter`,[...n.get(`power-meter`)??[],a]):n.set(`energy`,[a]));let o=[...n.entries()].sort(([e],[t])=>b7(e)-b7(t)||e.localeCompare(t)).map(([e,n])=>{let r=[...n].sort((t,n)=>{let r=_7(t.key)?.field??``,i=_7(n.key)?.field??``;return x7(e,r)-x7(e,i)||t.scope.localeCompare(n.scope)}),i=`cap:${e}`;return{id:i,kind:`cap`,name:e,charts:C7(i,t(e),r)}});if(i.length>0){let e=r.get(`pipeline-analytics`)??[];r.set(`pipeline-analytics`,e)}let s=[...r.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,n])=>{let r=`addon:${e}`,a=C7(r,t(e),n);return{id:r,kind:`producer`,name:e,charts:[...e===`pipeline-analytics`&&i.length>0?[{type:`occupancy`,id:`${r}:occupancy`,title:i[0]?.displayName??`Occupancy`,series:[...i].sort((e,t)=>e.scope.localeCompare(t.scope))}]:[],...a]}});return[...o,...s].filter(e=>e.charts.length>0)}function T7(e){let t=new Set;for(let n of e)if(n.type===`lines`||n.type===`occupancy`)for(let e of n.series)t.add(e.key);else t.add(n.series.key);return[...t]}function E7(e,t){return e?.series.find(e=>e.scope===t)}function fce(e,t){return t===`counter`?e.last:e.twMean??e.mean??e.last}function D7(e,t,n){let r=E7(t,e.scope),i=t!==void 0&&t.resolution!==`raw`,a=e.source===`cap`,o=(r?.points??[]).map(t=>({t:t.t,v:fce(t,e.kind),...i&&e.kind===`gauge`?{min:t.min,max:t.max}:{}}));return a&&r?.before&&r.before.value!==null&&(o[0]?.t??1/0)>n&&o.unshift({t:n,v:r.before.value}),{points:o,gapMs:a||t===void 0?void 0:KN(t.resolution===`raw`?1e4:h7[t.resolution]),held:a}}function O7(e,t){return e.map(e=>({...e,t:e.t+t}))}var k7=[`false`,`true`];function A7(e,t,n,r){let i=e.kind===`boolean`?k7:e.values??[],a=E7(t,e.scope),o=t=>e.kind===`boolean`?t.last===null?null:t.last>=.5?`true`:`false`:t.state;if(t===void 0||a===void 0)return{segments:[],totals:new Map,states:i};let s=a.before===null?null:e.kind===`boolean`?a.before.value===null?null:a.before.value>=.5?`true`:`false`:a.before.state;if(t.resolution===`raw`){let e=CN(a.points.map(e=>({t:e.t,state:o(e)})),n,r,s),t=new Map;for(let n of e)n.state!==null&&t.set(n.state,(t.get(n.state)??0)+(n.to-n.from));return{segments:e,totals:t,states:i}}let c=h7[t.resolution],l=new Map,u=[];for(let t of a.points){let i=Math.min(r,t.t+c),a=Math.max(n,t.t);if(!(i>a))continue;let o=pce(t,e,c),s=null,d=-1;for(let[e,t]of o)l.set(e,(l.get(e)??0)+t*((i-a)/c)),t>d&&(d=t,s=e);let f=u.at(-1);f&&f.state===s&&f.to===a?u[u.length-1]={...f,to:i}:u.push({from:a,to:i,state:s})}return{segments:u.filter(e=>e.state!==null),totals:l,states:i}}function pce(e,t,n){if(t.kind===`boolean`){let t=e.twMean??e.mean;return t===null?e.last===null?new Map:new Map([[e.last>=.5?`true`:`false`,n]]):new Map([[`true`,t*n],[`false`,(1-t)*n]])}return e.states?new Map(Object.entries(e.states)):e.state===null?new Map:new Map([[e.state,n]])}function j7(e){let t=e?.series[0],n=e===void 0||e.resolution===`raw`?h7[`1h`]:h7[e.resolution];return{buckets:(t?.points??[]).map(e=>({t:e.t,values:[e.delta]})),bucketMs:n}}function M7(e){return e.map(e=>{let t=eo(e.scope);return{scope:e.scope,zoneId:t.zoneId,className:t.className}})}function N7(e){return{zones:[...new Set(e.map(e=>e.zoneId))].sort(),classes:[...new Set(e.flatMap(e=>e.className===void 0?[]:[e.className]))].sort()}}function P7(e,t){return e.filter(e=>(t.zone===null||e.zoneId===t.zone)&&(t.className===null?e.className===void 0:e.className===t.className))}E();var F7=`__all__`;function I7(e,t){let n=e.split(`.`).at(-1)??``;return/open/i.test(n)?{on:t(`uiLibrary.history.state.open`,`open`),off:t(`uiLibrary.history.state.closed`,`closed`)}:/online|connected/i.test(n)?{on:t(`uiLibrary.history.state.online`,`online`),off:t(`uiLibrary.history.state.offline`,`offline`)}:/detected|tampered/i.test(n)?{on:t(`uiLibrary.history.state.detected`,`detected`),off:t(`uiLibrary.history.state.clear`,`clear`)}:{on:t(`uiLibrary.history.state.on`,`on`),off:t(`uiLibrary.history.state.off`,`off`)}}function L7(e){return e!==void 0&&!e.ok?e.error:null}function R7({spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}){let s=q(),c=n===null;if(e.type===`states`){let n=t(e.series.key,!1),i=L7(n);if(i)return v(B7,{title:e.title,error:i,actions:o});let l=n?.ok?n.result:void 0,u=A7(e.series,l,r.from,r.to),d=I7(e.series.key,s);return v(a7,{title:e.title,range:r,syncKey:a,pending:c,actions:o,rows:[{id:e.id,label:e.title,kind:e.series.kind===`boolean`?`boolean`:`enum`,states:u.states,segments:u.segments,totals:u.totals,stateLabel:e.series.kind===`boolean`?e=>e===`true`?d.on:d.off:void 0}]})}if(e.type===`energy`){let n=t(e.series.key,!1),i=L7(n);if(i)return v(B7,{title:e.title,error:i,actions:o});let{buckets:s,bucketMs:l}=j7(n?.ok?n.result:void 0);return v(tF,{title:e.title,layers:[{id:`kwh`,label:e.title,colorIndex:4}],buckets:s,bucketMs:l,range:r,unit:e.series.unit??`kWh`,showTotal:!0,syncKey:a,pending:c,actions:o})}return e.type===`occupancy`?v(hce,{spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}):v(z7,{title:e.title,series:e.series,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o,labelOf:t=>e.series.length>1||t.scope!==``?mce(t):e.title})}function mce(e){return e.scope===``?e.displayName:`${e.displayName} · ${e.scope}`}function z7({title:e,series:t,entryFor:n,reads:r,window:i,compare:a,syncKey:o,actions:s,labelOf:l,toolbar:u,colorOf:d}){let f=q(),m=[...new Set(t.map(e=>L7(n(e.key,!1))).filter(e=>e!==null))],h=p(()=>{let e=[];return t.forEach((o,s)=>{let c=n(o.key,!1),u=c?.ok?c.result:void 0,p=D7(o,u,i.from),m=d?.(o,s)??s,h=p.held&&u?.resolution===`raw`?`step`:`linear`;if(e.push({id:`${o.key}|${o.scope}`,label:l(o),unit:o.unit,colorIndex:m,points:p.points,gapMs:p.gapMs,interpolation:h,band:t.length===1&&u!==void 0&&u.resolution!==`raw`}),a&&r?.previous){let t=n(o.key,!0),a=t?.ok?t.result:void 0;if(a){let t=D7(o,a,i.from-r.shiftMs);e.push({id:`${o.key}|${o.scope}|previous`,label:f(`uiLibrary.history.previousOf`,`{{label}} (previous period)`,{label:l(o)}),unit:o.unit,colorIndex:m,points:O7(t.points,r.shiftMs),gapMs:t.gapMs,interpolation:h,compare:!0})}}}),e},[t,n,i.from,a,r,l,d,f]);return m.length>0?v(B7,{title:e,error:m.join(`; `),actions:s}):v(r7,{title:e,series:h,range:i,syncKey:o,pending:r===null,actions:c(P,{children:[u,s]})})}function hce({spec:e,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o}){let s=q(),[l,u]=C(F7),[d,f]=C(F7),m=p(()=>M7(e.series),[e.series]),h=p(()=>N7(m),[m]),g=new Set(P7(m,{zone:l===F7?null:l,className:d===F7?null:d}).map(e=>e.scope)),_=e.series.filter(e=>g.has(e.scope)),y=e=>e===``?s(`uiLibrary.history.wholeFrame`,`Whole frame`):e,b=e=>{let t=m.find(t=>t.scope===e.scope);return t?t.className===void 0?y(t.zoneId):`${y(t.zoneId)} · ${t.className}`:e.scope},x=e=>{let t=m.find(t=>t.scope===e.scope),n=m.filter(e=>e.className===t?.className);return Math.max(0,n.findIndex(t=>t.scope===e.scope))},S=c(P,{children:[h.zones.length>1&&v(Yl,{"aria-label":s(`uiLibrary.history.filterZone`,`Zone`),value:l,onChange:e=>u(e.target.value),className:`h-6 text-[10px] py-0`,options:[{value:F7,label:s(`uiLibrary.history.allZones`,`All zones`)},...h.zones.map(e=>({value:e,label:y(e)}))]}),h.classes.length>0&&v(Yl,{"aria-label":s(`uiLibrary.history.filterClass`,`Class`),value:d,onChange:e=>f(e.target.value),className:`h-6 text-[10px] py-0`,options:[{value:F7,label:s(`uiLibrary.history.allClasses`,`All classes`)},...h.classes.map(e=>({value:e,label:e}))]})]});return v(z7,{title:e.title,series:_,entryFor:t,reads:n,window:r,compare:i,syncKey:a,actions:o,toolbar:S,labelOf:b,colorOf:x})}function B7({title:e,error:t,actions:n}){let r=q();return c(`figure`,{className:`min-w-0 m-0`,children:[c(`div`,{className:`flex items-baseline justify-between gap-2 mb-1`,children:[v(`figcaption`,{className:`text-[10px] uppercase tracking-wider text-foreground-subtle truncate`,children:e}),n]}),v(hN,{height:`md`,message:r(`uiLibrary.history.readFailed`,`This history could not be read: {{error}}`,{error:t})})]})}var gce=uo({subject:fo(`kind`,[uo({kind:po(`device`),deviceId:co().int()}),uo({kind:po(`node`),nodeId:lo().min(1)})]),key:lo().min(1),scope:lo()}),_ce=24;function V7(e){return`${e.subject.kind===`device`?`d:${String(e.subject.deviceId)}`:`n:${e.subject.nodeId}`}|${e.key}|${e.scope}`}function H7(e){return[...e.subject.kind===`device`?[`d`,String(e.subject.deviceId)]:[`n`,e.subject.nodeId],e.key,e.scope].map(e=>encodeURIComponent(e)).join(`,`)}function U7(e){let t=e.split(`,`);if(t.length!==4)return null;let n;try{n=t.map(e=>decodeURIComponent(e))}catch{return null}let[r,i,a,o]=n;if(a===void 0||a===``||o===void 0||i===void 0)return null;if(r===`d`){let e=Number(i);return Number.isInteger(e)?{subject:{kind:`device`,deviceId:e},key:a,scope:o}:null}return r===`n`&&i!==``?{subject:{kind:`node`,nodeId:i},key:a,scope:o}:null}function W7(e){let t=new Set,n=[];for(let r of e){let e=V7(r);if(!t.has(e)&&(t.add(e),n.push(r),n.length>=24))break}return n}function G7(e,t){let n=new URLSearchParams;for(let t of W7(e))n.append(`s`,H7(t));return t!==void 0&&t!==`custom`&&n.set(`window`,t),`${K7}?${n.toString()}`}var K7=`/system/history`,q7=`admin.history-panels`,vce=ho(o7),yce=uo({id:lo().min(1),name:lo().min(1).max(80),window:vce,selection:go(gce).max(24)}),bce=uo({version:po(1),panels:go(yce).max(50),hidden:mo(lo(),go(lo()).max(200))}),J7={version:1,panels:[],hidden:{}};function Y7(e){if(e==null)return{value:J7,parsed:!0};let t=bce.safeParse(e);return t.success?{value:t.data,parsed:!0}:{value:J7,parsed:!1}}function X7(e,t,n,r){let i=String(t),a=e.hidden[i]??[],o=r?a.includes(n)?a:[...a,n]:a.filter(e=>e!==n),s=Object.fromEntries(Object.entries(e.hidden).filter(([e])=>e!==i));return{...e,hidden:o.length>0?{...s,[i]:o}:s}}function Z7(e,t){let n=e.panels.filter(e=>e.id!==t.id);return{...e,panels:[...n,t]}}function Q7(e,t){return{...e,panels:e.panels.filter(e=>e.id!==t)}}function $7(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${String(t.getFullYear())}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function e9(e){let t=new Date(e).getTime();return Number.isFinite(t)?t:null}function t9({value:e,onChange:t,custom:n,onCustomChange:r,compare:i,onCompareChange:a}){let o=q(),s=Date.now(),l=n??{from:s-864e5,to:s};return c(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 min-w-0`,children:[v(uP,{ariaLabel:o(`uiLibrary.history.window`,`Time window`),value:e,onChange:t,options:[{id:`24h`,label:o(`uiLibrary.history.window24h`,`24 h`)},{id:`7d`,label:o(`uiLibrary.history.window7d`,`7 d`)},{id:`30d`,label:o(`uiLibrary.history.window30d`,`30 d`)},{id:`1y`,label:o(`uiLibrary.history.window1y`,`1 y`)},{id:`custom`,label:o(`uiLibrary.history.windowCustom`,`Custom`)}]}),e===`custom`&&c(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v(Bl,{type:`datetime-local`,"aria-label":o(`uiLibrary.history.from`,`From`),className:`h-7 w-auto text-xs`,value:$7(l.from),onChange:e=>{let t=e9(e.target.value);t!==null&&t<l.to&&r({from:t,to:l.to})}}),v(`span`,{className:`text-[10px] text-foreground-subtle`,children:`–`}),v(Bl,{type:`datetime-local`,"aria-label":o(`uiLibrary.history.to`,`To`),className:`h-7 w-auto text-xs`,value:$7(l.to),onChange:e=>{let t=e9(e.target.value);t!==null&&t>l.from&&r({from:l.from,to:t})}})]}),i!==void 0&&a&&c(`label`,{className:`inline-flex items-center gap-1.5 text-[11px] text-foreground-muted cursor-pointer select-none`,children:[v(BB,{checked:i,onChange:e=>a(e.target.checked)}),o(`uiLibrary.history.compare`,`Compare with previous period`)]})]})}var xce=800;function n9(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function r9(e){if(typeof e!=`object`||!e)return!1;let t=`data`in e?e.data:void 0,n=typeof t==`object`&&t&&`code`in t?t.code:void 0;return n===`FORBIDDEN`||n===`UNAUTHORIZED`}function i9(e){return e instanceof Error?e.message:String(e)}async function a9(e,t,n){let r=n.maxPoints??xce,i=[];for(let a of n9(t,24))try{let t=await e.queryMany({items:[...a],from:n.from,to:n.to,resolution:`auto`,maxPoints:r});a.forEach((e,n)=>{i.push(t.results[n]??{ok:!1,error:`no answer for this item`})})}catch(t){if(!r9(t)){let e=i9(t);for(let t of a)i.push({ok:!1,error:e});continue}i.push(...await Sce(e,a,n.from,n.to,r,i9(t)))}return i}async function Sce(e,t,n,r,i,a){return Promise.all(t.map(async t=>{if(!(`deviceId`in t))return{ok:!1,error:a};try{return{ok:!0,result:await e.query({deviceId:t.deviceId,key:t.key,...t.scope===void 0?{}:{scope:t.scope},from:n,to:r,resolution:`auto`,maxPoints:i})}}catch(e){return{ok:!1,error:i9(e)}}}))}E();var o9=6e4;function s9(e,t){let n=t<=l7[`24h`]?o9:t<=l7[`7d`]?5*o9:t<=l7[`30d`]?15*o9:60*o9;return Math.ceil(e/n)*n}function c9(){let e=Rn().trpcClient;return p(()=>({queryMany:t=>e.deviceHistory.queryMany.query(t),query:t=>e.deviceHistory.query.query(t)}),[e])}function l9(e){let t=IM(`device-history`),n=Rn().trpcClient,r=w({queryKey:[`device-history`,`listSeries`,e],queryFn:()=>n.deviceHistory.listSeries.query({deviceId:e}),enabled:t===`present`,staleTime:6e4});return{presence:t,list:r.status===`success`?{status:`ok`,data:r.data}:r.status===`error`?{status:`error`,error:r.error.message}:{status:`pending`}}}function u9(e){return`${`deviceId`in e?`d:${String(e.deviceId)}`:`n:${e.forNodeId}`}|${e.key}|${e.scope??`*`}`}function d9(e,t,n,r=!0){let i=c9(),a=e.map(u9),o=w({queryKey:[`device-history`,`reads`,a,t.from,t.to,n],queryFn:async()=>{let r=f7(t),[o,s]=await Promise.all([a9(i,e,t),n?a9(i,e,r.window):Promise.resolve(null)]),c=e=>new Map(e.map((e,t)=>[a[t]??String(t),e]));return{current:c(o),previous:s===null?null:c(s),shiftMs:r.shiftMs}},enabled:r&&e.length>0,staleTime:3e4,placeholderData:e=>e});return o.status===`success`?{status:`ok`,data:o.data}:o.status===`error`?{status:`error`,error:o.error.message}:{status:`pending`}}E();var f9=[`preferences`,q7];function p9(){let e=Rn().trpcClient,t=k(),n=w({queryKey:f9,queryFn:async()=>{let t=(await e.preferences.get.query({namespaces:[q7]})).rows.find(e=>e.namespace===q7);return t===void 0?null:{value:t.value,revision:t.revision}},staleTime:3e4}),r=n.data??null,i=Y7(r?.value),a=_(async n=>{let i=async(r,a)=>{let o=Y7(r?.value);if(!o.parsed)throw Error(`history-panels: stored row is not readable`);let s=n(o.value),c=await e.preferences.put.mutate({namespace:q7,value:{...s},baseRevision:r?.revision??0});if(c.status===`saved`){t.setQueryData(f9,{value:c.row.value,revision:c.row.revision});return}let l=c.current===null?null:{value:c.current.value,revision:c.current.revision};if(t.setQueryData(f9,l),!a)throw Error(`history-panels: the row changed while saving`);await i(l,!1)};await i(r,!0)},[e,t,r]);return{status:n.status===`success`?`ok`:n.status===`error`?`error`:`pending`,value:n.status===`success`?i.value:J7,writable:n.status===`success`&&i.parsed,update:a}}E();function m9(e){let t=e.replace(/[-_]/g,` `).trim();return t.length===0?e:t.charAt(0).toUpperCase()+t.slice(1)}function Cce(e,t){return(t.type===`lines`||t.type===`occupancy`?t.series:[t.series]).map(t=>({subject:{kind:`device`,deviceId:e},key:t.key,scope:t.scope}))}function h9({deviceId:e,fixedWindow:t,onNavigate:n}){let r=q(),[i,a]=U6(`hw`),[o,s]=U6(`hr`),[l,u]=U6(`hc`),d=t??(u7(i)?i:`24h`),f=t?null:m7(o),m=t===void 0&&l===`1`,h=d7(d,Date.now(),f),g=d7(d,s9(Date.now(),h.to-h.from),f),{presence:y,list:b}=l9(e),x=p9(),S=p(()=>new Set(x.value.hidden[String(e)]??[]),[x.value.hidden,e]),[w,T]=C(new Set),E=p(()=>b.status===`ok`?w7(b.data,m9):[],[b]),D=p(()=>E.map(e=>({...e,charts:e.charts.filter(e=>!S.has(e.id))})).filter(e=>e.charts.length>0),[E,S]),O=E.reduce((e,t)=>e+t.charts.filter(e=>S.has(e.id)).length,0),k=d9(p(()=>T7(D.flatMap(e=>e.charts)).map(t=>({deviceId:e,key:t})),[D,e]),g,m,b.status===`ok`),A=k.status===`ok`?k.data:null,j=_((t,n)=>{let r=u9({deviceId:e,key:t});return k.status===`error`?{ok:!1,error:k.error}:(n?A?.previous:A?.current)?.get(r)},[e,k,A]),M=_(e=>{n?n(e):globalThis.location.assign(`${ri()}${e}`)},[n]),N=(t,n)=>{x.writable&&x.update(r=>X7(r,e,t,n))},P=()=>{x.writable&&x.update(t=>{let n=t;for(let t of S)n=X7(n,e,t,!1);return n})};if(y===`pending`)return v(g9,{});if(y===`unknown`)return v(eN,{title:r(`uiLibrary.history.presenceUnknownTitle`,`Could not reach the hub`),message:r(`uiLibrary.history.presenceUnknown`,`The hub did not say whether device history is installed. Try again in a moment.`)});if(y===`absent`)return v(QM,{icon:eee,title:r(`uiLibrary.history.absentTitle`,`Device history is not running on this hub`),description:r(`uiLibrary.history.absent`,`Nothing is recorded until the device-history system addon is enabled.`)});if(b.status===`pending`)return v(g9,{});if(b.status===`error`)return v(eN,{title:r(`uiLibrary.history.listFailedTitle`,`History could not be read`),message:b.error});if(E.length===0)return v(QM,{icon:hr,title:r(`uiLibrary.history.emptyTitle`,`Nothing recorded for this device yet`),description:r(`uiLibrary.history.empty`,`A value appears here once it changes, or at the next five-minute check.`)});let F=`device-history:${String(e)}`;return c(`div`,{className:Xe,children:[t===void 0&&c(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[v(t9,{value:d,onChange:e=>a(e===`24h`?null:e),custom:f,onCustomChange:e=>s(p7(e)),compare:m,onCompareChange:e=>u(e?`1`:null)}),O>0&&c(_A,{variant:`ghost`,size:`sm`,onClick:P,disabled:!x.writable,children:[v(Oe,{className:`h-3.5 w-3.5`,"aria-hidden":`true`}),r(`uiLibrary.history.showHidden`,{one:`Show {{count}} hidden chart`,other:`Show {{count}} hidden charts`},{count:O})]})]}),D.map(n=>v(dB,{expanded:!w.has(n.id),onExpandedChange:e=>T(t=>{let r=new Set(t);return e?r.delete(n.id):r.add(n.id),r}),header:c(`div`,{className:`flex items-center gap-2 min-w-0`,children:[v(`span`,{className:`text-xs font-semibold text-foreground truncate`,children:m9(n.name)}),v(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:r(`uiLibrary.history.chartCount`,{one:`{{count}} chart`,other:`{{count}} charts`},{count:n.charts.length})})]}),children:v(`div`,{className:`grid grid-cols-1 gap-4 2xl:grid-cols-2`,children:n.charts.map(n=>v(R7,{spec:n,entryFor:j,reads:A,window:g,compare:m,syncKey:F,actions:v(M6,{title:r(`uiLibrary.history.chartMenu`,`Chart actions`),items:[{id:`open`,label:r(`uiLibrary.history.openInHistory`,`Open in History`),icon:hr,onClick:()=>M(G7(Cce(e,n),d))},{id:`hide`,label:r(`uiLibrary.history.hide`,`Hide`),icon:Oe,hidden:t!==void 0,disabled:!x.writable,onClick:()=>N(n.id,!0)}]})},n.id))})},n.id))]})}function g9(){return c(`div`,{className:Xe,"aria-busy":`true`,children:[v(hM,{className:`h-7 w-72`}),v(hM,{className:`h-40 w-full`}),v(hM,{className:`h-40 w-full`})]})}E();var _9=Kn(`camstack:zone-editing`,null);function v9({children:e}){let[t,n]=C(!1),[r,i]=C(null),[a,o]=C(null),[s,c]=C(null),l=_(e=>{n(e),e||(i(null),o(null),c(null))},[]),u=_(e=>{i(e)},[]),d=_(e=>{o(e)},[]),f=_(e=>{n(!0),o(null),i(e),c(null)},[]),m=_(()=>{n(!1),i(null),o(null),c(null)},[]),h=_(e=>{o(e.id),c(e)},[]),g=_(e=>{c(t=>t===null?t:{...t,...e})},[]),y=_(()=>{c(null)},[]),b=p(()=>({editing:t,drawingKind:r,selectedZoneId:a,editingDraft:s,setEditing:l,setDrawingKind:u,setSelectedZoneId:d,startDrawing:f,exitEditing:m,enterDraft:h,updateDraft:g,discardDraft:y}),[t,r,a,s,l,u,d,f,m,h,g,y]);return v(_9.Provider,{value:b,children:e})}function wce(){return I(_9)}E();function y9(e,t,n){let r=f(null),i=f(null);(r.current===null||i.current!==e)&&(r.current=wa(e),i.current=e);let a=f(void 0),o=f(null),s=o.current;return t===null?(a.current=void 0,o.current=null):(a.current===void 0||s===null||s.source!==r.current||s.deviceId!==t||s.capName!==n)&&(a.current=na(r.current,t,n),o.current={source:r.current,deviceId:t,capName:n}),Be(a.current)}E();var b9=500,x9=800;function S9(e,t,n){try{let r=e.live;if(!r)return null;let i=r.onEvent;return!i||typeof i.subscribe!=`function`?null:i.subscribe({category:t},{onData:n})}catch{return null}}function C9(e,t){return e?.id===t}function w9(e,t){let[n,r]=C(null),[i,a]=C(null),[o,s]=C(null),[c,l]=C(`watching`),u=f(void 0),d=f(void 0),p=f(void 0),m=f(0);return b(()=>{if(t===null)return;let n=S9(e,`detection.motion-analysis`,e=>{let n=e;if(!C9(n?.source,t))return;let i=n.data;!i?.regions||i.regions.length===0||(r({zones:i.regions.map(e=>({...e.bbox,intensity:e.intensity})),frameWidth:i.frameWidth,frameHeight:i.frameHeight}),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>r(null),b9))});return()=>{n?.unsubscribe(),u.current&&clearTimeout(u.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.motion-zones-raw`,e=>{let n=e;if(!C9(n?.source,t))return;let r=n.data;r?.zones&&(a({boxes:r.zones.map(e=>({bbox:e.bbox,changeScore:e.changeScore})),frameWidth:r.frameSize?.width??0,frameHeight:r.frameSize?.height??0,motionScore:r.zones.length>0?r.zones.reduce((e,t)=>e+t.changeScore,0)/r.zones.length:0}),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>a(null),b9))});return()=>{n?.unsubscribe(),d.current&&clearTimeout(d.current)}},[e,t]),b(()=>{if(m.current=0,t===null)return;let n=S9(e,`pipeline-analytics.frame-tracked`,e=>{let n=e?.data;!n||n.deviceId!==t||n.detections?.length&&typeof n.detections[0]?.kind==`string`&&(m.current=Date.now(),s({detections:n.detections,frameWidth:n.frameWidth,frameHeight:n.frameHeight}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(null),x9))});return()=>{n?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.result`,e=>{let n=e;if(!C9(n?.source,t)||Date.now()-m.current<x9)return;let r=n.data?.frame;r?.detections?.length&&(s({detections:r.detections,frameWidth:r.width,frameHeight:r.height}),p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(null),x9))});return()=>{n?.unsubscribe(),p.current&&clearTimeout(p.current)}},[e,t]),b(()=>{if(t===null)return;let n=S9(e,`detection.phase-transition`,e=>{let n=e;C9(n?.source,t)&&n.data?.to&&l(n.data.to)});return()=>{n?.unsubscribe()}},[e,t]),{motion:n,motionRaw:i,detection:o,phase:c}}var T9=3e4;function E9(e){return!(e.frameWidth>0)||!(e.frameHeight>0)?null:{id:e.id,className:e.className,x1:e.bbox.x/e.frameWidth,y1:e.bbox.y/e.frameHeight,x2:(e.bbox.x+e.bbox.w)/e.frameWidth,y2:(e.bbox.y+e.bbox.h)/e.frameHeight,becameStationaryAt:e.becameStationaryAt,...e.label===void 0?{}:{label:e.label}}}function Tce(e,t){let n=w({queryKey:[`zone-analytics`,t,`stationaryOverlay`],enabled:t!==null,refetchInterval:T9,staleTime:T9/2,queryFn:async()=>{let n=(await e.zoneAnalytics.getCurrentSnapshot.query({deviceId:t}))?.stationaryObjects??[],r=[];for(let e of n){let t=E9(e);t!==null&&r.push(t)}return r}});return n.isError?void 0:n.data}E();function D9(e){let t=e?.deviceId??null,n=e?.historyLimit??20,r=Po(`doorbell.onPressed`,t===null?void 0:e=>e.deviceId===t),[i,a]=C([]);return b(()=>{r&&a(e=>{if(e.length>0&&e[0].deviceId===r.deviceId&&e[0].timestamp===r.timestamp)return e;let t=[r,...e];return t.length>n?t.slice(0,n):t})},[r,n]),{latest:r??null,history:i}}E();var Ece=1e3;function O9(e,t){let n=Rn(),r=k(),[i,a]=C(n.connectionVersion);b(()=>n.subscribeConnectionEvents((e,t)=>{e===`connected`&&a(t)}),[n]);let o=t.join(`|`),s=JSON.stringify(e);b(()=>{let e=[],t=null,i=()=>{let e=JSON.parse(s),t=e.length===1&&Array.isArray(e[0])?e:[e];r.invalidateQueries({queryKey:t})},a=()=>{t===null&&(t=setTimeout(()=>{t=null,i()},Ece))};i();for(let t of o.split(`|`))if(t)try{e.push(n.subscribeEvent(t,a))}catch{}return()=>{t!==null&&clearTimeout(t);for(let t of e)t()}},[n,r,o,s,i])}function Dce(e,t,n){let r=Rn();return w({queryKey:e,queryFn:()=>t(r)(),...n})}function Oce(e,t){let n=Rn();return j({mutationFn:t=>e(n)(t),...t})}var k9=`en`,A9=new Map,j9=new Set,M9=0;function N9(e){let t=(e??``).trim().toLowerCase().split(/[-_]/)[0]??``;return t===``?k9:t}function P9(){if(typeof document<`u`){let e=document.documentElement.lang;if(e.trim()!==``)return N9(e)}return typeof navigator<`u`&&typeof navigator.language==`string`?N9(navigator.language):k9}function F9(e,t,n){let r=N9(t),i=A9.get(e)??new Map;i.set(r,n),A9.set(e,i),M9+=1;for(let e of j9)e()}function kce(e){j9.add(e);let t=null;return typeof document<`u`&&typeof MutationObserver<`u`&&(t=new MutationObserver(e),t.observe(document.documentElement,{attributes:!0,attributeFilter:[`lang`]})),()=>{j9.delete(e),t?.disconnect()}}function I9(){return`${P9()}#${M9}`}function L9(e,t){let n=e;for(let e of t){if(n===void 0||typeof n==`string`)return;n=n[e]}return typeof n==`string`?n:void 0}function Ace(e,t){try{return new Intl.PluralRules(e).select(t)}catch{return`other`}}function R9(e,t,n,r){let i=A9.get(e)?.get(t);if(i===void 0)return;let a=n.split(`.`);if(r!==void 0){let e=a[a.length-1]??n,o=a.slice(0,-1),s=L9(i,[...o,`${e}_${Ace(t,r)}`]);if(s!==void 0)return s;let c=L9(i,[...o,`${e}_other`]);if(c!==void 0)return c}return L9(i,a)}var jce=/\{\{\s*([\w.]+)\s*\}\}/g;function z9(e,t){return t===void 0?e:e.replace(jce,(e,n)=>{let r=t[n];return r===void 0?e:String(r)})}function B9(e,t,n,r){let i=r?.count,a=typeof i==`number`?i:void 0;return z9(R9(e,t,n,a)??R9(e,k9,n,a)??n,r)}E();function Mce(){return S(kce,I9,I9)}function V9(e,t){let n=Mce(),r=n.slice(0,n.indexOf(`#`)),i=t===void 0?r:N9(t);return{t:_((t,n)=>B9(e,i,t,n),[e,i,n]),lang:i}}var Nce=/<(\/?)([A-Za-z][\w-]*)(\s*\/)?>/g;function H9(e,t,n,r){let i=e[t];return i===void 0?v(d,{children:n},r):h(i,{key:r},...n)}function U9(e,t,n){let r={name:``,children:[]},i=[r],a=0,o=0,s=()=>i[i.length-1]??r,c=e=>{e!==``&&s().children.push(z9(e,n))};for(let n of e.matchAll(Nce)){c(e.slice(a,n.index)),a=n.index+n[0].length;let r=n[1]===`/`,l=n[2]??``;if(o+=1,n[3]!==void 0)s().children.push(H9(t,l,[],`k${o}`));else if(!r)i.push({name:l,children:[]});else if(i.length>1&&s().name===l){let e=i.pop();e&&s().children.push(H9(t,l,e.children,`k${o}`))}}for(c(e.slice(a));i.length>1;){let e=i.pop();e&&s().children.push(...e.children)}return r.children}function Pce(e,t){for(let[n,r]of Object.entries(t))F9(e,n,r);return{ns:e,useT:t=>V9(e,t),Trans:t=>{let{t:n}=V9(e),r=t.values?.count;return v(P,{children:U9(n(t.i18nKey,typeof r==`number`?{count:r}:void 0),t.components??{},t.values)})},translate:(t,n)=>B9(e,P9(),t,n)}}var Fce={onvif:vi,hikvision:Ln,reolink:fe,homeAssistant:Oi,rtsp:ur},Ice={online:Ni,offline:Ur,degraded:Ai,unknown:$n},W9={onvif:`#3b82f6`,hikvision:`#a855f7`,reolink:`#06b6d4`,homeAssistant:`#22d3ee`,rtsp:`#78716c`},G9={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`,successFill:`#4ade80`,successOn:`#0c0a09`,warningFill:`#fbbf24`,warningOn:`#0c0a09`,dangerFill:`#f87171`,dangerOn:`#0c0a09`,infoFill:`#60a5fa`,infoOn:`#0c0a09`,primaryFill:`#f59e42`,primaryOn:`#0c0a09`,neutralFill:`#44403c`,neutralOn:`#fafaf9`,provider:W9},K9={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`,successFill:`#15803d`,successOn:`#ffffff`,warningFill:`#b45309`,warningOn:`#ffffff`,dangerFill:`#dc2626`,dangerOn:`#ffffff`,infoFill:`#2563eb`,infoOn:`#ffffff`,primaryFill:`#c2410c`,primaryOn:`#ffffff`,neutralFill:`#57534e`,neutralOn:`#ffffff`,provider:W9},q9={colors:{dark:G9,light:K9},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 J9(e,t){let n={...e};for(let r in t){let i=t[r],a=e[r];i!==void 0&&typeof i==`object`&&i&&!Array.isArray(i)&&typeof a==`object`&&a?n[r]=J9(a,i):i!==void 0&&(n[r]=i)}return n}function Lce(e){return e?J9(structuredClone(q9),e):structuredClone(q9)}function Y9(e){return e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}function Rce(e){return`--color-${Y9(e)}`}function X9(e){let t=[];for(let[n,r]of Object.entries(e))n!==`provider`&&t.push(` ${Rce(n)}: ${r};`);return t.join(`
|
|
39
39
|
`)}function zce(e){let t=[];for(let[n,r]of Object.entries(e))t.push(` --color-provider-${Y9(n)}: ${r};`);return t.join(`
|
|
40
40
|
`)}function Bce(e){let t=[];for(let[n,r]of Object.entries(e))t.push(` --spacing-${n}: ${r}px;`);return t.join(`
|
|
41
41
|
`)}function Vce(e){let t=[];for(let[n,r]of Object.entries(e))t.push(` --radius-${n}: ${r}px;`);return t.join(`
|