@camstack/addon-admin-ui 1.2.37 → 1.2.39
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-ruAb2ySj.js → AddLocationWizard-OriRyfGb.js} +1 -1
- package/dist/assets/{AddonCollectionPage-y9PlVqw3.js → AddonCollectionPage-7y8If9fE.js} +1 -1
- package/dist/assets/{Addons-cAsBu2OQ.js → Addons-hU4-qfh2.js} +1 -1
- package/dist/assets/{AdminTabs-BVHcviOJ.js → AdminTabs-DM6mL-tM.js} +1 -1
- package/dist/assets/{AiProfiles-B6EskvNu.js → AiProfiles-Brqvkhl4.js} +1 -1
- package/dist/assets/{BrokerForm-DIw2g_KM.js → BrokerForm-B-QT1L9v.js} +1 -1
- package/dist/assets/{Build-sVmfeGFf.js → Build-Dt5OBjW5.js} +1 -1
- package/dist/assets/{Capabilities-CTlKJVid.js → Capabilities-BYnCJ_wF.js} +1 -1
- package/dist/assets/{CapabilityBadges-B_ZC7k04.js → CapabilityBadges-C5TaGUC8.js} +1 -1
- package/dist/assets/{Cluster-DkXZdWpm.js → Cluster-XbnMe9Pm.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-U0cdF9UF.js → ClusterRecordingTab-BCsf2fwB.js} +1 -1
- package/dist/assets/{Dashboard-BCNcg--7.js → Dashboard-r3XlD3RZ.js} +1 -1
- package/dist/assets/{Data-ZtVnR1Fe.js → Data-BKTmde3A.js} +1 -1
- package/dist/assets/DetectionIntelligence-BUJk53Nr.js +1 -0
- package/dist/assets/{DeviceAggregateSection-UxtJHE5B.js → DeviceAggregateSection-DF9Z2L7S.js} +1 -1
- package/dist/assets/{DeviceDetail-BbYvgUSY.js → DeviceDetail-CsHJjW3e.js} +1 -1
- package/dist/assets/{Devices-DzLVWcFg.js → Devices-CaA0QYmI.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-C5yT7D0W.js → EmbedPlayerPage-BrIhUfY9.js} +1 -1
- package/dist/assets/Events-aoQrd7-L.js +1 -0
- package/dist/assets/{FormBuilder-C0N6NRfe.js → FormBuilder-BJU_ZIZk.js} +1 -1
- package/dist/assets/{Identity-FI4f8ox5.js → Identity-BCOzZv52.js} +1 -1
- package/dist/assets/{IntegrationDetail-DxAOxN6t.js → IntegrationDetail-2L8sysid.js} +1 -1
- package/dist/assets/{Integrations-w3RuUxDV.js → Integrations-Dh3w0aKJ.js} +1 -1
- package/dist/assets/{Integrations-D5S4Yf1A.js → Integrations-vZKrLwHE.js} +1 -1
- package/dist/assets/{Logs-BfDIf7QZ.js → Logs-CHQXs8Vu.js} +1 -1
- package/dist/assets/{MotionZonesSettings-CHyWV5lm.js → MotionZonesSettings-BjvHQ1e5.js} +1 -1
- package/dist/assets/{MyAccess-76Y7QhMu.js → MyAccess-DNymG7pu.js} +1 -1
- package/dist/assets/{Network-BAUdETHi.js → Network-D_CsKU8a.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-CeWEr-Zg.js → NodeAddonsSettingsPanel-Ba1gsH1f.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-CUinkSSN.js → NodeInferenceDevices-UGBHLkhA.js} +1 -1
- package/dist/assets/{Notifications-CK3PuxFQ.js → Notifications-DILhVkzg.js} +1 -1
- package/dist/assets/{Pipeline-CTSS1aGu.js → Pipeline-_RMzi7q3.js} +1 -1
- package/dist/assets/Plates-CO4B3ixk.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-C4ycA7Un.js → PrivacyMaskSettings-BXIBSDkD.js} +1 -1
- package/dist/assets/{ProviderIcon-DyK-gNEs.js → ProviderIcon-B5LCn3Mf.js} +1 -1
- package/dist/assets/{Recordings-UAlZznSu.js → Recordings-BL_kacL0.js} +1 -1
- package/dist/assets/{ScanNetworkModal-h3WtjMhA.js → ScanNetworkModal-B2JsrwAN.js} +1 -1
- package/dist/assets/{Settings-oupU5GDf.js → Settings-CpbZOr_5.js} +1 -1
- package/dist/assets/{Showroom-HqqCUr23.js → Showroom-DEmabhu2.js} +1 -1
- package/dist/assets/{Terminal-7B0qx8ho.js → Terminal-CDDcYkp0.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-BnceOEA8.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DTslggLS.js} +1 -1
- package/dist/assets/{boxes-BS6UzXs9.js → boxes-CPXAmMjb.js} +1 -1
- package/dist/assets/{build-cluster-graph-CO-MCBmD.js → build-cluster-graph-DVv0t_wf.js} +1 -1
- package/dist/assets/circle-check-big-CJjIBE-Y.js +1 -0
- package/dist/assets/clock-BCe1hJij.js +1 -0
- package/dist/assets/{copy-bKWchDUS.js → copy-C5lJfJcA.js} +1 -1
- package/dist/assets/debounced-invalidate-CEaa4b9p.js +1 -0
- package/dist/assets/dist-Bie7I4Dp.js +7 -0
- package/dist/assets/{dist-CXHmz2j1.js → dist-oY93oUD8.js} +1 -1
- package/dist/assets/{download-C3-lXLSJ.js → download-Bzkw7O4Z.js} +1 -1
- package/dist/assets/{face-bbox-Cb2eJK0t.js → face-bbox-BIMrI8Pc.js} +1 -1
- package/dist/assets/{hostInit-DtkE57IB.js → hostInit-Cwmrkw0G.js} +1 -1
- package/dist/assets/{index-Bke_0boK.js → index-C8SRsMDj.js} +3 -3
- package/dist/assets/{key-round-CSNhr2jN.js → key-round-BzoMmtbk.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-e0821d3f.js → mf-entry-bootstrap-0-d82c7966.js} +2 -2
- package/dist/assets/{pencil-Dbscj0iB.js → pencil-Y8UysE-S.js} +1 -1
- package/dist/assets/{player-overlays-CCOENCr_.js → player-overlays-DELm4F-u.js} +1 -1
- package/dist/assets/plus-wHPjAjjI.js +1 -0
- package/dist/assets/{radio-BCrXf-T5.js → radio-BHeC3wQq.js} +1 -1
- package/dist/assets/{refresh-cw-B50UNH29.js → refresh-cw-Dj7zL6_z.js} +1 -1
- package/dist/assets/remoteEntry-RbjAYG4k.js +1 -0
- package/dist/assets/rotate-ccw-D5cMUAdd.js +1 -0
- package/dist/assets/rotate-cw-D9vE4NZ4.js +1 -0
- package/dist/assets/search-BrQOPJ2n.js +1 -0
- package/dist/assets/{send-vIA2Sg01.js → send-BBUpM83x.js} +1 -1
- package/dist/assets/{server-CVgGKwKo.js → server-BI_u9sYY.js} +1 -1
- package/dist/assets/square-E_LF6StT.js +1 -0
- package/dist/assets/{square-check-big-DTiBKI6p.js → square-check-big-mv0hqUya.js} +1 -1
- package/dist/assets/{src-DiF3p-RR.js → src-DB2IsJfq.js} +4 -4
- package/dist/assets/src-wWV0FeEw.js +7 -0
- package/dist/assets/{undo-2-buMXiXDJ.js → undo-2-D0BRjC1S.js} +1 -1
- package/dist/assets/{upload-YICZuTHD.js → upload-CI8AxjkJ.js} +1 -1
- package/dist/assets/{useEventInvalidation-CGT7WKQk.js → useEventInvalidation-D-wl8gip.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CbdC118i.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-C9fYNixB.js} +2 -2
- package/dist/assets/{wifi-B6uMvniy.js → wifi-D-4Fli1P.js} +1 -1
- package/dist/assets/{zap-O3h5iXhW.js → zap-CnvxsMR1.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +77 -3
- package/package.json +1 -1
- package/dist/assets/DetectionIntelligence-BlZl9E8S.js +0 -1
- package/dist/assets/Events-BGJ5su4V.js +0 -1
- package/dist/assets/Plates-Cns09Gg2.js +0 -1
- package/dist/assets/circle-check-big-DKZCFZff.js +0 -1
- package/dist/assets/clock-DqPUDB1Y.js +0 -1
- package/dist/assets/debounced-invalidate-CoCA-chF.js +0 -1
- package/dist/assets/dist-B66gZe27.js +0 -7
- package/dist/assets/plus-kjGKne3v.js +0 -1
- package/dist/assets/remoteEntry-DSjWOwlm.js +0 -1
- package/dist/assets/rotate-ccw-CnFi79eH.js +0 -1
- package/dist/assets/rotate-cw-BMi2-EKp.js +0 -1
- package/dist/assets/search-Cqbwip0Z.js +0 -1
- package/dist/assets/square-NIJNDIvZ.js +0 -1
- package/dist/assets/src-C3IwZqep.js +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$a as e,$r as t,Ao as n,B as r,Bo as i,Jr as a,Kr as o,Lo as s,Mr as c,Qr as l,Ro as u,Vo as d,Wr as f,Xr as p,Zr as m,ci as h,ii as g,io as _,jn as v,jo as y,li as b,ni as x,oi as S,q as C,qr as w,ri as T,si as E,ti as D,ui as O,uo as k,xt as A,z as j,zo as M}from"./src-DiF3p-RR.js";import{I as N,K as P,Q as F,S as I,U as L,W as R,a as z,b as ee,i as B,o as te,q as V,x as H,z as U}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as W,N as ne,T as G}from"./src-C3IwZqep.js";import{p as re}from"./player-overlays-CCOENCr_.js";import{t as ie}from"./clock-DqPUDB1Y.js";import{t as ae}from"./copy-bKWchDUS.js";import{t as oe}from"./download-C3-lXLSJ.js";import{a as se,c as K,d as ce,f as le,i as ue,m as de,n as fe,o as pe,p as me,r as he,s as ge,t as _e}from"./debounced-invalidate-CoCA-chF.js";import{t as ve}from"./refresh-cw-B50UNH29.js";import{t as ye}from"./search-Cqbwip0Z.js";import{t as be}from"./square-check-big-DTiBKI6p.js";import{t as xe}from"./square-NIJNDIvZ.js";import{t as Se}from"./undo-2-buMXiXDJ.js";import{D as Ce,F as we,G as q,L as Te,N as Ee,R as De,S as J,W as Oe,i as ke,l as Ae,s as je,t as Me}from"./index-Bke_0boK.js";import{t as Ne}from"./AdminPage-Dq33XE9j.js";import{i as Pe,n as Fe,t as Ie}from"./authed-media-B8T1dsFh.js";import{t as Le}from"./AdminTabs-BVHcviOJ.js";var Re=q(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),ze=q(`bug`,[[`path`,{d:`m8 2 1.88 1.88`,key:`fmnt4t`}],[`path`,{d:`M14.12 3.88 16 2`,key:`qol33r`}],[`path`,{d:`M9 7.13v-1a3.003 3.003 0 1 1 6 0v1`,key:`d7y7pr`}],[`path`,{d:`M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6`,key:`xs1cw7`}],[`path`,{d:`M12 20v-9`,key:`1qisl0`}],[`path`,{d:`M6.53 9C4.6 8.8 3 7.1 3 5`,key:`32zzws`}],[`path`,{d:`M6 13H2`,key:`82j7cp`}],[`path`,{d:`M3 21c0-2.1 1.7-3.9 3.8-4`,key:`4p0ekp`}],[`path`,{d:`M20.97 5c0 2.1-1.6 3.8-3.5 4`,key:`18gb23`}],[`path`,{d:`M22 13h-4`,key:`1jl80f`}],[`path`,{d:`M17.2 17c2.1.1 3.8 1.9 3.8 4`,key:`k3fwyw`}]]),Be=q(`circle-dashed`,[[`path`,{d:`M10.1 2.182a10 10 0 0 1 3.8 0`,key:`5ilxe3`}],[`path`,{d:`M13.9 21.818a10 10 0 0 1-3.8 0`,key:`11zvb9`}],[`path`,{d:`M17.609 3.721a10 10 0 0 1 2.69 2.7`,key:`1iw5b2`}],[`path`,{d:`M2.182 13.9a10 10 0 0 1 0-3.8`,key:`c0bmvh`}],[`path`,{d:`M20.279 17.609a10 10 0 0 1-2.7 2.69`,key:`1ruxm7`}],[`path`,{d:`M21.818 10.1a10 10 0 0 1 0 3.8`,key:`qkgqxc`}],[`path`,{d:`M3.721 6.391a10 10 0 0 1 2.7-2.69`,key:`1mcia2`}],[`path`,{d:`M6.391 20.279a10 10 0 0 1-2.69-2.7`,key:`1fvljs`}]]),Ve=q(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),He=q(`copy-plus`,[[`line`,{x1:`15`,x2:`15`,y1:`12`,y2:`18`,key:`1p7wdc`}],[`line`,{x1:`12`,x2:`18`,y1:`15`,y2:`15`,key:`1nscbv`}],[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Ue=q(`graduation-cap`,[[`path`,{d:`M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z`,key:`j76jl0`}],[`path`,{d:`M22 10v6`,key:`1lu8f3`}],[`path`,{d:`M6 12.5V16a6 3 0 0 0 12 0v-3.5`,key:`1r8lef`}]]),We=q(`square-parking`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 17V7h4a3 3 0 0 1 0 6H9`,key:`1dfk2c`}]]),Ge=q(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]);F();var Ke=`pipeline-analytics`,qe=`debug.listTracks`,Je=`debug.analyze`,Ye=`/addon/pipeline-analytics/debug-export`;function Xe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ze(e,t){let n=e[t];return typeof n==`string`?n:null}function Y(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:null}function Qe(e,t){let n=e[t];return typeof n==`boolean`?n:null}function $e(e){return e===`error`||e===`warn`||e===`info`}function et(e){if(!Xe(e))return null;let t=Ze(e,`code`),n=Ze(e,`detail`),r=e.severity;return t===null||n===null||!$e(r)?null:{code:t,severity:r,detail:n}}function tt(e){if(!Xe(e))return null;let t=Ze(e,`trackId`),n=Y(e,`deviceId`),r=Ze(e,`className`),i=Y(e,`firstSeen`),a=Y(e,`lastSeen`),o=Y(e,`durationMs`),s=Qe(e,`active`);if(t===null||n===null||r===null||i===null||a===null||o===null||s===null)return null;let c=Ze(e,`label`);return{trackId:t,deviceId:n,className:r,...c===null?{}:{label:c},firstSeen:i,lastSeen:a,durationMs:o,active:s}}function nt(e){let t=tt(e);if(t===null||!Xe(e))return null;let n=Y(e,`mediaCount`),r=Y(e,`eventCount`),i=Y(e,`positionCount`);if(n===null||r===null||i===null)return null;let a=e.mediaKinds,o=e.findings;if(!Array.isArray(a)||!Array.isArray(o))return null;let s=a.filter(e=>typeof e==`string`),c=[];for(let e of o){let t=et(e);t!==null&&c.push(t)}return{...t,mediaCount:n,mediaKinds:s,eventCount:r,positionCount:i,findings:c}}function rt(e){if(!Xe(e))return null;let t=Qe(e,`truncated`),n=e.tracks;if(t===null||!Array.isArray(n))return null;let r=[];for(let e of n){let t=tt(e);if(t===null)return null;r.push(t)}return{tracks:r,truncated:t}}function it(e){if(!Xe(e))return null;let t=e.reports,n=e.vanished;if(!Array.isArray(t)||!Array.isArray(n))return null;let r=[];for(let e of t){let t=nt(e);if(t===null)return null;r.push(t)}return{reports:r,vanished:n.filter(e=>typeof e==`string`)}}var at={MEDIA_EVICTED_OR_NEVER:`no media`,MISSING_KEYFRAME:`no keyframe`,MISSING_FIRSTFRAME:`no first frame`,MISSING_LASTFRAME:`no last frame`,MISSING_THUMBNAIL:`no thumbnail`,MISSING_BEST_CROP:`no crop`,SHORT_TRACK:`very short`,ZERO_EVENTS:`no events`,ZERO_POSITIONS:`no trajectory`,NO_PERIODIC_SNAPSHOTS:`no snapshots`,LASTFRAME_STALE:`stale last frame`,MEDIA_STOPPED_EARLY:`media stopped early`,NO_BEST_EVENT:`no best event`,LOW_BEST_SCORE:`low score`};function ot(e){return at[e]??e}var st={error:0,warn:1,info:2};function ct(e){return e.toSorted((e,t)=>st[e.severity]-st[t.severity]||e.code.localeCompare(t.code))}function lt(e){return e.length===0?Ye:`${Ye}?deviceIds=${e.join(`,`)}`}function ut(e){if(e<1e4)return`${(e/1e3).toFixed(1)}s`;let t=Math.round(e/1e3);if(t<60)return`${String(t)}s`;let n=Math.floor(t/60);return`${String(n)}m ${String(t%60).padStart(2,`0`)}s`}var dt=`all`,ft=`The server answered in a shape this build does not understand.`,pt={error:`danger`,warn:`warning`,info:`info`};function mt({findings:e}){return e.length===0?H(i,{variant:`success`,children:`no anomaly found`}):H(`div`,{className:`flex flex-wrap gap-1`,children:ct(e).map(e=>H(i,{variant:pt[e.severity],title:e.detail,children:ot(e.code)},e.code))})}function ht({track:e,report:t,cameraName:n,analyzing:r}){return I(`div`,{className:`flex flex-col gap-1.5 border-b border-border px-3 py-2.5 last:border-b-0`,children:[I(`div`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[H(`span`,{className:`font-medium text-foreground`,children:n}),H(`span`,{className:`text-foreground-subtle`,children:e.label??e.className}),I(`span`,{className:`text-foreground-subtle`,children:[new Date(e.lastSeen).toLocaleString(),` · `,ut(e.durationMs)]}),e.active&&H(i,{variant:`default`,children:`still open`}),t!==void 0&&I(`span`,{className:`text-foreground-subtle`,children:[String(t.mediaCount),` media · `,String(t.eventCount),` events ·`,` `,String(t.positionCount),` positions`]})]}),H(`div`,{className:`flex items-center gap-2`,children:t===void 0?H(`span`,{className:`text-xs text-foreground-subtle`,children:r?`analysing…`:`not analysed`}):H(mt,{findings:t.findings})}),H(`code`,{className:`text-[10px] text-foreground-subtle`,children:e.trackId})]})}function gt(){let e=re(),[t,n]=V(dt),[r,i]=V(!1),[a,o]=V(null),c=v({}),l=R(()=>[{value:dt,label:`All cameras`},...(c.data??[]).map(e=>({value:String(e.id),label:e.name}))],[c.data]),u=R(()=>{let e=new Map;for(let t of c.data??[])e.set(t.id,t.name);return e},[c.data]),f=R(()=>t===dt?[]:[Number.parseInt(t,10)],[t]),p=z({queryKey:[`events-debug`,`list`,f],queryFn:async()=>rt(await e.trpcClient.addons.custom.mutate({addonId:Ke,action:qe,input:f.length===0?{}:{deviceIds:f}}))}),m=R(()=>(p.data?.tracks??[]).map(e=>e.trackId),[p.data]),h=z({queryKey:[`events-debug`,`analyze`,m],enabled:m.length>0,queryFn:async()=>it(await e.trpcClient.addons.custom.mutate({addonId:Ke,action:Je,input:{trackIds:m}}))}),g=R(()=>{let e=new Map;for(let t of h.data?.reports??[])e.set(t.trackId,t);return e},[h.data]),y=()=>{p.refetch(),h.refetch()},b=async()=>{i(!0),o(null);try{await Fe(lt(f),`camstack-debug.zip`)}catch(e){o(e instanceof Error?e.message:`Export failed.`)}finally{i(!1)}},x=p.data?.tracks??[],S=p.data===null||h.data===null;return H(Ne,{children:I(`section`,{className:`space-y-3`,children:[I(`div`,{className:`flex flex-wrap items-center gap-2`,children:[H(`div`,{className:`w-44`,children:H(s,{value:t,options:l,onChange:e=>n(e.target.value)})}),I(d,{variant:`secondary`,onClick:y,disabled:p.isFetching,children:[p.isFetching?H(J,{className:`h-3.5 w-3.5 animate-spin`}):H(ve,{className:`h-3.5 w-3.5`}),`Refresh`]}),I(d,{onClick:()=>void b(),disabled:r||x.length===0,children:[r?H(J,{className:`h-3.5 w-3.5 animate-spin`}):H(oe,{className:`h-3.5 w-3.5`}),`Export all (`,String(x.length),`)`]})]}),I(`p`,{className:`text-xs text-foreground-subtle`,children:[`A `,H(`code`,{children:`debug`}),` mark does not pin retention — this lists the marked tracks that still exist. A track whose media was evicted shows as missing media.`]}),p.isError&&H(_,{message:`Could not load the marked tracks.`}),S&&!p.isError&&H(_,{message:ft}),a!==null&&H(_,{message:a}),p.data?.truncated===!0&&H(_,{message:`A camera filled the per-camera cap — some marked tracks are not listed. Un-mark a few, or filter to one camera.`}),(h.data?.vanished.length??0)>0&&I(`p`,{className:`text-xs text-foreground-subtle`,children:[String(h.data?.vanished.length),` marked track(s) were evicted between the list and the analysis.`]}),H(M,{children:p.isLoading?H(`div`,{className:`px-3 py-6 text-center text-xs text-foreground-subtle`,children:`Loading…`}):x.length===0?I(`div`,{className:`flex flex-col items-center gap-2 px-3 py-8 text-center`,children:[H(ze,{className:`h-5 w-5 text-foreground-subtle`}),H(`p`,{className:`text-xs text-foreground-subtle`,children:`No track is marked for debug. Mark one from a track's actions to see it here.`})]}):x.map(e=>H(ht,{track:e,report:g.get(e.trackId),cameraName:u.get(e.deviceId)??`Camera ${String(e.deviceId)}`,analyzing:h.isFetching},e.trackId))})]})})}function _t(e){return e.subLabel??e.label}var vt=720*60*60*1e3;function yt(e){let t=[];for(let n of e)t.push(...n);return t}function bt(e,t){let n=[...e];return n.sort((e,n)=>t===`importance`?n.importance-e.importance:n.timestamp-e.timestamp),n}function xt(e,t){return e.filter(e=>!(e.importance<t.minImportance||t.cameras.size>0&&!t.cameras.has(e.deviceId)||t.classes.size>0&&!t.classes.has(e.className)))}function St(e,t){return`${String(e)}:${t}`}function Ct(e,t){let n=new Map,r=new Set;for(let i of e){let e=St(i.deviceId,i.trackId);if(!t.has(e)||r.has(e))continue;r.add(e);let a=n.get(i.deviceId);a?a.push(i.trackId):n.set(i.deviceId,[i.trackId])}return n}function wt(e,t){return{since:e.fromMs??t-vt,until:e.toMs??t}}var Tt=typeof o==`function`,Et=`Track deletion arrives with the next server update`;function Dt(){return{mutateAsync:async()=>{throw Error(`deleteTracks unavailable`)},isPending:!1}}var Ot=Tt?o:Dt,kt=200,At=3e4;function jt(e){let t=re(),n=B({queries:e.deviceIds.map(n=>({queryKey:[`events-feed`,n,e.since,e.until,e.minImportance??null,e.classFilter??null],staleTime:At,refetchInterval:At,queryFn:async()=>(await t.trpcClient.pipelineAnalytics.getKeyEvents.query({deviceId:n,since:e.since,until:e.until,limit:kt,...e.minImportance===void 0?{}:{minImportance:e.minImportance},...e.classFilter===void 0?{}:{classFilter:e.classFilter}})).map(e=>({...e,deviceId:n}))}))});return{rows:bt(yt(n.map(e=>e.data??[])),`importance`),isLoading:n.some(e=>e.isLoading)}}F();var Mt=[`events-feed`],Nt=2e3;function Pt(e){let t=te(),n=e?.paused===!0,r=P(t);r.current=t;let i=P(n);i.current=n;let[a,o]=V(!1),s=N(()=>{r.current.invalidateQueries({queryKey:Mt})},[]),c=P(void 0);c.current||=_e({delayMs:Nt,invalidate:()=>{i.current?o(!0):s()}}),U(()=>()=>c.current?.cancel(),[]),U(()=>{n||!a||(o(!1),s())},[n,a,s]);let l=N(()=>{o(!1),s()},[s]);return k(W.PipelineAnalyticsDetectionEvent,()=>{c.current?.trigger()}),k(W.PipelineAnalyticsTrackEnded,()=>{c.current?.trigger()}),{pending:a,refreshNow:l}}F();function Ft({groups:e,selected:t,onChange:n,loading:i=!1}){let{t:a}=Me(),[o,s]=V(!1),[c,l]=V(``),[u,d]=V(new Set),f=c.trim().toLowerCase(),p=e=>f.length===0||j(e,a).toLowerCase().includes(f),m=R(()=>e.map(e=>({macro:e.macro,subs:e.subs.filter(t=>p(t)||p(e.macro))})).filter(e=>p(e.macro)||e.subs.length>0),[e,f]),h=e=>d(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=e=>{let r=new Set(t),i=t.has(e.macro.kind)&&e.subs.every(e=>t.has(e.kind)),a=[e.macro.kind,...e.subs.map(e=>e.kind)];if(i)for(let e of a)r.delete(e);else for(let e of a)r.add(e);n(r)},_=e=>{let r=new Set(t);r.has(e)?r.delete(e):r.add(e),n(r)},v=()=>n(new Set),y=t.size;return I(`div`,{className:`relative`,children:[I(`button`,{type:`button`,onClick:()=>s(e=>!e),className:`flex items-center gap-1 rounded-md px-2.5 py-1 text-xs transition-colors ${y>0?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[H(Ge,{className:`h-3.5 w-3.5`}),y>0?`Kinds (${String(y)})`:`Kinds`,H(Te,{className:`h-3 w-3`})]}),o&&I(`div`,{className:`absolute z-20 mt-1 max-h-80 w-64 overflow-auto rounded-md border border-border bg-surface p-2 shadow-lg`,children:[I(`div`,{className:`mb-2 flex items-center gap-1 rounded border border-border px-1.5`,children:[H(ye,{className:`h-3.5 w-3.5 text-foreground-subtle`}),H(`input`,{type:`text`,value:c,onChange:e=>l(e.target.value),placeholder:`Search kinds…`,className:`w-full bg-transparent py-1 text-xs outline-none`}),y>0&&H(`button`,{type:`button`,onClick:v,className:`text-[10px] text-foreground-subtle hover:text-foreground`,children:`Clear`})]}),m.length===0&&H(`div`,{className:`px-1 py-2 text-[11px] text-foreground-subtle`,children:i?`Loading kinds…`:f.length>0?`No kind matches that search.`:`These cameras advertise no event kinds.`}),m.map(e=>{let n=r(e.macro.iconId),i=u.has(e.macro.kind)||f.length>0,o=t.has(e.macro.kind);return I(`div`,{className:`mb-0.5`,children:[I(`div`,{className:`flex items-center gap-1`,children:[e.subs.length>0?H(`button`,{type:`button`,onClick:()=>h(e.macro.kind),className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Expand`,children:H(i?Te:we,{className:`h-3 w-3`})}):H(`span`,{className:`w-3`}),I(`label`,{className:`flex flex-1 cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[H(`input`,{type:`checkbox`,checked:o,onChange:()=>g(e),className:`accent-primary`}),H(n,{className:`h-3.5 w-3.5`,style:{color:e.macro.color}}),H(`span`,{className:`font-medium`,children:j(e.macro,a)})]})]}),i&&e.subs.map(e=>{let n=r(e.iconId);return I(`label`,{className:`ml-5 flex cursor-pointer items-center gap-1.5 rounded px-1 py-0.5 text-xs hover:bg-surface-hover`,children:[H(`input`,{type:`checkbox`,checked:t.has(e.kind),onChange:()=>_(e.kind),className:`accent-primary`}),H(n,{className:`h-3.5 w-3.5`,style:{color:e.color}}),H(`span`,{children:j(e,a)})]},e.kind)})]},e.macro.kind)})]})]})}function It(e,t){let n=new Map;for(let r of e)if(!(t.size>0&&!t.has(r.deviceId)))for(let e of r.kinds)n.has(e.kind)||n.set(e.kind,e);return n}function Lt(e,t){return{...t,kind:e,labelKey:`eventKind.${e}`,label:e.charAt(0).toUpperCase()+e.slice(1),iconId:e,parentKind:null,level:`macro`}}var Rt=new Set([`detection`,`package`]);function zt(e,t){return[...It(e,t).values()].filter(e=>e.parentKind===null&&Rt.has(e.category)).sort((e,t)=>e.label.localeCompare(t.label))}function Bt(e,t){let n=It(e,t),r=new Map,i=new Map;for(let e of n.values()){if(e.parentKind===null){i.set(e.kind,e);continue}let t=r.get(e.parentKind);t===void 0?r.set(e.parentKind,[e]):t.push(e)}for(let[e,t]of r){if(i.has(e))continue;let n=t[0];n!==void 0&&i.set(e,Lt(e,n))}return[...i.values()].map(e=>({macro:e,subs:[...r.get(e.kind)??[]].sort((e,t)=>e.label.localeCompare(t.label))})).sort((e,t)=>e.macro.label.localeCompare(t.macro.label))}F();var Vt=1400,Ht=`Admin-gated URL — opens only inside an authenticated session`;function Ut({label:e,value:t,title:n}){let[r,i]=V(!1);return U(()=>{if(!r)return;let e=setTimeout(()=>i(!1),Vt);return()=>clearTimeout(e)},[r]),I(`button`,{type:`button`,onClick:N(()=>{(async()=>{try{await navigator.clipboard.writeText(t),i(!0)}catch{window.prompt(`Copy the media URL:`,t)}})()},[t]),title:n,"aria-label":`Copy ${e} URL`,className:`flex min-w-0 items-center gap-1 rounded border px-1.5 py-0.5 text-[10px] font-medium transition-colors ${r?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`border-border text-foreground-subtle hover:border-primary hover:text-foreground`}`,children:[H(r?De:ae,{className:`h-2.5 w-2.5 shrink-0`}),H(`span`,{className:`truncate`,children:r?`Copied`:e})]})}function Wt({localUrl:e,publicUrl:t}){return I(`div`,{className:`flex flex-wrap gap-1`,children:[H(Ut,{label:`Local`,value:e,title:`Copy LAN URL — ${Ht}`}),t&&H(Ut,{label:`Public`,value:t,title:`Copy public URL — ${Ht}`})]})}var Gt={firstFrame:`First frame (track start)`,lastFrame:`Last frame (track end)`,thumbnail:`Best detection`,thumbnailSmall:`Best detection (480)`,snapshot:`Snapshot`,keyFrame:`Key frame (native-res)`,keyFrameSmall:`Key frame (960)`,crop:`Object crop`,fullFrame:`Full frame`,fullFrameBoxed:`Full frame (boxed)`,faceCrop:`Face crop`,plateCrop:`Plate crop`};function Kt(e){return e in Gt}function qt(e){return Kt(e)?Gt[e]:e}function Jt(e,t){return`${e}${Ie}/${encodeURIComponent(t)}`}F();var Yt=3e4;function Xt(e){let[t,n]=V(null),r=N(e=>{n(t=>t??e)},[]);return U(()=>{e||n(null)},[e]),{publicOrigin:t,probes:e?H(Zt,{onOrigin:r}):null}}function Zt({onOrigin:e}){let{data:t}=A({capName:`network-access`});return H(ee,{children:(t??[]).map(t=>H(Qt,{addonId:t.addonId,onOrigin:e},t.addonId))})}function Qt({addonId:e,onOrigin:t}){let{data:n}=c({addonId:e},{refetchInterval:Yt,retry:!1});return U(()=>{let e=n?G.safeParse(n):null,r=e?.success?e.data.endpoint?.url:void 0;if(r)try{t(new URL(r).origin)}catch{}},[n,t]),null}var $t=typeof O==`function`,en=`Track flags arrive with the next server update`;function tn(){return{mutateAsync:async()=>{throw Error(`setTrackFlags unavailable`)},isPending:!1}}var nn=$t?O:tn;function rn(e){if(typeof e!=`object`||!e||!(`trackId`in e)||!(`markForTrain`in e)||!(`debug`in e))return null;let{trackId:t,markForTrain:n,debug:r}=e;return typeof t!=`string`||typeof n!=`boolean`||typeof r!=`boolean`?null:{trackId:t,markForTrain:n,debug:r}}F();function an({label:e,hint:t,checked:n,disabled:r,title:i,icon:a,onToggle:o}){return I(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":e,disabled:r,title:i,onClick:o,className:`flex w-full items-center gap-2 rounded-md border px-2 py-1.5 text-left transition-colors disabled:opacity-50 ${n?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[H(`span`,{className:n?`text-primary`:`text-foreground-subtle`,children:a}),I(`span`,{className:`min-w-0 flex-1`,children:[H(`span`,{className:`block text-[11px] font-medium text-foreground`,children:e}),H(`span`,{className:`block text-[10px] text-foreground-subtle`,children:t})]}),H(`span`,{"aria-hidden":`true`,className:`h-4 w-7 shrink-0 rounded-full p-0.5 transition-colors ${n?`bg-primary`:`bg-border`}`,children:H(`span`,{className:`block h-3 w-3 rounded-full bg-white transition-transform ${n?`translate-x-3`:``}`})})]})}function on({deviceId:e,trackId:t,markForTrain:n,debug:r,onChange:i}){let a=nn(),[o,s]=V(null),c=o?.markForTrain??n===!0,l=o?.debug??r===!0,u=!$t||a.isPending,d=$t?void 0:en,f=n=>{u||(async()=>{try{let r=rn(await a.mutateAsync({deviceId:e,trackId:t,flags:n}));if(!r)return;s(r),i?.(r)}catch(e){let t=e instanceof Error?e.message:``;window.alert(t===``?`Could not update this track. Check the server logs.`:`Could not update this track — ${t}`)}})()};return I(`div`,{className:`grid gap-1.5 sm:grid-cols-2`,children:[H(an,{label:`Mark for training`,hint:`Keeps this track and its media past retention`,checked:c,disabled:u,...d===void 0?{}:{title:d},icon:H(Ue,{className:`h-4 w-4`}),onToggle:()=>f({markForTrain:!c})}),H(an,{label:`Debug`,hint:`Flag this track for diagnostic attention`,checked:l,disabled:u,...d===void 0?{}:{title:d},icon:H(ze,{className:`h-4 w-4`}),onToggle:()=>f({debug:!l})})]})}var X=100,sn=120,cn={polyline:``,points:[],snapshots:[],start:null,end:null,peakBox:null},Z=e=>e<0?0:e>1?1:e,Q=e=>Math.round(e*100)/100;function ln(e,t){if(e.length<=t)return[...e];let n=(e.length-1)/(t-1),r=[];for(let i=0;i<t;i++)r.push(e[Math.round(i*n)]);return r[r.length-1]=e[e.length-1],r}function un(e,t,n){if(e.length===0||t===null)return cn;let{width:r,height:i}=t;if(!Number.isFinite(r)||!Number.isFinite(i)||r<=0||i<=0)return cn;let a=ln(e,n?.maxPoints??sn).map(e=>({x:Q(Z(e.x/r)*X),y:Q(Z(e.y/i)*X)})),o=a[0]??null,s=a[a.length-1]??null,c=a.length>=2?a.map(e=>`${e.x},${e.y}`).join(` `):``,l=(n?.snapshots??[]).map(e=>({x:Q(Z(e.x/r)*X),y:Q(Z(e.y/i)*X),mediaKey:e.mediaKey})),u=null,d=-1;for(let t of e){let e=Z(t.bbox.w/r)*Z(t.bbox.h/i);e>d&&(d=e,u=t)}return{polyline:c,points:a,snapshots:l,start:o,end:s,peakBox:u?{x:Q(Z(u.bbox.x/r)*X),y:Q(Z(u.bbox.y/i)*X),w:Q(Z(u.bbox.w/r)*X),h:Q(Z(u.bbox.h/i)*X)}:null}}F();var dn=15e3,fn=window.location.origin,pn=new Set([`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]),mn=new Set([`keyFrame`,`fullFrame`,`fullFrameBoxed`,`firstFrame`,`lastFrame`,`thumbnail`,`snapshot`]);function hn(e){let[t,n]=V(null);return U(()=>{if(n(null),!e)return;let t=!1,r=new Image;return r.onload=()=>{t||n({width:r.naturalWidth,height:r.naturalHeight})},r.src=e,()=>{t=!0,r.onload=null}},[e]),t}function gn({overlay:e,onPickSnapshot:t}){return!e.polyline&&!e.peakBox&&e.snapshots.length===0?null:I(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`pointer-events-none absolute inset-0 h-full w-full`,children:[e.peakBox&&H(`rect`,{x:e.peakBox.x,y:e.peakBox.y,width:e.peakBox.w,height:e.peakBox.h,fill:`none`,stroke:`#f59e0b`,strokeWidth:2,vectorEffect:`non-scaling-stroke`,rx:1}),e.polyline&&H(`polyline`,{points:e.polyline,fill:`none`,stroke:`#38bdf8`,strokeWidth:2,strokeLinejoin:`round`,strokeLinecap:`round`,strokeOpacity:.85,vectorEffect:`non-scaling-stroke`}),e.points.map((e,t)=>H(`circle`,{cx:e.x,cy:e.y,r:1,fill:`#38bdf8`,fillOpacity:.6,vectorEffect:`non-scaling-stroke`},`${String(e.x)}-${String(e.y)}-${String(t)}`)),e.snapshots.map((e,n)=>H(`circle`,{cx:e.x,cy:e.y,r:1.9,fill:`#0ea5e9`,fillOpacity:.95,stroke:`#082f49`,strokeWidth:.7,vectorEffect:`non-scaling-stroke`,className:t?`pointer-events-auto cursor-pointer`:void 0,onClick:t?n=>{n.stopPropagation(),t(e.mediaKey)}:void 0,children:H(`title`,{children:`Snapshot checkpoint — click to view this frame`})},`snap-${e.mediaKey}-${String(n)}`)),e.start&&H(`circle`,{cx:e.start.x,cy:e.start.y,r:2.4,fill:`#22c55e`,stroke:`#052e16`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`}),e.end&&H(`circle`,{cx:e.end.x,cy:e.end.y,r:2.4,fill:`#ef4444`,stroke:`#450a0a`,strokeWidth:.6,vectorEffect:`non-scaling-stroke`})]})}function $({label:e,value:t,mono:n}){return I(`div`,{className:`flex items-baseline justify-between gap-3 border-b border-border/60 py-1.5 last:border-0`,children:[H(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),H(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${n?`font-mono text-[11px]`:``}`,title:t,children:t})]})}function _n({row:t,cameraName:r,deleteAvailable:i,onClose:o,onDeleted:s,onFlagsChanged:c}){let u=re(),f=Ot(),p=t!==null,h=t?.deviceId??0,g=t?.trackId??``,_=t?.bestEventId??``,v=t?.timestamp??0,b=t?.windowMs??0,{data:x}=m({deviceId:h,trackId:g},{enabled:p}),{data:S}=l({trackId:g},{enabled:p}),{data:C}=a({eventId:_},{enabled:p&&_!==``}),{data:w}=e({deviceId:h,since:v-dn,until:v+b+dn},{enabled:p}),[T,E]=V(null),[D,O]=V(!1),{publicOrigin:k,probes:A}=Xt(p);U(()=>{E(null)},[h,g]);let j=R(()=>{let e=S??[],t=C??[];return e.find(e=>e.kind===`keyFrame`)||t.find(e=>e.kind===`fullFrameBoxed`)||([...t,...e].find(e=>e.kind===`crop`)??null)},[S,C]),M=Pe(j?`${Ie}/${encodeURIComponent(j.key)}`:void 0),P=R(()=>{let e=new Set,t=[];for(let n of[...C??[],...S??[]])!n.base64||e.has(n.key)||(e.add(n.key),t.push(n));return t},[C,S]),F=R(()=>P.find(e=>pn.has(e.kind))??null,[P]),L=hn(F?`data:image/jpeg;base64,${F.base64}`:null),z=R(()=>un(x?.positions??[],L,{snapshots:(x?.snapshots??[]).map(e=>({x:e.position.x,y:e.position.y,mediaKey:e.mediaKey}))}),[x?.positions,x?.snapshots,L]),B=N(e=>{let t=P.find(t=>t.key===e);t&&E(t)},[P]);if(t===null)return null;let te=T?`data:image/jpeg;base64,${T.base64}`:M.src,W=T?.kind??j?.kind,ne=W!==void 0&&mn.has(W)&&L!==null&&(x?.positions.length??0)>=2,G=w&&w.length>0?w[0]:null,ie=()=>{G&&(O(!0),(async()=>{try{let e=await u.trpcClient.videoclips.getClipPlayback.query({deviceId:t.deviceId,clipId:G.id});window.open(e.playbackUrl,`_blank`,`noopener`)}catch{window.alert(`Could not resolve clip playback. Check the server logs.`)}finally{O(!1)}})())},ae=()=>{!i||f.isPending||window.confirm(`Delete this track and all its media? This cannot be undone.`)&&(async()=>{try{await f.mutateAsync({deviceId:t.deviceId,trackIds:[t.trackId]}),s()}catch{window.alert(`Failed to delete this track. Check the server logs.`)}})()},oe=Math.round(t.importance*100),se=x?.importanceReason?`${String(oe)}% · ${x.importanceReason}`:`${String(oe)}%`,K=x?.zonesVisited&&x.zonesVisited.length>0?x.zonesVisited.join(`, `):`—`,le=x?.audioLabels&&x.audioLabels.length>0?x.audioLabels.map(e=>`${e.label} ×${String(e.count)} (${String(Math.round(e.peakScore*100))}%)`).join(` · `):`—`,fe=x?x.totalDistance.toFixed(2):`—`,pe=me(x?x.firstSeen:v),he=x?me(x.lastSeen):`—`;return H(n,{open:!0,onOpenChange:e=>!e&&o(),children:I(y,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Event detail`,className:`flex 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:h-auto 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:[I(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[I(`div`,{className:`min-w-0`,children:[I(`div`,{className:`truncate text-sm font-semibold text-foreground`,children:[t.className,_t(t)?I(`span`,{className:`text-foreground-subtle`,children:[` · `,_t(t)]}):null]}),H(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:r})]}),H(`button`,{type:`button`,onClick:o,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:H(ke,{className:`h-4 w-4`})})]}),I(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[te?H(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:H(ue,{src:te,alt:`Key frame from ${r}`,fit:`natural`,className:`w-full`,overlay:ne?H(gn,{overlay:z,onPickSnapshot:B}):void 0})}):H(`div`,{className:`flex aspect-video w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-surface-hover text-foreground-subtle`,children:M.failed?I(ee,{children:[H(de,{className:`h-8 w-8 opacity-60`}),H(`span`,{className:`text-[11px]`,children:`Key-frame media unavailable`})]}):H(J,{className:`h-6 w-6 animate-spin opacity-70`})}),P.length>0&&H(`div`,{className:`-mx-1 flex gap-2 overflow-x-auto px-1 pb-1`,children:P.map(e=>{let t=`data:image/jpeg;base64,${e.base64}`,n=qt(e.kind),r=Jt(fn,e.key),i=k?Jt(k,e.key):null;return I(`figure`,{className:`flex w-32 shrink-0 flex-col gap-1`,children:[H(`button`,{type:`button`,onClick:()=>E(e),className:`relative h-16 w-full overflow-hidden rounded border border-border hover:border-primary`,title:`${n} · ${me(e.timestamp)}`,children:H(`img`,{src:t,alt:n,className:`h-full w-full object-cover`})}),I(`figcaption`,{className:`min-w-0 px-0.5`,children:[H(`div`,{className:`truncate text-[10px] font-medium leading-tight text-foreground`,title:n,children:n}),H(`div`,{className:`text-[10px] leading-tight text-foreground-subtle`,title:me(e.timestamp),children:ce(e.timestamp)})]}),H(Wt,{localUrl:r,publicUrl:i})]},e.key)})}),A,G&&I(d,{variant:`secondary`,onClick:ie,disabled:D,children:[D?H(J,{className:`h-3.5 w-3.5 animate-spin`}):H(Ce,{className:`h-3.5 w-3.5`}),` `,`View clip`]}),H(on,{deviceId:t.deviceId,trackId:t.trackId,...(x?.markForTrain??t.markForTrain)===void 0?{}:{markForTrain:x?.markForTrain??t.markForTrain},...(x?.debug??t.debug)===void 0?{}:{debug:x?.debug??t.debug},onChange:c}),I(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[H($,{label:`Camera`,value:r}),H($,{label:`Class`,value:t.className}),H($,{label:`Label`,value:t.label??`—`}),H($,{label:`Sub-label`,value:t.subLabel??`—`}),H($,{label:`Importance`,value:se}),H($,{label:`Zones visited`,value:K}),H($,{label:`Audio heard`,value:le}),H($,{label:`Total distance`,value:fe}),H($,{label:`First seen`,value:pe}),H($,{label:`Last seen`,value:he}),H($,{label:`Track`,value:t.trackId,mono:!0})]})]}),H(`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:H(`span`,{title:i?void 0:Et,children:I(d,{variant:`secondary`,onClick:ae,disabled:!i||f.isPending,children:[f.isPending?H(J,{className:`h-3.5 w-3.5 animate-spin`}):H(je,{className:`h-3.5 w-3.5`}),` `,`Delete track`]})})})]})})}function vn(e){if(e===void 0||!Number.isFinite(e)||e<=0)return``;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return`${String(n)}m ${String(r).padStart(2,`0`)}s`}function yn({row:e,cameraName:t,nowMs:n,onOpenDetail:r,selected:i=!1,onToggleSelect:a,score:o}){let s=Pe(e.bestEventId?`${Ie}/${e.bestEventId}`:void 0),c=Math.round(e.importance*100),l=o===void 0?void 0:Math.round(o*100),u=vn(e.windowMs),d=()=>r(e);return I(`div`,{className:`relative flex flex-col rounded-md border bg-surface overflow-hidden ${i?`border-primary ring-1 ring-primary`:`border-border`}`,children:[I(`div`,{className:`aspect-video relative overflow-hidden bg-surface-hover`,children:[s.src?H(`img`,{src:s.src,alt:`Event from ${t}`,onClick:d,className:`h-full w-full cursor-zoom-in object-cover`}):H(`button`,{type:`button`,onClick:d,className:`flex h-full w-full flex-col items-center justify-center gap-1 bg-surface-hover text-foreground-subtle`,title:s.failed?`Key-event media unavailable`:`No key-event media`,children:H(de,{className:`h-6 w-6 opacity-60`})}),a&&H(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(St(e.deviceId,e.trackId))},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?H(be,{className:`h-4 w-4 text-primary`}):H(xe,{className:`h-4 w-4`})}),l!==void 0&&I(`span`,{className:`absolute left-1 top-1 z-10 rounded bg-primary/85 px-1.5 py-0.5 text-[10px] font-semibold text-white tabular-nums`,title:`CLIP semantic-match score`,children:[String(l),`%`]}),c>0&&H(`span`,{className:`absolute right-1 top-1 z-10 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-semibold text-white`,children:String(c)}),(e.markForTrain===!0||e.debug===!0)&&I(`span`,{className:`absolute bottom-1 left-1 z-10 flex gap-1`,children:[e.markForTrain===!0&&H(`span`,{className:`rounded bg-primary/85 p-0.5 text-white`,title:`Marked for training`,"aria-label":`Marked for training`,children:H(Ue,{className:`h-3 w-3`})}),e.debug===!0&&H(`span`,{className:`rounded bg-black/70 p-0.5 text-white`,title:`Flagged for debug`,"aria-label":`Flagged for debug`,children:H(ze,{className:`h-3 w-3`})})]})]}),I(`button`,{type:`button`,onClick:d,className:`min-w-0 px-2 py-1.5 text-left space-y-0.5`,children:[I(`p`,{className:`text-[11px] font-medium text-foreground truncate`,title:e.className,children:[e.className,_t(e)?I(`span`,{className:`text-foreground-subtle`,children:[` · `,_t(e)]}):null]}),H(`p`,{className:`text-[10px] text-foreground-subtle truncate`,title:t,children:t}),I(`div`,{className:`flex items-center justify-between gap-2`,children:[H(`span`,{className:`text-[10px] text-foreground-subtle truncate`,children:le(e.timestamp,n)}),u&&H(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:u})]})]})]})}F();function bn(){let[e,t]=V(!1),n=P(null),[r,i]=V(0),a=N(e=>{n.current!==e&&(n.current=e,i(e=>e+1))},[]);return U(()=>{let e=n.current;if(!e||typeof IntersectionObserver>`u`){t(!1);return}let r=new IntersectionObserver(e=>{let n=e[e.length-1];n&&t(!n.isIntersecting)},{rootMargin:`64px 0px 0px 0px`,threshold:0});return r.observe(e),()=>r.disconnect()},[r]),{ref:a,scrolledPast:e}}F();var xn=[`events-feed`],Sn=60,Cn=[{value:`importance`,label:`Importance`,icon:Re},{value:`time`,label:`Recent`,icon:ie}];function wn(){let e=te(),[n,r]=V(ge),[i,a]=V(new Set),[o,s]=V(new Set),[c,l]=V(0),[u,f]=V(`time`),[p,m]=V(new Set),[h,g]=V(null),[_,y]=V(()=>Date.now());U(()=>{let e=setInterval(()=>y(Date.now()),6e4);return()=>clearInterval(e)},[]);let{since:b,until:x}=R(()=>wt({fromMs:n.fromMs,toMs:n.toMs},_),[n.fromMs,n.toMs,_]),S=bn(),{pending:C,refreshNow:w}=Pt({paused:h!==null||p.size>0||S.scrolledPast}),{data:T}=v({}),E=R(()=>(T??[]).filter(e=>e.type===ne.Camera),[T]),D=R(()=>E.map(e=>e.id),[E]),{data:O,isLoading:k}=t({deviceIds:D},{enabled:D.length>0,staleTime:5*6e4}),A=R(()=>Bt(O??[],i),[O,i]),j=Ot(),M=j.isPending,{rows:N,isLoading:P}=jt({deviceIds:D,since:b,until:x,minImportance:c>0?c:void 0,classFilter:o.size===1?[...o][0]:void 0}),F=R(()=>{let e=new Map;for(let t of E??[])e.set(t.id,t.name);return e},[E]),L=e=>F.get(e)??`Camera #${String(e)}`,z=R(()=>K(N).map(e=>({id:e,name:L(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[N,F]),B=R(()=>bt(xt(N,{cameras:i,classes:o,minImportance:c}),u),[N,i,o,c,u]),W=fe(B,Sn,R(()=>JSON.stringify([[...i].sort((e,t)=>e-t),[...o].sort(),c,u,b,x]),[i,o,c,u,b,x])),G=()=>{e.invalidateQueries({queryKey:xn})},re=()=>m(new Set);function ie(e){m(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}function ae(){if(p.size===0||!Tt)return;let e=Ct(N,p),t=[...e.values()].reduce((e,t)=>e+t.length,0);if(t===0||!window.confirm(`Delete ${String(t)} track${t===1?``:`s`} and all their media? This cannot be undone.`))return;let n=[...e];Promise.allSettled(n.map(([e,t])=>j.mutateAsync({deviceId:e,trackIds:t}))).then(e=>{G();let t=[],r=new Set;if(e.forEach((e,i)=>{let a=n[i];if(!a)return;let[o,s]=a;if(e.status===`fulfilled`)for(let e of s)r.add(St(o,e));else t.push(o)}),m(e=>{let t=new Set(e);for(let e of r)t.delete(e);return t}),t.length>0){let e=t.map(e=>L(e)).join(`, `);window.alert(`Failed to delete tracks on: ${e}. They remain selected — retry, or check the server logs.`)}})}let oe=B.length!==N.length;return I(`div`,{className:`relative space-y-3`,children:[I(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[H(se,{onChange:r}),H(pe,{cameras:z,selected:i,onChange:a}),H(Ft,{groups:A,selected:o,onChange:s,loading:k}),I(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[H(`span`,{children:`Min score`}),H(`input`,{type:`range`,min:0,max:1,step:.05,value:c,onChange:e=>l(Number(e.target.value)),className:`h-1 w-24 cursor-pointer accent-primary`,"aria-label":`Minimum importance`}),H(`span`,{className:`w-6 tabular-nums text-foreground`,children:Math.round(c*100)})]}),H(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Cn.map(e=>{let t=e.icon;return I(`button`,{type:`button`,onClick:()=>f(e.value),className:`flex items-center gap-1 rounded px-2 py-1 text-[11px] transition-colors ${u===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[H(t,{className:`h-3.5 w-3.5`}),` `,e.label]},e.value)})}),!P&&H(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:oe?`${String(B.length)} of ${String(N.length)} events`:`${String(B.length)} event${B.length===1?``:`s`}`})]}),p.size>0&&I(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[I(`span`,{className:`text-xs font-medium text-foreground`,children:[p.size,` selected`]}),I(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[H(`span`,{title:Tt?void 0:`Track deletion arrives with the next server update`,children:I(d,{variant:`secondary`,onClick:ae,disabled:!Tt||M,children:[M?H(J,{className:`h-3.5 w-3.5 animate-spin`}):H(je,{className:`h-3.5 w-3.5`}),` `,`Delete`]})}),H(d,{variant:`ghost`,onClick:re,disabled:M,children:H(ke,{className:`h-3.5 w-3.5`})})]})]}),P&&I(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[H(J,{className:`h-4 w-4 animate-spin`}),` Loading events…`]}),!P&&B.length===0&&H(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:`No key events in this window.`}),C&&H(`div`,{className:`sticky top-2 z-20 flex justify-center`,children:H(`button`,{type:`button`,onClick:w,className:`rounded-full border border-primary/40 bg-surface px-3 py-1 text-[11px] font-medium text-primary shadow-sm hover:bg-primary/10`,children:`New events — refresh`})}),!P&&B.length>0&&I(ee,{children:[H(`div`,{ref:S.ref,"aria-hidden":!0,className:`h-0`}),H(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-2`,children:W.pageItems.map(e=>H(yn,{row:e,cameraName:L(e.deviceId),nowMs:_,selected:p.has(St(e.deviceId,e.trackId)),onToggleSelect:ie,onOpenDetail:g},St(e.deviceId,e.trackId)))}),H(he,{currentPage:W.page,totalItems:W.totalItems,pageSize:W.pageSize,onPageChange:W.setPage,itemNoun:`events`})]}),h&&H(_n,{row:h,cameraName:L(h.deviceId),deleteAvailable:Tt,onClose:()=>g(null),onDeleted:()=>{G(),g(null)},onFlagsChanged:e=>{g(t=>t&&t.trackId===e.trackId?{...t,markForTrain:e.markForTrain,debug:e.debug}:t)}})]})}F();var Tn=50,En=350,Dn=[{value:.2,label:`Loose`},{value:.25,label:`Balanced`},{value:.3,label:`Strict`}];function On(e){return{id:e.id,trackId:e.trackId??e.id,deviceId:e.deviceId,timestamp:e.timestamp,className:e.className,label:e.label,subLabel:e.subLabel,importance:e.importance??0,bestEventId:e.mediaKey??e.trackId??e.id,windowMs:void 0}}function kn({onActiveChange:e}){let[n,r]=V(``),[i,a]=V(.2),[o,s]=V(null),[c,l]=V(null),[u,d]=V(null),f=C(n,En).trim(),p=f.length>0;U(()=>{e(p)},[p,e]);let[m,g]=V(()=>Date.now());U(()=>{let e=setInterval(()=>g(Date.now()),6e4);return()=>clearInterval(e)},[]);let{data:_}=v({}),y=R(()=>(_??[]).filter(e=>e.type===ne.Camera),[_]),b=R(()=>{let e=new Map;for(let t of _??[])e.set(t.id,t.name);return e},[_]),x=e=>b.get(e)??`Camera #${String(e)}`,S=R(()=>y.map(e=>e.id),[y]),{data:w}=t({deviceIds:S},{enabled:S.length>0,staleTime:5*6e4}),T=R(()=>zt(w??[],new Set(c===null?[]:[c])),[w,c]);U(()=>{o!==null&&(T.some(e=>e.kind===o)||s(null))},[T,o]);let{data:E,isFetching:D,isError:O,error:k}=h({text:f,minScore:i,limit:Tn,classFilter:o??void 0,deviceId:c??void 0},{enabled:p}),A=R(()=>[...E??[]].sort((e,t)=>t.score-e.score).map(e=>({...On(e),score:e.score})),[E]);function M(e){s(t=>t===e?null:e)}return I(`div`,{className:`space-y-3`,children:[I(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-3`,children:[I(`div`,{className:`flex flex-wrap items-center gap-2`,children:[I(`div`,{className:`relative min-w-[16rem] flex-1`,children:[H(ye,{className:`pointer-events-none absolute left-2.5 top-1/2 h-4 w-4 -translate-y-1/2 text-foreground-subtle`}),H(`input`,{type:`text`,value:n,onChange:e=>r(e.target.value),placeholder:`Semantic search — describe what you're looking for…`,className:`h-9 w-full rounded-md border border-border bg-background pl-8 pr-8 text-sm text-foreground placeholder:text-foreground-subtle focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary`,"aria-label":`Semantic event search`}),n&&H(`button`,{type:`button`,onClick:()=>r(``),className:`absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Clear search`,children:H(ke,{className:`h-3.5 w-3.5`})})]}),D&&p&&H(J,{className:`h-4 w-4 shrink-0 animate-spin text-foreground-subtle`})]}),I(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2`,children:[H(`div`,{className:`flex items-center gap-1`,children:T.map(e=>H(`button`,{type:`button`,onClick:()=>M(e.kind),className:`rounded-md px-2.5 py-1 text-xs transition-colors ${o===e.kind?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:j(e)},e.kind))}),I(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[H(`span`,{children:`Camera`}),I(`select`,{value:c===null?``:String(c),onChange:e=>l(e.target.value===``?null:Number(e.target.value)),className:`h-7 rounded-md border border-border bg-background px-1.5 text-xs text-foreground focus:border-primary focus:outline-none`,"aria-label":`Filter by camera`,children:[H(`option`,{value:``,children:`All`}),y.map(e=>H(`option`,{value:String(e.id),children:e.name},e.id))]})]}),I(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[H(`span`,{children:`Match`}),H(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:Dn.map(e=>H(`button`,{type:`button`,onClick:()=>a(e.value),className:`rounded px-2 py-1 text-[11px] transition-colors ${i===e.value?`bg-primary/12 text-primary font-medium`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,title:`Minimum CLIP score ${e.value.toFixed(2)}`,children:e.label},e.value))})]}),p&&!D&&!O&&I(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:[A.length,` match`,A.length===1?``:`es`]})]})]}),p&&I(`div`,{className:`space-y-3`,children:[O&&I(`p`,{className:`py-4 text-xs text-danger`,children:[`Search failed: `,k instanceof Error?k.message:`unknown error`,`. Check that the CLIP embedding step is enabled.`]}),!O&&D&&A.length===0&&I(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[H(J,{className:`h-4 w-4 animate-spin`}),` Searching…`]}),!O&&!D&&A.length===0&&I(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:[`No semantic matches for “`,f,`”. Try a looser match threshold or a different phrasing.`]}),!O&&A.length>0&&H(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(11rem,1fr))] gap-2`,children:A.map(e=>H(yn,{row:e,cameraName:x(e.deviceId),nowMs:m,score:e.score,onOpenDetail:d},e.id))})]}),u&&H(_n,{row:u,cameraName:x(u.deviceId),deleteAvailable:Tt,onClose:()=>d(null),onDeleted:()=>d(null)})]})}var An=15e3;function jn(e){let t=re(),n=B({queries:e.map(e=>({queryKey:[`stationary-objects`,e],staleTime:An,refetchInterval:An,queryFn:async()=>((await t.trpcClient.zoneAnalytics.getCurrentSnapshot.query({deviceId:e}))?.stationaryObjects??[]).map(t=>({...t,deviceId:e}))}))});return{rows:n.flatMap(e=>e.data??[]).toSorted((e,t)=>t.becameStationaryAt-e.becameStationaryAt),isLoading:n.some(e=>e.isLoading)}}F();function Mn(e,t){let n=Math.max(0,Math.round((e-t)/6e4));if(n<1)return`just now`;if(n<60)return`${String(n)}m`;let r=Math.floor(n/60);return`${String(r)}h ${String(n%60)}m`}function Nn({row:e,cameraName:t,nowMs:n}){let r=e.keyFrameMediaKey?.startsWith(`track:`)?e.keyFrameMediaKey.split(`:`)[1]:e.keyFrameMediaKey,i=Pe(r?`${Ie}/${r}`:void 0);return I(`div`,{className:`flex flex-col overflow-hidden rounded-md border border-border bg-surface`,children:[I(`div`,{className:`relative aspect-video overflow-hidden bg-surface-hover`,children:[i.src?H(`img`,{src:i.src,alt:`Parked ${e.className} on ${t}`,className:`h-full w-full object-cover`}):H(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:H(We,{className:`h-6 w-6`})}),H(`span`,{className:`absolute left-1 top-1 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium capitalize text-white`,children:e.label??e.className})]}),I(`div`,{className:`flex flex-col gap-0.5 p-1.5`,children:[H(`span`,{className:`truncate text-[11px] text-foreground`,children:t}),I(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`parked `,Mn(n,e.becameStationaryAt)]})]})]})}function Pn(){let[e,t]=V(!1),n=Date.now(),{data:r}=v({}),i=R(()=>(r??[]).filter(e=>e.type===ne.Camera),[r]),a=R(()=>i.map(e=>e.id),[i]),o=R(()=>{let e=new Map;for(let t of i)e.set(t.id,t.name);return e},[i]),{rows:s}=jn(a);return s.length===0?null:I(`div`,{className:`rounded-md border border-border bg-surface/40`,children:[I(`button`,{type:`button`,onClick:()=>t(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left`,children:[H(e?Te:we,{className:`h-4 w-4 text-foreground-subtle`}),H(We,{className:`h-4 w-4 text-foreground-subtle`}),H(`span`,{className:`text-sm font-semibold text-foreground`,children:`Stationary`}),H(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[10px] font-medium text-foreground-subtle`,children:s.length}),H(`span`,{className:`ml-2 text-[11px] text-foreground-subtle`,children:`Parked objects — kept out of the event feed`})]}),e&&H(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2 p-3 pt-0`,children:s.map(e=>H(Nn,{row:e,cameraName:o.get(e.deviceId)??`Camera #${String(e.deviceId)}`,nowMs:n},e.id))})]})}F();function Fn(){let[e,t]=V(!1);return H(Ne,{children:I(`section`,{className:`space-y-3`,children:[H(kn,{onActiveChange:t}),!e&&H(Pn,{}),!e&&H(wn,{})]})})}var In=[`person`,`vehicle`,`animal`,`package`,`face`,`plate`],Ln=new Set(In);function Rn(e){let t=e?.trim().toLowerCase();return t===void 0||t===``?null:Ln.has(t)?`"${t}" is a macro class, not a label — person / postman / Marco are three different tiers`:null}function zn({annotations:e,selectedIndex:t,onSelect:n,onChange:r,onDelete:a}){return e.length===0?I(`p`,{className:`text-[11px] text-foreground-subtle p-3`,children:[`No subject on this frame yet. Drag on the image to draw one, or ask the pipeline for a proposal. Annotate `,H(`strong`,{children:`every`}),` subject — a frame with one box and three unlabelled people teaches the model that two thirds of the people in it are background.`]}):H(`ul`,{className:`divide-y divide-border`,children:e.map((e,o)=>{let c=o===t,l=Rn(e.label),f=Rn(e.subLabel);return I(`li`,{className:`p-2.5 space-y-1.5 ${c?`bg-surface-hover`:``}`,onFocus:()=>{n(o)},children:[I(`div`,{className:`flex items-center gap-2`,children:[H(s,{className:`w-28`,value:e.macroClass,options:In.map(e=>({value:e,label:e})),onChange:e=>{let t=In.find(t=>t===e.target.value);t!==void 0&&r(o,{macroClass:t})}}),H(s,{className:`w-32`,value:e.kind,options:[{value:`subject`,label:`subject`},{value:`model_error`,label:`model error`}],onChange:e=>{r(o,{kind:e.target.value===`model_error`?`model_error`:`subject`})}}),e.source===`assist`&&I(i,{variant:`info`,children:[e.assistModelId??`assist`,e.assistScore===void 0?``:` ${e.assistScore.toFixed(2)}`]}),H(d,{variant:`ghost`,size:`sm`,"aria-label":`Delete this subject`,onClick:()=>{a(o)},children:H(je,{className:`h-3 w-3`})})]}),I(`div`,{className:`flex items-center gap-2`,children:[H(u,{className:`flex-1`,placeholder:`label (postman, van, cat…)`,value:e.label??``,onChange:e=>{r(o,{label:e.target.value})}}),H(u,{className:`flex-1`,placeholder:`sub-label (a name, a plate…)`,value:e.subLabel??``,onChange:e=>{r(o,{subLabel:e.target.value})}})]}),l!==null&&H(`p`,{className:`text-[11px] text-danger`,children:l}),f!==null&&H(`p`,{className:`text-[11px] text-danger`,children:f})]},`${String(o)}-${String(e.bbox.x)}`)})})}function Bn(e){return e.every(e=>Rn(e.label)===null&&Rn(e.subLabel)===null&&Ln.has(e.macroClass))}function Vn(e){return e<0?0:e>1?1:e}function Hn(e,t,n,r){if(!(e>0)||!(t>0)||!(n>0)||!(r>0))return null;let i=Math.min(e/n,t/r),a=n*i,o=r*i;return{left:(e-a)/2,top:(t-o)/2,width:a,height:o}}function Un(e,t,n){return{x:Vn((e-n.left)/n.width),y:Vn((t-n.top)/n.height)}}function Wn(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(t.x-e.x),h:Math.abs(t.y-e.y)}}function Gn(e){return e.w>=.01&&e.h>=.01}function Kn(e,t){return{left:t.left+e.x*t.width,top:t.top+e.y*t.height,width:e.w*t.width,height:e.h*t.height}}function qn(e,t){let n=-1,r=1/0;return e.forEach((e,i)=>{if(!(t.x>=e.x&&t.x<=e.x+e.w&&t.y>=e.y&&t.y<=e.y+e.h))return;let a=e.w*e.h;a<r&&(n=i,r=a)}),n}F();function Jn({imageSrc:e,imageWidth:t,imageHeight:n,boxes:r,selectedIndex:i,onSelect:a,onDraw:o}){let s=P(null),[c,l]=V({w:0,h:0}),[u,d]=V(null);L(()=>{let e=s.current;if(e===null)return;let t=new ResizeObserver(()=>{l({w:e.clientWidth,h:e.clientHeight})});return t.observe(e),l({w:e.clientWidth,h:e.clientHeight}),()=>{t.disconnect()}},[]);let f=Hn(c.w,c.h,t,n),p=N(e=>{let t=s.current;if(t===null||f===null)return null;let n=t.getBoundingClientRect();return Un(e.clientX-n.left,e.clientY-n.top,f)},[f]);return I(`div`,{ref:s,className:`relative w-full h-full min-h-[280px] bg-surface-sunken select-none touch-none`,onPointerDown:e=>{let t=p(e);t!==null&&(e.currentTarget.setPointerCapture(e.pointerId),d({start:t,current:Wn(t,t)}))},onPointerMove:e=>{if(u===null)return;let t=p(e);t!==null&&d({start:u.start,current:Wn(u.start,t)})},onPointerUp:()=>{if(u===null)return;let e=u.current;d(null),Gn(e)?o(e):a(qn(r.map(e=>e.bbox),u.start))},children:[H(`img`,{src:e,alt:`Frame being annotated`,className:`absolute inset-0 w-full h-full object-contain pointer-events-none`}),f!==null&&r.map((e,t)=>{let n=Kn(e.bbox,f),r=e.kind===`model_error`,a=t===i,o=r?`#ef4444`:a?`#22c55e`:`#3b82f6`;return H(`div`,{className:`absolute pointer-events-none`,style:{left:n.left,top:n.top,width:n.width,height:n.height,border:`${a?`2px`:`1px`} ${r?`dashed`:`solid`} ${o}`,opacity:e.source===`assist`&&!a?.65:1},children:I(`span`,{className:`absolute -top-4 left-0 text-[10px] px-1 rounded`,style:{background:o,color:`#08121f`},children:[e.label??e.macroClass,r?` ✕`:``]})},`${String(t)}-${String(e.bbox.x)}-${String(e.bbox.y)}`)}),u!==null&&f!==null&&H(`div`,{className:`absolute border border-dashed border-primary pointer-events-none`,style:Kn(u.current,f)})]})}function Yn(e){return e>=1e6?`${(e/1e6).toFixed(1)} MB`:`${Math.round(e/1e3)} KB`}function Xn({candidates:e,copies:t,activeFrameId:n,refusals:r,isSelecting:a,onSelectCandidate:o,onOpenCopy:s,onRemoveCopy:c}){let l=new Set(t.map(e=>e.sourceMediaKey)),u=e.filter(e=>!l.has(e.mediaKey));return I(`div`,{className:`space-y-3`,children:[I(`section`,{children:[I(`h3`,{className:`text-xs font-semibold text-foreground mb-1.5`,children:[`In the dataset (`,t.length,`)`]}),t.length===0?H(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No frame copied yet. Selecting a frame copies it into retrain storage immediately — the dataset stops depending on the track's own media from that moment.`}):H(`ul`,{className:`flex flex-wrap gap-2`,children:t.map(e=>H(`li`,{children:I(`div`,{className:`rounded-md border px-2 py-1.5 text-[11px] ${e.frameId===n?`border-primary bg-surface-hover`:`border-border`}`,children:[I(`button`,{type:`button`,className:`flex items-center gap-1.5 text-left`,onClick:()=>{s(e.frameId)},children:[H(De,{className:`h-3 w-3 text-success`}),H(`span`,{className:`font-medium text-foreground`,children:e.sourceKind}),I(`span`,{className:`text-foreground-subtle`,children:[e.width,`×`,e.height,` · `,Yn(e.sizeBytes)]})]}),I(`button`,{type:`button`,"aria-label":`Remove this frame from the dataset`,className:`mt-1 flex items-center gap-1 text-foreground-muted hover:text-danger`,onClick:()=>{c(e.frameId)},children:[H(je,{className:`h-3 w-3`}),`remove`]})]})},e.frameId))})]}),I(`section`,{children:[I(`h3`,{className:`text-xs font-semibold text-foreground mb-1.5`,children:[`Available frames (`,u.length,`)`]}),u.length===0?H(`p`,{className:`text-[11px] text-foreground-subtle`,children:e.length===0?`This track has no whole, unannotated frame left — its media aged out before it was marked. Anything already copied above is still usable.`:`Every available frame is already in the dataset.`}):H(`ul`,{className:`flex flex-wrap gap-2`,children:u.map(e=>{let t=r.get(e.mediaKey);return I(`li`,{children:[I(d,{variant:`secondary`,size:`sm`,disabled:a||t!==void 0,onClick:()=>{o(e.mediaKey)},children:[a?H(J,{className:`h-3 w-3 animate-spin`}):H(t===void 0?He:de,{className:`h-3 w-3`}),H(`span`,{className:`ml-1`,children:e.kind}),H(`span`,{className:`ml-1 text-foreground-subtle`,children:Yn(e.sizeBytes)})]}),t!==void 0&&H(i,{variant:`danger`,className:`ml-1`,children:t})]},e.mediaKey)})})]})]})}function Zn(e){return e.frameCount===0?`untouched`:e.annotationCount===0?`started`:`ready`}var Qn={untouched:{icon:Ve,label:`to do`,variant:`default`},started:{icon:Be,label:`frames only`,variant:`info`},ready:{icon:Ee,label:`annotated`,variant:`success`}};function $n(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function er({tracks:e,isLoading:t,selectedTrackId:n,deviceNames:r,onSelect:a}){return t?I(`div`,{className:`flex items-center gap-2 p-4 text-xs text-foreground-subtle`,children:[H(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading staging tracks…`]}):e.length===0?H(`div`,{className:`p-4 text-xs text-foreground-subtle`,children:`Nothing in staging. Mark a track for training from the viewer or the Events grid and it appears here.`}):H(`ul`,{className:`divide-y divide-border`,children:e.map(e=>{let t=Qn[Zn(e)],o=t.icon;return H(`li`,{children:I(`button`,{type:`button`,onClick:()=>{a(e)},className:`w-full text-left px-3 py-2 flex items-start gap-2 hover:bg-surface-hover ${e.trackId===n?`bg-surface-hover`:``}`,children:[H(o,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),I(`span`,{className:`min-w-0 flex-1`,children:[I(`span`,{className:`flex items-center gap-2`,children:[H(`span`,{className:`text-xs font-medium text-foreground truncate`,children:e.label??e.className}),H(i,{variant:t.variant,children:t.label})]}),I(`span`,{className:`block text-[11px] text-foreground-subtle truncate`,children:[r.get(e.deviceId)??`Camera ${String(e.deviceId)}`,` ·`,` `,$n(e.lastSeen)]}),I(`span`,{className:`block text-[11px] text-foreground-muted`,children:[e.frameCount,` frame`,e.frameCount===1?``:`s`,` ·`,` `,e.annotationCount,` subject`,e.annotationCount===1?``:`s`]})]})]})},e.trackId)})})}F();var tr=`person`;function nr(){let[e,t]=V(null),[n,r]=V(null),[a,o]=V([]),[s,c]=V(-1),[l,u]=V(new Map),[m,h]=V(null),_=v({projection:`slim`,isCamera:!0}),y=R(()=>{let e=new Map;for(let t of _.data??[])e.set(t.id,t.name);return e},[_.data]),C=T({}),O=x({trackId:e?.trackId??``},{enabled:e!==null}),k=D({trackId:e?.trackId??``},{enabled:e!==null}),A=p({frameId:n??``},{enabled:n!==null}),j=b(),M=w(),P=g(),F=E(),L=f(),z=S();U(()=>{if(n===null){o([]);return}o((k.data??[]).filter(e=>e.mediaKey===n).map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},...e.subLabel===void 0?{}:{subLabel:e.subLabel},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore}}))),c(-1)},[n,k.data]),U(()=>{let e=O.data?.copies??[];n===null&&e.length>0&&r(e[0].frameId)},[O.data,n]);let B=N(e=>{t(e),r(null),o([]),u(new Map),h(null)},[]),te=N(async t=>{if(e===null)return;let n=await j.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,mediaKeys:[t]});if(n.refused.length>0){let e=new Map(l);for(let t of n.refused)e.set(t.sourceMediaKey,t.reason);u(e)}n.copied.length>0&&r(n.copied[0].frameId),await O.refetch(),await C.refetch()},[e,j,l,O,C]),W=N(async t=>{e!==null&&(await M.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,frameId:t}),n===t&&r(null),await O.refetch(),await k.refetch(),await C.refetch())},[e,M,n,O,k,C]),ne=N(async t=>{if(e===null||n===null)return;h(null);let r=await P.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,frameId:n,subject:t===`package`?{kind:`package`}:{kind:`objects`,modelId:`yolo26n`,minScore:.3}});if(r.kind===`refused`){h(r.reason===`no-zone`?`A package proposal runs on the zone crop only — this camera has no zone, and running the detector on the whole frame at 0.35 proposes furniture.`:`The pipeline refused: ${r.reason}${r.detail===void 0?``:` — ${r.detail}`}`);return}o(e=>[...e,...r.proposals.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label===void 0?{}:{label:e.label},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore}}))]),h(`${r.proposals.length} proposal${r.proposals.length===1?``:`s`} from ${r.modelId}`+(r.belowThreshold>0?` — ${r.belowThreshold} more were below ${r.minScore.toFixed(2)}`:``))},[e,n,P]),G=N(e=>{o(t=>[...t,{bbox:e,macroClass:tr,kind:`subject`,source:`operator`}]),c(a.length)},[a.length]),re=N((e,t)=>{o(n=>n.map((n,r)=>r===e?{...n,...t}:n))},[]),ie=N(e=>{o(t=>t.filter((t,n)=>n!==e)),c(-1)},[]),ae=N(async()=>{e===null||n===null||(await F.mutateAsync({deviceId:e.deviceId,trackId:e.trackId,frameId:n,annotations:a.map(e=>({bbox:e.bbox,macroClass:e.macroClass,...e.label!==void 0&&e.label!==``?{label:e.label}:{},...e.subLabel!==void 0&&e.subLabel!==``?{subLabel:e.subLabel}:{},kind:e.kind,source:e.source,...e.assistModelId===void 0?{}:{assistModelId:e.assistModelId},...e.assistScore===void 0?{}:{assistScore:e.assistScore}}))}),await k.refetch(),await C.refetch(),h(`Annotations saved.`))},[e,n,a,F,k,C]),oe=N(async()=>{if(e===null)return;let n=await L.mutateAsync({deviceId:e.deviceId,trackId:e.trackId});h(n.changed?`Track completed — it is now trained, and its own media is evictable again.`:n.reason===`no-frames-copied`?`Refused: no frame was ever copied into the dataset. Completing would let retention delete material nothing was extracted from.`:`Refused: ${n.reason??`unknown`}`),await C.refetch(),n.changed&&t(null)},[e,L,C]),se=N(async()=>{if(e===null)return;let t=await z.mutateAsync({deviceId:e.deviceId,trackId:e.trackId});h(t.changed?`Track returned to staging. Its copies and annotations were left alone.`:`Refused: ${t.reason??`unknown`}`),await C.refetch()},[e,z,C]),K=A.data,ce=Bn(a)&&n!==null;return I(Ne,{subtitle:`Turn the tracks you marked for training into an annotated dataset. Selecting a frame copies it — the dataset never depends on media that can be swept.`,actions:e===null?null:I(`div`,{className:`flex items-center gap-2`,children:[I(d,{variant:`secondary`,size:`sm`,onClick:()=>void se(),children:[H(Se,{className:`h-3 w-3`}),H(`span`,{className:`ml-1`,children:`Back to staging`})]}),I(d,{size:`sm`,onClick:()=>void oe(),children:[H(Ue,{className:`h-3 w-3`}),H(`span`,{className:`ml-1`,children:`Complete track`})]})]}),children:[m!==null&&H(`div`,{className:`rounded-md border border-border bg-surface px-3 py-2 text-xs text-foreground`,children:m}),I(`div`,{className:`grid grid-cols-1 lg:grid-cols-[minmax(0,260px)_minmax(0,1fr)] gap-4`,children:[I(`aside`,{className:`rounded-md border border-border bg-surface overflow-hidden`,children:[I(`div`,{className:`px-3 py-2 border-b border-border flex items-center justify-between`,children:[H(`h2`,{className:`text-xs font-semibold text-foreground`,children:`Staging`}),H(i,{children:C.data?.length??0})]}),H(er,{tracks:C.data??[],isLoading:C.isLoading,selectedTrackId:e?.trackId??null,deviceNames:y,onSelect:B})]}),H(`section`,{className:`space-y-3 min-w-0`,children:e===null?H(`p`,{className:`text-xs text-foreground-subtle`,children:`Pick a track from the staging list to start annotating it.`}):I(ee,{children:[H(`div`,{className:`rounded-md border border-border bg-surface p-3`,children:H(Xn,{candidates:O.data?.candidates??[],copies:O.data?.copies??[],activeFrameId:n,refusals:l,isSelecting:j.isPending,onSelectCandidate:e=>void te(e),onOpenCopy:r,onRemoveCopy:e=>void W(e)})}),n!==null&&I(`div`,{className:`grid grid-cols-1 xl:grid-cols-[minmax(0,1fr)_minmax(0,380px)] gap-3`,children:[H(`div`,{className:`rounded-md border border-border overflow-hidden`,children:K===void 0?I(`div`,{className:`flex items-center gap-2 p-6 text-xs text-foreground-subtle`,children:[H(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading the frame…`]}):H(Jn,{imageSrc:`data:image/jpeg;base64,${K.base64}`,imageWidth:K.width,imageHeight:K.height,boxes:a,selectedIndex:s,onSelect:c,onDraw:G})}),I(`div`,{className:`rounded-md border border-border bg-surface flex flex-col min-h-0`,children:[I(`div`,{className:`px-3 py-2 border-b border-border flex items-center gap-2`,children:[H(`h2`,{className:`text-xs font-semibold text-foreground flex-1`,children:`Subjects`}),I(d,{variant:`secondary`,size:`sm`,disabled:P.isPending,onClick:()=>void ne(`objects`),children:[H(Ae,{className:`h-3 w-3`}),H(`span`,{className:`ml-1`,children:`Propose`})]}),I(d,{variant:`secondary`,size:`sm`,disabled:P.isPending,onClick:()=>void ne(`package`),children:[H(Ae,{className:`h-3 w-3`}),H(`span`,{className:`ml-1`,children:`Packages`})]})]}),H(`div`,{className:`flex-1 overflow-y-auto`,children:H(zn,{annotations:a,selectedIndex:s,onSelect:c,onChange:re,onDelete:ie})}),I(`div`,{className:`px-3 py-2 border-t border-border flex items-center justify-between`,children:[I(`span`,{className:`text-[11px] text-foreground-subtle`,children:[a.filter(e=>e.kind===`model_error`).length,` marked as model errors`]}),H(d,{size:`sm`,disabled:!ce||F.isPending,onClick:()=>void ae(),children:`Save frame`})]})]})]})]})})]})]})}function rr(){return H(`div`,{className:`flex flex-col p-4`,children:H(Le,{tabs:[{id:`feed`,label:`Feed`,icon:Oe,content:H(Fn,{})},{id:`retrain`,label:`Retrain`,icon:Ue,content:H(nr,{})},{id:`debug`,label:`Debug`,icon:ze,content:H(gt,{})}]})})}export{rr as EventsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$i as e,Ao as t,Bo as n,Fo as r,Mo as i,No as a,Po as o,Qi as s,Ro as c,Vo as l,aa as u,ca as d,ea as f,ia as p,jn as m,jo as h,la as g,na as _,oa as v,ra as y,sa as b,ta as x,ua as S,uo as C}from"./src-DiF3p-RR.js";import{K as w,Q as T,S as E,W as D,b as O,o as k,q as A,x as j,z as M}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{K as N}from"./src-C3IwZqep.js";import{a as P,i as ee,n as F,r as te,t as I}from"./face-bbox-Cb2eJK0t.js";import{a as L,c as R,f as z,i as B,l as ne,m as V,n as re,o as ie,p as ae,r as H,s as oe,t as U,u as se}from"./debounced-invalidate-CoCA-chF.js";import{t as W}from"./pencil-Dbscj0iB.js";import{t as G}from"./plus-kjGKne3v.js";import{t as ce}from"./square-check-big-DTiBKI6p.js";import{t as K}from"./square-NIJNDIvZ.js";import{F as q,G as le,L as ue,R as de,S as J,i as Y,s as X,z as Z}from"./index-Bke_0boK.js";import{t as fe}from"./AdminPage-Dq33XE9j.js";import{r as pe,t as me}from"./authed-media-B8T1dsFh.js";var he=le(`badge-check`,[[`path`,{d:`M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z`,key:`3c2336`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);T();var Q=[[`plateGallery`]];function ge({vehicleId:e}){let t=k(),{data:n,isLoading:r}=u({vehicleId:e}),i=b();function a(n){i.mutate({vehicleId:e,sampleId:n.id},{onSettled:()=>{t.invalidateQueries({queryKey:Q})}})}return r?E(`div`,{className:`flex items-center gap-2 py-3 text-xs text-foreground-subtle`,children:[j(J,{className:`h-3.5 w-3.5 animate-spin`}),`Loading plates…`]}):!n||n.length===0?j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No plates yet.`}):j(`div`,{className:`mt-2 grid grid-cols-3 gap-2 sm:grid-cols-4 md:grid-cols-6`,children:n.map(e=>E(`div`,{className:`group relative overflow-hidden rounded-md border border-border bg-surface`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[e.base64?j(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:e.text,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center text-foreground-subtle`,children:j(Z,{className:`h-6 w-6`})}),j(`button`,{type:`button`,onClick:()=>a(e),disabled:i.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 plate sample`,children:j(Y,{className:`h-4 w-4 text-white`})})]}),j(`p`,{className:`truncate px-1.5 py-1 text-center font-mono text-[11px] font-semibold tracking-wide text-foreground`,title:e.text,children:e.text})]},e.id))})}function _e({vehicle:e,expanded:s,onToggle:u}){let f=k(),[p,m]=A(``),[g,v]=A(!1),[y,b]=A(!1),x=d(),S=_();function C(){m(e.name),v(!0)}function w(){v(!1),m(``)}function T(){let t=p.trim();if(!t||t===e.name){w();return}x.mutate({id:e.id,name:t},{onSettled:()=>{f.invalidateQueries({queryKey:Q}),w()}})}function D(){S.mutate({id:e.id},{onSettled:()=>{f.invalidateQueries({queryKey:Q}),b(!1)}})}return E(`div`,{className:`rounded-md border border-border bg-surface`,children:[E(`div`,{className:`flex items-center gap-2 px-3 py-2`,children:[j(`div`,{className:`h-8 w-12 shrink-0 overflow-hidden rounded border border-border bg-surface-hover`,children:e.coverBase64?j(`img`,{src:`data:image/jpeg;base64,${e.coverBase64}`,alt:e.name,className:`h-full w-full object-cover`}):j(`div`,{className:`flex h-full w-full items-center justify-center`,children:j(Z,{className:`h-4 w-4 text-foreground-subtle`})})}),j(`div`,{className:`flex flex-1 min-w-0 items-center gap-2`,children:g?E(O,{children:[j(c,{value:p,onChange:e=>m(e.target.value),onKeyDown:e=>{e.key===`Enter`&&T(),e.key===`Escape`&&w()},className:`h-6 text-xs`,autoFocus:!0}),j(`button`,{type:`button`,onClick:T,disabled:x.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Confirm rename`,children:j(de,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:w,className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel rename`,children:j(Y,{className:`h-3.5 w-3.5`})})]}):j(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name})}),j(n,{variant:`default`,className:`text-[10px]`,children:e.sampleCount}),!g&&E(`div`,{className:`flex items-center gap-1`,children:[j(`button`,{type:`button`,onClick:C,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle hover:text-foreground`,"aria-label":`Rename`,children:j(W,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>b(!0),className:`p-1 rounded hover:bg-danger/10 text-foreground-subtle hover:text-danger`,"aria-label":`Delete`,children:j(X,{className:`h-3.5 w-3.5`})})]}),j(`button`,{type:`button`,onClick:u,className:`p-1 rounded hover:bg-surface-hover text-foreground-subtle`,"aria-label":s?`Collapse`:`Expand`,children:j(s?ue:q,{className:`h-3.5 w-3.5`})})]}),s&&j(`div`,{className:`border-t border-border px-3 pb-3 pt-2`,children:j(ge,{vehicleId:e.id})}),j(t,{open:y,onOpenChange:e=>!e&&b(!1),children:E(h,{children:[E(o,{children:[j(r,{children:`Delete vehicle`}),E(i,{children:[`Delete `,j(`strong`,{children:e.name}),` and all its plate samples? This cannot be undone.`]})]}),E(a,{children:[j(l,{variant:`secondary`,onClick:()=>b(!1),children:`Cancel`}),E(l,{variant:`danger`,onClick:D,disabled:S.isPending,children:[S.isPending?j(J,{className:`h-3.5 w-3.5 animate-spin`}):null,`Delete`]})]})]})})]})}function ve(){let e=k(),[t,n]=A(``),r=f();function i(){let i=t.trim();i&&r.mutate({name:i},{onSettled:()=>{e.invalidateQueries({queryKey:Q}),n(``)}})}return E(`div`,{className:`flex items-center gap-2 pt-2`,children:[j(c,{placeholder:`New vehicle name…`,value:t,onChange:e=>n(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i()},className:`h-7 text-xs flex-1`}),E(l,{variant:`primary`,size:`sm`,onClick:i,disabled:r.isPending||!t.trim(),children:[r.isPending?j(J,{className:`h-3.5 w-3.5 animate-spin`}):j(G,{className:`h-3.5 w-3.5`}),`Add`]})]})}function ye(){let{data:e,isLoading:t}=v(),[n,r]=A(null);function i(e){r(t=>t===e?null:e)}return t?E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(J,{className:`h-4 w-4 animate-spin`}),`Loading vehicles…`]}):E(`div`,{className:`space-y-2`,children:[(!e||e.length===0)&&j(`p`,{className:`py-2 text-xs text-foreground-subtle`,children:`No vehicles enrolled yet. Add one below.`}),e?.map(e=>j(_e,{vehicle:e,expanded:n===e.id,onToggle:()=>i(e.id)},e.id)),j(ve,{})]})}T();var be=[[`plateGallery`]];function xe(e){let[t,n]=A(null),[r,i]=A(null),[a,o]=A(!1);return M(()=>{if(n(null),i(null),o(!1),!e)return;let t=!1,r=null;return(async()=>{try{let i=await pe(`${me}/${encodeURIComponent(e)}`);if(t)return;r=URL.createObjectURL(i),n(r)}catch{t||o(!0)}})(),()=>{t=!0,r&&URL.revokeObjectURL(r)}},[e]),M(()=>{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 Se(e){let t=e.filter(e=>e.base64.length>0);return t.length===0?null:t.find(e=>/crop|plate/i.test(e.kind))??t[0]}function $({label:e,value:t,mono:n}){return E(`div`,{className:`flex items-baseline justify-between gap-3 py-1.5 border-b border-border/60 last:border-0`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:e}),j(`span`,{className:`min-w-0 truncate text-right text-xs font-medium text-foreground ${n?`font-mono`:``}`,title:t,children:t})]})}function Ce({box:e}){return j(`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:j(`span`,{className:`absolute -top-4 left-0 rounded bg-primary px-1 text-[9px] font-semibold uppercase tracking-wide text-white`,children:`Plate`})})}function we({plate:n,cameraName:r,onClose:i,onAssign:a,onUnassign:o,onDelete:s,actionsPending:u}){let d=k(),{data:f,isFetching:p}=y({plateId:n?.plateId??``},{enabled:n!==null}),m=e(),[g,_]=A(`frame`),[v,b]=A(!1),[x,S]=A(``),{frameSrc:C,naturalWidth:w,naturalHeight:T,failed:O}=xe(n?.keyFrameMediaKey);M(()=>{b(!1),S(``),_(`frame`)},[n?.plateId]);let N=D(()=>{let e=Se(f??[]);return e?`data:image/jpeg;base64,${e.base64}`:n?.base64?`data:image/jpeg;base64,${n.base64}`:null},[f,n]),L=D(()=>!n?.plateBbox||w===null||T===null?null:I(n.plateBbox,w,T),[n?.plateBbox,w,T]);if(n===null)return null;let R=typeof n.keyFrameMediaKey==`string`&&n.keyFrameMediaKey.length>0&&!O,z=R&&g===`frame`,ne=n.assigned?n.vehicleName??`Assigned`:n.recognizedVehicleId?`${n.vehicleName??`Recognized`} (suggested)`:`Unassigned`,re=`${String(Math.round(n.score*100))}%${n.corrected?` · corrected`:``}`;function ie(){n&&(S(n.text),b(!0))}function H(){if(!n)return;let e=x.trim().toUpperCase();if(!e||e===n.text){b(!1);return}m.mutate({plateId:n.plateId,text:e},{onSettled:()=>{d.invalidateQueries({queryKey:be}),b(!1)}})}return j(t,{open:!0,onOpenChange:e=>!e&&i(),children:E(h,{width:`lg`,placement:`sheet-on-mobile`,"aria-label":`Plate detail`,className:`flex 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:h-auto 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:[E(`header`,{className:`flex shrink-0 items-start justify-between gap-2 border-b border-border px-4 py-3`,children:[E(`div`,{className:`min-w-0`,children:[j(`div`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:n.text||`Plate detail`}),j(`div`,{className:`mt-0.5 truncate text-[11px] text-foreground-subtle`,children:r})]}),j(`button`,{type:`button`,onClick:i,className:`rounded p-1 text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,"aria-label":`Close`,children:j(Y,{className:`h-4 w-4`})})]}),E(`div`,{className:`min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-contain px-4 py-3`,children:[R&&E(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5 text-xs`,children:[E(`button`,{type:`button`,onClick:()=>_(`frame`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${g===`frame`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(ee,{className:`h-3.5 w-3.5`}),` Full frame`]}),E(`button`,{type:`button`,onClick:()=>_(`crop`),className:`flex flex-1 items-center justify-center gap-1 rounded px-2 py-1 transition-colors ${g===`crop`?`bg-primary/12 font-medium text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[j(P,{className:`h-3.5 w-3.5`}),` Crop`]})]}),z&&C?j(`div`,{className:`overflow-hidden rounded-lg border border-border bg-background`,children:j(B,{src:C,alt:`Full frame with detected plate`,fit:`natural`,className:`w-full`,overlay:L?j(Ce,{box:L}):void 0})}):N?E(`div`,{className:`relative aspect-[2/1] w-full overflow-hidden rounded-lg border border-border bg-background`,children:[j(B,{src:N,alt:`Detected plate`,className:`h-full w-full`}),p&&j(`div`,{className:`absolute right-2 top-2 rounded-full bg-black/50 p-1 text-white`,children:j(J,{className:`h-3.5 w-3.5 animate-spin`})})]}):E(`div`,{className:`flex aspect-[2/1] w-full flex-col items-center justify-center gap-1.5 rounded-lg border border-border bg-warning/5 text-foreground-subtle`,children:[j(V,{className:`h-8 w-8 text-warning/70`}),j(`span`,{className:`text-[11px] font-medium uppercase tracking-wide text-warning/80`,children:`No image`}),j(`span`,{className:`px-6 text-center text-[10px] text-foreground-subtle`,children:`The crop media for this plate could not be resolved. Safe to delete.`})]}),j(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-2`,children:E(`div`,{className:`flex items-center justify-between gap-3`,children:[j(`span`,{className:`shrink-0 text-[11px] uppercase tracking-wide text-foreground-subtle`,children:`Plate text`}),v?E(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-1.5`,children:[j(c,{value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Enter`&&H(),e.key===`Escape`&&b(!1)},className:`h-7 max-w-[10rem] text-right font-mono text-xs uppercase`,autoFocus:!0}),j(`button`,{type:`button`,onClick:H,disabled:m.isPending,className:`text-success hover:text-success/80 disabled:opacity-50`,"aria-label":`Save corrected text`,children:m.isPending?j(J,{className:`h-3.5 w-3.5 animate-spin`}):j(de,{className:`h-3.5 w-3.5`})}),j(`button`,{type:`button`,onClick:()=>b(!1),className:`text-foreground-subtle hover:text-foreground`,"aria-label":`Cancel`,children:j(Y,{className:`h-3.5 w-3.5`})})]}):E(`button`,{type:`button`,onClick:ie,className:`group flex min-w-0 items-center gap-1.5`,title:`Correct the OCR reading`,children:[j(`span`,{className:`truncate font-mono text-sm font-semibold tracking-wide text-foreground`,children:n.text||`—`}),j(W,{className:`h-3 w-3 shrink-0 text-foreground-subtle group-hover:text-foreground`})]})]})}),E(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-1`,children:[j($,{label:`Camera`,value:r}),j($,{label:`Captured`,value:ae(n.timestamp)}),j($,{label:`Confidence`,value:re}),j($,{label:`Vehicle`,value:ne}),j($,{label:`Track`,value:n.trackId,mono:!0})]})]}),E(`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:[n.assigned?E(l,{variant:`secondary`,onClick:()=>o(n.plateId),disabled:u,children:[j(F,{className:`h-3.5 w-3.5`}),` Detach`]}):E(l,{variant:`primary`,onClick:()=>a(n.plateId),disabled:u,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(l,{variant:`secondary`,onClick:()=>s(n.plateId),disabled:u,children:[j(X,{className:`h-3.5 w-3.5`}),` Delete`]})]})]})})}T();var Te=[[`plateGallery`]];function Ee({plateIds:e,vehicles:n,onDone:u}){let d=k(),p=s(),m=f(),[g,_]=A(``),[v,y]=A(!1),[b,x]=A(null),S=e!==null&&e.length>0,C=e?.length??0;function w(){y(!1),_(``),x(null)}function T(){w(),u()}function D(t){!e||e.length===0||p.mutate({plateIds:[...e],vehicleId:t},{onSettled:()=>{d.invalidateQueries({queryKey:Te}),T()}})}function O(){!e||!g.trim()||m.mutate({name:g.trim()},{onSuccess:e=>{e?.id&&D(e.id)},onError:()=>{d.invalidateQueries({queryKey:Te}),T()}})}let M=p.isPending||m.isPending;return j(t,{open:S,onOpenChange:e=>!e&&T(),children:E(h,{children:[E(o,{children:[j(r,{children:C>1?`Assign ${String(C)} plates to vehicle`:`Assign plate to vehicle`}),j(i,{children:`Select an existing vehicle or create a new one.`})]}),j(`div`,{className:`space-y-1 max-h-56 overflow-y-auto`,children:n.map(e=>E(`button`,{type:`button`,onClick:()=>x(e.id),className:`w-full rounded-md px-3 py-2 text-left text-xs transition-colors ${b===e.id?`bg-primary/12 text-primary`:`hover:bg-surface-hover text-foreground`}`,children:[j(`span`,{className:`font-medium`,children:e.name}),E(`span`,{className:`ml-2 text-foreground-subtle`,children:[e.sampleCount,` plates`]})]},e.id))}),v?j(`div`,{className:`flex items-center gap-2 pt-2 border-t border-border`,children:j(c,{placeholder:`New vehicle name…`,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&O()},autoFocus:!0,className:`flex-1`})}):j(`button`,{type:`button`,onClick:()=>{x(null),y(!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 vehicle…`}),E(a,{children:[j(l,{variant:`secondary`,onClick:T,disabled:M,children:`Cancel`}),v?E(l,{variant:`primary`,onClick:O,disabled:M||!g.trim(),children:[M&&j(J,{className:`h-3.5 w-3.5 animate-spin`}),`Create & assign`]}):E(l,{variant:`primary`,onClick:()=>b&&D(b),disabled:M||!b,children:[M&&j(J,{className:`h-3.5 w-3.5 animate-spin`}),`Assign`,C>1?` ${String(C)}`:``]})]})]})})}T();var De=[[`plateGallery`]],Oe=500,ke=120;function Ae({plate:e,cameraName:t,nowMs:n,selected:r,onToggleSelect:i,onAssign:a,onOpenDetail:o}){let s=k(),c=g(),l=x(),u=()=>{s.invalidateQueries({queryKey:De})},d=()=>o(e.plateId);return E(`div`,{className:`relative flex flex-col overflow-hidden rounded-md border bg-surface ${r?`border-primary ring-1 ring-primary`:`border-border`}`,children:[E(`div`,{className:`relative aspect-[2/1] overflow-hidden bg-surface-hover`,children:[e.base64?j(`img`,{src:`data:image/jpeg;base64,${e.base64}`,alt:`Plate ${e.text} from ${t}`,onClick:d,className:`h-full w-full cursor-zoom-in object-cover`}):E(`button`,{type:`button`,onClick:d,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 plate's crop media is missing. Safe to delete.`,children:[j(V,{className:`h-7 w-7 text-warning/70`}),j(`span`,{className:`text-[9px] font-medium uppercase tracking-wide text-warning/80`,children:`No crop`})]}),j(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),i(e.plateId)},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":r?`Deselect`:`Select`,children:r?j(ce,{className:`h-4 w-4 text-primary`}):j(K,{className:`h-4 w-4`})}),e.corrected&&E(`span`,{className:`absolute right-0 top-0 z-10 flex items-center gap-0.5 rounded-bl-md bg-primary/80 px-1 py-0.5 text-[8px] font-semibold uppercase tracking-wide text-white`,title:`Manually corrected`,children:[j(he,{className:`h-3 w-3`}),` Fixed`]})]}),E(`div`,{className:`min-w-0 px-2 pt-1.5 space-y-0.5`,children:[j(`p`,{className:`truncate font-mono text-xs font-bold tracking-wide text-foreground`,title:e.text,children:e.text||`—`}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,title:t,children:t}),j(`p`,{className:`truncate text-[10px] text-foreground-subtle`,children:z(e.timestamp,n)}),e.vehicleName&&j(`p`,{className:`truncate text-[10px] font-medium text-primary`,title:e.vehicleName,children:e.vehicleName})]}),E(`div`,{className:`mt-1 flex items-center gap-0.5 border-t border-border/60 px-1 py-0.5`,children:[e.assigned?j(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c.mutate({plateId:e.plateId},{onSettled:u})},disabled:c.isPending,className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-warning/10 hover:text-warning disabled:opacity-40`,"aria-label":`Detach plate`,title:`Detach`,children:c.isPending?j(J,{className:`h-4 w-4 animate-spin`}):j(F,{className:`h-4 w-4`})}):j(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),a(e.plateId)},className:`rounded p-1.5 text-foreground-subtle transition-colors hover:bg-primary/10 hover:text-primary`,"aria-label":`Assign plate to vehicle`,title:`Assign to vehicle`,children:j(te,{className:`h-4 w-4`})}),j(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),l.mutate({plateId:e.plateId},{onSettled:u})},disabled:l.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 plate`,title:`Delete plate`,children:l.isPending?j(J,{className:`h-4 w-4 animate-spin`}):j(X,{className:`h-4 w-4`})})]})]})}var je=[{label:`All`,value:`all`},{label:`Unassigned`,value:`unassigned`},{label:`Assigned`,value:`assigned`}];function Me(e,t){return t===`unassigned`?e.filter(e=>!e.assigned):t===`assigned`?e.filter(e=>e.assigned):e}function Ne(){let e=k(),[t,n]=A(`all`),[r,i]=A(oe),[a,o]=A(new Set),[s,c]=A(new Set),[u,d]=A(null),[f,h]=A(null),{data:_,isLoading:y}=p({limit:Oe},{refetchInterval:3e4}),{data:b=[]}=v(),{data:C}=m({}),w=g(),T=S(),M=x(),N=Date.now(),P=_??[],ee=D(()=>{let e=new Map;for(let t of C??[])e.set(t.id,t.name);return e},[C]),I=e=>ee.get(e)??`Camera #${String(e)}`,z=D(()=>R(P).map(e=>({id:e,name:I(e)})).sort((e,t)=>e.name.localeCompare(t.name)),[P,ee]),B=D(()=>ne(se(Me(P,t),r),a),[P,t,r,a]),V=re(B,ke,D(()=>JSON.stringify([t,r.fromMs,r.toMs,[...a].sort((e,t)=>e-t)]),[t,r.fromMs,r.toMs,a])),ae=D(()=>new Map(P.map(e=>[e.plateId,e])),[P]),U=f===null?null:ae.get(f)??null,W=()=>{e.invalidateQueries({queryKey:De})},G=()=>c(new Set);function ce(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let K=[...s],q=T.isPending||M.isPending,le=w.isPending||M.isPending;function ue(){K.length!==0&&T.mutate({plateIds:K},{onSettled:()=>{W(),G()}})}function de(){K.length!==0&&Promise.allSettled(K.map(e=>M.mutateAsync({plateId:e}))).then(()=>{W(),G()})}function Z(e){h(null),d([e])}function fe(e){w.mutate({plateId:e},{onSettled:W}),h(null)}function pe(e){M.mutate({plateId:e},{onSettled:W}),h(null)}let me=B.length!==P.length;return E(`div`,{className:`relative space-y-3`,children:[E(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[j(`div`,{className:`flex items-center gap-1`,children:je.map(e=>j(`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))}),j(L,{onChange:i}),j(ie,{cameras:z,selected:a,onChange:o}),!y&&j(`span`,{className:`ml-auto text-[10px] text-foreground-subtle`,children:me?`${String(B.length)} of ${String(P.length)} plates`:`${String(B.length)} plate${B.length===1?``:`s`}`})]}),s.size>0&&E(`div`,{className:`flex flex-wrap items-center gap-2 rounded-md border border-primary/40 bg-primary/8 px-3 py-2`,children:[E(`span`,{className:`text-xs font-medium text-foreground`,children:[s.size,` selected`]}),E(`div`,{className:`ml-auto flex flex-wrap items-center gap-1.5`,children:[E(l,{variant:`primary`,onClick:()=>d(K),disabled:q,children:[j(te,{className:`h-3.5 w-3.5`}),` Assign`]}),E(l,{variant:`secondary`,onClick:ue,disabled:q,children:[T.isPending?j(J,{className:`h-3.5 w-3.5 animate-spin`}):j(F,{className:`h-3.5 w-3.5`}),` `,`Detach`]}),E(l,{variant:`secondary`,onClick:de,disabled:q,children:[j(X,{className:`h-3.5 w-3.5`}),` Delete`]}),j(l,{variant:`ghost`,onClick:G,disabled:q,children:j(Y,{className:`h-3.5 w-3.5`})})]})]}),y&&E(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[j(J,{className:`h-4 w-4 animate-spin`}),` Loading plates…`]}),!y&&B.length===0&&j(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:P.length>0?`No plates match the current filters.`:`No plates recognized yet.`}),!y&&B.length>0&&E(O,{children:[j(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(9rem,1fr))] gap-2`,children:V.pageItems.map(e=>j(Ae,{plate:e,cameraName:I(e.deviceId),nowMs:N,selected:s.has(e.plateId),onToggleSelect:ce,onAssign:e=>d([e]),onOpenDetail:h},e.plateId))}),j(H,{currentPage:V.page,totalItems:V.totalItems,pageSize:V.pageSize,onPageChange:V.setPage,itemNoun:`plates`})]}),j(we,{plate:U,cameraName:U?I(U.deviceId):``,onClose:()=>h(null),onAssign:Z,onUnassign:fe,onDelete:pe,actionsPending:le}),j(Ee,{plateIds:u,vehicles:b,onDone:()=>{d(null),G()}})]})}T();var Pe=[[`plateGallery`]],Fe=2e3;function Ie(){let e=k(),t=w(e);t.current=e;let n=w(void 0);n.current||=U({delayMs:Fe,invalidate:()=>{t.current.invalidateQueries({queryKey:Pe})}}),M(()=>()=>n.current?.cancel(),[]),C(N.PipelineAnalyticsPlateGalleryChanged,()=>{n.current?.trigger()})}function Le(){return Ie(),j(fe,{icon:Z,title:`Plates`,subtitle:`Manage enrolled vehicles and assign recognized license plates to them.`,children:E(`section`,{className:`space-y-3`,children:[E(`div`,{children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Vehicles`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`Enrolled vehicle identities used for plate recognition. Expand a row to view or remove plate samples.`}),j(ye,{})]}),E(`div`,{className:`pt-4 border-t border-border`,children:[j(`h2`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Recent recognized plates`}),j(`p`,{className:`text-xs text-foreground-subtle mb-3`,children:`License plates read by the detection pipeline. Assign them to a vehicle, correct the OCR text, or delete.`}),j(Ne,{})]})]})})}export{Le as PlatesPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e}from"./index-Bke_0boK.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{G as e}from"./index-Bke_0boK.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{K as e,Q as t,S as n,W as r,q as i,x as a,z as o}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{B as s,F as c,G as l,I as u,L as d,R as f}from"./index-Bke_0boK.js";var p=l(`image-off`,[[`line`,{x1:`2`,x2:`22`,y1:`2`,y2:`22`,key:`a6p6uj`}],[`path`,{d:`M10.41 10.41a2 2 0 1 1-2.83-2.83`,key:`1bzlo9`}],[`line`,{x1:`13.5`,x2:`6`,y1:`13.5`,y2:`21`,key:`1q0aeu`}],[`line`,{x1:`18`,x2:`21`,y1:`12`,y2:`15`,key:`5mozeu`}],[`path`,{d:`M3.59 3.59A1.99 1.99 0 0 0 3 5v14a2 2 0 0 0 2 2h14c.55 0 1.052-.22 1.41-.59`,key:`mmje98`}],[`path`,{d:`M21 15V5a2 2 0 0 0-2-2H9`,key:`43el77`}]]);t();var m={fromMs:null,toMs:null},h=36e5,g=24*h;function _(e,t){switch(e){case`24h`:return{fromMs:t-g,toMs:null};case`7d`:return{fromMs:t-7*g,toMs:null};case`30d`:return{fromMs:t-30*g,toMs:null};case`all`:return m}}function v(e){return e.fromMs!==null||e.toMs!==null}function y(e,t){return v(t)?e.filter(e=>!(t.fromMs!==null&&e.timestamp<t.fromMs||t.toMs!==null&&e.timestamp>t.toMs)):[...e]}function b(e,t){return t.size===0?[...e]:e.filter(e=>t.has(e.deviceId))}function x(e){let t=new Set,n=[];for(let r of e)t.has(r.deviceId)||(t.add(r.deviceId),n.push(r.deviceId));return n}function S(e){if(!e)return null;let t=Date.parse(`${e}T00:00:00`);return Number.isNaN(t)?null:t}function C(e){if(!e)return null;let t=Date.parse(`${e}T23:59:59.999`);return Number.isNaN(t)?null:t}function w(e,t){if(!Number.isFinite(e)||e<=0)return`—`;let n=t-e;return n<6e4?`just now`:n<h?`${String(Math.floor(n/6e4))}m ago`:n<g?`${String(Math.floor(n/h))}h ago`:n<7*g?`${String(Math.floor(n/g))}d ago`:new Date(e).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function T(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleTimeString(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function E(e){return!Number.isFinite(e)||e<=0?`—`:new Date(e).toLocaleString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function D({cameras:t,selected:r,onChange:c}){let[l,u]=i(!1),p=e(null);o(()=>{if(!l)return;function e(e){p.current&&e.target instanceof Node&&!p.current.contains(e.target)&&u(!1)}function t(e){e.key===`Escape`&&u(!1)}return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]);function m(e){let t=new Set(r);t.has(e)?t.delete(e):t.add(e),c(t)}let h=r.size,g=h===0?`All cameras`:h===1?t.find(e=>r.has(e.id))?.name??`1 camera`:`${String(h)} cameras`;return n(`div`,{ref:p,className:`relative`,children:[n(`button`,{type:`button`,onClick:()=>u(e=>!e),disabled:t.length===0,className:`flex items-center gap-1.5 rounded-md border px-2.5 py-1 text-xs transition-colors disabled:opacity-40 ${h>0?`border-primary/40 bg-primary/8 text-primary`:`border-border text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(s,{className:`h-3.5 w-3.5`}),a(`span`,{className:`max-w-[10rem] truncate`,children:g}),a(d,{className:`h-3 w-3 opacity-70`})]}),l&&n(`div`,{className:`absolute left-0 z-30 mt-1 max-h-64 w-[min(15rem,calc(100vw-1.5rem))] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg shadow-black/30`,children:[h>0&&a(`button`,{type:`button`,onClick:()=>c(new Set),className:`mb-1 w-full rounded px-2 py-1 text-left text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:`Clear selection`}),t.map(e=>{let t=r.has(e.id);return n(`button`,{type:`button`,onClick:()=>m(e.id),className:`flex w-full items-center gap-2 rounded px-2 py-1.5 text-left text-xs transition-colors ${t?`bg-primary/10 text-primary`:`text-foreground hover:bg-surface-hover`}`,children:[a(`span`,{className:`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${t?`border-primary bg-primary text-white`:`border-border`}`,children:t&&a(f,{className:`h-2.5 w-2.5`})}),a(`span`,{className:`truncate`,children:e.name})]},e.id)})]})]})}t();var O=[{label:`24h`,value:`24h`},{label:`7d`,value:`7d`},{label:`30d`,value:`30d`},{label:`All`,value:`all`}];function k({onChange:e}){let[t,r]=i(`all`),[o,s]=i(``),[c,l]=i(``);function u(t){r(t),s(``),l(``),e(_(t,Date.now()))}function d(t,n){r(`custom`),s(t),l(n),e({fromMs:S(t),toMs:C(n)})}let f=`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground outline-none focus:border-primary [color-scheme:light] dark:[color-scheme:dark]`;return n(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[a(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:O.map(e=>a(`button`,{type:`button`,onClick:()=>u(e.value),className:`rounded px-2.5 py-1 text-[11px] 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))}),n(`div`,{className:`flex items-center gap-1`,children:[a(`input`,{type:`date`,"aria-label":`From date`,value:o,max:c||void 0,onChange:e=>d(e.target.value,c),className:`${f} ${t===`custom`&&o?`border-primary/50`:``}`}),a(`span`,{className:`text-[11px] text-foreground-subtle`,children:`→`}),a(`input`,{type:`date`,"aria-label":`To date`,value:c,min:o||void 0,onChange:e=>d(o,e.target.value),className:`${f} ${t===`custom`&&c?`border-primary/50`:``}`})]})]})}t();var A=2.6;function j({src:e,alt:t,className:r,overlay:s,fit:c=`contain`}){let[l,u]=i(!1),[d,f]=i(`50% 50%`);o(()=>{u(!1),f(`50% 50%`)},[e]);function p(e){if(!l){let t=e.currentTarget.getBoundingClientRect(),n=(e.clientX-t.left)/t.width*100,r=(e.clientY-t.top)/t.height*100;f(`${String(n)}% ${String(r)}%`)}u(e=>!e)}let m=c===`natural`;return a(`div`,{className:`relative overflow-hidden bg-background ${r??``}`,onClick:p,children:n(`div`,{className:`relative select-none transition-transform duration-200 ease-out ${m?`w-full`:`h-full w-full`} ${l?`cursor-zoom-out`:`cursor-zoom-in`}`,style:{transformOrigin:d,transform:l?`scale(${String(A)})`:`scale(1)`},children:[a(`img`,{src:e,alt:t,draggable:!1,className:m?`block h-auto w-full object-contain`:`h-full w-full object-contain`}),s]})})}var M=2;function N(e,t){if(t<=1)return[{kind:`page`,n:1}];if(t<=7){let e=[];for(let n=1;n<=t;n++)e.push({kind:`page`,n});return e}let n=[],r=Math.max(2,e-M),i=Math.min(t-1,e+M);n.push({kind:`page`,n:1}),r>2&&n.push({kind:`ellipsis`,side:`left`});for(let e=r;e<=i;e++)n.push({kind:`page`,n:e});return i<t-1&&n.push({kind:`ellipsis`,side:`right`}),n.push({kind:`page`,n:t}),n}function P({currentPage:e,totalItems:t,pageSize:r,onPageChange:i,itemNoun:o=`items`}){if(t<=r)return null;let s=Math.ceil(t/r),l=(e-1)*r+1,d=Math.min(e*r,t),f=N(e,s),p=`inline-flex h-7 min-w-7 items-center justify-center rounded-md px-2 text-[11px] transition-colors disabled:opacity-40`;return n(`div`,{className:`flex items-center justify-between gap-4 flex-wrap pt-2 text-[11px] text-foreground-subtle`,children:[n(`span`,{children:[`Showing `,l,`–`,d,` of `,t,` `,o]}),n(`div`,{className:`flex items-center gap-1`,children:[a(`button`,{type:`button`,className:`${p} hover:bg-surface-hover`,onClick:()=>i(e-1),disabled:e<=1,"aria-label":`Previous page`,children:a(u,{className:`h-3.5 w-3.5`})}),f.map(t=>t.kind===`ellipsis`?a(`span`,{className:`px-1 opacity-60`,children:`…`},`ellipsis-${t.side}`):a(`button`,{type:`button`,className:`${p} ${t.n===e?`bg-primary/12 text-primary font-medium`:`hover:bg-surface-hover hover:text-foreground`}`,onClick:()=>i(t.n),"aria-current":t.n===e?`page`:void 0,children:t.n},t.n)),a(`button`,{type:`button`,className:`${p} hover:bg-surface-hover`,onClick:()=>i(e+1),disabled:e>=s,"aria-label":`Next page`,children:a(c,{className:`h-3.5 w-3.5`})})]})]})}t();function F(e,t,n){let[a,s]=i(1);o(()=>{s(1)},[n]);let c=e.length,l=Math.max(1,Math.ceil(c/t)),u=Math.min(a,l);return o(()=>{u!==a&&s(u)},[u,a]),{page:u,setPage:s,pageItems:r(()=>{let n=(u-1)*t;return e.slice(n,n+t)},[e,u,t]),totalPages:l,totalItems:c,pageSize:t}}function I(e){let{delayMs:t,invalidate:n,setTimeoutFn:r=setTimeout,clearTimeoutFn:i=clearTimeout}=e,a;function o(){a===void 0&&(a=r(()=>{a=void 0,n()},t))}function s(){a!==void 0&&(i(a),a=void 0)}return{trigger:o,cancel:s}}export{k as a,x as c,T as d,w as f,j as i,b as l,p as m,F as n,D as o,E as p,P as r,m as s,I as t,y as u};
|