@camstack/addon-admin-ui 1.2.491 → 1.2.492
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/{AddonAssetIcon-C-W05jOS.js → AddonAssetIcon-DPfW-s0a.js} +1 -1
- package/dist/assets/Addons-gtliNZKC.js +5 -0
- package/dist/assets/{AdminPage-Dy-fEJbf.js → AdminPage-BdEQCHFs.js} +1 -1
- package/dist/assets/{AdminSectionedPage-CLYqZKQj.js → AdminSectionedPage-7l_b_UM1.js} +1 -1
- package/dist/assets/AiProfiles-DiN_iC0i.js +3 -0
- package/dist/assets/{BrokerEditorDialog-BfNVIR0c.js → BrokerEditorDialog-DpESkmwf.js} +1 -1
- package/dist/assets/Build-B7gqcqjg.js +40 -0
- package/dist/assets/{Calendars-CJ9P43Kk.js → Calendars-B9HfY7pV.js} +1 -1
- package/dist/assets/Cluster-Uz6OqlVa.js +1 -0
- package/dist/assets/{CompositionBlockEditor-CosgjAjy.js → CompositionBlockEditor-CmDkv2bG.js} +1 -1
- package/dist/assets/{CompositionEditorPage-CJx0RCW8.js → CompositionEditorPage-C5eZuMFZ.js} +1 -1
- package/dist/assets/Data-C9kIrnCS.js +2 -0
- package/dist/assets/DeviceDetail-DbYvDHGL.js +2 -0
- package/dist/assets/{DeviceDoActionFields-Bb2ej2cH.js → DeviceDoActionFields-BQBSfHSr.js} +1 -1
- package/dist/assets/{Devices-BF4EQ5d8.js → Devices-BaRmnv1a.js} +1 -1
- package/dist/assets/{EmbedPlayerPage-evY5cBae.js → EmbedPlayerPage-D_5IGoVF.js} +1 -1
- package/dist/assets/HelperWizard-3t0KSEHM.js +2 -0
- package/dist/assets/History-CSkUfCQp.js +1 -0
- package/dist/assets/Identity-DzkRf83p.js +1 -0
- package/dist/assets/IntegrationDetail-BuQFUn72.js +1 -0
- package/dist/assets/IntegrationHub-cZVxvlwv.js +1 -0
- package/dist/assets/Integrations--EaU9bdJ.js +1 -0
- package/dist/assets/Integrations-DeS_5dJb.js +1 -0
- package/dist/assets/Library-sgObS0IL.js +1 -0
- package/dist/assets/Locations-DrOt7YT5.js +3 -0
- package/dist/assets/{Logs-DWUljlNw.js → Logs-DCL8j2dX.js} +1 -1
- package/dist/assets/{MaskShapeCanvas-BvI_4dLm.js → MaskShapeCanvas-CEO3VTVU.js} +1 -1
- package/dist/assets/{MotionZonesSettings-BvSmNtWZ.js → MotionZonesSettings-Dxe-b_w-.js} +1 -1
- package/dist/assets/{MyAccess-DyOUww3e.js → MyAccess-CGPcoa0o.js} +1 -1
- package/dist/assets/Network-CVqG_YWz.js +1 -0
- package/dist/assets/{NodeAddonsSettingsPanel-TyErVJaa.js → NodeAddonsSettingsPanel-BDdBjBR6.js} +1 -1
- package/dist/assets/Notifications-aQWpR38O.js +1 -0
- package/dist/assets/Pipeline-S9l6g7rC.js +1 -0
- package/dist/assets/{PrivacyMaskSettings-BBpPNBYz.js → PrivacyMaskSettings--AmTjVWH.js} +1 -1
- package/dist/assets/Recordings-BUt6suUH.js +1 -0
- package/dist/assets/{ScanNetworkModal-Dn_Cbh-y.js → ScanNetworkModal-BclXo106.js} +1 -1
- package/dist/assets/SceneMonitorEditor-BwCuyEh-.js +1 -0
- package/dist/assets/SessionsList-CA8CTvaN.js +2 -0
- package/dist/assets/{Showroom-Hd3Y1pZa.js → Showroom-DzExLJ-t.js} +1 -1
- package/dist/assets/System-B05hIwRj.js +1 -0
- package/dist/assets/{Terminal-DZwz7oSc.js → Terminal-DEhXvwWb.js} +3 -3
- package/dist/assets/{Viewer-Dupx7vL4.js → Viewer-wkTckbx1.js} +1 -1
- package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CWGVTk4s.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-Df7aVLZ8.js} +1 -1
- package/dist/assets/{addon-icons-context-CzTWZHSh.js → addon-icons-context-C1pY0Jxx.js} +1 -1
- package/dist/assets/{archive-COytoRbW.js → archive-BbyhgjWL.js} +1 -1
- package/dist/assets/{assignment-candidates-6WyXElcY.js → assignment-candidates-CMyWsd7o.js} +1 -1
- package/dist/assets/{authed-media-BYn8KpCA.js → authed-media-CYHzcXg2.js} +1 -1
- package/dist/assets/{bell-off-CqaftCCC.js → bell-off-BSZr41wl.js} +1 -1
- package/dist/assets/{board-model-BnBpDyVJ.js → board-model-DpCndLv1.js} +1 -1
- package/dist/assets/{boxes-DiH5aKPU.js → boxes-C9MrE-GD.js} +1 -1
- package/dist/assets/circle-slash-kaaJHDJP.js +1 -0
- package/dist/assets/{cloud-upload-CydKKaEp.js → cloud-upload-DQNky4H3.js} +1 -1
- package/dist/assets/crop-CPejcRNN.js +1 -0
- package/dist/assets/{device-integration-icon-BJlT_oa3.js → device-integration-icon-BXlumGnh.js} +1 -1
- package/dist/assets/device-picker-model-D7B8bsDV.js +1 -0
- package/dist/assets/{eraser-BvwiPI1u.js → eraser-CUFimZpD.js} +1 -1
- package/dist/assets/{format-pVRrtm44.js → format-B-2R99aG.js} +1 -1
- package/dist/assets/{hard-drive-download-qh4K1hU8.js → hard-drive-download-BObH6Vyd.js} +1 -1
- package/dist/assets/{hostInit-BSSPz1Tp.js → hostInit-JMVVBCFU.js} +1 -1
- package/dist/assets/i18n-D7mWXOH-.js +1 -0
- package/dist/assets/icons-oE92iMVl.js +1 -0
- package/dist/assets/{index-DTd1apaT.css → index-DrkhFGtr.css} +1 -1
- package/dist/assets/index-QtGtcmlM.js +4 -0
- package/dist/assets/{key-GQVUlMPP.js → key-JyYB9gnI.js} +1 -1
- package/dist/assets/{key-round-BYU9tibU.js → key-round-CBNBBS9z.js} +1 -1
- package/dist/assets/{layers-wvbWI8iv.js → layers-BSjuwfeB.js} +1 -1
- package/dist/assets/{linked-devices-model-CXZKHslN.js → linked-devices-model-Dt0g8o39.js} +1 -1
- package/dist/assets/{list-ordered-DcXCNlr1.js → list-ordered-BNIrg43G.js} +1 -1
- package/dist/assets/location-owned-usage-gqoXJMPj.js +1 -0
- package/dist/assets/{log-in-BEcXcuRp.js → log-in-CMkgyQRs.js} +1 -1
- package/dist/assets/{memory-stick-CzBkDqRK.js → memory-stick-wHF0f3FH.js} +1 -1
- package/dist/assets/{message-square-plus-DAfPpZoi.js → message-square-plus-DkMEFxkw.js} +1 -1
- package/dist/assets/{mf-entry-bootstrap-0-2a116f23.js → mf-entry-bootstrap-0-eacfb2da.js} +2 -2
- package/dist/assets/{mic-off-DJsgLuRv.js → mic-off-8IZcOYj3.js} +1 -1
- package/dist/assets/{monitor-off-BIDr69WD.js → monitor-off-CLYkAPWS.js} +1 -1
- package/dist/assets/{monitor-smartphone-0cl5JG2q.js → monitor-smartphone-BAM_Pnvy.js} +1 -1
- package/dist/assets/mount-D7B8bsDV.js +1 -0
- package/dist/assets/player-overlays-C0MwGGCz.js +1 -0
- package/dist/assets/{recycle-6xhPDDKa.js → recycle-C1WW7862.js} +1 -1
- package/dist/assets/remoteEntry-C2offcwH.js +1 -0
- package/dist/assets/{scan-eye-C_qPMtrX.js → scan-eye-Dt5KUwOk.js} +1 -1
- package/dist/assets/{scissors-5gO0XeLA.js → scissors-BDs6D_EV.js} +1 -1
- package/dist/assets/{search-x-LetCZ_ep.js → search-x-D22Vg4Xu.js} +1 -1
- package/dist/assets/{send-BfNViT0x.js → send-DdEV1Nk_.js} +1 -1
- package/dist/assets/{settings-2-T7g84dNm.js → settings-2-B7DN8MZt.js} +1 -1
- package/dist/assets/{sigma-BlXZ2aw7.js → sigma-B9KtLJQ5.js} +1 -1
- package/dist/assets/{speaker-Ca-uaBj6.js → speaker-vP0Jzm3D.js} +1 -1
- package/dist/assets/src-BLJh-44s.js +67 -0
- package/dist/assets/{step-inspector-model-CQm0mKvR.js → step-inspector-model-Ju3q4CZU.js} +1 -1
- package/dist/assets/{table-2-CxbhwUvc.js → table-2-BTRcysei.js} +1 -1
- package/dist/assets/{timer-reset-BZJJw_vy.js → timer-reset-Byxo5HZN.js} +1 -1
- package/dist/assets/{ungroup-B0PNlyKk.js → ungroup-DHuQH4zo.js} +1 -1
- package/dist/assets/{unlink-BTcNOC7C.js → unlink-CLur1WlL.js} +1 -1
- package/dist/assets/{usb-CVx1D-fe.js → usb-6aY8GAbW.js} +1 -1
- package/dist/assets/{use-scenes-feed-CyaFpfUP.js → use-scenes-feed-BKeBSQyR.js} +1 -1
- package/dist/assets/{use-stationary-objects-CE5HpIjg.js → use-stationary-objects-DqsMnj7J.js} +1 -1
- package/dist/assets/useEventInvalidation-D7B8bsDV.js +1 -0
- package/dist/assets/{useNodeUrlSelection-DzLKeuVO.js → useNodeUrlSelection-Bnfx9MW8.js} +1 -1
- package/dist/assets/user-round-Cktilqeo.js +1 -0
- package/dist/assets/{user-x-CDW03V4s.js → user-x-4Hfj3QdW.js} +1 -1
- package/dist/assets/{video-CWc9XxJk.js → video-6lAlm9YD.js} +1 -1
- package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Dq9ZgXY3.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Brtll3hk.js} +2 -2
- package/dist/index.html +9 -9
- package/dist/server/addon.js +1 -1
- package/package.json +1 -1
- package/dist/assets/Addons-DzzCgAq-.js +0 -5
- package/dist/assets/AiProfiles-CgwzlUVs.js +0 -3
- package/dist/assets/Build-CkP-FHmg.js +0 -40
- package/dist/assets/Cluster-BY0AJ7Y8.js +0 -1
- package/dist/assets/Data-B9ZuZX-A.js +0 -2
- package/dist/assets/DeviceDetail-CB185X1z.js +0 -2
- package/dist/assets/HelperWizard-CD_0QhkR.js +0 -2
- package/dist/assets/History-afx6dKjt.js +0 -1
- package/dist/assets/Identity-BrjQOQ40.js +0 -1
- package/dist/assets/IntegrationDetail-DWTyAAj6.js +0 -1
- package/dist/assets/IntegrationHub-BXbnNmwc.js +0 -1
- package/dist/assets/Integrations-B_RGvZtR.js +0 -1
- package/dist/assets/Integrations-kKJWlcWD.js +0 -1
- package/dist/assets/Library-jWD_BsMv.js +0 -1
- package/dist/assets/Locations-Da36xo8K.js +0 -3
- package/dist/assets/Network-f3eno7Nz.js +0 -1
- package/dist/assets/Notifications-Bx6F55kk.js +0 -1
- package/dist/assets/Pipeline-yNzjqrit.js +0 -1
- package/dist/assets/Recordings-Ci4LULiQ.js +0 -1
- package/dist/assets/SceneMonitorEditor-CuPQcK5y.js +0 -1
- package/dist/assets/SessionsList-DRYMTqqU.js +0 -2
- package/dist/assets/System-C4I1BL8G.js +0 -1
- package/dist/assets/circle-slash-DjmuKPXI.js +0 -1
- package/dist/assets/crop-FLPers4o.js +0 -1
- package/dist/assets/device-picker-model-GAczoeeF.js +0 -1
- package/dist/assets/i18n-CI5vBtLY.js +0 -1
- package/dist/assets/icons-wHAKhjV4.js +0 -1
- package/dist/assets/index-B5aMjANu.js +0 -4
- package/dist/assets/location-owned-usage-BP75gZgA.js +0 -1
- package/dist/assets/mount-GAczoeeF.js +0 -1
- package/dist/assets/player-overlays-DN3wN3kB.js +0 -1
- package/dist/assets/remoteEntry-CxXnwLxt.js +0 -1
- package/dist/assets/src-DaPCpXY_.js +0 -67
- package/dist/assets/useEventInvalidation-GAczoeeF.js +0 -1
- package/dist/assets/user-round-DmS1e16J.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{An as c,Ci as l,Gr as u,Pt as d,dt as f,sr as p,wn as m,xi as h,xn as g}from"./player-overlays-DN3wN3kB.js";import{Qa as _,to as v}from"./client-CoTSmvjZ.js";import{$r as y,Ao as b,Qa as x,Tr as S,do as C,lo as w,oi as T,xi as E,xo as D,xs as O,ya as k}from"./src-DaPCpXY_.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{P as j}from"./index-B5aMjANu.js";import{n as M,t as N}from"./BrokerEditorDialog-BfNVIR0c.js";o();var P={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function F({kind:t,value:n,onChange:i}){let{t:o}=A(),[s,l]=a(!1),u=k({kind:t}),d=M(u.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[u.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(p,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),u.isError&&r(S,{message:o(`brokers.picker.loadFailed`,{message:u.error instanceof Error?u.error.message:o(`common.unknownError`)})}),!u.isLoading&&!u.isError&&d.length===0&&r(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),d.map(t=>e(`button`,{type:`button`,"aria-pressed":n===t.id,onClick:()=>i(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${n===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[r(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),r(T,{variant:P[t.status],className:`text-[10px]`,children:t.status})]},t.id)),e(y,{variant:`outline`,size:`sm`,onClick:()=>l(!0),children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>l(!1),onSaved:e=>{l(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,c]=a(null);return e(`div`,{className:`space-y-4`,children:[e(y,{variant:`ghost`,size:`sm`,onClick:i,children:[r(h,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:c}),r(`div`,{className:`flex justify-end pt-1`,children:r(y,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}o();function L(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 R={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 z({addonId:t,configSchema:n,canTest:i=!0,initialName:o,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=A(),[p,m]=a(o??``),[h,g]=a(s??{}),[y,b]=a(null),x=O({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),S=E(),C=!i||y?.status===`validated`,w=!l&&p.trim().length===0,T=!w&&C;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[r(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),r(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":w,"aria-describedby":w?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${w?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),w&&r(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&r(j,{schema:n,values:h,onChange:e=>{g(e),b(null)},onAction:async(e,r,a)=>{let o=await S.mutateAsync({addonId:t,action:e,input:a??{}});if(i&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=v(n,r);g(i),b(null),x.mutate({addonId:t,settings:i})}return o}}),y&&r(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${R[y.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.`})}})(y)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`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`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>x.mutate({addonId:t,settings:v(n,h)}),disabled:x.isPending||!i,title:i?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`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[w&&r(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),r(`button`,{onClick:()=>{w||u({name:p,config:v(n,h),secretKeys:[..._(n)]})},disabled:!T,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`)})]})]})]})]})}function B(e,t){if(t.prefilledConfig.setupIntegration!==!0)return null;let n=t.prefilledConfig.host;return typeof n!=`string`||n.trim().length===0?null:{addonId:e,name:t.suggestedName,config:{host:n.trim()}}}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){if(!V(e)||!V(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!V(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;return{addonId:n,name:r,config:a}}o();function U({open:i,onClose:o,scope:s,onSetupIntegration:c}){let{t:d}=A(),h=x(),[g,_]=a(new Set),[v,y]=a(new Set),{data:b}=D({projection:`slim`}),S=t(()=>new Set((b??[]).map(e=>e.stableId)),[b]),C=n(async(e,t)=>{let n=B(e,t);if(n!==null){c?.(n),o();return}y(e=>new Set(e).add(t.stableId));try{await h.mutateAsync({addonId:e,candidate:t}),_(e=>new Set(e).add(t.stableId))}catch{}finally{y(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[h,o,c]),w=n((t,n)=>{let i=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=S.has(n.stableId),o=g.has(n.stableId)||a,s=v.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[r(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),i&&r(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:i})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[r(l,{className:`h-3.5 w-3.5`}),` `,a?d(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):d(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void C(t,n),disabled:s,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:[s?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(u,{className:`h-3.5 w-3.5`}),d(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,d]);if(!i)return null;let T=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:o}),e(`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:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(m,{className:`h-4 w-4 text-primary`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:T})]}),r(`button`,{onClick:o,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:r(f,{className:`h-4 w-4`})})]}),s?r(G,{scope:s,onAdopt:w,onReset:()=>_(new Set)}):r(W,{onAdopt:w,onReset:()=>_(new Set)})]})]})}function W({onAdopt:a,onReset:o}){let{t:c}=A(),l=w(),u=n(()=>{o(),l.mutate({})},[l,o]);i(()=>{!l.isPending&&!l.data&&u()},[]);let d=t(()=>(l.data?.groups??[]).filter(e=>e.candidates.length>0),[l.data]),f=t(()=>d.reduce((e,t)=>e+t.candidates.length,0),[d]);return e(s,{children:[r(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:u,disabled:l.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:[r(g,{className:`h-3.5 w-3.5 ${l.isPending?`animate-spin`:``}`}),c(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!l.isPending&&l.isError&&r(q,{}),!l.isPending&&l.data&&d.length===0&&r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!l.isPending&&d.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:f})}),!l.isPending&&d.map(t=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(e=>a(t.addonId,e))]},t.addonId))]})]})}function G({scope:t,onAdopt:i,onReset:o}){let{t:c}=A(),l=b({addonId:t.addonId}).data??null,[u,d]=a({}),f=C(),h=n(()=>{o(),f.mutate({addonId:t.addonId,params:u})},[f,t.addonId,u,o]),g=f.data?.candidates??[];return r(s,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&r(j,{schema:l,values:u,onChange:d}),e(`button`,{onClick:h,disabled:f.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:[f.isPending?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(m,{className:`h-3.5 w-3.5`}),f.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),f.isError&&r(q,{}),!f.isPending&&f.data&&g.length===0&&r(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!f.isPending&&g.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),g.map(e=>i(t.addonId,e))]})]})})}function K({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(p,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function q(){let{t}=A();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[r(d,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),r(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{F as a,I as i,H as n,z as r,U as t};
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Ei as c,En as l,Fn as u,Oi as d,Xr as f,fr as p,gt as m,kn as h,zt as g}from"./player-overlays-C0MwGGCz.js";import{Qa as _,to as v}from"./client-CoTSmvjZ.js";import{Eo as y,Ja as b,Tr as x,Yr as S,_i as C,_o as w,_s as T,ao as E,ha as D,ni as O,so as k}from"./src-BLJh-44s.js";import{t as A}from"./useTranslation-BJr-n0es.js";import{P as j}from"./index-QtGtcmlM.js";import{n as M,t as N}from"./BrokerEditorDialog-DpESkmwf.js";o();var P={connected:`success`,connecting:`warning`,disconnected:`default`,"auth-failed":`danger`,unreachable:`danger`,error:`danger`};function F({kind:t,value:n,onChange:i}){let{t:o}=A(),[s,c]=a(!1),l=D({kind:t}),d=M(l.data).filter(e=>e.kind===t);return e(`div`,{className:`space-y-2`,children:[l.isLoading&&e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[r(p,{className:`h-3.5 w-3.5 animate-spin`}),` `,o(`brokers.picker.loading`)]}),l.isError&&r(x,{message:o(`brokers.picker.loadFailed`,{message:l.error instanceof Error?l.error.message:o(`common.unknownError`)})}),!l.isLoading&&!l.isError&&d.length===0&&r(`p`,{className:`rounded-lg border border-border bg-surface px-3 py-4 text-center text-xs text-foreground-subtle`,children:o(`brokers.picker.none`)}),d.map(t=>e(`button`,{type:`button`,"aria-pressed":n===t.id,onClick:()=>i(t.id),className:`flex w-full items-center justify-between gap-3 rounded-lg border bg-surface p-3 text-left transition-colors ${n===t.id?`border-primary ring-1 ring-primary`:`border-border hover:border-foreground-subtle/30`}`,children:[r(`span`,{className:`text-xs font-semibold text-foreground`,children:t.name}),r(O,{variant:P[t.status],className:`text-[10px]`,children:t.status})]},t.id)),e(S,{variant:`outline`,size:`sm`,onClick:()=>c(!0),children:[r(u,{className:`h-3.5 w-3.5`}),` `,o(`brokers.picker.createNew`)]}),s&&r(N,{kind:t,onClose:()=>c(!1),onSaved:e=>{c(!1),i(e)}})]})}o();function I({kind:t,onResolved:n,onBack:i}){let{t:o}=A(),[s,l]=a(null);return e(`div`,{className:`space-y-4`,children:[e(S,{variant:`ghost`,size:`sm`,onClick:i,children:[r(c,{className:`h-3.5 w-3.5`}),` `,o(`common.back`)]}),r(F,{kind:t,value:s,onChange:l}),r(`div`,{className:`flex justify-end pt-1`,children:r(S,{variant:`primary`,size:`sm`,disabled:s===null,onClick:()=>s!==null&&n(s),children:o(`integrations.brokerStep.useThisBroker`,`Use this broker`)})})]})}o();function L(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 R={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 z({addonId:t,configSchema:n,canTest:i=!0,initialName:o,initialConfig:s,submitLabel:c,hideName:l=!1,onSave:u,onBack:d}){let{t:f}=A(),[p,m]=a(o??``),[h,g]=a(s??{}),[y,b]=a(null),x=T({onSuccess:e=>b(L(e)),onError:e=>b({status:`inconclusive`,error:String(e)})}),S=C(),w=!i||y?.status===`validated`,E=!l&&p.trim().length===0,D=!E&&w;return e(`div`,{className:`space-y-4`,children:[!l&&e(`div`,{children:[r(`label`,{htmlFor:`integration-name`,className:`block text-[11px] font-medium text-foreground mb-1`,children:f(`integrations.integrationName`)}),r(`input`,{id:`integration-name`,type:`text`,value:p,onChange:e=>m(e.target.value),placeholder:f(`integrations.integrationNamePlaceholder`),"aria-invalid":E,"aria-describedby":E?`integration-name-error`:void 0,className:`w-full rounded-lg border bg-surface px-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none ${E?`border-danger focus:border-danger`:`border-border focus:border-primary/50`}`}),E&&r(`p`,{id:`integration-name-error`,"data-testid":`integration-name-error`,className:`mt-1 text-xs text-danger`,children:f(`integrations.nameRequired`,`Name is required`)})]}),n&&r(j,{schema:n,values:h,onChange:e=>{g(e),b(null)},onAction:async(e,r,a)=>{let o=await S.mutateAsync({addonId:t,action:e,input:a??{}});if(i&&typeof o==`object`&&o){let e=o;if(!(typeof e.token==`string`||typeof e.sslCertificate==`string`||typeof e.host==`string`))return o;let r={...h};for(let[t,n]of Object.entries(e))typeof n==`string`&&t!==`summary`&&(r[t]=n);let i=v(n,r);g(i),b(null),x.mutate({addonId:t,settings:i})}return o}}),y&&r(`div`,{className:`rounded-lg border px-3 py-2 text-xs ${R[y.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.`})}})(y)}),e(`div`,{className:`flex items-center justify-between pt-2`,children:[r(`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`)}),e(`div`,{className:`flex items-center gap-2`,children:[r(`button`,{onClick:()=>x.mutate({addonId:t,settings:v(n,h)}),disabled:x.isPending||!i,title:i?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`)}),e(`div`,{className:`flex flex-col items-end gap-1`,children:[E&&r(`p`,{"data-testid":`integration-name-submit-error`,className:`text-xs text-danger`,children:f(`integrations.nameRequiredSubmit`,`Enter a name before continuing.`)}),r(`button`,{onClick:()=>{E||u({name:p,config:v(n,h),secretKeys:[..._(n)]})},disabled:!D,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`)})]})]})]})]})}function B(e,t){if(t.prefilledConfig.setupIntegration!==!0)return null;let n=t.prefilledConfig.host;return typeof n!=`string`||n.trim().length===0?null:{addonId:e,name:t.suggestedName,config:{host:n.trim()}}}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function H(e){if(!V(e)||!V(e.integrationSeed))return null;let t=e.integrationSeed,n=t.addonId,r=t.name,i=t.config;if(typeof n!=`string`||n.length===0||typeof r!=`string`||!V(i))return null;let a={};for(let[e,t]of Object.entries(i))a[e]=t;return{addonId:n,name:r,config:a}}o();function U({open:i,onClose:o,scope:s,onSetupIntegration:c}){let{t:l}=A(),u=b(),[g,_]=a(new Set),[v,y]=a(new Set),{data:x}=w({projection:`slim`}),S=t(()=>new Set((x??[]).map(e=>e.stableId)),[x]),C=n(async(e,t)=>{let n=B(e,t);if(n!==null){c?.(n),o();return}y(e=>new Set(e).add(t.stableId));try{await u.mutateAsync({addonId:e,candidate:t}),_(e=>new Set(e).add(t.stableId))}catch{}finally{y(e=>{let n=new Set(e);return n.delete(t.stableId),n})}},[u,o,c]),T=n((t,n)=>{let i=typeof n.prefilledConfig.host==`string`?n.prefilledConfig.host:null,a=S.has(n.stableId),o=g.has(n.stableId)||a,s=v.has(n.stableId);return e(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0`,children:[r(`p`,{className:`truncate text-xs font-medium text-foreground`,children:n.suggestedName}),i&&r(`p`,{className:`truncate text-[10px] font-mono text-foreground-subtle`,children:i})]}),o?e(`span`,{className:`flex items-center gap-1 text-[11px] text-foreground-subtle`,children:[r(d,{className:`h-3.5 w-3.5`}),` `,a?l(`integrations.scanNetworkModal.alreadyAdded`,`Already added`):l(`integrations.scanNetworkModal.added`,`Added`)]}):e(`button`,{type:`button`,onClick:()=>void C(t,n),disabled:s,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:[s?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(f,{className:`h-3.5 w-3.5`}),l(`common.add`,`Add`)]})]},n.stableId)},[g,v,S,C,l]);if(!i)return null;let E=s?`Scan network — ${s.label}`:`Scan network for devices`;return e(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center`,children:[r(`div`,{className:`absolute inset-0 bg-black/60`,onClick:o}),e(`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:[e(`div`,{className:`flex items-center justify-between border-b border-border px-5 py-4 shrink-0`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(h,{className:`h-4 w-4 text-primary`}),r(`h2`,{className:`text-sm font-semibold text-foreground`,children:E})]}),r(`button`,{onClick:o,className:`rounded-md p-1 text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:r(m,{className:`h-4 w-4`})})]}),s?r(G,{scope:s,onAdopt:T,onReset:()=>_(new Set)}):r(W,{onAdopt:T,onReset:()=>_(new Set)})]})]})}function W({onAdopt:a,onReset:o}){let{t:c}=A(),u=E(),d=n(()=>{o(),u.mutate({})},[u,o]);i(()=>{!u.isPending&&!u.data&&d()},[]);let f=t(()=>(u.data?.groups??[]).filter(e=>e.candidates.length>0),[u.data]),p=t(()=>f.reduce((e,t)=>e+t.candidates.length,0),[f]);return e(s,{children:[r(`div`,{className:`flex items-center justify-end gap-2 border-b border-border px-5 py-2 shrink-0`,children:e(`button`,{onClick:d,disabled:u.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:[r(l,{className:`h-3.5 w-3.5 ${u.isPending?`animate-spin`:``}`}),c(`integrations.scanNetworkModal.reScan`,`Re-scan`)]})}),e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[u.isPending&&r(K,{label:c(`integrations.scanNetworkModal.scanningTheLocalNetwork`,`Scanning the local network…`)}),!u.isPending&&u.isError&&r(q,{}),!u.isPending&&u.data&&f.length===0&&r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!u.isPending&&f.length>0&&r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.found`,{count:p})}),!u.isPending&&f.map(t=>e(`div`,{className:`space-y-1.5`,children:[e(`div`,{className:`flex items-center gap-2`,children:[r(`span`,{className:`text-[11px] font-semibold text-foreground`,children:t.label}),e(`span`,{className:`text-[10px] text-foreground-subtle`,children:[`(`,t.candidates.length,`)`]})]}),t.candidates.map(e=>a(t.addonId,e))]},t.addonId))]})]})}function G({scope:t,onAdopt:i,onReset:o}){let{t:c}=A(),l=y({addonId:t.addonId}).data??null,[u,d]=a({}),f=k(),m=n(()=>{o(),f.mutate({addonId:t.addonId,params:u})},[f,t.addonId,u,o]),g=f.data?.candidates??[];return r(s,{children:e(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4 space-y-4`,children:[l&&r(j,{schema:l,values:u,onChange:d}),e(`button`,{onClick:m,disabled:f.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:[f.isPending?r(p,{className:`h-3.5 w-3.5 animate-spin`}):r(h,{className:`h-3.5 w-3.5`}),f.isPending?c(`integrations.scanNetworkModal.scanning`,`Scanning…`):c(`integrations.scanNetworkModal.scan`,`Scan`)]}),f.isError&&r(q,{}),!f.isPending&&f.data&&g.length===0&&r(`p`,{className:`py-6 text-center text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.noDevicesRespondedToThe`,`No devices responded to the scan.`)}),!f.isPending&&g.length>0&&e(`div`,{className:`space-y-1.5`,children:[r(`p`,{className:`text-xs text-foreground-subtle`,children:c(`integrations.scanNetworkModal.foundShort`,{count:g.length})}),g.map(e=>i(t.addonId,e))]})]})})}function K({label:t}){return e(`div`,{className:`flex flex-col items-center py-12`,children:[r(p,{className:`h-6 w-6 animate-spin text-primary`}),r(`p`,{className:`mt-3 text-xs text-foreground-subtle`,children:t})]})}function q(){let{t}=A();return e(`div`,{className:`flex items-start gap-3 rounded-lg border border-destructive/40 bg-destructive/10 px-4 py-3`,children:[r(g,{className:`h-4 w-4 text-destructive mt-0.5 shrink-0`}),r(`p`,{className:`text-xs text-destructive`,children:t(`integrations.scanNetworkModal.theScanFailedTryAgain`,`The scan failed. Try again.`)})]})}export{F as a,I as i,H as n,z as r,U as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s,x as c}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Cr as l,G as u,Ht as d,J as f,K as p,Ni as m,Q as h,Tn as g,U as _,c as v,d as ee,dt as te,f as y,l as b,p as x,pa as S,s as C,st as w,ua as T,z as E}from"./player-overlays-C0MwGGCz.js";import{t as D}from"./settings-2-B7DN8MZt.js";import{MaskShapeCanvas as O}from"./MaskShapeCanvas-CEO3VTVU.js";s();var k=h(`/addon/pipeline-analytics/event-media`);function A(e){return`${k}/m/${e}`}function j(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 M(e){return e.states.reduce((e,t)=>e+t.references.length,0)}var N=`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 ne({monitor:t,disabled:n,onDelete:r}){let a=S(),o=j(t),s=M(t),c=w();return o.length===0?i(`p`,{className:`${E} leading-relaxed`,children:a(`uiLibrary.sceneReferenceGallery.empty`,`No photographs captured yet. Press “Capture daylight” to take the one this scene will judge everything against.`)}):i(`div`,{className:`flex flex-col gap-2`,children:o.map(t=>e(`div`,{className:`flex flex-col gap-1`,children:[e(`p`,{className:`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,children:[x(t.condition,a),` · `,t.tiles.length]}),i(`ul`,{className:`flex flex-wrap gap-1.5`,children:t.tiles.map(o=>{let l=`${o.stateId}:${String(o.index)}`,u=s===1;return e(`li`,{className:`flex w-24 flex-col gap-1 rounded-md border border-border p-1`,children:[i(P,{reference:o.reference}),i(`span`,{className:`${E} tabular-nums`,children:F(o.reference.capturedAt)}),e(`button`,{type:`button`,className:N,disabled:n,"aria-label":a(`uiLibrary.sceneReferenceGallery.deleteLabel`,`Delete the {{variant}} photograph from {{date}}`,{variant:x(t.condition,a).toLowerCase(),date:F(o.reference.capturedAt)}),onClick:()=>{(async()=>{u&&!await c({title:a(`uiLibrary.sceneReferenceGallery.deleteTitle`,`Delete the only photograph?`),message:a(`uiLibrary.sceneReferenceGallery.lastWarning`,`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.`),confirmLabel:a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`),variant:`danger`})||r({stateId:o.stateId,index:o.index})})()},children:[i(d,{className:`mr-1 inline h-3 w-3`}),a(`uiLibrary.sceneReferenceGallery.delete`,`Delete`)]})]},l)})})]},t.condition))})}function P({reference:t}){let n=S(),[r,a]=o(!1),s=t.thumbnailMediaId;return s===void 0||r?e(`div`,{className:`flex h-16 w-full flex-col items-center justify-center gap-0.5 rounded bg-surface text-foreground-subtle`,title:n(`uiLibrary.sceneReferenceGallery.missingPicture`,`The picture for this reference is no longer stored. The reference itself is intact and still being scored against.`),children:[i(l,{className:`h-4 w-4`}),i(`span`,{className:`text-[9px]`,children:n(`uiLibrary.sceneReferenceGallery.noPicture`,`no picture`)})]}):i(`img`,{src:A(s),alt:``,loading:`lazy`,className:`h-16 w-full rounded object-cover`,onError:()=>a(!0)})}function F(e){let t=new Date(e);return`${t.toLocaleDateString()} ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`}s();var I=`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:border-primary focus:outline-none disabled:opacity-50`,L=`text-[10px] font-medium text-foreground-subtle`,R=`flex flex-col gap-2 rounded-md border border-border bg-surface/40 p-2`,z=`text-[10px] font-semibold uppercase tracking-wide text-foreground-subtle`,B=5,V=3600;function H(e,t){switch(e){case`periodic`:return t(`uiLibrary.sceneSettingsForm.triggerHintPeriodic`,`Only on the clock. Predictable, and it notices a change even on a camera nothing ever moves in front of.`);case`on-motion`:return t(`uiLibrary.sceneSettingsForm.triggerHintOnMotion`,`Only after the camera has been still again for the quiet window below. Cheapest, but a change nobody walks past is never seen.`);case`both`:return t(`uiLibrary.sceneSettingsForm.triggerHintBoth`,`Both — the clock is the safety net that lets the motion path miss. This is the right answer for almost every scene.`)}}function U(e,t){switch(e){case`skip`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintSkip`,`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.`);case`judge-anyway`:return t(`uiLibrary.sceneSettingsForm.uncoveredHintJudge`,`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 W(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 G({monitor:t,disabled:n,onPatch:r}){let s=S(),[l,u]=o(()=>W(t)),[d,f]=o(!1);a(()=>{d||u(W(t))},[t,d]);let p=e=>{f(!1),r(e)},m=e=>t.check.mode===`similarity`?{mode:`similarity`,threshold:e.threshold??t.check.threshold,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount}:{...t.check,hysteresisCount:e.hysteresisCount??t.check.hysteresisCount},h=t.confirm?.enabled===!0,g=t.check.mode===`similarity`?t.check.threshold:null;return e(`div`,{className:`flex flex-col gap-2`,children:[e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatItWatches`,`What it watches`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.name`,`Name`)}),i(`input`,{type:`text`,value:l.label,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,label:e.target.value})),onBlur:()=>{let e=l.label.trim();e.length>0&&e!==t.label?p({label:e}):f(!1)}})]}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.enabled,disabled:n,onChange:e=>p({enabled:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.watching`,`Watching`)})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.watchingHint`,`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.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.whenToLook`,`When to look`)}),e(`select`,{value:t.triggerMode,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`periodic`||t===`on-motion`||t===`both`)&&p({triggerMode:t})},children:[i(`option`,{value:`both`,children:s(`uiLibrary.sceneSettingsForm.triggerBoth`,`On the clock and after motion settles`)}),i(`option`,{value:`periodic`,children:s(`uiLibrary.sceneSettingsForm.triggerPeriodic`,`On the clock only`)}),i(`option`,{value:`on-motion`,children:s(`uiLibrary.sceneSettingsForm.triggerOnMotion`,`After motion settles only`)})]})]}),i(`p`,{className:E,children:H(t.triggerMode,s)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.checkEvery`,`Check every (seconds)`)}),i(`input`,{type:`number`,min:B,max:V,value:l.checkIntervalSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,checkIntervalSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.checkIntervalSec,B,V);e===t.checkIntervalSec?f(!1):p({checkIntervalSec:e})}})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.intervalHint`,`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.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.howSure`,`How sure it has to be`)}),t.check.mode===`similarity`&&e(c,{children:[e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:i(T,{uiKey:`uiLibrary.sceneSettingsForm.matchThreshold`,fallback:`Match threshold — <0>{{value}}</0>`,components:[i(`span`,{className:`tabular-nums`},`value`)],values:{value:l.threshold.toFixed(2)}})}),i(`input`,{type:`range`,min:.3,max:.99,step:.01,value:l.threshold,disabled:n,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,threshold:Number(e.target.value)})),onMouseUp:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})},onBlur:()=>{l.threshold===g?f(!1):p({check:m({threshold:l.threshold})})}})]}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:s(`uiLibrary.sceneSettingsForm.thresholdHint`,`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.`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.agreeingChecks`,`Agreeing checks before it changes its mind`)}),i(`input`,{type:`number`,min:1,max:10,value:l.hysteresisCount,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,hysteresisCount:Number(e.target.value)||1})),onBlur:()=>{let e=K(l.hysteresisCount,1,10);e===t.check.hysteresisCount?f(!1):p({check:m({hysteresisCount:e})})}})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.agreeingHint`,`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.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.quietFor`,`Quiet for (seconds) before a check counts`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.quietSeconds,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,quietSeconds:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.quietSeconds,0,3600);e===t.quietSeconds?f(!1):p({quietSeconds:e})}})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.quietHint`,`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.`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.minGap`,`Minimum gap between counted checks (seconds)`)}),i(`input`,{type:`number`,min:0,max:3600,value:l.minObservationSpacingSec,disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,minObservationSpacingSec:Number(e.target.value)||0})),onBlur:()=>{let e=K(l.minObservationSpacingSec,0,3600);e===t.minObservationSpacingSec?f(!1):p({minObservationSpacingSec:e})}})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.minGapHint`,`Spreads the agreeing checks over real time instead of letting three adjacent polls inside one long occlusion be mistaken for three independent opinions.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.lighting`,`Lighting`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.noReference`,`When a light has no reference of its own`)}),e(`select`,{value:t.onUncoveredCondition,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`skip`||t===`judge-anyway`)&&p({onUncoveredCondition:t})},children:[i(`option`,{value:`skip`,children:s(`uiLibrary.sceneSettingsForm.uncoveredSkip`,`Skip the check (recommended)`)}),i(`option`,{value:`judge-anyway`,children:s(`uiLibrary.sceneSettingsForm.uncoveredJudge`,`Judge against the other light anyway`)})]})]}),i(`p`,{className:E,children:U(t.onUncoveredCondition,s)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.whatYouGetTold`,`What you get told`)}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.notificationsFollow`,`Notifications follow`)}),e(`select`,{value:t.emit,disabled:n,className:I,onChange:e=>{let t=e.target.value;(t===`latched`||t===`live`)&&p({emit:t})},children:[i(`option`,{value:`latched`,children:s(`uiLibrary.sceneSettingsForm.emitLatched`,`The flag — told once, still visible at breakfast`)}),i(`option`,{value:`live`,children:s(`uiLibrary.sceneSettingsForm.emitLive`,`The live state — follows the region as it changes`)})]})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.emitHint`,`“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.`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:t.autoRestore,disabled:n,onChange:e=>p({autoRestore:e.target.checked})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.autoRestore`,`Clear the flag by itself when things look normal again`)})]}),i(`p`,{className:E,children:s(`uiLibrary.sceneSettingsForm.autoRestoreHint`,`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.`)})]}),e(`div`,{className:R,children:[i(`p`,{className:z,children:s(`uiLibrary.sceneSettingsForm.aiDoubleCheck`,`AI double-check`)}),e(`label`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`checkbox`,checked:h,disabled:n||l.confirmPrompt.trim().length===0,onChange:e=>p(e.target.checked?{confirm:{...q(l.confirmPrompt.trim()),enabled:!0}}:{confirm:null})}),i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.askVision`,`Ask a vision model before changing the answer`)})]}),e(`label`,{className:`flex flex-col gap-1`,children:[i(`span`,{className:L,children:s(`uiLibrary.sceneSettingsForm.question`,`The question to ask`)}),i(`input`,{type:`text`,value:l.confirmPrompt,placeholder:s(`uiLibrary.sceneSettingsForm.questionPlaceholder`,`e.g. Is the wheelie bin still there?`),disabled:n,className:I,onFocus:()=>f(!0),onChange:e=>u(t=>({...t,confirmPrompt:e.target.value})),onBlur:()=>{let e=l.confirmPrompt.trim();e.length>0&&e!==t.confirm?.prompt?p({confirm:{...q(e),enabled:h}}):f(!1)}})]}),i(`p`,{className:E,children:i(T,{uiKey:`uiLibrary.sceneSettingsForm.confirmHint`,fallback:`The model is asked <0>only</0> 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.`,components:[i(`strong`,{},`only`)]})})]})]})}function K(e,t,n){return Math.min(n,Math.max(t,e))}function q(e){return{enabled:!1,prompt:e,timeoutMs:8e3,maxImagePx:448,onTimeout:`hold`}}s();var J=`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`,Y=`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`,re=`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`,ie={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`},ae=.8,oe=3;function X({deviceId:s}){let l=S(),h=p(te().trpcClient,s),w=f(h?.state.sceneMonitor),T=u(s,{width:640}),[k,A]=o(null),[j,M]=o(!1),[N,P]=o(null),[F,I]=o(null),[L,R]=o(null),[z,B]=o(null),[V,H]=o(!1),[U,W]=o(null),[K,q]=o(``),X=t(!0);a(()=>(X.current=!0,()=>{X.current=!1}),[]);let Z=r(async()=>{if(h)try{let e=await h.sceneMonitor?.listScenes({});if(!X.current)return;e&&A(e)}catch(e){if(!X.current)return;_(e)?M(!0):I(e instanceof Error?e.message:String(e))}},[h]);a(()=>{A(null),M(!1),I(null),Z()},[Z]);let Q=w?.monitors??k?.monitors??[],se=Date.now(),$=r(async(e,t)=>{P(e),I(null);try{await t(),await Z()}catch(e){X.current&&I(e instanceof Error?e.message:String(e))}finally{X.current&&P(null)}},[Z]),ce=n(()=>{let e=Q.map(e=>({id:e.id,shape:e.roi,label:e.label,enabled:e.enabled}));return U===null?e:[...e,{id:`__draft__`,shape:U,label:l(`uiLibrary.sceneMonitor.newSceneLabel`,`New scene`)}]},[Q,U,l]),le=r((e,t)=>{if(t.kind===`rect`){if(e===`__draft__`){W(t);return}$(`roi-${String(e)}`,async()=>h?.sceneMonitor?.updateScene({monitorId:String(e),patch:{roi:t}}))}},[h,$]),ue=r(e=>{e.kind===`rect`&&W(e)},[]),de=r(async()=>{U===null||K.trim().length===0||(await $(`create`,async()=>{await h?.sceneMonitor?.createScene({label:K.trim(),roi:U,check:{mode:`similarity`,threshold:ae,hysteresisCount:oe}})}),W(null),q(``),H(!1))},[h,U,K,$]);return h?i(`div`,{className:`flex flex-col gap-3`,children:j?i(`p`,{className:`${E} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.unsupported`,`Scene monitoring is not available for this camera.`)}):e(c,{children:[i(`p`,{className:`${E} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.intro`,`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.`)}),i(`div`,{className:`relative overflow-hidden rounded-md border border-border`,children:i(O,{items:ce,supportedShapes:[`rect`],selectedId:L??(U===null?null:`__draft__`),onSelect:e=>R(e===null?null:String(e)),onShapeChange:le,onDrawComplete:ue,drawingKind:V&&U===null?`rect`:null,backdrop:T.src===null?null:i(`img`,{src:T.src,alt:``,className:`h-full w-full object-contain`,draggable:!1})})}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i(`button`,{type:`button`,className:V?Y:J,"aria-pressed":V,onClick:()=>{H(e=>!e),W(null)},disabled:N!==null,children:V?l(`uiLibrary.sceneMonitor.cancel`,`Cancel`):l(`uiLibrary.sceneMonitor.newScene`,`+ New scene`)}),i(`button`,{type:`button`,className:J,onClick:T.refresh,disabled:N!==null,children:l(`uiLibrary.sceneMonitor.refresh`,`Refresh frame`)})]}),V&&e(`div`,{className:`flex flex-col gap-2 rounded-md border border-border bg-surface p-2`,children:[i(`p`,{className:`text-[10px] text-foreground-subtle`,children:U===null?l(`uiLibrary.sceneMonitor.draftHint`,`Click on the frame to drop a box, then drag its corner to fit it around the thing you want watched.`):l(`uiLibrary.sceneMonitor.nameHint`,`Name it, then create. You capture what “normal” looks like next.`)}),U!==null&&ee(U)&&i(`p`,{className:`text-[11px] leading-relaxed text-warning`,children:l(`uiLibrary.sceneMonitor.tooLarge`,`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.`)}),e(`div`,{className:`flex items-center gap-2`,children:[i(`input`,{type:`text`,value:K,onChange:e=>q(e.target.value),placeholder:l(`uiLibrary.sceneMonitor.placeholder`,`e.g. Immondizia prelevata`),className:`flex-1 rounded-md border border-border bg-surface px-2 py-1 text-[12px] text-foreground`}),i(`button`,{type:`button`,className:Y,onClick:()=>void de(),disabled:U===null||K.trim().length===0||N!==null,children:l(`uiLibrary.sceneMonitor.create`,`Create`)})]})]}),F!==null&&i(`p`,{className:`text-[11px] leading-relaxed text-danger`,children:F}),Q.length===0?i(`p`,{className:`${E} leading-relaxed`,children:l(`uiLibrary.sceneMonitor.empty`,`No scenes on this camera yet.`)}):i(`ul`,{className:`flex flex-col gap-2`,children:Q.map(t=>{let n=v(t,l);return e(`li`,{className:`flex flex-col gap-1.5 rounded-md border p-2 ${L===t.id?`border-primary/50`:`border-border`}`,children:[e(`div`,{className:`flex items-center gap-2`,children:[i(`button`,{type:`button`,className:`flex-1 text-left text-[12px] font-medium text-foreground`,onClick:()=>R(t.id),children:t.label}),i(`span`,{className:`rounded border px-1.5 py-0.5 text-[10px] font-medium ${ie[n.tone]}`,children:n.text})]}),i(`p`,{className:`${E} leading-relaxed`,children:y(t,se,l)}),i(`p`,{className:`${E} tabular-nums`,children:b(t,l)}),i(ne,{monitor:t,disabled:N!==null,onDelete:({stateId:e,index:n})=>void $(`refdel-${t.id}-${e}-${String(n)}`,async()=>h.sceneMonitor?.deleteReference({monitorId:t.id,stateId:e,index:n}))}),e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[C.map(n=>{let r=n===`ir`;return e(`button`,{type:`button`,className:J,disabled:N!==null,title:r?l(`uiLibrary.sceneMonitor.optionalTitle`,`Optional. Without a night reference the checks in infrared are simply skipped — the scene keeps working in daylight and nothing is reported as broken.`):l(`uiLibrary.sceneMonitor.captureTitle`,`Take a fresh photo now and store it as the {{variant}} reference`,{variant:x(n,l).toLowerCase()}),onClick:()=>void $(`cap-${t.id}-${n}`,async()=>h.sceneMonitor?.captureReference({monitorId:t.id,condition:n})),children:[i(m,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.capture`,`Capture {{variant}}`,{variant:x(n,l).toLowerCase()}),r&&i(`span`,{className:`ml-1 text-foreground-subtle/70`,children:l(`uiLibrary.sceneMonitor.optional`,`(optional)`)})]},n)}),e(`button`,{type:`button`,className:Y,disabled:N!==null||t.states.length===0,title:l(`uiLibrary.sceneMonitor.resetTitle`,`Clear the flag and re-photograph what normal looks like right now`),onClick:()=>void $(`reset-${t.id}`,async()=>h.sceneMonitor?.resetScene({monitorId:t.id})),children:[i(g,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.reset`,`Reset`)]}),i(`button`,{type:`button`,className:J,disabled:N!==null,onClick:()=>void $(`check-${t.id}`,async()=>h.sceneMonitor?.recheckNow({monitorId:t.id})),children:l(`uiLibrary.sceneMonitor.checkNow`,`Check now`)}),e(`button`,{type:`button`,className:z===t.id?Y:J,"aria-pressed":z===t.id,"aria-label":l(`uiLibrary.sceneMonitor.settingsFor`,`Settings for {{label}}`,{label:t.label}),disabled:N!==null,onClick:()=>B(e=>e===t.id?null:t.id),children:[i(D,{className:`mr-1 inline h-3 w-3`}),l(`uiLibrary.sceneMonitor.settings`,`Settings`)]}),i(`button`,{type:`button`,className:re,disabled:N!==null,onClick:()=>void $(`del-${t.id}`,async()=>h.sceneMonitor?.deleteScene({monitorId:t.id})),children:i(d,{className:`h-3 w-3`})})]}),z===t.id&&i(G,{monitor:t,disabled:N!==null,onPatch:e=>void $(`tune-${t.id}`,async()=>h.sceneMonitor?.updateScene({monitorId:t.id,patch:e}))})]},t.id)})})]})}):null}export{X as SceneMonitorEditor};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,et as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as c,Ht as l,Wr as u,ct as d,dt as f,fr as p,gt as m,mn as h,pa as g,pn as _,st as v,yi as y}from"./player-overlays-C0MwGGCz.js";import{a as b,i as x,s as S}from"./video-6lAlm9YD.js";import{t as C}from"./key-round-CBNBBS9z.js";import{Bn as ee,Cn as w,Ed as T,Et as E,Rn as D,Sn as O,Tr as k,Vn as A,Wn as j,Wu as M,Yr as N,_o as te,_r as P,ad as ne,bn as F,ct as I,dr as L,ed as R,fn as z,fr as B,ft as re,gr as V,hr as H,mn as U,mr as W,mt as ie,ni as G,od as K,pd as q,pn as ae,pr as J,ri as oe,st as se}from"./src-BLJh-44s.js";import{t as Y}from"./i18n-D7mWXOH-.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{er as ce,n as Z,t as le,ur as ue}from"./index-QtGtcmlM.js";s();function de({id:t,title:n,icon:r,description:a,actions:o,tone:s=`default`,notice:l=null,onDismissNotice:u,children:d}){return i(F,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:q(`text-[11px] leading-relaxed`,s===`danger`?`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-foreground`:`text-foreground-subtle`),children:a}),l!==null&&i(pe,{notice:l,onDismiss:u}),d]})})}var fe={success:{icon:y,line:`border-success/30 text-foreground`,mark:`text-success`},danger:{icon:x,line:`border-danger/40 text-danger`,mark:`text-danger`}};function pe({notice:t,onDismiss:n}){let{t:r}=X(),a=fe[t.tone],o=a.icon;return e(`div`,{role:t.tone===`danger`?`alert`:`status`,className:q(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:q(`mt-0.5 h-3.5 w-3.5 shrink-0`,a.mark),"aria-hidden":!0}),i(`span`,{className:`min-w-0 flex-1`,children:t.message}),n!==void 0&&i(K,{type:`button`,variant:`ghost`,size:`sm`,icon:m,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=M();return n(()=>{let t=new Map;for(let n of e??[])t.set(n.id,n.username);return t},[e])}function he(e,t=null){return e===null?t:{tone:`danger`,message:e}}var ge={active:`access.credentialColumns.statusActive`,expired:`access.credentialColumns.statusExpired`,revoked:`access.credentialColumns.statusRevoked`,current:`access.credentialColumns.statusCurrent`};function _e(e){return Y.t(ge[e])}var ve={active:`success`,expired:`warning`,revoked:`default`,current:`info`},ye={current:0,active:1,expired:2,revoked:3};function be(e,t){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?`—`:n.toLocaleString()}function xe({status:e}){return i(G,{variant:ve[e],className:`text-[10px]`,children:_e(e)})}function Se({row:t,action:n}){if(!n.isAvailable(t))return null;let r=n.icon,a=n.busyId===t.id;return e(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n.onRun(t),disabled:n.disabled,"aria-label":Y.t(`access.credentialColumns.actionOn`,{action:n.label,name:t.name}),className:n.tone===`neutral`?void 0:`text-danger hover:bg-danger/10`,children:[a?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(r,{className:`h-3 w-3`,"aria-hidden":!0}),n.label]})}function Ce(t){return[{key:`name`,header:Y.t(`access.credentialColumns.name`,`Name`),sortValue:e=>e.name.toLowerCase(),render:t=>e(`div`,{className:`min-w-0 max-w-[18rem]`,children:[i(`div`,{className:`truncate font-medium text-foreground`,title:t.name,children:t.name}),t.detail!==null&&i(`div`,{className:`truncate font-mono text-[10px] text-foreground-subtle`,title:t.detail,children:t.detail})]})},t.hideOwner?null:{key:`owner`,header:Y.t(`access.credentialColumns.owner`,`Owner`),sortValue:e=>e.ownerName.toLowerCase(),render:e=>e.ownerName},{key:`kind`,header:Y.t(`access.credentialColumns.kindScope`,`Kind / scope`),sortValue:e=>e.kind.toLowerCase(),nowrap:!1,render:t=>e(`div`,{className:`min-w-[8rem] max-w-[16rem]`,children:[i(`div`,{className:`text-foreground`,children:t.kind}),t.scope!==null&&i(`div`,{className:`line-clamp-2 text-[10px] text-foreground-subtle`,title:t.scope,children:t.scope})]})},{key:`status`,header:Y.t(`access.credentialColumns.status`,`Status`),sortValue:e=>ye[e.status],render:e=>i(xe,{status:e.status})},{key:`created`,header:Y.t(`access.credentialColumns.created`,`Created`),sortValue:e=>e.createdAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.createdAt,`—`)})},{key:`lastUsed`,header:Y.t(`access.credentialColumns.lastUsed`,`Last used`),sortValue:e=>e.lastUsedAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.lastUsedAt,Y.t(`access.credentialColumns.never`))})},{key:`expires`,header:Y.t(`access.credentialColumns.expires`,`Expires`),sortValue:e=>e.expiresAt,render:e=>i(`span`,{className:`text-foreground-subtle`,children:be(e.expiresAt,t.expiresNone)})},t.action===null?null:{key:`actions`,header:``,align:`right`,notSortableReason:Y.t(`access.credentialColumns.actionsHeader`),render:e=>i(`div`,{className:`flex items-center justify-end gap-1`,children:[...t.extraActions??[],t.action].map(t=>t===null?null:i(Se,{row:e,action:t},t.label))})}].filter(e=>e!==null)}s();var we=6,Te={"current-session":`access.bulk.skipCurrentSession`,"not-active":`access.bulk.skipNotActive`};function Ee(e){let t=Te[e];return t===void 0?e:Y.t(t)}function De(e,t){return Y.t(t.key,{count:e})}function Q(e,t){return Y.t(`access.bulk.countOf`,{count:e,noun:De(e,t)})}function Oe(e){let t=new Map;for(let n of e)t.set(n.status,(t.get(n.status)??0)+1);return[...t.entries()].map(([e,t])=>Y.t(`access.bulk.statusCount`,{count:t,status:_e(e).toLowerCase()})).join(`, `)}function ke(e,t){let n=e.slice(0,we).map(e=>`• ${e.name} — ${e.ownerName}`),r=e.length>we?[Y.t(`access.bulk.previewMore`,{count:e.length-we})]:[];return[Y.t(`access.bulk.previewIntro`,{what:Q(e.length,t),breakdown:Oe(e)}),``,...n,...r].join(`
|
|
2
|
+
`)}async function Ae(e,t,n){let r=String(t.length),i=await e({title:Y.t(`access.bulk.confirmTitle`,{what:Q(t.length,n)}),message:ke(t,n),label:Y.t(`access.bulk.confirmLabel`,{expected:r}),placeholder:r,confirmLabel:Y.t(`access.bulk.confirmButton`,{expected:r}),variant:`danger`,validate:e=>e.trim()===r?null:Y.t(`access.bulk.confirmMismatch`,{expected:r,noun:De(2,n)})});return i!==null&&i.trim()===r}function je(e,t){let n=d(),r=T.auth.revokeCredentials.useMutation(),[i,a]=o(null);return{run:async i=>{if(i.length===0||!await Ae(n,i,e))return!1;a(null);try{let t=await r.mutateAsync({ids:i.map(e=>e.id),confirmCount:i.length}),n=t.skipped.map(e=>Ee(e.reason));return a({tone:`success`,message:n.length>0?Y.t(`access.bulk.revokedSkipped`,{what:Q(t.revoked.length,e),count:n.length,reasons:[...new Set(n)].join(`, `)}):Y.t(`access.bulk.revoked`,{what:Q(t.revoked.length,e)})}),!0}catch(e){return a({tone:`danger`,message:Y.t(`access.bulk.revokeFailed`,{error:e instanceof Error?e.message:Y.t(`access.bulk.requestFailed`)})}),!1}finally{t()}},busy:r.isPending,outcome:i,dismiss:()=>a(null)}}function Me(e,t,n){let r=d(),[i,a]=o(!1),[s,c]=o(null);return{run:async i=>{if(i.length===0||!await Ae(r,i,e))return!1;c(null),a(!0);let o=[],s=0;for(let e of i)try{await t(e.id),s+=1}catch(t){o.push(`${e.name}: ${t instanceof Error?t.message:Y.t(`access.bulk.requestFailed`)}`)}return a(!1),n(),o.length===0?(c({tone:`success`,message:Y.t(`access.bulk.revoked`,{what:Q(s,e)})}),!0):(c({tone:`danger`,message:Y.t(o.length>3?`access.bulk.eachPartialMore`:`access.bulk.eachPartial`,{what:Q(s,e),count:o.length,details:o.slice(0,3).join(`; `)})}),s>0)},busy:i,outcome:s,dismiss:()=>c(null)}}s();var Ne={searchText:e=>[e.name,e.detail??``,e.ownerName,e.kind,e.scope??``],facetGroups:[{id:`status`,value:e=>e.status},{id:`owner`,value:e=>e.ownerName},{id:`kind`,value:e=>e.kind}]},Pe={status:`access.credentialTable.groupStatus`,owner:`access.credentialTable.groupOwner`,kind:`access.credentialTable.groupKind`},Fe=e=>e.status!==`current`,Ie=[`active`,`current`];function Le({rows:t,label:r,isLoading:a,loadError:s,emptyText:c,hideOwner:l=!1,expiresNone:u,action:d,extraActions:f,bulk:m,defaultStatus:h=Ie}){let{t:g}=X(),[_]=o(()=>h.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...h]}}),v=z(t,Ne,_),[y,b]=o(()=>new Set),x=u??g(`access.credentialColumns.never`),S=n(()=>Ce({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,g]),C=n(()=>m===void 0?()=>!1:e=>Fe(e)&&m.isSelectable(e),[m]),ee=n(()=>v.rows.filter(e=>y.has(e.id)&&C(e)),[v.rows,y,C]);return a?e(`div`,{className:`flex items-center gap-2 py-4 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),g(`access.credentialTable.loading`,{label:r})]}):s===null?e(`div`,{className:`space-y-3`,children:[i(ae,{state:v.state,facets:v.facets,groups:v.groups.filter(e=>!(l&&e.id===`owner`)).map(e=>({...e,label:Pe[e.id]===void 0?e.id:g(Pe[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:g(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:g(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:g(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:g(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),m!==void 0&&i(Re,{bulk:m,shown:v.rows.filter(C),targets:ee,onSelect:b}),i(O,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:w,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:g(`access.credentialTable.pagesLabel`,{label:r}),previous:g(`access.credentialTable.previousPage`),next:g(`access.credentialTable.nextPage`),range:(e,t,n)=>g(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?g(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...m===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>g(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:g(`access.credentialTable.pageLabel`,{noun:De(1,m.noun)})}}})]}):i(k,{title:g(`access.credentialTable.couldNotLoad`,`Could not load {{label}}`,{label:r}),message:s})}function Re({bulk:t,shown:n,targets:r,onSelect:a}){let{t:o}=X(),{revoke:s,noun:c}=t,u=(t.quickSelect??[]).map(e=>({...e,rows:n.filter(e.match)})).filter(e=>e.rows.length>0),d=async()=>{await s.run(r)&&a(new Set)};return e(`div`,{className:`flex flex-wrap items-center gap-2`,"data-testid":`bulk-bar`,children:[n.length>0&&i(N,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(n.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:n.length})}),u.map(t=>e(N,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(t.rows.map(e=>e.id))),children:[t.label,` (`,String(t.rows.length),`)`]},t.label)),r.length>0&&e(`div`,{className:`ml-auto flex flex-wrap items-center gap-2`,children:[i(`span`,{className:`text-[11px] tabular-nums text-foreground`,"aria-live":`polite`,children:o(`access.credentialTable.selectedLabel`,{what:Q(r.length,c)})}),e(N,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[i(m,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(N,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?i(p,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(l,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.revoke`,{what:Q(r.length,c)})]})]})]})}var ze=(e,t)=>t===null?`—`:e.get(t)??t;function Be(e,t){return e!=null&&e<=t?`expired`:`active`}function Ve(e,t,n){return{id:e.id,name:n.client(e.client),detail:e.ip,ownerId:e.userId,ownerName:ze(t,e.userId),kind:n.method(e.method),scope:null,status:e.current?`current`:`active`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function He(e,t){return{id:e.id,name:e.integrationId,detail:null,ownerId:e.userId,ownerName:e.username,kind:e.integrationId,scope:t,status:e.revokedAt===null?`active`:`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:null}}var Ue=`All permissions`,We=`View link`,Ge=`Scoped`,Ke={"grid-view":`Grid`,"events-view":`Events`};function qe(e,t){return e.map(e=>t.get(e)??`#${String(e)}`).join(`, `)}function Je(e){return e!==`*`&&e.type===`share-view`&&`grant`in e}function Ye(e,t,n){return e===`*`?Ue:Je(e)?`${`${Ke[e.grant.kind]} view${e.grant.talk===!0?` + talk`:``}`}: ${qe(e.grant.deviceIds,t)}`:n(e)}function Xe(e){return e.includes(`*`)?Ue:e.some(Je)?We:Ge}function Ze(e,t,n,r){return{id:e.id,name:e.label,detail:null,ownerId:e.subjectId,ownerName:ze(t,e.subjectId),kind:Xe(e.scopes),scope:n,status:e.revokedAt===null?Be(e.expiresAt,r):`revoked`,createdAt:e.createdAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Qe(e){return`${e.provider}\u0000${e.subject}`}function $e(e,t){return{id:Qe(e),name:e.label??e.subject,detail:e.issuer,ownerId:e.userId,ownerName:ze(t,e.userId),kind:e.provider,scope:null,status:`active`,createdAt:e.linkedAt,lastUsedAt:null,expiresAt:null}}var et=40,tt=[{test:/Electron\//,name:`CamStack desktop`},{test:/Edg(e|A|iOS)?\//,name:`Edge`},{test:/OPR\/|Opera/,name:`Opera`},{test:/Firefox\/|FxiOS\//,name:`Firefox`},{test:/Chrome\/|CriOS\//,name:`Chrome`},{test:/Version\/[\d.]+.*Safari\//,name:`Safari`}],nt=[{test:/iPhone/,name:`iPhone`},{test:/iPad/,name:`iPad`},{test:/Android/,name:`Android`},{test:/Mac OS X|Macintosh/,name:`macOS`},{test:/Windows/,name:`Windows`},{test:/CrOS/,name:`ChromeOS`},{test:/Linux/,name:`Linux`}],rt=[{test:/CFNetwork\/.*Darwin\//,name:`CamStack app on iOS`},{test:/^okhttp\//i,name:`CamStack app on Android`},{test:/^(node|undici)\b/i,name:`Script (Node.js)`},{test:/^curl\//i,name:`curl`}];function it(e,t){return e.find(e=>e.test.test(t))?.name??null}function at(e){return e.length<=et?e:`${e.slice(0,et)}…`}function ot(e){if(e===null||e.trim().length===0)return{label:Y.t(`helpers.sessionClient.unknownDevice`),raw:null};let t=e.trim(),n=it(rt,t);if(n!==null)return{label:n,raw:t};let r=it(tt,t),i=it(nt,t);return r!==null&&i!==null?{label:Y.t(`helpers.sessionClient.browserOnSystem`,{browser:r,system:i}),raw:t}:r===null?{label:at(t),raw:t}:{label:r,raw:t}}var st={password:`helpers.sessionClient.method.password`,passkey:`helpers.sessionClient.method.passkey`,sso:`helpers.sessionClient.method.sso`,handoff:`helpers.sessionClient.method.handoff`,exchange:`helpers.sessionClient.method.exchange`};function ct(e){let t=st[e];return t===void 0?e:Y.t(t)}function lt(e){if(e==null)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleString()}s();function ut(e,t){return e instanceof Error&&e.message.length>0?e.message:t}function dt(n){let{t:a}=X(),s=f(),[c,l]=o(!1),[u,d]=o(``),[m,h]=o(null),[g,_]=o(null),v=t(null),y=r(e=>{v.current?.(e),v.current=null,l(!1),d(``),h(null),_(null)},[]),b=r(()=>new Promise(e=>{v.current?.(null),v.current=e,_(null),l(!0)}),[]),x=async()=>{h(`password`),_(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});y(e)}catch(e){_(ut(e,`Password is incorrect`)),h(null)}},S=async()=>{h(`passkey`),_(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!le(e))throw Error(`passkey authentication options missing challenge`);let t=await Z({optionsJSON:e}),{reauthToken:n}=await s.reauthenticate({passkeyResponse:Object.fromEntries(Object.entries(t))});y(n)}catch(e){_(ut(e,`Passkey verification failed`)),h(null)}};return{requestProof:b,dialog:i(L,{open:c,onOpenChange:e=>!e&&y(null),children:e(J,{children:[e(V,{children:[i(P,{children:a(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),i(W,{children:a(`auth.reauthDialog.needsPassword`,{action:n})})]}),e(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&m===null&&x()},children:[i(ne,{type:`password`,autoComplete:`current-password`,placeholder:a(`auth.reauthDialog.currentPassword`,`Current password`),value:u,onChange:e=>d(e.target.value),"aria-label":a(`auth.reauthDialog.currentPassword`,`Current password`)}),g!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:g}),e(H,{className:`flex flex-wrap gap-2`,children:[e(N,{type:`button`,variant:`outline`,disabled:m!==null,onClick:()=>void S(),children:[m===`passkey`?i(p,{className:`h-4 w-4 animate-spin`}):i(C,{className:`h-4 w-4`}),a(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),e(N,{type:`submit`,disabled:u.length===0||m!==null,children:[m===`password`&&i(p,{className:`h-4 w-4 animate-spin`}),a(`common.confirm`,`Confirm`)]})]})]})]})})}}function ft({token:t,label:n,onClose:r}){let{t:a}=X();return i(L,{open:!0,onOpenChange:e=>!e&&r(),children:e(J,{width:`md`,scroll:`body`,children:[i(V,{children:i(P,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:n})})}),e(B,{className:`space-y-3`,children:[i(`div`,{className:`rounded-md border border-warning/30 bg-warning/10 px-3 py-2 text-xs text-warning`,children:a(`auth.tokenModals.copyThisTokenNowOnce`,`Copy this token now. Once you close this dialog the secret cannot be displayed again.`)}),i(`div`,{className:`select-all break-all rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:t})]}),e(H,{children:[i(U,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),i(N,{type:`button`,variant:`primary`,size:`sm`,onClick:r,children:a(`auth.tokenModals.done`,`Done`)})]})]})})}var pt={token:`newToken`,scoped:`newScoped`,admin:`newAdmin`};s();var mt=80,$=86400,ht=[{value:`1`,seconds:$},{value:`7`,seconds:7*$},{value:`30`,seconds:30*$},{value:`90`,seconds:90*$},{value:`never`,seconds:`never`}],gt={type:`device-multiselect`,key:`cameras`,deviceFilter:{types:[`camera`]},maxItems:64},_t={type:`capability`,target:``,access:[`view`,`create`]};function vt({open:t,users:r,onClose:s,onSubmit:c,submitting:l,formError:d,awaitingProof:f}){let{t:m}=X(),v=g(),{user:y}=ce(),b=y?.isAdmin===!0,x=b?null:y?.scopes??[],[S,w]=o(`scopes`),[T,E]=o(y?.id??``),[O,k]=o(``),[M,te]=o([_t]),[P,F]=o([]),[L,z]=o(`grid-view`),[B,re]=o(!1),[V,H]=o(`30`);a(()=>{t||(w(`scopes`),E(y?.id??``),k(``),te([_t]),F([]),z(`grid-view`),re(!1),H(`30`))},[t,y?.id]),a(()=>{S!==`view-link`&&V===`never`&&H(`30`)},[S,V]);let U=n(()=>ht.filter(e=>e.seconds!==`never`||S===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?m(`access.createTokenModal.never`,`Never (until revoked)`):m(`access.createTokenModal.days`,{count:Number(e.value)})})),[S,m]),W=O.trim(),G=S===`scopes`?I(M,v):null,K=P.map(Number).filter(e=>Number.isInteger(e)&&e>=0),q=ht.find(e=>e.value===V)?.seconds??30*$,ae=()=>S===`all`?[`*`]:S===`view-link`?[{type:`share-view`,grant:{kind:L,deviceIds:K,...B?{talk:!0}:{}}}]:M,J=W.length>0&&W.length<=mt&&!l&&!f&&(S===`all`?b:S===`view-link`?K.length>0:M.length>0&&G===null),Y=()=>{if(!J)return;let e=b&&S!==`all`&&T!==``&&T!==y?.id;c({scopes:ae(),expiresIn:q,label:W,...e?{subjectId:T}:{}})},Z=S===`all`,le=Z?h:_;return i(ie,{open:t,onClose:s,title:m(`access.createTokenModal.createToken`,`Create token`),icon:Z?h:C,error:d,width:`md`,testId:`create-token-dialog`,footer:e(N,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:Y,disabled:!J,"data-testid":`create-token-submit`,children:[l||f?i(p,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):i(le,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),m(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(j,{children:m(`access.createTokenModal.whatItMayDo`,`What it may do`)}),i(D,{appearance:`pills`,value:S,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&w(e)},children:e(ee,{"aria-label":m(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(A,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[i(_,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(A,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[i(u,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachViewLink`,`View link`)]}),b?e(A,{value:`all`,"data-testid":`token-reach-all`,children:[i(h,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),m(`access.createTokenModal.reachAll`,`All permissions`)]}):null]})})]}),Z?i(`div`,{className:`space-y-1 rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px] leading-relaxed text-foreground`,"data-testid":`admin-token-warning`,children:i(`p`,{children:i(ue,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:i(`strong`,{})}})})}):null,b&&S!==`all`&&r.length>1?e(`div`,{className:`space-y-1`,children:[i(j,{htmlFor:`token-user`,children:m(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),i(R,{id:`token-user`,value:T,onChange:e=>E(e.target.value),options:r.map(e=>({value:e.id,label:e.username}))})]}):null,e(`div`,{className:`space-y-1`,children:[i(j,{htmlFor:`token-name`,children:m(`access.createTokenModal.label`,`Label`)}),i(ne,{id:`token-name`,value:O,maxLength:mt,required:!0,onChange:e=>k(e.target.value),placeholder:S===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),S===`scopes`?e(`div`,{className:`space-y-1`,children:[i(j,{children:m(`access.createTokenModal.scopes`,`Scopes`)}),i(se,{value:M,onChange:te,clampToParent:x}),G&&i(`p`,{className:`text-[10px] text-danger`,children:G}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:m(`access.createTokenModal.eachScopePicksACap`,`Each scope picks a (cap or addon) target + one or more access flavours. The token can access ONLY what's listed.`)})]}):null,S===`view-link`?e(`div`,{className:`space-y-2`,"data-testid":`token-view-link`,children:[e(`div`,{className:`space-y-1`,children:[i(j,{children:m(`access.createTokenModal.cameras`,`Cameras`)}),i(oe,{field:{...gt,label:m(`access.createTokenModal.cameras`,`Cameras`)},value:P,onChange:e=>F(Array.isArray(e)?e.filter(e=>typeof e==`string`):[])})]}),e(`div`,{className:`space-y-1`,children:[i(j,{htmlFor:`token-view-kind`,children:m(`access.createTokenModal.viewKind`,`Shows`)}),i(R,{id:`token-view-kind`,value:L,onChange:e=>z(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:m(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:m(`access.createTokenModal.viewEvents`,`Events`)}]})]}),L===`grid-view`?e(`label`,{className:`flex items-start gap-2 text-sm text-foreground`,children:[i(`input`,{type:`checkbox`,className:`mt-0.5`,checked:B,onChange:e=>re(e.target.checked),"data-testid":`token-view-talk`}),i(`span`,{children:m(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[i(j,{htmlFor:`token-lifetime`,children:m(`access.createTokenModal.expires`,`Expires after`)}),i(R,{id:`token-lifetime`,value:V,onChange:e=>H(e.target.value),options:U})]})]})})}s();var yt={key:`access.nouns.token`};function bt(e){return typeof e==`object`&&!!e&&`kind`in e}function xt(e,t){let n=e.access===void 0?``:` [${e.access.join(`, `)}]`;return e.type===`device`?`device:[${bt(e.selector)?E(e.selector,t):`?`}]${n}`:e.type===`addon-routes`?`${t(`access.tokensSection.everyAddonRoutes`,`every addon's routes`)}${n}`:`${e.type}:${e.target??``}${n}`}function St({headerOwnsCreate:t=!1,createRequested:r=!1,onCreateConsumed:s,ownOnly:c=!1}){let{t:u}=X(),d=g(),{user:f}=ce(),p=v(),m=T.useUtils(),h=me(),{data:_}=M(),y=n(()=>_??[],[_]),{data:b}=te({}),x=n(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),S=T.auth.listTokens.useQuery(void 0),{requestProof:ee,dialog:w}=dt(`Creating a token with all permissions`),{state:E,openNew:D,close:O}=re({newKey:pt.token}),[k,A]=o(null),[j,P]=o(null),[ne,F]=o(!1),[I,L]=o(null),[R,z]=o(null);a(()=>{r&&(D(),s?.())},[r,D,s]);let B=()=>{m.auth.listTokens.invalidate(),m.auth.listAuthAudit.invalidate()},V=T.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{B(),O(),P(null),F(!1),L({token:e,label:t.label})},onError:e=>{P(`Create failed: ${e.message}`),F(!1)}}),H=T.auth.revokeToken.useMutation({onSuccess:()=>{z(null),B()},onError:e=>{z(null),A(`Revoke failed: ${e.message}`)}}),U=je(yt,B),W=Date.now(),ie=(S.data??[]).filter(e=>!c||e.subjectId===f?.id).map(e=>Ze(e,h,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ye(e,x,e=>xt(e,d))).join(`, `),W)),G=async e=>{await p({title:u(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?u(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):u(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:u(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(A(null),z(e.id),H.mutate({id:e.id}))},K=e=>{(async()=>{A(null),P(null);let t;if(e.scopes.includes(`*`)){F(!0);let e=await ee();if(F(!1),e===null)return;t=e}V.mutate({scopes:[...e.scopes],expiresIn:e.expiresIn,label:e.label,...e.subjectId===void 0?{}:{subjectId:e.subjectId},...t===void 0?{}:{reauthToken:t}})})()};return e(`div`,{"data-testid":`tokens`,children:[w,i(de,{notice:he(k,U.outcome),onDismissNotice:()=>{A(null),U.dismiss()},id:c?`my-tokens`:`tokens`,title:c?u(`access.tokensSection.myTokens`,`My tokens`):u(`access.tokensSection.tokens`,`Tokens`),icon:C,actions:t?void 0:e(N,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:D,children:[i(C,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),u(`system.access.newToken`,`New token`)]}),description:u(`access.tokensSection.oneFormat`,`Every token is its scopes: a few permissions for a script, all permissions for an admin script, or a view of some cameras for a share link. Revoking one stops it on its next use.`),children:i(Le,{rows:ie,label:u(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:u(`access.tokensSection.noTokens`,`No tokens.`),action:{label:u(`access.tokensSection.revoke2`,`Revoke`),icon:l,isAvailable:e=>e.status===`active`,onRun:e=>void G(e),busyId:R,disabled:U.busy||R!==null},...f?.isAdmin===!0?{bulk:{revoke:U,noun:yt,isSelectable:e=>e.status===`active`}}:{}})}),i(vt,{open:E.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{O(),P(null),F(!1)},submitting:V.isPending,formError:j,awaitingProof:ne,onSubmit:K}),I&&i(ft,{token:I.token,label:I.label,onClose:()=>L(null)})]})}var Ct=864e5,wt={qr:`QR (by an admin)`,self:`Self-enrolled`},Tt={ios:`iOS`,android:`Android`,web:`Web`,other:`Other`};function Et(e){return e.status===`revoked`}function Dt(e){return e.status!==`revoked`}function Ot(e,t=`—`){if(e===null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:n.toLocaleString()}function kt(e,t){return e===null||Number.isNaN(e)?null:Math.floor((e-t)/Ct)}function At(e,t){let n=kt(e,t);return n===null?`unknown`:n<0?`expired`:n<30?`soon`:`ok`}function jt(e,t){let n=kt(e,t);return n===null?Y.t(`helpers.certificateModel.unknown`):n===0?Y.t(`helpers.certificateModel.today`):n>0?Y.t(`helpers.certificateModel.inDays`,{count:n}):Y.t(`helpers.certificateModel.daysAgo`,{count:-n})}function Mt(e){if(e===null)return null;let t=Date.parse(e);return Number.isNaN(t)?null:t}function Nt(e){return e===null||e.length===0?`—`:e.length<=17?e:`${e.slice(0,8)}…${e.slice(-8)}`}function Pt(e){return e.length<=10?e:`${e.slice(0,10)}…`}function Ft(e){if(!e.online)return{allowed:!1,reason:Y.t(`helpers.certificateModel.nodeOffline`)};if(e.isHub&&e.https.kind===`served`){if(e.https.status.mode===`uploaded`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.uploadedCert`)};if(e.https.status.mode===`disabled`)return{allowed:!1,reason:Y.t(`helpers.certificateModel.tlsDisabled`)}}return{allowed:!0,reason:null}}var It={prepare:`helpers.certificateModel.stage.prepare`,issue:`helpers.certificateModel.stage.issue`,install:`helpers.certificateModel.stage.install`,reconnect:`helpers.certificateModel.stage.reconnect`,confirm:`helpers.certificateModel.stage.confirm`};function Lt(e){if(e.ok)return{tone:`success`,message:Y.t(`helpers.certificateModel.renewed`,{nodeId:e.nodeId,serial:Pt(e.newSerial)})};let t=e.keptPreviousLeaf?Y.t(`helpers.certificateModel.keptPrevious`):Y.t(`helpers.certificateModel.maybeNoCert`);return{tone:`danger`,message:Y.t(`helpers.certificateModel.renewalFailed`,{nodeId:e.nodeId,stage:Y.t(It[e.stage]),reason:e.reason,kept:t})}}function Rt(e,t){let n=Math.max(0,e-t),r=Math.ceil(n/1e3),i=Math.floor(r/60),a=r%60;return{expired:n===0,label:`${String(i)}:${String(a).padStart(2,`0`)}`}}var zt=11;function Bt(e,t){let n=e.slice(0,zt);return t===null?n:`${n} · ${t}`}function Vt(e){return{id:e.id,name:e.deviceName,detail:Bt(e.fingerprint,e.lastUsedFrom),ownerId:e.userId,ownerName:e.username??e.userId,kind:Tt[e.platform],scope:wt[e.enrolledVia],status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ht(e,t){return{id:e.id,name:e.deviceName,detail:null,ownerId:null,ownerName:t,kind:Tt[e.platform],scope:null,status:e.status,createdAt:e.issuedAt,lastUsedAt:e.lastUsedAt,expiresAt:e.expiresAt}}function Ut({sessions:t,isLoading:n,loadError:r,emptyText:a,onRevoke:o,revokingId:s}){let{t:c}=X();return n?e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(p,{className:`h-3.5 w-3.5 animate-spin`}),c(`auth.sessionsList.loadingSessions`,`Loading sessions…`)]}):r===null?t.length===0?i(`div`,{className:`rounded border border-dashed border-border px-3 py-4 text-xs text-foreground-subtle text-center`,children:a}):i(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:t.map(e=>i(Wt,{session:e,revoking:s===e.id,onRevoke:()=>o(e)},e.id))}):e(`div`,{className:`text-[11px] text-danger`,children:[c(`auth.sessionsList.couldNotLoadSessions`,`Could not load sessions:`),` `,r]})}function Wt({session:t,revoking:n,onRevoke:r}){let{t:a}=X(),o=ot(t.client);return e(`li`,{"data-testid":`session-row`,className:`flex items-start gap-3 px-3 py-2 text-xs`,children:[i(b,{className:`h-3.5 w-3.5 mt-0.5 shrink-0 text-foreground-subtle`}),e(`div`,{className:`flex-1 min-w-0 space-y-0.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`font-medium text-foreground truncate`,title:o.raw??void 0,children:o.label}),t.current&&i(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-[10px] font-medium text-primary`,children:a(`auth.sessionsList.thisDevice`,`This device`)})]}),e(`div`,{className:`flex flex-wrap gap-x-3 text-[11px] text-foreground-subtle`,children:[i(`span`,{children:ct(t.method)}),i(`span`,{className:`font-mono`,children:t.ip??a(`auth.sessionsList.ipUnknown`,`IP unknown`)}),i(`span`,{children:a(`auth.sessionsList.lastActive`,{when:lt(t.lastUsedAt)})}),i(`span`,{children:a(`auth.sessionsList.expires`,{when:lt(t.expiresAt)})})]})]}),!t.current&&e(`button`,{onClick:r,disabled:n,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[n?i(p,{className:`h-3 w-3 animate-spin`}):i(S,{className:`h-3 w-3`}),a(`auth.sessionsList.signOut`,`Sign out`)]})]})}export{me as A,He as C,Me as D,je as E,de as O,$e as S,Le as T,dt as _,Dt as a,lt as b,jt as c,Ot as d,Ft as f,pt as g,St as h,Et as i,he as k,Lt as l,Pt as m,Vt as n,Rt as o,Nt as p,Ht as r,Mt as s,Ut as t,At as u,ot as v,Ve as w,Qe as x,ct as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{at as i}from"./src-DaPCpXY_.js";import{P as a,cr as o,lr as s}from"./index-B5aMjANu.js";r();function c({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function l({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}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[r,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(c,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(c,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(l,{name:`primary`,cssVar:`--color-primary`}),t(l,{name:`background`,cssVar:`--color-background`}),t(l,{name:`surface`,cssVar:`--color-surface`}),t(l,{name:`foreground`,cssVar:`--color-foreground`}),t(l,{name:`success`,cssVar:`--color-success`}),t(l,{name:`warning`,cssVar:`--color-warning`}),t(l,{name:`danger`,cssVar:`--color-danger`}),t(l,{name:`info`,cssVar:`--color-info`}),t(l,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(l,{name:`onvif`,hex:`#3b82f6`}),t(l,{name:`hikvision`,hex:`#a855f7`}),t(l,{name:`reolink`,hex:`#06b6d4`}),t(l,{name:`ha`,hex:`#22d3ee`}),t(l,{name:`rtsp`,hex:`#78716c`})]})}),t(c,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(`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`}),t(`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`}),t(`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`}),t(`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`}),t(`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`}),t(`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`})]})}),t(c,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(`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...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(`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`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(`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:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(`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:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(`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})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(f,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`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=>t(`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))})]})]})}),t(c,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(i,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(s,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(c,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(c,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(o,{type:e,size:`lg`,showLabel:!0},e))})}),e(c,{title:`Form Builder Demo`,children:[t(a,{schema:u,values:r,onChange:d}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(r,null,2)})]})]}),t(c,{title:`Info Boxes`,children:t(`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:n,label:r,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`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function f(){let[e,r]=n(!0);return t(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(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:t(`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{C as e,S as t,Y as n,et as r}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{at as i}from"./src-BLJh-44s.js";import{P as a,cr as o,lr as s}from"./index-QtGtcmlM.js";r();function c({title:n,children:r}){return e(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[t(`div`,{className:`border-b border-border px-4 py-2.5`,children:t(`h2`,{className:`text-xs font-semibold text-foreground uppercase tracking-wider`,children:n})}),t(`div`,{className:`p-4`,children:r})]})}function l({name:n,cssVar:r,hex:i}){return e(`div`,{className:`flex flex-col items-center gap-1.5`,children:[t(`div`,{className:`h-10 w-10 rounded-lg border border-border shadow-inner`,style:{backgroundColor:r?`var(${r})`:i}}),t(`span`,{className:`text-[10px] text-foreground-subtle text-center leading-tight`,children:n})]})}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[r,d]=n({name:`Example`,count:10,enabled:!0,mode:`a`,tags:[`camera`],confidence:60});return e(`div`,{className:`p-6 space-y-6 max-w-5xl mx-auto`,children:[e(`div`,{className:`mb-6`,children:[t(`h1`,{className:`text-xl font-bold text-foreground`,children:`Component Showroom`}),t(`p`,{className:`text-sm text-foreground-subtle mt-1`,children:`All UI components at a glance`})]}),t(c,{title:`Typography`,children:e(`div`,{className:`space-y-3`,children:[t(`h1`,{className:`text-2xl font-bold text-foreground`,children:`Heading 1 — Display title`}),t(`h2`,{className:`text-xl font-semibold text-foreground`,children:`Heading 2 — Section title`}),t(`h3`,{className:`text-base font-semibold text-foreground`,children:`Heading 3 — Card title`}),t(`h4`,{className:`text-sm font-semibold text-foreground`,children:`Heading 4 — Sub-section`}),t(`p`,{className:`text-sm text-foreground`,children:`Body text — Regular paragraph content goes here. It uses the foreground color.`}),t(`p`,{className:`text-sm text-foreground-subtle`,children:`Subtle text — Secondary/descriptive text with reduced emphasis.`}),t(`p`,{className:`text-xs text-foreground-subtle uppercase tracking-wider font-semibold`,children:`Label / Caption`}),t(`p`,{className:`text-xs text-foreground-disabled`,children:`Disabled / placeholder text`})]})}),t(c,{title:`Colors`,children:e(`div`,{className:`flex flex-wrap gap-4`,children:[t(l,{name:`primary`,cssVar:`--color-primary`}),t(l,{name:`background`,cssVar:`--color-background`}),t(l,{name:`surface`,cssVar:`--color-surface`}),t(l,{name:`foreground`,cssVar:`--color-foreground`}),t(l,{name:`success`,cssVar:`--color-success`}),t(l,{name:`warning`,cssVar:`--color-warning`}),t(l,{name:`danger`,cssVar:`--color-danger`}),t(l,{name:`info`,cssVar:`--color-info`}),t(l,{name:`border`,cssVar:`--color-border`}),t(`div`,{className:`w-px`}),t(l,{name:`onvif`,hex:`#3b82f6`}),t(l,{name:`hikvision`,hex:`#a855f7`}),t(l,{name:`reolink`,hex:`#06b6d4`}),t(l,{name:`ha`,hex:`#22d3ee`}),t(l,{name:`rtsp`,hex:`#78716c`})]})}),t(c,{title:`Buttons`,children:e(`div`,{className:`flex flex-wrap gap-3`,children:[t(`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`}),t(`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`}),t(`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`}),t(`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`}),t(`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`}),t(`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`})]})}),t(c,{title:`Inputs`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Text input`}),t(`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...`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Number input`}),t(`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`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Password input`}),t(`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:`••••••••`})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Select`}),e(`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:[t(`option`,{children:`Option A`}),t(`option`,{children:`Option B`}),t(`option`,{children:`Option C`})]})]}),e(`div`,{className:`md:col-span-2`,children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Textarea`}),t(`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})]}),t(`div`,{children:e(`label`,{className:`flex items-center gap-2 cursor-pointer select-none`,children:[t(`input`,{type:`checkbox`,className:`h-3.5 w-3.5 rounded border-border accent-primary`,defaultChecked:!0}),t(`span`,{className:`text-xs font-medium text-foreground`,children:`Checkbox (checked)`})]})}),t(`div`,{children:e(`div`,{className:`flex items-center justify-between`,children:[t(`span`,{className:`text-xs font-medium text-foreground`,children:`Toggle switch`}),t(f,{})]})}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Slider`}),t(`input`,{type:`range`,className:`w-full h-1 accent-primary cursor-pointer`,min:0,max:100,defaultValue:60})]}),e(`div`,{children:[t(`label`,{className:`block text-xs font-medium text-foreground mb-1`,children:`Tags example`}),t(`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=>t(`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))})]})]})}),t(c,{title:`Badges`,children:e(`div`,{className:`space-y-3`,children:[e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`StatusBadge`}),t(`div`,{className:`flex flex-wrap gap-2`,children:[`running`,`stopped`,`error`,`online`,`offline`,`idle`].map(e=>t(i,{status:e},e))})]}),e(`div`,{children:[t(`p`,{className:`text-xs text-foreground-subtle mb-2`,children:`CapabilityBadges`}),t(s,{capabilities:[`streaming`,`detection`,`recording`,`audio`]})]})]})}),t(c,{title:`Cards`,children:e(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[e(`div`,{className:`rounded-lg bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Surface card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-surface`. Default card background."})]}),e(`div`,{className:`rounded-lg border border-border bg-surface p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Bordered card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `border border-border bg-surface`."})]}),e(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-primary mb-1`,children:`Accent card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:`Highlighted with primary color.`})]}),e(`div`,{className:`rounded-lg bg-background p-4`,children:[t(`h3`,{className:`text-sm font-semibold text-foreground mb-1`,children:`Background card`}),t(`p`,{className:`text-xs text-foreground-subtle`,children:"Uses `bg-background`. Inset card."})]})]})}),t(c,{title:`Provider Icons`,children:t(`div`,{className:`flex flex-wrap gap-4`,children:[`onvif`,`hikvision`,`reolink`,`homeassistant`,`rtsp`,`onvif`].map(e=>t(o,{type:e,size:`lg`,showLabel:!0},e))})}),e(c,{title:`Form Builder Demo`,children:[t(a,{schema:u,values:r,onChange:d}),e(`details`,{className:`mt-3`,children:[t(`summary`,{className:`text-[10px] text-foreground-subtle cursor-pointer hover:text-foreground`,children:`View current values`}),t(`pre`,{className:`mt-2 rounded-md bg-background p-3 text-[10px] text-foreground-subtle overflow-auto`,children:JSON.stringify(r,null,2)})]})]}),t(c,{title:`Info Boxes`,children:t(`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:n,label:r,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`}}[n];return e(`div`,{className:`rounded-md border-l-4 px-3 py-2.5 ${a.border} ${a.bg}`,children:[t(`p`,{className:`text-xs font-semibold mb-0.5 ${a.text}`,children:r}),t(`p`,{className:`text-xs text-foreground-subtle leading-relaxed`,children:i})]},n)})})})]})}function f(){let[e,r]=n(!0);return t(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:()=>r(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:t(`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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,K as t,R as n,S as r,V as i,Y as a,a as o,et as s,o as c,t as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{D as d,Di as f,Ei as p,En as m,Ht as h,Ti as g,Wr as _,_n as v,bi as y,br as b,ct as x,dt as S,fr as C,gn as w,jn as T,lr as ee,on as te,ot as E,pn as ne,sr as re,st as ie,xi as ae,zt as oe}from"./player-overlays-C0MwGGCz.js";import{oi as se}from"./client-CoTSmvjZ.js";import{i as ce}from"./video-6lAlm9YD.js";import{t as D}from"./key-round-CBNBBS9z.js";import{As as le,Bn as ue,Cn as de,Cs as fe,Ds as pe,Es as O,Ms as k,Os as me,Qu as A,Rn as he,Sn as j,Ss as ge,Tr as _e,Ts as ve,Vn as M,Yr as N,_r as P,ad as F,bn as ye,br as be,dr as xe,fr as Se,gr as Ce,hr as we,hu as Te,js as Ee,ks as De,mn as I,mr as Oe,ni as L,pd as R,pr as ke,vu as Ae,ws as je,xd as Me,xu as Ne,zn as z}from"./src-BLJh-44s.js";import{t as B}from"./i18n-D7mWXOH-.js";import{t as V}from"./useTranslation-BJr-n0es.js";import{S as Pe,T as Fe,gr as Ie,ur as Le}from"./index-QtGtcmlM.js";import{t as Re}from"./AdminSectionedPage-7l_b_UM1.js";import{t as H}from"./AdminPage-BdEQCHFs.js";import{t as ze}from"./NodeAddonsSettingsPanel-BDdBjBR6.js";import{t as Be}from"./AddonAssetIcon-DPfW-s0a.js";s();var Ve={detection:`border-green-500`,detector:`border-green-500`,streaming:`border-blue-500`,decode:`border-blue-500`,decoder:`border-blue-500`,recording:`border-orange-500`,recorder:`border-orange-500`,transcoding:`border-purple-500`,transcoder:`border-purple-500`,restream:`border-cyan-500`,restreamer:`border-cyan-500`,storage:`border-yellow-500`,notification:`border-pink-500`,notifier:`border-pink-500`,faces:`border-indigo-500`},He={detection:`bg-green-500/5`,detector:`bg-green-500/5`,streaming:`bg-blue-500/5`,decode:`bg-blue-500/5`,decoder:`bg-blue-500/5`,recording:`bg-orange-500/5`,recorder:`bg-orange-500/5`,transcoding:`bg-purple-500/5`,transcoder:`bg-purple-500/5`,restream:`bg-cyan-500/5`,restreamer:`bg-cyan-500/5`,storage:`bg-yellow-500/5`,notification:`bg-pink-500/5`,notifier:`bg-pink-500/5`,faces:`bg-indigo-500/5`};function Ue({entry:t,actions:n}){let i=t.name.toLowerCase(),a=Ve[i]??`border-primary`,o=He[i]??`bg-primary/5`,s=t.providers.find(e=>e.active),c=n?.pendingCapability===t.name;return e(`div`,{className:`rounded-lg border-t-2 border border-border ${a} ${o} p-3 space-y-2`,children:[e(`div`,{className:`flex items-center justify-between gap-2`,children:[e(`span`,{className:`text-xs font-semibold text-foreground capitalize flex items-center gap-1.5`,children:[t.name,c&&r(C,{className:`h-3 w-3 animate-spin text-primary`})]}),r(`span`,{className:`rounded-full px-2 py-0.5 text-[10px] font-medium ${t.mode===`singleton`?`bg-primary/10 text-primary`:`bg-info/10 text-info`}`,children:t.mode})]}),t.mode===`singleton`?r(We,{entry:t,actions:n,activeProvider:s,isPending:c}):r(Ge,{entry:t,actions:n,isPending:c})]})}function We({entry:t,actions:n,activeProvider:i,isPending:a}){let{t:o}=V();if(!n)return r(`div`,{children:i?e(`div`,{className:`flex items-center gap-1.5 text-[10px] text-foreground`,children:[r(y,{className:`h-3 w-3 text-green-400 shrink-0`}),r(`span`,{className:`font-medium`,children:i.addonName}),r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto`,children:`ACTIVE`})]}):r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noActiveProvider`,`No active provider`)})});if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:o(`addons.capabilityMap.noProviders`,`No providers`)});let s=`__inherit__`;return e(`div`,{className:`space-y-2`,children:[r(`div`,{className:`space-y-1`,children:t.providers.map(i=>{let o=i.active;return e(`button`,{type:`button`,disabled:a||o,onClick:()=>n.onSelectSingleton(t.name,i.addonId),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${o?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${o?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:i.addonName}),o&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},i.addonId)})}),t.perNode&&t.perNode.length>0&&r(`div`,{className:`space-y-2 pt-1 border-t border-border/40`,children:t.perNode.map(i=>{let c=i.hasOverride&&i.resolvedActive?i.resolvedActive:s,l=[{value:s,label:i.resolvedActive?o(`addons.capabilityMap.inheritGlobalWith`,{provider:i.resolvedActive}):o(`addons.capabilityMap.inheritGlobal`)},...i.providers.map(e=>({value:e,label:e}))],u=e=>{e===s?n.onClearNodeSingleton(t.name,i.nodeId):n.onSelectNodeSingleton(t.name,i.nodeId,e)},d=a;return e(`div`,{className:`space-y-0.5`,children:[e(`div`,{className:`text-[9px] font-semibold uppercase tracking-widest text-foreground-subtle/60 px-1.5`,children:[i.nodeId,i.hasOverride&&r(`span`,{className:`ml-1.5 rounded-full bg-primary/10 text-primary px-1 py-0.5 normal-case tracking-normal font-medium`,children:o(`common.override`)})]}),l.map(t=>{let n=c===t.value;return e(`button`,{type:`button`,disabled:d||n,onClick:()=>u(t.value),className:`flex w-full items-center gap-1.5 rounded px-1.5 py-1 text-[10px] text-left transition-colors ${n?`bg-green-500/10 text-foreground cursor-default`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground disabled:opacity-50`}`,children:[r(`span`,{className:`h-2.5 w-2.5 rounded-full border shrink-0 ${n?`border-green-400 bg-green-400`:`border-border`}`}),r(`span`,{className:`font-medium truncate`,children:t.label}),n&&t.value!==s&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium ml-auto shrink-0`,children:`ACTIVE`})]},t.value)})]},i.nodeId)})})]})}function Ge({entry:t,actions:n,isPending:i}){let{t:a}=V();if(t.providers.length===0)return r(`div`,{className:`text-[10px] text-foreground-subtle italic`,children:a(`addons.capabilityMap.noProviders`,`No providers`)});if(!n)return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`div`,{className:`flex items-center justify-between gap-2 text-[10px]`,children:[r(`span`,{className:`text-foreground-subtle`,children:t.addonName}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium`,children:`ACTIVE`})]},t.addonId))});let o=t.providers.filter(e=>e.active).map(e=>e.addonId),s=(e,r)=>{let i=r?[...new Set([...o,e])]:o.filter(t=>t!==e);n.onToggleCollection(t.name,i)};return r(`div`,{className:`space-y-1`,children:t.providers.map(t=>e(`label`,{className:`flex items-center justify-between gap-2 text-[10px] rounded px-1.5 py-1 transition-colors ${i?`opacity-50`:`hover:bg-surface-hover cursor-pointer`}`,children:[e(`span`,{className:`flex items-center gap-1.5 min-w-0`,children:[r(`input`,{type:`checkbox`,checked:t.active,disabled:i,onChange:e=>s(t.addonId,e.target.checked),className:`h-3 w-3 accent-green-500 shrink-0`}),r(`span`,{className:`text-foreground truncate`,children:t.addonName})]}),t.active&&r(`span`,{className:`rounded-full bg-green-500/10 text-green-400 px-1.5 py-0.5 font-medium shrink-0`,children:`ACTIVE`})]},t.addonId))})}function U({capabilities:e,actions:t}){let{t:n}=V();return e.length===0?r(`div`,{className:`text-xs text-foreground-subtle text-center py-8`,children:n(`addons.capabilityMap.noCapabilitiesRegistered`,`No capabilities registered`)}):r(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,children:e.map(e=>r(Ue,{entry:e,actions:t},e.name))})}var W=[`capabilities`,`listCapabilities`];function Ke(e){return e===`singleton`||e===`collection`}function qe(e){let t=e.indexOf(`@`);return t===-1?B.t(`system.capabilities.providerHub`,{addonId:e}):`${e.slice(0,t)} (${e.slice(t+1)})`}function Je(e,t){return{name:e.name,mode:t,providers:e.providers.map(n=>({addonId:n,addonName:qe(n),active:t===`singleton`?e.activeProvider===n:!e.disabledProviders.includes(n)})),...t===`singleton`&&e.perNode?{perNode:e.perNode}:{}}}function Ye(){let{t:n}=V(),i=S(),[s,c]=a(null),[u,d]=a(null),f=o({queryKey:W,queryFn:()=>i.trpcClient.capabilities.listCapabilities.query()}),p=t(()=>{let e=(f.data??[]).flatMap(e=>Ke(e.mode)?[Je(e,e.mode)]:[]),t=e.filter(e=>e.mode===`singleton`).toSorted((e,t)=>e.name.localeCompare(t.name)),n=e.filter(e=>e.mode===`collection`).toSorted((e,t)=>e.name.localeCompare(t.name));return[...t,...n]},[f.data]),m=t(()=>p.filter(e=>e.mode===`singleton`),[p]),h=t(()=>p.filter(e=>e.mode===`collection`),[p]),g=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:t.capName,addonId:t.addonId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSet`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),_=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToSetOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),v=l({mutationFn:e=>i.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:t.capName,nodeId:t.nodeId})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToClearOnNode`,{cap:t.capName,node:t.nodeId,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),b=l({mutationFn:e=>i.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),d(null)},onSuccess:async(e,t)=>{d({kind:`success`,message:n(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:t.capName,length:t.enabledAddonIds.length})}),await f.refetch()},onError:(e,t)=>{d({kind:`error`,message:n(`system.capabilities.failedToUpdate`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),x={onSelectSingleton:(e,t)=>g.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>_.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>v.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>b.mutate({capName:e,enabledAddonIds:t}),pendingCapability:s};return e(H,{embedded:!0,icon:te,title:n(`system.capabilities.capabilities`,`Capabilities`),subtitle:n(`system.capabilities.chooseWhichProviderIsActive`,`Choose which provider is active for each system capability. Singleton caps pick exactly one provider; collection caps enable a set.`),children:[u&&e(`div`,{className:`flex items-center gap-2 rounded-md border px-3 py-2 text-xs ${u.kind===`success`?`border-success/30 bg-success/10 text-success`:`border-danger/40 bg-danger/10 text-danger`}`,children:[u.kind===`success`?r(y,{className:`h-3.5 w-3.5 shrink-0`}):r(ae,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:u.message})]}),f.isLoading&&r(`div`,{className:`flex items-center justify-center py-16`,children:r(`div`,{className:`animate-spin h-6 w-6 border-2 border-primary border-t-transparent rounded-full`})}),f.isError&&!f.isLoading&&r(_e,{title:n(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:f.error instanceof Error?f.error.message:n(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void f.refetch()}),!f.isLoading&&!f.isError&&p.length===0&&r(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:n(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!f.isLoading&&!f.isError&&p.length>0&&e(`div`,{className:`space-y-6`,children:[m.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.singletonPickOneProvider`,`Singleton — pick one provider`)}),r(U,{capabilities:m,actions:x})]}),h.length>0&&e(`section`,{className:`space-y-2`,children:[r(`h2`,{className:`text-[11px] font-semibold uppercase tracking-widest text-foreground-subtle/70`,children:n(`system.capabilities.collectionEnableASet`,`Collection — enable a set`)}),r(U,{capabilities:h,actions:x})]})]})]})}var G=[`locked`,`reset`,`shares-backup`,`recovery-key`,`rotation-pending`,`orphans`],Xe={"key-missing":`helpers.keychainNotices.lockedKeyMissing`,"wrong-key":`helpers.keychainNotices.lockedWrongKey`,"key-file-unreadable":`helpers.keychainNotices.lockedKeyFileUnreadable`,"store-unavailable":`helpers.keychainNotices.lockedStoreUnavailable`,"not-initialized":`helpers.keychainNotices.lockedNotInitialized`,"decrypt-failed":`helpers.keychainNotices.lockedDecryptFailed`};function Ze(e){let t=Xe[e];return t===void 0?e:B.t(t)}function Qe({status:e,reset:t,pendingReentry:n,orphans:r}){let i=e.keychain.state===`locked`,a=e.keySource??e.configuredSource,o=[];return e.keychain.state===`locked`&&o.push({id:`locked`,tone:`danger`,title:B.t(`helpers.keychainNotices.locked`,{reason:Ze(e.keychain.reason)})}),t!==null&&t.acknowledgedAt===null&&o.push({id:`reset`,tone:`danger`,title:n>0?B.t(`helpers.keychainNotices.resetPending`,{count:n}):B.t(`helpers.keychainNotices.resetDone`)}),a.sharesBackupWithDatabase&&o.push({id:`shares-backup`,tone:`warning`,title:B.t(`helpers.keychainNotices.sharesBackup`)}),!i&&e.recoveryKeyDownloadedAt===null&&o.push({id:`recovery-key`,tone:`warning`,title:B.t(`helpers.keychainNotices.recoveryKey`)}),!i&&e.rotationPending&&o.push({id:`rotation-pending`,tone:`info`,title:B.t(`helpers.keychainNotices.rotationPending`)}),!i&&r>0&&o.push({id:`orphans`,tone:`info`,title:B.t(`helpers.keychainNotices.orphans`,{count:r})}),[...o].sort((e,t)=>G.indexOf(e.id)-G.indexOf(t.id))}var $e={dateStyle:`short`,timeStyle:`short`};function K(e){return e===null?`—`:new Date(e).toLocaleString(void 0,$e)}function q({value:t,copyValue:n,srLabel:i,maxWidthClass:a,className:o}){let s=n??t;return e(`span`,{className:R(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:R(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(I,{value:s,srLabel:i,className:`h-6 shrink-0 px-1.5`})]})}s();var et=new Set([`reveal`,`download-recovery-key`,`rotate-master-key`,`reset`]);function tt(e){return[{key:`at`,header:e(`system.keychainAuditTable.colWhen`),render:e=>K(e.at)},{key:`action`,header:e(`system.keychainAuditTable.colAction`),render:e=>r(L,{variant:et.has(e.action)?`warning`:`default`,children:e.action})},{key:`actor`,header:e(`system.keychainAuditTable.colActor`),render:e=>r(`span`,{className:`font-mono`,children:e.actor})},{key:`ref`,header:e(`system.keychainAuditTable.colRef`),render:e=>e.ref===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):r(q,{value:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[22rem]`})},{key:`detail`,header:e(`system.keychainAuditTable.colDetail`),render:e=>r(`span`,{className:`text-foreground-muted`,children:e.detail??``})}]}function nt({entries:n}){let{t:i}=V(),[o,s]=a(0),c=t(()=>tt(i),[i]);if(n===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:i(`common.loading`,`Loading…`)});let l=Math.max(1,Math.ceil(n.length/25)),u=Math.min(o,l-1),d=u*25,f=n.slice(d,d+25);return e(`div`,{className:`space-y-2`,children:[r(j,{columns:c,rows:f,rowKey:e=>e.id,minWidthPx:760,emptyMessage:i(`secrets.keychainAuditTable.nothingHasBeenAuditedYet`,`Nothing has been audited yet.`)}),n.length>25&&e(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-[11px] text-foreground-subtle`,children:[r(`span`,{children:i(n.length>=500?`system.keychainAuditTable.rangeRecent`:`system.keychainAuditTable.range`,{from:d+1,to:d+f.length,total:n.length})}),e(`span`,{className:`inline-flex items-center gap-1`,children:[r(N,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(N,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function rt(e,t){switch(e){case`locked`:return r(N,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:B.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:B.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:B.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(N,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:B.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(N,{size:`sm`,variant:`outline`,onClick:t.onShowOrphans,children:B.t(`secrets.keychainNoticeContent.review`,`Review`)});case`shares-backup`:return null}}function it(e,t){switch(e){case`locked`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.noValueCanBeRead`,`No value can be read or stored. If the master key is lost for good, Reset archives every stored value and starts a new keychain; every secret field then reads “not set”.`)});case`reset`:return t.reset===null?null:r(at,{reset:t.reset,pending:t.pendingReentry});case`shares-backup`:return r(`p`,{children:r(Le,{i18nKey:`secrets.keychainNoticeContent.backupKeyFile`,components:{code:r(`code`,{className:`font-mono`})}})});case`recovery-key`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.withoutACopyOfThe`,`Without a copy of the master key, the stored values cannot be recovered.`)});case`rotation-pending`:return r(`p`,{children:B.t(`secrets.keychainNoticeContent.theKeychainUnlockedWithA`,`The keychain unlocked with a previous key. Rotate to move onto the configured one.`)});case`orphans`:return null}}function at({reset:t,pending:n}){let{t:i}=V(),a=t.actor===`trigger-file`?i(`secrets.keychainNoticeContent.resetByTrigger`):i(`secrets.keychainNoticeContent.resetByAdmin`,{actor:t.actor});return e(`div`,{className:`space-y-1.5`,children:[r(`p`,{children:i(`secrets.keychainNoticeContent.resetDetail`,{when:K(t.at),by:a,archived:t.archived})}),n.length>0&&r(`ul`,{className:`max-h-40 space-y-0.5 overflow-y-auto rounded-md border border-border bg-background p-2 font-mono text-[11px] text-foreground`,children:n.map(t=>e(`li`,{className:`break-all`,children:[t.owner,` · `,t.scope,` · `,t.fieldPath]},t.ref))})]})}s();var ot=2,J={danger:{icon:ce,text:`text-danger`,border:`border-danger/40`},warning:{icon:oe,text:`text-warning`,border:`border-warning/40`},info:{icon:b,text:`text-info`,border:`border-border`}};function st({notices:t,renderAction:n,renderDetail:i}){let{t:o}=V(),[s,c]=a(!1),l=t[0];if(l===void 0)return null;let u=t.length>ot,d=u&&!s?t.slice(0,1):t,p=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:R(`rounded-lg border bg-surface`,J[l.tone].border),children:[r(`ul`,{className:`divide-y divide-border`,children:d.map(e=>r(ct,{notice:e,action:n(e.id),detail:i(e.id)},e.id))}),u&&r(`div`,{className:`border-t border-border px-3 py-1`,children:e(N,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(f,{className:R(`h-3.5 w-3.5 transition-transform`,s&&`rotate-180`),"aria-hidden":!0}),s?o(`secrets.keychainNotices.showLess`,`Show less`):o(`secrets.keychainNotices.more`,`{{hidden}} more`,{hidden:p})]})})]})}function ct({notice:t,action:n,detail:i}){let{t:o}=V(),[s,c]=a(!1),l=J[t.tone],u=l.icon,d=i!=null,f=`keychain-notice-${t.id}`;return e(`li`,{className:`px-3 py-2`,children:[e(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[e(`p`,{className:`flex min-w-0 flex-1 items-start gap-2 text-xs text-foreground`,children:[r(u,{className:R(`mt-0.5 h-3.5 w-3.5 shrink-0`,l.text),"aria-hidden":!0}),r(`span`,{className:`min-w-0 break-words`,children:t.title})]}),e(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 pl-5 sm:pl-0`,children:[d&&r(N,{size:`sm`,variant:`ghost`,"aria-expanded":s,"aria-controls":f,onClick:()=>c(e=>!e),children:o(`secrets.keychainNotices.details`,`Details`)}),n]})]}),d&&s&&r(`div`,{id:f,className:`mt-2 pl-5 text-xs text-foreground-muted`,children:i})]})}var lt={"config-file":`Key file (config.yaml)`,"previous-config-file":`Previous key file`,platform:`OS keychain`,"default-file":`Default key file (data volume)`},ut=8;function dt({status:t,busy:n,onDownload:i,onRotate:a,onPurge:o}){let{t:s}=V(),c=t.keychain.state===`locked`,l=t.keySource??t.configuredSource;return r(ye,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:D,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(N,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(N,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(N,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${d} grid grid-cols-1 gap-x-6 gap-y-3 sm:grid-cols-2 xl:grid-cols-4`,children:[e(Y,{label:s(`secrets.keychainStatusCard.state`,`State`),children:[c?e(L,{variant:`danger`,className:`gap-1`,children:[r(ee,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.locked`,`Locked`)]}):e(L,{variant:`success`,className:`gap-1`,children:[r(ne,{className:`h-3 w-3`,"aria-hidden":!0}),s(`secrets.keychainStatusCard.unlocked`,`Unlocked`)]}),r(`span`,{className:`ml-2 text-foreground-subtle`,children:s(`common.stored`,{count:t.secretCount})})]}),e(Y,{label:s(`secrets.keychainStatusCard.keySource`,`Key source`),children:[r(`span`,{className:`block`,children:lt[l.kind]}),l.path!==void 0&&r(q,{value:l.path,srLabel:`key path`})]}),r(Y,{label:s(`secrets.keychainStatusCard.fingerprint`,`Fingerprint`),children:t.fingerprint===null?r(`span`,{className:`text-foreground-subtle`,children:`—`}):e(`span`,{className:`inline-flex items-center gap-0.5`,children:[r(`span`,{className:`font-mono`,title:t.fingerprint,children:t.fingerprint.slice(0,ut)}),r(I,{value:t.fingerprint,srLabel:`fingerprint`})]})}),r(Y,{label:s(`secrets.keychainStatusCard.recoveryKey`,`Recovery key`),children:t.recoveryKeyDownloadedAt===null?r(L,{variant:`warning`,children:s(`secrets.keychainStatusCard.notTaken`,`Not taken`)}):r(`span`,{children:s(`secrets.keychainStatusCard.taken`,{when:K(t.recoveryKeyDownloadedAt)})})})]})})}function Y({label:t,children:n}){return e(`div`,{className:`min-w-0 text-xs`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`mt-0.5 min-w-0 text-foreground`,children:n})]})}s();var ft=1e3;function pt({revealed:t,onClose:n}){let{t:o}=V(),[s,c]=a(A);i(()=>{if(t===null)return;let e=Date.now();c(A);let r=setTimeout(n,A),i=setInterval(()=>c(Math.max(0,A-(Date.now()-e))),ft);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let l=Math.ceil(s/1e3);return r(xe,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(ke,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(u,{children:[e(Ce,{children:[r(P,{className:`break-all`,children:t.entry.fieldPath}),e(Oe,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(Se,{children:r(`pre`,{"data-testid":`revealed-value`,className:`whitespace-pre-wrap break-all rounded-md border border-border bg-background p-3 font-mono text-xs text-foreground`,children:t.value})}),e(we,{className:`flex-col items-stretch gap-2 sm:flex-row sm:items-center sm:justify-between`,children:[r(`p`,{className:`text-[11px] text-foreground-subtle`,children:o(`secrets.revealDialog.recorded`,{seconds:l})}),e(`div`,{className:`flex justify-end gap-2`,children:[r(I,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(N,{size:`sm`,variant:`outline`,onClick:n,children:o(`secrets.revealDialog.hide`,`Hide`)})]})]})]})})})}var X={orphan:{labelKey:`secrets.secretsTableState.usageOrphan`,variant:`warning`,hintKey:`secrets.secretsTableState.usageOrphanHint`,rank:0},unknown:{labelKey:`secrets.secretsTableState.usageUnknown`,variant:`default`,hintKey:`secrets.secretsTableState.usageUnknownHint`,rank:1},"in-use":{labelKey:`secrets.secretsTableState.usageInUse`,variant:`success`,hintKey:`secrets.secretsTableState.usageInUseHint`,rank:2}},mt=[{id:`all`,labelKey:`common.all`},{id:`in-use`,labelKey:`secrets.secretsTableState.usageInUse`},{id:`orphan`,labelKey:`secrets.secretsTableState.filterOrphans`},{id:`unknown`,labelKey:`secrets.secretsTableState.usageUnknown`}],Z=`system`;function ht(t){let{t:n}=V(),{secrets:i,filter:a,onFilterChange:o,onDeleteOrphans:s,deleting:c,locked:l}=t;if(i===void 0)return r(`p`,{className:`text-xs text-foreground-subtle`,children:n(`common.loading`,`Loading…`)});let u=e=>e===`all`?i.length:i.filter(t=>t.usage===e).length,d=i.filter(e=>e.usage===`orphan`).map(e=>e.ref),f=a===`all`?i:i.filter(e=>e.usage===a);return e(`div`,{className:`space-y-2`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[r(`div`,{className:`flex flex-wrap gap-1`,role:`group`,"aria-label":n(`secrets.secretsTable.filterByUsage`,`Filter by usage`),children:mt.map(t=>e(N,{size:`sm`,variant:a===t.id?`secondary`:`ghost`,"aria-pressed":a===t.id,className:a===t.id?`ring-1 ring-border`:void 0,onClick:()=>o(t.id),children:[n(t.labelKey),r(`span`,{className:`text-foreground-subtle tabular-nums`,children:u(t.id)})]},t.id))}),d.length>0&&e(N,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(h,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(j,{columns:_t(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:de,defaultSort:{columnKey:`owner`,dir:`asc`},emptyMessage:i.length===0?n(`secrets.secretsTable.noValueIsStoredIn`,`No value is stored in the keychain yet.`):n(`secrets.secretsTable.noStoredValueMatchesThis`,`No stored value matches this filter.`)})]})}function gt({owner:t}){let{t:n}=V();return e(`span`,{className:`flex items-center gap-2`,children:[r(Be,{addonId:t,fallback:t===Z?v:T,tileClassName:`bg-surface-hover text-foreground-subtle`,size:`sm`}),r(`span`,{className:`font-medium`,children:t===Z?n(`secrets.secretsTable.hubSystem`,`Hub (system)`):t})]})}function _t({locked:t,onReveal:n,revealing:i}){return[{key:`owner`,header:B.t(`secrets.secretsTable.owner`,`Owner`),render:e=>r(gt,{owner:e.owner}),sortValue:e=>e.owner},{key:`scope`,header:B.t(`secrets.secretsTable.scope`,`Scope`),render:e=>r(`span`,{className:`block max-w-[11rem] truncate font-mono`,title:e.scope,children:e.scope}),sortValue:e=>e.scope},{key:`field`,header:B.t(`secrets.secretsTable.field`,`Field`),render:e=>r(q,{value:e.fieldPath,copyValue:e.ref,srLabel:`secret ref`,maxWidthClass:`max-w-[16rem]`}),sortValue:e=>e.fieldPath},{key:`updated`,header:B.t(`secrets.secretsTable.updated`,`Updated`),render:e=>K(e.updatedAt),sortValue:e=>e.updatedAt},{key:`last-read`,header:B.t(`secrets.secretsTable.lastRead`,`Last read`),render:e=>K(e.lastReadAt),sortValue:e=>e.lastReadAt},{key:`status`,header:B.t(`secrets.secretsTable.status`,`Status`),render:e=>r(L,{variant:X[e.usage].variant,title:B.t(X[e.usage].hintKey),children:B.t(X[e.usage].labelKey)}),sortValue:e=>X[e.usage].rank},{key:`actions`,header:``,align:`right`,notSortableReason:`Actions`,render:a=>e(N,{size:`sm`,variant:`ghost`,disabled:t||i,"aria-label":B.t(`secrets.secretsTable.reveal`,`Reveal {{fieldPath}}`,{fieldPath:a.fieldPath}),title:t?B.t(`secrets.secretsTable.theKeychainIsLocked`,`The keychain is locked`):B.t(`secrets.secretsTable.revealAudited`,`Reveal (audited)`),onClick:()=>n(a),children:[r(_,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),B.t(`secrets.secretsTable.reveal2`,`Reveal`)]})}]}function vt(e){return e instanceof Error?e.message:String(e)}function yt(e){let{t}=V(),n=ie(),r=E(),i=x(),a=je(),o=Ee(),s=pe(),c=me(),l=ge(),u=fe(),d=async(t,n)=>{try{await n()}catch(e){await r({title:t,message:vt(e),variant:`danger`})}e()};return{busy:a.isPending||o.isPending||s.isPending||c.isPending,deleting:u.isPending,download:async()=>{await n({title:t(`secrets.useKeychainActions.downloadTitle`),message:t(`secrets.useKeychainActions.downloadMessage`),confirmLabel:t(`secrets.useKeychainActions.downloadConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.downloadRefused`),async()=>{let e=await a.mutateAsync({});await i({title:t(`secrets.useKeychainActions.recoveryTitle`,{fingerprint:e.fingerprint}),message:t(`secrets.useKeychainActions.recoveryMessage`),defaultValue:e.key,readOnly:!0,confirmLabel:t(`secrets.useKeychainActions.recoveryDone`)})})},rotate:async()=>{await n({title:t(`secrets.useKeychainActions.rotateTitle`),message:t(`secrets.useKeychainActions.rotateMessage`),confirmLabel:t(`secrets.useKeychainActions.rotateConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.rotateRefused`),async()=>{let e=await o.mutateAsync({});await r({title:t(`secrets.useKeychainActions.rotatedTitle`),message:t(`secrets.useKeychainActions.rotatedMessage`,{fingerprint:e.fingerprint})})})},purge:async()=>{await n({title:t(`secrets.useKeychainActions.purgeTitle`),message:t(`secrets.useKeychainActions.purgeMessage`),confirmLabel:t(`secrets.useKeychainActions.purgeConfirm`),variant:`warning`})&&await d(t(`secrets.useKeychainActions.purgeRefused`),async()=>{await s.mutateAsync({})})},reset:async()=>{await i({title:t(`secrets.useKeychainActions.resetTitle`),message:t(`secrets.useKeychainActions.resetMessage`,{confirmation:`RESET KEYCHAIN`}),confirmLabel:t(`secrets.useKeychainActions.resetConfirm`),validate:e=>e===`RESET KEYCHAIN`?null:t(`secrets.useKeychainActions.resetMismatch`)})===`RESET KEYCHAIN`&&await d(t(`secrets.useKeychainActions.resetRefused`),async()=>{await c.mutateAsync({confirm:se})})},acknowledgeReset:async()=>{await d(t(`secrets.useKeychainActions.dismissFailed`),async()=>{await l.mutateAsync({})})},deleteOrphans:async e=>{await n({title:t(`secrets.useKeychainActions.orphansTitle`,{count:e.length}),message:t(`secrets.useKeychainActions.orphansMessage`),confirmLabel:t(`secrets.useKeychainActions.orphansConfirm`),variant:`danger`})&&await d(t(`secrets.useKeychainActions.orphansRefused`),async()=>{let n=await u.mutateAsync({refs:[...e]});n.kept.length>0&&await r({title:t(`secrets.useKeychainActions.keptTitle`),message:t(`secrets.useKeychainActions.keptMessage`,{deleted:n.deleted.length,kept:n.kept.length})})})}}}s();var Q=`view`;function bt(){let[e,t]=Ie();return[e.get(Q)===`audit`?`audit`:`values`,n=>{let r=new URLSearchParams(e);n===`values`?r.delete(Q):r.set(Q,n),t(r,{replace:!0})}]}function xt(){let{t:i}=V(),o=k({}),s=O({}),c=ve({limit:500}),l=De({}),u=le(),d=E(),[f,p]=bt(),[m,h]=a(`all`),[g,_]=a(null),v=yt(()=>{o.refetch(),s.refetch(),c.refetch(),l.refetch()}),y=o.data?.keychain.state===`locked`,b=t(()=>(s.data??[]).filter(e=>e.usage===`orphan`).length,[s.data]),x=t(()=>o.data===void 0?[]:Qe({status:o.data,reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry.length??0,orphans:b}),[o.data,l.data,b]),S={reset:l.data?.reset??null,pendingReentry:l.data?.pendingReentry??[],busy:v.busy,onReset:()=>void v.reset(),onAcknowledgeReset:()=>void v.acknowledgeReset(),onDownload:()=>void v.download(),onRotate:()=>void v.rotate(),onShowOrphans:()=>{h(`orphan`),p(`values`)}},C=async e=>{try{_({entry:e,value:(await u.mutateAsync({ref:e.ref})).value}),s.refetch()}catch(e){await d({title:i(`admin.system.secrets.revealRefused`,`Reveal refused`),message:Fe(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(H,{embedded:!0,icon:D,title:i(`admin.system.secrets.secrets`,`Secrets`),subtitle:i(`admin.system.secrets.passwordsTokensAndKeysEncrypted`,`Passwords, tokens and keys, encrypted in the hub keychain. Values leave the hub only through an audited reveal.`),children:[r(st,{notices:x,renderAction:e=>rt(e,S),renderDetail:e=>it(e,S)}),o.data!==void 0&&r(dt,{status:o.data,busy:v.busy,onDownload:S.onDownload,onRotate:S.onRotate,onPurge:()=>void v.purge()}),e(he,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(ue,{children:[r(M,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(M,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(z,{value:`values`,children:r(ht,{secrets:s.data,locked:y,filter:m,onFilterChange:h,onReveal:e=>void C(e),revealing:u.isPending,onDeleteOrphans:e=>void v.deleteOrphans(e),deleting:v.deleting})}),r(z,{value:`audit`,children:r(nt,{entries:c.data})})]}),r(pt,{revealed:g,onClose:w})]})}s();var St=[[`system`]];function $(e){return e.toFixed(6).replace(/0+$/,``).replace(/\.$/,``)}function Ct(){let{t}=V(),n=c(),o=Ae(),s=Ne(),l=Te(),[u,d]=a(``),[f,p]=a(``),[h,g]=a(null),_=o.data?.location??null;i(()=>{d(_===null?``:$(_.latitude)),p(_===null?``:$(_.longitude))},[_]);let v=async()=>{await n.invalidateQueries({queryKey:St})},y=async e=>{e.preventDefault();let t=Number(u),n=Number(f);if(u.trim()===``||f.trim()===``){g(`Enter both a latitude and a longitude, or press Clear.`);return}if(!Number.isFinite(t)||t<-90||t>90){g(`Latitude must be between -90 and 90 decimal degrees.`);return}if(!Number.isFinite(n)||n<-180||n>180){g(`Longitude must be between -180 and 180 decimal degrees.`);return}g(null),await s.mutateAsync({latitude:t,longitude:n}),await v()},b=async()=>{g(null),await s.mutateAsync(null),await v()},x=async()=>{g(null),await l.mutateAsync(),await v()},S=s.isPending||l.isPending||o.isLoading;return e(be,{className:`space-y-3`,children:[e(`div`,{className:`flex items-start justify-between gap-3`,children:[e(`div`,{className:`flex items-start gap-2`,children:[r(re,{className:`h-4 w-4 mt-0.5 text-muted-foreground shrink-0`}),r(`div`,{children:r(`h3`,{className:`text-sm font-medium`,children:t(`settings.siteLocationCard.siteLocation`,`Site location`)})})]}),_===null?r(L,{variant:`warning`,children:t(`settings.siteLocationCard.notConfigured`,`Not configured`)}):r(L,{variant:_.source===`operator-set`?`success`:`info`,children:_.source===`operator-set`?t(`settings.siteLocationCard.setByYou`,`Set by you`):t(`settings.siteLocationCard.derivedFromIp`,`Derived from IP`)})]}),_?.label!==void 0&&_.label!==``?r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.detectedNear`,{place:_.label})}):null,_===null&&o.data?.derivationAttemptedAt!==null?e(`p`,{className:`text-xs text-warning`,children:[t(`settings.siteLocationCard.automaticDetectionFromThePublic`,`Automatic detection from the public IP did not succeed`),o.data?.derivationError!==null&&o.data?.derivationError!==void 0?`: ${o.data.derivationError}`:`.`,` `,t(`settings.siteLocationCard.itIsNotRetriedOn`,`It is not retried on its own — enter the coordinates, or press Detect.`)]}):null,e(`form`,{className:`flex flex-wrap items-end gap-3`,onSubmit:y,children:[e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.latitude`,`Latitude`)}),r(F,{className:`w-40`,value:u,inputMode:`decimal`,placeholder:`40.851800`,onChange:e=>d(e.target.value),"aria-label":t(`settings.siteLocationCard.latitude`,`Latitude`)})]}),e(`label`,{className:`flex flex-col gap-1 text-xs`,children:[r(`span`,{className:`text-muted-foreground`,children:t(`settings.siteLocationCard.longitude`,`Longitude`)}),r(F,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),r(N,{type:`submit`,disabled:S,children:t(`common.save`,`Save`)}),e(N,{type:`button`,variant:`ghost`,disabled:S,onClick:x,children:[r(m,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),_===null?null:r(N,{type:`button`,variant:`ghost`,disabled:S,onClick:b,children:t(`settings.siteLocationCard.clear`,`Clear`)})]}),h===null?null:r(`p`,{className:`text-xs text-danger`,children:h}),r(`p`,{className:`text-xs text-muted-foreground`,children:t(`settings.siteLocationCard.wgs84DecimalDegreesDetectAsks`,`WGS84 decimal degrees. Detect asks a public geo-IP service once and will not overwrite a value you typed — clear it first.`)})]})}function wt(){let{t}=V(),{nodes:n,isLoading:i}=Me(),a=n.find(e=>e.isHub&&e.isOnline),o=a?.addons.map(e=>e.addonId)??[];return e(H,{embedded:!0,children:[r(Ct,{}),i?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.loadingHubTopology`,`Loading hub topology…`)}):a?o.length===0?r(`div`,{className:`text-muted-foreground text-sm py-12 text-center`,children:t(`admin.system.settings.noAddonsInstalledOnThe`,`No addons installed on the hub yet.`)}):r(ze,{nodeId:a.id,addonIds:o,level:`global`}):e(`div`,{className:`flex flex-col items-center justify-center text-muted-foreground text-sm gap-2 py-12`,children:[r(w,{className:`h-8 w-8 opacity-30`}),r(`p`,{children:t(`admin.system.settings.noOnlineHubNodeFound`,`No online hub node found.`)}),r(`p`,{className:`text-xs`,children:t(`admin.system.settings.settingsWillAppearOnceThe`,`Settings will appear once the hub is reachable.`)})]})]})}function Tt(){let{t:e}=V(),t=Pe(`/system/settings`,{t:e,isAdmin:!0})??{icon:w,title:e(`system.systemNav`,`System`)};return r(Re,{icon:t.icon,title:t.title,defaultSection:`settings`,sectionsLabel:`${t.title} sections`,sections:[{id:`settings`,label:e(`system.system.settings`,`Settings`),content:r(wt,{})},{id:`secrets`,label:e(`system.system.secrets`,`Secrets`),content:r(xt,{}),ownedParams:[`view`]},{id:`capabilities`,label:e(`system.system.capabilities`,`Capabilities`),content:r(Ye,{})}]})}export{Tt as SystemPage};
|