@camstack/addon-admin-ui 1.2.86 → 1.2.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AddLocationWizard-CVvsaNYx.js → AddLocationWizard-ClWHdX1D.js} +1 -1
- package/dist/assets/{AddonCollectionPage-JA8tzL7q.js → AddonCollectionPage-CCm-n_-k.js} +1 -1
- package/dist/assets/{Addons-BOYMP0uf.js → Addons-CNQu3idA.js} +1 -1
- package/dist/assets/{AdminTabs-B-UL_iuP.js → AdminTabs-Ya-WafVI.js} +1 -1
- package/dist/assets/{AiProfiles-DI31JvyZ.js → AiProfiles-G8ohU36w.js} +1 -1
- package/dist/assets/{BrokerForm-CFTyH54D.js → BrokerForm-Cja9Cp03.js} +1 -1
- package/dist/assets/{Build-BP0Mx9FT.js → Build-BUwpX-xq.js} +1 -1
- package/dist/assets/{Capabilities-BvxWbN6u.js → Capabilities-CzxtAA9j.js} +1 -1
- package/dist/assets/{CapabilityBadges-DjOvNnpp.js → CapabilityBadges-BVAXgYuj.js} +1 -1
- package/dist/assets/{Cluster-CsEHMgVp.js → Cluster-C3WY-Tom.js} +1 -1
- package/dist/assets/{Data-Bt2o6J7H.js → Data-DP4AzN8W.js} +1 -1
- package/dist/assets/{DetectionIntelligence-CeunXPtW.js → DetectionIntelligence-Dm0ZECMd.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-DLNzCtMs.js → DeviceAggregateSection-aUgWgamW.js} +1 -1
- package/dist/assets/{DeviceDetail-DCh8ydpY.js → DeviceDetail-BoKKas-k.js} +1 -1
- package/dist/assets/{Devices-fMM-N9UK.js → Devices-BVC0zPbb.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-D8LRITOt.js → EmbedPlayerPage-BwM49mOX.js} +1 -1
- package/dist/assets/{Events-Drj6ybP0.js → Events-X4Lovw2K.js} +1 -1
- package/dist/assets/{FormBuilder-ChyOUw_O.js → FormBuilder-CgtfU1VA.js} +1 -1
- package/dist/assets/{Identity-kjnupMGz.js → Identity-C2TOQEJq.js} +1 -1
- package/dist/assets/{IntegrationDetail-683FxnPV.js → IntegrationDetail-3MgmsFlC.js} +1 -1
- package/dist/assets/{Integrations-BAa7Hx8I.js → Integrations-AQCeGcvO.js} +1 -1
- package/dist/assets/{Integrations-Bvz5KiZt.js → Integrations-CE6i7W5X.js} +1 -1
- package/dist/assets/{Logs-CPMTc4WW.js → Logs-C1e0vFcW.js} +1 -1
- package/dist/assets/{MotionZonesSettings-DhO5kuER.js → MotionZonesSettings-AZZ7Vac3.js} +1 -1
- package/dist/assets/{MyAccess-C5kfikXk.js → MyAccess-oAGUI1mc.js} +1 -1
- package/dist/assets/{Network-DBtVDYGt.js → Network-BLaNQAjB.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BdP5wGIu.js → NodeAddonsSettingsPanel-B1Cyvbcv.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-CubcmlvI.js → NodeInferenceDevices-CkoeBXMD.js} +1 -1
- package/dist/assets/{Notifications-DBH3QGle.js → Notifications-D2ro0AxS.js} +1 -1
- package/dist/assets/{Pipeline-DgZbCwcO.js → Pipeline-BvxT4V4g.js} +1 -1
- package/dist/assets/{Plates-DiVTWUKg.js → Plates-TsHHlZDi.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-zKU6VZ4G.js → PrivacyMaskSettings-BxIYztmC.js} +1 -1
- package/dist/assets/{ProviderIcon-JxmOoO_O.js → ProviderIcon-BBJFc8mr.js} +1 -1
- package/dist/assets/{Recordings-DTGdM6Ip.js → Recordings-CYIFqOWF.js} +1 -1
- package/dist/assets/{ScanNetworkModal-DkqUu2Xc.js → ScanNetworkModal-BQIyP8Qh.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-DZucoVrl.js → SceneMonitorEditor-ZOTjS5Og.js} +1 -1
- package/dist/assets/{Scenes-DMSYbhd1.js → Scenes-DDemjEwK.js} +1 -1
- package/dist/assets/{Settings-olnTIAze.js → Settings-BJydhDaq.js} +1 -1
- package/dist/assets/{Showroom-CdPGD4R4.js → Showroom-Di_0Md3V.js} +1 -1
- package/dist/assets/{Terminal-Ck0I64eZ.js → Terminal-CIo6IaUC.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BpY1fOVD.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C91lgIiF.js} +1 -1
- package/dist/assets/{bell-ring-BgQsFN7F.js → bell-ring-0co0yj8J.js} +1 -1
- package/dist/assets/{boxes-BnOBLNz5.js → boxes-CKu64rZy.js} +1 -1
- package/dist/assets/{build-cluster-graph-BwHdP82z.js → build-cluster-graph-BWmowgwv.js} +1 -1
- package/dist/assets/circle-check-big-BPF9MiQz.js +1 -0
- package/dist/assets/{circle-x-DAqnOyA6.js → circle-x-_qOKhKMV.js} +1 -1
- package/dist/assets/clock-DoS4fxPG.js +1 -0
- package/dist/assets/{copy-Dl5E5of_.js → copy-CE9Wp04n.js} +1 -1
- package/dist/assets/{debounced-invalidate-BIRVvqvY.js → debounced-invalidate-CfnWx62K.js} +1 -1
- package/dist/assets/{dist-CUfLXJC3.js → dist-CcR-lswN.js} +1 -1
- package/dist/assets/{dist-C2l22cSJ.js → dist-D6EYui_h.js} +1 -1
- package/dist/assets/{download-AfoMEWCf.js → download-mZ1OYsqe.js} +1 -1
- package/dist/assets/{face-bbox-BFT7iMc1.js → face-bbox-Y-X13UcQ.js} +1 -1
- package/dist/assets/{hard-drive-C9zTEogy.js → hard-drive-D6z2TCCh.js} +1 -1
- package/dist/assets/{hostInit-Cw_l9Xfz.js → hostInit-Dr0x9nND.js} +1 -1
- package/dist/assets/{index-vZPXzSPK.js → index-CoX6Kh_l.js} +3 -3
- package/dist/assets/{key-round-sF-8oSo7.js → key-round-CegkgxO2.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-8f39d7c2.js → mf-entry-bootstrap-0-e3818a6f.js} +2 -2
- package/dist/assets/{pencil-DsWgW1cM.js → pencil-CCyVFYXA.js} +1 -1
- package/dist/assets/play-DCoy3WUZ.js +1 -0
- package/dist/assets/{player-overlays-BGbLKvcn.js → player-overlays-BCuyatPp.js} +1 -1
- package/dist/assets/plus-D-xjJ9wd.js +1 -0
- package/dist/assets/power-ChfUL_0y.js +1 -0
- package/dist/assets/{radio-CWn4dw9L.js → radio-DvHOeyw2.js} +1 -1
- package/dist/assets/{refresh-cw-Cly4MRhi.js → refresh-cw-CvqUZLg2.js} +1 -1
- package/dist/assets/remoteEntry-C4Nbi34r.js +1 -0
- package/dist/assets/rotate-ccw-CwngHzIQ.js +1 -0
- package/dist/assets/rotate-cw-pPP0LEo9.js +1 -0
- package/dist/assets/search-Cvti5PjG.js +1 -0
- package/dist/assets/{send-yaKZ1tHd.js → send-DRex-kWD.js} +1 -1
- package/dist/assets/{server-CLOtA1S4.js → server-DSkdRu09.js} +1 -1
- package/dist/assets/square-B3jj9vzX.js +1 -0
- package/dist/assets/{square-check-big-DsiPGDCA.js → square-check-big-BbcMGYFH.js} +1 -1
- package/dist/assets/{src-Buv5KpAz.js → src-BmCjCFGO.js} +3 -3
- package/dist/assets/{src-CQVcBp6b.js → src-D8hsVOc6.js} +1 -1
- package/dist/assets/{star-fUCw1hyi.js → star-BT_oUHvU.js} +1 -1
- package/dist/assets/{undo-2-DXcExZt9.js → undo-2-D7QQycip.js} +1 -1
- package/dist/assets/{upload-CLT-rIe6.js → upload-D5h4xcC3.js} +1 -1
- package/dist/assets/{use-scenes-feed-CvesyXw2.js → use-scenes-feed-DcfGN5ks.js} +1 -1
- package/dist/assets/useEventInvalidation-DCo7fWEj.js +1 -0
- package/dist/assets/{video-CFtTGKiz.js → video--sYC3ys-.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BwIIU_83.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DBBIBnMR.js} +2 -2
- package/dist/assets/{wifi-Glpx3AkR.js → wifi-Wacew_4h.js} +1 -1
- package/dist/assets/{zap-aTn3GS-l.js → zap-CrjJ004P.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +11 -2
- package/package.json +1 -1
- package/dist/assets/circle-check-big-FvfSWrhR.js +0 -1
- package/dist/assets/clock-BpmU9WHJ.js +0 -1
- package/dist/assets/play-BkPr3HPj.js +0 -1
- package/dist/assets/plus-zSkh3oEn.js +0 -1
- package/dist/assets/power-C4yi0usE.js +0 -1
- package/dist/assets/remoteEntry-BwhR6qpk.js +0 -1
- package/dist/assets/rotate-ccw-D0bM0VXI.js +0 -1
- package/dist/assets/rotate-cw-CNTEn7nJ.js +0 -1
- package/dist/assets/search-Bq3ZLayo.js +0 -1
- package/dist/assets/square-BlSn3fsr.js +0 -1
- package/dist/assets/useEventInvalidation-B-Cb5-ry.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as u}from"./player-overlays-BGbLKvcn.js";import{At as d,Br as f,Dt as p,Et as m,It as h,Lt as g,Ms as _,Nt as v,Ot as y,Pt as b,ai as x,ci as S,di as C,fi as w,ii as T,kt as E,li as D,ln as O,ni as k,oi as A,pi as j,ri as M,si as N,ti as P,ui as F,wt as I}from"./src-Buv5KpAz.js";import{Lt as L}from"./src-CQVcBp6b.js";import{a as R,i as z,n as B,r as V,t as H}from"./face-bbox-BFT7iMc1.js";import{a as U,c as ee,f as W,i as G,l as te,m as ne,n as K,o as re,p as q,r as ie,s as ae,t as oe,u as se}from"./debounced-invalidate-BIRVvqvY.js";import{t as ce}from"./pencil-DsWgW1cM.js";import{t as le}from"./plus-zSkh3oEn.js";import{t as ue}from"./refresh-cw-Cly4MRhi.js";import{t as de}from"./rotate-cw-CNTEn7nJ.js";import{t as fe}from"./square-check-big-DsiPGDCA.js";import{t as pe}from"./square-BlSn3fsr.js";import{t as me}from"./undo-2-DXcExZt9.js";import{C as J,I as Y,K as X,R as he,h as ge,i as Z,l as _e,o as ve,s as ye,z as be}from"./index-vZPXzSPK.js";import{t as xe}from"./AdminPage-CCD07UMs.js";import{r as Se,t as Ce}from"./authed-media-BPd_L9jr.js";var we=X(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Te=X(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);n();var Ee=`pipeline-analytics`,De=`photo.analyze`,Oe=`photo.enroll`,ke=`photo.discard`,Ae=18*1024*1024;function je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function $(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function Me(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Ne(e){if(!je(e))return null;let t=$(e,`x`),n=$(e,`y`),r=$(e,`width`),i=$(e,`height`);return t===null||n===null||r===null||i===null?null:{x:t,y:n,width:r,height:i}}function Pe(e){if(!je(e))return null;let t=$(e,`detectionShortSidePx`),n=$(e,`score`);if(t===null||n===null)return null;let r=$(e,`magnitude`);return{detectionShortSidePx:t,score:n,...r===null?{}:{magnitude:r}}}function Fe(e){if(!je(e))return null;let t=$(e,`faceIndex`),n=$(e,`score`),r=Me(e,`enrollable`),i=Ne(e.bbox),a=Pe(e.quality);if(t===null||n===null||r===null||i===null||a===null)return null;let o=Q(e,`refusedReason`),s=Q(e,`alignedCropBase64`),c=Q(e,`modelId`);return{faceIndex:t,bbox:i,score:n,enrollable:r,quality:a,...o===null?{}:{refusedReason:o},...s===null?{}:{alignedCropBase64:s},...c===null?{}:{modelId:c}}}function Ie(e){if(!je(e))return null;let t=Q(e,`sessionId`),n=Q(e,`ranOnNodeId`),r=e.faces;if(t===null||n===null||!Array.isArray(r))return null;let i=[];for(let e of r){let t=Fe(e);t!==null&&i.push(t)}return{sessionId:t,ranOnNodeId:n,faces:i}}function Le(e){if(!je(e))return null;let t=Q(e,`sampleId`),n=Q(e,`identityId`),r=Q(e,`modelId`);return t===null||n===null||r===null?null:{sampleId:t,identityId:n,modelId:r}}function Re(e,t,n){let r={...e};return n===null||n===``?delete r[t]:r[t]=n,r}function ze(e,t){return e.filter(e=>e.enrollable&&t[e.faceIndex]!==void 0).length}function Be(e,t,n){let r=[];for(let i of t){if(!i.enrollable)continue;let t=n[i.faceIndex];t!==void 0&&r.push({sessionId:e,faceIndex:i.faceIndex,identityId:t})}return r}function Ve(e){switch(e){case`no-embedding`:return`Too small or too indistinct for the recognizer to measure — try a photo where this face is larger.`;case`no-model-id`:return`The recognizer did not report which model it used, so this face cannot be enrolled safely.`;case`no-aligned-crop`:return`The recognizer produced no aligned crop for this face, so there is nothing to store.`;case`magnitude`:return`Refused by the quality gate: the features look degenerate, and a sample like this matches everybody.`;default:return`This face is not usable as a sample.`}}function He(e,t){let n=[],r=[];for(let i of e)i.size>t.maxBytes?n.push(i.name):r.push(i);return{accepted:r.slice(0,t.maxCount),oversize:n,overflow:r.slice(t.maxCount).map(e=>e.name)}}async function Ue(e,t,n){let r=Array(e.length),i=e.map((e,t)=>({item:e,index:t})),a=0,o=async()=>{for(;;){let e=i[a];if(a+=1,e===void 0)return;r[e.index]=await n(e.item,e.index)}},s=Array.from({length:Math.max(1,Math.min(t,e.length))},()=>o());return await Promise.all(s),r}function We(e,t,n){return e.map(e=>e.photoIndex===t?{...e,...n}:e)}function Ge(e,t){return`${e}:${t}`}function Ke(e,t,n,r){let i=Re(e[t]??{},n,r),a={...e};return Object.keys(i).length===0?delete a[t]:a[t]=i,a}function qe(e,t){let n=0;for(let r of e)r.analysis!==void 0&&(n+=ze(r.analysis.faces,t[r.photoIndex]??{}));return n}var Je=`__new__`;function Ye(e,t,n){let r=[];for(let i of e){if(i.analysis===void 0)continue;let e=t[i.photoIndex]??{};for(let t of i.analysis.faces){if(!t.enrollable||e[t.faceIndex]!==`__new__`)continue;let a=(n[Ge(i.photoIndex,t.faceIndex)]??``).trim();if(a===``)return{kind:`error`,message:`${i.filename}: face ${t.faceIndex+1} is set to a new person but has no name.`};r.includes(a)||r.push(a)}}return{kind:`ok`,names:r}}function Xe(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=Number(i),o={};for(let[r,i]of Object.entries(a)){let a=Number(r);if(i!==`__new__`){o[a]=i;continue}let s=n[(t[Ge(e,a)]??``).trim()];s!==void 0&&(o[a]=s)}r[e]=o}return r}function Ze(e,t){let n=[];for(let r of e){if(r.analysis===void 0)continue;let e=Be(r.analysis.sessionId,r.analysis.faces,t[r.photoIndex]??{});for(let t of e)n.push({photoIndex:r.photoIndex,request:t})}return n}function Qe(e){return/expired/i.test(e)}function $e(e){return e instanceof Error?e.message:String(e)}async function et(e,t,n){let r=new Map(e.map(e=>[e.photoIndex,e])),i={},a=[],o=0,s=null,c=(e,t)=>`${r.get(e)?.filename??`photo ${e+1}`}, face ${t+1}`;for(let l of Ze(e,t)){let e=i[l.photoIndex],t=e===void 0?l.request:{...l.request,sessionId:e.sessionId};try{let e=await n.enroll(t);o+=1,s=e.modelId}catch(t){let u=$e(t);if(!Qe(u)||e!==void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let d=r.get(l.photoIndex);if(d===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let f;try{f=await n.reanalyze(d)}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired and re-analysing failed (${$e(e)})`);continue}if(i[l.photoIndex]=f,f.faces.find(e=>e.faceIndex===l.request.faceIndex&&e.enrollable)===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired, and re-analysing no longer finds this face — assign it again from the fresh result`);continue}try{let e=await n.enroll({...l.request,sessionId:f.sessionId});o+=1,s=e.modelId}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${$e(e)}`)}}}return{enrolled:o,stampedModelId:s,failures:a,refreshedAnalyses:i}}var tt=[[`faceGallery`]],nt=``;function rt(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`error`,()=>n(Error(`the file could not be read`)),{once:!0}),r.addEventListener(`load`,()=>{let e=r.result;if(typeof e!=`string`){n(Error(`the file could not be read`));return}let i=e.indexOf(`,`);t(i>=0?e.slice(i+1):e)},{once:!0}),r.readAsDataURL(e)})}function it(e){return e instanceof Error?e.message:String(e)}function at({face:e,identities:t,value:n,onChange:o,disabled:s}){let l=i(()=>[{value:nt,label:`Ignore this face`},...t.map(e=>({value:e.id,label:e.name})),{value:Je,label:`+ New person…`}],[t]);return r(`div`,{className:`rounded-md border border-border bg-surface p-2`,children:[c(`div`,{className:`mb-2 aspect-square w-full overflow-hidden rounded border border-border bg-surface-hover`,children:e.alignedCropBase64?c(`img`,{src:`data:image/jpeg;base64,${e.alignedCropBase64}`,alt:`Face ${e.faceIndex+1}`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Te,{className:`h-8 w-8`})})}),e.enrollable?r(a,{children:[c(v,{options:l,value:n,disabled:s,onChange:e=>o(e.target.value),"aria-label":`Assign face ${e.faceIndex+1}`}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:[Math.round(e.quality.detectionShortSidePx),` px`,e.modelId?` · ${e.modelId}`:``]})]}):r(`div`,{className:`space-y-1`,children:[c(h,{variant:`warning`,className:`text-[10px]`,children:`Not usable`}),c(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:Ve(e.refusedReason)})]})]})}function ot({photo:e,identities:t,draft:n,newNames:i,disabled:a,onAssign:o,onNameChange:s,onRetry:l}){let u=e.analysis?.faces??[],d=n[e.photoIndex]??{};return r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex items-center gap-2 border-b border-border pb-1`,children:[c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.filename}),e.status===`analyzing`||e.status===`queued`?r(`span`,{className:`flex items-center gap-1 text-xs text-foreground-subtle`,children:[c(J,{className:`h-3 w-3 animate-spin`}),` analysing…`]}):null,e.status===`analyzed`&&e.analysis!==void 0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[u.length,` face`,u.length===1?``:`s`,` · analysed on`,` `,e.analysis.ranOnNodeId]}),e.status===`failed`&&r(g,{variant:`secondary`,size:`sm`,disabled:a,onClick:l,children:[c(de,{className:`h-3 w-3`}),` Retry`]})]}),e.status===`failed`&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`This photo could not be analysed: `,e.error??`unknown error`,`. The other photos are unaffected.`]})]}),e.status===`analyzed`&&u.length===0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:`No faces were found in this photo. A face has to be reasonably large and facing the camera for the detector to measure it.`}),u.length>0&&c(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5`,children:u.map(e=>c(at,{face:e,identities:t,value:d[e.faceIndex]??nt,disabled:a,onChange:t=>o(e.faceIndex,t)},e.faceIndex))}),u.filter(e=>d[e.faceIndex]===Je).map(t=>r(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`w-28 shrink-0 truncate text-xs text-foreground-subtle`,children:[`Face `,t.faceIndex+1]}),c(`input`,{className:`h-7 flex-1 rounded-md border border-border bg-surface px-2.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,placeholder:`New person name… (type the same name under another face to reuse it)`,value:i[Ge(e.photoIndex,t.faceIndex)]??``,onChange:e=>s(t.faceIndex,e.target.value)})]},t.faceIndex))]})}function st({open:n,onOpenChange:a}){let l=u(),f=o(),h=t(null),{data:_}=A(),v=k(),[b,x]=s([]),[S,C]=s(!1),[w,T]=s(null),[D,O]=s({}),[j,M]=s({}),[N,P]=s(null),F=i(()=>(_??[]).map(e=>({id:e.id,name:e.name})),[_]),L=b.some(e=>e.status===`queued`||e.status===`analyzing`),R=L||S,z=e(e=>{for(let t of e){let e=t.analysis?.sessionId;e!==void 0&&l.trpcClient.addons.custom.mutate({addonId:Ee,action:ke,input:{sessionId:e}}).catch(()=>void 0)}},[l]),B=e(()=>{x([]),O({}),M({}),T(null),P(null),h.current&&(h.current.value=``)},[]),V=e(()=>{z(b),B(),a(!1)},[z,a,b,B]),H=e(async e=>{let t=Ie(await l.trpcClient.addons.custom.mutate({addonId:Ee,action:De,input:{photoBase64:e.photoBase64,filename:e.filename}}));if(t===null)throw Error(`the server replied with something this page could not read`);return t},[l]),U=e(async e=>{x(t=>We(t,e.photoIndex,{status:`analyzing`,error:void 0}));try{let t=await H(e);x(n=>We(n,e.photoIndex,{status:`analyzed`,analysis:t}))}catch(t){x(n=>We(n,e.photoIndex,{status:`failed`,error:it(t)}))}},[H]),ee=e(async e=>{if(e.length===0)return;z(b),B();let t=He(e,{maxCount:12,maxBytes:Ae}),n=[];t.oversize.length>0&&n.push(`Over the ${Math.round(Ae/(1024*1024))} MB limit and skipped: ${t.oversize.join(`, `)}.`),t.overflow.length>0&&n.push(`A batch holds at most 12 photos — not analysed: ${t.overflow.join(`, `)}. Enrol them in a second round.`),n.length>0&&T(n.join(` `));let r;try{r=await Promise.all(t.accepted.map(async(e,t)=>({photoIndex:t,filename:e.name,photoBase64:await rt(e),status:`queued`})))}catch(e){T(it(e));return}x(r),await Ue(r,2,e=>U(e))},[z,b,B,U]),W=qe(b,D),G=e(async()=>{C(!0),T(null),P(null);try{let e=Ye(b,D,j);if(e.kind===`error`){T(e.message);return}let t={};for(let n of e.names)t[n]=(await v.mutateAsync({name:n})).id;let n=await et(b,Xe(D,j,t),{enroll:async e=>{let t=Le(await l.trpcClient.addons.custom.mutate({addonId:Ee,action:Oe,input:e}));if(t===null)throw Error(`unreadable reply`);return t},reanalyze:e=>H(e)});Object.keys(n.refreshedAnalyses).length>0&&x(e=>e.map(e=>{let t=n.refreshedAnalyses[e.photoIndex];return t===void 0?e:{...e,status:`analyzed`,analysis:t}})),f.invalidateQueries({queryKey:tt}),n.failures.length>0&&T(n.failures.join(` · `)),P(n.enrolled===0?`Nothing was enrolled.`:`Enrolled ${n.enrolled} sample${n.enrolled===1?``:`s`}${n.stampedModelId===null?``:` with ${n.stampedModelId}`}.`)}catch(e){T(it(e))}finally{C(!1)}},[H,v,D,j,b,f,l]),te=b.filter(e=>e.status===`analyzed`).length;return c(I,{open:n,onOpenChange:e=>e?a(!0):V(),children:r(m,{className:`max-w-3xl`,children:[r(E,{children:[c(d,{children:`Enrol from photos`}),c(p,{children:`Every photo is analysed with the same face detector the cameras use, and all the faces found are reviewed below in one pass, grouped by photo. Assign each face to a person, or leave it ignored.`})]}),r(`div`,{className:`rounded-md border border-border bg-surface-hover px-3 py-2 text-xs text-foreground-subtle`,children:[`For reliable recognition use `,c(`strong`,{children:`at least 3 photos per person`}),`, taken at different times, with different poses and lighting — you can select them all at once. Several frames from the same moment count as one — they do not add information.`]}),r(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{ref:h,type:`file`,accept:`image/jpeg,image/png,image/webp`,multiple:!0,className:`hidden`,onChange:e=>void ee(Array.from(e.target.files??[]))}),r(g,{variant:`secondary`,size:`sm`,disabled:R,onClick:()=>h.current?.click(),children:[L?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(we,{className:`h-3.5 w-3.5`}),`Choose photos`]}),b.length>0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[te,`/`,b.length,` photo`,b.length===1?``:`s`,` analysed`]})]}),w!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),c(`span`,{children:w})]}),N!==null&&c(`div`,{className:`rounded-md border border-success/40 bg-success/10 px-3 py-2 text-xs text-success`,children:N}),b.length>0&&c(`div`,{className:`max-h-[50vh] space-y-4 overflow-y-auto pr-1`,children:b.map(e=>c(ot,{photo:e,identities:F,draft:D,newNames:j,disabled:R,onAssign:(t,n)=>O(r=>Ke(r,e.photoIndex,t,n===nt?null:n)),onNameChange:(t,n)=>M(r=>({...r,[Ge(e.photoIndex,t)]:n})),onRetry:()=>void U(e)},e.photoIndex))}),r(y,{children:[c(g,{variant:`secondary`,onClick:V,disabled:S,children:`Close`}),r(g,{variant:`primary`,onClick:()=>void G(),disabled:R||W===0,children:[S?c(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Enrol `,W,` face`,W===1?``:`s`]})]})]})})}n();var ct=[[`faceGallery`]];function lt({identityId:e}){let t=o(),{data:n,isLoading:i}=N({identityId:e}),a=D();function s(n){a.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:ct})}})}return i?r(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):c(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>r(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?c(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Te,{className:`h-6 w-6`})}),e.source===`photo`&&c(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 p-0.5 text-white`,title:`Enrolled from an uploaded photo`,children:c(we,{className:`h-3 w-3`})}),c(`button`,{type:`button`,onClick:()=>s(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:c(Z,{className:`h-4 w-4 text-white`})})]},e.id))})}function ut({identity:e,expanded:t,onToggle:n}){let i=o(),[l,u]=s(``),[f,_]=s(!1),[v,x]=s(!1),S=F(),C=T();function w(){u(e.name),_(!0)}function D(){_(!1),u(``)}function O(){let t=l.trim();if(!t||t===e.name){D();return}S.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:ct}),D()}})}function k(){C.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:ct}),x(!1)}})}return r(`div`,{className:`rounded-md border border-border bg-surface`,children:[r(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[c(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?c(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center`,children:c(Te,{className:`h-4 w-4 text-foreground-subtle`})})}),c(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:f?r(a,{children:[c(b,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O(),e.key===`Escape`&&D()},className:`h-6 text-xs`,autoFocus:!0}),c(`button`,{type:`button`,onClick:O,disabled:S.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:c(be,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:D,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:c(Z,{className:`h-3.5 w-3.5`})})]}):c(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),c(h,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!f&&r(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,onClick:w,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:c(ce,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:()=>x(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:c(ye,{className:`h-3.5 w-3.5`})})]}),c(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:c(t?he:Y,{className:`h-3.5 w-3.5`})})]}),t&&c(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:c(lt,{identityId:e.id})}),c(I,{open:v,onOpenChange:e=>!e&&x(!1),children:r(m,{children:[r(E,{children:[c(d,{children:`Delete person`}),r(p,{children:[`Delete `,c(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),r(y,{children:[c(g,{variant:`secondary`,onClick:()=>x(!1),children:`Cancel`}),r(g,{variant:`danger`,onClick:k,disabled:C.isPending,children:[C.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function dt(){let e=o(),[t,n]=s(``),i=k();function a(){let r=t.trim();r&&i.mutate({name:r},{onSettled:()=>{e.invalidateQueries({queryKey:ct}),n(``)}})}return r(`div`,{className:`flex items-center gap-2 pt-2`,children:[c(b,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),r(g,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(le,{className:`h-3.5 w-3.5`}),`Add`]})]})}function ft(){let{data:e,isLoading:t}=A(),[n,i]=s(null),[a,o]=s(!1);function l(e){i(t=>t===e?null:e)}return t?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):r(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>c(ut,{identity:e,expanded:n===e.id,onToggle:()=>l(e.id)},e.id)),c(dt,{}),c(`div`,{className:`pt-1`,children:r(g,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:[c(we,{className:`h-3.5 w-3.5`}),`Enrol from a photo`]})}),c(st,{open:a,onOpenChange:o})]})}function pt(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function mt(e){return e.filter(pt).map(e=>e.faceId)}function ht(e){let t=0;for(let n of e)pt(n)&&(t+=1);return t}function gt(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}n();var _t=[[`faceGallery`]];function vt({faceIds:e,identities:t,onDone:n}){let i=o(),a=P(),l=k(),[u,f]=s(``),[h,_]=s(!1),[v,x]=s(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){_(!1),f(``),x(null)}function T(){w(),n()}function D(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:_t}),T()}})}function O(){!e||!u.trim()||l.mutate({name:u.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{i.invalidateQueries({queryKey:_t}),T()}})}let A=a.isPending||l.isPending;return c(I,{open:S,onOpenChange:e=>!e&&T(),children:r(m,{children:[r(E,{children:[c(d,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),c(p,{children:`Select an existing person or create a new one.`})]}),c(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>r(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${v===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[c(`span`,{className:`font-medium`,children:e.name}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),h?c(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:c(b,{placeholder:`New person name…`,value:u,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):c(`button`,{type:`button`,onClick:()=>{x(null),_(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),r(y,{children:[c(g,{variant:`secondary`,onClick:T,disabled:A,children:`Cancel`}),h?r(g,{variant:`primary`,onClick:O,disabled:A||!u.trim(),children:[A&&c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):r(g,{variant:`primary`,onClick:()=>v&&D(v),disabled:A||!v,children:[A&&c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}n();function yt(e){let[t,n]=s(null),[r,i]=s(null),[a,o]=s(!1);return l(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Se(`${Ce}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),l(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function bt(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function xt({label:e,value:t}){return r(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[c(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),c(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function St({box:e}){return c(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:c(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ct({face:e,cameraName:t,onClose:n,onAssign:a,onUnassign:o,onDelete:l,actionsPending:u}){let{data:d,isFetching:f}=x({faceId:e?.faceId??``},{enabled:e!==null}),[p,h]=s(`frame`),{frameSrc:_,naturalWidth:v,naturalHeight:y,failed:b}=yt(e?.keyFrameMediaKey),S=i(()=>{let t=bt(d??[]);return t?`data:image/jpeg;base64,${t.base64}`:gt(e)},[d,e]),C=i(()=>!e?.faceBbox||v===null||y===null?null:H(e.faceBbox,v,y),[e?.faceBbox,v,y]);if(e===null)return null;let w=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!b,T=w&&p===`frame`,E=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return c(I,{open:!0,onOpenChange:e=>!e&&n(),children:r(m,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[r(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),c(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),c(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(Z,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[w&&r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[r(`button`,{type:`button`,onClick:()=>h(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(z,{className:`h-3.5 w-3.5`}),` Full frame`]}),r(`button`,{type:`button`,onClick:()=>h(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(R,{className:`h-3.5 w-3.5`}),` Crop`]})]}),T&&_?c(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:c(K,{src:_,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:C?c(St,{box:C}):void 0})}):S?r(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[c(K,{src:S,alt:`Detected face`,className:`h-full w-full`}),f&&c(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:c(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):r(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[c(ne,{className:`h-8 w-8 text-warning/70`}),c(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),c(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[c(xt,{label:`Camera`,value:t}),c(xt,{label:`Captured`,value:q(e.timestamp)}),c(xt,{label:`Track`,value:e.trackId}),c(xt,{label:`Identity`,value:E})]})]}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?r(g,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:u,children:[c(B,{className:`h-3.5 w-3.5`}),` Detach`]}):r(g,{variant:`primary`,onClick:()=>a(e.faceId),disabled:u,children:[c(V,{className:`h-3.5 w-3.5`}),` Assign`]}),r(g,{variant:`secondary`,onClick:()=>l(e.faceId),disabled:u,children:[c(ye,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function wt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Tt(e,t){return e.faceIds.filter(e=>!t.has(e))}function Et(e,t){return e.faceIds.filter(e=>t(e))}n();var Dt=[[`faceGallery`]],Ot=20,kt=.3,At=.9,jt=.05,Mt=.5,Nt=2,Pt=10,Ft=2;function It({cluster:e,face:t,active:n,onSelect:i}){let a=gt(t);return r(`button`,{type:`button`,onClick:i,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[c(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:a===null?c(ne,{className:`h-24 w-24 p-6 text-foreground-subtle`}):c(`img`,{src:a,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),r(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Lt({face:e,cameraName:t,nowMs:n,excluded:i,onToggleExclude:a,onDelete:o,deletePending:s}){let l=gt(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${i?`border-border opacity-40 grayscale`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[l===null?r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[c(ne,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(K,{src:l,alt:`Face from ${t}`,className:`h-full w-full`}),c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Include face`:`Exclude face`,title:i?`Include`:`Exclude`,children:c(i?me:Z,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:W(e.timestamp,n)})]}),c(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:s,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:s?c(J,{className:`h-4 w-4 animate-spin`}):c(ye,{className:`h-4 w-4`})})})]})}function Rt({open:e,onClose:t,byId:n,cameraName:u,nowMs:d,identities:f,selectMany:p}){let h=o(),_=O(),v=M(),[y,b]=s(Mt),[x,S]=s(Ft),[w,T]=s(null),[E,D]=s({}),[k,A]=s(null),{data:j,isFetching:N,refetch:P}=C({threshold:y,minClusterSize:x,limit:Ot},{enabled:e}),F=j??[];l(()=>{D({})},[y,x]),l(()=>{if(F.length===0){T(null);return}F.some(e=>e.representativeFaceId===w)||T(F[0]?.representativeFaceId??null)},[F]);let L=i(()=>F.find(e=>e.representativeFaceId===w)??null,[F,w]),R=L?E[L.representativeFaceId]??new Set:new Set,z=i(()=>L?Et(L,e=>n.has(e)):[],[L,n]),B=L?L.faceIds.length-z.length:0,H=L?Tt({...L,faceIds:z},R):[];function U(e){if(!L)return;let t=L.representativeFaceId;D(n=>({...n,[t]:wt(n[t]??new Set,e)}))}function ee(){h.invalidateQueries({queryKey:Dt})}async function W(e){await _({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({faceId:e},{onSettled:ee})}function G(){A(null),t()}function te(){H.length!==0&&(p(H),G())}return r(I,{open:e,onOpenChange:e=>!e&&G(),children:[r(m,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[r(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(_e,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),c(`button`,{type:`button`,onClick:G,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(Z,{className:`h-4 w-4`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,c(`input`,{type:`range`,min:kt,max:At,step:jt,value:y,onChange:e=>b(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),c(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:y.toFixed(2)})]}),r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,c(`input`,{type:`number`,min:Nt,max:Pt,step:1,value:x,onChange:e=>S(Math.min(Pt,Math.max(Nt,Number(e.target.value)||Nt))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),r(g,{variant:`secondary`,onClick:()=>{D({}),P()},disabled:N,children:[N?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(ue,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:N&&F.length===0?r(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):F.length===0?c(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):r(a,{children:[c(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:F.map(e=>c(It,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===w,onSelect:()=>T(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:F.map(e=>c(It,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===w,onSelect:()=>T(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&r(a,{children:[B>0&&r(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[B,` not loaded — excluded from actions`]}),c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:z.map(e=>{let t=n.get(e);return t?c(Lt,{face:t,cameraName:u(t.deviceId),nowMs:d,excluded:R.has(e),onToggleExclude:()=>U(e),onDelete:()=>void W(e),deletePending:v.isPending&&v.variables?.faceId===e},e):null})})]})})]})}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[c(g,{variant:`secondary`,onClick:te,disabled:H.length===0,children:`Select in gallery`}),r(g,{variant:`primary`,onClick:()=>A(H),disabled:H.length===0,children:[c(V,{className:`h-3.5 w-3.5`}),` Adopt (`,H.length,`)`]})]})]}),c(vt,{faceIds:k,identities:f,onDone:()=>A(null)})]})}n();var zt=[[`faceGallery`]],Bt=500,Vt=120;function Ht({face:e,cameraName:t,nowMs:n,selected:i,onToggleSelect:a,onAssign:s,onOpenDetail:l}){let u=o(),d=w(),f=M(),p=()=>{u.invalidateQueries({queryKey:zt})},m=()=>l(e.faceId),h=gt(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[h===null?r(`button`,{type:`button`,onClick:m,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[c(ne,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(`img`,{src:h,alt:`Face from ${t}`,onClick:m,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Deselect`:`Select`,children:i?c(fe,{className:`h-4 w-4 text-primary`}):c(pe,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:W(e.timestamp,n)}),e.identityName&&c(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),r(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d.mutate({faceId:e.faceId},{onSettled:p})},disabled:d.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:d.isPending?c(J,{className:`h-4 w-4 animate-spin`}):c(B,{className:`h-4 w-4`})}):c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:c(V,{className:`h-4 w-4`})}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f.mutate({faceId:e.faceId},{onSettled:p})},disabled:f.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:f.isPending?c(J,{className:`h-4 w-4 animate-spin`}):c(ye,{className:`h-4 w-4`})})]})]})}var Ut=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function Wt(){let e=o(),[t,n]=s(`all`),[l,u]=s(ae),[d,p]=s(new Set),[m,h]=s(new Set),[_,v]=s(null),[y,b]=s(!1),[x,C]=s(null),{data:T,isLoading:E}=S({limit:Bt,filter:t,includeCrops:!1},{refetchInterval:3e4}),{data:D=[]}=A(),{data:O}=f({}),k=P(),N=w(),F=j(),I=M(),L=Date.now(),R=T??[],z=i(()=>{let e=new Map;for(let t of O??[])e.set(t.id,t.name);return e},[O]),H=e=>z.get(e)??`Camera #${String(e)}`,W=i(()=>ee(R).map(e=>({id:e,name:H(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[R,z]),K=i(()=>te(se(R,l),d),[R,l,d]),q=re(K,Vt,i(()=>JSON.stringify([t,l.fromMs,l.toMs,[...d].sort((e,t)=>e-t)]),[t,l.fromMs,l.toMs,d])),oe=i(()=>new Map(R.map(e=>[e.faceId,e])),[R]),ce=i(()=>ht(K),[K]),le=x===null?null:oe.get(x)??null,ue=()=>{e.invalidateQueries({queryKey:zt})},de=()=>h(new Set);function fe(e){h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){h(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(mt(K))}let Y=[...m],X=k.isPending||F.isPending||I.isPending,he=N.isPending||I.isPending;function ge(){Y.length!==0&&F.mutate({faceIds:Y},{onSettled:()=>{ue(),de()}})}function ve(){Y.length!==0&&Promise.allSettled(Y.map(e=>I.mutateAsync({faceId:e}))).then(()=>{ue(),de()})}function be(e){C(null),v([e])}function xe(e){N.mutate({faceId:e},{onSettled:ue}),C(null)}function Se(e){I.mutate({faceId:e},{onSettled:ue}),C(null)}let Ce=K.length!==R.length;return r(`div`,{className:`relative space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c(`div`,{className:`flex items-center gap-1`,children:Ut.map(e=>c(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),c(ie,{onChange:u}),c(G,{cameras:W,selected:d,onChange:p}),r(`button`,{type:`button`,onClick:()=>b(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${y?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(_e,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!E&&ce>0&&r(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[c(ne,{className:`h-3.5 w-3.5`}),` Select `,ce,` crop-less`]}),!E&&c(`span`,{className:`text-[10px] text-foreground-subtle ${ce>0?`ml-2`:`ml-auto`}`,children:Ce?`${String(K.length)} of ${String(R.length)} faces`:`${String(K.length)} face${K.length===1?``:`s`}`})]}),m.size>0&&r(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:[m.size,` selected`]}),r(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[r(g,{variant:`primary`,onClick:()=>v(Y),disabled:X,children:[c(V,{className:`h-3.5 w-3.5`}),` Assign`]}),r(g,{variant:`secondary`,onClick:ge,disabled:X,children:[F.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(B,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),r(g,{variant:`secondary`,onClick:ve,disabled:X,children:[c(ye,{className:`h-3.5 w-3.5`}),` Delete`]}),c(g,{variant:`ghost`,onClick:de,disabled:X,children:c(Z,{className:`h-3.5 w-3.5`})})]})]}),E&&r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!E&&K.length===0&&c(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:R.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!E&&K.length>0&&r(a,{children:[c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:q.pageItems.map(e=>c(Ht,{face:e,cameraName:H(e.deviceId),nowMs:L,selected:m.has(e.faceId),onToggleSelect:fe,onAssign:e=>v([e]),onOpenDetail:C},e.faceId))}),c(U,{currentPage:q.page,totalItems:q.totalItems,pageSize:q.pageSize,onPageChange:q.setPage,itemNoun:`faces`})]}),c(Ct,{face:le,cameraName:le?H(le.deviceId):``,onClose:()=>C(null),onAssign:be,onUnassign:xe,onDelete:Se,actionsPending:he}),c(vt,{faceIds:_,identities:D,onDone:()=>{v(null),de()}}),c(Rt,{open:y,onClose:()=>b(!1),byId:oe,cameraName:H,nowMs:L,identities:D,selectMany:pe})]})}n();var Gt=[[`faceGallery`]],Kt=2e3;function qt(){let e=o(),n=t(e);n.current=e;let r=t(void 0);r.current||=oe({delayMs:Kt,invalidate:()=>{n.current.invalidateQueries({queryKey:Gt})}}),l(()=>()=>r.current?.cancel(),[]),_(L.PipelineAnalyticsFaceGalleryChanged,()=>{r.current?.trigger()})}function Jt(){return qt(),c(xe,{icon:ge,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:r(`section`,{className:`space-y-3`,children:[r(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),c(ft,{})]}),r(`div`,{className:`pt-4 border-t border-border`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),c(Wt,{})]})]})})}export{Jt as DetectionIntelligencePage};
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,o,q as s,x as c,z as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as u}from"./player-overlays-BCuyatPp.js";import{At as d,Br as f,Dt as p,Et as m,It as h,Lt as g,Ms as _,Nt as v,Ot as y,Pt as b,ai as x,ci as S,di as C,fi as w,ii as T,kt as E,li as D,ln as O,ni as k,oi as A,pi as j,ri as M,si as N,ti as P,ui as F,wt as I}from"./src-BmCjCFGO.js";import{Lt as L}from"./src-D8hsVOc6.js";import{a as R,i as z,n as B,r as V,t as H}from"./face-bbox-Y-X13UcQ.js";import{a as U,c as ee,f as W,i as G,l as te,m as ne,n as K,o as re,p as q,r as ie,s as ae,t as oe,u as se}from"./debounced-invalidate-CfnWx62K.js";import{t as ce}from"./pencil-CCyVFYXA.js";import{t as le}from"./plus-D-xjJ9wd.js";import{t as ue}from"./refresh-cw-CvqUZLg2.js";import{t as de}from"./rotate-cw-pPP0LEo9.js";import{t as fe}from"./square-check-big-BbcMGYFH.js";import{t as pe}from"./square-B3jj9vzX.js";import{t as me}from"./undo-2-D7QQycip.js";import{C as J,I as Y,K as X,R as he,h as ge,i as Z,l as _e,o as ve,s as ye,z as be}from"./index-CoX6Kh_l.js";import{t as xe}from"./AdminPage-CCD07UMs.js";import{r as Se,t as Ce}from"./authed-media-BPd_L9jr.js";var we=X(`image-plus`,[[`path`,{d:`M16 5h6`,key:`1vod17`}],[`path`,{d:`M19 2v6`,key:`4bpg5p`}],[`path`,{d:`M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5`,key:`1ue2ih`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}]]),Te=X(`user-round`,[[`circle`,{cx:`12`,cy:`8`,r:`5`,key:`1hypcn`}],[`path`,{d:`M20 21a8 8 0 0 0-16 0`,key:`rfgkzh`}]]);n();var Ee=`pipeline-analytics`,De=`photo.analyze`,Oe=`photo.enroll`,ke=`photo.discard`,Ae=18*1024*1024;function je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function $(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function Me(e,t){let n=e[t];return typeof n==`boolean`?n:null}function Ne(e){if(!je(e))return null;let t=$(e,`x`),n=$(e,`y`),r=$(e,`width`),i=$(e,`height`);return t===null||n===null||r===null||i===null?null:{x:t,y:n,width:r,height:i}}function Pe(e){if(!je(e))return null;let t=$(e,`detectionShortSidePx`),n=$(e,`score`);if(t===null||n===null)return null;let r=$(e,`magnitude`);return{detectionShortSidePx:t,score:n,...r===null?{}:{magnitude:r}}}function Fe(e){if(!je(e))return null;let t=$(e,`faceIndex`),n=$(e,`score`),r=Me(e,`enrollable`),i=Ne(e.bbox),a=Pe(e.quality);if(t===null||n===null||r===null||i===null||a===null)return null;let o=Q(e,`refusedReason`),s=Q(e,`alignedCropBase64`),c=Q(e,`modelId`);return{faceIndex:t,bbox:i,score:n,enrollable:r,quality:a,...o===null?{}:{refusedReason:o},...s===null?{}:{alignedCropBase64:s},...c===null?{}:{modelId:c}}}function Ie(e){if(!je(e))return null;let t=Q(e,`sessionId`),n=Q(e,`ranOnNodeId`),r=e.faces;if(t===null||n===null||!Array.isArray(r))return null;let i=[];for(let e of r){let t=Fe(e);t!==null&&i.push(t)}return{sessionId:t,ranOnNodeId:n,faces:i}}function Le(e){if(!je(e))return null;let t=Q(e,`sampleId`),n=Q(e,`identityId`),r=Q(e,`modelId`);return t===null||n===null||r===null?null:{sampleId:t,identityId:n,modelId:r}}function Re(e,t,n){let r={...e};return n===null||n===``?delete r[t]:r[t]=n,r}function ze(e,t){return e.filter(e=>e.enrollable&&t[e.faceIndex]!==void 0).length}function Be(e,t,n){let r=[];for(let i of t){if(!i.enrollable)continue;let t=n[i.faceIndex];t!==void 0&&r.push({sessionId:e,faceIndex:i.faceIndex,identityId:t})}return r}function Ve(e){switch(e){case`no-embedding`:return`Too small or too indistinct for the recognizer to measure — try a photo where this face is larger.`;case`no-model-id`:return`The recognizer did not report which model it used, so this face cannot be enrolled safely.`;case`no-aligned-crop`:return`The recognizer produced no aligned crop for this face, so there is nothing to store.`;case`magnitude`:return`Refused by the quality gate: the features look degenerate, and a sample like this matches everybody.`;default:return`This face is not usable as a sample.`}}function He(e,t){let n=[],r=[];for(let i of e)i.size>t.maxBytes?n.push(i.name):r.push(i);return{accepted:r.slice(0,t.maxCount),oversize:n,overflow:r.slice(t.maxCount).map(e=>e.name)}}async function Ue(e,t,n){let r=Array(e.length),i=e.map((e,t)=>({item:e,index:t})),a=0,o=async()=>{for(;;){let e=i[a];if(a+=1,e===void 0)return;r[e.index]=await n(e.item,e.index)}},s=Array.from({length:Math.max(1,Math.min(t,e.length))},()=>o());return await Promise.all(s),r}function We(e,t,n){return e.map(e=>e.photoIndex===t?{...e,...n}:e)}function Ge(e,t){return`${e}:${t}`}function Ke(e,t,n,r){let i=Re(e[t]??{},n,r),a={...e};return Object.keys(i).length===0?delete a[t]:a[t]=i,a}function qe(e,t){let n=0;for(let r of e)r.analysis!==void 0&&(n+=ze(r.analysis.faces,t[r.photoIndex]??{}));return n}var Je=`__new__`;function Ye(e,t,n){let r=[];for(let i of e){if(i.analysis===void 0)continue;let e=t[i.photoIndex]??{};for(let t of i.analysis.faces){if(!t.enrollable||e[t.faceIndex]!==`__new__`)continue;let a=(n[Ge(i.photoIndex,t.faceIndex)]??``).trim();if(a===``)return{kind:`error`,message:`${i.filename}: face ${t.faceIndex+1} is set to a new person but has no name.`};r.includes(a)||r.push(a)}}return{kind:`ok`,names:r}}function Xe(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=Number(i),o={};for(let[r,i]of Object.entries(a)){let a=Number(r);if(i!==`__new__`){o[a]=i;continue}let s=n[(t[Ge(e,a)]??``).trim()];s!==void 0&&(o[a]=s)}r[e]=o}return r}function Ze(e,t){let n=[];for(let r of e){if(r.analysis===void 0)continue;let e=Be(r.analysis.sessionId,r.analysis.faces,t[r.photoIndex]??{});for(let t of e)n.push({photoIndex:r.photoIndex,request:t})}return n}function Qe(e){return/expired/i.test(e)}function $e(e){return e instanceof Error?e.message:String(e)}async function et(e,t,n){let r=new Map(e.map(e=>[e.photoIndex,e])),i={},a=[],o=0,s=null,c=(e,t)=>`${r.get(e)?.filename??`photo ${e+1}`}, face ${t+1}`;for(let l of Ze(e,t)){let e=i[l.photoIndex],t=e===void 0?l.request:{...l.request,sessionId:e.sessionId};try{let e=await n.enroll(t);o+=1,s=e.modelId}catch(t){let u=$e(t);if(!Qe(u)||e!==void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let d=r.get(l.photoIndex);if(d===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${u}`);continue}let f;try{f=await n.reanalyze(d)}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired and re-analysing failed (${$e(e)})`);continue}if(i[l.photoIndex]=f,f.faces.find(e=>e.faceIndex===l.request.faceIndex&&e.enrollable)===void 0){a.push(`${c(l.photoIndex,l.request.faceIndex)}: the analysis expired, and re-analysing no longer finds this face — assign it again from the fresh result`);continue}try{let e=await n.enroll({...l.request,sessionId:f.sessionId});o+=1,s=e.modelId}catch(e){a.push(`${c(l.photoIndex,l.request.faceIndex)}: ${$e(e)}`)}}}return{enrolled:o,stampedModelId:s,failures:a,refreshedAnalyses:i}}var tt=[[`faceGallery`]],nt=``;function rt(e){return new Promise((t,n)=>{let r=new FileReader;r.addEventListener(`error`,()=>n(Error(`the file could not be read`)),{once:!0}),r.addEventListener(`load`,()=>{let e=r.result;if(typeof e!=`string`){n(Error(`the file could not be read`));return}let i=e.indexOf(`,`);t(i>=0?e.slice(i+1):e)},{once:!0}),r.readAsDataURL(e)})}function it(e){return e instanceof Error?e.message:String(e)}function at({face:e,identities:t,value:n,onChange:o,disabled:s}){let l=i(()=>[{value:nt,label:`Ignore this face`},...t.map(e=>({value:e.id,label:e.name})),{value:Je,label:`+ New person…`}],[t]);return r(`div`,{className:`rounded-md border border-border bg-surface p-2`,children:[c(`div`,{className:`mb-2 aspect-square w-full overflow-hidden rounded border border-border bg-surface-hover`,children:e.alignedCropBase64?c(`img`,{src:`data:image/jpeg;base64,${e.alignedCropBase64}`,alt:`Face ${e.faceIndex+1}`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Te,{className:`h-8 w-8`})})}),e.enrollable?r(a,{children:[c(v,{options:l,value:n,disabled:s,onChange:e=>o(e.target.value),"aria-label":`Assign face ${e.faceIndex+1}`}),r(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:[Math.round(e.quality.detectionShortSidePx),` px`,e.modelId?` · ${e.modelId}`:``]})]}):r(`div`,{className:`space-y-1`,children:[c(h,{variant:`warning`,className:`text-[10px]`,children:`Not usable`}),c(`p`,{className:`text-[10px] leading-tight text-foreground-subtle`,children:Ve(e.refusedReason)})]})]})}function ot({photo:e,identities:t,draft:n,newNames:i,disabled:a,onAssign:o,onNameChange:s,onRetry:l}){let u=e.analysis?.faces??[],d=n[e.photoIndex]??{};return r(`div`,{className:`space-y-2`,children:[r(`div`,{className:`flex items-center gap-2 border-b border-border pb-1`,children:[c(`span`,{className:`truncate text-xs font-medium text-foreground`,children:e.filename}),e.status===`analyzing`||e.status===`queued`?r(`span`,{className:`flex items-center gap-1 text-xs text-foreground-subtle`,children:[c(J,{className:`h-3 w-3 animate-spin`}),` analysing…`]}):null,e.status===`analyzed`&&e.analysis!==void 0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[u.length,` face`,u.length===1?``:`s`,` · analysed on`,` `,e.analysis.ranOnNodeId]}),e.status===`failed`&&r(g,{variant:`secondary`,size:`sm`,disabled:a,onClick:l,children:[c(de,{className:`h-3 w-3`}),` Retry`]})]}),e.status===`failed`&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`This photo could not be analysed: `,e.error??`unknown error`,`. The other photos are unaffected.`]})]}),e.status===`analyzed`&&u.length===0&&c(`p`,{className:`text-xs text-foreground-subtle`,children:`No faces were found in this photo. A face has to be reasonably large and facing the camera for the detector to measure it.`}),u.length>0&&c(`div`,{className:`grid grid-cols-3 gap-3 sm:grid-cols-4 md:grid-cols-5`,children:u.map(e=>c(at,{face:e,identities:t,value:d[e.faceIndex]??nt,disabled:a,onChange:t=>o(e.faceIndex,t)},e.faceIndex))}),u.filter(e=>d[e.faceIndex]===Je).map(t=>r(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`w-28 shrink-0 truncate text-xs text-foreground-subtle`,children:[`Face `,t.faceIndex+1]}),c(`input`,{className:`h-7 flex-1 rounded-md border border-border bg-surface px-2.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,placeholder:`New person name… (type the same name under another face to reuse it)`,value:i[Ge(e.photoIndex,t.faceIndex)]??``,onChange:e=>s(t.faceIndex,e.target.value)})]},t.faceIndex))]})}function st({open:n,onOpenChange:a}){let l=u(),f=o(),h=t(null),{data:_}=A(),v=k(),[b,x]=s([]),[S,C]=s(!1),[w,T]=s(null),[D,O]=s({}),[j,M]=s({}),[N,P]=s(null),F=i(()=>(_??[]).map(e=>({id:e.id,name:e.name})),[_]),L=b.some(e=>e.status===`queued`||e.status===`analyzing`),R=L||S,z=e(e=>{for(let t of e){let e=t.analysis?.sessionId;e!==void 0&&l.trpcClient.addons.custom.mutate({addonId:Ee,action:ke,input:{sessionId:e}}).catch(()=>void 0)}},[l]),B=e(()=>{x([]),O({}),M({}),T(null),P(null),h.current&&(h.current.value=``)},[]),V=e(()=>{z(b),B(),a(!1)},[z,a,b,B]),H=e(async e=>{let t=Ie(await l.trpcClient.addons.custom.mutate({addonId:Ee,action:De,input:{photoBase64:e.photoBase64,filename:e.filename}}));if(t===null)throw Error(`the server replied with something this page could not read`);return t},[l]),U=e(async e=>{x(t=>We(t,e.photoIndex,{status:`analyzing`,error:void 0}));try{let t=await H(e);x(n=>We(n,e.photoIndex,{status:`analyzed`,analysis:t}))}catch(t){x(n=>We(n,e.photoIndex,{status:`failed`,error:it(t)}))}},[H]),ee=e(async e=>{if(e.length===0)return;z(b),B();let t=He(e,{maxCount:12,maxBytes:Ae}),n=[];t.oversize.length>0&&n.push(`Over the ${Math.round(Ae/(1024*1024))} MB limit and skipped: ${t.oversize.join(`, `)}.`),t.overflow.length>0&&n.push(`A batch holds at most 12 photos — not analysed: ${t.overflow.join(`, `)}. Enrol them in a second round.`),n.length>0&&T(n.join(` `));let r;try{r=await Promise.all(t.accepted.map(async(e,t)=>({photoIndex:t,filename:e.name,photoBase64:await rt(e),status:`queued`})))}catch(e){T(it(e));return}x(r),await Ue(r,2,e=>U(e))},[z,b,B,U]),W=qe(b,D),G=e(async()=>{C(!0),T(null),P(null);try{let e=Ye(b,D,j);if(e.kind===`error`){T(e.message);return}let t={};for(let n of e.names)t[n]=(await v.mutateAsync({name:n})).id;let n=await et(b,Xe(D,j,t),{enroll:async e=>{let t=Le(await l.trpcClient.addons.custom.mutate({addonId:Ee,action:Oe,input:e}));if(t===null)throw Error(`unreadable reply`);return t},reanalyze:e=>H(e)});Object.keys(n.refreshedAnalyses).length>0&&x(e=>e.map(e=>{let t=n.refreshedAnalyses[e.photoIndex];return t===void 0?e:{...e,status:`analyzed`,analysis:t}})),f.invalidateQueries({queryKey:tt}),n.failures.length>0&&T(n.failures.join(` · `)),P(n.enrolled===0?`Nothing was enrolled.`:`Enrolled ${n.enrolled} sample${n.enrolled===1?``:`s`}${n.stampedModelId===null?``:` with ${n.stampedModelId}`}.`)}catch(e){T(it(e))}finally{C(!1)}},[H,v,D,j,b,f,l]),te=b.filter(e=>e.status===`analyzed`).length;return c(I,{open:n,onOpenChange:e=>e?a(!0):V(),children:r(m,{className:`max-w-3xl`,children:[r(E,{children:[c(d,{children:`Enrol from photos`}),c(p,{children:`Every photo is analysed with the same face detector the cameras use, and all the faces found are reviewed below in one pass, grouped by photo. Assign each face to a person, or leave it ignored.`})]}),r(`div`,{className:`rounded-md border border-border bg-surface-hover px-3 py-2 text-xs text-foreground-subtle`,children:[`For reliable recognition use `,c(`strong`,{children:`at least 3 photos per person`}),`, taken at different times, with different poses and lighting — you can select them all at once. Several frames from the same moment count as one — they do not add information.`]}),r(`div`,{className:`flex items-center gap-2`,children:[c(`input`,{ref:h,type:`file`,accept:`image/jpeg,image/png,image/webp`,multiple:!0,className:`hidden`,onChange:e=>void ee(Array.from(e.target.files??[]))}),r(g,{variant:`secondary`,size:`sm`,disabled:R,onClick:()=>h.current?.click(),children:[L?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(we,{className:`h-3.5 w-3.5`}),`Choose photos`]}),b.length>0&&r(`span`,{className:`text-xs text-foreground-subtle`,children:[te,`/`,b.length,` photo`,b.length===1?``:`s`,` analysed`]})]}),w!==null&&r(`div`,{className:`flex items-start gap-2 rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[c(ve,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),c(`span`,{children:w})]}),N!==null&&c(`div`,{className:`rounded-md border border-success/40 bg-success/10 px-3 py-2 text-xs text-success`,children:N}),b.length>0&&c(`div`,{className:`max-h-[50vh] space-y-4 overflow-y-auto pr-1`,children:b.map(e=>c(ot,{photo:e,identities:F,draft:D,newNames:j,disabled:R,onAssign:(t,n)=>O(r=>Ke(r,e.photoIndex,t,n===nt?null:n)),onNameChange:(t,n)=>M(r=>({...r,[Ge(e.photoIndex,t)]:n})),onRetry:()=>void U(e)},e.photoIndex))}),r(y,{children:[c(g,{variant:`secondary`,onClick:V,disabled:S,children:`Close`}),r(g,{variant:`primary`,onClick:()=>void G(),disabled:R||W===0,children:[S?c(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Enrol `,W,` face`,W===1?``:`s`]})]})]})})}n();var ct=[[`faceGallery`]];function lt({identityId:e}){let t=o(),{data:n,isLoading:i}=N({identityId:e}),a=D();function s(n){a.mutate({identityId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:ct})}})}return i?r(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading samples…`]}):!n||n.length===0?c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No samples yet.`}):c(`div`,{className:`mt-2 grid grid-cols-4 gap-2 sm:grid-cols-6 md:grid-cols-8`,children:n.map(e=>r(`div`,{className:`group relative aspect-square overflow-hidden rounded-md border border-border bg-surface`,children:[e.base64?c(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Sample`,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:c(Te,{className:`h-6 w-6`})}),e.source===`photo`&&c(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 p-0.5 text-white`,title:`Enrolled from an uploaded photo`,children:c(we,{className:`h-3 w-3`})}),c(`button`,{type:`button`,onClick:()=>s(e),disabled:a.isPending,className:`absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 transition-opacity group-hover:opacity-100 disabled:cursor-not-allowed`,"aria-label":`Remove sample`,children:c(Z,{className:`h-4 w-4 text-white`})})]},e.id))})}function ut({identity:e,expanded:t,onToggle:n}){let i=o(),[l,u]=s(``),[f,_]=s(!1),[v,x]=s(!1),S=F(),C=T();function w(){u(e.name),_(!0)}function D(){_(!1),u(``)}function O(){let t=l.trim();if(!t||t===e.name){D();return}S.mutate({id:e.id,name:t},{onSettled:()=>{i.invalidateQueries({queryKey:ct}),D()}})}function k(){C.mutate({id:e.id},{onSettled:()=>{i.invalidateQueries({queryKey:ct}),x(!1)}})}return r(`div`,{className:`rounded-md border border-border bg-surface`,children:[r(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[c(`div`,{className:`h-8 w-8 shrink-0 overflow-hidden rounded-full border border-border bg-surface-hover`,children:e.coverBase64?c(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):c(`div`,{className:`flex h-full w-full items-center justify-center`,children:c(Te,{className:`h-4 w-4 text-foreground-subtle`})})}),c(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:f?r(a,{children:[c(b,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O(),e.key===`Escape`&&D()},className:`h-6 text-xs`,autoFocus:!0}),c(`button`,{type:`button`,onClick:O,disabled:S.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:c(be,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:D,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:c(Z,{className:`h-3.5 w-3.5`})})]}):c(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),c(h,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!f&&r(`div`,{className:`flex items-center gap-1`,children:[c(`button`,{type:`button`,onClick:w,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:c(ce,{className:`h-3.5 w-3.5`})}),c(`button`,{type:`button`,onClick:()=>x(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:c(ye,{className:`h-3.5 w-3.5`})})]}),c(`button`,{type:`button`,onClick:n,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":t?`Collapse`:`Expand`,children:c(t?he:Y,{className:`h-3.5 w-3.5`})})]}),t&&c(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:c(lt,{identityId:e.id})}),c(I,{open:v,onOpenChange:e=>!e&&x(!1),children:r(m,{children:[r(E,{children:[c(d,{children:`Delete person`}),r(p,{children:[`Delete `,c(`strong`,{children:e.name}),` and all their samples? This cannot be undone.`]})]}),r(y,{children:[c(g,{variant:`secondary`,onClick:()=>x(!1),children:`Cancel`}),r(g,{variant:`danger`,onClick:k,disabled:C.isPending,children:[C.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function dt(){let e=o(),[t,n]=s(``),i=k();function a(){let r=t.trim();r&&i.mutate({name:r},{onSettled:()=>{e.invalidateQueries({queryKey:ct}),n(``)}})}return r(`div`,{className:`flex items-center gap-2 pt-2`,children:[c(b,{placeholder:`New person name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&a()},className:`h-7 text-xs flex-1`}),r(g,{variant:`primary`,size:`sm`,onClick:a,disabled:i.isPending||!t.trim(),children:[i.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(le,{className:`h-3.5 w-3.5`}),`Add`]})]})}function ft(){let{data:e,isLoading:t}=A(),[n,i]=s(null),[a,o]=s(!1);function l(e){i(t=>t===e?null:e)}return t?r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),`Loading people…`]}):r(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&c(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No people enrolled yet. Add one below.`}),e?.map(e=>c(ut,{identity:e,expanded:n===e.id,onToggle:()=>l(e.id)},e.id)),c(dt,{}),c(`div`,{className:`pt-1`,children:r(g,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:[c(we,{className:`h-3.5 w-3.5`}),`Enrol from a photo`]})}),c(st,{open:a,onOpenChange:o})]})}function pt(e){let t=e.cropUrl!==void 0&&e.cropUrl.length>0,n=e.base64!==void 0&&e.base64.length>0;return!t&&!n}function mt(e){return e.filter(pt).map(e=>e.faceId)}function ht(e){let t=0;for(let n of e)pt(n)&&(t+=1);return t}function gt(e){return e==null?null:e.cropUrl!==void 0&&e.cropUrl.length>0?e.cropUrl:e.base64!==void 0&&e.base64.length>0?`data:image/jpeg;base64,${e.base64}`:null}n();var _t=[[`faceGallery`]];function vt({faceIds:e,identities:t,onDone:n}){let i=o(),a=P(),l=k(),[u,f]=s(``),[h,_]=s(!1),[v,x]=s(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){_(!1),f(``),x(null)}function T(){w(),n()}function D(t){!e||e.length===0||a.mutate({faceIds:[...e],identityId:t},{onSettled:()=>{i.invalidateQueries({queryKey:_t}),T()}})}function O(){!e||!u.trim()||l.mutate({name:u.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{i.invalidateQueries({queryKey:_t}),T()}})}let A=a.isPending||l.isPending;return c(I,{open:S,onOpenChange:e=>!e&&T(),children:r(m,{children:[r(E,{children:[c(d,{children:C>1?`Assign ${String(C)} faces to person`:`Assign face to person`}),c(p,{children:`Select an existing person or create a new one.`})]}),c(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:t.map(e=>r(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${v===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[c(`span`,{className:`font-medium`,children:e.name}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` samples`]})]},e.id))}),h?c(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:c(b,{placeholder:`New person name…`,value:u,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):c(`button`,{type:`button`,onClick:()=>{x(null),_(!0)},className:`mt-2 w-full rounded-md border border-dashed border-border px-3 py-2 text-left text-xs text-foreground-subtle hover:border-primary hover:text-primary transition-colors`,children:`+ New person…`}),r(y,{children:[c(g,{variant:`secondary`,onClick:T,disabled:A,children:`Cancel`}),h?r(g,{variant:`primary`,onClick:O,disabled:A||!u.trim(),children:[A&&c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):r(g,{variant:`primary`,onClick:()=>v&&D(v),disabled:A||!v,children:[A&&c(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}n();function yt(e){let[t,n]=s(null),[r,i]=s(null),[a,o]=s(!1);return l(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await Se(`${Ce}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),l(()=>{if(!t)return;let e=new Image;return e.onload=()=>i({width:e.naturalWidth,height:e.naturalHeight}),e.onerror=()=>o(!0),e.src=t,()=>{e.onload=null,e.onerror=null}},[t]),{frameSrc:t,naturalWidth:r?.width??null,naturalHeight:r?.height??null,failed:a}}function bt(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|face/i.test(e.kind))??t[0]}function xt({label:e,value:t}){return r(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[c(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),c(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground`,children:t})]})}function St({box:e}){return c(`div`,{className:`pointer-events-none absolute rounded-[3px] border-2 border-primary shadow-[0_0_0_9999px_rgba(0,0,0,0.28)]`,style:{left:`${String(e.x*100)}%`,top:`${String(e.y*100)}%`,width:`${String(e.width*100)}%`,height:`${String(e.height*100)}%`},children:c(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Face`})})}function Ct({face:e,cameraName:t,onClose:n,onAssign:a,onUnassign:o,onDelete:l,actionsPending:u}){let{data:d,isFetching:f}=x({faceId:e?.faceId??``},{enabled:e!==null}),[p,h]=s(`frame`),{frameSrc:_,naturalWidth:v,naturalHeight:y,failed:b}=yt(e?.keyFrameMediaKey),S=i(()=>{let t=bt(d??[]);return t?`data:image/jpeg;base64,${t.base64}`:gt(e)},[d,e]),C=i(()=>!e?.faceBbox||v===null||y===null?null:H(e.faceBbox,v,y),[e?.faceBbox,v,y]);if(e===null)return null;let w=typeof e.keyFrameMediaKey==`string`&&e.keyFrameMediaKey.length>0&&!b,T=w&&p===`frame`,E=e.assigned?e.identityName??`Assigned`:e.recognizedIdentityId?`${e.identityName??`Recognized`} (suggested)`:`Unassigned`;return c(I,{open:!0,onOpenChange:e=>!e&&n(),children:r(m,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Face detail`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 bottom-0 left-0 right-0 top-auto w-full max-w-full translate-x-0 translate-y-0 rounded-b-none md:bottom-auto md:left-1/2 md:right-auto md:top-1/2 md:w-[calc(100vw-2rem)] md:max-w-xl md:-translate-x-1/2 md:-translate-y-1/2 md:rounded-lg md:max-h-[calc(100dvh-2rem)]`,children:[r(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`min-w-0`,children:[c(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:`Face detail`}),c(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:t})]}),c(`button`,{type:`button`,onClick:n,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(Z,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[w&&r(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[r(`button`,{type:`button`,onClick:()=>h(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(z,{className:`h-3.5 w-3.5`}),` Full frame`]}),r(`button`,{type:`button`,onClick:()=>h(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${p===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(R,{className:`h-3.5 w-3.5`}),` Crop`]})]}),T&&_?c(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:c(K,{src:_,alt:`Full frame with detected face`,fit:`natural`,className:`w-full`,overlay:C?c(St,{box:C}):void 0})}):S?r(`div`,{className:`relative aspect-square w-full overflow-hidden rounded-lg border border-border`,children:[c(K,{src:S,alt:`Detected face`,className:`h-full w-full`}),f&&c(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:c(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):r(`div`,{className:`flex aspect-square w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[c(ne,{className:`h-8 w-8 text-warning/70`}),c(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),c(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this face could not be resolved (a pre-fix orphan). Safe to delete.`})]}),r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[c(xt,{label:`Camera`,value:t}),c(xt,{label:`Captured`,value:q(e.timestamp)}),c(xt,{label:`Track`,value:e.trackId}),c(xt,{label:`Identity`,value:E})]})]}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[e.assigned?r(g,{variant:`secondary`,onClick:()=>o(e.faceId),disabled:u,children:[c(B,{className:`h-3.5 w-3.5`}),` Detach`]}):r(g,{variant:`primary`,onClick:()=>a(e.faceId),disabled:u,children:[c(V,{className:`h-3.5 w-3.5`}),` Assign`]}),r(g,{variant:`secondary`,onClick:()=>l(e.faceId),disabled:u,children:[c(ye,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}function wt(e,t){let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),n}function Tt(e,t){return e.faceIds.filter(e=>!t.has(e))}function Et(e,t){return e.faceIds.filter(e=>t(e))}n();var Dt=[[`faceGallery`]],Ot=20,kt=.3,At=.9,jt=.05,Mt=.5,Nt=2,Pt=10,Ft=2;function It({cluster:e,face:t,active:n,onSelect:i}){let a=gt(t);return r(`button`,{type:`button`,onClick:i,className:`flex shrink-0 flex-col items-center gap-1.5 rounded-md border p-2 text-center transition-colors md:w-full md:flex-row md:gap-2.5 md:text-left ${n?`border-primary bg-primary/8`:`border-border bg-surface hover:bg-surface-hover`}`,children:[c(`div`,{className:`h-24 w-24 shrink-0 overflow-hidden rounded bg-surface-hover`,children:a===null?c(ne,{className:`h-24 w-24 p-6 text-foreground-subtle`}):c(`img`,{src:a,alt:``,loading:`lazy`,decoding:`async`,className:`h-24 w-24 object-cover`})}),r(`span`,{className:`w-24 text-[11px] leading-tight text-foreground-subtle md:w-auto`,children:[e.size,` faces · `,Math.round(e.cohesion*100),`% alike`]})]})}function Lt({face:e,cameraName:t,nowMs:n,excluded:i,onToggleExclude:a,onDelete:o,deletePending:s}){let l=gt(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden transition-opacity ${i?`border-border opacity-40 grayscale`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[l===null?r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,children:[c(ne,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(K,{src:l,alt:`Face from ${t}`,className:`h-full w-full`}),c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),a()},className:`absolute right-1 top-1 z-10 rounded-full bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Include face`:`Exclude face`,title:i?`Include`:`Exclude`,children:c(i?me:Z,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:W(e.timestamp,n)})]}),c(`div`,{className:`mt-1 flex items-center justify-end border-t border-border/60 px-1 py-0.5`,children:c(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),o()},disabled:s,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:s?c(J,{className:`h-4 w-4 animate-spin`}):c(ye,{className:`h-4 w-4`})})})]})}function Rt({open:e,onClose:t,byId:n,cameraName:u,nowMs:d,identities:f,selectMany:p}){let h=o(),_=O(),v=M(),[y,b]=s(Mt),[x,S]=s(Ft),[w,T]=s(null),[E,D]=s({}),[k,A]=s(null),{data:j,isFetching:N,refetch:P}=C({threshold:y,minClusterSize:x,limit:Ot},{enabled:e}),F=j??[];l(()=>{D({})},[y,x]),l(()=>{if(F.length===0){T(null);return}F.some(e=>e.representativeFaceId===w)||T(F[0]?.representativeFaceId??null)},[F]);let L=i(()=>F.find(e=>e.representativeFaceId===w)??null,[F,w]),R=L?E[L.representativeFaceId]??new Set:new Set,z=i(()=>L?Et(L,e=>n.has(e)):[],[L,n]),B=L?L.faceIds.length-z.length:0,H=L?Tt({...L,faceIds:z},R):[];function U(e){if(!L)return;let t=L.representativeFaceId;D(n=>({...n,[t]:wt(n[t]??new Set,e)}))}function ee(){h.invalidateQueries({queryKey:Dt})}async function W(e){await _({title:`Delete face`,message:`Permanently deletes this face crop. This cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&v.mutate({faceId:e},{onSettled:ee})}function G(){A(null),t()}function te(){H.length!==0&&(p(H),G())}return r(I,{open:e,onOpenChange:e=>!e&&G(),children:[r(m,{placement:`sheet-on-mobile`,width:`lg`,"aria-label":`Look-alike groups`,className:`flex max-h-[92dvh] flex-col gap-0 overflow-hidden p-0 md:max-w-4xl`,children:[r(`header`,{className:`flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-2`,children:[r(`div`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[c(_e,{className:`h-4 w-4 text-primary`}),` Look-alike groups`]}),c(`button`,{type:`button`,onClick:G,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:c(Z,{className:`h-4 w-4`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Threshold`,c(`input`,{type:`range`,min:kt,max:At,step:jt,value:y,onChange:e=>b(Number(e.target.value)),className:`h-1.5 w-28 cursor-pointer accent-primary`}),c(`span`,{className:`w-8 shrink-0 text-right font-mono text-[11px] tabular-nums text-foreground`,children:y.toFixed(2)})]}),r(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Min size`,c(`input`,{type:`number`,min:Nt,max:Pt,step:1,value:x,onChange:e=>S(Math.min(Pt,Math.max(Nt,Number(e.target.value)||Nt))),className:`w-12 rounded border border-border bg-background px-1.5 py-0.5 text-xs text-foreground`})]}),r(g,{variant:`secondary`,onClick:()=>{D({}),P()},disabled:N,children:[N?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(ue,{className:`h-3.5 w-3.5`}),`Re-analyze`]})]})]}),c(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-hidden px-4 py-3 md:flex-row`,children:N&&F.length===0?r(`div`,{className:`flex flex-1 items-center justify-center gap-2 py-8 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),` Finding similar faces…`]}):F.length===0?c(`div`,{className:`flex flex-1 items-center justify-center py-8 text-xs text-foreground-subtle`,children:`No look-alike groups at this threshold.`}):r(a,{children:[c(`div`,{className:`flex gap-2 overflow-x-auto pb-1 md:hidden`,children:F.map(e=>c(It,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===w,onSelect:()=>T(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`hidden shrink-0 flex-col gap-2 overflow-y-auto md:flex md:w-56`,children:F.map(e=>c(It,{cluster:e,face:n.get(e.representativeFaceId),active:e.representativeFaceId===w,onSelect:()=>T(e.representativeFaceId)},e.representativeFaceId))}),c(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:L&&r(a,{children:[B>0&&r(`p`,{className:`mb-2 text-[11px] text-foreground-subtle`,children:[B,` not loaded — excluded from actions`]}),c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-2`,children:z.map(e=>{let t=n.get(e);return t?c(Lt,{face:t,cameraName:u(t.deviceId),nowMs:d,excluded:R.has(e),onToggleExclude:()=>U(e),onDelete:()=>void W(e),deletePending:v.isPending&&v.variables?.faceId===e},e):null})})]})})]})}),r(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3 pb-[max(0.75rem,env(safe-area-inset-bottom))]`,children:[c(g,{variant:`secondary`,onClick:te,disabled:H.length===0,children:`Select in gallery`}),r(g,{variant:`primary`,onClick:()=>A(H),disabled:H.length===0,children:[c(V,{className:`h-3.5 w-3.5`}),` Adopt (`,H.length,`)`]})]})]}),c(vt,{faceIds:k,identities:f,onDone:()=>A(null)})]})}n();var zt=[[`faceGallery`]],Bt=500,Vt=120;function Ht({face:e,cameraName:t,nowMs:n,selected:i,onToggleSelect:a,onAssign:s,onOpenDetail:l}){let u=o(),d=w(),f=M(),p=()=>{u.invalidateQueries({queryKey:zt})},m=()=>l(e.faceId),h=gt(e);return r(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[r(`div`,{className:`aspect-square relative overflow-hidden bg-surface-hover`,children:[h===null?r(`button`,{type:`button`,onClick:m,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-warning/5 text-foreground-subtle`,title:`No crop image — the face's crop media is missing (a pre-fix orphan). Safe to delete.`,children:[c(ne,{className:`h-7 w-7 text-warning/70`}),c(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}):c(`img`,{src:h,alt:`Face from ${t}`,onClick:m,loading:`lazy`,decoding:`async`,className:`h-full w-full cursor-zoom-in object-cover`}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.faceId)},className:`absolute left-0 top-0 z-10 rounded-br-md bg-black/50 p-1.5 text-white hover:bg-black/70`,"aria-label":i?`Deselect`:`Select`,children:i?c(fe,{className:`h-4 w-4 text-primary`}):c(pe,{className:`h-4 w-4`})})]}),r(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[c(`p`,{className:`text-[10px] font-medium text-foreground truncate`,title:t,children:t}),c(`p`,{className:`text-[10px] text-foreground-subtle truncate`,children:W(e.timestamp,n)}),e.identityName&&c(`p`,{className:`text-[10px] font-medium text-primary truncate`,title:e.identityName,children:e.identityName})]}),r(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),d.mutate({faceId:e.faceId},{onSettled:p})},disabled:d.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach face`,title:`Detach`,children:d.isPending?c(J,{className:`h-4 w-4 animate-spin`}):c(B,{className:`h-4 w-4`})}):c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(e.faceId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign face to person`,title:`Assign to person`,children:c(V,{className:`h-4 w-4`})}),c(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),f.mutate({faceId:e.faceId},{onSettled:p})},disabled:f.isPending,className:`ml-auto rounded p-1.5 text-foreground-subtle transition-colors hover:bg-danger/10 hover:text-danger disabled:opacity-40`,"aria-label":`Delete face`,title:`Delete face`,children:f.isPending?c(J,{className:`h-4 w-4 animate-spin`}):c(ye,{className:`h-4 w-4`})})]})]})}var Ut=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Recognized`,value:`recognized`}];function Wt(){let e=o(),[t,n]=s(`all`),[l,u]=s(ae),[d,p]=s(new Set),[m,h]=s(new Set),[_,v]=s(null),[y,b]=s(!1),[x,C]=s(null),{data:T,isLoading:E}=S({limit:Bt,filter:t,includeCrops:!1},{refetchInterval:3e4}),{data:D=[]}=A(),{data:O}=f({}),k=P(),N=w(),F=j(),I=M(),L=Date.now(),R=T??[],z=i(()=>{let e=new Map;for(let t of O??[])e.set(t.id,t.name);return e},[O]),H=e=>z.get(e)??`Camera #${String(e)}`,W=i(()=>ee(R).map(e=>({id:e,name:H(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[R,z]),K=i(()=>te(se(R,l),d),[R,l,d]),q=re(K,Vt,i(()=>JSON.stringify([t,l.fromMs,l.toMs,[...d].sort((e,t)=>e-t)]),[t,l.fromMs,l.toMs,d])),oe=i(()=>new Map(R.map(e=>[e.faceId,e])),[R]),ce=i(()=>ht(K),[K]),le=x===null?null:oe.get(x)??null,ue=()=>{e.invalidateQueries({queryKey:zt})},de=()=>h(new Set);function fe(e){h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function pe(e){h(t=>{let n=new Set(t);for(let t of e)n.add(t);return n})}function me(){pe(mt(K))}let Y=[...m],X=k.isPending||F.isPending||I.isPending,he=N.isPending||I.isPending;function ge(){Y.length!==0&&F.mutate({faceIds:Y},{onSettled:()=>{ue(),de()}})}function ve(){Y.length!==0&&Promise.allSettled(Y.map(e=>I.mutateAsync({faceId:e}))).then(()=>{ue(),de()})}function be(e){C(null),v([e])}function xe(e){N.mutate({faceId:e},{onSettled:ue}),C(null)}function Se(e){I.mutate({faceId:e},{onSettled:ue}),C(null)}let Ce=K.length!==R.length;return r(`div`,{className:`relative space-y-3`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c(`div`,{className:`flex items-center gap-1`,children:Ut.map(e=>c(`button`,{type:`button`,onClick:()=>n(e.value),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${t===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.label},e.value))}),c(ie,{onChange:u}),c(G,{cameras:W,selected:d,onChange:p}),r(`button`,{type:`button`,onClick:()=>b(!0),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${y?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[c(_e,{className:`h-3.5 w-3.5`}),` Similar groups`]}),!E&&ce>0&&r(`button`,{type:`button`,onClick:me,className:`ml-auto flex items-center gap-1 rounded-md px-2.5 py-1 text-xs text-warning/90 transition-colors hover:bg-warning/10`,title:`Select every visible face whose crop image is missing so you can delete the orphans in one pass`,children:[c(ne,{className:`h-3.5 w-3.5`}),` Select `,ce,` crop-less`]}),!E&&c(`span`,{className:`text-[10px] text-foreground-subtle ${ce>0?`ml-2`:`ml-auto`}`,children:Ce?`${String(K.length)} of ${String(R.length)} faces`:`${String(K.length)} face${K.length===1?``:`s`}`})]}),m.size>0&&r(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:[m.size,` selected`]}),r(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[r(g,{variant:`primary`,onClick:()=>v(Y),disabled:X,children:[c(V,{className:`h-3.5 w-3.5`}),` Assign`]}),r(g,{variant:`secondary`,onClick:ge,disabled:X,children:[F.isPending?c(J,{className:`h-3.5 w-3.5 animate-spin`}):c(B,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),r(g,{variant:`secondary`,onClick:ve,disabled:X,children:[c(ye,{className:`h-3.5 w-3.5`}),` Delete`]}),c(g,{variant:`ghost`,onClick:de,disabled:X,children:c(Z,{className:`h-3.5 w-3.5`})})]})]}),E&&r(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[c(J,{className:`h-4 w-4 animate-spin`}),` Loading faces…`]}),!E&&K.length===0&&c(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:R.length>0?`No faces match the current date / camera filters.`:`No faces found for this filter.`}),!E&&K.length>0&&r(a,{children:[c(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(6.5rem,1fr))] gap-2`,children:q.pageItems.map(e=>c(Ht,{face:e,cameraName:H(e.deviceId),nowMs:L,selected:m.has(e.faceId),onToggleSelect:fe,onAssign:e=>v([e]),onOpenDetail:C},e.faceId))}),c(U,{currentPage:q.page,totalItems:q.totalItems,pageSize:q.pageSize,onPageChange:q.setPage,itemNoun:`faces`})]}),c(Ct,{face:le,cameraName:le?H(le.deviceId):``,onClose:()=>C(null),onAssign:be,onUnassign:xe,onDelete:Se,actionsPending:he}),c(vt,{faceIds:_,identities:D,onDone:()=>{v(null),de()}}),c(Rt,{open:y,onClose:()=>b(!1),byId:oe,cameraName:H,nowMs:L,identities:D,selectMany:pe})]})}n();var Gt=[[`faceGallery`]],Kt=2e3;function qt(){let e=o(),n=t(e);n.current=e;let r=t(void 0);r.current||=oe({delayMs:Kt,invalidate:()=>{n.current.invalidateQueries({queryKey:Gt})}}),l(()=>()=>r.current?.cancel(),[]),_(L.PipelineAnalyticsFaceGalleryChanged,()=>{r.current?.trigger()})}function Jt(){return qt(),c(xe,{icon:ge,title:`Faces`,subtitle:`Manage enrolled identities and assign detected face crops to people.`,children:r(`section`,{className:`space-y-3`,children:[r(`div`,{children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`People`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled identities used for face recognition. Expand a row to view or remove training samples.`}),c(ft,{})]}),r(`div`,{className:`pt-4 border-t border-border`,children:[c(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent detected faces`}),c(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Face crops captured by the detection pipeline. Assign them to a person to build recognition training data.`}),c(Wt,{})]})]})})}export{Jt as DetectionIntelligencePage};
|
package/dist/assets/{DeviceAggregateSection-DLNzCtMs.js → DeviceAggregateSection-aUgWgamW.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,o as a,q as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$r as c,Ir as l,Jo as u,Kr as d,Lr as f,ei as p,qo as m}from"./src-
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,o as a,q as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$r as c,Ir as l,Jo as u,Kr as d,Lr as f,ei as p,qo as m}from"./src-BmCjCFGO.js";import{jt as h}from"./src-D8hsVOc6.js";import{t as g}from"./FormBuilder-CgtfU1VA.js";import{C as _,r as v}from"./index-CoX6Kh_l.js";import{n as y,r as b,t as x}from"./SchemaTabBar-DC28nb9j.js";import{t as S}from"./StableTabPanel-Dc954AQl.js";n();function C({schema:e,values:t,pendingKeys:n,onChange:a,onAction:c,onSave:l,onDiscard:u,disabled:d,activeSubTab:f,onSubTabChange:p,flattenTabs:m=!1,deviceId:h}){let _=e.tabs??[],v=i(()=>{let t=new Map;for(let n of e.sections){let e=n.tab??`general`,r=t.get(e)??[];r.push(n),t.set(e,r)}return t},[e.sections]),b=new Set(_.map(e=>e.id)),C=[..._,...[...v.keys()].filter(e=>!b.has(e)).map(e=>({id:e,label:e,icon:`wrench`,order:100}))],w=C[0]?.id??`general`,[T,E]=o(w),D=p!==void 0,O=new Set(C.map(e=>e.id)),k=D?f&&O.has(f)?f:w:O.has(T)?T:w,A=e=>{D?p(e):E(e)},j=v.get(k)??[],M={sections:j.length<=1?j.length===1?[{...j[0],title:``}]:j:j.every(e=>!e.title)?[{...j[0],title:``,fields:j.flatMap(e=>e.fields)}]:j},N=s(y,{pendingCount:n.length,onSave:()=>l(n),onDiscard:()=>u(n),saving:d});if(m||C.length<=1)return r(`div`,{className:`flex flex-col gap-3`,children:[s(g,{schema:e,values:t,onChange:a,onAction:c,disabled:d,deviceId:h}),N]});let P=new Map,F=new Map;for(let[e,t]of v){P.set(e,t.length);let r=new Set,i=e=>{for(let t of e)if(`key`in t&&typeof t.key==`string`&&r.add(t.key),t.type===`group`)i(t.fields);else if(t.type===`sub-tabs`)for(let e of t.tabs)i(e.fields)};for(let e of t)i(e.fields);let a=n.filter(e=>r.has(e)).length;a>0&&F.set(e,a)}return r(`div`,{className:`flex flex-col gap-3`,children:[s(x,{tabs:C.map(e=>({id:e.id,label:e.label})),activeId:k,onChange:A,countByTab:P,pendingByTab:F}),s(S,{tabKey:k,children:s(g,{schema:M,values:t,onChange:a,onAction:c,disabled:d,deviceId:h})}),N]})}var w=`device-export`,T=`export`,E=`Export`;function D(e){return e.type===`separator`||e.type===`info`||e.type===`object-array`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`?!1:e.type===`group`?e.fields.some(D):e.type===`sub-tabs`?e.tabs.some(e=>e.fields.some(D)):e.writerCapName===w}function O(e){return e.tab===`export`?!0:e.fields.some(D)}n();function k(e,t){return t&&t===`admin`?e:!0}function A(e){if(!e)return null;let t={sections:[...e.sections].toSorted((e,t)=>{let n=e.tab??`general`,r=t.tab??`general`;return n===r?O(e)&&O(t)?e.id.localeCompare(t.id):(e.order??0)-(t.order??0):n.localeCompare(r)})};return e.tabs?{...t,tabs:e.tabs}:t}function j(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`widget`||e.type===`addon-action-button`||e.type===`device-action-button`}function M(e){return e.key}function N(e){if(!j(e))return e.value}function P(e){return j(e)?null:e}function F(e,t){for(let n of e)if(t(n),n.type===`group`)F(n.fields,t);else if(n.type===`sub-tabs`)for(let e of n.tabs)F(e.fields,t)}function I(e){if(!e)return{};let t={};for(let n of e.sections)F(n.fields,e=>{let n=M(e);n!==null&&(t[n]=N(e))});return t}function L(e,t){if(!e)return null;let n=null;for(let r of e.sections)if(F(r.fields,e=>{if(n!==null||M(e)!==t)return;let r=P(e);r&&r.writerCapName&&r.writerAddonId&&(n={capName:r.writerCapName,addonId:r.writerAddonId})}),n!==null)break;return n}function R(e){return{...e,fields:e.fields.map(z)}}function z(e){return e.type===`separator`||e.type===`info`||e.type===`button`||e.type===`object-array`?e:{...e,readonlyField:!0}}function B(e,t){return e&&{...e,sections:e.sections.map(e=>({...e,fields:e.fields.map(e=>{let n=P(e);return n?k(t,n.minRole)?e:z(e):e})}))}}function V({deviceId:n,sectionFilter:o,activeSubTab:g,onSubTabChange:y,flattenSubTabs:x,subTabGrouping:S}){let w=a(),{user:T}=v(),E=T?.isAdmin===!0,D=t(!1),{data:k,isLoading:j}=f({deviceId:n},{refetchInterval:()=>D.current?!1:2500,enabled:Number.isFinite(n)}),{data:M}=l({deviceId:n},{enabled:Number.isFinite(n)}),N=k?.settings??null,P=k?.live??null,F=i(()=>{if(!N&&!P)return null;let e=N?.sections??[],t=(P?.sections??[]).map(R),n=[...e,...t],r=o?n.filter(o):n.filter(e=>e.location!==`top-tab`&&!O(e));if(r.length===0)return null;if(S){let e=r.map(e=>({...e,tab:S.groupOf(e)})),t=new Set(e.map(e=>e.tab)),n=S.tabs.filter(e=>t.has(e.id));return n.length>0?{tabs:n,sections:e}:{sections:e}}let i=new Set;for(let e of r)i.add(e.tab??`general`);let a=[...N?.tabs??[],...(P?.tabs??[]).filter(e=>!(N?.tabs??[]).some(t=>t.id===e.id))].filter(e=>i.has(e.id));return a.length>0?{tabs:a,sections:r}:{sections:r}},[N,P,o,S]),z=i(()=>A(F),[F]),V=i(()=>B(z,E),[z,E]),H=i(()=>I(V),[V]),U=u(),W=m(),G=c(),K=d(),q=p({onSuccess:()=>{w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),J={isPending:q.isPending,mutate:e=>{q.mutate({deviceId:n,changes:[...e]})}},Y=b({schema:V,serverValues:H,onImmediateSave:e(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J]),onDeferredSave:e(e=>{let t=Object.entries(e).map(([e,t])=>{let n=L(V,e);return n?{writerCapName:n.capName,writerAddonId:n.addonId,key:e,value:t}:null}).filter(e=>e!==null);t.length>0&&J.mutate(t)},[V,J])}),{values:X,pendingKeys:Z,handleChange:Q,handleSave:$,handleDiscard:ee}=Y;if(D.current=Y.editingPaused,j)return r(`div`,{className:`flex items-center justify-center py-12 text-foreground-subtle`,children:[s(_,{className:`h-4 w-4 animate-spin mr-2`}),s(`span`,{className:`text-xs`,children:`Loading device aggregate…`})]});if(!V||V.sections.length===0)return s(`div`,{className:`text-xs text-foreground-subtle italic py-4 text-center`,children:`No aggregate contributions for this device.`});async function te(e,t,r){if(e===`regenerate-rtsp-token`){let e=[`rtspUrl:`,`regenerateToken:`].find(e=>t.startsWith(e));if(!e)throw Error(`regenerate-rtsp-token: unrecognised key "${t}" (expected "rtspUrl:<streamId>" or "regenerateToken:<streamId>")`);let r=t.slice(e.length);if(!r)throw Error(`regenerate-rtsp-token: key "${t}" has no streamId after prefix`);let i=h(n,r);await U.mutateAsync({brokerId:i}),w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]});return}if(e===`test-probe`){if(!M)return{status:`error`,error:`Device metadata not loaded yet`};try{return await G.mutateAsync({addonId:M.addonId,type:M.type,key:t,value:r})}catch(e){return{status:`error`,error:e instanceof Error?e.message:String(e)}}}if(e===`refresh-probe`){if(!t.startsWith(`probedInfo:`))throw Error(`refresh-probe: unrecognised key "${t}" (expected "probedInfo:<streamId>")`);let e=t.slice(11);if(!e)throw Error(`refresh-probe: key "${t}" has no streamId after prefix`);let r=h(n,e),i=await W.mutateAsync({brokerId:r});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),i}if(e===`device-custom-action`){let e=await K.mutateAsync({deviceId:n,action:t,input:r});return w.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),e}throw Error(`[device-aggregate] unknown action "${e}"`)}return s(C,{schema:V,values:X,pendingKeys:Z,onChange:Q,onAction:te,onSave:$,onDiscard:ee,disabled:J.isPending,activeSubTab:g,onSubTabChange:y,flattenTabs:x,deviceId:n})}export{O as i,T as n,E as r,V as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,a,b as o,o as s,q as c,t as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{K as f,W as p,Z as m,o as h,r as g,t as _,v}from"./player-overlays-BGbLKvcn.js";import{$ as y,$i as b,$t as x,A as S,Ba as C,Bt as w,Co as T,D as E,Dr as D,E as O,Ei as k,Fa as ee,G as te,Gr as ne,H as A,Hr as re,I as ie,Ir as j,J as M,Jr as N,Jt as P,K as F,L as I,La as ae,Lr as oe,M as L,Mr as se,No as R,Nr as z,O as ce,P as le,Qr as B,Qt as ue,R as de,Rt as fe,Ta as V,Ti as pe,U as me,V as H,Vr as U,Vt as W,W as G,Wa as he,Wi as K,Xr as ge,Yr as q,Zi as _e,Zr as ve,Zt as ye,_ as be,a as J,an as xe,at as Se,b as Ce,c as we,co as Te,ct as Ee,d as De,dt as Oe,ea as ke,et as Ae,ft as je,gr as Me,gt as Ne,hr as Pe,i as Fe,jn as Ie,k as Le,ko as Re,l as ze,ln as Be,lt as Ve,mt as He,no as Ue,o as We,on as Ge,ot as Ke,pt as qe,qn as Je,qr as Ye,r as Xe,s as Ze,sn as Qe,to as $e,u as et,ut as tt,v as nt,vi as rt,wi as it,wr as at,y as ot,z as st,zr as ct,zt as lt}from"./src-Buv5KpAz.js";import{Ft as ut,Nt as dt,Pt as ft,a as pt,dt as mt,i as ht,pt as Y}from"./src-CQVcBp6b.js";import{t as gt}from"./CapabilityBadges-DjOvNnpp.js";import{n as _t,t as vt}from"./bell-ring-BgQsFN7F.js";import{t as yt}from"./boxes-BnOBLNz5.js";import{t as bt}from"./ProviderIcon-JxmOoO_O.js";import{c as xt,d as St,n as Ct,s as wt,u as Tt}from"./NodeInferenceDevices-CubcmlvI.js";import{n as Et}from"./FormBuilder-ChyOUw_O.js";import{t as Dt}from"./pencil-DsWgW1cM.js";import{t as Ot}from"./power-C4yi0usE.js";import{t as kt}from"./refresh-cw-Cly4MRhi.js";import{t as At}from"./rotate-ccw-D0bM0VXI.js";import{t as jt}from"./rotate-cw-CNTEn7nJ.js";import{t as Mt}from"./server-CLOtA1S4.js";import{t as Nt}from"./wifi-Glpx3AkR.js";import{C as Pt,G as Ft,J as It,K as X,M as Lt,N as Rt,U as zt,V as Bt,X as Vt,Y as Ht,a as Ut,b as Wt,c as Gt,d as Kt,g as qt,i as Jt,m as Yt,s as Xt,t as Zt,y as Qt,z as $t}from"./index-vZPXzSPK.js";import"./useEventInvalidation-B-Cb5-ry.js";import{t as en}from"./StatusBadge-CeptlsPG.js";import{i as tn,n as nn,r as rn,t as an}from"./DeviceAggregateSection-DLNzCtMs.js";var on=X(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),sn=X(`disc`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),cn=X(`ear`,[[`path`,{d:`M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0`,key:`1dfaln`}],[`path`,{d:`M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4`,key:`1qnva7`}]]),ln=X(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),un=X(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),dn=X(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),fn=X(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);n();var pn=[{id:`object-detection`,label:`Object detection`,costWhenOff:`No detections, tracks or detection-driven notifications for this camera.`,capName:ft},{id:`audio-analysis`,label:`Audio analysis`,costWhenOff:`No audio events (glass, alarm, speech) and no audio-driven notifications.`,capName:dt}],mn=`Recording`,hn=`Nothing new is written to disk — live still works, existing footage is kept.`;function gn(e,t){let{bindings:n,bindable:r}=t,i=n===null?void 0:n.find(t=>t.capName===e.capName&&t.kind===`wrapped`),a=r?.find(t=>t.capName===e.capName)?.wrappers[0],o=i!==void 0&&i.providerAddonId!==``?i.providerAddonId:a??null,s=n===null?null:i!==void 0;return{id:e.id,label:e.label,costWhenOff:e.costWhenOff,on:s,available:s!==null&&o!==null,capName:e.capName,wrapperAddonId:o}}function _n(e,t,n,r){let i=e.entries.filter(e=>e.capName!==t);return r?{...e,entries:[...i,{capName:t,kind:`wrapped`,providerAddonId:n}]}:{...e,entries:i}}function vn(e,t){let n=e.filter(e=>e.on===!1).map(e=>e.id),r=e.filter(e=>e.on===null).map(e=>e.id),i=t=>t.map(t=>e.find(e=>e.id===t)?.label??t).join(`, `),a=[];return n.length>0&&a.push(`Off: ${i(n)}`),r.length>0&&a.push(`Unknown: ${i(r)}`),{layout:t?`menu`:`inline`,offIds:n,unknownIds:r,summary:a.length===0?`All camera functions on`:a.join(` · `)}}function yn(e){let t=pn.map(t=>gn(t,e)),n={id:`recording`,label:mn,costWhenOff:hn,on:e.recordingEnabled,available:e.recordingEnabled!==null,capName:null,wrapperAddonId:null};return[...t,n]}var bn={"object-detection":qt,"audio-analysis":cn,recording:sn};function xn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.enabled==`boolean`&&Array.isArray(t.bands)}function Sn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.deviceId==`number`&&Array.isArray(t.entries)}function Cn(e){return Sn(e)?e.entries:null}function wn(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e={...n},r=e.capName,i=e.wrappers;typeof r!=`string`||!Array.isArray(i)||t.push({capName:r,wrappers:i.filter(e=>typeof e==`string`)})}return t}function Tn({deviceId:t}){let n=s(),i=Number.isFinite(t),[a,o]=c(null),[l,d]=c(!1),f=z({deviceId:t},{enabled:i}),p=U({deviceType:Y.Camera},{enabled:i}),m=Re({deviceId:t},{enabled:i,retry:!1});Fe([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let h=[[`deviceManager`,`getBindings`],{input:{deviceId:t}}],g=[[`recording`,`getDeviceConfig`],{input:{deviceId:t}}],_=m.data,v=xn(_)?_:null,y=yn({bindings:Cn(f.data),bindable:wn(p.data),recordingEnabled:v===null?null:v.enabled}),b=B({onError:(e,r)=>{let i=r.capName===y[1]?.capName?`audio-analysis`:`object-detection`;console.error(`[CameraFunctionSwitches] wrapper write failed — reverting`,{tags:{deviceId:t},meta:{capName:r.capName,error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]}),o({id:i,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),x=R({onError:e=>{console.error(`[CameraFunctionSwitches] recording write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`recording`,`getDeviceConfig`]]}),o({id:`recording`,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`recording`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),S=e(e=>{if(!e.available||e.on===null)return;let r=!e.on;if(e.id===`recording`){if(v===null)return;n.setQueryData(g,{...v,enabled:r}),x.mutate({deviceId:t,config:{...v,enabled:r}});return}let{capName:i,wrapperAddonId:a}=e;if(i===null||a===null)return;let o=n.getQueryData(h);Sn(o)&&n.setQueryData(h,_n(o,i,a,r)),b.mutate({deviceId:t,capName:i,wrapperAddonId:a,active:r})},[h,t,n,v,g,x,b]),C=vn(y,Ne()),w=e=>a?.id===e.id?a.message:null;return C.layout===`menu`?r(je,{open:l,onOpenChange:d,children:[r(He,{"aria-label":`Camera functions`,title:C.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${a===null?C.offIds.length>0?`border-warning/40 text-warning hover:bg-warning/10`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(Kt,{className:`h-3.5 w-3.5`}),C.offIds.length>0&&r(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:[C.offIds.length,` off`]})]}),r(qe,{className:`left-auto right-0 mt-1 min-w-[240px] p-1`,children:[u(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Camera functions`}),u(`ul`,{className:`space-y-0.5`,children:y.map(e=>u(`li`,{children:u(En,{state:e,failure:w(e),onToggle:()=>S(e)})},e.id))})]})]}):u(`div`,{className:`flex items-center gap-1`,children:y.map(e=>u(Dn,{state:e,failure:w(e),onToggle:()=>S(e)},e.id))})}function En({state:e,failure:t,onToggle:n}){let i=bn[e.id],a=e.on===null,o=e.on===!1;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:a?`${e.label} — state unknown; the source that owns it did not answer.`:t===null?e.costWhenOff:`Last write failed: ${t}`,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px] text-foreground transition-colors hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:[u(i,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${t===null?a?`text-foreground-subtle/50`:o?`text-warning`:`text-success`:`text-danger`}`}),r(`span`,{className:`flex-1 min-w-0`,children:[u(`span`,{className:`block leading-tight`,children:e.label}),u(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:t===null?a?`Unknown`:e.costWhenOff:`Write failed: ${t}`})]}),u(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${a?`bg-surface-hover text-foreground-subtle/60`:o?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:a?`—`:o?`off`:`on`})]})}function Dn({state:e,failure:t,onToggle:n}){let i=bn[e.id],a=e.on===null,o=e.on===!1,s=a?`${e.label} — state unknown; the source that owns it did not answer.`:o?`${e.label} is OFF. ${e.costWhenOff}`:`${e.label} is on. Turning it off: ${e.costWhenOff}`;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:t===null?s:`${s} — last write failed: ${t}`,className:`inline-flex items-center gap-1 rounded-lg border px-1.5 sm:px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${t===null?a?`border-dashed border-border text-foreground-subtle/50`:o?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(i,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden lg:inline`,children:e.label}),o&&u(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:`off`})]})}function On({parentDeviceId:e}){let{t}=Zt(),n=It(),i=m(),{data:a,isLoading:o,isError:s}=xt(e),{data:c}=j({deviceId:e},{enabled:Number.isFinite(e)});if(o)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(s)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(a??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let d=ce(c?.stableId??``,l,c?.childLayout),f=d.ungrouped,p=e=>n(`/devices/${String(e)}`),h=c?.name??``,g=(e,t)=>u(O,{trpc:i.trpcClient,device:{...t,name:S(t,h)},variant:`minimal`,onNavigate:p},e),_=f.some(e=>!!e.role),v=f.some(e=>!e.role),y=_&&!v?t(`device.accessories`,{defaultValue:`Accessories`}):!_&&v?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),b=f.length>0?r(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[u(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:y}),u(`div`,{className:`space-y-1`,children:f.map(e=>g(e.id,e))})]}):null,x=d.disabledSection===void 0?null:u(E,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:d.disabledSection.children.length,defaultOpen:!1,children:u(`div`,{className:`opacity-60 space-y-1`,children:d.disabledSection.children.map(e=>g(e.id,e))})},d.disabledSection.title);return d.sections.length===0?x===null?b:r(`div`,{className:`space-y-2`,children:[b,x]}):r(`div`,{className:`space-y-2`,children:[d.sections.map(e=>u(E,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>g(e.id,e))},e.title)),b,x]})}function kn({deviceId:e}){let t=m(),{data:n,isLoading:r}=wt(e),{data:i,isLoading:a}=xt(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?u(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):u(`div`,{className:`flex h-full w-full flex-col`,children:u(I,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}n();function An({dev:e,busy:t,setBusy:n}){let i=e?.motionTrigger,a=f(e?.state.motionTrigger),[o,s]=c(!1);if(!i)return null;let l=a?.enabled===!0,d=a!==void 0,p=async()=>{if(t||!d)return;let e=!l;n(!0),s(!0);try{await i.setMotionTrigger({enabled:e})}finally{n(!1),s(!1)}};return r(`button`,{type:`button`,onClick:()=>{p()},disabled:t||!d,title:d?l?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[u(Ft,{className:`h-3 w-3`}),u(`span`,{children:o?l?`Disabling…`:`Enabling…`:d?l?`On motion: on`:`On motion: off`:`On motion: …`})]})}n();function Z({deviceId:e,deviceType:t,features:n}){let i=m(),a=H(t)?.HeroCard??A,o=p(i.trpcClient,e),s=f(o?.state.deviceStatus),[l,d]=c(!1),h=s!==void 0&&s.online===!1,g=h?s.lastChangedAt:null;return r(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[h?u(`div`,{className:`flex justify-center`,children:u(st,{lastChangedAt:g})}):null,u(a,{trpc:i.trpcClient,deviceId:e,features:n}),u(`div`,{className:`flex justify-center`,children:u(An,{dev:o,busy:l,setBusy:d})})]})}function jn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:u(me,{trpc:m().trpcClient,deviceId:e,features:t})})}function Mn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:u(A,{trpc:m().trpcClient,deviceId:e,features:t})})}function Nn(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function Pn(e){if(!e)return null;let t=Nn(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var Fn=1e3,In=60*Fn,Ln=60*In,Rn=24*Ln;function zn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<Fn?`just now`:n<In?`${String(Math.floor(n/Fn))}s ago`:n<Ln?`${String(Math.floor(n/In))}m ago`:n<Rn?`${String(Math.floor(n/Ln))}h ago`:`${String(Math.floor(n/Rn))}d ago`}n();var Bn=1500,Vn=15e3,Hn=1e3;function Un({deviceId:e}){let n=p(m().trpcClient,e)?.state.eventEmitter,i=f(n);d(()=>{if(!n)return;n.refresh();let e=setInterval(()=>{n.refresh()},Vn);return()=>{clearInterval(e)}},[n]);let a=i?.lastEvent??null,o=a?.seq??null,s=t(null),[l,h]=c(!1);d(()=>{if(o===null)return;let e=s.current;if(s.current=o,e===null||e===o)return;h(!0);let t=setTimeout(()=>{h(!1)},Bn);return()=>{clearTimeout(t)}},[o]);let[g,_]=c(()=>Date.now());d(()=>{let e=setInterval(()=>{_(Date.now())},Hn);return()=>{clearInterval(e)}},[]);let v=Pn(a),y=i?.eventTypes??[],b=i?.eventCountSinceStart??0,x=i!==void 0,S=Nn(a?.data);return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[u(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(l),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${l?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:v??`No press recorded`,children:u(l?dn:ln,{className:`h-10 w-10`})}),r(`div`,{className:`text-center`,children:[S!==null&&u(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(S)}`}),u(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${v?`text-foreground`:`text-foreground-subtle`}`,children:v??(x?`No press recorded`:`Awaiting state…`)}),u(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a?zn(a.timestamp,g):`Waiting for the first event`})]}),y.length>0&&u(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:y.map(e=>u(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===a?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(b)} ${b===1?`event`:`events`} since start`})]})}function Wn({deviceName:e,deviceType:t,provider:n,isOnline:i,features:a}){return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[u(bt,{type:n,size:`lg`}),r(`div`,{children:[u(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),u(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),r(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[u(en,{status:i?`online`:`offline`}),a.length>0&&u(gt,{capabilities:a})]}),u(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}n();function Gn({deviceId:e}){let t=s(),n=Pe({deviceId:e},{refetchInterval:1e4,retry:!1}),a=Me({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),o=i(()=>Kn(n.data??[]),[n.data]);return r(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[r(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[u(qn,{label:`Discovered`,value:o.total,icon:u(Qt,{className:`h-3.5 w-3.5`})}),u(qn,{label:`Adopted`,value:o.adopted,accent:`success`}),u(qn,{label:`Available`,value:o.available,accent:o.available>0?`primary`:void 0}),r(`button`,{type:`button`,onClick:()=>{a.mutateAsync({deviceId:e}).catch(()=>{})},disabled:a.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[a.isPending?u(Pt,{className:`h-3.5 w-3.5 animate-spin`}):u(kt,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[u(Jn,{icon:u(Nt,{className:`h-3 w-3 text-emerald-500`}),label:`${o.online} online`}),u(Jn,{icon:u(Wt,{className:`h-3 w-3 text-amber-500`}),label:`${o.sleeping} sleeping`}),u(Jn,{icon:u(Ut,{className:`h-3 w-3 text-destructive`}),label:`${o.offline} offline`}),o.unknown>0?u(Jn,{icon:u(on,{className:`h-3 w-3 text-foreground-subtle`}),label:`${o.unknown} unknown`}):null]})]})}function Kn(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function qn({label:e,value:t,icon:n,accent:i}){return r(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${i===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:i===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[r(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,u(`span`,{className:`truncate`,children:e})]}),u(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function Jn({icon:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1`,children:[e,u(`span`,{children:t})]})}var Yn={[Y.Switch]:Z,[Y.Siren]:Z,[Y.Light]:Z,[Y.Sensor]:Z,[Y.Button]:Z,[Y.Hub]:Gn,[Y.Cover]:jn,[Y.Valve]:Z,[Y.Humidifier]:Z,[Y.WaterHeater]:Z,[Y.Container]:kn,[Y.Lock]:Z,[Y.Fan]:Z,[Y.Thermostat]:Z,[Y.Climate]:Z,[Y.MediaPlayer]:Z,[Y.Control]:Z,[Y.AlarmPanel]:Z,[Y.EventEmitter]:Un,[Y.Notifier]:Mn,[Y.Script]:Z,[Y.Automation]:Z,[Y.Presence]:Z,[Y.Update]:Z,[Y.Vacuum]:Z,[Y.LawnMower]:Z,[Y.Weather]:Z,[Y.Image]:Z,[Y.PetFeeder]:Z};function Xn(e){return Yn[e]??Wn}function Zn(e){return u(Xn(e.deviceType),{...e})}function Qn(e){return Ze(m().trpcClient,e)}n();function $n(n){let[r,i]=c(`idle`),[a,o]=c(null),s=t(null),l=t(null),u=t(null),f=t(!0),p=pe(),m=it(),h=k(),g=e(()=>{if(s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null},[]),_=e(async()=>{if(r===`idle`)return;i(`stopping`);let e=u.current;if(e&&n!==null)try{await Promise.race([h.mutateAsync({deviceId:n,sessionId:e}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}g(),f.current&&(i(`idle`),o(null))},[r,n,h,g]),v=e(async()=>{if(n===null||r!==`idle`&&r!==`error`)return;o(null);let e=null,t=null,a=null;try{i(`requesting-mic`),e=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),l.current=e,i(`starting`);let r=await p.mutateAsync({deviceId:n});a=r.sessionId,u.current=a,i(`connecting`),t=new RTCPeerConnection,s.current=t,t.oniceconnectionstatechange=()=>{if(!f.current)return;let e=t.iceConnectionState;e===`connected`||e===`completed`?i(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&f.current&&(o(e===`failed`?`WebRTC connection failed`:null),_())};for(let n of e.getAudioTracks())t.addTrack(n,e);await t.setRemoteDescription({type:`offer`,sdp:r.sdpOffer});let c=await t.createAnswer();await t.setLocalDescription(c);let d=t.localDescription?.sdp??c.sdp??``;await m.mutateAsync({deviceId:n,sessionId:a,sdpAnswer:d})}catch(r){let c=r instanceof Error?r.message:String(r);if(console.warn(`[intercom] start failed`,r),t)try{t.close()}catch{}if(e)for(let t of e.getTracks())try{t.stop()}catch{}if(s.current=null,l.current=null,a!==null)try{await h.mutateAsync({deviceId:n,sessionId:a})}catch{}u.current=null,f.current&&(o(c),i(`error`))}},[n,r,p,m,h,_]);return d(()=>(f.current=!0,()=>{f.current=!1;let e=u.current;if(e!==null&&n!==null&&h.mutate({deviceId:n,sessionId:e}),s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null}),[n]),{state:r,error:a,start:v,stop:_,isTalking:r===`talking`}}n();var er=0;function Q(){return++er}function tr(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function nr(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function rr(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function ir(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function ar({scope:n,greeting:i,className:a}){let o=m(),[s,f]=c(()=>{let e=[];return i&&e.push({id:Q(),kind:`info`,text:i}),e.push({id:Q(),kind:`info`,text:`scope: ${tr(n)} — type help or context for available commands`}),e}),[p,h]=c(``),[g,_]=c([]),[v,y]=c(-1),b=t(null),x=t(null);d(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[s]);let S=e(()=>{b.current?.focus()},[]),C=l({mutationFn:e=>o.trpcClient.repl.execute.mutate({code:e,scope:n}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;f(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);f(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function w(e){let t=e.trim();if(t){if(t===`clear`){f([{id:Q(),kind:`info`,text:`scope: ${tr(n)}`}]),h(``);return}if(t===`help`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...nr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`context`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...ir(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`examples`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...rr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}_(e=>[...e,t]),y(-1),f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`}]),h(``),C.mutate(t)}}function T(e){if(e.key===`Enter`){e.preventDefault(),w(p);return}if(e.key===`ArrowUp`){if(e.preventDefault(),g.length===0)return;let t=v===-1?g.length-1:Math.max(0,v-1);y(t),h(g[t]??``);return}if(e.key===`ArrowDown`){if(e.preventDefault(),v===-1)return;let t=v+1;t>=g.length?(y(-1),h(``)):(y(t),h(g[t]??``));return}e.ctrlKey&&e.key===`l`&&(e.preventDefault(),f([{id:Q(),kind:`info`,text:`scope: ${tr(n)}`}]))}let E={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return r(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${a??``}`,onClick:S,children:[r(`div`,{ref:x,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[s.map(e=>u(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${E[e.kind]}`,children:e.text},e.id)),C.isPending&&u(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),r(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[u(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),u(`input`,{ref:b,value:p,onChange:e=>h(e.target.value),onKeyDown:T,disabled:C.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function or({deviceId:e,intercomAvailable:t=!1}){let n=m(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Qn(i?e:null),{streams:s,pipelineMetrics:c,createSession:l,sendAnswer:d,handleOffer:f,getIceServers:p,addIceCandidate:_,getIceCandidates:v,closeSession:y,getSessionState:b}=We(n.trpcClient,i?e:null),S=h(i?e:null,{width:dr}),C=$n(i&&t?e:null),w=C.state===`requesting-mic`||C.state===`starting`||C.state===`connecting`||C.state===`stopping`,T=C.isTalking||w,E=()=>{C.state===`idle`||C.state===`error`?C.start():C.state!==`stopping`&&C.stop()},D=g(),O=x(),k=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,ee=D.length>0?u(o,{children:D.map(e=>u(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return u(ze,{serverUrl:r,createSession:l,sendAnswer:d,handleOffer:f,getIceServers:p,addIceCandidate:_,getIceCandidates:v,closeSession:y,getSessionState:b,...O.request?{playbackUrl:O.request.url,playbackAuthToken:k,...O.request.label?{playbackLabel:O.request.label}:{},onExitPlayback:()=>O.clear()}:{},streams:s,pipelineMetrics:c,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:S.src,...S.src?{posterUrl:S.src}:{},snapshotLoading:S.loading,onRefreshSnapshot:S.refresh,intercomAvailable:t,intercomShown:T,onIntercomToggle:E,extraOverlay:ee,chromeless:!0,className:`h-full`})}function sr({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full`,children:u(M,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function cr({deviceId:e}){if(!Number.isFinite(e))return r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,a,b as o,o as s,q as c,t as l,x as u,z as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{K as f,W as p,Z as m,o as h,r as g,t as _,v}from"./player-overlays-BCuyatPp.js";import{$ as y,$i as b,$t as x,A as S,Ba as C,Bt as w,Co as T,D as E,Dr as D,E as O,Ei as k,Fa as ee,G as te,Gr as ne,H as A,Hr as re,I as ie,Ir as j,J as M,Jr as N,Jt as P,K as F,L as I,La as ae,Lr as oe,M as L,Mr as se,No as R,Nr as z,O as ce,P as le,Qr as B,Qt as ue,R as de,Rt as fe,Ta as V,Ti as pe,U as me,V as H,Vr as U,Vt as W,W as G,Wa as he,Wi as K,Xr as ge,Yr as q,Zi as _e,Zr as ve,Zt as ye,_ as be,a as J,an as xe,at as Se,b as Ce,c as we,co as Te,ct as Ee,d as De,dt as Oe,ea as ke,et as Ae,ft as je,gr as Me,gt as Ne,hr as Pe,i as Fe,jn as Ie,k as Le,ko as Re,l as ze,ln as Be,lt as Ve,mt as He,no as Ue,o as We,on as Ge,ot as Ke,pt as qe,qn as Je,qr as Ye,r as Xe,s as Ze,sn as Qe,to as $e,u as et,ut as tt,v as nt,vi as rt,wi as it,wr as at,y as ot,z as st,zr as ct,zt as lt}from"./src-BmCjCFGO.js";import{Ft as ut,Nt as dt,Pt as ft,a as pt,dt as mt,i as ht,pt as Y}from"./src-D8hsVOc6.js";import{t as gt}from"./CapabilityBadges-BVAXgYuj.js";import{n as _t,t as vt}from"./bell-ring-0co0yj8J.js";import{t as yt}from"./boxes-CKu64rZy.js";import{t as bt}from"./ProviderIcon-BBJFc8mr.js";import{c as xt,d as St,n as Ct,s as wt,u as Tt}from"./NodeInferenceDevices-CkoeBXMD.js";import{n as Et}from"./FormBuilder-CgtfU1VA.js";import{t as Dt}from"./pencil-CCyVFYXA.js";import{t as Ot}from"./power-ChfUL_0y.js";import{t as kt}from"./refresh-cw-CvqUZLg2.js";import{t as At}from"./rotate-ccw-CwngHzIQ.js";import{t as jt}from"./rotate-cw-pPP0LEo9.js";import{t as Mt}from"./server-DSkdRu09.js";import{t as Nt}from"./wifi-Wacew_4h.js";import{C as Pt,G as Ft,J as It,K as X,M as Lt,N as Rt,U as zt,V as Bt,X as Vt,Y as Ht,a as Ut,b as Wt,c as Gt,d as Kt,g as qt,i as Jt,m as Yt,s as Xt,t as Zt,y as Qt,z as $t}from"./index-CoX6Kh_l.js";import"./useEventInvalidation-DCo7fWEj.js";import{t as en}from"./StatusBadge-CeptlsPG.js";import{i as tn,n as nn,r as rn,t as an}from"./DeviceAggregateSection-aUgWgamW.js";var on=X(`circle-help`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),sn=X(`disc`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}]]),cn=X(`ear`,[[`path`,{d:`M6 8.5a6.5 6.5 0 1 1 13 0c0 6-6 6-6 10a3.5 3.5 0 1 1-7 0`,key:`1dfaln`}],[`path`,{d:`M15 8.5a2.5 2.5 0 0 0-5 0v1a2 2 0 1 1 0 4`,key:`1qnva7`}]]),ln=X(`hand`,[[`path`,{d:`M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2`,key:`1fvzgz`}],[`path`,{d:`M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2`,key:`1kc0my`}],[`path`,{d:`M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8`,key:`10h0bg`}],[`path`,{d:`M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15`,key:`1s1gnw`}]]),un=X(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),dn=X(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),fn=X(`volume-2`,[[`path`,{d:`M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z`,key:`uqj9uw`}],[`path`,{d:`M16 9a5 5 0 0 1 0 6`,key:`1q6k2b`}],[`path`,{d:`M19.364 18.364a9 9 0 0 0 0-12.728`,key:`ijwkga`}]]);n();var pn=[{id:`object-detection`,label:`Object detection`,costWhenOff:`No detections, tracks or detection-driven notifications for this camera.`,capName:ft},{id:`audio-analysis`,label:`Audio analysis`,costWhenOff:`No audio events (glass, alarm, speech) and no audio-driven notifications.`,capName:dt}],mn=`Recording`,hn=`Nothing new is written to disk — live still works, existing footage is kept.`;function gn(e,t){let{bindings:n,bindable:r}=t,i=n===null?void 0:n.find(t=>t.capName===e.capName&&t.kind===`wrapped`),a=r?.find(t=>t.capName===e.capName)?.wrappers[0],o=i!==void 0&&i.providerAddonId!==``?i.providerAddonId:a??null,s=n===null?null:i!==void 0;return{id:e.id,label:e.label,costWhenOff:e.costWhenOff,on:s,available:s!==null&&o!==null,capName:e.capName,wrapperAddonId:o}}function _n(e,t,n,r){let i=e.entries.filter(e=>e.capName!==t);return r?{...e,entries:[...i,{capName:t,kind:`wrapped`,providerAddonId:n}]}:{...e,entries:i}}function vn(e,t){let n=e.filter(e=>e.on===!1).map(e=>e.id),r=e.filter(e=>e.on===null).map(e=>e.id),i=t=>t.map(t=>e.find(e=>e.id===t)?.label??t).join(`, `),a=[];return n.length>0&&a.push(`Off: ${i(n)}`),r.length>0&&a.push(`Unknown: ${i(r)}`),{layout:t?`menu`:`inline`,offIds:n,unknownIds:r,summary:a.length===0?`All camera functions on`:a.join(` · `)}}function yn(e){let t=pn.map(t=>gn(t,e)),n={id:`recording`,label:mn,costWhenOff:hn,on:e.recordingEnabled,available:e.recordingEnabled!==null,capName:null,wrapperAddonId:null};return[...t,n]}var bn={"object-detection":qt,"audio-analysis":cn,recording:sn};function xn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.enabled==`boolean`&&Array.isArray(t.bands)}function Sn(e){if(typeof e!=`object`||!e)return!1;let t={...e};return typeof t.deviceId==`number`&&Array.isArray(t.entries)}function Cn(e){return Sn(e)?e.entries:null}function wn(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){if(typeof n!=`object`||!n)continue;let e={...n},r=e.capName,i=e.wrappers;typeof r!=`string`||!Array.isArray(i)||t.push({capName:r,wrappers:i.filter(e=>typeof e==`string`)})}return t}function Tn({deviceId:t}){let n=s(),i=Number.isFinite(t),[a,o]=c(null),[l,d]=c(!1),f=z({deviceId:t},{enabled:i}),p=U({deviceType:Y.Camera},{enabled:i}),m=Re({deviceId:t},{enabled:i,retry:!1});Fe([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let h=[[`deviceManager`,`getBindings`],{input:{deviceId:t}}],g=[[`recording`,`getDeviceConfig`],{input:{deviceId:t}}],_=m.data,v=xn(_)?_:null,y=yn({bindings:Cn(f.data),bindable:wn(p.data),recordingEnabled:v===null?null:v.enabled}),b=B({onError:(e,r)=>{let i=r.capName===y[1]?.capName?`audio-analysis`:`object-detection`;console.error(`[CameraFunctionSwitches] wrapper write failed — reverting`,{tags:{deviceId:t},meta:{capName:r.capName,error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]}),o({id:i,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`deviceManager`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),x=R({onError:e=>{console.error(`[CameraFunctionSwitches] recording write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),n.invalidateQueries({queryKey:[[`recording`,`getDeviceConfig`]]}),o({id:`recording`,message:e instanceof Error?e.message:String(e)})},onSuccess:()=>{o(null),n.invalidateQueries({queryKey:[[`recording`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`]]})}}),S=e(e=>{if(!e.available||e.on===null)return;let r=!e.on;if(e.id===`recording`){if(v===null)return;n.setQueryData(g,{...v,enabled:r}),x.mutate({deviceId:t,config:{...v,enabled:r}});return}let{capName:i,wrapperAddonId:a}=e;if(i===null||a===null)return;let o=n.getQueryData(h);Sn(o)&&n.setQueryData(h,_n(o,i,a,r)),b.mutate({deviceId:t,capName:i,wrapperAddonId:a,active:r})},[h,t,n,v,g,x,b]),C=vn(y,Ne()),w=e=>a?.id===e.id?a.message:null;return C.layout===`menu`?r(je,{open:l,onOpenChange:d,children:[r(He,{"aria-label":`Camera functions`,title:C.summary,className:`inline-flex items-center gap-1 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors ${a===null?C.offIds.length>0?`border-warning/40 text-warning hover:bg-warning/10`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(Kt,{className:`h-3.5 w-3.5`}),C.offIds.length>0&&r(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:[C.offIds.length,` off`]})]}),r(qe,{className:`left-auto right-0 mt-1 min-w-[240px] p-1`,children:[u(`div`,{className:`px-2 py-1 text-[10px] uppercase tracking-wider text-foreground-subtle`,children:`Camera functions`}),u(`ul`,{className:`space-y-0.5`,children:y.map(e=>u(`li`,{children:u(En,{state:e,failure:w(e),onToggle:()=>S(e)})},e.id))})]})]}):u(`div`,{className:`flex items-center gap-1`,children:y.map(e=>u(Dn,{state:e,failure:w(e),onToggle:()=>S(e)},e.id))})}function En({state:e,failure:t,onToggle:n}){let i=bn[e.id],a=e.on===null,o=e.on===!1;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:a?`${e.label} — state unknown; the source that owns it did not answer.`:t===null?e.costWhenOff:`Last write failed: ${t}`,className:`flex w-full items-start gap-2 rounded-md px-2 py-1.5 text-left text-[12px] text-foreground transition-colors hover:bg-surface-hover disabled:opacity-40 disabled:cursor-not-allowed`,children:[u(i,{className:`h-3.5 w-3.5 shrink-0 mt-0.5 ${t===null?a?`text-foreground-subtle/50`:o?`text-warning`:`text-success`:`text-danger`}`}),r(`span`,{className:`flex-1 min-w-0`,children:[u(`span`,{className:`block leading-tight`,children:e.label}),u(`span`,{className:`block mt-0.5 text-[10px] text-foreground-subtle leading-tight`,children:t===null?a?`Unknown`:e.costWhenOff:`Write failed: ${t}`})]}),u(`span`,{className:`shrink-0 rounded px-1 py-0.5 text-[9px] font-semibold uppercase tracking-wide ${a?`bg-surface-hover text-foreground-subtle/60`:o?`bg-warning/20 text-warning`:`bg-success/20 text-success`}`,children:a?`—`:o?`off`:`on`})]})}function Dn({state:e,failure:t,onToggle:n}){let i=bn[e.id],a=e.on===null,o=e.on===!1,s=a?`${e.label} — state unknown; the source that owns it did not answer.`:o?`${e.label} is OFF. ${e.costWhenOff}`:`${e.label} is on. Turning it off: ${e.costWhenOff}`;return r(`button`,{type:`button`,role:`switch`,"aria-label":e.label,"aria-checked":e.on===!0,disabled:!e.available,onClick:n,title:t===null?s:`${s} — last write failed: ${t}`,className:`inline-flex items-center gap-1 rounded-lg border px-1.5 sm:px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${t===null?a?`border-dashed border-border text-foreground-subtle/50`:o?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(i,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden lg:inline`,children:e.label}),o&&u(`span`,{className:`rounded bg-warning/20 px-1 text-[9px] font-semibold uppercase tracking-wide`,children:`off`})]})}function On({parentDeviceId:e}){let{t}=Zt(),n=It(),i=m(),{data:a,isLoading:o,isError:s}=xt(e),{data:c}=j({deviceId:e},{enabled:Number.isFinite(e)});if(o)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-foreground-subtle`,children:t(`common.loading`,{defaultValue:`Loading…`})})});if(s)return u(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:u(`p`,{className:`text-[10px] text-warning`,children:t(`integrations.childrenLoadError`,{defaultValue:`Failed to load children`})})});let l=(a??[]).filter(e=>e.display?.hidden!==!0);if(l.length===0)return null;let d=ce(c?.stableId??``,l,c?.childLayout),f=d.ungrouped,p=e=>n(`/devices/${String(e)}`),h=c?.name??``,g=(e,t)=>u(O,{trpc:i.trpcClient,device:{...t,name:S(t,h)},variant:`minimal`,onNavigate:p},e),_=f.some(e=>!!e.role),v=f.some(e=>!e.role),y=_&&!v?t(`device.accessories`,{defaultValue:`Accessories`}):!_&&v?t(`device.adoptedDevices`,{defaultValue:`Adopted devices`}):t(`device.children`,{defaultValue:`Children`}),b=f.length>0?r(`div`,{className:`rounded-lg border border-border bg-surface p-3`,children:[u(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle mb-1.5`,children:y}),u(`div`,{className:`space-y-1`,children:f.map(e=>g(e.id,e))})]}):null,x=d.disabledSection===void 0?null:u(E,{title:t(`device.disabledSection`,{defaultValue:`Disabled`}),count:d.disabledSection.children.length,defaultOpen:!1,children:u(`div`,{className:`opacity-60 space-y-1`,children:d.disabledSection.children.map(e=>g(e.id,e))})},d.disabledSection.title);return d.sections.length===0?x===null?b:r(`div`,{className:`space-y-2`,children:[b,x]}):r(`div`,{className:`space-y-2`,children:[d.sections.map(e=>u(E,{title:e.title,count:e.children.length,defaultOpen:e.defaultOpen,children:e.children.map(e=>g(e.id,e))},e.title)),b,x]})}function kn({deviceId:e}){let t=m(),{data:n,isLoading:r}=wt(e),{data:i,isLoading:a}=xt(e),o=r||a,s=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,features:e.features,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),c=typeof n?.linkDeviceId==`number`?n.linkDeviceId:null,l=typeof n?.primaryChildEntityId==`string`?n.primaryChildEntityId:null;return o?u(`div`,{className:`h-full min-h-32 w-full animate-pulse rounded-lg bg-surface`,"aria-hidden":`true`}):u(`div`,{className:`flex h-full w-full flex-col`,children:u(I,{trpc:t.trpcClient,children:s,linkDeviceId:c,primaryChildEntityId:l})})}n();function An({dev:e,busy:t,setBusy:n}){let i=e?.motionTrigger,a=f(e?.state.motionTrigger),[o,s]=c(!1);if(!i)return null;let l=a?.enabled===!0,d=a!==void 0,p=async()=>{if(t||!d)return;let e=!l;n(!0),s(!0);try{await i.setMotionTrigger({enabled:e})}finally{n(!1),s(!1)}};return r(`button`,{type:`button`,onClick:()=>{p()},disabled:t||!d,title:d?l?`Disable trigger on motion`:`Enable trigger on motion`:`Awaiting state…`,"aria-pressed":l,className:`inline-flex items-center gap-1.5 rounded-full border px-2.5 py-1 text-[11px] font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${l?`border-primary/50 bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle hover:text-foreground`}`,children:[u(Ft,{className:`h-3 w-3`}),u(`span`,{children:o?l?`Disabling…`:`Enabling…`:d?l?`On motion: on`:`On motion: off`:`On motion: …`})]})}n();function Z({deviceId:e,deviceType:t,features:n}){let i=m(),a=H(t)?.HeroCard??A,o=p(i.trpcClient,e),s=f(o?.state.deviceStatus),[l,d]=c(!1),h=s!==void 0&&s.online===!1,g=h?s.lastChangedAt:null;return r(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:[h?u(`div`,{className:`flex justify-center`,children:u(st,{lastChangedAt:g})}):null,u(a,{trpc:i.trpcClient,deviceId:e,features:n}),u(`div`,{className:`flex justify-center`,children:u(An,{dev:o,busy:l,setBusy:d})})]})}function jn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch gap-3 p-3 sm:p-4`,children:u(me,{trpc:m().trpcClient,deviceId:e,features:t})})}function Mn({deviceId:e,features:t}){return u(`div`,{className:`flex h-full w-full flex-col items-stretch p-3 sm:p-4`,children:u(A,{trpc:m().trpcClient,deviceId:e,features:t})})}function Nn(e){if(!e)return null;let t=e.channel;return typeof t!=`number`||!Number.isInteger(t)||t<0?null:t}function Pn(e){if(!e)return null;let t=Nn(e.data);return t===null?e.eventType:`Button ${String(t)} · ${e.eventType}`}var Fn=1e3,In=60*Fn,Ln=60*In,Rn=24*Ln;function zn(e,t){if(e==null||e<=0)return`—`;let n=t-e;return n<Fn?`just now`:n<In?`${String(Math.floor(n/Fn))}s ago`:n<Ln?`${String(Math.floor(n/In))}m ago`:n<Rn?`${String(Math.floor(n/Ln))}h ago`:`${String(Math.floor(n/Rn))}d ago`}n();var Bn=1500,Vn=15e3,Hn=1e3;function Un({deviceId:e}){let n=p(m().trpcClient,e)?.state.eventEmitter,i=f(n);d(()=>{if(!n)return;n.refresh();let e=setInterval(()=>{n.refresh()},Vn);return()=>{clearInterval(e)}},[n]);let a=i?.lastEvent??null,o=a?.seq??null,s=t(null),[l,h]=c(!1);d(()=>{if(o===null)return;let e=s.current;if(s.current=o,e===null||e===o)return;h(!0);let t=setTimeout(()=>{h(!1)},Bn);return()=>{clearTimeout(t)}},[o]);let[g,_]=c(()=>Date.now());d(()=>{let e=setInterval(()=>{_(Date.now())},Hn);return()=>{clearInterval(e)}},[]);let v=Pn(a),y=i?.eventTypes??[],b=i?.eventCountSinceStart??0,x=i!==void 0,S=Nn(a?.data);return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 p-4`,children:[u(`div`,{"data-testid":`event-emitter-indicator`,"data-flashing":String(l),className:`flex h-24 w-24 items-center justify-center rounded-full border-2 transition-all ${l?`border-primary bg-primary/20 text-primary shadow-lg shadow-primary/30 scale-105`:`border-border bg-surface text-foreground-subtle`}`,"aria-live":`polite`,title:v??`No press recorded`,children:u(l?dn:ln,{className:`h-10 w-10`})}),r(`div`,{className:`text-center`,children:[S!==null&&u(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-primary`,children:`Button ${String(S)}`}),u(`div`,{"data-testid":`event-emitter-headline`,className:`text-sm font-semibold ${v?`text-foreground`:`text-foreground-subtle`}`,children:v??(x?`No press recorded`:`Awaiting state…`)}),u(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:a?zn(a.timestamp,g):`Waiting for the first event`})]}),y.length>0&&u(`div`,{className:`flex max-w-full flex-wrap justify-center gap-1`,children:y.map(e=>u(`span`,{"data-testid":`event-emitter-chip`,className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${e===a?.eventType?`border-primary bg-primary/15 text-primary`:`border-border bg-surface text-foreground-subtle`}`,children:e},e))}),u(`div`,{className:`text-[10px] text-foreground-subtle`,children:`${String(b)} ${b===1?`event`:`events`} since start`})]})}function Wn({deviceName:e,deviceType:t,provider:n,isOnline:i,features:a}){return r(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface p-6 text-center`,children:[u(bt,{type:n,size:`lg`}),r(`div`,{children:[u(`div`,{className:`text-sm font-semibold text-foreground`,children:e}),u(`div`,{className:`text-[10px] text-foreground-subtle uppercase tracking-wider mt-0.5`,children:t})]}),r(`div`,{className:`flex items-center gap-2 flex-wrap justify-center`,children:[u(en,{status:i?`online`:`offline`}),a.length>0&&u(gt,{capabilities:a})]}),u(`div`,{className:`text-[10px] text-foreground-subtle italic max-w-xs mt-1`,children:`No live view for this device type. Use the Config tab or the shortcut row to interact.`})]})}n();function Gn({deviceId:e}){let t=s(),n=Pe({deviceId:e},{refetchInterval:1e4,retry:!1}),a=Me({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceDiscovery`,`listDiscovered`]]}),t.invalidateQueries({queryKey:[[`deviceDiscovery`,`getStatus`]]})}}),o=i(()=>Kn(n.data??[]),[n.data]);return r(`div`,{className:`flex h-full w-full flex-col gap-3 p-3 sm:p-4`,children:[r(`div`,{className:`flex flex-wrap items-stretch gap-2 sm:gap-3`,children:[u(qn,{label:`Discovered`,value:o.total,icon:u(Qt,{className:`h-3.5 w-3.5`})}),u(qn,{label:`Adopted`,value:o.adopted,accent:`success`}),u(qn,{label:`Available`,value:o.available,accent:o.available>0?`primary`:void 0}),r(`button`,{type:`button`,onClick:()=>{a.mutateAsync({deviceId:e}).catch(()=>{})},disabled:a.isPending,className:`inline-flex items-center justify-center gap-1.5 rounded-lg border border-border px-3 py-2 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 self-stretch shrink-0`,children:[a.isPending?u(Pt,{className:`h-3.5 w-3.5 animate-spin`}):u(kt,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden sm:inline`,children:`Discover`})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-foreground-subtle border-t border-border-subtle pt-2`,children:[u(Jn,{icon:u(Nt,{className:`h-3 w-3 text-emerald-500`}),label:`${o.online} online`}),u(Jn,{icon:u(Wt,{className:`h-3 w-3 text-amber-500`}),label:`${o.sleeping} sleeping`}),u(Jn,{icon:u(Ut,{className:`h-3 w-3 text-destructive`}),label:`${o.offline} offline`}),o.unknown>0?u(Jn,{icon:u(on,{className:`h-3 w-3 text-foreground-subtle`}),label:`${o.unknown} unknown`}):null]})]})}function Kn(e){let t={total:e.length,adopted:0,available:0,online:0,sleeping:0,offline:0,unknown:0};for(let n of e)n.alreadyAdopted?t.adopted+=1:t.available+=1,t[n.status]+=1;return t}function qn({label:e,value:t,icon:n,accent:i}){return r(`div`,{className:`flex flex-1 basis-[140px] min-w-0 flex-col gap-1 rounded-lg border px-2 py-1.5 sm:px-3 sm:py-2 ${i===`success`?`bg-emerald-500/10 border-emerald-500/30 text-emerald-500`:i===`primary`?`bg-primary/10 border-primary/30 text-primary`:`bg-surface-hover border-border text-foreground`}`,children:[r(`div`,{className:`flex items-center gap-1.5 text-[10px] uppercase tracking-wider opacity-70 truncate`,children:[n,u(`span`,{className:`truncate`,children:e})]}),u(`div`,{className:`text-xl sm:text-2xl font-semibold tabular-nums leading-none`,children:t})]})}function Jn({icon:e,label:t}){return r(`span`,{className:`inline-flex items-center gap-1`,children:[e,u(`span`,{children:t})]})}var Yn={[Y.Switch]:Z,[Y.Siren]:Z,[Y.Light]:Z,[Y.Sensor]:Z,[Y.Button]:Z,[Y.Hub]:Gn,[Y.Cover]:jn,[Y.Valve]:Z,[Y.Humidifier]:Z,[Y.WaterHeater]:Z,[Y.Container]:kn,[Y.Lock]:Z,[Y.Fan]:Z,[Y.Thermostat]:Z,[Y.Climate]:Z,[Y.MediaPlayer]:Z,[Y.Control]:Z,[Y.AlarmPanel]:Z,[Y.EventEmitter]:Un,[Y.Notifier]:Mn,[Y.Script]:Z,[Y.Automation]:Z,[Y.Presence]:Z,[Y.Update]:Z,[Y.Vacuum]:Z,[Y.LawnMower]:Z,[Y.Weather]:Z,[Y.Image]:Z,[Y.PetFeeder]:Z};function Xn(e){return Yn[e]??Wn}function Zn(e){return u(Xn(e.deviceType),{...e})}function Qn(e){return Ze(m().trpcClient,e)}n();function $n(n){let[r,i]=c(`idle`),[a,o]=c(null),s=t(null),l=t(null),u=t(null),f=t(!0),p=pe(),m=it(),h=k(),g=e(()=>{if(s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null},[]),_=e(async()=>{if(r===`idle`)return;i(`stopping`);let e=u.current;if(e&&n!==null)try{await Promise.race([h.mutateAsync({deviceId:n,sessionId:e}),new Promise((e,t)=>setTimeout(()=>t(Error(`server stopSession timeout`)),2e3))])}catch(e){console.warn(`[intercom] server stopSession failed (continuing teardown)`,e)}g(),f.current&&(i(`idle`),o(null))},[r,n,h,g]),v=e(async()=>{if(n===null||r!==`idle`&&r!==`error`)return;o(null);let e=null,t=null,a=null;try{i(`requesting-mic`),e=await navigator.mediaDevices.getUserMedia({audio:!0,video:!1}),l.current=e,i(`starting`);let r=await p.mutateAsync({deviceId:n});a=r.sessionId,u.current=a,i(`connecting`),t=new RTCPeerConnection,s.current=t,t.oniceconnectionstatechange=()=>{if(!f.current)return;let e=t.iceConnectionState;e===`connected`||e===`completed`?i(`talking`):(e===`failed`||e===`closed`||e===`disconnected`)&&f.current&&(o(e===`failed`?`WebRTC connection failed`:null),_())};for(let n of e.getAudioTracks())t.addTrack(n,e);await t.setRemoteDescription({type:`offer`,sdp:r.sdpOffer});let c=await t.createAnswer();await t.setLocalDescription(c);let d=t.localDescription?.sdp??c.sdp??``;await m.mutateAsync({deviceId:n,sessionId:a,sdpAnswer:d})}catch(r){let c=r instanceof Error?r.message:String(r);if(console.warn(`[intercom] start failed`,r),t)try{t.close()}catch{}if(e)for(let t of e.getTracks())try{t.stop()}catch{}if(s.current=null,l.current=null,a!==null)try{await h.mutateAsync({deviceId:n,sessionId:a})}catch{}u.current=null,f.current&&(o(c),i(`error`))}},[n,r,p,m,h,_]);return d(()=>(f.current=!0,()=>{f.current=!1;let e=u.current;if(e!==null&&n!==null&&h.mutate({deviceId:n,sessionId:e}),s.current){try{s.current.close()}catch{}s.current=null}if(l.current){for(let e of l.current.getTracks())try{e.stop()}catch{}l.current=null}u.current=null}),[n]),{state:r,error:a,start:v,stop:_,isTalking:r===`talking`}}n();var er=0;function Q(){return++er}function tr(e){switch(e.type){case`system`:return`system`;case`device`:return`#${e.deviceId}`;case`provider`:return e.providerId;case`addon`:return e.addonId}}function nr(e){return[``,`Commands`,` help Show this help`,` examples Show usage examples for the current scope`,` context Show every available variable + full API surface`,` clear Clear terminal (also Ctrl+L)`,``,`Shortcuts`,` Enter Execute expression`,` Arrow Up/Down Navigate command history`,` Ctrl+L Clear terminal`,``,`Try: ${{system:` sm.summary() // fleet overview`,device:` device.state.battery.value?.sleeping // sync read`,provider:` devices.map(d => d.name)`,addon:` manifest.version`}[e.type]}`,``,`Top-level objects: sm (SystemMirror), DeviceType, Math, JSON, Date, …`]}function rr(e){switch(e.type){case`device`:return[``,`── State (sync, zero round-trip) ─────────────────────────`,` device.state.battery.value`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,``,`── Actions (async, through wrapper chain) ────────────────`,` await device.snapshot.getSnapshot({})`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.switch.setState({ on: true })`,``,`── Wait for condition ───────────────────────────────────`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`── Subscribe to changes ─────────────────────────────────`,` const off = device.state.battery.subscribe(s => console.log(s))`,``,`── Quick info ───────────────────────────────────────────`,` info.name device name`,` info.addonId owning addon`,` sm.dump(deviceId) full debug dump`];case`system`:return[``,`── Lookups ──────────────────────────────────────────────`,` sm.getDeviceById(8)`,` sm.getDeviceByName('Sala da pranzo')`,` sm.getDevicesByAddon('reolink')`,` sm.getDevicesByType(DeviceType.Camera)`,``,`── Filters (typed query) ────────────────────────────────`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] })`,` sm.query({ name: /^Cam-/ })`,``,`── Cross-device ─────────────────────────────────────────`,` sm.whereState('battery', s => s.percentage < 20).length`,` sm.mapState('battery', s => s.percentage)`,` sm.countByCap('snapshot')`,``,`── Batch action ─────────────────────────────────────────`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,``,`── Listen ───────────────────────────────────────────────`,` sm.listenCap('motion', (id, s) => console.log(id, s))`,` sm.onDeviceAdded((id, info) => console.log('+', info.name))`,``,`── Diagnostics ──────────────────────────────────────────`,` sm.summary()`,` sm.dump(8)`];case`provider`:return[``,` devices.map(d => d.name)`,` await getIntegration()`,` sm.getDevicesByAddon('<this-addon-id>').length`];case`addon`:return[``,` manifest.name`,` manifest.version`,` declaration`]}}function ir(e){let t=[``,`Scope: ${e.type}`,``];switch(e.type){case`system`:return[...t,`Primary API — sm (SystemMirror):`,` sm.getDeviceById(id) DeviceProxy | null (sync)`,` sm.getDeviceByName(name) DeviceProxy | null`,` sm.getDeviceByStableId(sid) DeviceProxy | null`,` sm.getAllDevices() readonly DeviceProxy[]`,` sm.getDeviceInfo(id) DeviceInfo | null`,` sm.summary() fleet stats`,``,`Filters — sm.query({...}):`,` sm.query({ addonId: 'reolink', online: true })`,` sm.query({ caps: ['battery', 'snapshot'] }) // ALL caps required`,` sm.query({ anyCap: ['ptz', 'motion'] }) // ANY cap`,` sm.query({ name: { contains: 'sala' } }) // case-insensitive`,` sm.query({ name: /^Cam-\\d+$/ })`,` sm.query({ type: DeviceType.Camera })`,` sm.query({ parentDeviceId: 8 }) // accessories of cam 8`,` sm.query({ where: (info, dev) => dev.state.battery.value?.sleeping })`,``,`State queries:`,` sm.whereState('battery', s => s.percentage < 20)`,` sm.mapState('battery', s => s.percentage)`,` sm.findState('motion', s => s.detected)`,` sm.countByCap('snapshot')`,``,`Listeners (return unsubscribe fn):`,` sm.listen((id, cap, slice) => …) // every state change`,` sm.listenCap('motion', (id, slice) => …)`,` sm.listenDevice(8, (id, cap, slice) => …)`,` sm.onDeviceAdded((id, info) => …)`,` sm.onDeviceRemoved((id, info) => …)`,``,`Wait primitives:`,` await sm.waitForState(8, 'battery', s => !s.sleeping, 30_000)`,` await sm.waitForDevice(99, 30_000)`,``,`Batch:`,` await sm.invokeCap('snapshot', 'getSnapshot', {}, { parallelism: 4 })`,` await sm.forEachCap('reboot', d => d.reboot.reboot({}))`,``,`Diagnostics:`,` sm.dump(8) debug dump (one device)`,` sm.dump() full fleet dump`,` sm.summary() breakdown by cap/addon/type`,``,`Legacy: deviceRegistry, addonRegistry, eventBus, devices(), addons()`];case`device`:return[...t,`Pre-bound variables:`,` device DeviceProxy for this device (sync state + async methods)`,` deviceId number`,` info DeviceInfo metadata (name, addonId, type, online, …)`,` sm SystemMirror (full cluster view)`,` rawDevice legacy IDevice instance (escape hatch)`,``,`Reactive state (sync, zero round-trip):`,` device.state.battery.value BatteryStatus | undefined`,` device.state.battery.value?.sleeping`,` device.state.battery.value?.percentage`,` device.state.motion.value?.detected`,` device.state.switch.value?.on`,` device.state.brightness.value?.percentage`,` device.state.doorbell.value?.lastPressedAt`,``,`Cap actions (async, through wrapper chain):`,` await device.snapshot.getSnapshot({})`,` await device.snapshot.getSnapshot({ streamId: 'high' })`,` await device.ptz.move({ direction: 'left', steps: 1 })`,` await device.ptz.goToPreset({ presetId: 'home' })`,` await device.switch.setState({ on: true })`,` await device.brightness.setBrightness({ percentage: 60 })`,` await device.reboot.reboot({})`,``,`Subscribe to slice changes:`,` const off = device.state.battery.subscribe(s => console.log(s))`,` // off() to unsubscribe`,``,`Wait for a state condition:`,` await sm.waitForState(deviceId, 'battery', s => !s.sleeping, 30_000)`,``,`Diagnostics:`,` info.name device name`,` info.addonId which addon owns it`,` info.online transport health`,` sm.dump(deviceId) full debug dump (binding + state + info)`];case`provider`:return[...t,`Pre-bound variables:`,` devices Devices belonging to this provider (raw IDevice[])`,` getIntegration() Integration metadata`,``,`For typed device access use the SystemMirror:`,` await getSystemMirror()`,` sm.getDevicesByAddon('this-addon-id')`];case`addon`:return[...t,`Pre-bound variables:`,` manifest { name, version, ... }`,` declaration addon declaration`,` source addon source location`,``,`Examples:`,` manifest.name`,` manifest.version`]}}function ar({scope:n,greeting:i,className:a}){let o=m(),[s,f]=c(()=>{let e=[];return i&&e.push({id:Q(),kind:`info`,text:i}),e.push({id:Q(),kind:`info`,text:`scope: ${tr(n)} — type help or context for available commands`}),e}),[p,h]=c(``),[g,_]=c([]),[v,y]=c(-1),b=t(null),x=t(null);d(()=>{let e=x.current;e&&(e.scrollTop=e.scrollHeight)},[s]);let S=e(()=>{b.current?.focus()},[]),C=l({mutationFn:e=>o.trpcClient.repl.execute.mutate({code:e,scope:n}),onSuccess:e=>{let t=e??{},n=typeof t.output==`string`?t.output:e==null?`undefined`:typeof e==`string`?e:JSON.stringify(e,null,2),r=t.type===`error`;f(e=>[...e,{id:Q(),kind:r?`error`:`result`,text:n}])},onError:e=>{let t=e instanceof Error?e.message:String(e);f(e=>[...e,{id:Q(),kind:`error`,text:t}])}});function w(e){let t=e.trim();if(t){if(t===`clear`){f([{id:Q(),kind:`info`,text:`scope: ${tr(n)}`}]),h(``);return}if(t===`help`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...nr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`context`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...ir(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}if(t===`examples`){f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`},...rr(n).map(e=>({id:Q(),kind:`info`,text:e}))]),h(``);return}_(e=>[...e,t]),y(-1),f(e=>[...e,{id:Q(),kind:`input`,text:`> ${t}`}]),h(``),C.mutate(t)}}function T(e){if(e.key===`Enter`){e.preventDefault(),w(p);return}if(e.key===`ArrowUp`){if(e.preventDefault(),g.length===0)return;let t=v===-1?g.length-1:Math.max(0,v-1);y(t),h(g[t]??``);return}if(e.key===`ArrowDown`){if(e.preventDefault(),v===-1)return;let t=v+1;t>=g.length?(y(-1),h(``)):(y(t),h(g[t]??``));return}e.ctrlKey&&e.key===`l`&&(e.preventDefault(),f([{id:Q(),kind:`info`,text:`scope: ${tr(n)}`}]))}let E={input:`text-zinc-300`,result:`text-emerald-300`,error:`text-red-300`,info:`text-zinc-400`};return r(`div`,{className:`flex flex-col bg-[#0c0a09] rounded-lg border border-border overflow-hidden font-mono text-xs ${a??``}`,onClick:S,children:[r(`div`,{ref:x,className:`flex-1 overflow-y-auto p-3 space-y-1 min-h-[120px]`,children:[s.map(e=>u(`pre`,{className:`whitespace-pre-wrap break-words leading-relaxed ${E[e.kind]}`,children:e.text},e.id)),C.isPending&&u(`span`,{className:`text-zinc-500 animate-pulse`,children:`…thinking`})]}),r(`div`,{className:`flex items-center gap-2 border-t border-zinc-800 px-3 py-2 bg-[#0c0a09]`,children:[u(`span`,{className:`text-emerald-400 flex-shrink-0 select-none font-bold`,children:`>`}),u(`input`,{ref:b,value:p,onChange:e=>h(e.target.value),onKeyDown:T,disabled:C.isPending,placeholder:`device.state.battery.value`,autoFocus:!0,className:`flex-1 bg-transparent text-zinc-100 placeholder:text-zinc-600 focus:outline-none caret-emerald-400 disabled:opacity-50`,spellCheck:!1,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`})]})]})}function or({deviceId:e,intercomAvailable:t=!1}){let n=m(),r=typeof window<`u`?window.location.origin:``,i=Number.isFinite(e),a=Qn(i?e:null),{streams:s,pipelineMetrics:c,createSession:l,sendAnswer:d,handleOffer:f,getIceServers:p,addIceCandidate:_,getIceCandidates:v,closeSession:y,getSessionState:b}=We(n.trpcClient,i?e:null),S=h(i?e:null,{width:dr}),C=$n(i&&t?e:null),w=C.state===`requesting-mic`||C.state===`starting`||C.state===`connecting`||C.state===`stopping`,T=C.isTalking||w,E=()=>{C.state===`idle`||C.state===`error`?C.start():C.state!==`stopping`&&C.stop()},D=g(),O=x(),k=typeof window<`u`?window.localStorage.getItem(`camstack_admin_token`):null,ee=D.length>0?u(o,{children:D.map(e=>u(`div`,{className:`absolute inset-0`,children:e.node},e.id))}):null;return u(ze,{serverUrl:r,createSession:l,sendAnswer:d,handleOffer:f,getIceServers:p,addIceCandidate:_,getIceCandidates:v,closeSession:y,getSessionState:b,...O.request?{playbackUrl:O.request.url,playbackAuthToken:k,...O.request.label?{playbackLabel:O.request.label}:{},onExitPlayback:()=>O.clear()}:{},streams:s,pipelineMetrics:c,phase:a.phase,detections:a,defaultShowDetections:!0,defaultShowMotion:!0,showPlayStop:!0,snapshotSrc:S.src,...S.src?{posterUrl:S.src}:{},snapshotLoading:S.loading,onRefreshSnapshot:S.refresh,intercomAvailable:t,intercomShown:T,onIntercomToggle:E,extraOverlay:ee,chromeless:!0,className:`h-full`})}function sr({deviceId:e,containerDeviceId:t}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full`,children:u(M,{...t===void 0?{deviceId:e}:{containerDeviceId:t},limit:50,maxHeight:`max-h-full`,showScope:!1,showFilters:!1})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function cr({deviceId:e}){if(!Number.isFinite(e))return r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]});let t=[`CamStack REPL — device #${e}`,``,` device.state.battery.value sync state read`,` await device.snapshot.getSnapshot({}) cap action`,``,` type 'examples' for more, 'context' for the full API`].join(`
|
|
2
2
|
`);return u(ar,{scope:{type:`device`,deviceId:e},greeting:t,className:`h-full border-0 rounded-none`})}function lr({deviceId:e}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:u(F,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}function ur({deviceId:e}){return Number.isFinite(e)?u(`div`,{className:`flex flex-col h-full overflow-y-auto`,children:u(te,{deviceId:e,limit:50,maxHeight:`max-h-full`})}):r(`div`,{className:`flex items-center justify-center h-full text-[11px] text-foreground-subtle italic`,children:[`Device #`,e,` not loaded.`]})}var dr=960;function fr({deviceId:e}){let t=s(),n=Number.isFinite(e),{data:i}=j({deviceId:e},{enabled:n}),a=typeof i?.type==`string`?i.type:`camera`;Fe([`deviceManager`,`getBindings`],[`capability.binding-changed`]);let{data:o,isLoading:c,isError:l,error:d}=z({deviceId:e},{enabled:n}),{data:f}=U({deviceType:a},{enabled:!!a}),p=B({onSuccess:()=>{t.invalidateQueries({queryKey:[[`deviceManager`,`getBindings`]]})}});if(c)return u(`div`,{className:`p-4`,children:u(`div`,{className:`h-20 rounded-lg border border-border bg-surface animate-pulse`})});if(l)return r(`div`,{className:`p-4 text-xs text-red-400`,children:[`Failed to load bindings: `,d instanceof Error?d.message:String(d)]});let m=new Map,h={};for(let e of f??[])h[e.capName]=e.wrappers;for(let e of o?.entries??[])m.set(e.capName,{...e,wrappers:h[e.capName]??[]});for(let e of f??[])m.has(e.capName)||m.set(e.capName,{capName:e.capName,kind:`unbound`,providerAddonId:``,providerNodeId:``,nativeAddonId:``,wrappers:e.wrappers});let g=[...m.values()].toSorted((e,t)=>e.capName.localeCompare(t.capName));if(g.length===0)return r(`div`,{className:`flex flex-col items-center justify-center gap-2 p-8 text-foreground-subtle`,children:[u(yt,{className:`h-8 w-8 opacity-40`}),u(`p`,{className:`text-xs`,children:`No capability providers applicable to this device yet.`}),u(`p`,{className:`text-[10px] opacity-60`,children:`Native providers show up here as soon as the owning addon registers them.`})]});let _=g.filter(e=>e.kind!==`unbound`).length;return r(`div`,{className:`flex flex-col gap-3 p-1`,children:[r(`div`,{className:`text-[11px] text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-foreground`,children:_}),` of `,g.length,` capabilit`,g.length===1?`y`:`ies`,` bound — rows marked `,u(`em`,{children:`unbound`}),` have a wrapper available you can activate.`]}),u(Ae,{columns:[{key:`capability`,header:`Capability`,render:e=>u(`span`,{className:`font-mono text-foreground`,children:e.capName})},{key:`kind`,header:`Kind`,render:e=>u(pr,{kind:e.kind})},{key:`provider`,header:`Active Provider`,render:e=>u(`span`,{className:`font-mono text-foreground-subtle`,children:e.providerAddonId||u(`span`,{className:`opacity-40`,children:`—`})})},{key:`node`,header:`Node`,render:e=>e.providerNodeId?u(mr,{nodeId:e.providerNodeId}):u(`span`,{className:`text-[10px] opacity-40`,children:`—`})},{key:`native`,header:`Native`,render:e=>u(`span`,{className:`font-mono text-foreground-subtle`,children:e.nativeAddonId||u(`span`,{className:`opacity-40`,children:`—`})})},{key:`wrapper`,header:`Wrapper`,render:t=>{let n=t.kind===`wrapped`?t.providerAddonId:null;return u(hr,{wrappers:t.wrappers,activeWrapperId:n,disabled:p.isPending,onPick:r=>{let i=n===r;p.mutate({deviceId:e,capName:t.capName,wrapperAddonId:r,active:!i})}})}}],rows:g,rowKey:e=>e.capName,minWidthPx:720})]})}function pr({kind:e}){return e===`native`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-success/30 text-success bg-success/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(Mt,{className:`h-3 w-3`}),`native`]}):e===`wrapped`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-primary/30 text-primary bg-primary/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(St,{className:`h-3 w-3`}),`wrapped`]}):e===`linked`?r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-warning/30 text-warning bg-warning/5 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(un,{className:`h-3 w-3`}),`linked`]}):r(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-border text-foreground-subtle/70 px-1.5 py-0.5 text-[10px] font-medium`,children:[u(Tt,{className:`h-3 w-3`}),`unbound`]})}function mr({nodeId:e}){return u(`span`,{className:`inline-flex items-center rounded-md border border-border px-1.5 py-0.5 font-mono text-[10px] ${e===`hub`?`text-foreground-subtle`:`text-foreground`}`,children:e})}function hr({wrappers:e,activeWrapperId:t,disabled:n,onPick:i}){return e.length===0?u(`span`,{className:`text-[10px] opacity-40`,children:`none available`}):u(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>{let a=e===t;return r(`button`,{disabled:n,onClick:()=>i(e),title:a?`Click to deactivate (revert to native)`:`Activate wrapper ${e}`,className:`inline-flex items-center gap-1 rounded-md border px-1.5 py-0.5 font-mono text-[10px] transition-colors disabled:opacity-50 ${a?`border-primary/40 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[u(a?$t:At,{className:`h-3 w-3`}),e]},e)})})}function gr({deviceId:e,activeSubTab:t,onSubTabChange:n}){return u(`div`,{className:`flex flex-col gap-3`,children:u(an,{deviceId:e,activeSubTab:t,onSubTabChange:n})})}n();var _r=new Set([`package-detection`]);function vr(e,t){if(!e)return null;for(let n of e.slots)for(let e of n.addons)if(e.id===t)return e;return null}function yr(e){return e?e.modelId!==void 0||e.settings!==void 0:!1}function br({deviceId:e,refreshToken:t}){let n=s(),l=m().trpcClient,[d,f]=c(null),[p,h]=c(null),[g,_]=c(null),v=ee({deviceId:e},{refetchOnMount:`always`}),y=ae({deviceId:e},{refetchOnMount:`always`}),b=he(void 0,{refetchOnMount:`always`});Fe([`nodes`,`topology`],[`agent.online`,`agent.offline`,`agent.unregistered`,`addon.installed`,`addon.uninstalled`]);let x=_e(void 0,{refetchOnMount:`always`}),S=i(()=>{let e=new Set;for(let t of x.data??[])t.isOnline&&e.add(t.id);return e},[x.data]),C=i(()=>(b.data??[]).filter(e=>S.has(e.nodeId)).map(e=>e.nodeId),[b.data,S]),T=C[0]??``,E=V({nodeId:T},{enabled:T!==``,refetchOnMount:`always`}),D=a({enabled:C.length>0,queryKey:[[`pipelineOrchestrator`,`getNodeInferenceDevices`],`device-step`,C.join(`,`),t],queryFn:async()=>{let e={};for(let t of C)try{e[t]=(await l.pipelineOrchestrator.getNodeInferenceDevices.query({nodeId:t})).devices}catch{e[t]=[]}return e}}),O=()=>{n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraSettings`]]}),n.invalidateQueries({queryKey:[[`pipelineOrchestrator`,`getCameraStepOverrides`]]})},k=$e({onSuccess:O}),te=Ue({onSuccess:O}),ne=i(()=>E.data?et(E.data):[],[E.data]),A=i(()=>{let e=b.data??[],t=S.size===0?[]:e.filter(e=>S.has(e.nodeId)),n=[];for(let e of t){let t=(D.data?.[e.nodeId]??[]).filter(e=>e.enabled&&e.available);if(t.length>=2)for(let r of t)n.push({agentNodeId:e.nodeId,engineLabel:r.format,deviceKey:r.key,deviceLabel:Ct(r).label});else n.push({agentNodeId:e.nodeId,engineLabel:t[0]?.format??`(engine unknown)`})}return n},[b.data,D.data,S]),re=(e,t)=>D.data?.[e]?.find(e=>e.key===t)??null,ie=e=>{if(e.deviceKey!==void 0)return e.deviceKey;let t=D.data?.[e.agentNodeId]??[],n=t.filter(e=>e.enabled&&e.available);return n.length>=1?n[0].key:t.find(e=>e.available)?.key??t[0]?.key??null},j=(e,t,n)=>y.data?.[e]?.[t]?.[n]??null,M=e=>{if(_r.has(e))return{kind:`zone-driven`};let t=vr(E.data??null,e)?.enabledByDefault??!0,n=v.data?.stepToggles?.[e];return{kind:`gate`,effectiveOn:n??t,defaultOn:t,explicit:n!==void 0}},N=(e,t)=>{let n=vr(E.data??null,e);if(n)return lt(n,t)},P=(e,t)=>{let n=M(e),r=n.kind===`gate`?n.effectiveOn:!1,i=vr(E.data??null,e),a=ie(t),o=a===null?null:re(t.agentNodeId,a);if(!W(i?.models??[],o?.format))return r?{kind:`skip`}:{kind:`na`};let s=a===null?null:j(t.agentNodeId,a,e),c=o?.steps?.[e];return{kind:`enabled`,modelId:(i?w({catalog:i,device:o,override:s?.modelId,base:c?.modelId}):void 0)??`Auto`,overridden:yr(s)}},F=d&&E.data?vr(E.data,d.addonId):null,I=d?re(d.agentNodeId,d.deviceKey):null,oe=I?.format??`coreml`,L=d?yr(j(d.agentNodeId,d.deviceKey,d.addonId)):!1,se=d?N(d.addonId,I):void 0,R=i(()=>{if(!d||!I)return null;let e=I.steps?.[d.addonId];return{enabled:!0,...e?.modelId===void 0?{}:{modelId:e.modelId},settings:e?.settings??{}}},[d,I]),z=()=>{f(null),h(null)},ce=(e,t)=>{let n=ie(t);n!==null&&(f({addonId:e,agentNodeId:t.agentNodeId,deviceKey:n}),h(j(t.agentNodeId,n,e)))},le=(t,n)=>{te.mutate({deviceId:e,addonId:t,enabled:n})},B=()=>{d&&k.mutate({deviceId:e,agentNodeId:d.agentNodeId,deviceKey:d.deviceKey,addonId:d.addonId,patch:p},{onSuccess:z})},ue=()=>{d&&k.mutate({deviceId:e,agentNodeId:d.agentNodeId,deviceKey:d.deviceKey,addonId:d.addonId,patch:null},{onSuccess:z})};if(b.isLoading||T!==``&&E.isLoading)return u(`div`,{className:`text-xs text-foreground-subtle animate-pulse p-4`,children:`Loading pipeline…`});if(A.length===0)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`No online agents.`});if(!E.data)return u(`div`,{className:`text-xs text-foreground-subtle p-4`,children:`Catalog unavailable.`});let de=d!==null&&F!==null&&I!==null;return r(`div`,{className:`relative h-full w-full space-y-3`,children:[r(`div`,{className:`rounded-md border border-border bg-muted/20 px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-foreground`,children:`Gate`}),` (col 1) decides whether this camera runs a step — independent of nodes. Each`,` `,u(`span`,{className:`font-medium text-foreground`,children:`node column`}),` shows the model that node runs; click a cell to pin a per-camera model override for that accelerator. A gated-on step with no model on a device shows a clickable `,u(`span`,{className:`text-amber-500`,children:`⚠ skip`}),` `,`and won't run there.`]}),r(`div`,{className:`rounded-md border border-sky-500/25 bg-sky-500/[0.06] px-3 py-2 text-[11px] leading-relaxed text-foreground-subtle`,children:[u(`span`,{className:`font-medium text-sky-400`,children:`Placement is dynamic.`}),` When a node has multiple inference accelerators, each session is balanced across them per-session at dispatch time — these device columns show each accelerator's effective model (override ?? device default), not a fixed assignment.`]}),u(`div`,{className:de?`md:pr-[360px]`:``,children:ne.length>0?u(Ce,{tree:ne,agents:A,gateFor:M,getCellState:P,onCellClick:ce,selectedCell:d,onSetGate:le,gateBusy:te.isPending,fallbackNodeId:g,onFallbackNodeChange:_}):u(`div`,{className:`text-xs text-foreground-subtle`,children:`Catalog empty.`})}),u(De,{open:de,onClose:z,title:F?.name??``,subtitle:d&&I?`${d.agentNodeId} · ${Ct(I).label} · ${I.format}`:``,footer:r(o,{children:[u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted text-foreground-subtle disabled:opacity-50`,disabled:!L||k.isPending,onClick:ue,children:`Clear override`}),u(`div`,{className:`flex-1`}),u(`button`,{type:`button`,className:`px-3 py-1 text-xs border border-border rounded bg-surface hover:bg-muted`,onClick:z,children:`Cancel`}),u(`button`,{type:`button`,disabled:!d||!R||k.isPending,className:`px-3 py-1 text-xs bg-primary text-primary-foreground rounded disabled:opacity-50`,onClick:B,children:k.isPending?`Saving…`:`Save`})]}),children:F&&d&&R?u(fe,{mode:`device`,addon:F,agentDefault:R,agentNodeId:d.agentNodeId,currentPatch:p,engineFormat:oe,effectiveModelId:se,onChangePatch:h}):u(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-300`,children:`This accelerator is no longer reported by the node, so there is nothing to provision here.`})})]})}var xr=[{id:`object-detection`,label:`Object detection`,icon:`scan-search`},{id:`tracking`,label:`Tracking`,icon:`route`},{id:`motion`,label:`Motion`,icon:`activity`},{id:`stationary`,label:`Stationary`,icon:`square-parking`},{id:`zones`,label:`Zones`,icon:`shapes`},{id:`audio`,label:`Audio`,icon:`volume-2`},{id:`cluster`,label:`Cluster`,icon:`server`}],Sr={"pipeline-object-detection":`object-detection`,"detection-sensitivity":`object-detection`,"onboard-object-detection":`object-detection`,tracking:`tracking`,"tracking-core":`tracking`,"motion-tuning":`motion`,"stationary-objects":`stationary`,occupancy:`stationary`,zones:`zones`,"pipeline-audio":`audio`,"cluster-assignment":`cluster`,"orchestrator-live":`cluster`};function Cr(e){return Sr[e]??`object-detection`}n();var wr=`steps`,Tr=`settings`,Er=new Set([wr,Tr]);function Dr(e){return e.location===`top-tab`&&(e.tab===`detection-pipeline`||e.tab===`zones`)}function Or({deviceId:t,activeSubTab:n,onSubTabChange:i}){return r(Ee,{value:n&&Er.has(n)?n:wr,onValueChange:e(e=>{i?.(e)},[i]),className:`flex flex-col`,children:[r(tt,{className:`flex-shrink-0`,children:[u(Oe,{value:wr,children:`Steps`}),u(Oe,{value:Tr,children:`Settings`})]}),u(Ve,{value:wr,children:u(br,{deviceId:t,refreshToken:0})}),u(Ve,{value:Tr,children:u(an,{deviceId:t,sectionFilter:Dr,subTabGrouping:{groupOf:e=>Cr(e.id),tabs:xr}})})]})}function $({label:e,value:t}){return r(`div`,{className:`${v} flex items-start gap-2 sm:gap-3`,children:[u(`span`,{className:`w-20 sm:w-28 flex-shrink-0 text-[11px] text-foreground-subtle`,children:e}),u(`div`,{className:`flex-1 min-w-0 text-[11px] text-foreground`,children:t})]})}n();function kr({deviceId:e,initialName:n}){let i=s(),[a,o]=c(!1),[l,f]=c(n),[p,m]=c(!1),h=t(null);d(()=>{a||f(n)},[n,a]),d(()=>{a&&h.current?.focus()},[a]);let g=q({onSuccess:()=>{i.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),i.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),i.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]})}}),_=async()=>{let t=l.trim();if(t.length===0||t===n){o(!1),f(n);return}m(!0);try{await g.mutateAsync({deviceId:e,name:t}),o(!1)}catch{}finally{m(!1)}},v=()=>{f(n),o(!1)};return a?u($,{label:`Name`,value:r(`div`,{className:`flex items-center gap-1`,children:[u(`input`,{ref:h,type:`text`,value:l,onChange:e=>f(e.target.value),onKeyDown:e=>{e.key===`Enter`?_():e.key===`Escape`&&v()},disabled:p,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u(`button`,{type:`button`,onClick:()=>void _(),disabled:p,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:u($t,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:v,disabled:p,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:u(Jt,{className:`h-3 w-3`})})]})}):u($,{label:`Name`,value:r(`div`,{className:`flex items-center gap-2 group`,children:[u(`span`,{className:`truncate`,children:n}),u(`button`,{type:`button`,onClick:()=>o(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit name`,children:u(Dt,{className:`h-3.5 w-3.5`})})]})})}n();function Ar({deviceId:e,initialLocation:n}){let a=s(),[o,l]=c(!1),[f,p]=c(n??``),[m,h]=c(!1),g=t(null),{data:_}=re(void 0,{enabled:o}),v=_??[];d(()=>{o||p(n??``)},[n,o]),d(()=>{o&&g.current?.focus()},[o]);let y=N({onSuccess:()=>{a.invalidateQueries({queryKey:[[`deviceManager`,`getDevice`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listAll`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`getDeviceAggregate`]]}),a.invalidateQueries({queryKey:[[`deviceManager`,`listLocations`]]})}}),b=i(()=>{let e=f.trim().toLowerCase();return e.length===0?v:v.filter(t=>t.toLowerCase()!==e&&t.toLowerCase().includes(e))},[v,f]),x=f.trim().length>0&&!v.some(e=>e.toLowerCase()===f.trim().toLowerCase()),S=async t=>{let r=(t??f).trim(),i=r.length===0?null:r;if(i===(n??null)){l(!1);return}h(!0);try{await y.mutateAsync({deviceId:e,location:i}),l(!1)}catch{}finally{h(!1)}},C=()=>{p(n??``),l(!1)};return o?u($,{label:`Location`,value:r(`div`,{className:`relative`,children:[r(`div`,{className:`flex items-center gap-1`,children:[u(`input`,{ref:g,type:`text`,value:f,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`?S():e.key===`Escape`&&C()},disabled:m,placeholder:`Room / area (or leave empty to clear)`,className:`flex-1 min-w-0 px-1.5 py-0.5 text-[11px] bg-background border border-border rounded focus:outline-none focus:border-primary`}),u(`button`,{type:`button`,onClick:()=>void S(),disabled:m,className:`p-0.5 rounded hover:bg-success/10 text-success disabled:opacity-50`,"aria-label":`Save`,children:u($t,{className:`h-3 w-3`})}),u(`button`,{type:`button`,onClick:C,disabled:m,className:`p-0.5 rounded hover:bg-danger/10 text-danger disabled:opacity-50`,"aria-label":`Cancel`,children:u(Jt,{className:`h-3 w-3`})})]}),(b.length>0||x)&&r(`div`,{className:`absolute z-10 left-0 right-0 mt-0.5 max-h-40 overflow-y-auto rounded-md border border-border bg-surface shadow-md`,children:[b.map(e=>r(`button`,{type:`button`,onClick:()=>{p(e),S(e)},className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover`,children:[u(Et,{className:`h-3 w-3 text-foreground-subtle flex-shrink-0`}),u(`span`,{className:`truncate`,children:e})]},e)),x&&r(`button`,{type:`button`,onClick:()=>void S(),className:`w-full flex items-center gap-2 px-2 py-1 text-left text-[11px] hover:bg-surface-hover border-t border-border`,children:[u(`span`,{className:`text-foreground-subtle`,children:`Create`}),r(`span`,{className:`font-medium truncate`,children:[`"`,f.trim(),`"`]})]})]})]})}):u($,{label:`Location`,value:r(`div`,{className:`flex items-center gap-2 group`,children:[n?u(`span`,{className:`truncate`,children:n}):u(`span`,{className:`italic text-foreground-subtle`,children:`unset`}),u(`button`,{type:`button`,onClick:()=>l(!0),className:`p-0.5 rounded text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,"aria-label":`Edit location`,children:u(Dt,{className:`h-3.5 w-3.5`})})]})})}n();function jr({deviceId:e}){let t=s(),{data:n}=wt(e),{data:i}=xt(e),[a,l]=c(null),d=ge({onSuccess:()=>{l(null),t.invalidateQueries({queryKey:[[`deviceManager`]]})},onError:e=>{l(`Could not change primary child: ${e.message}`)}});if(n==null||String(n.type??``)!==Y.Container)return null;let f=(i??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,name:e.name,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}}));if(f.length<=1)return null;let p=de(f,typeof n.linkDeviceId==`number`?n.linkDeviceId:null,typeof n.primaryChildEntityId==`string`?n.primaryChildEntityId:null);return r(o,{children:[u($,{label:`Primary child`,value:u(ie,{childrenList:f,selectedId:p===null?f[0].id:p.id,onSetPrimary:t=>d.mutate({deviceId:e,primaryChildEntityId:t}),disabled:d.isPending})}),a!==null&&u(`p`,{role:`alert`,className:`px-3 sm:px-4 py-1.5 text-[11px] text-danger`,children:a})]})}n();var Mr=[`manufacturer`,`model`,`hardware`,`firmware`,`serialNumber`,`uid`,`mac`,`itemNo`];function Nr(e){return e.replace(/([a-z])([A-Z])/g,`$1 $2`).replace(/^./,e=>e.toUpperCase())}function Pr(e){return e==null?`—`:typeof e==`string`||typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Fr(){let e=Ge(),t=Qe(),{data:n}=j({deviceId:e??0},{enabled:e!==null}),{data:i}=z({deviceId:e??0},{enabled:e!==null}),a=n??t??null,[o,s]=c(`identity`);if(e===null||!a)return null;let l=String(a.stableId??``),d=String(a.name??``),f=String(a.type??``),p=String(a.addonId??``),m=a.features??[],h=new Set([`device-status`,`feature-probe`,`device-ops`]),g=(i?.entries??[]).filter(e=>e.kind===`native`&&!h.has(e.capName)).map(e=>e.capName),_=m.length>0?m:g,v=a.location??null,y=a.metadata??null,b=y!==null&&Object.keys(y).length>0;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-3 sm:px-4 py-2 flex items-center justify-between gap-3`,children:[u(`h2`,{className:`text-[11px] font-semibold text-foreground uppercase tracking-wider`,children:`Device Info`}),b&&r(`div`,{className:`flex items-center gap-1 rounded-md bg-surface-hover p-0.5`,children:[u(Ir,{active:o===`identity`,onClick:()=>s(`identity`),label:`Identity`}),u(Ir,{active:o===`hardware`,onClick:()=>s(`hardware`),label:`Hardware`})]})]}),(!b||o===`identity`)&&r(`div`,{className:`divide-y divide-border`,children:[u($,{label:`ID`,value:r(`span`,{className:`font-mono text-[11px] text-foreground`,children:[`#${e}`,r(`span`,{className:`ml-1.5 text-foreground-subtle`,children:[`(`,l,`)`]})]})}),u(kr,{deviceId:e,initialName:d}),u(Ar,{deviceId:e,initialLocation:v}),u(jr,{deviceId:e}),u($,{label:`Type`,value:f}),u($,{label:`Provider`,value:u(bt,{type:p,size:`sm`,showLabel:!0})}),u($,{label:`Capabilities`,value:_.length>0?u(gt,{capabilities:_,showLabels:!0}):u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`None`})})]}),b&&o===`hardware`&&u(Lr,{metadata:y})]})}function Ir({active:e,onClick:t,label:n}){return u(`button`,{type:`button`,onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${e?`bg-surface text-foreground shadow-sm`:`text-foreground-subtle hover:text-foreground`}`,children:n})}function Lr({metadata:e}){let t=Mr.filter(t=>t in e),n=Object.keys(e).filter(e=>!Mr.includes(e)).toSorted(),i=[...t,...n];return r(`div`,{children:[u(`div`,{className:`px-3 sm:px-4 py-1.5 text-[10px] text-foreground-subtle border-b border-border bg-surface-subtle/40`,children:`Auto-populated by the driver on every connect. Read-only.`}),u(`div`,{className:`divide-y divide-border`,children:i.map(t=>u($,{label:Nr(t),value:u(`span`,{className:`font-mono text-[11px] text-foreground break-all`,children:Pr(e[t])})},t))})]})}var Rr=`Notifications`,zr=`This camera never notifies — no rule, no target, no alarm. Existing events, tracks and recordings are unaffected.`;function Br(e){let{mutedDeviceIds:t,deviceId:n}=e,r=t===null?null:!t.includes(n),i=e.pendingOn??null;return{label:Rr,on:r===null?null:i??r,available:r!==null,costWhenOff:zr}}function Vr(e,t){return!e.available||e.on===null?null:{deviceId:t,muted:e.on}}n();function Hr(e){if(typeof e!=`object`||!e)return null;let t={...e}.mutedDeviceIds;return Array.isArray(t)?t.filter(e=>typeof e==`number`):null}function Ur({deviceId:t}){let n=s(),i=Number.isFinite(t),[a,o]=c(null),[l,d]=c(null),f=Br({mutedDeviceIds:Hr(b({},{enabled:i}).data),deviceId:t,pendingOn:l}),p=ke({onError:e=>{console.error(`[DeviceNotificationMute] mute write failed — reverting`,{tags:{deviceId:t},meta:{error:e instanceof Error?e.message:String(e)}}),d(null),o(e instanceof Error?e.message:String(e)),n.invalidateQueries({queryKey:[[`notificationRules`,`listDeviceMutes`]]})},onSuccess:()=>{o(null),d(null),n.invalidateQueries({queryKey:[[`notificationRules`]]})}}),m=e(()=>{let e=Vr(f,t);e!==null&&(d(!e.muted),p.mutate(e))},[t,p,f]),h=f.on===null,g=f.on===!1,_=g?_t:vt;return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2 flex items-center justify-between gap-2`,children:[u(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Notifications`}),g&&u(`span`,{className:`rounded bg-warning/20 px-1.5 py-0.5 text-[9px] font-semibold uppercase tracking-wide text-warning`,children:`muted`})]}),r(`div`,{className:`px-4 py-3 flex items-start gap-3`,children:[r(`button`,{type:`button`,role:`switch`,"aria-label":f.label,"aria-checked":f.on===!0,disabled:!f.available||p.isPending,onClick:m,title:h?`Notification mute — state unknown; the notification centre did not answer.`:g?`Muted. ${f.costWhenOff}`:`Notifying. Muting it: ${f.costWhenOff}`,className:`inline-flex items-center gap-1.5 rounded-lg border px-2 py-1.5 text-[11px] font-medium transition-colors disabled:cursor-not-allowed ${a===null?h?`border-dashed border-border text-foreground-subtle/50`:g?`border-warning/40 text-warning hover:bg-warning/10`:`border-success/30 text-success hover:bg-success/10`:`border-danger/50 text-danger bg-danger/5`}`,children:[u(_,{className:`h-3.5 w-3.5`}),u(`span`,{children:h?`Unknown`:g?`Muted`:`Notifying`})]}),u(`p`,{className:`flex-1 text-[11px] leading-relaxed text-foreground-subtle`,children:a===null?h?`The notification centre did not answer, so this device’s mute state is unknown.`:f.costWhenOff:`Write failed: ${a}`})]})]})}n();function Wr({deviceId:e}){let[t,n]=c(null),i=at({onSuccess:e=>{n(e.changed?`Re-aligned with source — ${e.rebuiltChildren} child${e.rebuiltChildren===1?``:`ren`} rebuilt.`:`Already up to date.`)},onError:e=>n(`Re-sync failed: ${e.message}`)});return r(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3`,children:[r(`div`,{className:`flex items-center justify-between gap-3`,children:[r(`div`,{children:[u(`h2`,{className:`text-xs font-semibold uppercase tracking-wider text-foreground`,children:`Re-sync`}),u(`p`,{className:`mt-0.5 text-[11px] text-foreground-subtle`,children:`Re-align this device's type, role, capabilities and units with its source.`})]}),r(`button`,{type:`button`,disabled:i.isPending,onClick:()=>{n(null),i.mutate({camDeviceId:e})},className:`inline-flex shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-3 py-1.5 text-xs font-medium text-foreground hover:bg-surface disabled:opacity-50`,children:[u(kt,{className:`h-3 w-3 ${i.isPending?`animate-spin`:``}`}),i.isPending?`Re-syncing…`:`Re-sync`]})]}),t!==null&&u(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:t})]})}n();var Gr={icon:``,label:``,unit:``,precision:``,hidden:!1};function Kr(e){return{icon:e?.icon??``,label:e?.label??``,unit:e?.unit??``,precision:e?.precision===void 0?``:String(e.precision),hidden:e?.hidden===!0}}function qr(e){if(typeof e!=`object`||!e)return;let t=e.unit;return typeof t==`string`?t:void 0}function Jr(e){let t=e.precision.trim()===``?void 0:Number.parseInt(e.precision,10),n={...e.icon===``?{}:{icon:e.icon},...e.label.trim()===``?{}:{label:e.label.trim()},...e.unit===``?{}:{unit:e.unit},...t!==void 0&&Number.isFinite(t)?{precision:t}:{},...e.hidden?{hidden:!0}:{}};return Object.keys(n).length===0?null:n}function Yr({deviceId:e}){let t=m(),n=s(),{data:a}=j({deviceId:e},{enabled:e>0}),o=typeof a?.role==`string`?a.role:null,l=o===null?void 0:G[o],d=l?.kind===`numeric`,f=Xe(t.trpcClient,e,o??``),p=l?.kind===`numeric`?l.canonicalUnit:void 0,h=qr(f)??p,g=h===void 0?void 0:ht(h),_=i(()=>g===void 0?[]:pt(g),[g]),[v,y]=c(null),b=v??Kr(a?.display),x=Ye({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}}),{data:S}=ct({},{staleTime:6e4}),C=ve({onSuccess:()=>{n.invalidateQueries({queryKey:[[`deviceManager`]]})}});if(a===void 0||o===null)return null;let w=e=>{y({...b,...e})},T=()=>{x.mutate({deviceId:e,display:Jr(b)})},E=()=>{y(Gr),x.mutate({deviceId:e,display:null})},D=()=>{let e={...b.icon===``?{}:{icon:b.icon},...b.unit===``?{}:{unit:b.unit},...b.precision.trim()!==``&&Number.isFinite(Number.parseInt(b.precision,10))?{precision:Number.parseInt(b.precision,10)}:{}},t={...S?.defaults,[o]:e};C.mutate({defaults:t})},O=le(o).label,k=Object.keys(L);return r(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[u(`div`,{className:`border-b border-border px-4 py-2`,children:u(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Display`})}),r(`div`,{className:`p-4 space-y-3`,children:[r(`label`,{className:`block`,children:[u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Icon`}),r(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:b.icon,onChange:e=>w({icon:e.target.value}),children:[r(`option`,{value:``,children:[`Default (`,O,`)`]}),k.map(e=>u(`option`,{value:e,children:e},e))]})]}),r(`label`,{className:`block`,children:[u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Label`}),u(`input`,{type:`text`,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:O,value:b.label,onChange:e=>w({label:e.target.value})})]}),d&&r(`div`,{className:`grid grid-cols-2 gap-3`,children:[r(`label`,{className:`block`,children:[u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Unit`}),r(`select`,{className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,value:b.unit,onChange:e=>w({unit:e.target.value}),disabled:_.length===0,children:[r(`option`,{value:``,children:[`Source`,h?` (${h})`:``]}),_.map(e=>u(`option`,{value:e,children:e},e))]})]}),r(`label`,{className:`block`,children:[u(`span`,{className:`text-[11px] text-foreground-subtle`,children:`Precision`}),u(`input`,{type:`number`,min:0,max:10,step:1,className:`mt-1 w-full rounded border border-border bg-surface px-2 py-1 text-sm text-foreground`,placeholder:`inherit`,value:b.precision,onChange:e=>w({precision:e.target.value})})]})]}),r(`label`,{className:`flex items-center gap-2`,children:[u(`input`,{type:`checkbox`,checked:b.hidden,onChange:e=>w({hidden:e.target.checked})}),u(`span`,{className:`text-sm text-foreground`,children:`Hide from device lists`})]}),r(`div`,{className:`flex flex-wrap items-center gap-2 pt-1`,children:[u(`button`,{type:`button`,className:`rounded bg-primary px-3 py-1 text-sm font-medium text-primary-foreground disabled:opacity-50`,onClick:T,disabled:x.isPending,children:`Save`}),u(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:E,disabled:x.isPending,children:`Reset`}),r(`button`,{type:`button`,className:`rounded border border-border px-3 py-1 text-sm text-foreground-subtle`,onClick:D,disabled:C.isPending,title:`Apply this unit / precision / icon as the default for every ${O} sensor`,children:[`Set as default for all `,O,` sensors`]})]})]})]})}function Xr(e){return e<1e3?`${e.toFixed(0)} kbps`:`${(e/1e3).toFixed(1)} Mbps`}function Zr({device:e}){let t=It(),n=typeof e.id==`number`?e.id:null,i=String(e.type??``),a=i===Y.Camera,o=i===Y.Hub,s=typeof e.role==`string`&&e.role.length>0,c=e.features??[],l=c.includes(mt.Resyncable),{data:d}=K({deviceId:n??0},{enabled:n!==null&&a,refetchInterval:5e3}),f=d?.streams??{},p=Object.entries(f),m=c.includes(mt.DoorbellButton),h=J(m?{deviceId:n??void 0,historyLimit:10}:void 0),g=h.latest?Date.now()-h.latest.timestamp<3e4:!1;return r(`div`,{className:`space-y-5`,children:[o&&n!==null&&u(ot,{deviceId:n,onOpenChild:e=>t(`/devices/${e}`)}),l&&n!==null&&u(Wr,{deviceId:n}),n!==null&&u(Ur,{deviceId:n}),a&&n!==null&&u(P,{widgetId:`pipeline-orchestrator/pipeline-quick-stats`,host:`device-tab`,deviceId:n}),m&&u(nt,{history:h.history,latestIsFresh:g}),a&&n!==null&&u(P,{widgetId:`stream-broker/stream-broker-panel`,host:`device-tab`,deviceId:n}),a&&p.length>0&&r(`div`,{className:`@container rounded-lg border border-border bg-surface overflow-hidden`,style:{containerType:`inline-size`},children:[u(`div`,{className:`border-b border-border px-4 py-2`,children:u(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:`Stream Network`})}),u(`div`,{className:`divide-y divide-border`,children:p.map(([e,t])=>r(`div`,{className:`px-4 py-2.5`,children:[r(`div`,{className:`flex items-center gap-2 mb-2`,children:[u(Nt,{className:`h-3 w-3 text-foreground-subtle`}),u(`span`,{className:`text-[11px] font-medium text-foreground`,children:e})]}),r(`div`,{className:`grid grid-cols-2 @[640px]:grid-cols-4 gap-2`,children:[u(Qr,{label:`Nominal`,value:Xr(t.nominalBitrateKbps??0)}),u(Qr,{label:`Observed`,value:Xr(t.observedBitrateKbps??0)}),u(Qr,{label:`Peak`,value:Xr(t.peakBitrateKbps??0)}),u(Qr,{label:`Packet Loss`,value:`${(t.packetLossPercent??0).toFixed(2)}%`,warning:(t.packetLossPercent??0)>1})]})]},e))})]}),u(Fr,{}),s&&n!==null&&u(Yr,{deviceId:n})]})}function Qr({label:e,value:t,warning:n}){return r(`div`,{children:[u(`p`,{className:`text-[10px] text-foreground-subtle`,children:e}),u(`p`,{className:`text-xs font-medium ${n?`text-warning`:`text-foreground`}`,children:t})]})}n();var $r=[{id:`overview`,label:`Overview`,cameraOnly:!1},{id:`config`,label:`Config`,cameraOnly:!1},{id:`detection-pipeline`,label:`Detection pipeline`,cameraOnly:!0},{id:`bindings`,label:`Bindings`,cameraOnly:!0}];function ei(e){let t=e===Y.Camera;return $r.filter(e=>t||!e.cameraOnly).map(({id:e,label:t})=>({id:e,label:t}))}var ti=[{id:`logs`,icon:Yt,label:`Logs`},{id:`repl`,icon:Gt,label:`REPL`},{id:`events`,icon:zt,label:`Events`},{id:`state`,icon:Lt,label:`State`}];function ni(){let n=Ht(),a=Number(n.deviceId),l=Number.isFinite(a),d=It(),f=s(),h=Be(),g=m(),[v,y]=Vt(),b=v.get(`tab`)??`overview`,x=v.get(`sub`),[S,w]=c(`logs`),E=`device-detail.left-col-width-px`,[O,k]=c(()=>{if(typeof window>`u`)return null;let e=window.localStorage.getItem(E),t=e?Number(e):NaN;return Number.isFinite(t)&&t>0?t:null}),ee=t(O);ee.current=O;function te(e){e.preventDefault();let t=e.clientX,n=e.currentTarget.previousElementSibling?.getBoundingClientRect().width??O??0,r=Math.max(330,Math.floor(window.innerWidth*.7)),i=e=>{k(Math.max(280,Math.min(r,n+(e.clientX-t))))},a=()=>{document.removeEventListener(`mousemove`,i),document.removeEventListener(`mouseup`,a);let e=ee.current;if(e!==null)try{window.localStorage.setItem(E,String(Math.round(e)))}catch{}document.body.style.userSelect=``,document.body.style.cursor=``};document.body.style.userSelect=`none`,document.body.style.cursor=`col-resize`,document.addEventListener(`mousemove`,i),document.addEventListener(`mouseup`,a)}let{data:A,isLoading:re,isError:ie}=j({deviceId:a},{enabled:l,refetchInterval:5e3,retry:1}),{data:M}=oe({deviceId:a},{enabled:l}),N=i(()=>{let e=M?.settings?.sections??[],t=M?.live?.sections??[],n=[...e,...t],r=new Set;for(let e of n)e.location===`top-tab`&&e.tab&&r.add(e.tab===`zones`?`detection-pipeline`:e.tab);return n.some(tn)&&r.add(nn),[...r].map(e=>e===`export`?{id:e,label:rn,isAddonContrib:!0}:{id:e,label:ut[e]?.label??e,isAddonContrib:!0})},[M]),P=A,F=String(P?.name??n.deviceId??`Device`),I=P?.online===!0,ae=I?`online`:`offline`,L=String(P?.addonId??`rtsp`),R=P?.features??[],z=P?.type,ce=z===Y.Camera,{data:le}=xt(l?a:0),B=z===Y.Container,fe=i(()=>(le??[]).map(e=>({id:e.id,stableId:e.stableId,type:e.type,...e.sourceInfo?{sourceInfo:{id:e.sourceInfo.id}}:{}})),[le]),V=i(()=>B?de(fe,typeof P?.linkDeviceId==`number`?P.linkDeviceId:null,typeof P?.primaryChildEntityId==`string`?P.primaryChildEntityId:null)?.id??null:null,[B,fe,P?.linkDeviceId,P?.primaryChildEntityId]),{data:pe}=oe({deviceId:V??0},{enabled:V!==null}),me=i(()=>{if(V===null)return[];let e=pe?.settings?.sections??[],t=pe?.live?.sections??[],n=new Set;for(let r of[...e,...t])r.location===`top-tab`&&r.tab&&n.add(r.tab);return[...n].map(e=>({id:e,label:ut[e]?.label??e,isAddonContrib:!0,childDeviceId:V}))},[V,pe]),H=typeof P?.parentDeviceId==`number`?P.parentDeviceId:null,{data:U}=j({deviceId:H??0},{enabled:H!==null}),W=Ne(),G=P?.disabled!==!0,he=i(()=>{let e=new Set,t=[];for(let n of[...ei(z),...N,...me])e.has(n.id)||(e.add(n.id),t.push(n));return t},[z,N,me]),K=i(()=>he.some(e=>e.id===b)?b:`overview`,[he,b]),ge=e(e=>{y(t=>{let n=new URLSearchParams(t);return e===`overview`?n.delete(`tab`):n.set(`tab`,e),n.delete(`sub`),n},{replace:!0})},[y]),q=e(e=>{y(t=>{let n=new URLSearchParams(t);return n.set(`sub`,e),n},{replace:!0})},[y]),_e=(le??[]).length>0,ve=i(()=>ti.filter(({featureGate:e})=>!e||R.includes(e)),[R]),{data:J}=rt({addonId:L},{enabled:!!L&&L!==`rtsp`}),Ce=ne({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]}),d(J?.id?`/integrations/${J.id}`:`/integrations`)}}),Ee=se({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),De=D({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Oe=T(),ke=Ie({onSuccess:()=>{f.invalidateQueries({queryKey:[[`deviceManager`]]})}}),Ae=R.includes(mt.Rebootable),je=R.includes(mt.BatteryOperated),Me=Le(g.trpcClient,je&&l?a:null),[Pe,Fe]=c(!1),Re=p(g.trpcClient,l?a:null),ze=async()=>{if(!(Pe||!Re)){Fe(!0);try{await Re.snapshot?.invalidateCache({});let e=await Re.snapshot?.getSnapshot({});if(!e)return;let t=`data:${e.contentType};base64,${e.base64}`,n=e.contentType.includes(`png`)?`png`:`jpg`,r=F.replace(/[^a-zA-Z0-9_.-]+/g,`_`),i=new Date().toISOString().replace(/[:.]/g,`-`),a=document.createElement(`a`);a.href=t,a.download=`${r}-${i}.${n}`,document.body.appendChild(a),a.click(),document.body.removeChild(a)}finally{Fe(!1)}}},Ve=Ee.isPending||De.isPending,{data:He}=C({deviceId:a},{enabled:l,refetchInterval:1e4}),Ue=He?.agentNodeId??null,We=typeof Ue==`string`&&Ue.length>0&&!Ue.startsWith(`addon:`)?Ue:void 0,{data:Ge}=Te({deviceId:a,...We?{nodeId:We}:{}},{enabled:l,refetchInterval:3e3,retry:!1}),{data:qe}=Je({deviceId:a},{enabled:l,refetchInterval:3e3,retry:!1}),Ye=qe?.level?.dbfs??null;function Xe(){if(!l)return null;switch(K){case`overview`:return u(Zr,{device:P??{}});case`config`:return u(gr,{deviceId:a,activeSubTab:x,onSubTabChange:q});case`detection-pipeline`:return u(Or,{deviceId:a,activeSubTab:x,onSubTabChange:q});case`bindings`:return u(fr,{deviceId:a});default:{let e=K,t=N.some(t=>t.id===e),n=me.find(t=>t.id===e);if(!t&&n===void 0)return null;let r=n?.childDeviceId??a;if(e===`export`)return u(an,{deviceId:a,sectionFilter:tn,activeSubTab:x,onSubTabChange:q});let i=u(an,{deviceId:r,sectionFilter:t=>t.location===`top-tab`&&(t.tab===e||e===`detection-pipeline`&&t.tab===`zones`),flattenSubTabs:e===`detection-pipeline`,activeSubTab:x,onSubTabChange:q});return n!==void 0&&r!==a?u(xe,{deviceId:r,children:i}):i}}}return l?re?r(`div`,{className:`flex flex-col h-full`,children:[r(`div`,{className:`border-b border-border bg-surface px-6 py-4`,children:[u(`div`,{className:`h-4 w-48 rounded bg-surface-hover animate-pulse mb-3`}),u(`div`,{className:`h-8 w-64 rounded bg-surface-hover animate-pulse`})]}),u(`div`,{className:`flex-1 p-6`,children:u(`div`,{className:`h-40 rounded-lg border border-border bg-surface animate-pulse`})})]}):ie||!A?r(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[u(`p`,{className:`text-lg font-semibold text-foreground`,children:`Device not found`}),r(`p`,{className:`text-xs`,children:[`No device with ID`,` `,r(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:[`#`,a]})]}),u(`button`,{onClick:()=>d(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]}):r(`div`,{className:`absolute inset-0 flex flex-col overflow-hidden`,children:[r(`div`,{className:`border-b border-border bg-surface px-6 py-3 flex-shrink-0`,children:[u(`div`,{className:`mb-2`,children:u(Se,{items:[{label:`Integrations`,onClick:()=>d(`/integrations`)},{label:J?.name??L,onClick:()=>J?.id&&d(`/integrations/${J.id}`)},{label:F}]})}),r(`div`,{className:`flex items-center gap-2 sm:gap-3`,children:[u(bt,{type:L,size:`lg`}),r(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[u(`h1`,{className:`text-sm sm:text-base font-semibold text-foreground truncate`,children:F}),u(en,{status:ae}),je&&u(Ke,{status:Me,variant:`full`})]}),H!==null&&U&&r(`button`,{type:`button`,onClick:()=>d(`/devices/${H}`),className:`text-[10px] text-foreground-subtle hover:text-primary transition-colors mt-0.5 inline-flex items-center gap-1`,title:`Open parent device ${U.name}`,children:[u(`span`,{children:`↑`}),u(`span`,{className:`truncate`,children:String(U.name??`Device #${H}`)})]}),u(`div`,{className:`hidden md:flex items-center gap-3 mt-0.5 text-[10px] text-foreground-subtle`,children:R.length>0&&u(gt,{capabilities:R})})]}),Ge&&u(`div`,{className:`hidden lg:flex`,children:u(ri,{metrics:Ge,dbfs:Ye})}),r(`div`,{className:`flex items-center gap-1 shrink-0`,children:[r(`button`,{onClick:async()=>{G?await h({title:`Disable "${F}"?`,message:`The device will stop processing streams and events. You can re-enable it later.`,confirmLabel:`Disable`,variant:`danger`})&&De.mutate({deviceId:a}):Ee.mutate({deviceId:a})},disabled:Ve,title:G?`Disable device`:`Enable device`,className:`inline-flex items-center gap-1.5 rounded-lg px-2 sm:px-2.5 py-1.5 text-[11px] font-medium border transition-colors disabled:opacity-50 ${G?`border-success/30 text-success hover:bg-success/10`:`border-border text-foreground-subtle/50 hover:text-foreground hover:bg-surface-hover`}`,children:[u(Ot,{className:`h-3.5 w-3.5`}),u(`span`,{className:`hidden sm:inline`,children:Ve?`Updating…`:G?`Enabled`:`Disabled`})]}),u(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`}),ce&&r(o,{children:[u(Tn,{deviceId:a}),u(`div`,{className:`hidden sm:block h-5 w-px bg-border mx-1`})]}),u(be,{triggerClassName:`ml-1`,items:[{id:`snapshot`,label:`Take snapshot`,description:`Fetch a fresh frame and download it.`,icon:Bt,disabled:Pe,onClick:()=>{ze()}},{id:`reboot`,label:`Reboot device`,description:`Camera goes offline for ~30 seconds.`,icon:jt,hidden:!Ae,disabled:Oe.isPending,danger:!0,onClick:async()=>{await h({title:`Reboot "${F}"?`,message:`The camera will go offline for around 30 seconds while the firmware reboots.`,confirmLabel:`Reboot`,variant:`danger`})&&Oe.mutate({deviceId:a})}},{id:`restart-addon`,label:`Restart addon`,description:`Bounces every device served by ${J?.name??L}.`,icon:kt,disabled:ke.isPending,danger:!0,onClick:async()=>{await h({title:`Restart "${J?.name??L}"?`,message:`Restarting the addon will briefly disconnect every device served by it (not just "${F}"). Streams will reconnect automatically.`,confirmLabel:`Restart`,variant:`danger`})&&ke.mutate({addonId:L})}},{id:`delete`,label:`Delete device`,description:`Remove the device and all its settings.`,icon:Xt,separatorBefore:!0,disabled:Ce.isPending,danger:!0,onClick:async()=>{await h({title:`Delete "${F}"?`,message:`This will remove the device and all its settings. This action cannot be undone.`,confirmLabel:`Delete`,variant:`danger`})&&Ce.mutate({deviceId:a})}}]})]})]})]}),u(xe,{deviceId:a,device:P??void 0,children:u(ue,{children:u(ye,{children:u(_,{children:u(we,{children:r(`main`,{className:W?`flex-1 overflow-y-auto flex flex-col`:`flex-1 min-h-0 overflow-hidden flex flex-row`,children:[r(`div`,{className:W?`flex flex-col bg-surface`:`${O===null?`w-1/2 lg:w-1/3`:``} flex-shrink-0 flex flex-col bg-surface min-h-0 overflow-hidden`,style:!W&&O!==null?{width:`${String(O)}px`}:void 0,children:[u(`div`,{className:ce?`flex-shrink-0 border-b border-border-subtle bg-black`:W?`flex-shrink-0 border-b border-border-subtle bg-surface`:`max-h-[55%] shrink-0 overflow-y-auto border-b border-border-subtle bg-surface`,children:ce?u(or,{deviceId:a,intercomAvailable:R.includes(mt.TwoWayAudio)}):u(Zn,{deviceId:a,deviceName:F,deviceType:z??`unknown`,provider:L,isOnline:I,features:R})}),r(`div`,{className:W?`flex flex-col border-b border-border`:`flex-1 min-h-0 flex flex-col overflow-hidden`,children:[u(`div`,{className:`flex-shrink-0 border-b border-border-subtle px-2 py-1.5`,children:u(`div`,{className:`flex gap-1 overflow-x-auto -mx-1 px-1 pb-0.5`,children:ve.map(({id:e,label:t,icon:n})=>r(`button`,{onClick:()=>w(e),title:t,className:`flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium transition-colors flex-shrink-0 ${S===e?`bg-primary/15 text-primary`:`text-foreground-subtle hover:text-foreground hover:bg-surface-hover`}`,children:[u(n,{className:`h-3 w-3`}),t]},e))})}),r(`div`,{className:W?`h-72 overflow-hidden`:`flex-1 min-h-0 overflow-hidden`,children:[S===`logs`&&u(sr,{deviceId:a,containerDeviceId:z===`container`?a:void 0}),S===`repl`&&u(cr,{deviceId:a}),S===`events`&&u(lr,{deviceId:a}),S===`state`&&u(ur,{deviceId:a})]})]})]}),!W&&u(`div`,{role:`separator`,"aria-orientation":`vertical`,title:`Drag to resize`,onMouseDown:te,className:`flex-shrink-0 w-1 cursor-col-resize bg-border hover:bg-primary/40 transition-colors group relative z-10`,children:u(`span`,{className:`absolute inset-y-0 -left-1 -right-1`})}),r(`div`,{className:W?`flex flex-col`:`flex-1 min-w-0 min-h-0 flex flex-col overflow-hidden`,children:[u(`div`,{className:`flex-shrink-0 border-b border-border bg-surface px-4`,children:u(`div`,{className:`flex flex-nowrap overflow-x-auto md:flex-wrap md:overflow-x-visible items-center gap-0`,children:he.map(e=>{let t=K===e.id;return r(`button`,{onClick:()=>ge(e.id),className:`relative flex-shrink-0 px-3 py-2 text-xs font-medium transition-colors ${t?`text-primary`:`text-foreground-subtle hover:text-foreground`}`,children:[e.label,t&&u(`span`,{className:`absolute bottom-0 left-0 right-0 h-0.5 rounded-full bg-primary`})]},e.id)})})}),r(`div`,{className:W?`p-3 flex flex-col gap-3`:`flex-1 min-h-0 overflow-y-auto p-4 flex flex-col gap-3`,children:[K===`overview`&&_e&&u(On,{parentDeviceId:a}),Xe()]})]})]})})})})})})]}):r(`div`,{className:`flex flex-col items-center justify-center h-full gap-3 text-foreground-subtle`,children:[u(`p`,{className:`text-lg font-semibold text-foreground`,children:`Invalid device id`}),r(`p`,{className:`text-xs`,children:[`The URL segment`,` `,u(`code`,{className:`font-mono bg-surface px-1.5 py-0.5 rounded text-[11px]`,children:n.deviceId}),` `,`is not a number.`]}),u(`button`,{onClick:()=>d(`/integrations`),className:`mt-2 rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 transition-colors`,children:`Back to Integrations`})]})}function ri({metrics:e,dbfs:t}){let n=y(e.phase??`idle`);return r(`div`,{className:`flex items-center gap-3 flex-shrink-0`,children:[r(`div`,{className:`flex items-center gap-1.5`,children:[u(`span`,{className:`h-1.5 w-1.5 rounded-full ${n.dotClass}`}),u(`span`,{className:`text-[10px] font-medium ${n.textColor}`,children:n.label})]}),u(`div`,{className:`h-3 w-px bg-border`}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[u(Ft,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:(e.actualFps??0).toFixed(1)}),u(`span`,{children:`fps`})]}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[u(Rt,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:(e.avgInferenceTimeMs??0).toFixed(0)}),u(`span`,{children:`ms`})]}),r(`div`,{className:`flex items-center gap-1 text-[10px] text-foreground-subtle`,title:`Current audio level (dBFS)`,children:[u(fn,{className:`h-3 w-3`}),u(`span`,{className:`text-foreground tabular-nums`,children:t==null?`—`:t.toFixed(0)}),u(`span`,{children:`dB`})]}),(e.queueDepth??0)>0&&r(`span`,{className:`text-[10px] text-warning tabular-nums`,children:[`q:`,e.queueDepth]})]})}export{ni as DeviceDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,o as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as o}from"./player-overlays-
|
|
1
|
+
import{I as e,Q as t,S as n,W as r,o as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as o}from"./player-overlays-BCuyatPp.js";import{Br as s,Dr as c,Gr as l,Mr as u,bi as d,i as f,w as p}from"./src-BmCjCFGO.js";import{t as m}from"./ProviderIcon-BBJFc8mr.js";import{J as h,V as g,o as _,t as v}from"./index-CoX6Kh_l.js";import{t as y}from"./AdminPage-CCD07UMs.js";import"./useEventInvalidation-DCo7fWEj.js";t();var b=32;function x(e,t){if(t===null)return{activeDevices:e,orphanDevices:[]};let n=e=>typeof e.addonId==`string`&&e.addonId.length>0&&!t.has(e.addonId),r=new Set;for(let t of e)n(t)&&r.add(t.id);let i=new Map;for(let t of e)i.set(t.id,t);let a=(e,t=0)=>{if(t>b)return!1;if(r.has(e.id))return!0;if(e.parentDeviceId==null)return!1;let n=i.get(e.parentDeviceId);return n?a(n,t+1):!1},o=[],s=[];for(let t of e)a(t)?s.push(t):o.push(t);return{activeDevices:o,orphanDevices:s}}function S(){let{t}=v(),b=h(),S=o(),C=i();f([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]),f([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`]);let{data:w}=s({}),{data:T}=d(void 0),E=l({onSuccess:()=>{C.invalidateQueries({queryKey:[[`deviceManager`]]})}}),D=c({onSuccess:()=>{C.invalidateQueries({queryKey:[[`deviceManager`]]})}}),O=u({onSuccess:()=>{C.invalidateQueries({queryKey:[[`deviceManager`]]})}}),k=r(()=>w??[],[w]),{activeDevices:A,orphanDevices:j}=r(()=>x(k,T===void 0?null:new Set(T.map(e=>e.addonId))),[k,T]),M=r(()=>{let e=new Map;for(let t of k)e.set(t.id,{id:t.id,name:t.name??t.stableId??`#${String(t.id)}`});return e},[k]),N=e(e=>M.get(e)??null,[M]),P=r(()=>(T??[]).map(e=>({id:e.addonId,name:e.name??e.addonId,icon:a(m,{type:e.addonId,size:`sm`})})),[T]),F=e(e=>a(m,{type:e,size:`sm`}),[]),I=e(e=>b(`/devices/${String(e)}`),[b]);return n(y,{icon:g,title:t(`nav.devices`,`Devices`),children:[a(p,{context:`devices`,devices:A,trpc:S.trpcClient,filters:{addons:P},resolveIntegrationIcon:F,resolveParent:N,onNavigate:I,batchActions:{remove:E.mutate,disable:D.mutate,enable:O.mutate}}),j.length>0&&n(`div`,{className:`mt-6 space-y-2`,children:[n(`div`,{className:`flex items-baseline gap-2`,children:[a(_,{className:`h-3.5 w-3.5 text-warning shrink-0`}),a(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Orphan devices`}),n(`span`,{className:`text-[10px] text-foreground-subtle`,children:[j.length,` device`,j.length===1?``:`s`,` pointing at integrations no longer registered`]})]}),n(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 p-2`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle px-2 pb-2`,children:"These devices reference an addonId that has no matching integration. Delete them, or re-install the missing integration to bring them back online. The provider scope (`addonId`) shown beside each row is what's failing to resolve."}),a(p,{context:`devices`,devices:j,trpc:S.trpcClient,filters:{addons:P},urlScope:`nested`,lsKey:`devices:orphan`,resolveIntegrationIcon:F,resolveParent:N,onNavigate:I})]})]})]})}export{S as DevicesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,d as r,q as i,u as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Y as c}from"./player-overlays-
|
|
1
|
+
import{Q as e,S as t,W as n,d as r,q as i,u as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Y as c}from"./player-overlays-BCuyatPp.js";import{Ns as l,Q as u,it as d,o as f}from"./src-BmCjCFGO.js";import{At as p}from"./src-D8hsVOc6.js";import{D as m,E as h,N as g,j as _,v,w as y}from"./__vite-browser-external-B6qJ4svC.js";e();var b=g([m({kind:y(`adaptive`)}),m({kind:y(`profile`),profile:p})]),x=m({serverUrl:_().min(1),token:_().min(1),deviceId:h().int().nonnegative(),target:b,muted:v()});function S(e,t){let n=t===void 0?{type:`state`,state:e}:{type:`state`,state:e,message:t};window.ReactNativeWebView?.postMessage(JSON.stringify(n))}function C(e){switch(e){case`playing`:return`playing`;case`error`:return`error`;case`connecting`:case`disconnected`:case`idle`:return`connecting`}}function w(e){return e.kind===`adaptive`?{kind:`adaptive`}:{kind:`profile`,profile:e.profile}}function T(e){return e.kind===`adaptive`?`embed:adaptive`:`embed:profile:${e.profile}`}function E(){let e=window.__CAMSTACK_EMBED__;if(e==null)return{ok:!1,error:`window.__CAMSTACK_EMBED__ is not set`};let t=x.safeParse(e);return t.success?{ok:!0,config:t.data}:{ok:!1,error:t.error.issues.map(e=>`${e.path.join(`.`)||`(root)`}: ${e.message}`).join(`; `)}}function D({message:e}){return s(()=>{S(`error`,e)},[e]),t(`div`,{style:{position:`fixed`,inset:0,display:`flex`,alignItems:`center`,justifyContent:`center`,background:`#000`,color:`#f87171`,fontFamily:`system-ui, sans-serif`,fontSize:13,padding:16,textAlign:`center`},children:[`Embed config error: `,e]})}function O({system:e,deviceId:t,initialTarget:r,initialMuted:a}){let[c,l]=i(r),[u,p]=i(a),{handleOffer:m,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,getSessionState:y}=f(e.trpcClient,t),x=n(()=>w(c),[c]),E=n(()=>(e,t)=>m(x,e,t),[m,x]),D=n(()=>(e,t,n)=>m(n,t,e),[m]);s(()=>(window.__camstackEmbed={setMuted:e=>p(e),setTarget:e=>{let t=b.safeParse(e);t.success&&l(t.data)}},()=>{window.__camstackEmbed&&delete window.__camstackEmbed}),[]);let O=T(c);return o(`div`,{style:{position:`fixed`,inset:0,width:`100vw`,height:`100vh`,background:`#000`},children:o(d,{serverUrl:e.serverUrl,streamKey:O,autoPlay:!0,muted:u,showControls:!1,className:`w-full h-full`,handleOffer:E,reoffer:D,getSessionState:y,getIceServers:h,addIceCandidate:g,getIceCandidates:_,closeSession:v,onStateChange:e=>S(C(e)),onError:e=>S(`error`,e)},O)})}function k(){let e=n(()=>E(),[]),t=n(()=>e.ok?{system:u({serverUrl:e.config.serverUrl,token:e.config.token}),queryClient:new r({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1}}})}:null,[e]);return s(()=>{if(t)return()=>{t.system.close()}},[t]),e.ok?t?o(c,{system:t.system,children:o(a,{client:t.queryClient,children:o(l.Provider,{client:t.system.trpcClient,queryClient:t.queryClient,children:o(O,{system:t.system,deviceId:e.config.deviceId,initialTarget:e.config.target,initialMuted:e.config.muted})})})}):o(D,{message:`Failed to initialise the embed player`}):o(D,{message:e.error})}export{k as EmbedPlayerPage};
|