@camstack/addon-admin-ui 1.2.17 → 1.2.18
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-KwzmlSoV.js → AddLocationWizard-BowIG3iq.js} +1 -1
- package/dist/assets/{AddonCollectionPage-Dn32SNWM.js → AddonCollectionPage-DzUEOYUV.js} +1 -1
- package/dist/assets/{Addons-EyEW4D4A.js → Addons-B5DucodR.js} +1 -1
- package/dist/assets/{AdminTabs-57hhQmVl.js → AdminTabs-C-SMNF-6.js} +1 -1
- package/dist/assets/{AiProfiles-uNlhciHT.js → AiProfiles-D65CezzL.js} +1 -1
- package/dist/assets/{BrokerForm-DyoPjxXz.js → BrokerForm-ENHOk64X.js} +1 -1
- package/dist/assets/{Capabilities-cVsIOc2t.js → Capabilities-dtlaxRnV.js} +1 -1
- package/dist/assets/{CapabilityBadges-s1q6EazS.js → CapabilityBadges-QVudw7lC.js} +1 -1
- package/dist/assets/{Cluster-BkmB4wXT.js → Cluster-9-Ysfuh5.js} +1 -1
- package/dist/assets/{ClusterRecordingTab-BH11-IbA.js → ClusterRecordingTab-CvimJgTY.js} +1 -1
- package/dist/assets/{Dashboard-CwGNZIik.js → Dashboard-CXFEM2IR.js} +1 -1
- package/dist/assets/{Data-DU6dKN0-.js → Data-DPmsq4Rb.js} +1 -1
- package/dist/assets/{DetectionIntelligence-DgBcQaJ7.js → DetectionIntelligence-CsY0BCKS.js} +1 -1
- package/dist/assets/{DeviceAggregateSection-DDZxpHxU.js → DeviceAggregateSection-CzThj0Vt.js} +1 -1
- package/dist/assets/{DeviceDetail-Z501iVY2.js → DeviceDetail-BWX7NeMm.js} +1 -1
- package/dist/assets/{Devices-BUppgEis.js → Devices-CdMd1Rxe.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-DyKLMuTg.js → EmbedPlayerPage-BPMSAjgX.js} +1 -1
- package/dist/assets/{Events-DRMEOb-1.js → Events-DlSc5xWS.js} +1 -1
- package/dist/assets/{FormBuilder-V9-ZYyfi.js → FormBuilder-BTBth7Mm.js} +1 -1
- package/dist/assets/{Identity-BOlAVEHc.js → Identity-BkJfHHax.js} +1 -1
- package/dist/assets/{IntegrationDetail-xhGos6_v.js → IntegrationDetail-DjcVm32z.js} +1 -1
- package/dist/assets/{Integrations-Dp5hPLpw.js → Integrations-BstWDI9y.js} +1 -1
- package/dist/assets/{Integrations-CXfoHU1-.js → Integrations-CCkqm_Su.js} +1 -1
- package/dist/assets/{Logs-kyji_5ss.js → Logs-BKvPV_wj.js} +1 -1
- package/dist/assets/{MotionZonesSettings-M7Q0c7HT.js → MotionZonesSettings-C3F5tNrn.js} +1 -1
- package/dist/assets/{MyAccess-BP00gmMz.js → MyAccess-D94hQDyr.js} +1 -1
- package/dist/assets/{Network-BupOQchv.js → Network-DRjrjeQG.js} +1 -1
- package/dist/assets/{NodeAddonsSettingsPanel-BHYPuuzP.js → NodeAddonsSettingsPanel-CL75zTHK.js} +1 -1
- package/dist/assets/{NodeInferenceDevices-CYZafvHq.js → NodeInferenceDevices-gVLIWG74.js} +1 -1
- package/dist/assets/Notifications-7spoN22j.js +1 -0
- package/dist/assets/{Pipeline-Cc89loIx.js → Pipeline-Dmgt7OdK.js} +1 -1
- package/dist/assets/{Plates-CaHuT1aj.js → Plates-0nXxdKJX.js} +1 -1
- package/dist/assets/{PrivacyMaskSettings-C8tsyRZP.js → PrivacyMaskSettings-BC6o9lqJ.js} +1 -1
- package/dist/assets/{ProviderIcon-CD80TWfL.js → ProviderIcon-tK6tKDtF.js} +1 -1
- package/dist/assets/{Recordings-Ds0k0Oit.js → Recordings-BtjWTugI.js} +1 -1
- package/dist/assets/{ScanNetworkModal-C1fdwcgx.js → ScanNetworkModal-CwPUWLnW.js} +1 -1
- package/dist/assets/{Settings-D9xYfuNz.js → Settings-CmklSlYL.js} +1 -1
- package/dist/assets/{Showroom-DfupwGEQ.js → Showroom-fSzPo12F.js} +1 -1
- package/dist/assets/{Terminal-QIfVJ57m.js → Terminal-DLULQ5yw.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DTU5DNxA.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C8V797Ba.js} +1 -1
- package/dist/assets/{build-cluster-graph-DryWXcym.js → build-cluster-graph-DIGI0NJ3.js} +1 -1
- package/dist/assets/circle-check-big-DifLR11P.js +1 -0
- package/dist/assets/clock-BXw5TTp6.js +1 -0
- package/dist/assets/{copy-xvYnf3mn.js → copy-D4StuZzs.js} +1 -1
- package/dist/assets/{debounced-invalidate-CT06Xct6.js → debounced-invalidate-CXo5TVm0.js} +1 -1
- package/dist/assets/{dist-kk5V4ONk.js → dist-B1ZcDDOx.js} +1 -1
- package/dist/assets/dist-BqHHqLgd.js +7 -0
- package/dist/assets/{download-4PdCPJIH.js → download-Dq6V-5xf.js} +1 -1
- package/dist/assets/{face-bbox-BOfEr6-A.js → face-bbox-CnD55hf6.js} +1 -1
- package/dist/assets/{hostInit-BbElAo79.js → hostInit-DyHdo8Gk.js} +1 -1
- package/dist/assets/{index-DUFmNDGR.js → index-BsmimqzB.js} +3 -3
- package/dist/assets/{key-round-BluylYau.js → key-round-BC8uv06u.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-d0572cd2.js → mf-entry-bootstrap-0-278ef480.js} +2 -2
- package/dist/assets/{pencil-upvlHQDr.js → pencil-BuY8CueB.js} +1 -1
- package/dist/assets/{player-overlays-DFxnnQ5-.js → player-overlays-CNHQKrHd.js} +1 -1
- package/dist/assets/plus-DyBHOfPx.js +1 -0
- package/dist/assets/{radio-CNyLw5GQ.js → radio-CQ2Qddgd.js} +1 -1
- package/dist/assets/{refresh-cw-Brd1nmbC.js → refresh-cw-BwbLLVV6.js} +1 -1
- package/dist/assets/remoteEntry-BQiHtOSG.js +1 -0
- package/dist/assets/{rotate-ccw-CrfFxSL1.js → rotate-ccw-D9ag3NNh.js} +1 -1
- package/dist/assets/rotate-cw-J5QBXynE.js +1 -0
- package/dist/assets/search-BLl1nrAm.js +1 -0
- package/dist/assets/{send-DcQrPOWq.js → send-CrQGjBpn.js} +1 -1
- package/dist/assets/{server-s54U0Xav.js → server-C-ApRIN8.js} +1 -1
- package/dist/assets/square-D5oi0WlG.js +1 -0
- package/dist/assets/{square-check-big-CkGVGfz1.js → square-check-big-D0Ns-qwF.js} +1 -1
- package/dist/assets/{src-Btp5jZp0.js → src-BDNLbHXL.js} +10 -10
- package/dist/assets/src-SFNx0Juf.js +7 -0
- package/dist/assets/{upload-ZqMKZ88x.js → upload-OKC5mQ8W.js} +1 -1
- package/dist/assets/{useEventInvalidation-ByOUWkAr.js → useEventInvalidation-BHTo3YFv.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CsWv8uI6.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CkMK9IKI.js} +2 -2
- package/dist/assets/{wifi-C008K8Xa.js → wifi-xQgrxKer.js} +1 -1
- package/dist/assets/{zap-VYSIuI1A.js → zap-B6f_Rmgy.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/server/addon.js +106 -4
- package/package.json +1 -1
- package/dist/assets/Notifications-C7yz_fFq.js +0 -1
- package/dist/assets/circle-check-big-Cz1WD2g9.js +0 -1
- package/dist/assets/clock-D9iqCSCa.js +0 -1
- package/dist/assets/dist-9AilmwYu.js +0 -7
- package/dist/assets/plus-pXafUidG.js +0 -1
- package/dist/assets/remoteEntry-CNHP9pn9.js +0 -1
- package/dist/assets/rotate-cw-BvJwWYA6.js +0 -1
- package/dist/assets/search-DHWQ7t3y.js +0 -1
- package/dist/assets/square-CqUnowVe.js +0 -1
- package/dist/assets/src-DlGmnrz9.js +0 -7
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{$n as e,Ao as t,Co as n,Do as r,Eo as i,Ka as a,Ki as o,Oo as s,S as c,So as l,To as u,bo as d,ko as f,oo as p,wo as m,yo as h}from"./src-Btp5jZp0.js";import{Q as g,S as _,W as v,a as y,b,i as x,q as S,t as C,x as w}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DTufy7Ue.js";import{E as T,T as E,k as D,w as O}from"./src-DlGmnrz9.js";import{p as k}from"./player-overlays-DFxnnQ5-.js";import{t as A}from"./circle-check-big-Cz1WD2g9.js";import{t as j}from"./copy-xvYnf3mn.js";import{t as M}from"./pencil-upvlHQDr.js";import{t as N}from"./plus-pXafUidG.js";import{t as P}from"./refresh-cw-Brd1nmbC.js";import{t as ee}from"./search-DHWQ7t3y.js";import{t as F}from"./send-DcQrPOWq.js";import{N as te,S as I,V as ne,W as L,i as re,s as R}from"./index-DUFmNDGR.js";import{t as z}from"./AdminPage-Dq33XE9j.js";import{t as ie}from"./AdminTabs-57hhQmVl.js";var B=L(`bell-ring`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M22 8c0-2.3-.8-4.3-2-6`,key:`5bb3ad`}],[`path`,{d:`M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326`,key:`11g9vi`}],[`path`,{d:`M4 2C2.8 3.7 2 5.7 2 8`,key:`tap9e0`}]]),ae=L(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),oe=L(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]);g();var V=e=>typeof e==`string`&&e.length>0;function se(e){return{levels:e.levels,formats:e.format,bodyMaxLen:e.bodyMaxLen,attachmentSlots:e.attachments.mediaTypes,attachmentMode:e.attachments.mode,attachmentMax:e.attachments.max,attachmentMaxBytes:e.attachments.maxBytes,maxActions:e.actions,showActions:e.actions>0,showClickUrl:e.clickUrl,showSound:e.sound,showTtl:e.ttl,showTag:!0}}function ce(e,t){return e.format.includes(t)?t:e.format[0]??`text`}function le(e,t){let n=[];for(let r of e.attachments.mediaTypes){if(n.length>=e.attachments.max)break;let i=t[r];V(i)&&n.push({mediaType:r,url:i})}return n}function ue(e,t){if(e.actions<=0)return[];let n=[];for(let r of t){if(n.length>=e.actions)break;let t=V(r.label),i=V(r.url);!t&&!i||n.push({id:`test-${n.length+1}`,label:t?r.label:`Action ${n.length+1}`,...i?{url:r.url}:{}})}return n}function de(e,t){let n=e.levels.some(e=>e.id===t.level)?t.level:void 0,r=le(e,t.attachmentUrls),i=ue(e,t.actions),a=e.ttl&&V(t.ttl)?Number(t.ttl):void 0;return{body:t.body,format:ce(e,t.format),priority:fe(t.priority),...V(t.title)?{title:t.title}:{},...n?{level:n}:{},...r.length>0?{attachments:r}:{},...i.length>0?{actions:i}:{},...e.clickUrl&&V(t.clickUrl)?{clickUrl:t.clickUrl}:{},...e.sound&&V(t.sound)?{sound:t.sound}:{},...a!==void 0&&Number.isFinite(a)?{ttl:a}:{},...V(t.tag)?{tag:t.tag}:{}}}function fe(e){return Number.isFinite(e)?Math.min(5,Math.max(1,Math.round(e))):3}function pe(e){return e.levels.find(e=>e.flags?.critical===!0)||e.levels.filter(e=>typeof e.ordinal==`number`).sort((e,t)=>t.ordinal-e.ordinal)[0]}function H(e){return{level:``,priority:3,format:e.format[0]??`text`,title:``,body:``,attachmentUrls:{},actions:[],clickUrl:``,sound:``,ttl:``,tag:``}}var me={image:`/addon/notifiers/samples/image`,video:`/addon/notifiers/samples/video`,gif:`/addon/notifiers/samples/gif`,audio:`/addon/notifiers/samples/audio`,icon:`/addon/notifiers/samples/icon`};function he(e,t){return e.attachments.max>0&&e.attachments.mediaTypes.includes(t)}function ge(e){let t=[`text`];for(let n of[`image`,`gif`,`video`,`audio`])he(e,n)&&t.push(n);return e.actions>0&&t.push(`actions`),e.levels.length>0&&t.push(`critical`),t.push(`overflow`),t}function U(e,t,n){let r=H(e);return he(e,t)?{...r,body:n,attachmentUrls:{[t]:me[t]}}:{...r,body:n}}function _e(e,t){let n=H(e);switch(t){case`text`:return{...n,title:`CamStack`,body:`Test notification — text only.`};case`image`:return U(e,`image`,`Test notification with an image.`);case`gif`:return U(e,`gif`,`Test notification with an animation.`);case`video`:return U(e,`video`,`Test notification with a video.`);case`audio`:return U(e,`audio`,`Test notification with audio.`);case`actions`:{let t=Array.from({length:e.actions},(e,t)=>({label:`Action ${t+1}`,url:`/`}));return{...n,title:`CamStack`,body:`Test notification with action buttons.`,actions:t,...e.clickUrl?{clickUrl:`/`}:{}}}case`critical`:{let t=pe(e);return{...n,title:`CamStack`,body:`Critical test notification.`,priority:5,level:t?.id??``}}case`overflow`:return{...n,body:`X`.repeat(e.bodyMaxLen+50)}}}var ve={text:`Text only`,image:`With image`,gif:`With GIF`,video:`With video`,audio:`With audio`,actions:`With buttons`,critical:`Critical`,overflow:`Overflow (advanced)`},W=`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,G=`block text-[11px] font-medium text-foreground mb-1`;function ye({target:e,kind:r,open:i,onClose:a}){let o=k(),s=v(()=>se(r.caps),[r.caps]),c=v(()=>ge(r.caps),[r.caps]),[u,p]=S(()=>H(r.caps)),[g,y]=S(null),b=v(()=>de(r.caps,u),[r.caps,u]),x=u.body.length,T=x>s.bodyMaxLen,E=e=>p(t=>({...t,...e})),D=C({mutationFn:()=>o.trpcClient.notificationOutput.testTarget.mutate({addonId:e.addonId,targetId:e.id,sample:de(r.caps,u)}),onMutate:()=>y(null),onSuccess:e=>y(e),onError:e=>y({success:!1,error:e instanceof Error?e.message:`Test failed`})}),O=e=>{p(_e(r.caps,e)),y(null)},A=(e,t,n)=>{let r=u.actions.length>0?[...u.actions]:[];for(;r.length<=e;)r.push({label:``,url:``});r[e]={...r[e],[t]:n},E({actions:r})};return w(h,{open:i,onOpenChange:e=>!e&&a(),children:_(d,{width:`lg`,className:`!max-w-2xl`,children:[w(n,{children:_(m,{children:[`Test "`,e.name,`" (`,r.label,`)`]})}),_(`div`,{className:`space-y-4 max-h-[60vh] overflow-y-auto pr-1`,children:[w(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>w(t,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>O(e),children:ve[e]},e))}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[s.levels.length>0&&_(`div`,{children:[w(`label`,{className:G,children:`Level`}),_(`select`,{className:W,value:u.level,onChange:e=>E({level:e.target.value}),children:[w(`option`,{value:``,children:`— derive from priority —`}),s.levels.map(e=>_(`option`,{value:e.id,children:[e.label,e.ordinal===null?` (qualitative)`:` (p${e.ordinal})`]},e.id))]}),(()=>{let e=s.levels.find(e=>e.id===u.level);return e?_(`div`,{className:`mt-1 space-y-1`,children:[e.description&&w(`p`,{className:`text-[10px] text-foreground-subtle`,children:e.description}),_(`div`,{className:`flex flex-wrap gap-1`,children:[e.flags?.critical&&w(f,{variant:`danger`,"data-testid":`flag-critical`,children:`critical`}),e.flags?.silent&&w(f,{variant:`info`,children:`silent`}),e.flags?.noPush&&w(f,{variant:`warning`,children:`no-push`})]}),e.requires&&e.requires.length>0&&_(`p`,{className:`text-[10px] text-warning`,children:[`Requires target config: `,e.requires.join(`, `)]})]}):null})()]}),_(`div`,{children:[_(`label`,{className:G,children:[`Priority (ordinal): `,u.priority]}),w(`input`,{type:`range`,min:1,max:5,step:1,value:u.priority,onChange:e=>E({priority:Number(e.target.value)}),className:`w-full accent-primary`,"aria-label":`priority`})]})]}),s.formats.length>0&&_(`div`,{children:[w(`label`,{className:G,children:`Format`}),w(`div`,{className:`flex flex-wrap gap-2`,children:s.formats.map(e=>_(`label`,{className:`flex items-center gap-1.5 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`radio`,name:`format`,className:`accent-primary`,checked:u.format===e,onChange:()=>E({format:e})}),e]},e))})]}),_(`div`,{children:[w(`label`,{className:G,children:`Title`}),w(`input`,{className:W,value:u.title,onChange:e=>E({title:e.target.value})})]}),_(`div`,{children:[_(`label`,{className:G,children:[`Body`,` `,_(`span`,{className:T?`text-danger`:`text-foreground-subtle`,children:[`(`,x,`/`,s.bodyMaxLen,T?` — overflow`:``,`)`]})]}),w(`textarea`,{className:`${W} min-h-[80px] resize-y`,value:u.body,onChange:e=>E({body:e.target.value})})]}),s.attachmentSlots.length>0&&_(`div`,{children:[_(`label`,{className:G,children:[`Attachments`,` `,_(`span`,{className:`text-foreground-subtle`,children:[`(mode: `,s.attachmentMode,`, max `,s.attachmentMax,s.attachmentMaxBytes?`, ≤${Math.round(s.attachmentMaxBytes/1024/1024)}MB`:``,`)`]})]}),w(`div`,{className:`space-y-1.5`,children:s.attachmentSlots.map(e=>_(`div`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`text-[10px] w-12 shrink-0 text-foreground-subtle`,children:e}),w(`input`,{className:W,placeholder:`${e} URL`,value:u.attachmentUrls[e]??``,onChange:t=>E({attachmentUrls:{...u.attachmentUrls,[e]:t.target.value}})})]},e))})]}),s.showActions&&_(`div`,{children:[_(`label`,{className:G,children:[`Actions (up to `,s.maxActions,`)`]}),w(`div`,{className:`space-y-1.5`,children:Array.from({length:Math.min(s.maxActions,3)},(e,t)=>_(`div`,{className:`flex items-center gap-2`,children:[w(`input`,{className:W,placeholder:`label`,value:u.actions[t]?.label??``,onChange:e=>A(t,`label`,e.target.value)}),w(`input`,{className:W,placeholder:`url`,value:u.actions[t]?.url??``,onChange:e=>A(t,`url`,e.target.value)})]},t))})]}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[s.showClickUrl&&_(`div`,{children:[w(`label`,{className:G,children:`Click URL`}),w(`input`,{className:W,value:u.clickUrl,onChange:e=>E({clickUrl:e.target.value})})]}),s.showSound&&_(`div`,{children:[w(`label`,{className:G,children:`Sound`}),w(`input`,{className:W,value:u.sound,onChange:e=>E({sound:e.target.value})})]}),s.showTtl&&_(`div`,{children:[w(`label`,{className:G,children:`TTL (seconds)`}),w(`input`,{className:W,type:`number`,value:u.ttl,onChange:e=>E({ttl:e.target.value})})]}),s.showTag&&_(`div`,{children:[w(`label`,{className:G,children:`Tag`}),w(`input`,{className:W,value:u.tag,onChange:e=>E({tag:e.target.value})})]})]}),g&&w(be,{result:g}),_(`details`,{className:`text-[10px]`,children:[w(`summary`,{className:`cursor-pointer text-foreground-subtle`,children:`Payload preview`}),w(`pre`,{className:`mt-1 overflow-x-auto rounded bg-surface p-2 text-foreground-subtle`,children:JSON.stringify(b,null,2)})]})]}),_(l,{children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:a,children:`Close`}),_(t,{size:`sm`,type:`button`,disabled:D.isPending||u.body.length===0,onClick:()=>D.mutate(),children:[D.isPending?w(I,{className:`h-3.5 w-3.5 animate-spin`}):w(F,{className:`h-3.5 w-3.5`}),`Send test`]})]})]})})}function be({result:e}){let t=e.renderedAs;return _(`div`,{className:`rounded-md border px-3 py-2 text-xs ${e.success?`border-success/40 bg-success/10`:`border-danger/40 bg-danger/10`}`,"data-testid":`test-result`,children:[_(`div`,{className:`flex items-center gap-2 font-medium`,children:[e.success?w(A,{className:`h-3.5 w-3.5 text-success`}):w(te,{className:`h-3.5 w-3.5 text-danger`}),w(`span`,{children:e.success?`Delivered`:`Failed`})]}),e.error&&w(`p`,{className:`mt-1 text-danger`,children:e.error}),t&&_(`dl`,{className:`mt-2 grid grid-cols-2 gap-x-3 gap-y-0.5 text-[11px] text-foreground-subtle`,children:[w(`dt`,{children:`Resolved level`}),w(`dd`,{className:`text-foreground`,children:t.level}),w(`dt`,{children:`Format sent`}),w(`dd`,{className:`text-foreground`,children:t.format}),w(`dt`,{children:`Attachments sent`}),w(`dd`,{className:`text-foreground`,children:t.attachmentsSent}),w(`dt`,{children:`Actions sent`}),w(`dd`,{className:`text-foreground`,children:t.actionsSent}),w(`dt`,{children:`Truncated`}),w(`dd`,{className:`text-foreground`,children:t.truncated?`yes`:`no`}),w(`dt`,{children:`Dropped`}),w(`dd`,{className:`text-foreground`,children:t.dropped.length>0?t.dropped.join(`, `):`—`})]})]})}function xe(e){let t=[],n=new Map;for(let r of e){let e=n.get(r.addonId);e?e.push(r):(n.set(r.addonId,[r]),t.push(r.addonId))}return t.map(e=>({addonId:e,kinds:n.get(e)??[]}))}function Se(e){let t=[],n=e=>{for(let r of e){if(r.type===`password`){t.push(r.key);continue}if(r.type===`group`){n(r.fields);continue}if(r.type===`sub-tabs`)for(let e of r.tabs)n(e.fields)}};for(let t of e.sections)n(t.fields);return t}function Ce(e,t,n){let r=new Set(n),i={};for(let[n,a]of Object.entries(e)){if(!r.has(n)){i[n]=a;continue}a==null||a===``||a!==t[n]&&(i[n]=a)}return i}function we(e,t){let n=new Set(t),r={};for(let[t,i]of Object.entries(e))r[t]=n.has(t)?``:i;return r}g();var Te=[`notificationOutput`,`listTargets`],Ee=[`notificationOutput`,`listTargetKinds`],De=[`userManagement`,`listUsers`],K=`ownerUserId`;function Oe(e){let t=e.config[K];return typeof t==`string`&&t.length>0?t:null}function ke(e){return[{key:`name`,header:`Target`,render:t=>{let n=e.kindByKey.get(t.kind);return _(`span`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface text-xs`,title:n?.label??t.kind,children:w(q,{kind:n,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:``})}),w(`span`,{className:`truncate text-sm font-medium text-foreground`,children:t.name}),!t.enabled&&w(f,{variant:`warning`,children:`disabled`})]})}},{key:`kind`,header:`Kind`,nowrap:!0,render:t=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByKey.get(t.kind)?.label??t.kind})},{key:`owner`,header:`Owner`,nowrap:!0,render:t=>{let n=Oe(t);return n===null?w(f,{variant:`default`,children:`system`}):w(`span`,{className:`text-[11px] text-foreground`,children:e.userNameById.get(n)??n})}},{key:`enabled`,header:`On`,align:`center`,nowrap:!0,render:t=>w(u,{checked:t.enabled,onCheckedChange:n=>e.onToggle(t,n),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>{let r=e.kindByKey.get(n.kind);return _(`span`,{className:`flex items-center justify-end gap-1`,children:[w(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>e.onTest(n),title:`Test`,children:w(F,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,disabled:!r,onClick:()=>r&&e.onEdit(n,r),title:`Edit`,children:w(M,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(n),title:`Delete`,children:w(R,{className:`h-3.5 w-3.5 text-danger`})})]})}}]}function q({kind:e,imgClassName:t,fallbackClassName:n}){return e?.iconUrl?w(`img`,{src:e.iconUrl,alt:e.label,className:t,loading:`lazy`,draggable:!1}):w(`span`,{className:n,children:e?.icon??`🔔`})}function Ae(){let e=k(),[n,r]=S({mode:`closed`}),[i,o]=S(null),c=y({queryKey:Te,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),l=y({queryKey:Ee,queryFn:async()=>(await e.trpcClient.notificationOutput.listTargetKinds.query({})).map(e=>{let t=e.iconUrl;return{...e,configSchema:e.configSchema,iconUrl:t}})}),u=v(()=>l.data??[],[l.data]),d=v(()=>{let e=new Map;for(let t of u)e.set(t.kind,t);return e},[u]),f=y({queryKey:De,queryFn:()=>e.trpcClient.userManagement.listUsers.query()}),m=v(()=>{let e=new Map;for(let t of f.data??[])e.set(t.id,t.username);return e},[f.data]),h=C({mutationFn:t=>e.trpcClient.notificationOutput.setTargetEnabled.mutate({addonId:t.target.addonId,targetId:t.target.id,enabled:t.enabled}),onSuccess:()=>void c.refetch()}),g=C({mutationFn:t=>e.trpcClient.notificationOutput.deleteTarget.mutate({addonId:t.addonId,targetId:t.id}),onSuccess:()=>void c.refetch()}),b=i?d.get(i.kind):void 0;return _(z,{icon:ne,title:`Notification Targets`,subtitle:`Deliver notifications to ntfy, Pushover, Telegram, Home Assistant and more. Each target's kind declares its capabilities; the test panel shows exactly what a message degrades to.`,actions:_(t,{size:`sm`,type:`button`,onClick:()=>r({mode:`pick-kind`}),children:[w(N,{className:`h-3.5 w-3.5`}),`Add target`]}),children:[c.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(I,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&w(a,{title:`Failed to load targets`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&(c.data??[]).length===0&&w(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification targets yet. Click "Add target" to configure one.`}),(c.data??[]).length>0&&w(s,{children:w(p,{columns:ke({kindByKey:d,userNameById:m,onToggle:(e,t)=>h.mutate({target:e,enabled:t}),onTest:o,onEdit:(e,t)=>r({mode:`form`,kind:t,target:e}),onDelete:e=>g.mutate(e)}),rows:c.data??[],rowKey:e=>e.id,minWidthPx:720,bordered:!1})}),n.mode===`pick-kind`&&w(je,{kinds:u,onCancel:()=>r({mode:`closed`}),onPick:e=>r({mode:`form`,kind:e,target:null})}),n.mode===`form`&&w(Me,{kind:n.kind,target:n.target,users:f.data??[],onCancel:()=>r({mode:`closed`}),onSaved:()=>{r({mode:`closed`}),c.refetch()}}),i&&b&&w(ye,{target:i,kind:b,open:!0,onClose:()=>o(null)})]})}function je({kinds:e,onPick:n,onCancel:r}){let i=v(()=>xe(e),[e]);return _(s,{className:`p-4 space-y-4`,children:[_(`div`,{className:`flex items-center justify-between`,children:[w(`h3`,{className:`text-sm font-semibold text-foreground`,children:`Choose a notification kind`}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:r,children:`Cancel`})]}),i.length===0&&w(`p`,{className:`text-xs text-foreground-subtle`,children:`No notification providers are installed. Install the notifiers addon (or connect Home Assistant) to add targets.`}),i.map(e=>_(`div`,{children:[w(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle mb-1.5`,children:e.addonId}),w(`div`,{className:`grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 gap-2`,children:e.kinds.map(t=>_(`button`,{type:`button`,onClick:()=>n(t),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs hover:border-primary/50 hover:bg-surface-hover transition-colors`,children:[w(q,{kind:t,imgClassName:`h-7 w-7 object-contain`,fallbackClassName:`text-lg leading-7`}),w(`span`,{className:`font-medium text-foreground`,children:t.label}),t.supportsDiscovery&&w(f,{variant:`info`,style:`outline`,children:`discover`})]},`${e.addonId}:${t.kind}`))})]},e.addonId))]})}function Me({kind:e,target:n,users:r,onSaved:a,onCancel:o}){let l=k(),u=v(()=>Se(e.configSchema),[e.configSchema]),d=v(()=>n?.config??{},[n]),[f,p]=S(n?.name??e.label),[m,h]=S(()=>n?we(n.config,u):{}),[g,y]=S(null),[b,x]=S(null),[T,E]=S(n?Oe(n)??``:``),D=C({mutationFn:()=>l.trpcClient.notificationOutput.discoverTargets.query({addonId:e.addonId,kind:e.kind,config:m}),onSuccess:e=>y(e),onError:e=>x(e instanceof Error?e.message:`Discovery failed`)}),O=C({mutationFn:()=>{let{[K]:t,...r}=Ce(m,d,u),i=T===``?r:{...r,[K]:T},a={id:n?.id??`${e.kind}-${Date.now()}`,name:f,kind:e.kind,addonId:e.addonId,enabled:n?.enabled??!0,config:i};return l.trpcClient.notificationOutput.upsertTarget.mutate({addonId:e.addonId,target:a})},onSuccess:a,onError:e=>x(e instanceof Error?e.message:`Save failed`)}),A=e=>{p(e.suggestedName),h(t=>({...t,...e.config})),y(null)};return _(s,{className:`p-4 space-y-4`,children:[_(`div`,{className:`flex items-center justify-between`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[w(q,{kind:e,imgClassName:`h-5 w-5 object-contain`,fallbackClassName:`text-lg`}),n?`Edit ${n.name}`:`Add ${e.label} target`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:o,children:`Cancel`})]}),b&&w(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:b}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),w(`input`,{className:`w-full rounded-md border border-border bg-background px-2.5 py-1.5 text-xs text-foreground focus:border-primary focus:ring-1 focus:ring-primary/30 outline-none`,value:f,onChange:e=>p(e.target.value)})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Owner`}),w(i,{value:T,options:[{value:``,label:`System (shared, admin-managed)`},...r.map(e=>({value:e.id,label:e.username}))],onChange:e=>E(e.target.value)}),w(`p`,{className:`mt-0.5 text-[10px] text-foreground-subtle`,children:`A user-owned target belongs to that user: it shows in their viewer and their own rules may deliver to it. System targets stay admin-managed.`})]}),e.supportsDiscovery&&_(`div`,{className:`space-y-2`,children:[_(t,{size:`sm`,variant:`outline`,type:`button`,disabled:D.isPending,onClick:()=>{x(null),D.mutate()},children:[D.isPending?w(I,{className:`h-3.5 w-3.5 animate-spin`}):w(ee,{className:`h-3.5 w-3.5`}),`Discover`]}),g&&g.length===0&&w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No candidates discovered.`}),g&&g.length>0&&w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:g.map((e,t)=>_(`button`,{type:`button`,onClick:()=>A(e),className:`flex w-full items-center justify-between px-3 py-1.5 text-xs hover:bg-surface-hover`,children:[w(`span`,{className:`text-foreground`,children:e.suggestedName}),w(`span`,{className:`text-[10px] text-primary`,children:`use`})]},`${e.suggestedName}-${t}`))})]}),u.length>0&&n&&w(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Secret fields are hidden. Leave them blank to keep the stored value; type a new value to replace it.`}),w(c,{schema:e.configSchema,values:m,onChange:h}),_(`div`,{className:`flex justify-end gap-2`,children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:o,children:`Cancel`}),_(t,{size:`sm`,type:`button`,disabled:O.isPending||f.trim().length===0,onClick:()=>{x(null),O.mutate()},children:[O.isPending&&w(I,{className:`h-3.5 w-3.5 animate-spin`}),n?`Save changes`:`Create target`]})]})]})}var J=[{value:`immediate`,label:`Immediate`,hint:`Fires on the first matching detection of a track (lowest latency).`},{value:`track-end`,label:`Track end`,hint:`Evaluates the finalised track record when it closes.`},{value:`device-event`,label:`Device event`,hint:`Doorbell press / sensor state change on a linked device.`},{value:`package-event`,label:`Package event`,hint:`A parcel delivery or pick-up.`}];function Ne(e){return J.find(t=>t.value===e)?.label??e}function Pe(e){return J.find(t=>t.value===e)?.value}var Y=[{value:`best`,label:`Best available image`,description:`The best subject crop available when the notification is sent.`},{value:`best-matching`,label:`Best matching image`,description:`The image that explains why the rule fired — the face crop for an identity rule, the plate crop for a plate rule; falls back to the best image otherwise.`},{value:`keyFrame`,label:`Key frame`,description:`The clean full scene frame with no subject box.`},{value:`none`,label:`No attachment`,description:`Send the notification with no image.`}];function Fe(e){return Y.find(t=>t.value===e)?.value}var Ie=[{value:``,label:`Automatic`},{value:`cropped`,label:`Cropped on the subject`},{value:`full`,label:`Full frame`},{value:`boxed`,label:`Full frame with boxes`}];function Le(e){let t=Ie.find(t=>t.value===e)?.value;return t===``?void 0:t}var Re=[{value:``,label:`Lowest available`},{value:`low`,label:`Low`},{value:`mid`,label:`Medium`},{value:`high`,label:`High`}];function ze(e){let t=Re.find(t=>t.value===e)?.value;return t===``?void 0:t}var Be=[{value:`any`,label:`Any source`},{value:`pipeline`,label:`Pipeline`},{value:`onboard`,label:`Onboard (camera)`},{value:`sensor`,label:`Sensor`}],Ve=[{value:`delivered`,label:`Delivered`},{value:`picked-up`,label:`Picked up`},{value:`both`,label:`Both`}],He=[{value:`any`,label:`Any of`},{value:`all`,label:`All of`}],Ue=[{value:1,label:`1 — Min`},{value:2,label:`2 — Low`},{value:3,label:`3 — Default`},{value:4,label:`4 — High`},{value:5,label:`5 — Max`}];function We(){return{name:``,enabled:!0,delivery:`immediate`,targetIds:[],targetUsers:[],targetParams:{},priority:3,mediaAttach:`best`,mediaZoneCrop:!1,mediaFrame:void 0,mediaGif:!1,mediaClip:!1,mediaProfile:void 0,templateTitle:``,templateBody:``,conditions:{},schedule:void 0}}function Ge(e){let t={};for(let n of e.targets)n.params&&Object.keys(n.params).length>0&&(t[n.targetId]=n.params);return{name:e.name,enabled:e.enabled,delivery:e.delivery,targetIds:e.targets.map(e=>e.targetId),targetUsers:e.targetUsers??[],targetParams:t,priority:e.priority,mediaAttach:e.media.attach,mediaZoneCrop:e.media.zoneCrop===!0,mediaFrame:e.media.frame,mediaGif:e.media.gif===!0,mediaClip:e.media.clip===!0,mediaProfile:e.media.profile,templateTitle:e.template?.title??``,templateBody:e.template?.body??``,conditions:e.conditions,schedule:e.schedule}}function Ke(e){return e.name.trim().length>0&&(e.targetIds.length>0||e.targetUsers.length>0)}function X(e,t){return e.appliesTo.includes(t)}function qe(e){if(e==null)return!0;if(Array.isArray(e))return e.length===0;if(typeof e==`string`)return e.length===0||e===`any`;if(typeof e==`number`)return!Number.isFinite(e);if(typeof e==`object`){if(`ids`in e){let t=e.ids;return!Array.isArray(t)||t.length===0}if(`values`in e){let t=e.values;return!Array.isArray(t)||t.length===0}return!1}return!1}function Je(e,t,n){let r=n.length===0?null:new Set(n.filter(e=>e.id!==`schedule`&&X(e,t)).map(e=>e.id)),i={};for(let[t,n]of Object.entries(e))r!==null&&!r.has(t)||qe(n)||(i[t]=n);return i}function Ye(e){return e!==void 0&&e.windows.length>0}function Xe(e,t,n=[]){let r=e.templateTitle.trim(),i=e.templateBody.trim(),a=r.length>0||i.length>0?{...r.length>0?{title:r}:{},...i.length>0?{body:i}:{}}:void 0,o=(n.length===0||n.some(t=>t.id===`schedule`&&X(t,e.delivery)))&&Ye(e.schedule)?e.schedule:void 0;return{name:e.name.trim(),enabled:e.enabled,delivery:e.delivery,conditions:Je(e.conditions,e.delivery,n),...o?{schedule:o}:{},targets:e.targetIds.map(t=>{let n=e.targetParams[t];return n&&Object.keys(n).length>0?{targetId:t,params:n}:{targetId:t}}),...e.targetUsers.length>0?{targetUsers:[...e.targetUsers]}:{},media:{attach:e.mediaAttach,...e.mediaZoneCrop?{zoneCrop:!0}:{},...e.mediaFrame===void 0?{}:{frame:e.mediaFrame},...e.mediaGif?{gif:!0}:{},...e.mediaClip?{clip:!0}:{},...e.mediaProfile===void 0?{}:{profile:e.mediaProfile}},throttle:t?.throttle??{cooldownSec:60,scope:`rule-device`},priority:e.priority,...a?{template:a}:{}}}g();function Ze(e,t){let n=k().trpcClient,r=x({queries:e.map(e=>({queryKey:[[`nc-pickers`,`zones`],{deviceId:e}],staleTime:3e4,queryFn:async()=>({deviceId:e,zones:(await n.zones.listZones.query({deviceId:e})).map(e=>({id:e.id,name:e.name}))})}))});return v(()=>{let e=[],n=new Set;for(let i of r){if(!i.data)continue;let r=t.find(e=>e.id===i.data.deviceId)?.name;for(let t of i.data.zones)n.has(t.id)||(n.add(t.id),e.push({value:t.id,label:t.name,...r===void 0?{}:{hint:r}}))}return{options:e,loading:r.some(e=>e.isLoading)}},[r,t])}function Qe(e){let t=k().trpcClient,n=x({queries:e.map(e=>({queryKey:[[`nc-pickers`,`event-kinds`],{deviceId:e}],staleTime:6e4,queryFn:async()=>(await t.pipelineAnalytics.listEventKinds.query({deviceId:e})).map(e=>({kind:e.kind,label:e.label}))}))});return v(()=>{let e=new Map;for(let t of n)for(let n of t.data??[])e.has(n.kind)||e.set(n.kind,n.label);let t=[...e.entries()].map(([e,t])=>({value:e,label:t}));return t.sort((e,t)=>e.label.localeCompare(t.label)),{options:t,loading:n.some(e=>e.isLoading)}},[n])}function $e(){let t=e();return v(()=>({options:(t.data??[]).map(e=>({value:e.name,label:e.name})),loading:t.isLoading}),[t.data,t.isLoading])}function et(){let e=o({limit:200});return v(()=>{let t=new Set;for(let n of e.data??[])n.text.trim().length>0&&t.add(n.text);return[...t].sort()},[e.data])}function Z({options:e,value:t,onChange:n,loading:r,emptyHint:i,placeholder:a}){let[o,s]=S(``),c=v(()=>new Set(e.map(e=>e.value)),[e]),l=v(()=>new Set(t),[t]),u=t.filter(e=>!c.has(e)),d=e=>{n(l.has(e)?t.filter(t=>t!==e):[...t,e])},f=()=>{let e=o.trim();e.length===0||t.includes(e)||(n([...t,e]),s(``))};return _(`div`,{className:`mt-1 space-y-1.5`,children:[u.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:u.map(e=>_(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.length>0?w(`div`,{className:`max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:l.has(e.value),onChange:()=>d(e.value),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.label}),e.hint!==void 0&&w(`span`,{className:`text-[10px] text-foreground-subtle`,children:e.hint})]},e.value))}):w(`p`,{className:`text-[10px] text-foreground-subtle`,children:r===!0?`Loading…`:i}),w(`input`,{value:o,onChange:e=>s(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),f())},placeholder:a,className:`w-full rounded-md border border-border bg-background px-2 py-1 text-xs text-foreground placeholder:text-foreground-subtle`})]})}g();var tt=[{id:`scope`,label:`Scope`},{id:`class`,label:`Classes`},{id:`zones`,label:`Zones`},{id:`quality`,label:`Quality`},{id:`label`,label:`Identity & plates`},{id:`device`,label:`Device event`},{id:`package`,label:`Package`},{id:`occupancy`,label:`Occupancy`},{id:`schedule`,label:`Schedule`}],nt=`block text-[11px] font-medium text-foreground`,Q=`text-[10px] text-foreground-subtle mt-0.5`;function rt({catalog:e,taxonomy:t,delivery:n,conditions:r,schedule:i,cameras:a,onConditionsChange:o,onScheduleChange:s}){let c=(e,t)=>{let n={...r};t===void 0?delete n[e]:n[e]=t,o(n)},l=tt.map(t=>({...t,descriptors:e.filter(e=>e.group===t.id&&O(e.id))})).filter(e=>e.descriptors.length>0),u=tt.map(t=>({...t,descriptors:e.filter(e=>e.group===t.id&&!O(e.id))})).filter(e=>e.descriptors.length>0),[d,p]=S(()=>{if(at(r,i))return!0;try{return localStorage.getItem(it)===`1`}catch{return!1}}),m=()=>{let e=!d;p(e);try{localStorage.setItem(it,e?`1`:`0`)}catch{}},h=e=>e.map(e=>_(`div`,{className:`space-y-2.5`,children:[w(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:e.label}),e.descriptors.map(e=>{let o=X(e,n);return _(`div`,{className:o?``:`opacity-50`,"data-testid":`condition-${e.id}`,children:[_(`div`,{className:`flex items-center justify-between gap-2`,children:[w(`label`,{className:nt,children:e.label}),!o&&_(f,{variant:`default`,children:[`not for `,e.appliesTo.join(` / `)]})]}),o?w(ot,{descriptor:e,taxonomy:t,conditions:r,schedule:i,cameras:a,onFieldChange:c,onScheduleChange:s}):w(`p`,{className:Q,children:`Not evaluated for the selected trigger — switch the trigger to use it.`}),o&&e.description&&w(`p`,{className:Q,children:e.description})]},e.id)})]},e.id));return _(`div`,{className:`space-y-4`,children:[h(l),u.length>0&&w(`button`,{type:`button`,onClick:m,"data-testid":`nc-advanced-toggle`,className:`w-full rounded-md border border-border px-3 py-1.5 text-left text-[11px] font-medium text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:d?`▾ Hide advanced configurations`:`▸ Show more configurations`}),d&&h(u)]})}var it=`camstack.nc.showAdvanced`;function at(e,t){for(let[t,n]of Object.entries(e))if(!O(t)&&n!==void 0&&!(Array.isArray(n)&&n.length===0))return!0;return t!==void 0&&t.windows.length>0}function ot({descriptor:e,taxonomy:t,conditions:n,schedule:r,cameras:a,onFieldChange:o,onScheduleChange:s}){switch(e.valueType){case`deviceIdList`:return w(mt,{cameras:a,value:n.devices??[],onChange:e=>o(`devices`,e.length>0?e:void 0)});case`stringList`:{if(!ct(e.id))return null;let r=e.id;if(r===`identities`||r===`identitiesExclude`)return w(bt,{value:$(n,r),onChange:e=>o(r,e.length>0?e:void 0)});if(r===`eventTypeTokens`)return w(xt,{deviceIds:n.devices??[],value:$(n,r),onChange:e=>o(r,e.length>0?e:void 0)});let i=T(e.id,t);return i===null?w(gt,{value:$(n,r),placeholder:`Add value…`,onChange:e=>o(r,e.length>0?e:void 0)}):w(ht,{picker:i,value:$(n,r),onChange:e=>o(r,e.length>0?e:void 0)})}case`zoneIdList`:return w(yt,{deviceIds:n.devices??[],cameras:a,value:n.zonesExclude??[],onChange:e=>o(`zonesExclude`,e.length>0?e:void 0)});case`number01`:{if(!ut(e.id))return null;let t=e.id;return w(_t,{value:dt(n,t),min:0,max:1,step:.05,onChange:e=>o(t,e)})}case`number`:return w(_t,{value:n.minDwellSeconds,min:0,step:1,onChange:e=>o(`minDwellSeconds`,e)});case`sourceSelect`:return w(i,{value:n.source??`any`,options:Be.map(e=>({value:e.value,label:e.label})),onChange:e=>o(`source`,ft(e.target.value))});case`packagePhase`:return w(i,{value:n.packagePhase??``,options:[{value:``,label:`— any phase —`},...Ve.map(e=>({value:e.value,label:e.label}))],onChange:e=>o(`packagePhase`,pt(e.target.value))});case`zoneSelection`:return w(vt,{deviceIds:n.devices??[],cameras:a,value:n.zones,onChange:e=>o(`zones`,e)});case`plateMatcher`:return w(Tt,{value:n.plates,onChange:e=>o(`plates`,e)});case`occupancy`:return w(wt,{deviceIds:n.devices??[],cameras:a,taxonomy:t,value:n.occupancy,onChange:e=>o(`occupancy`,e)});case`schedule`:return w(At,{value:r,onChange:s});default:return null}}var st={classes:!0,classesExclude:!0,labelEquals:!0,identities:!0,identitiesExclude:!0,zonesExclude:!0,eventTypeTokens:!0,sensorKinds:!0};function ct(e){return Object.prototype.hasOwnProperty.call(st,e)}var lt={minConfidence:!0,minImportance:!0,minLabelConfidence:!0};function ut(e){return Object.prototype.hasOwnProperty.call(lt,e)}function $(e,t){let n=e[t];return Array.isArray(n)?n:[]}function dt(e,t){let n=e[t];return typeof n==`number`?n:void 0}function ft(e){if(e===`pipeline`||e===`onboard`||e===`sensor`||e===`any`)return e}function pt(e){return Ve.find(t=>t.value===e)?.value}function mt({cameras:e,value:t,onChange:n}){if(e.length===0)return w(`p`,{className:Q,children:`No cameras available — the rule applies to all devices.`});let r=e=>n(t.includes(e)?t.filter(t=>t!==e):[...t,e]);return w(`div`,{className:`mt-1 max-h-40 overflow-y-auto rounded-md border border-border divide-y divide-border`,children:e.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:t.includes(e.id),onChange:()=>r(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.name})]},e.id))})}function ht({picker:e,value:t,onChange:n}){let r=v(()=>E(e),[e]),i=v(()=>new Set(t),[t]),a=t.filter(e=>!r.has(e)),o=e=>{n(i.has(e)?t.filter(t=>t!==e):[...t,e])};return _(`div`,{className:`space-y-2`,children:[a.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:a.map(e=>_(`button`,{type:`button`,onClick:()=>n(t.filter(t=>t!==e)),className:`inline-flex items-center gap-1 rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,title:`Custom value — click to remove`,children:[e,` ×`]},e))}),e.groups.map(e=>_(`div`,{children:[w(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-muted mb-1`,children:e.fallbackLabel}),w(`div`,{className:`flex flex-wrap gap-1`,children:e.options.map(e=>{let t=i.has(e.value);return w(`button`,{type:`button`,"aria-pressed":t,onClick:()=>o(e.value),className:t?`rounded border border-primary bg-primary/15 px-1.5 py-0.5 text-[10px] text-foreground`:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground hover:bg-surface-hover`,children:e.label},e.value)})})]},e.key))]})}function gt({value:e,placeholder:t,onChange:n}){let[i,a]=S(``),o=()=>{let t=i.trim();if(t.length===0||e.includes(t)){a(``);return}n([...e,t]),a(``)},s=t=>n(e.filter(e=>e!==t));return _(`div`,{className:`mt-1 space-y-1.5`,children:[e.length>0&&w(`div`,{className:`flex flex-wrap gap-1`,children:e.map(e=>_(`span`,{className:`inline-flex items-center gap-1 rounded bg-surface-hover px-1.5 py-0.5 text-[11px] text-foreground`,children:[e,w(`button`,{type:`button`,onClick:()=>s(e),"aria-label":`remove ${e}`,className:`text-foreground-subtle hover:text-danger`,children:w(re,{className:`h-3 w-3`})})]},e))}),w(r,{value:i,placeholder:t,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),o())},onBlur:o})]})}function _t({value:e,min:t,max:n,step:i,onChange:a}){return _(`div`,{className:`mt-1 flex items-center gap-2`,children:[w(r,{type:`number`,value:e??``,min:t,max:n,step:i,className:`max-w-[8rem]`,onChange:e=>{let t=e.target.value;if(t===``){a(void 0);return}let n=Number(t);a(Number.isFinite(n)?n:void 0)}}),e!==void 0&&n!==void 0&&w(`input`,{type:`range`,min:t,max:n,step:i,value:e,onChange:e=>a(Number(e.target.value)),className:`flex-1 accent-primary`,"aria-label":`value`})]})}function vt({deviceIds:e,cameras:t,value:n,onChange:r}){let a=n?.ids??[],o=n?.match??`any`,s=e=>r(e.length>0?{ids:e,match:o}:void 0),c=e=>r(a.length>0?{ids:a,match:e}:void 0);return _(`div`,{className:`mt-1 space-y-1.5`,children:[w(`div`,{className:`max-w-[10rem]`,children:w(i,{value:o,options:He.map(e=>({value:e.value,label:e.label})),onChange:e=>c(e.target.value===`all`?`all`:`any`)})}),w(yt,{deviceIds:e,cameras:t,value:a,onChange:s})]})}function yt({deviceIds:e,cameras:t,value:n,onChange:r}){let{options:i,loading:a}=Ze(e,t);return w(Z,{options:i,value:n,onChange:r,loading:a,emptyHint:e.length===0?`Select cameras above to pick their zones by name — or type a zone id.`:`The selected cameras have no zones — type a zone id if you know one.`,placeholder:`Zone id…`})}function bt({value:e,onChange:t}){let{options:n,loading:r}=$e();return w(Z,{options:n,value:e,onChange:t,loading:r,emptyHint:`No identities in the face gallery yet — type a name.`,placeholder:`Identity name…`})}function xt({deviceIds:e,value:t,onChange:n}){let{options:r,loading:i}=Qe(e);return w(Z,{options:r,value:t,onChange:n,loading:i,emptyHint:e.length===0?`Select cameras above to pick their event kinds — or type a token.`:`No event kinds reported for the selected cameras — type a token.`,placeholder:`Event token…`})}var St=[{value:`became-occupied`,label:`Became occupied`},{value:`became-free`,label:`Became free`},{value:`>=`,label:`Count ≥`},{value:`<=`,label:`Count ≤`}],Ct={op:`became-occupied`,count:1,sustainSeconds:15};function wt({deviceIds:e,cameras:t,taxonomy:n,value:a,onChange:o}){let{options:s,loading:c}=Ze(e,t),l=v(()=>{let e=T(`classes`,n);return e===null?[]:[...E(e)]},[n]),u=a??Ct,d=e=>o({...u,...e}),f=u.op===`became-occupied`||u.op===`became-free`;return _(`div`,{className:`mt-1 space-y-1.5`,children:[_(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[w(`div`,{className:`min-w-[10rem]`,children:w(i,{value:u.zoneId??``,options:[{value:``,label:c?`Loading zones…`:`— whole frame —`},...s.map(e=>({value:e.value,label:e.label}))],onChange:e=>d({zoneId:e.target.value===``?void 0:e.target.value})})}),w(`div`,{className:`min-w-[9rem]`,children:w(i,{value:u.className??``,options:[{value:``,label:`— any class —`},...l.map(e=>({value:e,label:e}))],onChange:e=>d({className:e.target.value===``?void 0:e.target.value})})}),w(`div`,{className:`min-w-[9rem]`,children:w(i,{value:u.op,options:St.map(e=>({value:e.value,label:e.label})),onChange:e=>{let t=St.find(t=>t.value===e.target.value);t&&d({op:t.value})}})})]}),_(`div`,{className:`flex flex-wrap items-center gap-3 text-xs text-foreground-subtle`,children:[_(`label`,{className:`flex items-center gap-1`,children:[f?`Threshold`:`Count`,w(r,{type:`number`,min:0,className:`w-16`,value:String(u.count),onChange:e=>d({count:Math.max(0,Number(e.target.value)||0)})})]}),_(`label`,{className:`flex items-center gap-1`,children:[`Hold for`,w(r,{type:`number`,min:0,max:3600,className:`w-16`,value:String(u.sustainSeconds),onChange:e=>d({sustainSeconds:Math.min(3600,Math.max(0,Number(e.target.value)||0))})}),`s`]}),a===void 0?null:w(`button`,{type:`button`,onClick:()=>o(void 0),className:`underline hover:text-foreground`,children:`Clear`})]}),w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`Counts confirmed tracked objects from zone analytics. The change must hold for the sustain window before it fires; with no snapshot for the camera or zone the rule never fires.`})]})}function Tt({value:e,onChange:t}){let n=e?.values??[],i=e?.maxDistance??1,a=e=>t(e.length>0?{values:e,maxDistance:i}:void 0),o=e=>t(n.length>0?{values:n,maxDistance:e}:void 0),s=et().filter(e=>!n.includes(e));return _(`div`,{className:`mt-1 space-y-1.5`,children:[w(gt,{value:n,placeholder:`Plate text…`,onChange:a}),s.length>0&&_(`div`,{className:`flex flex-wrap items-center gap-1`,children:[w(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Seen:`}),s.slice(0,12).map(e=>w(`button`,{type:`button`,onClick:()=>a([...n,e]),className:`rounded border border-border px-1.5 py-0.5 text-[10px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:e},e))]}),_(`label`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[`Max distance`,w(r,{type:`number`,min:0,max:3,step:1,value:i,className:`max-w-[5rem]`,onChange:e=>{let t=Number(e.target.value);o(Number.isFinite(t)?Math.max(0,Math.min(3,t)):1)}})]})]})}var Et=[{value:1,label:`Mon`},{value:2,label:`Tue`},{value:3,label:`Wed`},{value:4,label:`Thu`},{value:5,label:`Fri`},{value:6,label:`Sat`},{value:0,label:`Sun`}];function Dt(e){let t=Math.floor(e/60),n=e%60;return`${String(t).padStart(2,`0`)}:${String(n).padStart(2,`0`)}`}function Ot(e){let[t,n]=e.split(`:`),r=Number(t)*60+Number(n);return Number.isFinite(r)?Math.max(0,Math.min(1439,r)):0}function kt(){return{days:[1,2,3,4,5],startMinute:540,endMinute:1080}}function At({value:e,onChange:t}){let n=e?.windows??[],r=e?.invert??!1,i=(n,r)=>{if(n.length===0){t(void 0);return}t({windows:n,...r?{invert:!0}:{},...e?.timezone?{timezone:e.timezone}:{}})},a=()=>i([...n,kt()],r),o=e=>i(n.filter((t,n)=>n!==e),r),s=(e,t)=>i(n.map((n,r)=>r===e?t:n),r);return _(`div`,{className:`mt-1 space-y-2`,children:[n.length===0?w(`p`,{className:Q,children:`Always active — add a window to restrict when the rule fires.`}):n.map((e,t)=>w(jt,{window:e,onChange:e=>s(t,e),onRemove:()=>o(t)},t)),_(`div`,{className:`flex items-center gap-3`,children:[_(`button`,{type:`button`,onClick:a,className:`flex items-center gap-1 rounded-md bg-surface-hover px-2 py-1 text-[11px] text-foreground-subtle hover:text-foreground`,children:[w(N,{className:`h-3 w-3`}),` Add window`]}),n.length>0&&_(`label`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[w(`input`,{type:`checkbox`,checked:r,onChange:e=>i([...n],e.target.checked),className:`accent-primary`}),`Active outside the windows`]})]})]})}function jt({window:e,onChange:t,onRemove:n}){let r=n=>{let r=e.days.includes(n)?e.days.filter(e=>e!==n):[...e.days,n];r.length!==0&&t({...e,days:r})};return _(`div`,{className:`space-y-1.5 rounded-md border border-border p-2`,children:[_(`div`,{className:`flex items-center gap-2 text-xs`,children:[w(`input`,{type:`time`,value:Dt(e.startMinute),onChange:n=>t({...e,startMinute:Ot(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),w(`span`,{className:`text-foreground-subtle`,children:`→`}),w(`input`,{type:`time`,value:Dt(e.endMinute),onChange:n=>t({...e,endMinute:Ot(n.target.value)}),className:`rounded-md border border-border bg-background px-1 py-0.5`}),w(`span`,{className:`flex-1`}),w(`button`,{type:`button`,onClick:n,"aria-label":`Remove window`,className:`text-foreground-subtle hover:text-danger`,children:w(R,{className:`h-3.5 w-3.5`})})]}),w(`div`,{className:`flex flex-wrap gap-1`,children:Et.map(t=>w(`button`,{type:`button`,onClick:()=>r(t.value),className:`rounded px-1.5 py-0.5 text-[10px] ${e.days.includes(t.value)?`bg-primary text-primary-foreground`:`bg-surface-hover text-foreground-subtle`}`,children:t.label},t.value))})]})}g();var Mt=[`notificationRules`,`listRules`],Nt=[`notificationOutput`,`listTargets`,`forRules`],Pt=[`notificationRules`,`getConditionCatalog`],Ft=[`deviceManager`,`listAll`,`forRules`];function It(){let e=k(),[n,r]=S({mode:`closed`}),[i,o]=S(null),c=y({queryKey:Mt,queryFn:async()=>(await e.trpcClient.notificationRules.listRules.query({})).rules}),l=y({queryKey:Nt,queryFn:()=>e.trpcClient.notificationOutput.listTargets.query({})}),u=y({queryKey:Pt,queryFn:()=>e.trpcClient.notificationRules.getConditionCatalog.query({})}),d=y({queryKey:Ft,queryFn:async()=>(await e.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===D.Camera).map(e=>({id:e.id,name:e.name}))}),f=v(()=>{let e=new Map;for(let t of l.data??[])e.set(t.id,t.name);return e},[l.data]),m=C({mutationFn:t=>e.trpcClient.notificationRules.setRuleEnabled.mutate(t),onSuccess:()=>void c.refetch()}),h=C({mutationFn:t=>e.trpcClient.notificationRules.deleteRule.mutate({ruleId:t}),onSuccess:()=>{o(null),c.refetch()}}),g=c.data??[];return _(z,{icon:B,title:`Notification Rules`,subtitle:`Author rules that turn detections, doorbell presses and package events into notifications. Each rule picks a trigger, matches conditions and fans out to one or more delivery targets.`,actions:_(t,{size:`sm`,type:`button`,onClick:()=>r({mode:`form`,rule:null}),children:[w(N,{className:`h-3.5 w-3.5`}),`New rule`]}),children:[c.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(I,{className:`h-6 w-6 animate-spin text-primary`})}),c.isError&&!c.isLoading&&w(a,{title:`Failed to load rules`,message:c.error instanceof Error?c.error.message:`Unknown error`,onRetry:()=>void c.refetch()}),!c.isLoading&&!c.isError&&g.length===0&&w(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:`No notification rules yet. Click "New rule" to author one.`}),g.length>0&&w(s,{children:w(p,{columns:Lt({targetNameById:f,confirmDeleteId:i,deletePending:h.isPending,onToggle:(e,t)=>m.mutate({ruleId:e.id,enabled:t}),onEdit:e=>r({mode:`form`,rule:e}),onDuplicate:e=>r({mode:`form`,rule:{...e,id:``,name:`${e.name} (copy)`}}),onAskDelete:o,onConfirmDelete:e=>h.mutate(e.id)}),rows:g,rowKey:e=>e.id,minWidthPx:760,bordered:!1})}),n.mode===`form`&&w(Rt,{rule:n.rule,targets:l.data??[],catalog:u.data?.catalog??[],taxonomy:u.data?.taxonomy,cameras:d.data??[],onCancel:()=>r({mode:`closed`}),onSaved:()=>{r({mode:`closed`}),c.refetch()}})]})}function Lt(e){return[{key:`name`,header:`Rule`,render:e=>_(`span`,{className:`flex items-center gap-2`,children:[w(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name}),!e.enabled&&w(f,{variant:`warning`,children:`disabled`})]})},{key:`trigger`,header:`Trigger`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:Ne(e.delivery)})},{key:`targets`,header:`Targets`,render:t=>{let n=t.targets[0],r=n?e.targetNameById.get(n.targetId)??n.targetId:null;return w(`span`,{className:`text-[11px] text-foreground-subtle`,children:t.targets.length===1&&r?r:`${t.targets.length} target${t.targets.length===1?``:`s`}`})}},{key:`priority`,header:`Priority`,align:`center`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.priority})},{key:`enabled`,header:`On`,align:`center`,nowrap:!0,render:t=>w(u,{checked:t.enabled,onCheckedChange:n=>e.onToggle(t,n),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:n=>_(`span`,{className:`flex items-center justify-end gap-1`,children:[w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onEdit(n),title:`Edit`,children:w(M,{className:`h-3.5 w-3.5`})}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDuplicate(n),title:`Duplicate`,children:w(j,{className:`h-3.5 w-3.5`})}),e.confirmDeleteId===n.id?_(b,{children:[_(t,{size:`sm`,variant:`danger`,type:`button`,disabled:e.deletePending,onClick:()=>e.onConfirmDelete(n),children:[e.deletePending&&w(I,{className:`h-3.5 w-3.5 animate-spin`}),`Confirm`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onAskDelete(null),children:`Cancel`})]}):w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onAskDelete(n.id),title:`Delete`,children:w(R,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Rt({rule:e,targets:n,catalog:a,taxonomy:o,cameras:s,onSaved:c,onCancel:l}){let p=k(),m=e!=null&&e.id.length>0,[g,v]=S(()=>e?Ge(e):We()),[b,x]=S(null),[T,E]=S(null),D=e=>v(t=>({...t,...e})),O=m&&e?{throttle:e.throttle}:void 0,A=C({mutationFn:async()=>{let t=Xe(g,O,a);m&&e?await p.trpcClient.notificationRules.updateRule.mutate({ruleId:e.id,patch:t}):await p.trpcClient.notificationRules.createRule.mutate({rule:t})},onSuccess:c,onError:e=>x(e instanceof Error?e.message:`Save failed`)}),j=C({mutationFn:async()=>{let e=Xe(g,O,a);return(await p.trpcClient.notificationRules.testRule.mutate({rule:e,lookbackMinutes:60})).results},onMutate:()=>E(null),onSuccess:e=>E(e),onError:e=>x(e instanceof Error?e.message:`Test failed`)}),M=g.targetIds.map(e=>n.find(t=>t.id===e)?.name??e),N=e=>D({targetIds:g.targetIds.includes(e)?g.targetIds.filter(t=>t!==e):[...g.targetIds,e]}),P=y({queryKey:[`userManagement`,`listUsers`],queryFn:()=>p.trpcClient.userManagement.listUsers.query()}).data,ee=e=>D({targetUsers:g.targetUsers.includes(e)?g.targetUsers.filter(t=>t!==e):[...g.targetUsers,e]}),F=J.find(e=>e.value===g.delivery)?.hint;return w(h,{open:!0,onOpenChange:e=>!e&&l(),children:_(d,{width:`lg`,placement:`sheet-on-mobile`,children:[_(`div`,{className:`flex items-center justify-between mb-3`,children:[_(`h3`,{className:`text-sm font-semibold text-foreground flex items-center gap-2`,children:[w(B,{className:`h-4 w-4 text-foreground-subtle`}),m?`Edit ${e?.name}`:`New notification rule`]}),w(t,{size:`sm`,variant:`ghost`,type:`button`,onClick:l,children:`Cancel`})]}),b&&w(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger mb-3`,children:b}),_(`div`,{className:`space-y-4`,children:[_(`div`,{className:`flex items-end gap-3`,children:[_(`div`,{className:`min-w-0 flex-1`,children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Name`}),w(r,{value:g.name,onChange:e=>D({name:e.target.value}),placeholder:`e.g. Front door package`})]}),_(`label`,{className:`flex items-center gap-2 pb-1.5 text-[11px] font-medium text-foreground`,children:[w(u,{checked:g.enabled,onCheckedChange:e=>D({enabled:e}),"aria-label":`enabled`}),`Enabled`]})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Trigger`}),w(i,{value:g.delivery,onChange:e=>{let t=Pe(e.target.value);t&&D({delivery:t})},options:J.map(e=>({value:e.value,label:e.label}))}),F&&w(`p`,{className:`text-[10px] text-foreground-subtle mt-1`,children:F})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Delivery targets`}),n.length===0?w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No delivery targets configured. Add one under the Targets tab first.`}):w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:n.map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:g.targetIds.includes(e.id),onChange:()=>N(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.name}),!e.enabled&&w(f,{variant:`warning`,children:`disabled`})]},e.id))})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notify users`}),(P??[]).length===0?w(`p`,{className:`text-[11px] text-foreground-subtle`,children:`No users to notify.`}):w(`div`,{className:`rounded-md border border-border divide-y divide-border`,children:(P??[]).map(e=>_(`label`,{className:`flex items-center gap-2.5 px-3 py-1.5 text-xs text-foreground cursor-pointer hover:bg-surface-hover`,children:[w(`input`,{type:`checkbox`,checked:g.targetUsers.includes(e.id),onChange:()=>ee(e.id),className:`accent-primary`}),w(`span`,{className:`flex-1 truncate`,children:e.username}),e.isAdmin&&w(f,{variant:`info`,children:`admin`})]},e.id))}),w(`p`,{className:`text-[10px] text-foreground-subtle mt-1`,children:`Delivers to the targets each user owns, only for cameras that user can access.`})]}),_(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:[_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Priority`}),w(i,{value:String(g.priority),onChange:e=>D({priority:Number(e.target.value)}),options:Ue.map(e=>({value:String(e.value),label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Media attachment`}),w(i,{value:g.mediaAttach,onChange:e=>{let t=Fe(e.target.value);t&&D({mediaAttach:t})},options:Y.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:Y.find(e=>e.value===g.mediaAttach)?.description}),_(`div`,{className:`mt-2 space-y-1`,children:[_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaZoneCrop,onChange:e=>D({mediaZoneCrop:e.target.checked}),className:`accent-primary`}),`Crop the image to the rule's zone`]}),_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaGif,onChange:e=>D({mediaGif:e.target.checked}),className:`accent-primary`}),`Attach a GIF around the event`]}),_(`label`,{className:`flex items-center gap-2 text-xs text-foreground cursor-pointer`,children:[w(`input`,{type:`checkbox`,checked:g.mediaClip,onChange:e=>D({mediaClip:e.target.checked}),className:`accent-primary`}),`Attach an MP4 clip around the event`]})]}),(g.mediaGif||g.mediaClip)&&_(`div`,{className:`mt-2`,children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Video quality`}),w(i,{value:g.mediaProfile??``,onChange:e=>D({mediaProfile:ze(e.target.value)}),options:Re.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`A notification is watched on a phone — the cheapest stream is normally the right one, and the high profile only costs CPU to render.`})]})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Image frame`}),w(i,{value:g.mediaFrame??``,onChange:e=>D({mediaFrame:Le(e.target.value)}),options:Ie.map(e=>({value:e.value,label:e.label}))}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`What the attached still shows. "Automatic" leaves it to the attachment mode above.`})]})]}),_(`div`,{className:`space-y-2`,children:[_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification title`}),w(r,{value:g.templateTitle,onChange:e=>D({templateTitle:e.target.value}),placeholder:`{{camera}} — {{class}}`})]}),_(`div`,{children:[w(`label`,{className:`block text-[11px] font-medium text-foreground mb-1`,children:`Notification body`}),w(`textarea`,{value:g.templateBody,onChange:e=>D({templateBody:e.target.value}),rows:2,placeholder:`{{label}} seen in {{zone}} at {{time}}`,className:`w-full rounded-md border border-border bg-surface px-2.5 py-1.5 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary`})]}),_(`p`,{className:`text-[10px] text-foreground-subtle`,children:[`Leave blank to use the backend default text. Supported variables include`,` `,w(`code`,{children:`{{camera}}`}),`, `,w(`code`,{children:`{{class}}`}),`, `,w(`code`,{children:`{{label}}`}),`,`,` `,w(`code`,{children:`{{zone}}`}),`, `,w(`code`,{children:`{{confidence}}`}),`, `,w(`code`,{children:`{{time}}`}),`.`]})]}),_(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[w(`div`,{className:`mb-2 text-[11px] font-semibold text-foreground`,children:`Conditions`}),a.length===0?w(`p`,{className:`text-[10px] text-foreground-subtle`,children:`Condition catalog unavailable — this rule matches on its trigger and targets alone.`}):w(rt,{catalog:a,taxonomy:o,delivery:g.delivery,conditions:g.conditions,schedule:g.schedule,cameras:s,onConditionsChange:e=>D({conditions:e}),onScheduleChange:e=>D({schedule:e})})]}),_(`div`,{className:`rounded-md border border-border px-3 py-3`,children:[_(`div`,{className:`flex items-center justify-between gap-2`,children:[w(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Test rule`}),_(t,{size:`sm`,variant:`outline`,type:`button`,disabled:j.isPending||!Ke(g),onClick:()=>{x(null),j.mutate()},children:[j.isPending?w(I,{className:`h-3.5 w-3.5 animate-spin`}):w(ae,{className:`h-3.5 w-3.5`}),`Dry-run (last 60 min)`]})]}),w(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`Evaluate the CURRENT (unsaved) rule against recently persisted records — no notification is sent.`}),T!==null&&w(zt,{delivery:g.delivery,results:T,targetNames:M})]})]}),_(`div`,{className:`flex justify-end gap-2 mt-4`,children:[w(t,{variant:`secondary`,size:`sm`,type:`button`,onClick:l,children:`Cancel`}),_(t,{size:`sm`,type:`button`,disabled:A.isPending||!Ke(g),onClick:()=>{x(null),A.mutate()},children:[A.isPending&&w(I,{className:`h-3.5 w-3.5 animate-spin`}),m?`Save changes`:`Create rule`]})]})]})})}function zt({delivery:e,results:t,targetNames:n}){if(e===`device-event`)return w(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`Device-event rules cannot be dry-run: the sensor-event store has no cross-device scan surface, so a test returns no candidate records. The rule still fires live on a matching doorbell press / sensor change.`});if(t.length===0)return w(`p`,{className:`mt-2 text-[11px] text-foreground-subtle`,children:`No records in the last 60 minutes matched — nothing to evaluate.`});let r=t.filter(e=>e.wouldFire).length;return _(`div`,{className:`mt-2 space-y-1.5`,children:[_(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r,` of `,t.length,` evaluated record`,t.length===1?``:`s`,` would fire.`]}),w(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.slice(0,50).map(e=>_(`li`,{className:`flex items-center gap-2 px-2.5 py-1.5 text-[11px]`,children:[e.wouldFire?w(A,{className:`h-3.5 w-3.5 shrink-0 text-success`}):w(te,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),w(`span`,{className:`w-32 shrink-0 text-foreground-subtle`,children:new Date(e.timestamp).toLocaleString()}),_(`span`,{className:`w-14 shrink-0 text-foreground-subtle`,children:[`#`,e.deviceId]}),w(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.label??e.className??`object`}),e.wouldFire?_(`span`,{className:`shrink-0 truncate text-success`,children:[`→ `,n.join(`, `)||`targets`]}):e.failedCondition&&_(`span`,{className:`shrink-0 text-foreground-subtle`,children:[`failed: `,e.failedCondition]})]},e.recordId))})]})}g();var Bt=[{value:1,label:`Last hour`},{value:24,label:`Last 24 hours`},{value:168,label:`Last 7 days`},{value:0,label:`All time`}],Vt=[{value:``,label:`Any status`},{value:`pending`,label:`Pending`},{value:`sent`,label:`Sent`},{value:`dead`,label:`Dead`}],Ht=[50,100,250,500];function Ut(){return{ruleId:``,deviceId:``,status:``,windowHours:24,limit:100}}function Wt(e){return e===`pending`||e===`sent`||e===`dead`?e:void 0}function Gt(e){switch(e){case`pending`:return`info`;case`sent`:return`success`;case`dead`:return`danger`}}function Kt(){let e=k(),[t,n]=S(Ut),r=e=>n(t=>({...t,...e})),a=y({queryKey:[`notificationRules`,`listRules`,`forHistory`],queryFn:async()=>(await e.trpcClient.notificationRules.listRules.query({})).rules}),o=y({queryKey:[`deviceManager`,`listAll`,`forHistory`],queryFn:async()=>(await e.trpcClient.deviceManager.listAll.query({})).filter(e=>e.type===D.Camera).map(e=>({id:e.id,name:e.name}))}),c=Date.now(),l=y({queryKey:[`notificationRules`,`getHistory`,t],retry:!1,queryFn:async()=>{let n=t.windowHours>0?c-t.windowHours*36e5:void 0;return(await e.trpcClient.notificationRules.getHistory.query({filter:{limit:t.limit,...t.ruleId?{ruleId:t.ruleId}:{},...t.deviceId?{deviceId:Number(t.deviceId)}:{},...Wt(t.status)?{status:Wt(t.status)}:{},...n===void 0?{}:{since:n}}})).entries}}),u=v(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),d=e=>u.get(e)??`Camera #${String(e)}`,f=l.data??[],m=l.isError;return _(z,{icon:oe,title:`Delivery history`,subtitle:`A searchable log of every notification the rules delivered (or failed to deliver).`,children:[_(`div`,{className:`mb-4 grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Rule`}),w(i,{value:t.ruleId,onChange:e=>r({ruleId:e.target.value}),options:[{value:``,label:`All rules`},...(a.data??[]).map(e=>({value:e.id,label:e.name}))]})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Camera`}),w(i,{value:t.deviceId,onChange:e=>r({deviceId:e.target.value}),options:[{value:``,label:`All cameras`},...(o.data??[]).map(e=>({value:String(e.id),label:e.name}))]})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Status`}),w(i,{value:t.status,onChange:e=>r({status:e.target.value}),options:Vt.map(e=>({value:e.value,label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Window`}),w(i,{value:String(t.windowHours),onChange:e=>r({windowHours:Number(e.target.value)}),options:Bt.map(e=>({value:String(e.value),label:e.label}))})]}),_(`div`,{children:[w(`label`,{className:`mb-1 block text-[10px] font-medium text-foreground-subtle`,children:`Limit`}),w(i,{value:String(t.limit),onChange:e=>r({limit:Number(e.target.value)}),options:Ht.map(e=>({value:String(e),label:String(e)}))})]})]}),l.isLoading&&w(`div`,{className:`flex items-center justify-center py-16`,children:w(I,{className:`h-6 w-6 animate-spin text-primary`})}),m&&!l.isLoading&&w(s,{children:_(`div`,{className:`flex flex-col items-center gap-2 px-4 py-14 text-center`,children:[w(oe,{className:`h-6 w-6 text-foreground-subtle`}),w(`div`,{className:`text-sm font-medium text-foreground`,children:`Delivery history requires a server update`}),w(`p`,{className:`max-w-md text-xs text-foreground-subtle`,children:`The history query is not available on this hub yet. It becomes queryable after the next server update ships the notification-center history endpoint. Rules still deliver and record their outcome in the meantime.`}),_(`button`,{type:`button`,onClick:()=>void l.refetch(),className:`mt-1 inline-flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1 text-[11px] text-foreground-subtle hover:bg-surface-hover hover:text-foreground`,children:[w(P,{className:`h-3 w-3`}),` Retry`]})]})}),!m&&!l.isLoading&&f.length===0&&w(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:`No deliveries match these filters.`}),!m&&f.length>0&&w(s,{children:w(p,{columns:qt(d),rows:f,rowKey:e=>e.id,minWidthPx:720,bordered:!1})})]})}function qt(e){return[{key:`when`,header:`When`,nowrap:!0,render:e=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:new Date(e.createdAt).toLocaleString()})},{key:`rule`,header:`Rule`,render:e=>w(`span`,{className:`text-xs font-medium text-foreground`,children:e.ruleName})},{key:`camera`,header:`Camera`,nowrap:!0,render:t=>w(`span`,{className:`text-[11px] text-foreground-subtle`,children:e(t.deviceId)})},{key:`subject`,header:`Subject`,render:e=>_(`span`,{className:`text-[11px] text-foreground-subtle`,children:[e.subject.label??e.subject.className,e.subject.confidence===void 0?``:` · ${Math.round(e.subject.confidence*100)}%`]})},{key:`status`,header:`Status`,nowrap:!0,render:e=>_(`span`,{className:`flex items-center gap-1.5`,children:[w(f,{variant:Gt(e.status),children:e.status}),e.attempts>1?_(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`×`,e.attempts]}):null]})},{key:`error`,header:`Detail`,render:e=>e.error?w(`span`,{className:`text-[11px] text-danger`,children:e.error}):w(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})}]}function Jt(){return w(`div`,{className:`flex flex-col p-4`,children:w(ie,{tabs:[{id:`targets`,label:`Targets`,icon:ne,content:w(Ae,{})},{id:`rules`,label:`Rules`,icon:B,content:w(It,{})},{id:`history`,label:`History`,icon:oe,content:w(Kt,{})}]})})}export{Jt as NotificationsPage,Jt as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DUFmNDGR.js";var t=e(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]);export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{W as e}from"./index-DUFmNDGR.js";var t=e(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`polyline`,{points:`12 6 12 12 16 14`,key:`68esgv`}]]);export{t};
|