@camstack/addon-admin-ui 1.2.81 → 1.2.82
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-WDALxpq-.js → AddLocationWizard-BwgLlZv7.js} +1 -1
- package/dist/assets/{AddonCollectionPage-D86qUT-8.js → AddonCollectionPage-Cj4wS8-x.js} +1 -1
- package/dist/assets/{Addons-C7jR5jKB.js → Addons-Bez0j4jh.js} +1 -1
- package/dist/assets/{AdminTabs-D6yDsobg.js → AdminTabs-BsOfmLas.js} +1 -1
- package/dist/assets/AiProfiles-CCqpaNjG.js +3 -0
- package/dist/assets/{BrokerForm-DnKqFWQy.js → BrokerForm-Drb3n-di.js} +1 -1
- package/dist/assets/{Build-Ipz6h2Qx.js → Build-BSu-hlCH.js} +5 -5
- package/dist/assets/{Capabilities-wOV3gO99.js → Capabilities-B9tN-DdS.js} +1 -1
- package/dist/assets/{CapabilityBadges-CByvC3eB.js → CapabilityBadges-BNXFPTSR.js} +1 -1
- package/dist/assets/{Cluster-DDXbnzQA.js → Cluster-LnvP_-DT.js} +1 -1
- package/dist/assets/{Data-Btzeyfj7.js → Data-DQoZzIZB.js} +1 -1
- package/dist/assets/{DetectionIntelligence-Dt4la9Ns.js → DetectionIntelligence-CFoMsLZW.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-iY2G54zN.js → DeviceAggregateSection-D7sNSnRE.js} +1 -1
- package/dist/assets/{DeviceDetail-CVuY2t9Q.js → DeviceDetail-COpbvbHy.js} +2 -2
- package/dist/assets/{Devices-DornCZOc.js → Devices-BXT6J0za.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DLdvRzTy.js → EmbedPlayerPage-DQFmWgyi.js} +1 -1
- package/dist/assets/{Events-CEUNSnDV.js → Events-Cepqohr3.js} +1 -1
- package/dist/assets/{FormBuilder-B-sNHhCg.js → FormBuilder-yxzbuGp1.js} +1 -1
- package/dist/assets/{Identity-CLAq5pc-.js → Identity-4UbH5joN.js} +1 -1
- package/dist/assets/{IntegrationDetail-7LmaONwQ.js → IntegrationDetail-FBpSiNiq.js} +1 -1
- package/dist/assets/Integrations-Bg2x55D6.js +1 -0
- package/dist/assets/{Integrations-CDPziDzI.js → Integrations-BlwdDz0G.js} +1 -1
- package/dist/assets/{Logs-Rdo_SjmO.js → Logs-BCcd7cRS.js} +1 -1
- package/dist/assets/{MotionZonesSettings-Bhfztqso.js → MotionZonesSettings-CrtWFnAG.js} +1 -1
- package/dist/assets/{MyAccess-Cuk_gmTY.js → MyAccess-D5kgvplj.js} +1 -1
- package/dist/assets/Network-B0MvXDa9.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-mIPiVij_.js → NodeAddonsSettingsPanel-D-zNagxQ.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-9bqVJEiE.js → NodeInferenceDevices-DBUXozHP.js} +1 -1
- package/dist/assets/Notifications-CblnDXBf.js +1 -0
- package/dist/assets/{Pipeline-C3oEXt8M.js → Pipeline-DpNEvH7k.js} +1 -1
- package/dist/assets/{Plates-DyGd_pUG.js → Plates-CceWOulf.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-CTbYEYkc.js → PrivacyMaskSettings-1sJg0nCf.js} +1 -1
- package/dist/assets/{ProviderIcon-D8aWAoj0.js → ProviderIcon-D6droj6v.js} +1 -1
- package/dist/assets/{Recordings-CcL3TTxW.js → Recordings-ZhiDhtnW.js} +1 -1
- package/dist/assets/{ScanNetworkModal-C8Bakspm.js → ScanNetworkModal-DB571PA-.js} +1 -1
- package/dist/assets/{SceneMonitorEditor-Cx7eASci.js → SceneMonitorEditor-B_qhxMl3.js} +1 -1
- package/dist/assets/{Scenes-DnqImYTT.js → Scenes-CPSr7A8e.js} +1 -1
- package/dist/assets/{Settings-COAxk1-6.js → Settings-DWSXbJID.js} +1 -1
- package/dist/assets/{Showroom-DmEvzSMg.js → Showroom-Cm3xY6GG.js} +1 -1
- package/dist/assets/{Terminal-DasTfEQo.js → Terminal-7ZPYC_zr.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-tsLPdvDU.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CwufIJ7b.js} +1 -1
- package/dist/assets/{bell-ring-B6JDETmm.js → bell-ring-Bzv8dm-v.js} +1 -1
- package/dist/assets/{boxes-DVDxegRH.js → boxes-DyONyMfj.js} +1 -1
- package/dist/assets/{build-cluster-graph-B8Cdzik4.js → build-cluster-graph-BvbjCtkO.js} +1 -1
- package/dist/assets/circle-check-big-abMS-_w1.js +1 -0
- package/dist/assets/{circle-x-a0OLhq9b.js → circle-x-BagyAbVd.js} +1 -1
- package/dist/assets/clock-cR19SlFN.js +1 -0
- package/dist/assets/{copy-EKhXmX92.js → copy-Cg682Ob5.js} +1 -1
- package/dist/assets/{debounced-invalidate-BQ8ML6Ah.js → debounced-invalidate-CcW_auXQ.js} +1 -1
- package/dist/assets/{dist-Df5TpDx0.js → dist-B7jD-S4H.js} +1 -1
- package/dist/assets/{download-BChaquac.js → download--fExXTTV.js} +1 -1
- package/dist/assets/{face-bbox-DKVz3zEq.js → face-bbox-Cz1g9sBR.js} +1 -1
- package/dist/assets/{hard-drive-Dg_uzT-t.js → hard-drive-CeO72W4c.js} +1 -1
- package/dist/assets/{hostInit-CbA0YcFo.js → hostInit-CxhESPfk.js} +1 -1
- package/dist/assets/{index-DhYfPTfU.js → index-C4gpE4dh.js} +3 -3
- package/dist/assets/{key-round-DpXzoCIV.js → key-round-Di2VNu4U.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-631dbdb7.js → mf-entry-bootstrap-0-99898c10.js} +2 -2
- package/dist/assets/{pencil-dvZNet31.js → pencil-DLvxk9x1.js} +1 -1
- package/dist/assets/play-UOl727Zq.js +1 -0
- package/dist/assets/{player-overlays-DXNKqmwI.js → player-overlays-UTlrOH4s.js} +1 -1
- package/dist/assets/plus-CLrUKG39.js +1 -0
- package/dist/assets/power-CozRqx8K.js +1 -0
- package/dist/assets/{radio-CUBDyXa0.js → radio-RZ7CZVIj.js} +1 -1
- package/dist/assets/{refresh-cw-CikJV4hg.js → refresh-cw-6kHXys54.js} +1 -1
- package/dist/assets/remoteEntry-D-9G_Rwp.js +1 -0
- package/dist/assets/rotate-ccw-DV-a5MvB.js +1 -0
- package/dist/assets/rotate-cw-B4c6V4Ez.js +1 -0
- package/dist/assets/search-Diuzp1ZB.js +1 -0
- package/dist/assets/{send-jra0X2FY.js → send-DKjSQk9v.js} +1 -1
- package/dist/assets/{server-CLphEdE1.js → server-cirmHxYC.js} +1 -1
- package/dist/assets/square-DHyM8h05.js +1 -0
- package/dist/assets/{square-check-big-B4oQsHOX.js → square-check-big-ZW9Cb-30.js} +1 -1
- package/dist/assets/{src-DAigq6PX.js → src-C9CFJqET.js} +2 -2
- package/dist/assets/{src-C0QlPpXb.js → src-CEchIfpK.js} +7 -7
- package/dist/assets/{star-Ch9uuiCl.js → star-DYsm4pCY.js} +1 -1
- package/dist/assets/{undo-2-DLrLmKUr.js → undo-2-B4nFfmbK.js} +1 -1
- package/dist/assets/{upload-DVgOLthM.js → upload-CAXNjiO6.js} +1 -1
- package/dist/assets/{use-scenes-feed-DdlE4MDL.js → use-scenes-feed-CCncPGkQ.js} +1 -1
- package/dist/assets/{useEventInvalidation-DqKGeTpc.js → useEventInvalidation-V6uvnrrN.js} +1 -1
- package/dist/assets/{video-DuMIkvBP.js → video-BJrMHLZ5.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DdAFU5xY.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DtSdTes5.js} +2 -2
- package/dist/assets/{wifi-DNsDHc6u.js → wifi-CusedooP.js} +1 -1
- package/dist/assets/{zap-RHfxlZhI.js → zap-DUeFTNxj.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/AiProfiles-DECvat8h.js +0 -3
- package/dist/assets/Integrations-o_BOKz_C.js +0 -1
- package/dist/assets/Network-BAt6cJW9.js +0 -1
- package/dist/assets/Notifications-CwcH2yYC.js +0 -1
- package/dist/assets/circle-check-big-BZnwR-f7.js +0 -1
- package/dist/assets/clock-fhk_ag9V.js +0 -1
- package/dist/assets/play-D6bynunz.js +0 -1
- package/dist/assets/plus-CDo9Tbkz.js +0 -1
- package/dist/assets/power-BF-VFkkW.js +0 -1
- package/dist/assets/remoteEntry-DbX8dE3W.js +0 -1
- package/dist/assets/rotate-ccw-P5OXZofT.js +0 -1
- package/dist/assets/rotate-cw-DDRA2uuI.js +0 -1
- package/dist/assets/search-DhirDmpC.js +0 -1
- package/dist/assets/square-UC6vONGu.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as ee,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$ as te,J as ne,U as re,W as c,Z as ie,ct as l,et as ae,it as oe,j as u,n as se,nt as d}from"./player-overlays-
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as ee,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$ as te,J as ne,U as re,W as c,Z as ie,ct as l,et as ae,it as oe,j as u,n as se,nt as d}from"./player-overlays-UTlrOH4s.js";import{MaskShapeCanvas as f}from"./MaskShapeCanvas-Dcpby34M.js";var p=l(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),ce=l(`mic-off`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M15 9.34V5a3 3 0 0 0-5.68-1.33`,key:`1gzdoj`}],[`path`,{d:`M16.95 16.95A7 7 0 0 1 5 12v-2`,key:`cqa7eg`}],[`path`,{d:`M18.89 13.23A7 7 0 0 0 19 12v-2`,key:`16hl24`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v3a3 3 0 0 0 5.12 2.12`,key:`r2i35w`}]]);n();var m=`Microphone`,h=`The camera encodes no audio at all — live view, recordings, exports and the audio analyzer are all silent.`;function le(e){let t=e.supportsAudioMute===!0,n=t?e.audioEnabled:null,r=e.pendingOn??null;return{label:m,supported:t,on:n===null?null:r??n,available:t&&n!==null,costWhenOff:h}}function ue(e){return!e.available||e.on===null?null:{enabled:!e.on}}var de=120,fe=`privacy-mask`,g=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,_=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`;function v(e){return e.kind===`rect`||e.kind===`polygon`?e:null}function pe(e){let t=new Set(e.map(e=>e.id)),n=0;for(;t.has(n);)n+=1;return n}function y(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(JSON.stringify(e[n])!==JSON.stringify(t[n]))return!1;return!0}function b({deviceId:n}){let l=c(ie().trpcClient,n),[m,h]=a(null),[b,x]=a(!1),[S,C]=a(null),[w,T]=a(null),[E,D]=a(!1),[O,k]=a(!1),[A,j]=a(null),[M,N]=a(null),[me,P]=a(null),[F,I]=a(null),[L,R]=a(null),z=t(!1);s(()=>{if(!l)return;let e=!1;return z.current=!1,h(null),x(!1),C(null),T(null),k(!1),j(null),N(null),P(null),I(null),R(null),(async()=>{try{let t=await l.privacyMask?.getOptions({});if(e)return;if(!t)throw Error(`device proxy not ready`);if(h(t),z.current)return;let n=await l.privacyMask?.getStatus({});if(e)return;if(!n)throw Error(`device proxy not ready`);z.current=!0;let r={enabled:n.enabled,regions:n.regions};T(r),C(r),P(n.audioEnabled)}catch(t){if(e)return;re(t)?x(!0):console.error(`Privacy Mask load failed`,t)}})(),()=>{e=!0}},[l]);let B=i(()=>S!==null&&w!==null&&(S.enabled!==w.enabled||!y(S.regions,w.regions)),[S,w]),V=S?S.regions.length:0,H=m?m.maxRegions:0,U=t(0);s(()=>{U.current=H},[H]);let W=H>0&&V>=H,he=e(()=>{C(e=>e&&{...e,enabled:!e.enabled})},[]),G=e(e=>{j(typeof e==`number`?e:null)},[]),K=i(()=>S?S.regions.map(e=>({id:e.id,shape:e.shape,enabled:e.enabled,label:`Zone ${String(e.id)}`})):[],[S]),q=e((e,t)=>{let n=v(t);n&&C(t=>t&&{...t,regions:t.regions.map(t=>t.id===e?{...t,shape:n}:t)})},[]),J=e(e=>{let t=v(e);t&&(N(null),C(e=>{if(!e)return e;let n=U.current;if(n>0&&e.regions.length>=n)return e;let r=pe(e.regions),i={id:r,enabled:!0,shape:t};return j(r),{...e,regions:[...e.regions,i]}}))},[]),Y=e(e=>{k(!0),j(null),N(e)},[]),ge=e(e=>{k(!0),N(null),j(e)},[]),_e=e(e=>{j(t=>t===e?null:t),C(t=>t&&{...t,regions:t.regions.filter(t=>t.id!==e)})},[]),ve=e(()=>{N(null),j(null),w&&C({enabled:w.enabled,regions:w.regions})},[w]),ye=e(async()=>{if(!(!l||!S)){D(!0);try{await l.privacyMask?.setMask({patch:{enabled:S.enabled,regions:[...S.regions]}});let e=await l.privacyMask?.getStatus({});if(e){let t={enabled:e.enabled,regions:e.regions};T(t),C(t)}}catch(e){console.error(`Privacy Mask save failed`,e)}finally{D(!1)}}},[l,S]),X=le({supportsAudioMute:m===null?null:m.supportsAudioMute,audioEnabled:me,pendingOn:F}),Z=e(async()=>{let e=ue(X);if(!(!l||e===null)){I(e.enabled),R(null);try{await l.privacyMask?.setAudioEnabled(e);let t=await l.privacyMask?.getStatus({});t&&P(t.audioEnabled)}catch(e){console.error(`Privacy microphone write failed — reverting`,e),R(e instanceof Error?e.message:String(e))}finally{I(null)}}},[l,X]),be=e(()=>{k(e=>(e&&(N(null),j(null)),!e))},[]),Q=m?.supportedShapes??[];se(i(()=>O&&!b&&m&&S?{id:fe,order:de,node:o(f,{transparent:!0,items:K,supportedShapes:Q,polygonVertices:m.polygonVertices,selectedId:A,onSelect:G,onShapeChange:q,onDrawComplete:J,drawingKind:M})}:null,[O,b,m,S,K,Q,A,G,q,J,M]));let xe=m?.supportedShapes.includes(`rect`)??!1,Se=m?.supportedShapes.includes(`polygon`)??!1,$=m!==null&&(m.maxRegions<=0||m.supportedShapes.length===0);return l?o(ne,{title:`Privacy Mask`,icon:o(oe,{className:`h-3.5 w-3.5 text-foreground-subtle`}),children:r(`div`,{className:`flex flex-col gap-3`,children:[b||$?o(`p`,{className:`${u} leading-relaxed`,children:`This camera doesn't support an on-board privacy mask.`}):!b&&!$&&m!==null&&S!==null?r(ee,{children:[r(`p`,{className:`${u} leading-relaxed`,children:[`Toggle `,o(`strong`,{className:`text-foreground`,children:`Edit mask`}),` to draw blanked-out zones on the live frame, then `,o(`strong`,{className:`text-foreground`,children:`Save`}),` to push them to the camera. Drag a rectangle to move, its corner to resize; drag polygon vertices, click an edge midpoint to add one, or right-click a vertex to remove it.`]}),r(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[o(`button`,{type:`button`,onClick:be,disabled:E,"aria-pressed":O,className:O?_:g,children:O?`Done editing`:`Edit mask`}),o(`button`,{type:`button`,onClick:he,disabled:E,"aria-pressed":S.enabled,className:S.enabled?_:g,children:S.enabled?`Mask on`:`Mask off`}),xe&&o(`button`,{type:`button`,onClick:()=>Y(`rect`),disabled:E||W,"aria-pressed":M===`rect`,className:M===`rect`?_:g,title:W?`Maximum zones reached`:`Add a rectangle zone`,children:`+ Rect`}),Se&&o(`button`,{type:`button`,onClick:()=>Y(`polygon`),disabled:E||W,"aria-pressed":M===`polygon`,className:M===`polygon`?_:g,title:W?`Maximum zones reached`:`Add a polygon zone`,children:`+ Polygon`}),r(`span`,{className:`${u} ml-1 tabular-nums`,children:[V,` / `,H,` zones`]}),o(`span`,{className:`flex-1`}),o(`button`,{type:`button`,onClick:ve,disabled:E||!B,className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,children:`Revert`}),o(`button`,{type:`button`,onClick:()=>void ye(),disabled:E||!B,className:_,children:E?`Saving…`:`Save`})]}),V>0?o(`div`,{className:`flex flex-col gap-1`,children:S.regions.map(e=>{let t=A===e.id,n=e.shape.kind===`polygon`?p:ae;return r(`div`,{className:`flex items-center gap-2 rounded-md border px-2 py-1 transition-colors ${t?`border-primary/50 bg-primary/10`:`border-border bg-surface`}`,children:[r(`button`,{type:`button`,onClick:()=>ge(e.id),disabled:E,className:`flex flex-1 items-center gap-2 text-left text-[11px] font-medium text-foreground-subtle hover:text-foreground disabled:opacity-40 transition-colors`,children:[o(n,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:[`Zone `,e.id]}),o(`span`,{className:`text-foreground-faint capitalize`,children:e.shape.kind})]}),o(`button`,{type:`button`,onClick:()=>_e(e.id),disabled:E,"aria-label":`Delete zone ${String(e.id)}`,title:`Delete zone`,className:`inline-flex h-6 w-6 items-center justify-center rounded border border-border bg-surface text-foreground-subtle hover:border-red-400/40 hover:bg-red-500/10 hover:text-red-400 disabled:opacity-40 transition-colors`,children:o(te,{className:`h-3.5 w-3.5`})})]},e.id)})}):null]}):o(`p`,{className:`${u} leading-relaxed`,children:`Loading the camera's privacy mask…`}),X.supported&&r(`div`,{className:`flex items-start gap-3 rounded-md border border-border bg-surface px-2 py-2`,children:[o(`button`,{type:`button`,role:`switch`,"aria-label":X.label,"aria-checked":X.on===!0,disabled:!X.available||F!==null,onClick:()=>void Z(),title:X.on===null?`Microphone — state unknown; the camera did not answer.`:X.on?`The camera is capturing sound. Turning it off: ${X.costWhenOff}`:`The camera is silent. ${X.costWhenOff}`,className:X.on===!1||X.on===null?g:_,children:r(`span`,{className:`inline-flex items-center gap-1.5`,children:[X.on===!1?o(ce,{className:`h-3.5 w-3.5`}):o(d,{className:`h-3.5 w-3.5`}),X.on===null?`Microphone unknown`:X.on?`Microphone on`:`Microphone off`]})}),o(`p`,{className:`text-[10px] text-foreground-subtle flex-1 leading-relaxed`,children:L===null?X.on===null?`The camera did not report its microphone, so this state is unknown.`:X.costWhenOff:`Write failed: ${L}`})]})]})}):null}export{b as PrivacyMaskSettings};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{t as i}from"./radio-
|
|
1
|
+
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{t as i}from"./radio-RZ7CZVIj.js";import{t as a}from"./server-cirmHxYC.js";import{t as o}from"./wifi-CusedooP.js";import{K as s}from"./index-C4gpE4dh.js";var c=s(`cctv`,[[`path`,{d:`M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97`,key:`ir91b5`}],[`path`,{d:`M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z`,key:`jlp8i1`}],[`path`,{d:`M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15`,key:`19bib8`}],[`path`,{d:`M2 21v-4`,key:`l40lih`}],[`path`,{d:`M7 9h.01`,key:`19b3jx`}]]),l=s(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`1d0kgt`}]]);e();var u={frigate:{icon:c,color:`#3b82f6`,label:`Frigate`},scrypted:{icon:a,color:`#a855f7`,label:`Scrypted`},reolink:{icon:i,color:`#06b6d4`,label:`Reolink`},homeassistant:{icon:l,color:`#22d3ee`,label:`Home Assistant`},rtsp:{icon:o,color:`#78716c`,label:`RTSP`},onvif:{icon:o,color:`#78716c`,label:`ONVIF`}},d={sm:`h-4 w-4`,md:`h-5 w-5`,lg:`h-6 w-6`},f={sm:`h-7 w-7`,md:`h-8 w-8`,lg:`h-10 w-10`};function p(e){let t=e.toLowerCase();return t.startsWith(`provider-`)?t.slice(9):t}function m(e){return u[p(e)]??{icon:c,color:`#78716c`,label:e}}function h(e){let t=p(e);return`/api/addon-assets/${e.toLowerCase().startsWith(`provider-`)?e:`provider-${t}`}/assets/icon.svg`}function g({type:e,size:i=`md`,showLabel:a}){let o=m(e),s=o.icon,[c,l]=n(!1),u=h(e);return t(`div`,{className:`flex items-center gap-2`,children:[r(`div`,{className:`flex items-center justify-center rounded-lg ${f[i]}`,style:{backgroundColor:`${o.color}15`},children:c?r(s,{className:d[i],style:{color:o.color}}):r(`img`,{src:u,alt:o.label,className:d[i],onError:()=>l(!0)})}),a&&r(`span`,{className:`text-xs font-medium text-foreground-subtle`,children:o.label})]})}export{g as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as c,q as l}from"./player-overlays-DXNKqmwI.js";import{Ba as u,Bo as d,Co as f,Do as p,Fo as m,Ho as h,Io as g,Lo as _,Oo as v,Os as y,Rr as b,So as x,To as S,Uo as C,Vo as w,Wa as T,Yi as E,Zt as D,ea as O,gn as k,ia as A,ko as ee,la as j,ma as te,mn as M,on as ne,tt as N,un as P,wo as re,xo as ie,zo as ae}from"./src-C0QlPpXb.js";import{Tt as F,tt as I}from"./src-DAigq6PX.js";import{t as oe}from"./circle-x-a0OLhq9b.js";import{t as se}from"./download-BChaquac.js";import{t as L}from"./hard-drive-Dg_uzT-t.js";import{C as R,G as ce,K as z,M as B,O as V,V as le,i as ue,s as H}from"./index-DhYfPTfU.js";import{t as de}from"./AdminPage-CCD07UMs.js";import{r as fe}from"./authed-media-BPd_L9jr.js";import{t as pe}from"./DeviceAggregateSection-iY2G54zN.js";import{t as me}from"./AdminTabs-D6yDsobg.js";import{t as U}from"./format-size-CO9d3C3-.js";import{i as W,n as he,r as ge,t as _e}from"./AddLocationWizard-WDALxpq-.js";var G=z(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),K=z(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),ve=z(`settings-2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);t();function ye(){let e=b({}),t=r(()=>(e.data??[]).filter(e=>e.type===I.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,s]=a(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?o(D,{icon:le,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:c??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&o(ne,{deviceId:c,children:o(pe,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();var be=[`high`,`mid`,`low`],xe=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],Se=10080*60*1e3;function q(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ce({onClose:e,onCreated:t}){let i=b({}),s=r(()=>(i.data??[]).filter(e=>e.type===I.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=a(``),[u,d]=a(`high`),[p,m]=a(q(60)),[h,g]=a(q(0)),[_,v]=a(1),[y,x]=a(!0),[S,C]=a(``),[w,T]=a(null),E=c===``?s[0]?.id??null:c,D=new Date(p).getTime(),O=new Date(h).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=f({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:e,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]}),o(`button`,{onClick:e,className:`text-foreground-subtle hover:text-foreground`,children:o(ue,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:E??``,onChange:e=>l(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),o(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:be.map(e=>o(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),o(`input`,{type:`datetime-local`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),o(`input`,{type:`datetime-local`,value:h,onChange:e=>g(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),o(`select`,{value:_,onChange:e=>v(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:xe.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),o(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`e.g. courier at the gate`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),n(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[o(`input`,{type:`checkbox`,checked:y,disabled:_!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),`Include audio`,_===1?``:` (real-time only)`]}),!k&&o(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),w&&o(`p`,{className:`text-[11px] text-danger`,children:w})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:e,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),o(`button`,{onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:u,fromMs:D,toMs:O,options:{includeAudio:y,maxLifeMs:Se,deleteAfterDownload:!1,..._===1?{}:{speed:_},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:A.isPending?`Queuing…`:`Create export`})]})]})})}function we(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function Te(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function Ee(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${Te(e)} · ${o}`}function De(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function Oe(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}t();var ke=[[`recordingExport`]],Ae={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function je(){let{data:e,isLoading:t}=S({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=y(F.RecordingExportProgress,e=>e.exportId),{map:i}=y(F.RecordingExportCompleted,e=>e.exportId),{map:a}=y(F.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>Oe(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function Me(e){let[t,n]=a(()=>Date.now());return s(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ne(){let t=i(),[s,l]=a(!1),u=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=P(),f=c().trpcClient,p=Me(6e4),{rows:m,isLoading:h}=je(),{data:g}=b({}),_=r(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),v=e(()=>{t.invalidateQueries({queryKey:ke})},[t]),y=x({onSuccess:v}),S=re({onSuccess:v}),[C,w]=a(null),T=e(async e=>{w(e.id);try{let{url:t}=await f.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await fe(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),v()}finally{w(null)}},[f,v]),E=e(async e=>{await d({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&y.mutate({exportId:e.id})},[d,y]),O=e(async e=>{await d({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&S.mutate({exportId:e.id})},[d,S]),k=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:Ee(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:we(e.options)})},{key:`state`,header:`State`,render:e=>{let t=Ae[e.state];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&o(R,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&n(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?o(`span`,{className:`text-foreground-subtle`,children:`—`}):o(`span`,{className:`text-foreground-subtle tabular-nums`,children:De(e.expiresAt,p)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:U(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,r=e.state===`queued`||e.state===`rendering`,i=e.state!==`deleted`;return n(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&n(`button`,{onClick:()=>{T(e)},disabled:C===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[C===e.id?o(R,{className:`h-3 w-3 animate-spin`}):o(se,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{E(e)},disabled:y.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[o(oe,{className:`h-3 w-3`}),`Cancel`]}),i&&o(`button`,{onClick:()=>{O(e)},disabled:S.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:o(H,{className:`h-3 w-3`})})]})}}],[_,p,C,y.isPending,S.isPending,T,E,O]);return h&&m.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>l(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]})}),m.length===0?o(D,{icon:V,title:`No exports yet`,description:`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):o(N,{columns:k,rows:m,rowKey:e=>e.id,minWidthPx:720}),s&&o(Ce,{onClose:()=>l(!1),onCreated:u})]})}function J(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Y(e,t){let n=J(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function Pe(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Y(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>J(e).includes(n));return i===void 0?null:{label:Y(i,t),exact:!1}}var X=[`ok`,`warn`,`critical`];function Fe(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Z(e){return Math.min(1,Math.max(0,e))}function Ie(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Z((n-t)/n);return{fraction:r,severity:Fe(r),recordingsFraction:Z(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Le(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=Ie(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||X.indexOf(e.severity)>X.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}t();var Re=[[`recording`]],ze=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],Be={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Ve={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function Q(e){return`${String(Math.round(e*100))}%`}function He(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):`default root`:e.root}function Ue(){let t=i(),s=P(),[c,u]=a(`retention`),{data:d,isLoading:f}=p({},{refetchOnWindowFocus:!1}),{data:m}=b({}),{data:h}=_({}),g=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),v=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.displayName);return e},[h]),y=r(()=>(h??[]).find(e=>e.type===`recordings`&&e.isDefault)?.id??null,[h]),x=r(()=>d?.locations??[],[d?.locations]),S=r(()=>Pe(x,v,y),[x,v,y]),C=r(()=>Le(x),[x]),w=e(()=>{t.invalidateQueries({queryKey:Re})},[t]),T=ee({onSuccess:w}),E=ie({onSuccess:w}),O=e(async e=>{await s({title:`Prune ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${c}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&T.mutate({deviceId:e.deviceId,reason:c})},[s,T,c,g]),k=e(async e=>{await s({title:`Delete all footage for ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${U(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${U(e.usedBytes)}`,variant:`danger`})&&E.mutate({deviceId:e.deviceId})},[s,E,g]),A=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:g.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>S===null?o(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:S.exact?`text-foreground`:`text-foreground-subtle`,title:S.exact?`The only recordings volume on this node — this camera can only be here.`:`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`,children:[S.label,!S.exact&&o(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:U(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{O(e)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[o(K,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{k(e)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[o(H,{className:`h-3 w-3`}),`Delete`]})]})}],[g,S,O,k,T.isPending,E.isPending]);if(f&&!d)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!d)return o(D,{icon:L,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let j=d.devices.length;return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[o(l,{label:`Total used`,icon:o(L,{className:`h-3 w-3`}),footer:`${String(j)} camera${j===1?``:`s`} on ${d.nodeId}`,children:U(d.totalUsedBytes)}),C!==null&&C.severity!==null&&o(l,{label:`Free on recordings volumes`,icon:o(L,{className:`h-3 w-3`}),footer:`across ${String(C.knownVolumes)} volume${C.knownVolumes===1?``:`s`} of ${U(C.totalBytes)}`+(C.unknownVolumes>0?` · ${String(C.unknownVolumes)} did not report capacity`:``),children:o(`span`,{className:`tabular-nums ${Ve[C.severity]}`,children:U(C.freeBytes)})}),x.map(e=>{let t=Ie(e),r=e.locationId??e.root??`default`;return o(l,{label:`Disk: ${He(e,v)}`,footer:t===null?`${U(e.usedBytes)} of recordings · volume capacity unknown`:`${U(t.freeBytes)} free of ${U(t.totalBytes)} · ${U(e.usedBytes)} recordings (${Q(t.recordingsFraction)})`,children:t===null?o(`span`,{className:`tabular-nums`,children:U(e.usedBytes)}):n(`div`,{className:`flex items-center gap-2`,title:`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`,children:[o(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:o(`div`,{className:`h-full rounded ${Be[t.severity]}`,style:{width:Q(t.fraction)}})}),o(`span`,{className:`tabular-nums text-xs ${Ve[t.severity]}`,children:Q(t.fraction)})]})},r)})]}),n(`section`,{className:`flex items-center gap-2 text-xs`,children:[o(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),o(`select`,{id:`prune-reason`,value:c,onChange:e=>{let t=ze.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ze.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),j===0?o(D,{icon:L,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):o(N,{columns:A,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}t();var We=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],Ge={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function Ke(e){return new Date(e).toLocaleString()}function qe(){let[e,t]=a(`all`),{data:i,isLoading:s}=v({},{refetchOnWindowFocus:!1}),{data:c,isLoading:l}=j({},{refetchOnWindowFocus:!1}),{data:u}=b({}),d=r(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),f=r(()=>{let t=[...i??[],...c??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[i,c,e]),p=r(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ke(e.at)})},{key:`domain`,header:`Domain`,render:e=>o(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ge[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>o(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?o(`span`,{className:`text-foreground-subtle`,children:`cluster`}):o(`span`,{className:`text-foreground`,children:d.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?U(e.bytesReclaimed):`—`})}],[d]),m=s||l;return n(`div`,{className:`flex flex-col gap-4`,children:[o(`div`,{className:`flex items-center gap-1`,children:We.map(n=>o(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),m&&f.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):f.length===0?o(D,{icon:ce,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):o(N,{columns:p,rows:f,rowKey:e=>e.id,minWidthPx:720})]})}t();function $({types:e}){let t=i(),s=P(),{data:c}=_({}),l=g(),u=r(()=>l.data??[],[l.data]),[d,f]=a(null),[p,h]=a(null),v=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=C({onSuccess:v}),b=m({onSuccess:v}),x=r(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),S=e=>{e.isDefault||y.mutate(W(e,{isDefault:!0}))},w=(e,t)=>{y.mutate(W(e,{enabled:t}))},T=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&b.mutate({id:e.id})},E=e.map(e=>u.find(t=>t.id===e)).filter(e=>e!==void 0);return n(`div`,{className:`space-y-3`,children:[E.length===0?o(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):E.map(e=>o(ge,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>f(e),onEdit:e=>h(e),onDelete:e=>{T(e)},onSetDefault:e=>S(e),onToggleEnabled:(e,t)=>w(e,t)},e.id)),d!==null&&o(_e,{initialType:d,onClose:()=>f(null),onCreated:()=>{v(),f(null)}}),p!==null&&o(he,{location:p,onClose:()=>h(null),onSaved:()=>{v(),h(null)}})]})}t();var Je=`pipeline-analytics`;function Ye(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Xe(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=M({addonId:Je}),c=Ye(a),l=k({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(R,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Je,patch:{postProcessingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(R,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),o($,{types:[`eventMedia`]})]})]})}t();var Ze=`recorder`;function Qe(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function $e(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=M({addonId:Ze}),c=Qe(a,`recordingNodeId`,`hub`),l=k({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(R,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ze,patch:{recordingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(R,{className:`h-4 w-4 animate-spin text-primary`})]}),c!==`hub`&&n(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,o(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,o(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),o($,{types:[`recordings`,`recordingsLow`]})]})]})}t();var et=2e3;function tt(){let e=P(),t=i(),r=T(),a=u(void 0,{refetchInterval:e=>e.state.data?.state===`running`?et:!1}),c=a.data,l=c?.state===`running`,d=l||r.isPending;s(()=>{c?.state!==`done`||c.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,t]);let f=async()=>{await e({title:`Reconcile storage from disk?`,message:`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`,confirmLabel:`Reconcile`,variant:`warning`})&&(await r.mutateAsync(),await a.refetch())},p=l?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Makes the database match the filesystem for recordings, tracks, events and media. Rows whose files are gone are deleted, including snapshot-less motion events. Enrolled identities stay. The walk runs on the hub; you can leave this page.`}),n(`div`,{className:`mt-3 flex flex-col gap-2`,children:[n(`button`,{type:`button`,onClick:()=>void f(),disabled:d,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[d?o(R,{className:`h-3.5 w-3.5 animate-spin`}):o(L,{className:`h-3.5 w-3.5`}),p]}),c?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(c.completed),` camera(s) — dropped `,String(c.tracks),` tracks,`,` `,String(c.events),` events, `,String(c.mediaDropped),` media`,c.failed.length>0?`, ${String(c.failed.length)} failed (${c.failed.join(`, `)})`:``,`.`]}):null,c?.state===`error`&&c.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,c.error]}):null]})]})}t();var nt=[[`pipelineAnalytics`]],rt=1440*60*1e3,it=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function at(){let t=i(),s=P(),[c,u]=a(30),{data:d,isLoading:f}=A({},{refetchOnWindowFocus:!1}),{data:p}=b({}),m=r(()=>{let e=new Map;for(let t of p??[])e.set(t.id,t.name);return e},[p]),h=e(()=>{t.invalidateQueries({queryKey:nt})},[t]),g=te({onSuccess:h}),_=O({onSuccess:h}),v=e(async()=>{await s({title:`Prune events older than ${String(c)} day${c===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&g.mutate({olderThanMs:Date.now()-c*rt,reason:`retention`})},[s,g,c]),y=e(async e=>{await s({title:`Delete all events for ${m.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${U(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&_.mutate({deviceId:e.deviceId})},[s,_,m]),x=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:m.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:U(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{y(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[o(H,{className:`h-3 w-3`}),`Delete`]})}],[m,y,_.isPending]);return f&&!d?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):d?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[o(l,{label:`Total events`,icon:o(B,{className:`h-3 w-3`}),footer:`across ${String(d.devices.length)} camera${d.devices.length===1?``:`s`}`,children:d.totalRows.toLocaleString()}),o(l,{label:`Event media on disk`,children:U(d.totalBytes)})]}),n(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),o(`select`,{value:c,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:it.map(e=>o(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{v()},disabled:g.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[g.isPending?o(R,{className:`h-3 w-3 animate-spin`}):o(K,{className:`h-3 w-3`}),`Prune now`]})]}),d.devices.length===0?o(D,{icon:B,title:`No stored events`,description:`No camera has persisted events yet.`}):o(N,{columns:x,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):o(D,{icon:B,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}t();var ot=`storage-migration`;function st(){let{data:e}=E(void 0);return(e??[]).some(e=>e.addons.some(e=>e.capabilities.includes(ot)))}var ct=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],lt=new Set([`planning`,`pausing`,`moving`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ut(){return st()?o(dt,{}):o(D,{icon:G,title:`Storage migration not installed`,description:`This system doesn't advertise the storage-migration capability yet. Once it's deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`})}function dt(){let e=P(),{data:t}=_({}),[i,s]=a({}),[c,l]=a(null),[u,f]=a(null),p=r(()=>{let e=new Map;for(let n of t??[]){let t=e.get(n.type);t?t.push(n):e.set(n.type,[n])}return e},[t]),m=h({},{refetchInterval:2e3}),g=m.data??null,v=g!==null&<.has(g.phase),y=r(()=>{let e={};for(let t of ct){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),b=d({destinations:y??{}},{enabled:!1,retry:!1}),x=w(),S=ae(),C=async()=>{if(!y)return;f(null);let e=await b.refetch();if(e.error){f(e.error instanceof Error?e.error.message:String(e.error));return}l(e.data??null)},T=async()=>{if(y&&await e({title:`Start storage migration?`,message:`Pauses the affected writers, copies the data to the new locations, verifies it, then repoints the defaults. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){f(null);try{await x.mutateAsync({destinations:y}),l(null),await m.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}},E=async()=>{if(g&&await e({title:`Cancel migration?`,message:`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`,confirmLabel:`Cancel migration`,variant:`danger`}))try{await S.mutateAsync({jobId:g.jobId}),await m.refetch()}catch{}};return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(G,{className:`h-3.5 w-3.5`}),`Storage migration`]}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media to new storage locations in one coordinated operation: pauses the writers, copies via the recorder / pipeline-analytics movers, verifies, then repoints the defaults. Always applies to every camera — destinations are global defaults per storage class, so migration can't be scoped to a subset of cameras. This is the only supported way to move a storage location's data — the Storage tab no longer offers a per-location "Relocate" action.`}),o(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ct.map(e=>{let t=p.get(e.locationType)??[];return n(`div`,{className:`space-y-1`,children:[o(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;s(t=>({...t,[e.id]:n}))},disabled:v,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`— unchanged —`}),t.map(e=>o(`option`,{value:e.id,children:e.displayName},e.id))]})]},e.id)})}),u&&o(`p`,{className:`mt-2 text-[11px] text-danger`,children:u}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{C()},disabled:!y||b.isFetching||v,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[b.isFetching&&o(R,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{T()},disabled:!y||x.isPending||v,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[x.isPending&&o(R,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),c&&o(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:c.moves.length===0?o(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):c.moves.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))})]}),g&&n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-center justify-between`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Migration status`}),v&&n(`button`,{type:`button`,onClick:()=>{E()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[o(ue,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,o(`span`,{className:`font-medium`,children:g.phase}),v&&o(R,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),g.error&&o(`p`,{className:`mt-1 text-[11px] text-danger`,children:g.error}),g.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,g.pausedParticipants.join(`, `)]}),o(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:g.moves.map(e=>n(`div`,{className:`flex items-center justify-between px-2.5 py-1.5 text-[11px]`,children:[n(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),n(`span`,{className:`text-foreground-subtle`,children:[e.state??`pending`,e.error?` (${e.error})`:``]})]},e.storageClass))})]})]})}function ft(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster recording node and recordings folders.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o($e,{}),o(tt,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Events`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster post-processing node, the events folder, and the durable event-store footprint with retention and per-camera deletion.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o(Xe,{}),o(at,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Migration`}),o(`div`,{className:`mt-3`,children:o(ut,{})})]})]})}function pt(){return o(de,{icon:V,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:o(me,{tabs:[{id:`storage`,label:`Storage`,icon:L,content:o(Ue,{})},{id:`cameras`,label:`Cameras`,icon:le,content:o(ye,{})},{id:`exports`,label:`Export`,icon:V,content:o(Ne,{})},{id:`activity`,label:`Activity`,icon:ce,content:o(qe,{})},{id:`management`,label:`Management`,icon:ve,content:o(ft,{})}]})})}export{pt as RecordingsPage};
|
|
1
|
+
import{I as e,Q as t,S as n,W as r,o as i,q as a,x as o,z as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as c,q as l}from"./player-overlays-UTlrOH4s.js";import{Ba as u,Bo as d,Co as f,Do as p,Fo as m,Ho as h,Io as g,Lo as _,Oo as v,Os as y,Rr as b,So as x,To as S,Uo as C,Vo as w,Wa as T,Yi as E,Zt as D,ea as O,gn as k,ia as A,ko as ee,la as j,ma as te,mn as M,on as ne,tt as N,un as P,wo as re,xo as ie,zo as ae}from"./src-CEchIfpK.js";import{Pt as F,ut as I}from"./src-C9CFJqET.js";import{t as oe}from"./circle-x-BagyAbVd.js";import{t as se}from"./download--fExXTTV.js";import{t as L}from"./hard-drive-CeO72W4c.js";import{C as R,G as ce,K as z,M as B,O as V,V as le,i as ue,s as H}from"./index-C4gpE4dh.js";import{t as de}from"./AdminPage-CCD07UMs.js";import{r as fe}from"./authed-media-BPd_L9jr.js";import{t as pe}from"./DeviceAggregateSection-D7sNSnRE.js";import{t as me}from"./AdminTabs-BsOfmLas.js";import{t as U}from"./format-size-CO9d3C3-.js";import{i as W,n as he,r as ge,t as _e}from"./AddLocationWizard-BwgLlZv7.js";var G=z(`arrow-right-left`,[[`path`,{d:`m16 3 4 4-4 4`,key:`1x1c3m`}],[`path`,{d:`M20 7H4`,key:`zbl0bi`}],[`path`,{d:`m8 21-4-4 4-4`,key:`h9nckh`}],[`path`,{d:`M4 17h16`,key:`g4d7ey`}]]),K=z(`scissors`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M8.12 8.12 12 12`,key:`1alkpv`}],[`path`,{d:`M20 4 8.12 15.88`,key:`xgtan2`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}],[`path`,{d:`M14.8 14.8 20 20`,key:`ptml3r`}]]),ve=z(`settings-2`,[[`path`,{d:`M20 7h-9`,key:`3s1dr2`}],[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);t();function ye(){let e=b({}),t=r(()=>(e.data??[]).filter(e=>e.type===I.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[e.data]),[i,s]=a(null),c=i??t[0]?.id??null;return!e.isLoading&&t.length===0?o(D,{icon:le,title:`No cameras`,description:`Add a camera first.`}):n(`div`,{className:`space-y-3`,children:[n(`div`,{className:`flex items-center gap-2`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:c??``,onChange:e=>s(Number(e.target.value)),className:`rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:t.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),c!==null&&o(ne,{deviceId:c,children:o(pe,{deviceId:c,sectionFilter:e=>e.location===`top-tab`&&e.tab===`recording`})},c)]})}t();var be=[`high`,`mid`,`low`],xe=[{value:1,label:`Real time (1×)`},{value:2,label:`2×`},{value:4,label:`4×`},{value:8,label:`8×`},{value:16,label:`16×`}],Se=10080*60*1e3;function q(e){let t=new Date(Date.now()-e*6e4),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function Ce({onClose:e,onCreated:t}){let i=b({}),s=r(()=>(i.data??[]).filter(e=>e.type===I.Camera).sort((e,t)=>e.name.localeCompare(t.name)),[i.data]),[c,l]=a(``),[u,d]=a(`high`),[p,m]=a(q(60)),[h,g]=a(q(0)),[_,v]=a(1),[y,x]=a(!0),[S,C]=a(``),[w,T]=a(null),E=c===``?s[0]?.id??null:c,D=new Date(p).getTime(),O=new Date(h).getTime(),k=Number.isFinite(D)&&Number.isFinite(O)&&D<O,A=f({onSuccess:()=>{t(),e()},onError:e=>T(e instanceof Error?e.message:String(e))});return o(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-background/80 backdrop-blur-sm`,onClick:e,children:n(`div`,{className:`w-full max-w-md rounded-xl border border-border bg-surface shadow-2xl`,onClick:e=>e.stopPropagation(),children:[n(`div`,{className:`flex items-start justify-between border-b border-border px-4 py-3`,children:[n(`h2`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]}),o(`button`,{onClick:e,className:`text-foreground-subtle hover:text-foreground`,children:o(ue,{className:`h-4 w-4`})})]}),n(`div`,{className:`p-4 space-y-3`,children:[n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Camera`}),o(`select`,{value:E??``,onChange:e=>l(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:s.map(e=>o(`option`,{value:e.id,children:e.name},e.id))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Profile`}),o(`select`,{value:u,onChange:e=>d(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:be.map(e=>o(`option`,{value:e,children:e},e))})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`From`}),o(`input`,{type:`datetime-local`,value:p,onChange:e=>m(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`To`}),o(`input`,{type:`datetime-local`,value:h,onChange:e=>g(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`})]})]}),n(`div`,{className:`grid grid-cols-2 gap-3`,children:[n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Speed`}),o(`select`,{value:_,onChange:e=>v(Number(e.target.value)),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground`,children:xe.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),n(`div`,{className:`space-y-1`,children:[o(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Title (optional)`}),o(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`e.g. courier at the gate`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle`})]})]}),n(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[o(`input`,{type:`checkbox`,checked:y,disabled:_!==1,onChange:e=>x(e.target.checked),className:`accent-primary`}),`Include audio`,_===1?``:` (real-time only)`]}),!k&&o(`p`,{className:`text-[11px] text-danger`,children:`"From" must be before "To".`}),w&&o(`p`,{className:`text-[11px] text-danger`,children:w})]}),n(`div`,{className:`flex justify-end gap-2 border-t border-border px-4 py-3`,children:[o(`button`,{onClick:e,className:`rounded border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground`,children:`Cancel`}),o(`button`,{onClick:()=>{if(E===null||!k)return;T(null);let e=S.trim();A.mutate({deviceId:E,profile:u,fromMs:D,toMs:O,options:{includeAudio:y,maxLifeMs:Se,deleteAfterDownload:!1,..._===1?{}:{speed:_},...e.length>0?{title:e}:{}}})},disabled:E===null||!k||A.isPending,className:`rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:A.isPending?`Queuing…`:`Create export`})]})]})})}function we(e){let t=[];return e.timelapse?t.push(`timelapse ${String(e.timelapse.everyMs/1e3)}s`):(t.push(`${String(e.speed??1)}×`),e.includeAudio&&t.push(`+ audio`)),t.join(` `)}function Te(e){return new Date(e).toLocaleString(void 0,{day:`2-digit`,month:`short`,hour:`2-digit`,minute:`2-digit`})}function Ee(e,t){let n=Math.max(0,Math.round((t-e)/1e3)),r=Math.floor(n/3600),i=Math.floor(n%3600/60),a=n%60,o=r>0?`${String(r)}:${String(i).padStart(2,`0`)}:${String(a).padStart(2,`0`)}`:`${String(i)}:${String(a).padStart(2,`0`)}`;return`${Te(e)} · ${o}`}function De(e,t){let n=e-t;if(n<=0)return`expired`;let r=Math.floor(n/6e4);if(r<60)return`in ${String(r)}m`;let i=Math.floor(r/60);return i<24?`in ${String(i)}h`:`in ${String(Math.floor(i/24))}d`}function Oe(e,t,n,r){return e.map(e=>{if(e.state===`expired`||e.state===`deleted`)return e;let i=r.get(e.id);if(i)return{...e,state:`failed`,error:i.error,progressPct:null};let a=n.get(e.id);if(a)return{...e,state:`ready`,fileBytes:a.fileBytes,progressPct:100};let o=t.get(e.id);return o&&(e.state===`queued`||e.state===`rendering`)?{...e,state:`rendering`,progressPct:o.progressPct}:e})}t();var ke=[[`recordingExport`]],Ae={queued:{cls:`bg-muted text-foreground-subtle`,label:`queued`},rendering:{cls:`bg-primary/10 text-primary`,label:`rendering`,spin:!0},ready:{cls:`bg-success/10 text-success`,label:`ready`},failed:{cls:`bg-danger/10 text-danger`,label:`failed`},expired:{cls:`bg-muted text-foreground-subtle`,label:`expired`},deleted:{cls:`bg-muted text-foreground-subtle`,label:`deleted`}};function je(){let{data:e,isLoading:t}=S({},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data??[]).some(e=>e.state===`queued`||e.state===`rendering`)?3e3:!1}),{map:n}=y(F.RecordingExportProgress,e=>e.exportId),{map:i}=y(F.RecordingExportCompleted,e=>e.exportId),{map:a}=y(F.RecordingExportFailed,e=>e.exportId);return{rows:r(()=>Oe(e??[],n,i,a),[e,n,i,a]),isLoading:t}}function Me(e){let[t,n]=a(()=>Date.now());return s(()=>{let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}function Ne(){let t=i(),[s,l]=a(!1),u=()=>{t.invalidateQueries({queryKey:[[`recordingExport`,`listExports`]]})},d=P(),f=c().trpcClient,p=Me(6e4),{rows:m,isLoading:h}=je(),{data:g}=b({}),_=r(()=>{let e=new Map;for(let t of g??[])e.set(t.id,t.name);return e},[g]),v=e(()=>{t.invalidateQueries({queryKey:ke})},[t]),y=x({onSuccess:v}),S=re({onSuccess:v}),[C,w]=a(null),T=e(async e=>{w(e.id);try{let{url:t}=await f.recordingExport.getDownloadUrl.query({exportId:e.id}),n=await fe(t),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.options.title??e.id}.mp4`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r),v()}finally{w(null)}},[f,v]),E=e(async e=>{await d({title:`Cancel this export?`,message:`Stops the render. The partial file is discarded.`,confirmLabel:`Cancel export`,variant:`danger`})&&y.mutate({exportId:e.id})},[d,y]),O=e(async e=>{await d({title:`Delete this export?`,message:`Permanently removes the rendered file and its history row.`,confirmLabel:`Delete`,variant:`danger`})&&S.mutate({exportId:e.id})},[d,S]),k=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:_.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`range`,header:`Range`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:Ee(e.fromMs,e.toMs)})},{key:`variant`,header:`Variant`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:we(e.options)})},{key:`state`,header:`State`,render:e=>{let t=Ae[e.state];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${t.cls}`,children:[t.spin&&o(R,{className:`h-2.5 w-2.5 animate-spin`}),t.label,e.state===`rendering`&&e.progressPct!==null&&n(`span`,{className:`tabular-nums`,children:[e.progressPct,`%`]})]})}},{key:`expiry`,header:`Expires`,nowrap:!0,render:e=>e.state===`deleted`?o(`span`,{className:`text-foreground-subtle`,children:`—`}):o(`span`,{className:`text-foreground-subtle tabular-nums`,children:De(e.expiresAt,p)})},{key:`size`,header:`Size`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.fileBytes===null?`—`:U(e.fileBytes)})},{key:`actions`,header:``,align:`right`,render:e=>{let t=e.state===`ready`,r=e.state===`queued`||e.state===`rendering`,i=e.state!==`deleted`;return n(`div`,{className:`flex items-center justify-end gap-1`,children:[t&&n(`button`,{onClick:()=>{T(e)},disabled:C===e.id,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-primary/10 hover:text-foreground disabled:opacity-50`,title:`Download MP4`,children:[C===e.id?o(R,{className:`h-3 w-3 animate-spin`}):o(se,{className:`h-3 w-3`}),`Download`]}),r&&n(`button`,{onClick:()=>{E(e)},disabled:y.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Cancel render`,children:[o(oe,{className:`h-3 w-3`}),`Cancel`]}),i&&o(`button`,{onClick:()=>{O(e)},disabled:S.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete export`,children:o(H,{className:`h-3 w-3`})})]})}}],[_,p,C,y.isPending,S.isPending,T,E,O]);return h&&m.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading exports…`]}):n(`div`,{className:`space-y-3`,children:[o(`div`,{className:`flex justify-end`,children:n(`button`,{onClick:()=>l(!0),className:`inline-flex items-center gap-1.5 rounded bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground`,children:[o(V,{className:`h-3.5 w-3.5`}),`New export`]})}),m.length===0?o(D,{icon:V,title:`No exports yet`,description:`Create one here (New export) or from a camera's timeline in the viewer. Rendered clips show up here to download or manage.`}):o(N,{columns:k,rows:m,rowKey:e=>e.id,minWidthPx:720}),s&&o(Ce,{onClose:()=>l(!1),onCreated:u})]})}function J(e){return e.locationIds!==void 0&&e.locationIds.length>0?e.locationIds:e.locationId===null?[]:[e.locationId]}function Y(e,t){let n=J(e);return n.length===0?`default root`:n.map(e=>t.get(e)??e).join(` + `)}function Pe(e,t,n){if(e.length===0)return null;let r=e[0];if(e.length===1&&r!==void 0)return{label:Y(r,t),exact:!0};if(n===null)return null;let i=e.find(e=>J(e).includes(n));return i===void 0?null:{label:Y(i,t),exact:!1}}var X=[`ok`,`warn`,`critical`];function Fe(e){return e>=.95?`critical`:e>=.85?`warn`:`ok`}function Z(e){return Math.min(1,Math.max(0,e))}function Ie(e){let{availableBytes:t,totalBytes:n}=e;if(n===null||n<=0||t===null)return null;let r=Z((n-t)/n);return{fraction:r,severity:Fe(r),recordingsFraction:Z(e.usedBytes/n),freeBytes:t,totalBytes:n}}function Le(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=null;for(let o of e){let e=Ie(o);if(e===null){n+=1;continue}t+=1,r+=e.totalBytes,i+=e.freeBytes,(a===null||X.indexOf(e.severity)>X.indexOf(a))&&(a=e.severity)}return{knownVolumes:t,unknownVolumes:n,totalBytes:r,freeBytes:i,severity:a}}t();var Re=[[`recording`]],ze=[{value:`retention`,label:`Retention policy`},{value:`quota`,label:`Quota / disk pressure`},{value:`operator`,label:`Operator`}],Be={ok:`bg-primary`,warn:`bg-amber-500`,critical:`bg-danger`},Ve={ok:`text-foreground-subtle`,warn:`text-amber-500`,critical:`text-danger`};function Q(e){return`${String(Math.round(e*100))}%`}function He(e,t){let n=e.locationIds??(e.locationId===null?[]:[e.locationId]),r=n.map(e=>t.get(e)).filter(e=>e!==void 0);return r.length>0?r.join(` + `):e.root===void 0?n.length>0?n.join(` + `):`default root`:e.root}function Ue(){let t=i(),s=P(),[c,u]=a(`retention`),{data:d,isLoading:f}=p({},{refetchOnWindowFocus:!1}),{data:m}=b({}),{data:h}=_({}),g=r(()=>{let e=new Map;for(let t of m??[])e.set(t.id,t.name);return e},[m]),v=r(()=>{let e=new Map;for(let t of h??[])e.set(t.id,t.displayName);return e},[h]),y=r(()=>(h??[]).find(e=>e.type===`recordings`&&e.isDefault)?.id??null,[h]),x=r(()=>d?.locations??[],[d?.locations]),S=r(()=>Pe(x,v,y),[x,v,y]),C=r(()=>Le(x),[x]),w=e(()=>{t.invalidateQueries({queryKey:Re})},[t]),T=ee({onSuccess:w}),E=ie({onSuccess:w}),O=e(async e=>{await s({title:`Prune ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Applies the retention policy now (reason: ${c}). Footage beyond the policy is permanently deleted.`,confirmLabel:`Prune now`,variant:`danger`})&&T.mutate({deviceId:e.deviceId,reason:c})},[s,T,c,g]),k=e(async e=>{await s({title:`Delete all footage for ${g.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${U(e.usedBytes)} of recorded footage for this camera. This cannot be undone.`,confirmLabel:`Delete ${U(e.usedBytes)}`,variant:`danger`})&&E.mutate({deviceId:e.deviceId})},[s,E,g]),A=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:g.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`disk`,header:`Disk`,nowrap:!0,render:()=>S===null?o(`span`,{className:`text-foreground-subtle`,children:`—`}):n(`span`,{className:S.exact?`text-foreground`:`text-foreground-subtle`,title:S.exact?`The only recordings volume on this node — this camera can only be here.`:`The recordings DEFAULT. This node has several recordings volumes and the per-camera placement is not reported by recording.getStorageUsage, so this is where footage lands by default rather than a per-camera fact.`,children:[S.label,!S.exact&&o(`span`,{className:`ml-1 text-foreground-subtle`,children:`(default)`})]})},{key:`used`,header:`Used`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:U(e.usedBytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`div`,{className:`flex items-center justify-end gap-1`,children:[n(`button`,{onClick:()=>{O(e)},disabled:T.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,title:`Apply retention policy now`,children:[o(K,{className:`h-3 w-3`}),`Prune`]}),n(`button`,{onClick:()=>{k(e)},disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all footage`,children:[o(H,{className:`h-3 w-3`}),`Delete`]})]})}],[g,S,O,k,T.isPending,E.isPending]);if(f&&!d)return n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading storage usage…`]});if(!d)return o(D,{icon:L,title:`No storage data`,description:`The recording node has not reported any storage usage yet.`});let j=d.devices.length;return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:[o(l,{label:`Total used`,icon:o(L,{className:`h-3 w-3`}),footer:`${String(j)} camera${j===1?``:`s`} on ${d.nodeId}`,children:U(d.totalUsedBytes)}),C!==null&&C.severity!==null&&o(l,{label:`Free on recordings volumes`,icon:o(L,{className:`h-3 w-3`}),footer:`across ${String(C.knownVolumes)} volume${C.knownVolumes===1?``:`s`} of ${U(C.totalBytes)}`+(C.unknownVolumes>0?` · ${String(C.unknownVolumes)} did not report capacity`:``),children:o(`span`,{className:`tabular-nums ${Ve[C.severity]}`,children:U(C.freeBytes)})}),x.map(e=>{let t=Ie(e),r=e.locationId??e.root??`default`;return o(l,{label:`Disk: ${He(e,v)}`,footer:t===null?`${U(e.usedBytes)} of recordings · volume capacity unknown`:`${U(t.freeBytes)} free of ${U(t.totalBytes)} · ${U(e.usedBytes)} recordings (${Q(t.recordingsFraction)})`,children:t===null?o(`span`,{className:`tabular-nums`,children:U(e.usedBytes)}):n(`div`,{className:`flex items-center gap-2`,title:`Volume fill — everything on the disk, not only recordings. Warn at 85%, critical at 95%.`,children:[o(`div`,{className:`h-2 flex-1 overflow-hidden rounded bg-muted`,children:o(`div`,{className:`h-full rounded ${Be[t.severity]}`,style:{width:Q(t.fraction)}})}),o(`span`,{className:`tabular-nums text-xs ${Ve[t.severity]}`,children:Q(t.fraction)})]})},r)})]}),n(`section`,{className:`flex items-center gap-2 text-xs`,children:[o(`label`,{htmlFor:`prune-reason`,className:`text-foreground-subtle`,children:`Prune reason`}),o(`select`,{id:`prune-reason`,value:c,onChange:e=>{let t=ze.find(t=>t.value===e.target.value);t&&u(t.value)},className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:ze.map(e=>o(`option`,{value:e.value,children:e.label},e.value))})]}),j===0?o(D,{icon:L,title:`No recorded footage`,description:`No camera has recorded footage on this node yet.`}):o(N,{columns:A,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]})}t();var We=[{value:`all`,label:`All`},{value:`recording`,label:`Recordings`},{value:`events`,label:`Events`}],Ge={recording:`bg-primary/10 text-primary`,events:`bg-violet-500/10 text-violet-400`};function Ke(e){return new Date(e).toLocaleString()}function qe(){let[e,t]=a(`all`),{data:i,isLoading:s}=v({},{refetchOnWindowFocus:!1}),{data:c,isLoading:l}=j({},{refetchOnWindowFocus:!1}),{data:u}=b({}),d=r(()=>{let e=new Map;for(let t of u??[])e.set(t.id,t.name);return e},[u]),f=r(()=>{let t=[...i??[],...c??[]];return(e===`all`?t:t.filter(t=>t.domain===e)).toSorted((e,t)=>t.at-e.at)},[i,c,e]),p=r(()=>[{key:`at`,header:`When`,nowrap:!0,render:e=>o(`span`,{className:`text-foreground-subtle tabular-nums`,children:Ke(e.at)})},{key:`domain`,header:`Domain`,render:e=>o(`span`,{className:`inline-flex rounded px-1.5 py-0.5 text-[10px] font-medium ${Ge[e.domain]}`,children:e.domain})},{key:`op`,header:`Operation`,render:e=>o(`span`,{className:`text-foreground`,children:e.op})},{key:`reason`,header:`Reason`,render:e=>o(`span`,{className:`text-foreground-subtle`,children:e.reason})},{key:`device`,header:`Camera`,render:e=>e.deviceId===null?o(`span`,{className:`text-foreground-subtle`,children:`cluster`}):o(`span`,{className:`text-foreground`,children:d.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`items`,header:`Items`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.itemsAffected.toLocaleString()})},{key:`bytes`,header:`Reclaimed`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.bytesReclaimed>0?U(e.bytesReclaimed):`—`})}],[d]),m=s||l;return n(`div`,{className:`flex flex-col gap-4`,children:[o(`div`,{className:`flex items-center gap-1`,children:We.map(n=>o(`button`,{onClick:()=>t(n.value),className:`rounded px-2 py-1 text-xs font-medium ${e===n.value?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-muted`}`,children:n.label},n.value))}),m&&f.length===0?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading activity…`]}):f.length===0?o(D,{icon:ce,title:`No activity yet`,description:`Prune, delete and rescan operations across recordings and events show up here.`}):o(N,{columns:p,rows:f,rowKey:e=>e.id,minWidthPx:720})]})}t();function $({types:e}){let t=i(),s=P(),{data:c}=_({}),l=g(),u=r(()=>l.data??[],[l.data]),[d,f]=a(null),[p,h]=a(null),v=()=>{t.invalidateQueries({queryKey:[[`storage`,`listLocations`]]})},y=C({onSuccess:v}),b=m({onSuccess:v}),x=r(()=>{let e=new Map;for(let t of c??[]){let n=e.get(t.type);n?n.push(t):e.set(t.type,[t])}return e},[c]),S=e=>{e.isDefault||y.mutate(W(e,{isDefault:!0}))},w=(e,t)=>{y.mutate(W(e,{enabled:t}))},T=async e=>{if(e.isDefault){await s({title:`Cannot delete default location`,message:`"${e.displayName}" is the default for type "${e.type}". Mark another as default first.`,confirmLabel:`OK`,variant:`warning`});return}await s({title:`Delete location "${e.displayName}"?`,message:`Removes the record; files on disk are untouched.`,confirmLabel:`Delete`,variant:`danger`})&&b.mutate({id:e.id})},E=e.map(e=>u.find(t=>t.id===e)).filter(e=>e!==void 0);return n(`div`,{className:`space-y-3`,children:[E.length===0?o(`p`,{className:`text-[11px] text-foreground-subtle italic`,children:`No storage locations declared for this purpose.`}):E.map(e=>o(ge,{type:e.id,displayName:e.displayName,description:e.description,cardinality:e.cardinality,locations:x.get(e.id)??[],onAdd:e=>f(e),onEdit:e=>h(e),onDelete:e=>{T(e)},onSetDefault:e=>S(e),onToggleEnabled:(e,t)=>w(e,t)},e.id)),d!==null&&o(_e,{initialType:d,onClose:()=>f(null),onCreated:()=>{v(),f(null)}}),p!==null&&o(he,{location:p,onClose:()=>h(null),onSaved:()=>{v(),h(null)}})]})}t();var Je=`pipeline-analytics`;function Ye(e){for(let t of e?.sections??[])for(let e of t.fields??[])if(e.key===`postProcessingNodeId`&&typeof e.value==`string`)return e.value;return`hub`}function Xe(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=M({addonId:Je}),c=Ye(a),l=k({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Post-processing node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that runs detection post-processing (events, media, audio & motion). Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(R,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Je,patch:{postProcessingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(R,{className:`h-4 w-4 animate-spin text-primary`})]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Events folder`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where event crops / full frames are stored. A single folder — no collection / equal-splitting.`}),o($,{types:[`eventMedia`]})]})]})}t();var Ze=`recorder`;function Qe(e,t,n){for(let n of e?.sections??[])for(let e of n.fields??[])if(e.key===t&&typeof e.value==`string`)return e.value;return n}function $e(){let e=i(),{data:t}=E(void 0),{data:a,isLoading:s}=M({addonId:Ze}),c=Qe(a,`recordingNodeId`,`hub`),l=k({onSuccess:()=>{e.invalidateQueries({queryKey:[[`addonSettings`,`getGlobalSettings`]]})}}),u=r(()=>{let e=(t??[]).filter(e=>e.isOnline).map(e=>e.id);return[...new Set([`hub`,c,...e])].filter(Boolean)},[t,c]);return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Recording node`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The single node that records (continuous & events) and serves playback. Every other node stays inert — no multi-node balancing. Takes effect on addon restart.`}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[s?o(R,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):o(`select`,{value:c,onChange:e=>{e.target.value!==c&&l.mutate({addonId:Ze,patch:{recordingNodeId:e.target.value}})},disabled:l.isPending,className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:u.map(e=>o(`option`,{value:e,children:e===`hub`?`hub (default)`:e},e))}),l.isPending&&o(R,{className:`h-4 w-4 animate-spin text-primary`})]}),c!==`hub`&&n(`p`,{className:`mt-2 text-[11px] text-amber-500`,children:[`The stream-broker is hub-only — an agent recorder pulls streams from the hub over the network. The hub's RTSP restream port must be reachable from`,` `,o(`span`,{className:`font-medium`,children:c}),`. If the auto-derived host doesn't work, set the recorder's`,o(`span`,{className:`font-medium`,children:` recordingHubHostname`}),` global setting.`]})]}),n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`mb-1 text-sm font-semibold text-foreground`,children:`Recordings folders`}),o(`p`,{className:`mb-3 text-[11px] text-foreground-subtle`,children:`Where recordings are stored. Multi-location collections — segments are split across the locations of a type. Add a location to grow capacity; mark one default per type.`}),o($,{types:[`recordings`,`recordingsLow`]})]})]})}t();var et=2e3;function tt(){let e=P(),t=i(),r=T(),a=u(void 0,{refetchInterval:e=>e.state.data?.state===`running`?et:!1}),c=a.data,l=c?.state===`running`,d=l||r.isPending;s(()=>{c?.state!==`done`||c.finishedAtMs===null||(t.invalidateQueries({queryKey:[[`recording`]]}),t.invalidateQueries({queryKey:[[`pipelineAnalytics`]]}))},[c?.state,c?.finishedAtMs,t]);let f=async()=>{await e({title:`Reconcile storage from disk?`,message:`Makes the database match the filesystem: recordings index, tracks, events and media whose files are gone. Favourited tracks without files are deleted. Snapshot-less motion/audio events are deleted. Enrolled identities stay. This cannot be undone.`,confirmLabel:`Reconcile`,variant:`warning`})&&(await r.mutateAsync(),await a.refetch())},p=l?c.total>0?`Reconciling ${String(c.completed)}/${String(c.total)}…`:`Reconciling…`:r.isPending?`Reconciling…`:`Reconcile from disk`;return n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Disk reconcile`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Makes the database match the filesystem for recordings, tracks, events and media. Rows whose files are gone are deleted, including snapshot-less motion events. Enrolled identities stay. The walk runs on the hub; you can leave this page.`}),n(`div`,{className:`mt-3 flex flex-col gap-2`,children:[n(`button`,{type:`button`,onClick:()=>void f(),disabled:d,className:`inline-flex w-fit items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-[11px] font-medium border border-border text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[d?o(R,{className:`h-3.5 w-3.5 animate-spin`}):o(L,{className:`h-3.5 w-3.5`}),p]}),c?.state===`done`?n(`p`,{className:`text-[11px] text-foreground-subtle`,children:[`Last run: `,String(c.completed),` camera(s) — dropped `,String(c.tracks),` tracks,`,` `,String(c.events),` events, `,String(c.mediaDropped),` media`,c.failed.length>0?`, ${String(c.failed.length)} failed (${c.failed.join(`, `)})`:``,`.`]}):null,c?.state===`error`&&c.error!==null?n(`p`,{className:`text-[11px] text-destructive`,children:[`Reconcile failed: `,c.error]}):null]})]})}t();var nt=[[`pipelineAnalytics`]],rt=1440*60*1e3,it=[{days:1,label:`1 day`},{days:7,label:`7 days`},{days:30,label:`30 days`},{days:90,label:`90 days`}];function at(){let t=i(),s=P(),[c,u]=a(30),{data:d,isLoading:f}=A({},{refetchOnWindowFocus:!1}),{data:p}=b({}),m=r(()=>{let e=new Map;for(let t of p??[])e.set(t.id,t.name);return e},[p]),h=e(()=>{t.invalidateQueries({queryKey:nt})},[t]),g=te({onSuccess:h}),_=O({onSuccess:h}),v=e(async()=>{await s({title:`Prune events older than ${String(c)} day${c===1?``:`s`}?`,message:`Permanently deletes every event (motion / object / audio) older than the cutoff across all cameras, and their media. This cannot be undone.`,confirmLabel:`Prune events`,variant:`danger`})&&g.mutate({olderThanMs:Date.now()-c*rt,reason:`retention`})},[s,g,c]),y=e(async e=>{await s({title:`Delete all events for ${m.get(e.deviceId)??`#${String(e.deviceId)}`}?`,message:`Permanently deletes ${String(e.rows)} event${e.rows===1?``:`s`} (${U(e.bytes)} of media) for this camera. This cannot be undone.`,confirmLabel:`Delete events`,variant:`danger`})&&_.mutate({deviceId:e.deviceId})},[s,_,m]),x=r(()=>[{key:`camera`,header:`Camera`,render:e=>o(`span`,{className:`text-foreground`,children:m.get(e.deviceId)??`#${String(e.deviceId)}`})},{key:`rows`,header:`Events`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:e.rows.toLocaleString()})},{key:`bytes`,header:`Media`,align:`right`,nowrap:!0,render:e=>o(`span`,{className:`tabular-nums`,children:U(e.bytes)})},{key:`actions`,header:``,align:`right`,render:e=>n(`button`,{onClick:()=>{y(e)},disabled:_.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,title:`Delete all events for this camera`,children:[o(H,{className:`h-3 w-3`}),`Delete`]})}],[m,y,_.isPending]);return f&&!d?n(`div`,{className:`flex items-center gap-2 py-8 text-xs text-foreground-subtle`,children:[o(R,{className:`h-4 w-4 animate-spin`}),`Loading event-store footprint…`]}):d?n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[o(l,{label:`Total events`,icon:o(B,{className:`h-3 w-3`}),footer:`across ${String(d.devices.length)} camera${d.devices.length===1?``:`s`}`,children:d.totalRows.toLocaleString()}),o(l,{label:`Event media on disk`,children:U(d.totalBytes)})]}),n(`section`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[o(`span`,{className:`text-foreground-subtle`,children:`Prune events older than`}),o(`select`,{value:c,onChange:e=>u(Number(e.target.value)),className:`rounded-md border border-border bg-surface px-2 py-1 text-xs text-foreground`,children:it.map(e=>o(`option`,{value:e.days,children:e.label},e.days))}),n(`button`,{onClick:()=>{v()},disabled:g.isPending,className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-xs font-medium text-foreground-subtle hover:bg-amber-500/10 hover:text-amber-500 disabled:opacity-50`,children:[g.isPending?o(R,{className:`h-3 w-3 animate-spin`}):o(K,{className:`h-3 w-3`}),`Prune now`]})]}),d.devices.length===0?o(D,{icon:B,title:`No stored events`,description:`No camera has persisted events yet.`}):o(N,{columns:x,rows:[...d.devices],rowKey:e=>e.deviceId,minWidthPx:480})]}):o(D,{icon:B,title:`No event data`,description:`Pipeline analytics has not reported any event-store footprint yet.`})}t();var ot=`storage-migration`;function st(){let{data:e}=E(void 0);return(e??[]).some(e=>e.addons.some(e=>e.capabilities.includes(ot)))}var ct=[{id:`recordings`,label:`Recordings`,locationType:`recordings`},{id:`recordingsLow`,label:`Low-res recordings`,locationType:`recordingsLow`},{id:`eventMedia`,label:`Event media`,locationType:`eventMedia`}],lt=new Set([`planning`,`pausing`,`moving`,`verifying`,`repointing`,`refreshing`,`resuming`]);function ut(){return st()?o(dt,{}):o(D,{icon:G,title:`Storage migration not installed`,description:`This system doesn't advertise the storage-migration capability yet. Once it's deployed, this panel moves recordings, low-res recordings and event media to new storage locations in one coordinated, verified operation.`})}function dt(){let e=P(),{data:t}=_({}),[i,s]=a({}),[c,l]=a(null),[u,f]=a(null),p=r(()=>{let e=new Map;for(let n of t??[]){let t=e.get(n.type);t?t.push(n):e.set(n.type,[n])}return e},[t]),m=h({},{refetchInterval:2e3}),g=m.data??null,v=g!==null&<.has(g.phase),y=r(()=>{let e={};for(let t of ct){let n=i[t.id];n&&(e[t.id]=n)}return Object.keys(e).length>0?e:void 0},[i]),b=d({destinations:y??{}},{enabled:!1,retry:!1}),x=w(),S=ae(),C=async()=>{if(!y)return;f(null);let e=await b.refetch();if(e.error){f(e.error instanceof Error?e.error.message:String(e.error));return}l(e.data??null)},T=async()=>{if(y&&await e({title:`Start storage migration?`,message:`Pauses the affected writers, copies the data to the new locations, verifies it, then repoints the defaults. Safe to re-run if interrupted.`,confirmLabel:`Start migration`,variant:`danger`})){f(null);try{await x.mutateAsync({destinations:y}),l(null),await m.refetch()}catch(e){f(e instanceof Error?e.message:String(e))}}},E=async()=>{if(g&&await e({title:`Cancel migration?`,message:`Stops the in-progress migration. Data already moved and verified stays at the destination; anything already repointed is not reverted.`,confirmLabel:`Cancel migration`,variant:`danger`}))try{await S.mutateAsync({jobId:g.jobId}),await m.refetch()}catch{}};return n(`div`,{className:`flex flex-col gap-6`,children:[n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`h3`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[o(G,{className:`h-3.5 w-3.5`}),`Storage migration`]}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`Move recordings, low-res recordings and/or event media to new storage locations in one coordinated operation: pauses the writers, copies via the recorder / pipeline-analytics movers, verifies, then repoints the defaults. Always applies to every camera — destinations are global defaults per storage class, so migration can't be scoped to a subset of cameras. This is the only supported way to move a storage location's data — the Storage tab no longer offers a per-location "Relocate" action.`}),o(`div`,{className:`mt-3 grid grid-cols-1 gap-3 sm:grid-cols-3`,children:ct.map(e=>{let t=p.get(e.locationType)??[];return n(`div`,{className:`space-y-1`,children:[o(`label`,{htmlFor:`migration-dest-${e.id}`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e.label}),n(`select`,{id:`migration-dest-${e.id}`,value:i[e.id]??``,onChange:t=>{let n=t.target.value;s(t=>({...t,[e.id]:n}))},disabled:v,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground disabled:opacity-50`,children:[o(`option`,{value:``,children:`— unchanged —`}),t.map(e=>o(`option`,{value:e.id,children:e.displayName},e.id))]})]},e.id)})}),u&&o(`p`,{className:`mt-2 text-[11px] text-danger`,children:u}),n(`div`,{className:`mt-3 flex items-center gap-2`,children:[n(`button`,{type:`button`,onClick:()=>{C()},disabled:!y||b.isFetching||v,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[b.isFetching&&o(R,{className:`h-3 w-3 animate-spin`}),`Plan`]}),n(`button`,{type:`button`,onClick:()=>{T()},disabled:!y||x.isPending||v,className:`inline-flex items-center gap-1.5 rounded bg-primary px-2.5 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[x.isPending&&o(R,{className:`h-3 w-3 animate-spin`}),`Start migration`]})]}),c&&o(`div`,{className:`mt-3 divide-y divide-border rounded-md border border-border`,children:c.moves.length===0?o(`p`,{className:`px-2.5 py-1.5 text-[11px] text-foreground-subtle`,children:`Nothing to move — selected destinations match the current defaults.`}):c.moves.map(e=>n(`div`,{className:`px-2.5 py-1.5 text-[11px] text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]},`${e.storageClass}-${e.toLocationId}`))})]}),g&&n(`section`,{className:`rounded-md border border-border bg-surface p-4`,children:[n(`div`,{className:`flex items-center justify-between`,children:[o(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Migration status`}),v&&n(`button`,{type:`button`,onClick:()=>{E()},className:`inline-flex items-center gap-1 rounded border border-border px-2 py-1 text-[10px] font-medium text-danger hover:bg-danger/10`,children:[o(ue,{className:`h-3 w-3`}),`Cancel`]})]}),n(`p`,{className:`mt-1 text-xs text-foreground`,children:[`Phase: `,o(`span`,{className:`font-medium`,children:g.phase}),v&&o(R,{className:`ml-2 inline h-3 w-3 animate-spin text-primary`})]}),g.error&&o(`p`,{className:`mt-1 text-[11px] text-danger`,children:g.error}),g.pausedParticipants.length>0&&n(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:[`Paused: `,g.pausedParticipants.join(`, `)]}),o(`div`,{className:`mt-2 divide-y divide-border rounded-md border border-border`,children:g.moves.map(e=>n(`div`,{className:`flex items-center justify-between px-2.5 py-1.5 text-[11px]`,children:[n(`span`,{className:`text-foreground`,children:[e.storageClass,`: `,e.fromLocationId,` → `,e.toLocationId]}),n(`span`,{className:`text-foreground-subtle`,children:[e.state??`pending`,e.error?` (${e.error})`:``]})]},e.storageClass))})]})]})}function ft(){return n(`div`,{className:`flex flex-col gap-8`,children:[n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Recording`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster recording node and recordings folders.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o($e,{}),o(tt,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Events`}),o(`p`,{className:`mt-1 text-[11px] text-foreground-subtle`,children:`The cluster post-processing node, the events folder, and the durable event-store footprint with retention and per-camera deletion.`}),n(`div`,{className:`mt-3 flex flex-col gap-6`,children:[o(Xe,{}),o(at,{})]})]}),n(`div`,{children:[o(`h2`,{className:`text-sm font-semibold text-foreground`,children:`Migration`}),o(`div`,{className:`mt-3`,children:o(ut,{})})]})]})}function pt(){return o(de,{icon:V,title:`Recordings`,subtitle:`Recording node & storage, event-store management, exported clips, and an activity log.`,children:o(me,{tabs:[{id:`storage`,label:`Storage`,icon:L,content:o(Ue,{})},{id:`cameras`,label:`Cameras`,icon:le,content:o(ye,{})},{id:`exports`,label:`Export`,icon:V,content:o(Ne,{})},{id:`activity`,label:`Activity`,icon:ce,content:o(qe,{})},{id:`management`,label:`Management`,icon:ve,content:o(ft,{})}]})})}export{pt as RecordingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Er as l,Hr as u,Or as d,Rr as f,bi as p,gr as m,nr as h,or as g,sr as _}from"./src-C0QlPpXb.js";import{t as v}from"./download-BChaquac.js";import{t as y}from"./FormBuilder-B-sNHhCg.js";import{t as b}from"./refresh-cw-CikJV4hg.js";import{C as x,K as S,L as C,i as w,j as T,o as E,t as D,z as O}from"./index-DhYfPTfU.js";import{t as k}from"./BrokerForm-DnKqFWQy.js";var A=S(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]);n();var j=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],M=`/addon/import-alexa`,N=2e3;function P(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function F(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function I(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function L(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function R(e,t,n){let r=await fetch(`${M}${e}`,{method:`POST`,headers:L(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function z(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${M}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!F(i))throw Error(`Unexpected status response from server`);return i}async function B(e){try{await fetch(`${M}/login/cancel`,{method:`POST`,headers:L(),body:JSON.stringify({sessionId:e})})}catch{}}function V({brokerId:n,onResolved:i,onCancel:a}){let[l,u]=o(`amazon.it`),[d,f]=o(`Alexa account`),[p,m]=o({kind:`idle`}),h=t(!0);c(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=t(null),_=t(null),v=e(()=>{_.current!==null&&(clearInterval(_.current),_.current=null)},[]),y=e(async e=>{v(),h.current&&m({kind:`committing`,sessionId:e});try{let t=await R(`/login/commit`,{sessionId:e,name:d.trim().length>0?d.trim():`Alexa account`,...n===void 0?{}:{brokerId:n}},I);g.current=null,i(t.brokerId)}catch(t){let n=t instanceof Error?t.message:String(t);h.current&&m({kind:`error`,message:n,sessionId:e})}},[n,d,i,v]),S=e((e,t)=>{v();let n=async()=>{try{let n=await z(e);if(n.phase===`captured`){v(),y(e);return}if(n.phase===`error`){v(),h.current&&m({kind:`error`,message:n.error??`Login proxy returned an error`,sessionId:e});return}if(n.phase===`cancelled`){v(),h.current&&m({kind:`idle`});return}h.current&&m({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);h.current&&m(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};_.current=setInterval(()=>{n()},N)},[v,y]);c(()=>()=>{v(),g.current!==null&&B(g.current)},[v]);let C=async()=>{v(),g.current!==null&&(B(g.current),g.current=null),m({kind:`starting`});try{let e=await R(`/login/start`,{amazonDomain:l},P);g.current=e.sessionId,m({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),S(e.sessionId,e.loginUrl)}catch(e){m({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},w=()=>{v(),g.current!==null&&(B(g.current),g.current=null),m({kind:`idle`})},D=()=>{w()},O=p.kind===`idle`,k=p.kind===`starting`,A=p.kind===`polling`,M=p.kind===`committing`,F=p.kind===`error`,L=k||A||M,V=p.kind===`polling`?p.phase:null,H=p.kind===`polling`?p.loginUrl:null,U=A&&V===`awaiting-login`,W=A&&(V===`starting`||V===null);return r(`div`,{className:`space-y-4`,children:[(O||F)&&r(`div`,{className:`space-y-3`,children:[n===void 0&&r(`div`,{className:`space-y-1`,children:[s(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Account name`}),s(`input`,{id:`alexa-account-name`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`Alexa account`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`div`,{className:`space-y-1`,children:[s(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Amazon region`}),s(`select`,{id:`alexa-amazon-region`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:j.map(e=>s(`option`,{value:e,children:e},e))})]})]}),F&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[s(E,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),s(`span`,{children:p.message})]}),k&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Starting login proxy…`]}),W&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Waiting for proxy to be ready…`]}),M&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Saving credentials…`]}),U&&H!==null&&r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:`Open the link below to log in to your Amazon account`}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`After completing the login and any 2FA steps, this wizard will continue automatically.`}),r(`a`,{href:H,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[s(T,{className:`h-3.5 w-3.5`}),`Login to Amazon`]})]}),r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[10px] text-amber-700 dark:text-amber-300`,children:[s(`strong`,{children:`Note:`}),` The login proxy runs directly on the hub. If the link does not open or the page does not load, make sure the hub's proxy host and port are reachable from your browser. You can configure `,s(`code`,{className:`font-mono`,children:`proxyHost`}),` in the Alexa addon settings and ensure the proxy port is published (Docker port mapping).`]}),r(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[s(x,{className:`h-3 w-3 animate-spin`}),`Waiting for Amazon login to complete…`]})]}),r(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[s(`button`,{type:`button`,onClick:L?w:a,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:L?`Cancel login`:`Back`}),r(`div`,{className:`flex items-center gap-2`,children:[F&&r(`button`,{type:`button`,onClick:D,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[s(b,{className:`h-3.5 w-3.5`}),`Retry`]}),O&&s(`button`,{type:`button`,onClick:()=>{C()},disabled:n===void 0&&d.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:`Start login`})]})]})]})}n();var H=`alexa`;function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function W(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var G={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function K({kind:e,onResolved:t,onBack:n}){let[a,c]=o(e===H?`alexa-login`:`existing`),l=g({kind:e}),u=i(()=>U(l.data).filter(t=>t.kind===e),[l.data,e]),d=_(),f=i(()=>{for(let t of W(d.data))if(t.kinds.some(t=>t.kind===e))return t.addonId},[d.data,e]),[p,m]=o(null),[v,y]=o(``),b=h({}),S=()=>{p&&t(p)},w=async n=>{v.trim().length!==0&&t((await b.mutateAsync({kind:e,name:v.trim(),settings:n,...f===void 0?{}:{addonId:f}})).id)},T=e=>{e===`new`?m(null):b.reset(),c(e)};return r(`div`,{className:`space-y-4`,children:[r(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[s(C,{className:`h-3.5 w-3.5`}),` Back`]}),r(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[e===H&&s(`button`,{type:`button`,onClick:()=>T(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:`Login interactively`}),s(`button`,{type:`button`,onClick:()=>T(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:`Use existing`}),s(`button`,{type:`button`,onClick:()=>T(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:e===H?`Paste cookie`:`Create new`})]}),a===`alexa-login`&&s(V,{onResolved:t,onCancel:n}),a===`existing`&&r(`div`,{className:`space-y-3`,children:[l.isLoading&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(x,{className:`h-3.5 w-3.5 animate-spin`}),` Loading brokers…`]}),l.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load brokers:`,` `,l.error instanceof Error?l.error.message:`Unknown error`]}),!l.isLoading&&!l.isError&&u.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:[`No brokers of this kind yet. Switch to`,` `,s(`span`,{className:`font-medium text-foreground`,children:e===H?`Login interactively`:`Create new`}),` `,`to register one.`]}),s(`div`,{className:`space-y-2`,children:u.map(e=>r(`button`,{type:`button`,onClick:()=>m(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${p===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[s(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${G[e.status]}`,children:e.status})]},e.id))}),u.length>0&&s(`div`,{className:`flex justify-end pt-1`,children:s(`button`,{type:`button`,onClick:S,disabled:!p,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:`Use this broker`})})]}),a===`new`&&r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),s(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`My Home Assistant`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&s(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),s(k,{kind:e,...f===void 0?{}:{addonId:f},onSubmit:e=>{w(e).catch(()=>{})},onCancel:n,submitLabel:b.isPending?`Creating…`:`Create broker`,disabled:b.isPending||v.trim().length===0}),v.trim().length===0&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before creating.`})]})]})}n();function q(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var J={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function Y({addonId:e,configSchema:t,canTest:n=!0,initialName:i,initialConfig:a,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=D(),[m,h]=o(i??``),[g,_]=o(a??{}),[v,b]=o(null),x=p({onSuccess:e=>b(q(e)),onError:e=>b({status:`inconclusive`,error:String(e)})});return r(`div`,{className:`space-y-4`,children:[!l&&r(`div`,{children:[s(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),s(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),className:`w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50`})]}),t&&s(y,{schema:t,values:g,onChange:_}),v&&s(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${J[v.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(v)}),r(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),r(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:()=>x.mutate({addonId:e,settings:g}),disabled:x.isPending||!n,title:n?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),s(`button`,{onClick:()=>u({name:m,config:g}),disabled:l?!1:!m.trim(),className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})}n();function X({open:t,onClose:n,scope:a}){let c=m(),[l,u]=o(new Set),[d,p]=o(new Set),{data:h}=f({}),g=i(()=>new Set((h??[]).map(e=>e.stableId)),[h]),_=e(async(e,t)=>{p(e=>new Set(e).add(t.stableId));try{await c.mutateAsync({addonId:e,candidate:t}),u(e=>new Set(e).add(t.stableId))}catch{}finally{p(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[c]),y=e((e,t)=>{let n=typeof t.prefilledConfig.host==`string`?t.prefilledConfig.host:null,i=g.has(t.stableId),a=l.has(t.stableId)||i,o=d.has(t.stableId);return r(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[r(`div`,{className:`min-w-0`,children:[s(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),n&&s(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:n})]}),a?r(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[s(O,{className:`h-3.5 w-3.5`}),` `,i?`Already added`:`Added`]}):r(`button`,{type:`button`,onClick:()=>void _(e,t),disabled:o,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[o?s(x,{className:`h-3.5 w-3.5 animate-spin`}):s(v,{className:`h-3.5 w-3.5`}),`Add`]})]},t.stableId)},[l,d,g,_]);if(!t)return null;let b=a?`Scan network — ${a.label}`:`Scan network for devices`;return r(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n}),r(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[r(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(A,{className:`h-4 w-4 text-primary`}),s(`h2`,{className:`text-sm font-semibold text-foreground`,children:b})]}),s(`button`,{onClick:n,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:s(w,{className:`h-4 w-4`})})]}),a?s(Q,{scope:a,onAdopt:y,onReset:()=>u(new Set)}):s(Z,{onAdopt:y,onReset:()=>u(new Set)})]})]})}function Z({onAdopt:t,onReset:n}){let o=l(),u=e(()=>{n(),o.mutate({})},[o,n]);c(()=>{!o.isPending&&!o.data&&u()},[]);let d=i(()=>(o.data?.groups??[]).filter(e=>e.candidates.length>0),[o.data]),f=i(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return r(a,{children:[s(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:r(`button`,{onClick:u,disabled:o.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[s(b,{className:`h-3.5 w-3.5 ${o.isPending?`animate-spin`:``}`}),`Re-scan`]})}),r(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[o.isPending&&s(ee,{label:`Scanning the local network…`}),!o.isPending&&o.isError&&s($,{}),!o.isPending&&o.data&&d.length===0&&s(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:`No devices responded to the scan.`}),!o.isPending&&d.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:[`Found `,f,` device`,f===1?``:`s`,` on the network.`]}),!o.isPending&&d.map(e=>r(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label}),r(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,e.candidates.length,`)`]})]}),e.candidates.map(n=>t(e.addonId,n))]},e.addonId))]})]})}function Q({scope:t,onAdopt:n,onReset:i}){let c=u({addonId:t.addonId}).data??null,[l,f]=o({}),p=d(),m=e(()=>{i(),p.mutate({addonId:t.addonId,params:l})},[p,t.addonId,l,i]),h=p.data?.candidates??[];return s(a,{children:r(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[c&&s(y,{schema:c,values:l,onChange:f}),r(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?s(x,{className:`h-3.5 w-3.5 animate-spin`}):s(A,{className:`h-3.5 w-3.5`}),p.isPending?`Scanning…`:`Scan`]}),p.isError&&s($,{}),!p.isPending&&p.data&&h.length===0&&s(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:`No devices responded to the scan.`}),!p.isPending&&h.length>0&&r(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:[`Found `,h.length,` device`,h.length===1?``:`s`,`.`]}),h.map(e=>n(t.addonId,e))]})]})})}function ee({label:e}){return r(`div`,{className:`flex flex-col items-center py-12`,children:[s(x,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function $(){return r(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[s(E,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),s(`p`,{className:`text-xs text-destructive`,children:`The scan failed. Try again.`})]})}export{A as i,Y as n,K as r,X as t};
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Er as l,Hr as u,Or as d,Rr as f,bi as p,gr as m,nr as h,or as g,sr as _}from"./src-CEchIfpK.js";import{t as v}from"./download--fExXTTV.js";import{t as y}from"./FormBuilder-yxzbuGp1.js";import{t as b}from"./refresh-cw-6kHXys54.js";import{C as x,K as S,L as C,i as w,j as T,o as E,t as D,z as O}from"./index-C4gpE4dh.js";import{t as k}from"./BrokerForm-Drb3n-di.js";var A=S(`radar`,[[`path`,{d:`M19.07 4.93A10 10 0 0 0 6.99 3.34`,key:`z3du51`}],[`path`,{d:`M4 6h.01`,key:`oypzma`}],[`path`,{d:`M2.29 9.62A10 10 0 1 0 21.31 8.35`,key:`qzzz0`}],[`path`,{d:`M16.24 7.76A6 6 0 1 0 8.23 16.67`,key:`1yjesh`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}],[`path`,{d:`M17.99 11.66A6 6 0 0 1 15.77 16.67`,key:`1u2y91`}],[`circle`,{cx:`12`,cy:`12`,r:`2`,key:`1c9p78`}],[`path`,{d:`m13.41 10.59 5.66-5.66`,key:`mhq4k0`}]]);n();var j=[`amazon.com`,`amazon.it`,`amazon.de`,`amazon.co.uk`,`amazon.fr`,`amazon.es`,`amazon.ca`,`amazon.com.au`,`amazon.co.jp`,`amazon.in`,`amazon.com.br`,`amazon.com.mx`],M=`/addon/import-alexa`,N=2e3;function P(e){return typeof e==`object`&&!!e&&typeof e.sessionId==`string`&&typeof e.loginUrl==`string`}function F(e){return typeof e==`object`&&!!e&&typeof e.phase==`string`&&typeof e.sessionId==`string`}function I(e){return typeof e==`object`&&!!e&&typeof e.brokerId==`string`}function L(e){return{"Content-Type":`application/json`,Authorization:`Bearer ${localStorage.getItem(`camstack_admin_token`)??``}`,...e}}async function R(e,t,n){let r=await fetch(`${M}${e}`,{method:`POST`,headers:L(),body:JSON.stringify(t)}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!n(i))throw Error(`Unexpected response from server`);return i}async function z(e){let t=new URLSearchParams({sessionId:e}),n=localStorage.getItem(`camstack_admin_token`)??``,r=await fetch(`${M}/login/status?${t.toString()}`,{headers:{Authorization:`Bearer ${n}`}}),i=await r.json();if(!r.ok){let e=typeof i==`object`&&i?i.error??`Unknown error`:`Unknown error`;throw Error(String(e))}if(!F(i))throw Error(`Unexpected status response from server`);return i}async function B(e){try{await fetch(`${M}/login/cancel`,{method:`POST`,headers:L(),body:JSON.stringify({sessionId:e})})}catch{}}function V({brokerId:n,onResolved:i,onCancel:a}){let[l,u]=o(`amazon.it`),[d,f]=o(`Alexa account`),[p,m]=o({kind:`idle`}),h=t(!0);c(()=>(h.current=!0,()=>{h.current=!1}),[]);let g=t(null),_=t(null),v=e(()=>{_.current!==null&&(clearInterval(_.current),_.current=null)},[]),y=e(async e=>{v(),h.current&&m({kind:`committing`,sessionId:e});try{let t=await R(`/login/commit`,{sessionId:e,name:d.trim().length>0?d.trim():`Alexa account`,...n===void 0?{}:{brokerId:n}},I);g.current=null,i(t.brokerId)}catch(t){let n=t instanceof Error?t.message:String(t);h.current&&m({kind:`error`,message:n,sessionId:e})}},[n,d,i,v]),S=e((e,t)=>{v();let n=async()=>{try{let n=await z(e);if(n.phase===`captured`){v(),y(e);return}if(n.phase===`error`){v(),h.current&&m({kind:`error`,message:n.error??`Login proxy returned an error`,sessionId:e});return}if(n.phase===`cancelled`){v(),h.current&&m({kind:`idle`});return}h.current&&m({kind:`polling`,sessionId:e,loginUrl:n.loginUrl||t,phase:n.phase})}catch(e){let t=e instanceof Error?e.message:String(e);h.current&&m(e=>e.kind===`polling`?{...e}:{kind:`error`,message:t,sessionId:null})}};_.current=setInterval(()=>{n()},N)},[v,y]);c(()=>()=>{v(),g.current!==null&&B(g.current)},[v]);let C=async()=>{v(),g.current!==null&&(B(g.current),g.current=null),m({kind:`starting`});try{let e=await R(`/login/start`,{amazonDomain:l},P);g.current=e.sessionId,m({kind:`polling`,sessionId:e.sessionId,loginUrl:e.loginUrl,phase:`starting`}),S(e.sessionId,e.loginUrl)}catch(e){m({kind:`error`,message:e instanceof Error?e.message:String(e),sessionId:null})}},w=()=>{v(),g.current!==null&&(B(g.current),g.current=null),m({kind:`idle`})},D=()=>{w()},O=p.kind===`idle`,k=p.kind===`starting`,A=p.kind===`polling`,M=p.kind===`committing`,F=p.kind===`error`,L=k||A||M,V=p.kind===`polling`?p.phase:null,H=p.kind===`polling`?p.loginUrl:null,U=A&&V===`awaiting-login`,W=A&&(V===`starting`||V===null);return r(`div`,{className:`space-y-4`,children:[(O||F)&&r(`div`,{className:`space-y-3`,children:[n===void 0&&r(`div`,{className:`space-y-1`,children:[s(`label`,{htmlFor:`alexa-account-name`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Account name`}),s(`input`,{id:`alexa-account-name`,type:`text`,value:d,onChange:e=>f(e.target.value),placeholder:`Alexa account`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),r(`div`,{className:`space-y-1`,children:[s(`label`,{htmlFor:`alexa-amazon-region`,className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Amazon region`}),s(`select`,{id:`alexa-amazon-region`,value:l,onChange:e=>u(e.target.value),className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,children:j.map(e=>s(`option`,{value:e,children:e},e))})]})]}),F&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px] flex items-start gap-2`,children:[s(E,{className:`h-3.5 w-3.5 mt-0.5 flex-shrink-0`}),s(`span`,{children:p.message})]}),k&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Starting login proxy…`]}),W&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Waiting for proxy to be ready…`]}),M&&r(`div`,{className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-3 text-xs text-foreground-subtle`,children:[s(x,{className:`h-4 w-4 animate-spin flex-shrink-0`}),`Saving credentials…`]}),U&&H!==null&&r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`rounded-lg border border-border bg-surface p-3 space-y-2`,children:[s(`p`,{className:`text-xs font-semibold text-foreground`,children:`Open the link below to log in to your Amazon account`}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`After completing the login and any 2FA steps, this wizard will continue automatically.`}),r(`a`,{href:H,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90`,children:[s(T,{className:`h-3.5 w-3.5`}),`Login to Amazon`]})]}),r(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[10px] text-amber-700 dark:text-amber-300`,children:[s(`strong`,{children:`Note:`}),` The login proxy runs directly on the hub. If the link does not open or the page does not load, make sure the hub's proxy host and port are reachable from your browser. You can configure `,s(`code`,{className:`font-mono`,children:`proxyHost`}),` in the Alexa addon settings and ensure the proxy port is published (Docker port mapping).`]}),r(`div`,{className:`flex items-center gap-2 text-[10px] text-foreground-subtle`,children:[s(x,{className:`h-3 w-3 animate-spin`}),`Waiting for Amazon login to complete…`]})]}),r(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[s(`button`,{type:`button`,onClick:L?w:a,className:`rounded px-3 py-1.5 text-xs text-foreground-subtle border border-border hover:text-foreground`,children:L?`Cancel login`:`Back`}),r(`div`,{className:`flex items-center gap-2`,children:[F&&r(`button`,{type:`button`,onClick:D,className:`inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-xs text-foreground hover:bg-primary/10`,children:[s(b,{className:`h-3.5 w-3.5`}),`Retry`]}),O&&s(`button`,{type:`button`,onClick:()=>{C()},disabled:n===void 0&&d.trim().length===0,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:`Start login`})]})]})]})}n();var H=`alexa`;function U(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`):[]}function W(e){return Array.isArray(e)?e.filter(e=>typeof e==`object`&&!!e&&typeof e.addonId==`string`&&Array.isArray(e.kinds)):[]}var G={connected:`bg-emerald-500/15 text-emerald-700 dark:text-emerald-300`,connecting:`bg-amber-500/15 text-amber-700 dark:text-amber-300`,disconnected:`bg-foreground-subtle/15 text-foreground-subtle`,"auth-failed":`bg-danger/15 text-danger`,unreachable:`bg-danger/15 text-danger`,error:`bg-danger/15 text-danger`};function K({kind:e,onResolved:t,onBack:n}){let[a,c]=o(e===H?`alexa-login`:`existing`),l=g({kind:e}),u=i(()=>U(l.data).filter(t=>t.kind===e),[l.data,e]),d=_(),f=i(()=>{for(let t of W(d.data))if(t.kinds.some(t=>t.kind===e))return t.addonId},[d.data,e]),[p,m]=o(null),[v,y]=o(``),b=h({}),S=()=>{p&&t(p)},w=async n=>{v.trim().length!==0&&t((await b.mutateAsync({kind:e,name:v.trim(),settings:n,...f===void 0?{}:{addonId:f}})).id)},T=e=>{e===`new`?m(null):b.reset(),c(e)};return r(`div`,{className:`space-y-4`,children:[r(`button`,{type:`button`,onClick:n,className:`inline-flex items-center gap-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[s(C,{className:`h-3.5 w-3.5`}),` Back`]}),r(`div`,{className:`inline-flex rounded-lg border border-border p-0.5 flex-wrap gap-0.5`,children:[e===H&&s(`button`,{type:`button`,onClick:()=>T(`alexa-login`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`alexa-login`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:`Login interactively`}),s(`button`,{type:`button`,onClick:()=>T(`existing`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`existing`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:`Use existing`}),s(`button`,{type:`button`,onClick:()=>T(`new`),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${a===`new`?`bg-primary text-primary-foreground`:`text-foreground-subtle hover:text-foreground`}`,children:e===H?`Paste cookie`:`Create new`})]}),a===`alexa-login`&&s(V,{onResolved:t,onCancel:n}),a===`existing`&&r(`div`,{className:`space-y-3`,children:[l.isLoading&&r(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[s(x,{className:`h-3.5 w-3.5 animate-spin`}),` Loading brokers…`]}),l.isError&&r(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load brokers:`,` `,l.error instanceof Error?l.error.message:`Unknown error`]}),!l.isLoading&&!l.isError&&u.length===0&&r(`div`,{className:`rounded-lg border border-border bg-surface px-3 py-6 text-center text-xs text-foreground-subtle`,children:[`No brokers of this kind yet. Switch to`,` `,s(`span`,{className:`font-medium text-foreground`,children:e===H?`Login interactively`:`Create new`}),` `,`to register one.`]}),s(`div`,{className:`space-y-2`,children:u.map(e=>r(`button`,{type:`button`,onClick:()=>m(e.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${p===e.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[s(`span`,{className:`text-xs font-semibold text-foreground`,children:e.name}),s(`span`,{className:`text-[10px] rounded-full px-2 py-0.5 font-medium ${G[e.status]}`,children:e.status})]},e.id))}),u.length>0&&s(`div`,{className:`flex justify-end pt-1`,children:s(`button`,{type:`button`,onClick:S,disabled:!p,className:`inline-flex items-center gap-1.5 rounded bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground hover:bg-primary/90 disabled:opacity-50`,children:`Use this broker`})})]}),a===`new`&&r(`div`,{className:`space-y-3`,children:[r(`div`,{className:`space-y-1`,children:[s(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Name`}),s(`input`,{type:`text`,value:v,onChange:e=>y(e.target.value),placeholder:`My Home Assistant`,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]}),b.isError&&s(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:b.error instanceof Error?b.error.message:String(b.error)}),s(k,{kind:e,...f===void 0?{}:{addonId:f},onSubmit:e=>{w(e).catch(()=>{})},onCancel:n,submitLabel:b.isPending?`Creating…`:`Create broker`,disabled:b.isPending||v.trim().length===0}),v.trim().length===0&&s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Enter a name before creating.`})]})]})}n();function q(e){return{status:e.status===`validated`||e.status===`rejected`||e.status===`inconclusive`||e.status===`unsupported`?e.status:e.success?`validated`:`rejected`,...e.error===void 0?{}:{error:e.error},...e.detail===void 0?{}:{detail:e.detail}}}var J={validated:`border-success/30 bg-success/5 text-success`,rejected:`border-danger/30 bg-danger/5 text-danger`,inconclusive:`border-warning/30 bg-warning/5 text-warning`,unsupported:`border-border bg-surface text-foreground-subtle`};function Y({addonId:e,configSchema:t,canTest:n=!0,initialName:i,initialConfig:a,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=D(),[m,h]=o(i??``),[g,_]=o(a??{}),[v,b]=o(null),x=p({onSuccess:e=>b(q(e)),onError:e=>b({status:`inconclusive`,error:String(e)})});return r(`div`,{className:`space-y-4`,children:[!l&&r(`div`,{children:[s(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),s(`input`,{type:`text`,value:m,onChange:e=>h(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),className:`w-full rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:border-primary/50`})]}),t&&s(y,{schema:t,values:g,onChange:_}),v&&s(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${J[v.status]}`,children:(e=>{switch(e.status){case`validated`:return e.detail?`${f(`integrations.connectionSuccess`)} — ${e.detail}`:f(`integrations.connectionSuccess`);case`rejected`:return`${f(`integrations.errorPrefix`)} ${e.error??``}`;case`inconclusive`:return`${f(`integrations.connectionInconclusive`,{defaultValue:`Could not be checked:`})} ${e.error??``}`;case`unsupported`:return e.error??f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`})}})(v)}),r(`div`,{className:`flex items-center justify-between pt-2`,children:[s(`button`,{onClick:d,className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground-subtle hover:text-foreground transition-colors`,children:f(`integrations.back`)}),r(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{onClick:()=>x.mutate({addonId:e,settings:g}),disabled:x.isPending||!n,title:n?void 0:f(`integrations.connectionUntestable`,{defaultValue:`This integration cannot be tested before it is created.`}),className:`rounded-lg border border-border px-3 py-1.5 text-xs text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:x.isPending?f(`integrations.testing`):f(`integrations.testConnection`)}),s(`button`,{onClick:()=>u({name:m,config:g}),disabled:l?!1:!m.trim(),className:`rounded-lg bg-primary px-4 py-1.5 text-xs font-medium text-primary-foreground shadow-sm disabled:opacity-50`,children:c??f(`integrations.forward`)})]})]})]})}n();function X({open:t,onClose:n,scope:a}){let c=m(),[l,u]=o(new Set),[d,p]=o(new Set),{data:h}=f({}),g=i(()=>new Set((h??[]).map(e=>e.stableId)),[h]),_=e(async(e,t)=>{p(e=>new Set(e).add(t.stableId));try{await c.mutateAsync({addonId:e,candidate:t}),u(e=>new Set(e).add(t.stableId))}catch{}finally{p(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[c]),y=e((e,t)=>{let n=typeof t.prefilledConfig.host==`string`?t.prefilledConfig.host:null,i=g.has(t.stableId),a=l.has(t.stableId)||i,o=d.has(t.stableId);return r(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[r(`div`,{className:`min-w-0`,children:[s(`p`,{className:`truncate text-xs font-medium text-foreground`,children:t.suggestedName}),n&&s(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:n})]}),a?r(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[s(O,{className:`h-3.5 w-3.5`}),` `,i?`Already added`:`Added`]}):r(`button`,{type:`button`,onClick:()=>void _(e,t),disabled:o,className:`flex items-center gap-1 rounded-md bg-primary px-2.5 py-1 text-[11px] font-medium text-primary-foreground disabled:opacity-50`,children:[o?s(x,{className:`h-3.5 w-3.5 animate-spin`}):s(v,{className:`h-3.5 w-3.5`}),`Add`]})]},t.stableId)},[l,d,g,_]);if(!t)return null;let b=a?`Scan network — ${a.label}`:`Scan network for devices`;return r(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[s(`div`,{className:`absolute inset-0 bg-black/60`,onClick:n}),r(`div`,{className:`relative z-10 flex w-full max-w-2xl flex-col max-h-[calc(90dvh-2*max(env(safe-area-inset-top),env(safe-area-inset-bottom)))] rounded-xl border border-border bg-background shadow-2xl`,children:[r(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(A,{className:`h-4 w-4 text-primary`}),s(`h2`,{className:`text-sm font-semibold text-foreground`,children:b})]}),s(`button`,{onClick:n,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:s(w,{className:`h-4 w-4`})})]}),a?s(Q,{scope:a,onAdopt:y,onReset:()=>u(new Set)}):s(Z,{onAdopt:y,onReset:()=>u(new Set)})]})]})}function Z({onAdopt:t,onReset:n}){let o=l(),u=e(()=>{n(),o.mutate({})},[o,n]);c(()=>{!o.isPending&&!o.data&&u()},[]);let d=i(()=>(o.data?.groups??[]).filter(e=>e.candidates.length>0),[o.data]),f=i(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return r(a,{children:[s(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:r(`button`,{onClick:u,disabled:o.isPending,className:`flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,children:[s(b,{className:`h-3.5 w-3.5 ${o.isPending?`animate-spin`:``}`}),`Re-scan`]})}),r(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[o.isPending&&s(ee,{label:`Scanning the local network…`}),!o.isPending&&o.isError&&s($,{}),!o.isPending&&o.data&&d.length===0&&s(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:`No devices responded to the scan.`}),!o.isPending&&d.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:[`Found `,f,` device`,f===1?``:`s`,` on the network.`]}),!o.isPending&&d.map(e=>r(`div`,{className:`space-y-1.5`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(`span`,{className:`text-[11px] font-semibold text-foreground`,children:e.label}),r(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,e.candidates.length,`)`]})]}),e.candidates.map(n=>t(e.addonId,n))]},e.addonId))]})]})}function Q({scope:t,onAdopt:n,onReset:i}){let c=u({addonId:t.addonId}).data??null,[l,f]=o({}),p=d(),m=e(()=>{i(),p.mutate({addonId:t.addonId,params:l})},[p,t.addonId,l,i]),h=p.data?.candidates??[];return s(a,{children:r(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[c&&s(y,{schema:c,values:l,onChange:f}),r(`button`,{onClick:m,disabled:p.isPending,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground disabled:opacity-50`,children:[p.isPending?s(x,{className:`h-3.5 w-3.5 animate-spin`}):s(A,{className:`h-3.5 w-3.5`}),p.isPending?`Scanning…`:`Scan`]}),p.isError&&s($,{}),!p.isPending&&p.data&&h.length===0&&s(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:`No devices responded to the scan.`}),!p.isPending&&h.length>0&&r(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:[`Found `,h.length,` device`,h.length===1?``:`s`,`.`]}),h.map(e=>n(t.addonId,e))]})]})})}function ee({label:e}){return r(`div`,{className:`flex flex-col items-center py-12`,children:[s(x,{className:`h-6 w-6 animate-spin text-primary`}),s(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:e})]})}function $(){return r(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[s(E,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),s(`p`,{className:`text-xs text-destructive`,children:`The scan failed. Try again.`})]})}export{A as i,Y as n,K as r,X as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$ as l,B as u,H as d,I as f,K as p,L as m,R as h,U as g,V as _,W as v,Z as y,ct as b,j as x,o as S,rt as C,st as w,tt as ee}from"./player-overlays-DXNKqmwI.js";import{MaskShapeCanvas as te}from"./MaskShapeCanvas-Dcpby34M.js";var ne=b(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);n();var T=`/addon/pipeline-analytics/event-media`;function E(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function D(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var O=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function k({monitor:e,disabled:t,onDelete:n}){let i=E(e),a=D(e),[c,u]=o(null);return i.length===0?s(`p`,{className:`${x} leading-relaxed`,children:`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`}):s(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>r(`div`,{className:`flex flex-col gap-1`,children:[r(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[d(e.condition),` · `,e.tiles.length]}),s(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(i=>{let o=`${i.stateId}:${String(i.index)}`,f=a===1,p=c===o;return r(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[s(A,{reference:i.reference}),s(`span`,{className:`${x} tabular-nums`,children:j(i.reference.capturedAt)}),r(`button`,{type:`button`,className:O,disabled:t,"aria-label":`Delete the ${d(e.condition).toLowerCase()} photograph from ${j(i.reference.capturedAt)}`,onClick:()=>{if(f&&!p){u(o);return}u(null),n({stateId:i.stateId,index:i.index})},children:[s(l,{className:`mr-1 inline h-3 w-3`}),p?`Confirm`:`Delete`]}),p&&s(`p`,{className:`text-[10px] leading-snug text-warning`,children:`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`})]},o)})})]},e.condition))})}function A({reference:e}){let[t,n]=o(!1),i=e.thumbnailMediaId;return i===void 0||t?r(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`,children:[s(C,{className:`h-4 w-4`}),s(`span`,{className:`text-[9px]`,children:`no picture`})]}):s(`img`,{src:`${T}/${encodeURIComponent(i)}`,alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>n(!0)})}function j(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}n();var M=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,N=`text-[10px] font-medium text-foreground-subtle`,P=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,F=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,I=5,L=3600,R={periodic:`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`,"on-motion":`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`,both:`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`},z={skip:`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`,"judge-anyway":`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`};function B(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function V({monitor:e,disabled:t,onPatch:n}){let[i,l]=o(()=>B(e)),[u,d]=o(!1);c(()=>{u||l(B(e))},[e,u]);let f=e=>{d(!1),n(e)},p=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},m=e.confirm?.enabled===!0,h=e.check.mode===`similarity`?e.check.threshold:null;return r(`div`,{className:`flex flex-col gap-2`,children:[r(`div`,{className:P,children:[s(`p`,{className:F,children:`What it watches`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Name`}),s(`input`,{type:`text`,value:i.label,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,label:e.target.value})),onBlur:()=>{let t=i.label.trim();t.length>0&&t!==e.label?f({label:t}):d(!1)}})]}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:e=>f({enabled:e.target.checked})}),s(`span`,{className:N,children:`Watching`})]}),s(`p`,{className:x,children:`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`When to look`}),r(`select`,{value:e.triggerMode,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&f({triggerMode:t})},children:[s(`option`,{value:`both`,children:`On the clock and after motion settles`}),s(`option`,{value:`periodic`,children:`On the clock only`}),s(`option`,{value:`on-motion`,children:`After motion settles only`})]})]}),s(`p`,{className:x,children:R[e.triggerMode]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Check every (seconds)`}),s(`input`,{type:`number`,min:I,max:L,value:i.checkIntervalSec,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.checkIntervalSec,I,L);t===e.checkIntervalSec?d(!1):f({checkIntervalSec:t})}})]}),s(`p`,{className:x,children:`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`How sure it has to be`}),e.check.mode===`similarity`&&r(a,{children:[r(`label`,{className:`flex flex-col gap-1`,children:[r(`span`,{className:N,children:[`Match threshold — `,s(`span`,{className:`tabular-nums`,children:i.threshold.toFixed(2)})]}),s(`input`,{type:`range`,min:.3,max:.99,step:.01,value:i.threshold,disabled:t,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{i.threshold===h?d(!1):f({check:p({threshold:i.threshold})})},onBlur:()=>{i.threshold===h?d(!1):f({check:p({threshold:i.threshold})})}})]}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`})]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Agreeing checks before it changes its mind`}),s(`input`,{type:`number`,min:1,max:10,value:i.hysteresisCount,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=H(i.hysteresisCount,1,10);t===e.check.hysteresisCount?d(!1):f({check:p({hysteresisCount:t})})}})]}),s(`p`,{className:x,children:`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Quiet for (seconds) before a check counts`}),s(`input`,{type:`number`,min:0,max:3600,value:i.quietSeconds,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.quietSeconds,0,3600);t===e.quietSeconds?d(!1):f({quietSeconds:t})}})]}),s(`p`,{className:x,children:`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Minimum gap between counted checks (seconds)`}),s(`input`,{type:`number`,min:0,max:3600,value:i.minObservationSpacingSec,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?d(!1):f({minObservationSpacingSec:t})}})]}),s(`p`,{className:x,children:`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`Lighting`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`When a light has no reference of its own`}),r(`select`,{value:e.onUncoveredCondition,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&f({onUncoveredCondition:t})},children:[s(`option`,{value:`skip`,children:`Skip the check (recommended)`}),s(`option`,{value:`judge-anyway`,children:`Judge against the other light anyway`})]})]}),s(`p`,{className:x,children:z[e.onUncoveredCondition]})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`What you get told`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Notifications follow`}),r(`select`,{value:e.emit,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&f({emit:t})},children:[s(`option`,{value:`latched`,children:`The flag — told once, still visible at breakfast`}),s(`option`,{value:`live`,children:`The live state — follows the region as it changes`})]})]}),s(`p`,{className:x,children:`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:t,onChange:e=>f({autoRestore:e.target.checked})}),s(`span`,{className:N,children:`Clear the flag by itself when things look normal again`})]}),s(`p`,{className:x,children:`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`AI double-check`}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:m,disabled:t||i.confirmPrompt.trim().length===0,onChange:e=>f(e.target.checked?{confirm:{...U(i.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),s(`span`,{className:N,children:`Ask a vision model before changing the answer`})]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`The question to ask`}),s(`input`,{type:`text`,value:i.confirmPrompt,placeholder:`e.g. Is the wheelie bin still there?`,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=i.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?f({confirm:{...U(t),enabled:m}}):d(!1)}})]}),r(`p`,{className:x,children:[`The model is asked `,s(`strong`,{children:`only`}),` when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`]})]})]})}function H(e,t,n){return Math.min(n,Math.max(t,e))}function U(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}n();var W=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,G=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,K=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,q={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},re=.8,ie=3;function J({deviceId:n}){let b=v(y().trpcClient,n),C=p(b?.state.sceneMonitor),T=S(n,{width:640}),[E,D]=o(null),[O,A]=o(!1),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(!1),[H,U]=o(null),[J,Y]=o(``),X=t(!0);c(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=e(async()=>{if(b)try{let e=await b.sceneMonitor?.listScenes({});if(!X.current)return;e&&D(e)}catch(e){if(!X.current)return;g(e)?A(!0):P(e instanceof Error?e.message:String(e))}},[b]);c(()=>{D(null),A(!1),P(null),Z()},[Z]);let Q=C?.monitors??E?.monitors??[],ae=Date.now(),$=e(async(e,t)=>{M(e),P(null);try{await t(),await Z()}catch(e){X.current&&P(e instanceof Error?e.message:String(e))}finally{X.current&&M(null)}},[Z]),oe=i(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return H===null?e:[...e,{id:`__draft__`,shape:H,label:`New scene`}]},[Q,H]),se=e((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){U(t);return}$(`roi-${String(e)}`,async()=>b?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[b,$]),ce=e(e=>{e.kind===`rect`&&U(e)},[]),le=e(async()=>{H===null||J.trim().length===0||(await $(`create`,async()=>{await b?.sceneMonitor?.createScene({label:J.trim(),roi:H,check:{mode:`similarity`,threshold:re,hysteresisCount:ie}})}),U(null),Y(``),B(!1))},[b,H,J,$]);return b?s(`div`,{className:`flex flex-col gap-3`,children:O?s(`p`,{className:`${x} leading-relaxed`,children:`Scene monitoring is not available for this camera.`}):r(a,{children:[s(`p`,{className:`${x} leading-relaxed`,children:`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`}),s(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:s(te,{items:oe,supportedShapes:[`rect`],selectedId:F??(H===null?null:`__draft__`),onSelect:e=>I(e===null?null:String(e)),onShapeChange:se,onDrawComplete:ce,drawingKind:z&&H===null?`rect`:null,backdrop:T.src===null?null:s(`img`,{src:T.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s(`button`,{type:`button`,className:z?G:W,"aria-pressed":z,onClick:()=>{B(e=>!e),U(null)},disabled:j!==null,children:z?`Cancel`:`+ New scene`}),s(`button`,{type:`button`,className:W,onClick:T.refresh,disabled:j!==null,children:`Refresh frame`})]}),z&&r(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[s(`p`,{className:`text-[10px] text-foreground-subtle`,children:H===null?`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`:`Name it, then create. You capture what “normal” looks like next.`}),H!==null&&u(H)&&s(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`}),r(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`text`,value:J,onChange:e=>Y(e.target.value),placeholder:`e.g. Immondizia prelevata`,className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),s(`button`,{type:`button`,className:G,onClick:()=>void le(),disabled:H===null||J.trim().length===0||j!==null,children:`Create`})]})]}),N!==null&&s(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:N}),Q.length===0?s(`p`,{className:`${x} leading-relaxed`,children:`No scenes on this camera yet.`}):s(`ul`,{className:`flex flex-col gap-2`,children:Q.map(e=>{let t=m(e);return r(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${F===e.id?`border-primary/50`:`border-border`}`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>I(e.id),children:e.label}),s(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${q[t.tone]}`,children:t.text})]}),s(`p`,{className:`${x} leading-relaxed`,children:_(e,ae)}),s(`p`,{className:`${x} tabular-nums`,children:h(e)}),s(k,{monitor:e,disabled:j!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>b.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f.map(t=>{let n=t===`ir`;return r(`button`,{type:`button`,className:W,disabled:j!==null,title:n?`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`:`Take a fresh photo now and store it as the ${d(t).toLowerCase()} reference`,onClick:()=>void $(`cap-${e.id}-${t}`,async()=>b.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[s(w,{className:`mr-1 inline h-3 w-3`}),`Capture `,d(t).toLowerCase(),n&&s(`span`,{className:`ml-1 text-foreground-subtle/70`,children:`(optional)`})]},t)}),r(`button`,{type:`button`,className:G,disabled:j!==null||e.states.length===0,title:`Clear the flag and re-photograph what normal looks like right now`,onClick:()=>void $(`reset-${e.id}`,async()=>b.sceneMonitor?.resetScene({monitorId:e.id})),children:[s(ee,{className:`mr-1 inline h-3 w-3`}),`Reset`]}),s(`button`,{type:`button`,className:W,disabled:j!==null,onClick:()=>void $(`check-${e.id}`,async()=>b.sceneMonitor?.recheckNow({monitorId:e.id})),children:`Check now`}),r(`button`,{type:`button`,className:L===e.id?G:W,"aria-pressed":L===e.id,"aria-label":`Settings for ${e.label}`,disabled:j!==null,onClick:()=>R(t=>t===e.id?null:e.id),children:[s(ne,{className:`mr-1 inline h-3 w-3`}),`Settings`]}),s(`button`,{type:`button`,className:K,disabled:j!==null,onClick:()=>void $(`del-${e.id}`,async()=>b.sceneMonitor?.deleteScene({monitorId:e.id})),children:s(l,{className:`h-3 w-3`})})]}),L===e.id&&s(V,{monitor:e,disabled:j!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>b.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{J as SceneMonitorEditor};
|
|
1
|
+
import{I as e,K as t,Q as n,S as r,W as i,b as a,q as o,x as s,z as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{$ as l,B as u,H as d,I as f,K as p,L as m,R as h,U as g,V as _,W as v,Z as y,ct as b,j as x,o as S,rt as C,st as w,tt as ee}from"./player-overlays-UTlrOH4s.js";import{MaskShapeCanvas as te}from"./MaskShapeCanvas-Dcpby34M.js";var ne=b(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]);n();var T=`/addon/pipeline-analytics/event-media`;function E(e){let t=new Map;for(let n of e.states)n.references.forEach((e,r)=>{let i=t.get(e.condition)??[];i.push({stateId:n.id,index:r,reference:e}),t.set(e.condition,i)});return[...t.entries()].map(([e,t])=>({condition:e,tiles:[...t].sort((e,t)=>t.reference.capturedAt-e.reference.capturedAt)})).sort((e,t)=>e.condition.localeCompare(t.condition))}function D(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var O=`rounded border border-danger/50 bg-danger/10 px-1 py-0.5 text-[10px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`;function k({monitor:e,disabled:t,onDelete:n}){let i=E(e),a=D(e),[c,u]=o(null);return i.length===0?s(`p`,{className:`${x} leading-relaxed`,children:`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`}):s(`div`,{className:`flex flex-col gap-2`,children:i.map(e=>r(`div`,{className:`flex flex-col gap-1`,children:[r(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[d(e.condition),` · `,e.tiles.length]}),s(`ul`,{className:`flex flex-wrap gap-1.5`,children:e.tiles.map(i=>{let o=`${i.stateId}:${String(i.index)}`,f=a===1,p=c===o;return r(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[s(A,{reference:i.reference}),s(`span`,{className:`${x} tabular-nums`,children:j(i.reference.capturedAt)}),r(`button`,{type:`button`,className:O,disabled:t,"aria-label":`Delete the ${d(e.condition).toLowerCase()} photograph from ${j(i.reference.capturedAt)}`,onClick:()=>{if(f&&!p){u(o);return}u(null),n({stateId:i.stateId,index:i.index})},children:[s(l,{className:`mr-1 inline h-3 w-3`}),p?`Confirm`:`Delete`]}),p&&s(`p`,{className:`text-[10px] leading-snug text-warning`,children:`This is the only photograph this scene has. Delete it and the scene no longer knows what normal looks like — it stops judging until you capture again.`})]},o)})})]},e.condition))})}function A({reference:e}){let[t,n]=o(!1),i=e.thumbnailMediaId;return i===void 0||t?r(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`,children:[s(C,{className:`h-4 w-4`}),s(`span`,{className:`text-[9px]`,children:`no picture`})]}):s(`img`,{src:`${T}/${encodeURIComponent(i)}`,alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>n(!0)})}function j(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}n();var M=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,N=`text-[10px] font-medium text-foreground-subtle`,P=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,F=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,I=5,L=3600,R={periodic:`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`,"on-motion":`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`,both:`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`},z={skip:`Sit that light out. No verdict, no alarm, no flag touched — it picks itself back up when a light it knows returns. This is why the night capture is optional.`,"judge-anyway":`Compare against the references you do have. Only correct when the two lights genuinely look alike (a floodlit driveway, an indoor lamp) — against a real infrared frame it will report a change that did not happen.`};function B(e){return{label:e.label,checkIntervalSec:e.checkIntervalSec??60,threshold:e.check.mode===`similarity`?e.check.threshold:.8,hysteresisCount:e.check.hysteresisCount,quietSeconds:e.quietSeconds,minObservationSpacingSec:e.minObservationSpacingSec,confirmPrompt:e.confirm?.prompt??``}}function V({monitor:e,disabled:t,onPatch:n}){let[i,l]=o(()=>B(e)),[u,d]=o(!1);c(()=>{u||l(B(e))},[e,u]);let f=e=>{d(!1),n(e)},p=t=>e.check.mode===`similarity`?{mode:`similarity`,threshold:t.threshold??e.check.threshold,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount}:{...e.check,hysteresisCount:t.hysteresisCount??e.check.hysteresisCount},m=e.confirm?.enabled===!0,h=e.check.mode===`similarity`?e.check.threshold:null;return r(`div`,{className:`flex flex-col gap-2`,children:[r(`div`,{className:P,children:[s(`p`,{className:F,children:`What it watches`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Name`}),s(`input`,{type:`text`,value:i.label,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,label:e.target.value})),onBlur:()=>{let t=i.label.trim();t.length>0&&t!==e.label?f({label:t}):d(!1)}})]}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:e.enabled,disabled:t,onChange:e=>f({enabled:e.target.checked})}),s(`span`,{className:N,children:`Watching`})]}),s(`p`,{className:x,children:`Turned off, the scene keeps its region, its references and its flag — it simply stops checking. Nothing is lost by pausing one for a while.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`When to look`}),r(`select`,{value:e.triggerMode,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&f({triggerMode:t})},children:[s(`option`,{value:`both`,children:`On the clock and after motion settles`}),s(`option`,{value:`periodic`,children:`On the clock only`}),s(`option`,{value:`on-motion`,children:`After motion settles only`})]})]}),s(`p`,{className:x,children:R[e.triggerMode]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Check every (seconds)`}),s(`input`,{type:`number`,min:I,max:L,value:i.checkIntervalSec,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.checkIntervalSec,I,L);t===e.checkIntervalSec?d(!1):f({checkIntervalSec:t})}})]}),s(`p`,{className:x,children:`60 s suits “is the bin still out”. Every check costs one photograph and one encode, so going below about 30 s buys latency you almost never need and multiplies the cost by the number of scenes you own.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`How sure it has to be`}),e.check.mode===`similarity`&&r(a,{children:[r(`label`,{className:`flex flex-col gap-1`,children:[r(`span`,{className:N,children:[`Match threshold — `,s(`span`,{className:`tabular-nums`,children:i.threshold.toFixed(2)})]}),s(`input`,{type:`range`,min:.3,max:.99,step:.01,value:i.threshold,disabled:t,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{i.threshold===h?d(!1):f({check:p({threshold:i.threshold})})},onBlur:()=>{i.threshold===h?d(!1):f({check:p({threshold:i.threshold})})}})]}),s(`p`,{className:`text-[10px] text-foreground-subtle`,children:`How closely the region still has to resemble the photograph to count as unchanged. Higher means fussier: at 0.95 a passing cloud can read as a change; at 0.60 the bin can be taken and the scene will shrug. 0.80 is a sensible start — if it cries wolf, lower it; if it misses the thing you care about, raise it.`})]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Agreeing checks before it changes its mind`}),s(`input`,{type:`number`,min:1,max:10,value:i.hysteresisCount,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let t=H(i.hysteresisCount,1,10);t===e.check.hysteresisCount?d(!1):f({check:p({hysteresisCount:t})})}})]}),s(`p`,{className:x,children:`One bad photograph must never be able to flip a scene. 3 agreeing checks at 60 s is about four minutes of latency and is what makes the answer trustworthy — leaving a state costs exactly the same as entering one.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Quiet for (seconds) before a check counts`}),s(`input`,{type:`number`,min:0,max:3600,value:i.quietSeconds,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.quietSeconds,0,3600);t===e.quietSeconds?d(!1):f({quietSeconds:t})}})]}),s(`p`,{className:x,children:`A check taken while something is moving is a photograph of the van parked in front of the bin, so it is discarded rather than merely delayed. 0 disables the gate.`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Minimum gap between counted checks (seconds)`}),s(`input`,{type:`number`,min:0,max:3600,value:i.minObservationSpacingSec,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let t=H(i.minObservationSpacingSec,0,3600);t===e.minObservationSpacingSec?d(!1):f({minObservationSpacingSec:t})}})]}),s(`p`,{className:x,children:`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`Lighting`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`When a light has no reference of its own`}),r(`select`,{value:e.onUncoveredCondition,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&f({onUncoveredCondition:t})},children:[s(`option`,{value:`skip`,children:`Skip the check (recommended)`}),s(`option`,{value:`judge-anyway`,children:`Judge against the other light anyway`})]})]}),s(`p`,{className:x,children:z[e.onUncoveredCondition]})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`What you get told`}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`Notifications follow`}),r(`select`,{value:e.emit,disabled:t,className:M,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&f({emit:t})},children:[s(`option`,{value:`latched`,children:`The flag — told once, still visible at breakfast`}),s(`option`,{value:`live`,children:`The live state — follows the region as it changes`})]})]}),s(`p`,{className:x,children:`“Is the bin gone” is a flag: you want to be told once and still see it later. “Is the gate open” is a live state.`}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:e.autoRestore,disabled:t,onChange:e=>f({autoRestore:e.target.checked})}),s(`span`,{className:N,children:`Clear the flag by itself when things look normal again`})]}),s(`p`,{className:x,children:`Off by default, so an alarm never silently clears itself. The “back to normal” moment is recorded either way, so an automation can still react to it.`})]}),r(`div`,{className:P,children:[s(`p`,{className:F,children:`AI double-check`}),r(`label`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`checkbox`,checked:m,disabled:t||i.confirmPrompt.trim().length===0,onChange:e=>f(e.target.checked?{confirm:{...U(i.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),s(`span`,{className:N,children:`Ask a vision model before changing the answer`})]}),r(`label`,{className:`flex flex-col gap-1`,children:[s(`span`,{className:N,children:`The question to ask`}),s(`input`,{type:`text`,value:i.confirmPrompt,placeholder:`e.g. Is the wheelie bin still there?`,disabled:t,className:M,onFocus:()=>d(!0),onChange:e=>l(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let t=i.confirmPrompt.trim();t.length>0&&t!==e.confirm?.prompt?f({confirm:{...U(t),enabled:m}}):d(!1)}})]}),r(`p`,{className:x,children:[`The model is asked `,s(`strong`,{children:`only`}),` when the region has already changed enough to flip the answer — roughly twice a week for a bin, not once a minute. It reasons about the object rather than the pixels, so rain, shadows and a repositioned bin stop counting as the thing being taken. If it cannot be reached, the change is held rather than announced.`]})]})]})}function H(e,t,n){return Math.min(n,Math.max(t,e))}function U(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}n();var W=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover disabled:opacity-40 transition-colors`,G=`rounded-md border border-primary/50 bg-primary/15 px-2.5 py-1 text-[11px] font-medium text-primary hover:bg-primary/25 disabled:opacity-40 transition-colors`,K=`rounded-md border border-danger/50 bg-danger/10 px-2 py-1 text-[11px] font-medium text-danger hover:bg-danger/20 disabled:opacity-40 transition-colors`,q={alarm:`border-danger/50 bg-danger/15 text-danger`,ok:`border-success/50 bg-success/15 text-success`,unknown:`border-border bg-surface text-foreground-subtle`},re=.8,ie=3;function J({deviceId:n}){let b=v(y().trpcClient,n),C=p(b?.state.sceneMonitor),T=S(n,{width:640}),[E,D]=o(null),[O,A]=o(!1),[j,M]=o(null),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(!1),[H,U]=o(null),[J,Y]=o(``),X=t(!0);c(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=e(async()=>{if(b)try{let e=await b.sceneMonitor?.listScenes({});if(!X.current)return;e&&D(e)}catch(e){if(!X.current)return;g(e)?A(!0):P(e instanceof Error?e.message:String(e))}},[b]);c(()=>{D(null),A(!1),P(null),Z()},[Z]);let Q=C?.monitors??E?.monitors??[],ae=Date.now(),$=e(async(e,t)=>{M(e),P(null);try{await t(),await Z()}catch(e){X.current&&P(e instanceof Error?e.message:String(e))}finally{X.current&&M(null)}},[Z]),oe=i(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return H===null?e:[...e,{id:`__draft__`,shape:H,label:`New scene`}]},[Q,H]),se=e((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){U(t);return}$(`roi-${String(e)}`,async()=>b?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[b,$]),ce=e(e=>{e.kind===`rect`&&U(e)},[]),le=e(async()=>{H===null||J.trim().length===0||(await $(`create`,async()=>{await b?.sceneMonitor?.createScene({label:J.trim(),roi:H,check:{mode:`similarity`,threshold:re,hysteresisCount:ie}})}),U(null),Y(``),B(!1))},[b,H,J,$]);return b?s(`div`,{className:`flex flex-col gap-3`,children:O?s(`p`,{className:`${x} leading-relaxed`,children:`Scene monitoring is not available for this camera.`}):r(a,{children:[s(`p`,{className:`${x} leading-relaxed`,children:`A scene watches one region of this camera and tells you when it stops looking like the picture you captured. Draw a box around the thing you care about — a wheelie bin, a gate, a parking space — then capture what “normal” looks like. Daylight is enough to start: the night reference is optional, and without it the scene simply sits the infrared hours out instead of reporting a problem.`}),s(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:s(te,{items:oe,supportedShapes:[`rect`],selectedId:F??(H===null?null:`__draft__`),onSelect:e=>I(e===null?null:String(e)),onShapeChange:se,onDrawComplete:ce,drawingKind:z&&H===null?`rect`:null,backdrop:T.src===null?null:s(`img`,{src:T.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[s(`button`,{type:`button`,className:z?G:W,"aria-pressed":z,onClick:()=>{B(e=>!e),U(null)},disabled:j!==null,children:z?`Cancel`:`+ New scene`}),s(`button`,{type:`button`,className:W,onClick:T.refresh,disabled:j!==null,children:`Refresh frame`})]}),z&&r(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[s(`p`,{className:`text-[10px] text-foreground-subtle`,children:H===null?`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`:`Name it, then create. You capture what “normal” looks like next.`}),H!==null&&u(H)&&s(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:`That box covers most of the frame. A scene that big is dominated by the weather, the sky and passing cars — it will quietly stop noticing the thing you actually care about. Draw it tighter.`}),r(`div`,{className:`flex items-center gap-2`,children:[s(`input`,{type:`text`,value:J,onChange:e=>Y(e.target.value),placeholder:`e.g. Immondizia prelevata`,className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),s(`button`,{type:`button`,className:G,onClick:()=>void le(),disabled:H===null||J.trim().length===0||j!==null,children:`Create`})]})]}),N!==null&&s(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:N}),Q.length===0?s(`p`,{className:`${x} leading-relaxed`,children:`No scenes on this camera yet.`}):s(`ul`,{className:`flex flex-col gap-2`,children:Q.map(e=>{let t=m(e);return r(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${F===e.id?`border-primary/50`:`border-border`}`,children:[r(`div`,{className:`flex items-center gap-2`,children:[s(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>I(e.id),children:e.label}),s(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${q[t.tone]}`,children:t.text})]}),s(`p`,{className:`${x} leading-relaxed`,children:_(e,ae)}),s(`p`,{className:`${x} tabular-nums`,children:h(e)}),s(k,{monitor:e,disabled:j!==null,onDelete:({stateId:t,index:n})=>void $(`refdel-${e.id}-${t}-${String(n)}`,async()=>b.sceneMonitor?.deleteReference({monitorId:e.id,stateId:t,index:n}))}),r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[f.map(t=>{let n=t===`ir`;return r(`button`,{type:`button`,className:W,disabled:j!==null,title:n?`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`:`Take a fresh photo now and store it as the ${d(t).toLowerCase()} reference`,onClick:()=>void $(`cap-${e.id}-${t}`,async()=>b.sceneMonitor?.captureReference({monitorId:e.id,condition:t})),children:[s(w,{className:`mr-1 inline h-3 w-3`}),`Capture `,d(t).toLowerCase(),n&&s(`span`,{className:`ml-1 text-foreground-subtle/70`,children:`(optional)`})]},t)}),r(`button`,{type:`button`,className:G,disabled:j!==null||e.states.length===0,title:`Clear the flag and re-photograph what normal looks like right now`,onClick:()=>void $(`reset-${e.id}`,async()=>b.sceneMonitor?.resetScene({monitorId:e.id})),children:[s(ee,{className:`mr-1 inline h-3 w-3`}),`Reset`]}),s(`button`,{type:`button`,className:W,disabled:j!==null,onClick:()=>void $(`check-${e.id}`,async()=>b.sceneMonitor?.recheckNow({monitorId:e.id})),children:`Check now`}),r(`button`,{type:`button`,className:L===e.id?G:W,"aria-pressed":L===e.id,"aria-label":`Settings for ${e.label}`,disabled:j!==null,onClick:()=>R(t=>t===e.id?null:e.id),children:[s(ne,{className:`mr-1 inline h-3 w-3`}),`Settings`]}),s(`button`,{type:`button`,className:K,disabled:j!==null,onClick:()=>void $(`del-${e.id}`,async()=>b.sceneMonitor?.deleteScene({monitorId:e.id})),children:s(l,{className:`h-3 w-3`})})]}),L===e.id&&s(V,{monitor:e,disabled:j!==null,onPatch:t=>void $(`tune-${e.id}`,async()=>b.sceneMonitor?.updateScene({monitorId:e.id,patch:t}))})]},e.id)})})]})}):null}export{J as SceneMonitorEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,W as n,X as r,q as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{L as o,R as s,V as c,z as l}from"./player-overlays-
|
|
1
|
+
import{Q as e,S as t,W as n,X as r,q as i,x as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{L as o,R as s,V as c,z as l}from"./player-overlays-UTlrOH4s.js";import{At as u,Dt as d,Et as f,It as p,Lt as m,Ot as h,Pt as g,Rr as _,Rt as v,Tt as y,jt as b,nt as x,t as S,tt as C}from"./src-CEchIfpK.js";import{t as w}from"./plus-CLrUKG39.js";import{g as T}from"./index-C4gpE4dh.js";import{t as E}from"./AdminPage-CCD07UMs.js";import{t as D}from"./use-scenes-feed-CCncPGkQ.js";e();function O(e){return e.states.length===0?3:e.latched?0:e.verdict===`diverged`?1:e.verdict===`unknown`?2:4}function k(e){let t=[e.divergedAt,e.restoredAt].filter(e=>typeof e==`number`);return t.length===0?null:Math.max(...t)}function A(e,t){let n=new Map(e.map(e=>[e.deviceId,e.deviceName])),r=[];for(let e of t)for(let t of e.monitors)r.push({deviceId:e.deviceId,deviceName:n.get(e.deviceId)??`Camera ${e.deviceId}`,monitor:t});return r.toSorted((e,t)=>{let n=O(e.monitor)-O(t.monitor);if(n!==0)return n;let r=k(e.monitor)??-1,i=k(t.monitor)??-1;if(r!==i)return i-r;let a=e.deviceName.localeCompare(t.deviceName);return a===0?e.monitor.label.localeCompare(t.monitor.label):a})}var j={alarm:`danger`,ok:`success`,unknown:`default`};function M(e,t){let n=k(e);return n===null?`—`:`${l(Math.max(0,t-n))} ago`}function N(){let e=_({isCamera:!0,projection:`slim`}),l=n(()=>(e.data??[]).map(e=>({deviceId:e.id,deviceName:e.name})).sort((e,t)=>e.deviceName.localeCompare(t.deviceName)),[e.data]),O=n(()=>l.map(e=>e.deviceId),[l]),k=D(O),N=n(()=>A(l,k.results),[l,k.results]),[P,F]=i(null),[I,L]=i(null),R=Date.now(),z=l.find(e=>e.deviceId===P)?.deviceName??``;return t(E,{icon:T,title:`Scenes`,subtitle:`A scene watches one region of one camera and tells you when it stops looking like the picture you captured — a wheelie bin, a gate, a parking space.`,actions:t(v,{onClick:()=>L(O[0]??null),disabled:l.length===0,children:[a(w,{className:`mr-1 h-3.5 w-3.5`}),`New scene`]}),children:[k.unreachableCount>0?t(`p`,{className:`text-xs text-warning`,children:[k.unreachableCount,` camera`,k.unreachableCount===1?``:`s`,` could not be asked about scenes. Those cameras are missing from this list — this is not the same as having no scenes.`]}):null,a(p,{variant:`flat`,className:`p-0`,children:a(C,{columns:[{key:`label`,header:`Scene`,render:e=>a(`span`,{className:`font-medium`,children:e.monitor.label})},{key:`camera`,header:`Camera`,nowrap:!0,render:e=>e.deviceName},{key:`state`,header:`State`,nowrap:!0,render:e=>{let t=o(e.monitor);return a(m,{variant:j[t.tone],children:t.text})}},{key:`status`,header:`What it says`,render:e=>a(`span`,{className:`text-xs text-muted-foreground`,children:c(e.monitor,R)})},{key:`coverage`,header:`Variants`,render:e=>a(`span`,{className:`text-xs text-muted-foreground`,children:s(e.monitor)})},{key:`transition`,header:`Last change`,align:`right`,nowrap:!0,render:e=>a(`span`,{className:`text-xs tabular-nums text-muted-foreground`,children:M(e.monitor,R)})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:e=>a(v,{variant:`ghost`,onClick:()=>F(e.deviceId),children:`Open`})}],rows:N,rowKey:e=>`${e.deviceId}:${e.monitor.id}`,minWidthPx:880,bordered:!1,mobileMode:`scroll`,maxBodyHeight:x,emptyMessage:k.isLoading?`Loading scenes…`:`No scenes yet. Press “New scene”, pick a camera, then draw a box around the thing you want watched.`})}),a(y,{open:I!==null,onOpenChange:e=>!e&&L(null),children:t(d,{width:`sm`,children:[t(u,{children:[a(b,{children:`Which camera?`}),a(h,{children:`A scene lives on one camera. Pick the one that can see the thing.`})]}),t(`div`,{className:`mt-3 flex items-center gap-2`,children:[a(g,{value:I===null?``:String(I),onChange:e=>L(Number(e.target.value)),"aria-label":`Camera`,options:l.map(e=>({value:String(e.deviceId),label:e.deviceName}))}),a(v,{onClick:()=>{F(I),L(null)},disabled:I===null,children:`Continue`})]})]})}),a(y,{open:P!==null,onOpenChange:e=>!e&&F(null),children:t(d,{width:`lg`,scroll:`body`,children:[t(u,{children:[t(b,{children:[`Scenes — `,z]}),a(h,{children:`Draw a box, name it, then capture what “normal” looks like. Daylight is enough — the night reference is optional, and “Settings” on each scene tunes how fussy and how often it checks.`})]}),a(f,{className:`mt-3`,children:P===null?null:a(r,{fallback:a(`p`,{className:`text-xs text-muted-foreground`,children:`Loading the editor…`}),children:a(S,{deviceId:P})})})]})})]})}export{N as ScenesPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,o as n,q as r,x as i,z as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Ft as o,It as s,Jo as c,Ko as l,Lt as u,Rt as d,Yi as f,qo as p}from"./src-
|
|
1
|
+
import{Q as e,S as t,o as n,q as r,x as i,z as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Ft as o,It as s,Jo as c,Ko as l,Lt as u,Rt as d,Yi as f,qo as p}from"./src-CEchIfpK.js";import{n as m}from"./FormBuilder-yxzbuGp1.js";import{t as h}from"./refresh-cw-6kHXys54.js";import{p as g}from"./index-C4gpE4dh.js";import{t as _}from"./AdminPage-CCD07UMs.js";import{t as v}from"./NodeAddonsSettingsPanel-D-zNagxQ.js";e();var y=[[`system`]];function b(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function x(){let e=n(),f=p(),g=c(),_=l(),[v,x]=r(``),[S,C]=r(``),[w,T]=r(null),E=f.data?.location??null;a(()=>{x(E===null?``:b(E.latitude)),C(E===null?``:b(E.longitude))},[E]);let D=async()=>{await e.invalidateQueries({queryKey:y})},O=async e=>{e.preventDefault();let t=Number(v),n=Number(S);if(v.trim()===``||S.trim()===``){T(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){T(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){T(`Longitude must be between -180 and 180 decimal degrees.`);return}T(null),await g.mutateAsync({latitude:t,longitude:n}),await D()},k=async()=>{T(null),await g.mutateAsync(null),await D()},A=async()=>{T(null),await _.mutateAsync(),await D()},j=g.isPending||_.isPending||f.isLoading;return t(s,{className:`space-y-3`,children:[t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`flex items-start gap-2`,children:[i(m,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),t(`div`,{children:[i(`h3`,{className:`text-sm font-medium`,children:`Site location`}),i(`p`,{className:`text-xs text-muted-foreground max-w-prose`,children:`Where this installation physically is. Used to compute real sunrise and sunset times — scene monitoring tells day, dusk, night and dawn apart with them, so a reference captured in daylight is never scored against a half-lit frame. Left unset, the fallback is a coarse UTC clock split.`})]})]}),E===null?i(u,{variant:`warning`,children:`Not configured`}):i(u,{variant:E.source===`operator-set`?`success`:`info`,children:E.source===`operator-set`?`Set by you`:`Derived from IP`})]}),E?.label!==void 0&&E.label!==``?t(`p`,{className:`text-xs text-muted-foreground`,children:[`Detected near `,E.label,`.`]}):null,E===null&&f.data?.derivationAttemptedAt!==null?t(`p`,{className:`text-xs text-warning`,children:[`Automatic detection from the public IP did not succeed`,f.data?.derivationError!==null&&f.data?.derivationError!==void 0?`: ${f.data.derivationError}`:`.`,` `,`It is not retried on its own — enter the coordinates, or press Detect.`]}):null,t(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:O,children:[t(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:`Latitude`}),i(o,{className:`w-40`,value:v,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>x(e.target.value),"aria-label":`Latitude`})]}),t(`label`,{className:`flex flex-col gap-1 text-xs`,children:[i(`span`,{className:`text-muted-foreground`,children:`Longitude`}),i(o,{className:`w-40`,value:S,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>C(e.target.value),"aria-label":`Longitude`})]}),i(d,{type:`submit`,disabled:j,children:`Save`}),t(d,{type:`button`,variant:`ghost`,disabled:j,onClick:A,children:[i(h,{className:`h-3.5 w-3.5 mr-1`}),`Detect from IP`]}),E===null?null:i(d,{type:`button`,variant:`ghost`,disabled:j,onClick:k,children:`Clear`})]}),w===null?null:i(`p`,{className:`text-xs text-danger`,children:w}),i(`p`,{className:`text-xs text-muted-foreground`,children:`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`})]})}function S(){let{data:e,isLoading:n}=f(void 0),r=(e??[]).find(e=>e.isHub&&e.isOnline),a=r?.addons.map(e=>e.id)??[];return t(_,{children:[i(x,{}),n?i(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`Loading hub topology…`}):r?a.length===0?i(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:`No addons installed on the hub yet.`}):i(v,{nodeId:r.id,addonIds:a,level:`global`}):t(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[i(g,{className:`h-8 w-8 opacity-30`}),i(`p`,{children:`No online hub node found.`}),i(`p`,{className:`text-xs`,children:`Settings will appear once the hub is reachable.`})]})]})}export{S as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{t as i}from"./CapabilityBadges-CByvC3eB.js";import{t as a}from"./ProviderIcon-D8aWAoj0.js";import{t as o}from"./FormBuilder-B-sNHhCg.js";import{t as s}from"./StatusBadge-CeptlsPG.js";e();function c({title:e,children:n}){return t(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2.5`,children:r(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:e})}),r(`div`,{className:`p-4`,children:n})]})}function l({name:e,cssVar:n,hex:i}){return t(`div`,{className:`flex flex-col items-center gap-1.5`,children:[r(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:n?`var(${n})`:i}}),r(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:e})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[e,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return t(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[t(`div`,{className:`mb-6`,children:[r(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),r(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),r(c,{title:`Typography`,children:t(`div`,{className:`space-y-3`,children:[r(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),r(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),r(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),r(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),r(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),r(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),r(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),r(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),r(c,{title:`Colors`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[r(l,{name:`primary`,cssVar:`--color-primary`}),r(l,{name:`background`,cssVar:`--color-background`}),r(l,{name:`surface`,cssVar:`--color-surface`}),r(l,{name:`foreground`,cssVar:`--color-foreground`}),r(l,{name:`success`,cssVar:`--color-success`}),r(l,{name:`warning`,cssVar:`--color-warning`}),r(l,{name:`danger`,cssVar:`--color-danger`}),r(l,{name:`info`,cssVar:`--color-info`}),r(l,{name:`border`,cssVar:`--color-border`}),r(`div`,{className:`w-px`}),r(l,{name:`frigate`,hex:`#3b82f6`}),r(l,{name:`scrypted`,hex:`#a855f7`}),r(l,{name:`reolink`,hex:`#06b6d4`}),r(l,{name:`ha`,hex:`#22d3ee`}),r(l,{name:`rtsp`,hex:`#78716c`})]})}),r(c,{title:`Buttons`,children:t(`div`,{className:`flex flex-wrap gap-3`,children:[r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),r(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),r(c,{title:`Inputs`,children:t(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),r(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),r(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),r(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),t(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[r(`option`,{children:`Option A`}),r(`option`,{children:`Option B`}),r(`option`,{children:`Option C`})]})]}),t(`div`,{className:`md:col-span-2`,children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),r(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),r(`div`,{children:t(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[r(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),r(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),r(`div`,{children:t(`div`,{className:`flex items-center justify-between`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),r(f,{})]})}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),r(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),r(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>r(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),r(c,{title:`Badges`,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),r(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>r(s,{status:e},e))})]}),t(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),r(i,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),r(c,{title:`Cards`,children:t(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[t(`div`,{className:`rounded-lg bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),t(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),t(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),t(`div`,{className:`rounded-lg bg-background p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),r(c,{title:`Provider Icons`,children:r(`div`,{className:`flex flex-wrap gap-4`,children:[`frigate`,`scrypted`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>r(a,{type:e,size:`lg`,showLabel:!0},e))})}),t(c,{title:`Form Builder Demo`,children:[r(o,{schema:u,values:e,onChange:d}),t(`details`,{className:`mt-3`,children:[r(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),r(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(e,null,2)})]})]}),r(c,{title:`Info Boxes`,children:r(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:e,label:n,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[e];return t(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[r(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:n}),r(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},e)})})})]})}function f(){let[e,t]=n(!0);return r(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>t(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:r(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|
|
1
|
+
import{Q as e,S as t,q as n,x as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{t as i}from"./CapabilityBadges-BNXFPTSR.js";import{t as a}from"./ProviderIcon-D6droj6v.js";import{t as o}from"./FormBuilder-yxzbuGp1.js";import{t as s}from"./StatusBadge-CeptlsPG.js";e();function c({title:e,children:n}){return t(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[r(`div`,{className:`border-b border-border px-4 py-2.5`,children:r(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:e})}),r(`div`,{className:`p-4`,children:n})]})}function l({name:e,cssVar:n,hex:i}){return t(`div`,{className:`flex flex-col items-center gap-1.5`,children:[r(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:n?`var(${n})`:i}}),r(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:e})]})}var u={sections:[{id:`demo`,title:`Demo Fields`,columns:2,fields:[{key:`name`,type:`text`,label:`Name`,placeholder:`Enter name`},{key:`count`,type:`number`,label:`Count`,min:0,max:100,unit:`items`},{key:`enabled`,type:`boolean`,label:`Enabled`},{key:`mode`,type:`select`,label:`Mode`,options:[{value:`a`,label:`Alpha`},{value:`b`,label:`Beta`}]},{key:`tags`,type:`tags`,label:`Tags`,span:2,suggestions:[`camera`,`zone`,`alert`]},{key:`confidence`,type:`slider`,label:`Confidence`,min:0,max:100,step:5,unit:`%`,span:2},{key:`info`,type:`info`,label:`Note`,content:`This is an informational message for the user.`,variant:`info`}]}]};function d(){let[e,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return t(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[t(`div`,{className:`mb-6`,children:[r(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),r(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),r(c,{title:`Typography`,children:t(`div`,{className:`space-y-3`,children:[r(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),r(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),r(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),r(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),r(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),r(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),r(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),r(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),r(c,{title:`Colors`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[r(l,{name:`primary`,cssVar:`--color-primary`}),r(l,{name:`background`,cssVar:`--color-background`}),r(l,{name:`surface`,cssVar:`--color-surface`}),r(l,{name:`foreground`,cssVar:`--color-foreground`}),r(l,{name:`success`,cssVar:`--color-success`}),r(l,{name:`warning`,cssVar:`--color-warning`}),r(l,{name:`danger`,cssVar:`--color-danger`}),r(l,{name:`info`,cssVar:`--color-info`}),r(l,{name:`border`,cssVar:`--color-border`}),r(`div`,{className:`w-px`}),r(l,{name:`frigate`,hex:`#3b82f6`}),r(l,{name:`scrypted`,hex:`#a855f7`}),r(l,{name:`reolink`,hex:`#06b6d4`}),r(l,{name:`ha`,hex:`#22d3ee`}),r(l,{name:`rtsp`,hex:`#78716c`})]})}),r(c,{title:`Buttons`,children:t(`div`,{className:`flex flex-wrap gap-3`,children:[r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90 transition-opacity`,children:`Primary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-border bg-surface px-4 py-2 text-sm font-medium text-foreground hover:bg-surface-hover transition-colors`,children:`Secondary`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-danger/40 bg-danger/10 px-4 py-2 text-sm font-medium text-danger hover:bg-danger/20 transition-colors`,children:`Danger`}),r(`button`,{disabled:!0,className:`inline-flex items-center gap-1.5 rounded-md bg-primary px-4 py-2 text-sm font-medium text-white opacity-40 cursor-not-allowed`,children:`Disabled`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-warning/40 bg-warning/10 px-4 py-2 text-sm font-medium text-warning hover:bg-warning/20 transition-colors`,children:`Warning`}),r(`button`,{className:`inline-flex items-center gap-1.5 rounded-md border border-success/40 bg-success/10 px-4 py-2 text-sm font-medium text-success hover:bg-success/20 transition-colors`,children:`Success`})]})}),r(c,{title:`Inputs`,children:t(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),r(`input`,{type:`text`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`Type something...`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),r(`input`,{type:`number`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`0`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),r(`input`,{type:`password`,className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,placeholder:`••••••••`})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),t(`select`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30`,children:[r(`option`,{children:`Option A`}),r(`option`,{children:`Option B`}),r(`option`,{children:`Option C`})]})]}),t(`div`,{className:`md:col-span-2`,children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),r(`textarea`,{className:`w-full rounded-md border border-border bg-background px-3 py-2 text-sm text-foreground outline-none focus:border-primary focus:ring-1 focus:ring-primary/30 resize-y min-h-[60px]`,placeholder:`Enter multi-line text...`,rows:3})]}),r(`div`,{children:t(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[r(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),r(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),r(`div`,{children:t(`div`,{className:`flex items-center justify-between`,children:[r(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),r(f,{})]})}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),r(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),t(`div`,{children:[r(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),r(`div`,{className:`flex flex-wrap gap-1.5 rounded-md border border-border bg-background px-2 py-1.5 min-h-[38px]`,children:[`camera`,`zone`,`alert`].map(e=>r(`span`,{className:`inline-flex items-center gap-1 rounded-md bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:e},e))})]})]})}),r(c,{title:`Badges`,children:t(`div`,{className:`space-y-3`,children:[t(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),r(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>r(s,{status:e},e))})]}),t(`div`,{children:[r(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),r(i,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),r(c,{title:`Cards`,children:t(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[t(`div`,{className:`rounded-lg bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),t(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),t(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),t(`div`,{className:`rounded-lg bg-background p-4`,children:[r(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),r(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),r(c,{title:`Provider Icons`,children:r(`div`,{className:`flex flex-wrap gap-4`,children:[`frigate`,`scrypted`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>r(a,{type:e,size:`lg`,showLabel:!0},e))})}),t(c,{title:`Form Builder Demo`,children:[r(o,{schema:u,values:e,onChange:d}),t(`details`,{className:`mt-3`,children:[r(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),r(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(e,null,2)})]})]}),r(c,{title:`Info Boxes`,children:r(`div`,{className:`space-y-2`,children:[{variant:`info`,label:`Info`,content:`This is an informational message. Use it for tips and hints.`},{variant:`warning`,label:`Warning`,content:`This action may have side effects. Proceed with caution.`},{variant:`success`,label:`Success`,content:`Operation completed successfully. All systems are green.`},{variant:`danger`,label:`Danger`,content:`This operation is irreversible. Data will be permanently deleted.`}].map(({variant:e,label:n,content:i})=>{let a={info:{border:`border-info`,bg:`bg-info/5`,text:`text-info`},warning:{border:`border-warning`,bg:`bg-warning/5`,text:`text-warning`},success:{border:`border-success`,bg:`bg-success/5`,text:`text-success`},danger:{border:`border-danger`,bg:`bg-danger/5`,text:`text-danger`}}[e];return t(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[r(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:n}),r(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},e)})})})]})}function f(){let[e,t]=n(!0);return r(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>t(e=>!e),className:[`relative inline-flex h-4 w-8 shrink-0 items-center rounded-full transition-colors duration-150 cursor-pointer`,e?`bg-primary`:`bg-foreground-subtle/30`].join(` `),children:r(`span`,{className:[`inline-block h-3 w-3 rounded-full bg-white shadow transition-transform duration-150`,e?`translate-x-4`:`translate-x-0.5`].join(` `)})})}export{d as ShowroomPage};
|