@camstack/addon-admin-ui 1.2.526 → 1.2.527

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.
Files changed (148) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/assets/{AddonAssetIcon-Bk09xHqf.js → AddonAssetIcon-BZ0hQcho.js} +1 -1
  3. package/dist/assets/Addons-BAqAfY0r.js +5 -0
  4. package/dist/assets/{AdminPage-CYSYefaL.js → AdminPage-7avIuDBh.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-B4MRvqE8.js → AdminSectionedPage-Bd2owMGm.js} +1 -1
  6. package/dist/assets/AiProfiles-aCDtxD2T.js +3 -0
  7. package/dist/assets/BrokerEditorDialog-Cp7neyJC.js +1 -0
  8. package/dist/assets/Build-SObpGxas.js +40 -0
  9. package/dist/assets/{Calendars-D4ed6Nqc.js → Calendars-B2TORAnq.js} +1 -1
  10. package/dist/assets/Cluster-CD4DYic_.js +1 -0
  11. package/dist/assets/{ComposedDeviceEditDialog-DJ5mqI6C.js → ComposedDeviceEditDialog-BiIiBFG-.js} +1 -1
  12. package/dist/assets/CompositionBlockEditor-BXYXXUEU.js +2 -0
  13. package/dist/assets/{CompositionEditorPage-4rHclFIA.js → CompositionEditorPage-Cm4C-7Z-.js} +1 -1
  14. package/dist/assets/Data-CRPVPhFT.js +2 -0
  15. package/dist/assets/{DeviceDetail-3jKJ80IC.js → DeviceDetail-DNsWQGiy.js} +2 -2
  16. package/dist/assets/{DeviceDoActionFields-1jte2ge2.js → DeviceDoActionFields-BEhy6_KW.js} +1 -1
  17. package/dist/assets/{Devices-Bq4yRli5.js → Devices-CS5P4d9n.js} +1 -1
  18. package/dist/assets/{EmbedPlayerPage-DlIQigBi.js → EmbedPlayerPage-B7MIw7cv.js} +1 -1
  19. package/dist/assets/History-BbOfWf-p.js +1 -0
  20. package/dist/assets/Identity-Df140-fX.js +1 -0
  21. package/dist/assets/IntegrationDetail-B7sqZ94w.js +1 -0
  22. package/dist/assets/{IntegrationHub-8GCewFBs.js → IntegrationHub-DndCuqMe.js} +1 -1
  23. package/dist/assets/Integrations-BJh_WZAT.js +1 -0
  24. package/dist/assets/{Integrations-Bt3Im7Mh.js → Integrations-DRCpstaG.js} +1 -1
  25. package/dist/assets/{Library-DTn9Nkjs.js → Library-Cx17_SRL.js} +1 -1
  26. package/dist/assets/Locations-Dt9LOu5v.js +3 -0
  27. package/dist/assets/{Logs-BxTfJ-wk.js → Logs-CrxQn3Uq.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-DBEbXuH2.js → MaskShapeCanvas-tJyuoOTy.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-D3Xxjf5N.js → MotionZonesSettings-DaGyceJa.js} +1 -1
  30. package/dist/assets/{MyAccess-BTEJNJtS.js → MyAccess-Bp2dsON4.js} +1 -1
  31. package/dist/assets/Network-DftlNAIH.js +1 -0
  32. package/dist/assets/{NodeAddonsSettingsPanel-Do_I93Mx.js → NodeAddonsSettingsPanel-JIXh-CLX.js} +1 -1
  33. package/dist/assets/Notifications-2tj0VaIS.js +1 -0
  34. package/dist/assets/{Pipeline-Cjj8XOuS.js → Pipeline-CqZqLWQZ.js} +1 -1
  35. package/dist/assets/{PrivacyMaskSettings-CswE6pks.js → PrivacyMaskSettings-zzQcpeb0.js} +1 -1
  36. package/dist/assets/Recordings-DoAJqZqc.js +1 -0
  37. package/dist/assets/{RemoteGrid-BjtzHkpg.js → RemoteGrid-Bz_u9tq6.js} +1 -1
  38. package/dist/assets/ScanNetworkModal-DL-mWRtG.js +1 -0
  39. package/dist/assets/{SceneMonitorEditor-C2X6jZvS.js → SceneMonitorEditor-B0ICySEi.js} +1 -1
  40. package/dist/assets/SessionsList-QvqpXCDN.js +2 -0
  41. package/dist/assets/{Showroom-CHwcC6p6.js → Showroom-B6CDELO1.js} +1 -1
  42. package/dist/assets/System-C0KUcOaJ.js +1 -0
  43. package/dist/assets/{Templates-tilFwunF.js → Templates-uAAxbV9V.js} +1 -1
  44. package/dist/assets/{Terminal-DiMnsE8i.js → Terminal-D1fhPY66.js} +5 -5
  45. package/dist/assets/{Viewer-BwirleAM.js → Viewer-BWN8qfBa.js} +1 -1
  46. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-w6FCrjgB.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-sshFQYnL.js} +1 -1
  47. package/dist/assets/{addon-icons-context-CHk3ePjj.js → addon-icons-context-BHF-RdY-.js} +1 -1
  48. package/dist/assets/{archive-BU_eXxQC.js → archive-2V-x_y9T.js} +1 -1
  49. package/dist/assets/{assignment-candidates-B4bOK7k8.js → assignment-candidates-BpC51VXR.js} +1 -1
  50. package/dist/assets/{authed-media-BYuQnqbF.js → authed-media-CdbbdgDZ.js} +1 -1
  51. package/dist/assets/{bell-off-DCQedZIx.js → bell-off-DDQ8FbF1.js} +1 -1
  52. package/dist/assets/{board-model-t0EX_kXW.js → board-model-D3wYwuI4.js} +1 -1
  53. package/dist/assets/{boxes-BZMO9uMf.js → boxes-BwEV9Act.js} +1 -1
  54. package/dist/assets/circle-slash-BjzSCz4-.js +1 -0
  55. package/dist/assets/client-r4i0EpF6.js +711 -0
  56. package/dist/assets/{cloud-upload-CApwQ18P.js → cloud-upload-BII8r4p9.js} +1 -1
  57. package/dist/assets/crop-D9cpl5_W.js +1 -0
  58. package/dist/assets/{device-integration-icon-CXG5v8dp.js → device-integration-icon-Cf2JTj5q.js} +1 -1
  59. package/dist/assets/device-picker-model-B_Zjyqyk.js +1 -0
  60. package/dist/assets/{dist-Hz1nnJDv.js → dist-B0LFF94V.js} +1 -1
  61. package/dist/assets/dist-BOdjk8IV.js +711 -0
  62. package/dist/assets/{file-up-cso0QIDs.js → file-up-Bizrs9Ca.js} +1 -1
  63. package/dist/assets/{format-Csy9sDox.js → format-Bqo-j708.js} +1 -1
  64. package/dist/assets/{grip-vertical-DqjjXK1h.js → grip-vertical-C-qhB3oM.js} +1 -1
  65. package/dist/assets/{hard-drive-download-D-ykdsm5.js → hard-drive-download-Dym9jihx.js} +1 -1
  66. package/dist/assets/{hostInit-CTFssGi8.js → hostInit-bmlgmSTk.js} +1 -1
  67. package/dist/assets/i18n-BE1bPZOs.js +1 -0
  68. package/dist/assets/icons-BZ8D05w2.js +1 -0
  69. package/dist/assets/index-DimGtYV1.css +2 -0
  70. package/dist/assets/index-Ohn-2iW_.js +4 -0
  71. package/dist/assets/{key-C_dbeH7F.js → key-DddJ6bil.js} +1 -1
  72. package/dist/assets/{key-round-CPg0Y5qN.js → key-round-CbCqycf3.js} +1 -1
  73. package/dist/assets/{layers-Cb-ro1vb.js → layers-C-ZqYk3U.js} +1 -1
  74. package/dist/assets/{linked-devices-model-ZCUJsj_d.js → linked-devices-model-BPUD1khJ.js} +1 -1
  75. package/dist/assets/{list-ordered-V6P5uujF.js → list-ordered-Cxznlat2.js} +1 -1
  76. package/dist/assets/{location-owned-usage-C6DcC3IT.js → location-owned-usage-DOmOvdiG.js} +1 -1
  77. package/dist/assets/{log-in-Cxvw8rxc.js → log-in-9Uirjetj.js} +1 -1
  78. package/dist/assets/{memory-stick-Mm_iVwSZ.js → memory-stick-CLL3KiND.js} +1 -1
  79. package/dist/assets/{message-square-plus-Bfam15lf.js → message-square-plus-C2nVnMG1.js} +1 -1
  80. package/dist/assets/{mf-entry-bootstrap-0-019f9c14.js → mf-entry-bootstrap-0-edf9b20a.js} +2 -2
  81. package/dist/assets/{mic-off-CeSZf8K2.js → mic-off-CcHQBwDt.js} +1 -1
  82. package/dist/assets/{monitor-off-U-RK64kw.js → monitor-off-DUE1gt1S.js} +1 -1
  83. package/dist/assets/{monitor-smartphone-DezRerVw.js → monitor-smartphone-CwOoXB0L.js} +1 -1
  84. package/dist/assets/mount-B_Zjyqyk.js +1 -0
  85. package/dist/assets/{player-overlays-DgedyCX9.js → player-overlays-Cw_gjG75.js} +1 -1
  86. package/dist/assets/{recycle-Dkb1d-SV.js → recycle-hW2Os1lc.js} +1 -1
  87. package/dist/assets/remoteEntry-CHuAXwj-.js +1 -0
  88. package/dist/assets/{ruler-DzpBI-EP.js → ruler-SYjqj9n_.js} +1 -1
  89. package/dist/assets/{scan-eye-BmLTXsIf.js → scan-eye-BZlKp5Ev.js} +1 -1
  90. package/dist/assets/{scissors-lBRCylhQ.js → scissors-Prn6Kbb7.js} +1 -1
  91. package/dist/assets/{search-x-BRhrXpKx.js → search-x-CCA8373c.js} +1 -1
  92. package/dist/assets/{send-DVJoNc0-.js → send-C5rCH5_0.js} +1 -1
  93. package/dist/assets/{settings-2-D6sp_FTm.js → settings-2-wlw_-rxi.js} +1 -1
  94. package/dist/assets/{shapes-CQn3wvpk.js → shapes-Kj0bK1D8.js} +1 -1
  95. package/dist/assets/{sigma-CKK8bLRa.js → sigma-NPxR3lj1.js} +1 -1
  96. package/dist/assets/{speaker-BYorOPbN.js → speaker-CIKbprnA.js} +1 -1
  97. package/dist/assets/src-nnHXOip7.js +67 -0
  98. package/dist/assets/{step-inspector-model-DEfajBM3.js → step-inspector-model-BKKc_lkM.js} +1 -1
  99. package/dist/assets/{table-2-BPB4V5Fg.js → table-2-Sw__YAPa.js} +1 -1
  100. package/dist/assets/{timer-reset-Cu_VSXbl.js → timer-reset-BhPZYoCT.js} +1 -1
  101. package/dist/assets/{unlink-BcrHT0zX.js → unlink-DNy8sNAV.js} +1 -1
  102. package/dist/assets/{usb-DhXPqJtn.js → usb-CyQsTtlO.js} +1 -1
  103. package/dist/assets/{use-device-bound-caps-K47AcsQ5.js → use-device-bound-caps-BQo_OD1O.js} +1 -1
  104. package/dist/assets/{use-scenes-feed-DQrMGL5E.js → use-scenes-feed-BCDAv1nN.js} +1 -1
  105. package/dist/assets/{use-stationary-objects-yu-O0RPa.js → use-stationary-objects-BnIfyZw5.js} +1 -1
  106. package/dist/assets/useEventInvalidation-B_Zjyqyk.js +1 -0
  107. package/dist/assets/{useNodeUrlSelection-BuraZwll.js → useNodeUrlSelection-CR_BnlEg.js} +1 -1
  108. package/dist/assets/user-round-BY4YxbLZ.js +1 -0
  109. package/dist/assets/{user-x-DRSOzwTr.js → user-x-CUkBojXx.js} +1 -1
  110. package/dist/assets/variable-CpgCMY_Q.js +1 -0
  111. package/dist/assets/{video-5IaJhdjU.js → video-DXegVNA2.js} +1 -1
  112. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BtgDin-X.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-2LL0aB_0.js} +2 -2
  113. package/dist/index.html +10 -10
  114. package/dist/server/addon.js +902 -116
  115. package/package.json +1 -1
  116. package/dist/assets/Addons-BwXNg54C.js +0 -5
  117. package/dist/assets/AiProfiles-CRZH6xR0.js +0 -3
  118. package/dist/assets/BrokerEditorDialog-D9rZCGl9.js +0 -1
  119. package/dist/assets/Build-BJaqr-_Y.js +0 -40
  120. package/dist/assets/Cluster-Dkt_tVUy.js +0 -1
  121. package/dist/assets/CompositionBlockEditor-BEondavu.js +0 -2
  122. package/dist/assets/Data-pZe3A7Va.js +0 -2
  123. package/dist/assets/History-DTt-NAMR.js +0 -1
  124. package/dist/assets/Identity-C3GHYP7_.js +0 -1
  125. package/dist/assets/IntegrationDetail-EOwq3jVG.js +0 -1
  126. package/dist/assets/Integrations-BocurtE0.js +0 -1
  127. package/dist/assets/Locations-chgnzdWz.js +0 -3
  128. package/dist/assets/Network-plYS78UN.js +0 -1
  129. package/dist/assets/Notifications-mslnotOB.js +0 -1
  130. package/dist/assets/Recordings-BpB53ln_.js +0 -1
  131. package/dist/assets/ScanNetworkModal-BR3tzZcL.js +0 -1
  132. package/dist/assets/SessionsList-BOjlUhj5.js +0 -2
  133. package/dist/assets/System-CiZ0xcyP.js +0 -1
  134. package/dist/assets/circle-slash-DFl97Cbx.js +0 -1
  135. package/dist/assets/client-F3l12jEi.js +0 -674
  136. package/dist/assets/crop-gfwPOF8e.js +0 -1
  137. package/dist/assets/device-picker-model-Fpx4y0MY.js +0 -1
  138. package/dist/assets/dist-B2m_6_7g.js +0 -674
  139. package/dist/assets/i18n-BH0PY6IL.js +0 -1
  140. package/dist/assets/icons-B9uR9qKs.js +0 -1
  141. package/dist/assets/index-CQ7TjSgs.js +0 -4
  142. package/dist/assets/index-DjwiZ7qT.css +0 -2
  143. package/dist/assets/mount-Fpx4y0MY.js +0 -1
  144. package/dist/assets/remoteEntry-DpkkaSO3.js +0 -1
  145. package/dist/assets/src-B0EA_4Ed.js +0 -67
  146. package/dist/assets/useEventInvalidation-Fpx4y0MY.js +0 -1
  147. package/dist/assets/user-round-D6wDvac9.js +0 -1
  148. package/dist/assets/variable-cv0ONmJ-.js +0 -1
@@ -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,Gr as l,Ht as u,ct as d,dt as f,gt as p,ha as m,mn as h,pn as g,pr as _,st as v,xi as y}from"./player-overlays-Cw_gjG75.js";import{a as b,i as x,s as S}from"./video-DXegVNA2.js";import{t as C}from"./key-round-CbCqycf3.js";import{An as w,Cr as T,Fo as E,Jn as ee,Kd as D,Kn as O,Nd as k,Nr as A,On as j,Qn as M,Rd as te,Sn as N,Sr as P,Tr as F,Yn as I,_t as L,bn as R,br as z,di as B,fi as ne,ft as V,jn as H,jt as U,lf as W,pt as re,ri as G,wr as K,xd as q,xn as J,xr as ie,yr as ae,yt as oe,zd as se}from"./src-nnHXOip7.js";import{t as Y}from"./i18n-BE1bPZOs.js";import{t as X}from"./useTranslation-BJr-n0es.js";import{ir as ce,mr as le,n as Z,t as ue}from"./index-Ohn-2iW_.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(j,{headingId:`access-${t}`,title:n,icon:r,actions:o,testId:`access-${t}`,children:e(`div`,{className:`${c} space-y-3`,children:[i(`div`,{className:D(`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:D(`flex items-start gap-2 rounded-md border bg-surface px-3 py-2 text-[11px]`,a.line),children:[i(o,{className:D(`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(se,{type:`button`,variant:`ghost`,size:`sm`,icon:p,"aria-label":r(`access.accessSection.dismiss`,`Dismiss`),onClick:n,className:`-my-1 h-5 w-5`})]})}function me(){let{data:e}=q();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(B,{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(G,{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(_,{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=W.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:p,defaultStatus:m=Ie}){let{t:h}=X(),[g]=o(()=>m.length===0?{search:``,facets:[]}:{search:``,facets:[],groups:{status:[...m]}}),v=R(t,Ne,g),[y,b]=o(()=>new Set),x=u??h(`access.credentialColumns.never`),S=n(()=>Ce({hideOwner:l,expiresNone:x,action:d??null,...f===void 0?{}:{extraActions:f}}),[l,x,d,f,h]),C=n(()=>p===void 0?()=>!1:e=>Fe(e)&&p.isSelectable(e),[p]),T=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(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),h(`access.credentialTable.loading`,{label:r})]}):s===null?e(`div`,{className:`space-y-3`,children:[i(J,{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:h(Pe[e.id]),...e.id===`status`?{facetLabel:e=>_e(e)}:{}})),labels:{searchPlaceholder:h(`access.credentialTable.searchPlaceholder`,{label:r}),searchLabel:h(`access.credentialTable.searchLabel`,{label:r}),facetsLabel:h(`access.credentialTable.facetsLabel`,{label:r}),clearLabel:h(`access.credentialTable.clearFilters`)},onSearch:v.setSearch,onToggleFacet:v.toggleFacet,onToggleGroupFacet:v.toggleGroupFacet,onClear:v.clear}),p!==void 0&&i(Re,{bulk:p,shown:v.rows.filter(C),targets:T,onSelect:b}),i(w,{columns:S,rows:v.rows,rowKey:e=>e.id,minWidthPx:l?760:860,maxBodyHeight:H,defaultSort:{columnKey:`created`,dir:`desc`},pageSize:25,paginationLabels:{navLabel:h(`access.credentialTable.pagesLabel`,{label:r}),previous:h(`access.credentialTable.previousPage`),next:h(`access.credentialTable.nextPage`),range:(e,t,n)=>h(`access.credentialTable.range`,{from:e,to:t,total:n})},emptyMessage:v.active?h(`access.credentialTable.noMatchTheFilters`,`No {{label}} match the filters.`,{label:r}):c,rowClassName:e=>e.status===`revoked`||e.status===`expired`?`opacity-70`:void 0,...p===void 0?{}:{selection:{selected:y,onChange:b,isSelectable:C,rowLabel:e=>h(`access.credentialTable.rowLabel`,{name:e.name,owner:e.ownerName}),pageLabel:h(`access.credentialTable.pageLabel`,{noun:De(1,p.noun)})}}})]}):i(A,{title:h(`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,l=(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(G,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>a(new Set(n.map(e=>e.id))),children:o(`access.credentialTable.selectAllShown`,{count:n.length})}),l.map(t=>e(G,{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(G,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>a(new Set),children:[i(p,{className:`h-3 w-3`,"aria-hidden":!0}),o(`access.credentialTable.clearSelection`,`Clear selection`)]}),e(G,{type:`button`,variant:`danger`,size:`sm`,disabled:s.busy,onClick:()=>void d(),children:[s.busy?i(_,{className:`h-3 w-3 animate-spin`,"aria-hidden":!0}):i(u,{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(``),[p,m]=o(null),[h,g]=o(null),v=t(null),y=r(e=>{v.current?.(e),v.current=null,l(!1),d(``),m(null),g(null)},[]),b=r(()=>new Promise(e=>{v.current?.(null),v.current=e,g(null),l(!0)}),[]),x=async()=>{m(`password`),g(null);try{let{reauthToken:e}=await s.reauthenticate({password:u});y(e)}catch(e){g(ut(e,`Password is incorrect`)),m(null)}},S=async()=>{m(`passkey`),g(null);try{let{optionsJSON:e}=await s.reauthBeginPasskey();if(!ue(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){g(ut(e,`Passkey verification failed`)),m(null)}};return{requestProof:b,dialog:i(ae,{open:c,onOpenChange:e=>!e&&y(null),children:e(ie,{children:[e(K,{children:[i(F,{children:a(`auth.reauthDialog.confirmItSYou`,`Confirm it’s you`)}),i(P,{children:a(`auth.reauthDialog.needsPassword`,{action:n})})]}),e(`form`,{className:`space-y-3`,onSubmit:e=>{e.preventDefault(),u.length>0&&p===null&&x()},children:[i(te,{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`)}),h!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:h}),e(T,{className:`flex flex-wrap gap-2`,children:[e(G,{type:`button`,variant:`outline`,disabled:p!==null,onClick:()=>void S(),children:[p===`passkey`?i(_,{className:`h-4 w-4 animate-spin`}):i(C,{className:`h-4 w-4`}),a(`auth.reauthDialog.useAPasskey`,`Use a passkey`)]}),e(G,{type:`submit`,disabled:u.length===0||p!==null,children:[p===`password`&&i(_,{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(ae,{open:!0,onOpenChange:e=>!e&&r(),children:e(ie,{width:`md`,scroll:`body`,children:[i(K,{children:i(F,{children:a(`auth.tokenModals.token`,`Token: {{label}}`,{label:n})})}),e(z,{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(T,{children:[i(N,{value:t,label:a(`common.copy`,`Copy`),srLabel:`token`}),i(G,{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:u,formError:d,awaitingProof:f}){let{t:p}=X(),v=m(),{user:y}=ce(),b=y?.isAdmin===!0,x=b?null:y?.scopes??[],[S,w]=o(`scopes`),[T,E]=o(y?.id??``),[D,A]=o(``),[j,N]=o([_t]),[P,F]=o([]),[L,R]=o(`grid-view`),[z,B]=o(!1),[H,U]=o(`30`);a(()=>{t||(w(`scopes`),E(y?.id??``),A(``),N([_t]),F([]),R(`grid-view`),B(!1),U(`30`))},[t,y?.id]),a(()=>{S!==`view-link`&&H===`never`&&U(`30`)},[S,H]);let W=n(()=>ht.filter(e=>e.seconds!==`never`||S===`view-link`).map(e=>({value:e.value,label:e.seconds===`never`?p(`access.createTokenModal.never`,`Never (until revoked)`):p(`access.createTokenModal.days`,{count:Number(e.value)})})),[S,p]),K=D.trim(),q=S===`scopes`?re(j,v):null,J=P.map(Number).filter(e=>Number.isInteger(e)&&e>=0),ie=ht.find(e=>e.value===H)?.seconds??30*$,ae=()=>S===`all`?[`*`]:S===`view-link`?[{type:`share-view`,grant:{kind:L,deviceIds:J,...z?{talk:!0}:{}}}]:j,se=K.length>0&&K.length<=mt&&!u&&!f&&(S===`all`?b:S===`view-link`?J.length>0:j.length>0&&q===null),Y=()=>{if(!se)return;let e=b&&S!==`all`&&T!==``&&T!==y?.id;c({scopes:ae(),expiresIn:ie,label:K,...e?{subjectId:T}:{}})},Z=S===`all`,ue=Z?h:g;return i(oe,{open:t,onClose:s,title:p(`access.createTokenModal.createToken`,`Create token`),icon:Z?h:C,error:d,width:`md`,testId:`create-token-dialog`,footer:e(G,{type:`button`,variant:Z?`danger`:`primary`,size:`sm`,onClick:Y,disabled:!se,"data-testid":`create-token-submit`,children:[u||f?i(_,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}):i(ue,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),p(`access.createTokenModal.issueToken`,`Issue token`)]}),children:e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`space-y-1`,children:[i(M,{children:p(`access.createTokenModal.whatItMayDo`,`What it may do`)}),i(O,{appearance:`pills`,value:S,onValueChange:e=>{(e===`scopes`||e===`view-link`||e===`all`)&&w(e)},children:e(ee,{"aria-label":p(`access.createTokenModal.whatItMayDo`,`What it may do`),children:[e(I,{value:`scopes`,"data-testid":`token-reach-scopes`,children:[i(g,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),p(`access.createTokenModal.reachScopes`,`Scopes`)]}),e(I,{value:`view-link`,"data-testid":`token-reach-view-link`,children:[i(l,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),p(`access.createTokenModal.reachViewLink`,`View link`)]}),b?e(I,{value:`all`,"data-testid":`token-reach-all`,children:[i(h,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),p(`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(le,{i18nKey:`auth.adminTokenNoticeShort`,components:{strong:i(`strong`,{})}})})}):null,b&&S!==`all`&&r.length>1?e(`div`,{className:`space-y-1`,children:[i(M,{htmlFor:`token-user`,children:p(`access.createTokenModal.onBehalfOfUser`,`On behalf of user`)}),i(k,{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(M,{htmlFor:`token-name`,children:p(`access.createTokenModal.label`,`Label`)}),i(te,{id:`token-name`,value:D,maxLength:mt,required:!0,onChange:e=>A(e.target.value),placeholder:S===`view-link`?`kitchen-wall`:`nightly-backup`,autoFocus:!0})]}),S===`scopes`?e(`div`,{className:`space-y-1`,children:[i(M,{children:p(`access.createTokenModal.scopes`,`Scopes`)}),i(V,{value:j,onChange:N,clampToParent:x}),q&&i(`p`,{className:`text-[10px] text-danger`,children:q}),i(`p`,{className:`text-[10px] text-foreground-subtle`,children:p(`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(M,{children:p(`access.createTokenModal.cameras`,`Cameras`)}),i(ne,{field:{...gt,label:p(`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(M,{htmlFor:`token-view-kind`,children:p(`access.createTokenModal.viewKind`,`Shows`)}),i(k,{id:`token-view-kind`,value:L,onChange:e=>R(e.target.value===`events-view`?`events-view`:`grid-view`),options:[{value:`grid-view`,label:p(`access.createTokenModal.viewGrid`,`Live grid`)},{value:`events-view`,label:p(`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:z,onChange:e=>B(e.target.checked),"data-testid":`token-view-talk`}),i(`span`,{children:p(`access.createTokenModal.talk`,`Allow talk-back on these cameras`)})]}):null]}):null,e(`div`,{className:`space-y-1`,children:[i(M,{htmlFor:`token-lifetime`,children:p(`access.createTokenModal.expires`,`Expires after`)}),i(k,{id:`token-lifetime`,value:H,onChange:e=>U(e.target.value),options:W})]})]})})}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)?U(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:l}=X(),d=m(),{user:f}=ce(),p=v(),h=W.useUtils(),g=me(),{data:_}=q(),y=n(()=>_??[],[_]),{data:b}=E({}),x=n(()=>{let e=new Map;for(let t of b??[])e.set(t.id,t.name);return e},[b]),S=W.auth.listTokens.useQuery(void 0),{requestProof:w,dialog:T}=dt(`Creating a token with all permissions`),{state:ee,openNew:D,close:O}=L({newKey:pt.token}),[k,A]=o(null),[j,M]=o(null),[te,N]=o(!1),[P,F]=o(null),[I,R]=o(null);a(()=>{r&&(D(),s?.())},[r,D,s]);let z=()=>{h.auth.listTokens.invalidate(),h.auth.listAuthAudit.invalidate()},B=W.auth.mintToken.useMutation({onSuccess:({token:e,record:t})=>{z(),O(),M(null),N(!1),F({token:e,label:t.label})},onError:e=>{M(`Create failed: ${e.message}`),N(!1)}}),ne=W.auth.revokeToken.useMutation({onSuccess:()=>{R(null),z()},onError:e=>{R(null),A(`Revoke failed: ${e.message}`)}}),V=je(yt,z),H=Date.now(),U=(S.data??[]).filter(e=>!c||e.subjectId===f?.id).map(e=>Ze(e,g,e.scopes.includes(`*`)?null:e.scopes.map(e=>Ye(e,x,e=>xt(e,d))).join(`, `),H)),re=async e=>{await p({title:l(`access.tokensSection.revoke`,`Revoke "{{name}}"?`,{name:e.name}),message:e.kind===`All permissions`?l(`access.tokensSection.everyScriptUsingItLoses`,`Every script using it loses access immediately. This cannot be undone.`):l(`access.tokensSection.stopsWorking`,`Whoever holds it loses access immediately. This cannot be undone.`),confirmLabel:l(`access.tokensSection.revoke2`,`Revoke`),variant:`danger`})&&(A(null),R(e.id),ne.mutate({id:e.id}))},K=e=>{(async()=>{A(null),M(null);let t;if(e.scopes.includes(`*`)){N(!0);let e=await w();if(N(!1),e===null)return;t=e}B.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:[T,i(de,{notice:he(k,V.outcome),onDismissNotice:()=>{A(null),V.dismiss()},id:c?`my-tokens`:`tokens`,title:c?l(`access.tokensSection.myTokens`,`My tokens`):l(`access.tokensSection.tokens`,`Tokens`),icon:C,actions:t?void 0:e(G,{size:`sm`,type:`button`,"data-testid":`tokens-new`,onClick:D,children:[i(C,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),l(`system.access.newToken`,`New token`)]}),description:l(`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:U,label:l(`common.tokensLabel`),isLoading:S.isLoading,loadError:S.isError?S.error?.message??`Request failed`:null,emptyText:l(`access.tokensSection.noTokens`,`No tokens.`),action:{label:l(`access.tokensSection.revoke2`,`Revoke`),icon:u,isAvailable:e=>e.status===`active`,onRun:e=>void re(e),busyId:I,disabled:V.busy||I!==null},...f?.isAdmin===!0?{bulk:{revoke:V,noun:yt,isSelectable:e=>e.status===`active`}}:{}})}),i(vt,{open:ee.mode===`new`,users:y.map(e=>({id:e.id,username:e.username})),onClose:()=>{O(),M(null),N(!1)},submitting:B.isPending,formError:j,awaitingProof:te,onSubmit:K}),P&&i(ft,{token:P.token,label:P.label,onClose:()=>F(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(_,{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(_,{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{ut as i}from"./src-B0EA_4Ed.js";import{L as a,dr as o,fr as s}from"./index-CQ7TjSgs.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{ut as i}from"./src-nnHXOip7.js";import{R as a,fr as o,pr as s}from"./index-Ohn-2iW_.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{Ci as d,D as f,Di as p,Dn as m,Gr as h,Ht as g,Mn as _,Oi as v,Si as y,_n as b,cr as x,ct as S,dt as C,gn as w,ki as ee,on as te,ot as T,pn as ne,pr as re,st as ie,ur as ae,xr as oe,zt as se}from"./player-overlays-Cw_gjG75.js";import{Di as ce}from"./client-r4i0EpF6.js";import{i as le}from"./video-DXegVNA2.js";import{t as E}from"./key-round-CbCqycf3.js";import{Ad as D,An as O,Cr as ue,Gs as de,Gu as k,Hs as A,Hu as fe,Jn as pe,Js as me,Ju as he,Kd as j,Kn as ge,Ks as _e,Nr as ve,On as M,Or as N,Rd as P,Sn as F,Sr as ye,Tr as be,Us as xe,Vs as Se,Ws as Ce,Xs as we,Yn as I,Ys as Te,Zs as Ee,br as De,di as L,if as Oe,jn as ke,qn as R,qs as Ae,ri as z,wr as je,xr as Me,yr as Ne}from"./src-nnHXOip7.js";import{t as B}from"./i18n-BE1bPZOs.js";import{t as V}from"./useTranslation-BJr-n0es.js";import{T as Pe,br as Fe,k as Ie,mr as Le}from"./index-Ohn-2iW_.js";import{t as Re}from"./AdminSectionedPage-Bd2owMGm.js";import{t as H}from"./AdminPage-7avIuDBh.js";import{t as ze}from"./NodeAddonsSettingsPanel-JIXh-CLX.js";import{t as Be}from"./AddonAssetIcon-BZ0hQcho.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(re,{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(U,{entry:t,actions:n,activeProvider:s,isPending:c}):r(We,{entry:t,actions:n,isPending:c})]})}function U({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 We({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 W({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 Ge=[`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=C(),[s,c]=a(null),[u,f]=a(null),p=o({queryKey:Ge,queryFn:()=>i.trpcClient.capabilities.listCapabilities.query()}),m=t(()=>{let e=(p.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]},[p.data]),h=t(()=>m.filter(e=>e.mode===`singleton`),[m]),g=t(()=>m.filter(e=>e.mode===`collection`),[m]),_=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:n(`system.capabilities.isNowActive`,`{{capName}} → {{addonId}} is now active.`,{capName:t.capName,addonId:t.addonId})}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:n(`system.capabilities.failedToSet`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),v=l({mutationFn:e=>i.trpcClient.capabilities.setActiveSingleton.mutate({capability:e.capName,addonId:e.addonId,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:`${t.capName} @ ${t.nodeId} → ${t.addonId}.`}),await p.refetch()},onError:(e,t)=>{f({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)}),b=l({mutationFn:e=>i.trpcClient.capabilities.clearSingletonNodeOverride.mutate({capability:e.capName,nodeId:e.nodeId}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:n(`system.capabilities.nowInheritsTheGlobalDefault`,`{{capName}} @ {{nodeId}} now inherits the global default.`,{capName:t.capName,nodeId:t.nodeId})}),await p.refetch()},onError:(e,t)=>{f({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)}),x=l({mutationFn:e=>i.trpcClient.capabilities.setCollectionEnabledProviders.mutate({capability:e.capName,enabledAddonIds:[...e.enabledAddonIds]}),onMutate:e=>{c(e.capName),f(null)},onSuccess:async(e,t)=>{f({kind:`success`,message:n(`system.capabilities.providerSEnabled`,`{{capName}}: {{length}} provider(s) enabled.`,{capName:t.capName,length:t.enabledAddonIds.length})}),await p.refetch()},onError:(e,t)=>{f({kind:`error`,message:n(`system.capabilities.failedToUpdate`,{cap:t.capName,error:e instanceof Error?e.message:n(`common.unknownError`)})})},onSettled:()=>c(null)}),S={onSelectSingleton:(e,t)=>_.mutate({capName:e,addonId:t}),onSelectNodeSingleton:(e,t,n)=>v.mutate({capName:e,nodeId:t,addonId:n}),onClearNodeSingleton:(e,t)=>b.mutate({capName:e,nodeId:t}),onToggleCollection:(e,t)=>x.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(d,{className:`h-3.5 w-3.5 shrink-0`}),r(`span`,{children:u.message})]}),p.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`})}),p.isError&&!p.isLoading&&r(ve,{title:n(`system.capabilities.failedToLoadCapabilities`,`Failed to load capabilities`),message:p.error instanceof Error?p.error.message:n(`system.capabilities.unknownError`,`Unknown error`),onRetry:()=>void p.refetch()}),!p.isLoading&&!p.isError&&m.length===0&&r(`div`,{className:`text-xs text-foreground-subtle text-center py-16`,children:n(`system.capabilities.noCapabilitiesRegistered`,`No capabilities registered.`)}),!p.isLoading&&!p.isError&&m.length>0&&e(`div`,{className:`space-y-6`,children:[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.singletonPickOneProvider`,`Singleton — pick one provider`)}),r(W,{capabilities:h,actions:S})]}),g.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(W,{capabilities:g,actions:S})]})]})]})}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:j(`flex min-w-0 items-center gap-0.5`,a),children:[r(`span`,{className:j(`min-w-0 truncate font-mono`,o),title:s,children:t}),r(F,{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(O,{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(z,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.previousPage`,`Previous page`),disabled:u===0,onClick:()=>s(u-1),children:r(v,{className:`h-3.5 w-3.5`,"aria-hidden":!0})}),e(`span`,{className:`tabular-nums`,children:[u+1,` / `,l]}),r(z,{size:`sm`,variant:`outline`,"aria-label":i(`secrets.keychainAuditTable.nextPage`,`Next page`),disabled:u>=l-1,onClick:()=>s(u+1),children:r(p,{className:`h-3.5 w-3.5`,"aria-hidden":!0})})]})]})]})}function rt(e,t){switch(e){case`locked`:return r(z,{size:`sm`,variant:`danger`,disabled:t.busy,onClick:t.onReset,children:B.t(`secrets.keychainNoticeContent.resetKeychain`,`Reset keychain`)});case`reset`:return r(z,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onAcknowledgeReset,children:B.t(`secrets.keychainNoticeContent.dismiss`,`Dismiss`)});case`recovery-key`:return r(z,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onDownload,children:B.t(`secrets.keychainNoticeContent.download`,`Download`)});case`rotation-pending`:return r(z,{size:`sm`,variant:`outline`,disabled:t.busy,onClick:t.onRotate,children:B.t(`secrets.keychainNoticeContent.rotate`,`Rotate`)});case`orphans`:return r(z,{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:le,text:`text-danger`,border:`border-danger/40`},warning:{icon:se,text:`text-warning`,border:`border-warning/40`},info:{icon:oe,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,f=t.length-d.length;return e(`section`,{"aria-label":o(`secrets.keychainNotices.keychainNotices`,`Keychain notices`),className:j(`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(z,{size:`sm`,variant:`ghost`,"aria-expanded":s,onClick:()=>c(e=>!e),children:[r(ee,{className:j(`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:f})]})})]})}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:j(`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(z,{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(M,{headingId:`keychain-status`,title:s(`secrets.keychainStatusCard.keychain`,`Keychain`),icon:E,actions:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[t.retiredWraps>0&&r(z,{size:`sm`,variant:`ghost`,disabled:n||c,onClick:o,children:s(`secrets.keychainStatusCard.purge`,{count:t.retiredWraps})}),r(z,{size:`sm`,variant:`outline`,disabled:n||c,onClick:a,children:s(`secrets.keychainStatusCard.rotateKey`,`Rotate key`)}),r(z,{size:`sm`,variant:`outline`,disabled:n||c,onClick:i,children:s(`secrets.keychainStatusCard.downloadRecoveryKey`,`Download recovery key`)})]}),children:e(`dl`,{className:`${f} 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(ae,{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(F,{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(D);i(()=>{if(t===null)return;let e=Date.now();c(D);let r=setTimeout(n,D),i=setInterval(()=>c(Math.max(0,D-(Date.now()-e))),ft);return()=>{clearTimeout(r),clearInterval(i)}},[t,n]);let l=Math.ceil(s/1e3);return r(Ne,{open:t!==null,onOpenChange:e=>!e&&n(),children:r(Me,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:t!==null&&e(u,{children:[e(je,{children:[r(be,{className:`break-all`,children:t.entry.fieldPath}),e(ye,{className:`break-all`,children:[t.entry.owner,` · `,t.entry.scope]})]}),r(De,{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(ue,{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(F,{value:t.value,label:o(`common.copy`,`Copy`),srLabel:`revealed value`}),r(z,{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(z,{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(z,{size:`sm`,variant:`outline`,className:`ml-auto`,disabled:c||l,onClick:()=>s(d),children:[r(g,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),n(`secrets.secretsTableState.deleteOrphans`,{count:d.length})]})]}),r(O,{columns:_t(t),rows:f,rowKey:e=>e.ref,minWidthPx:860,maxBodyHeight:ke,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?b:_,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(z,{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(h,{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=T(),i=S(),a=xe(),o=we(),s=_e(),c=Ae(),l=Se(),u=A(),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:ce})})},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]=Fe();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=Ee({}),s=de({}),c=Ce({limit:500}),l=me({}),u=Te(),d=T(),[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:Ie(e),variant:`danger`})}},w=n(()=>_(null),[]);return e(H,{embedded:!0,icon:E,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(ge,{value:f,onValueChange:e=>p(e===`audit`?`audit`:`values`),children:[e(pe,{children:[r(I,{value:`values`,children:i(`admin.system.secrets.storedValues`,`Stored values`)}),r(I,{value:`audit`,children:i(`admin.system.secrets.audit`,`Audit`)})]}),r(R,{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(R,{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=k(),s=he(),l=fe(),[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()},S=async()=>{g(null),await l.mutateAsync(),await v()},C=s.isPending||l.isPending||o.isLoading;return e(N,{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(x,{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(P,{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(P,{className:`w-40`,value:f,inputMode:`decimal`,placeholder:`14.268100`,onChange:e=>p(e.target.value),"aria-label":t(`settings.siteLocationCard.longitude`,`Longitude`)})]}),r(z,{type:`submit`,disabled:C,children:t(`common.save`,`Save`)}),e(z,{type:`button`,variant:`ghost`,disabled:C,onClick:S,children:[r(m,{className:`h-3.5 w-3.5 mr-1`}),t(`settings.siteLocationCard.detectFromIp`,`Detect from IP`)]}),_===null?null:r(z,{type:`button`,variant:`ghost`,disabled:C,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}=Oe(),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};
@@ -1 +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,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hn as u,Ht as d,In as f,aa as p,ai as m,ia as h,ot as g,ra as _,st as v,ta as y,vn as b}from"./player-overlays-DgedyCX9.js";import{Dr as x,Or as S,Sr as C,ar as w,br as ee,ir as T,kr as E,rr as D,xr as O,yi as te,yr as ne}from"./client-F3l12jEi.js";import{l as re}from"./video-5IaJhdjU.js";import{t as k}from"./shapes-CQn3wvpk.js";import{t as ie}from"./unlink-BcrHT0zX.js";import{Ad as A,An as ae,Cr as oe,Et as j,Fd as M,Id as N,Ir as P,Ju as se,Ld as ce,Nr as le,Pr as ue,Tr as de,Xu as fe,Yu as pe,Zn as me,an as F,br as he,di as ge,fu as _e,jn as ve,oi as ye,qu as be,ri as I,wr as xe,wt as Se,xr as Ce,yr as we}from"./src-B0EA_4Ed.js";import{t as L}from"./useTranslation-BJr-n0es.js";import{t as Te}from"./AdminPage-CYSYefaL.js";import{C as Ee,S as R,T as z,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as B,s as V,t as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./RemoteGrid-BjtzHkpg.js";s();var H=12,U=4,W=3,G=(e,t,n,r,i,a={})=>({id:e,role:t,row:n,col:r,colSpan:i,...a}),K=e=>`custom:${e}`;function q(e,t,n=[]){return t.map((t,r)=>G(`r${e}c${r}`,t,e,r*U,U,{...n[r]===void 0?{}:{label:n[r]}}))}function J(e){return[G(`up`,`up`,e,U,U),G(`left`,`left`,e+1,0,U),G(`ok`,`ok`,e+1,U,U),G(`right`,`right`,e+1,2*U,U),G(`down`,`down`,e+2,U,U)]}function Y(e,t){return t.map((t,n)=>G(`app_${t}`,K(`app_${t}`),e,n*W,W,{icon:B(t)}))}var X=(e,t)=>({id:`core:section-divider`,row:e,col:0,options:{scale:{cols:H},title:t}});function qe(e,t,n){let r=V(H,e,t);for(let e of n){let t=w(r,D(e.id),{row:e.row,col:e.col},e.options);if(!t.ok)throw Error(`preset component ${e.id} at ${e.row}:${e.col}: ${t.reason}`);r=t.layout}return r}var Z={scale:{cols:U}},Je={scale:{rows:2,cols:U}},Ye=(e,t,n,r)=>({idSuffix:e,row:3,col:t,rowSpan:1,colSpan:1,role:n,label:r}),Xe=qe(23,[G(`input`,`input`,0,2*U,U),G(`mute`,`mute`,7,U,U),G(`ch_list`,K(`ch_list`),8,U,U,{label:`CH LIST`}),G(`settings`,K(`settings`),9,U,U,{label:`Settings`}),G(`home`,`home`,10,U,U),G(`guide`,`guide`,12,0,U),G(`e_manual`,K(`e_manual`),12,U,U,{label:`e-Manual`}),G(`info`,`info`,12,2*U,U),G(`back`,`back`,17,0,U),G(`exit`,`exit`,17,2*U,U),G(`color_a`,K(`color_a`),19,0,W,{label:`A`}),G(`color_b`,K(`color_b`),19,W,W,{label:`B`}),G(`color_c`,K(`color_c`),19,2*W,W,{label:`C`}),G(`color_d`,K(`color_d`),19,3*W,W,{label:`D`}),G(`pic_size`,K(`pic_size`),20,0,U,{label:`P.SIZE`}),G(`picture`,K(`picture`),20,U,U,{label:`Picture`}),G(`ad_subt`,K(`ad_subt`),20,2*U,U,{label:`AD/SUBT`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},X(1,`Numbers`),{id:`core:keypad`,row:2,col:0,options:{scale:Z.scale,extras:[Ye(`ttx`,0,K(`ttx_mix`),`TTX/MIX`),Ye(`prech`,2,K(`pre_ch`),`PRE-CH`)]}},X(6,`Volume and channels`),{id:`core:rocker-volume-v`,row:7,col:0,options:Je},{id:`core:rocker-channel-v`,row:7,col:2*U,options:Je},X(11,`Menus`),X(13,`Navigation`),{id:`core:dpad`,row:14,col:0,options:Z},X(18,`Colour and picture`),X(21,`Playback`),{id:`core:media-transport`,row:22,col:1,options:{scale:{cols:2}}}]),Ze=[`netflix`,`youtube`,`primevideo`,`disneyplus`,`dazn`,`raiplay`],Qe=qe(20,[G(`input`,`input`,0,2*U,U),...q(4,[`menu`,`home`,`exit`]),G(`guide`,`guide`,6,0,U),G(`info`,`info`,6,2*U,U),G(`back`,`back`,10,0,U),G(`play_pause`,`play_pause`,10,2*U,U),G(`mute`,`mute`,12,U,U),G(`ch_list`,K(`ch_list`),13,U,U,{label:`CH.LIST`}),G(`subtitle`,K(`subtitle`),14,0,6,{label:`Subtitle`}),G(`text`,K(`text`),14,6,6,{label:`Text`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},{id:`core:panel`,row:1,col:0,options:{scale:Z.scale,title:`Apps`,extras:Ze.map((e,t)=>({idSuffix:e,row:Math.floor(t/3),col:t%3,rowSpan:1,colSpan:1,role:K(`app_${e}`),icon:B(e)}))}},{id:`core:colour-keys`,row:3,col:0,options:{scale:{cols:W}}},X(5,`Navigation`),{id:`core:dpad`,row:7,col:0,options:Z},X(11,`Volume and channels`),{id:`core:rocker-volume-v`,row:12,col:0,options:Z},{id:`core:rocker-channel-v`,row:12,col:2*U,options:Z},X(15,`Numbers`),{id:`core:keypad`,row:16,col:0,options:Z}]),$e=V(H,8,[G(`power`,`power`,0,0,U),G(`input`,`input`,0,2*U,U),...J(1),...q(4,[`back`,`home`,`play_pause`]),G(`vol_up`,`volume_up`,5,0,U),G(`mute`,`mute`,5,U,U,{rowSpan:2}),G(`ch_up`,`channel_up`,5,2*U,U),G(`vol_down`,`volume_down`,6,0,U),G(`ch_down`,`channel_down`,6,2*U,U),...Y(7,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),et=V(H,9,[G(`power`,`power`,0,0,U),G(`input`,`input`,0,2*U,U),G(`settings`,K(`settings`),1,0,U,{label:`Settings`}),G(`up`,`up`,1,U,U),G(`guide`,`guide`,1,2*U,U),G(`left`,`left`,2,0,U),G(`ok`,`ok`,2,U,U),G(`right`,`right`,2,2*U,U),G(`back`,`back`,3,0,U),G(`down`,`down`,3,U,U),G(`home`,`home`,3,2*U,U),G(`vol_up`,`volume_up`,4,0,U,{rowSpan:2}),G(`vol_down`,`volume_down`,6,0,U,{rowSpan:2}),G(`mute`,`mute`,4,U,U),G(`info`,`info`,5,U,U),G(`menu`,`menu`,6,U,U),G(`exit`,`exit`,7,U,U),G(`ch_up`,`channel_up`,4,2*U,U,{rowSpan:2}),G(`ch_down`,`channel_down`,6,2*U,U,{rowSpan:2}),...Y(8,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),tt=V(H,8,[G(`assistant`,K(`assistant`),0,0,U,{label:`Assistant`}),G(`input`,`input`,0,U,U),G(`power`,`power`,0,2*U,U),...J(1),...q(4,[`back`,`home`,`guide`]),G(`vol_up`,`volume_up`,5,0,U),G(`mute`,`mute`,5,U,U),G(`ch_up`,`channel_up`,5,2*U,U),G(`vol_down`,`volume_down`,6,0,U),G(`play_pause`,`play_pause`,6,U,U),G(`ch_down`,`channel_down`,6,2*U,U),...Y(7,[`youtube`,`netflix`,`primevideo`,`disneyplus`])]),nt=V(H,7,[G(`siri`,K(`siri`),0,0,U,{label:`Siri`}),G(`power`,`power`,0,2*U,U),...J(1),...q(4,[`back`,`play_pause`,`home`]),G(`vol_up`,`volume_up`,5,0,6),G(`vol_down`,`volume_down`,5,6,6),G(`mute`,`mute`,6,U,U)]),rt=[{id:`samsung-classic`,layout:Xe},{id:`hisense-vidaa`,layout:Qe},{id:`samsung-smart`,layout:$e},{id:`lg-magic`,layout:et},{id:`google-tv`,layout:tt},{id:`apple-tv`,layout:nt}];function it(e){let t=rt.find(t=>t.id===e);return t===void 0?null:{...t.layout,buttons:t.layout.buttons.map(e=>({...e}))}}function at(e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);let n=[...t.values()];return[...n.filter(e=>e.id.startsWith(`core:`)),...n.filter(e=>!e.id.startsWith(`core:`))]}function ot(e,t){let n=e.nameI18n;return n===void 0?e.name:t.startsWith(`it`)?n.it:n.en}function st(e){let t=w({columns:e.size.cols,rows:e.size.rows,buttons:[]},e,{row:0,col:0});return t.ok?t.layout:null}function ct(e,t,n,r){let i=t.trim().toLowerCase();return i===``?[...e]:e.filter(e=>ot(e,n).toLowerCase().includes(i)||r(e.category).toLowerCase().includes(i))}function lt(e,t){let n=T(e,t);return n!==null&&n>1}function ut(e,t,n={}){let r=n.fillWidth===!0?T(e,t):null,i=r===null||r<2?{}:{scale:{cols:r}};if(n.at!==void 0)return w(e,t,n.at,i);let a=w(e,t,{row:0,col:0},i);if(a.ok||a.reason===`outside`||a.reason===`too-many`)return a;for(let n=0;n<e.rows;n+=1)for(let r=0;r<e.columns;r+=1){let a=w(e,t,{row:n,col:r},i);if(a.ok)return a}return a}function dt({open:t,grid:n,onOpenChange:r,onPick:a}){let{t:o,i18n:s}=L();return i(we,{open:t,onOpenChange:r,children:e(Ce,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(xe,{children:i(de,{children:o(`remote.palette.title`)})}),i(he,{children:t&&i(ft,{grid:n,language:s.language,onPick:(e,t)=>{a(e,t),r(!1)}})})]})})}function ft({grid:t,language:r,onPick:a}){let{t:s}=L(),c=_e({}),[l,u]=o(``),[d,f]=o(!1),p=e=>s(`remote.palette.category.${e}`,e),m=ct(n(()=>at(c.data===void 0?[]:[c.data]),[c.data]),l,r,p),h=m.some(e=>lt(t,e));return c.isError?i(le,{title:s(`remote.palette.errorTitle`),message:c.error.message,onRetry:()=>void c.refetch()}):c.data===void 0?e(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-loading`,children:[i(P,{className:`h-24`}),i(P,{className:`h-24`}),i(P,{className:`h-24`}),i(P,{className:`h-24`})]}):e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(b,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(M,{value:l,className:`pl-8`,placeholder:s(`remote.palette.search`),"aria-label":s(`remote.palette.search`),onChange:e=>u(e.target.value),"data-testid":`palette-search`})]}),h&&e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-muted`,children:[i(me,{checked:d,onChange:e=>f(e.target.checked),"data-testid":`palette-fill-width`}),s(`remote.palette.fillWidth`)]}),m.length===0?i(ue,{icon:k,title:s(`remote.palette.emptyTitle`),description:s(`remote.palette.emptyDescription`)}):i(`ul`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-list`,children:m.map(e=>i(`li`,{children:i(pt,{component:e,language:r,category:p(e.category),onPick:()=>a(e,{fillWidth:d})})},e.id))})]})}function pt({component:t,language:r,category:a,onPick:o}){let{t:s}=L(),c=n(()=>st(t),[t]),l=ot(t,r);return e(`button`,{type:`button`,className:`flex h-full w-full items-center gap-3 rounded-lg border border-border bg-surface p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"data-testid":`palette-item-${t.id}`,onClick:o,children:[i(`span`,{className:`w-20 shrink-0`,children:c!==null&&i(Ve,{grid:c,label:l,compact:!0})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:l}),e(`span`,{className:`block truncate text-xs text-foreground-muted`,children:[a,` ·`,` `,s(`remote.palette.size`,{cols:t.size.cols,rows:t.size.rows})]})]})]})}function Q(e,t){let n=t.kind===`group`?je(e,t.id):e.buttons.find(e=>e.id===t.id);return n===void 0?void 0:{row:n.row,col:n.col,rowSpan:n.rowSpan,colSpan:n.colSpan}}function mt(e,t,n,r){return e.width<=0||e.height<=0?{row:0,col:0}:{col:Math.floor((n-e.left)/e.width*t.columns),row:Math.floor((r-e.top)/e.height*t.rows)}}function ht(e,t,n){return{row:n.row-(t.row-e.row),col:n.col-(t.col-e.col)}}function gt(e,t,n){return t.kind===`group`?Ue(e,t.id,n.row,n.col):De(e,t.id,n.row,n.col)}function _t(e,t,n){let r=Q(e,t);if(r===void 0)return null;let i=gt(e,t,n);return{rect:{...r,row:n.row,col:n.col},valid:i.status===`ok`,reason:i.status===`ok`?null:i.reason}}function vt(e){switch(e){case`ArrowUp`:return{dRow:-1,dCol:0};case`ArrowDown`:return{dRow:1,dCol:0};case`ArrowLeft`:return{dRow:0,dCol:-1};case`ArrowRight`:return{dRow:0,dCol:1};default:return null}}function yt(e,t,n,r){let i=Q(e,t);return i===void 0?{status:`refused`,reason:`unknown-button`}:gt(e,t,{row:i.row+n,col:i.col+r})}s();var bt=4;function xt(e,n,i){let[s,c]=o(null),l=t({grid:e,onDrop:i});l.current={grid:e,onDrop:i};let u=t(null),d=t(!1);return a(()=>()=>u.current?.(),[]),{drag:s,onItemPointerDown:r((e,t)=>{let r=n.current;if(r===null||t.button!==0)return;let i=r.getBoundingClientRect();if(Q(l.current.grid,e)===void 0)return;let a={item:e,startX:t.clientX,startY:t.clientY,grabbed:mt(i,l.current.grid,t.clientX,t.clientY),active:!1,target:null},o=e=>{if(!a.active){if(Math.hypot(e.clientX-a.startX,e.clientY-a.startY)<bt)return;a.active=!0}let t=l.current.grid,n=mt(r.getBoundingClientRect(),t,e.clientX,e.clientY),i=Q(t,a.item);i!==void 0&&(a.target=ht(i,a.grabbed,n),c({item:a.item,preview:_t(t,a.item,a.target)}))},s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,p),window.removeEventListener(`keydown`,m),u.current=null,c(null),a.active&&(d.current=!0,window.setTimeout(()=>{d.current=!1},0),e&&a.target!==null&&l.current.onDrop(gt(l.current.grid,a.item,a.target)))},f=()=>s(!0),p=()=>s(!1),m=e=>{e.key===`Escape`&&s(!1)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,p),window.addEventListener(`keydown`,m),u.current=()=>s(!1)},[n]),consumeDragClick:r(()=>{let e=d.current;return d.current=!1,e},[])}}s();var St=`__custom__`;function Ct({value:n,onChange:r}){let{t:a}=L(),[s,c]=o(null),[l,u]=o(null),[d,p]=o(!1),m=t(null),h=s?.kind===`button`?s.id:null,g=s?.kind===`group`?s.id:null,_=n.buttons.find(e=>e.id===h)??null,v=g===null?void 0:je(n,g),y=(e,t)=>{if(e.status===`ok`){u(null),r(e.grid),t?.(e.grid);return}u(a(`remote.layout.refusal.${e.reason}`))},b=xt(n,m,e=>y(e));return e(`div`,{className:`grid gap-4 md:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-2`,children:[i(j,{label:a(`remote.layout.columns`),children:i(F,{value:n.columns,onDelta:e=>y(Ge(n,n.columns+e,n.rows))})}),i(j,{label:a(`remote.layout.rows`),children:i(F,{value:n.rows,onDelta:e=>y(Ge(n,n.columns,n.rows+e))})})]}),i(Ve,{grid:n,label:a(`remote.layout.previewLabel`),selectedId:h,selectedGroupId:g,onSelect:e=>{b.consumeDragClick()||c({kind:`button`,id:e})},onSelectGroup:e=>{b.consumeDragClick()||c({kind:`group`,id:e})},showEmptyCells:!0,gridRef:m,drag:b.drag,onItemPointerDown:b.onItemPointerDown,onItemKeyDown:(e,t)=>{let r=vt(t.key);r!==null&&(t.preventDefault(),y(yt(n,e,r.dRow,r.dCol)))}}),i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.dragHint`)}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(I,{variant:`outline`,size:`sm`,onClick:()=>p(!0),"data-testid":`remote-add-component`,children:[i(k,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addComponent`)]}),e(I,{variant:`outline`,size:`sm`,onClick:()=>y(ze(n,`ok`),e=>{let t=e.buttons.at(-1);c(t===void 0?null:{kind:`button`,id:t.id})}),"data-testid":`remote-add-button`,children:[i(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addButton`)]})]}),l!==null&&i(`p`,{role:`alert`,className:`text-xs text-warning`,"data-testid":`remote-layout-refusal`,children:l})]}),i(`div`,{className:`min-w-0`,children:_===null?v===void 0?i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.selectHint`)}):i(Et,{grid:n,groupId:v.id,apply:y,onGone:()=>c(null)}):i(Tt,{grid:n,buttonId:_.id,apply:y,onRemove:()=>{r(Ke(n,_.id)),c(null),u(null)}})}),i(dt,{open:d,grid:n,onOpenChange:p,onPick:(e,t)=>{let i=ut(n,e,t);if(!i.ok){u(a(`remote.layout.refusal.${i.reason}`));return}u(null),r(i.layout);let o=i.buttonIds[0];c(i.groupId===null?o===void 0?null:{kind:`button`,id:o}:{kind:`group`,id:i.groupId})}})]})}function wt(e){return[...Oe.flatMap(t=>Le(t).map(n=>({value:n,label:e(`remote.role.${n}`,Me(n)),group:e(`remote.roleGroup.${t}`)}))),{value:St,label:e(`remote.layout.customRole`),group:e(`remote.roleGroup.custom`)}]}function Tt({grid:t,buttonId:n,apply:r,onRemove:a}){let{t:s}=L(),c=t.buttons.find(e=>e.id===n),l=c===void 0?null:x(c.role),[u,f]=o(null);if(c===void 0)return null;let m=Be(c.role)||u!==null,g=u??l??``,v=E(g),b={trigger:s(`remote.layout.pickIcon`),panel:s(`remote.layout.iconPanel`),searchPlaceholder:s(`deviceDisplay.iconSearchPlaceholder`),clear:s(`remote.layout.noIcon`),noMatches:s(`deviceDisplay.iconNoMatches`)},w=e=>s(`deviceDisplay.iconCategory.${e}`,{defaultValue:te(e)});return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-inspector`,children:[i(ye,{mode:`single`,singleDisplay:`field`,label:s(`remote.layout.role`),options:wt((e,t)=>s(e,t??e)),value:m?St:c.role,onChange:e=>{if(e===St){f(l??``);return}f(null),r(R(t,c.id,{role:e}))}}),m&&i(j,{label:s(`remote.layout.customKey`),...g!==``&&!v?{error:s(`remote.layout.customKeyInvalid`)}:{},children:i(M,{value:g,placeholder:`hdmi_1`,onChange:e=>{let n=e.target.value;f(n),E(n)&&r(R(t,c.id,{role:S(n)}))}})}),e(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] items-end gap-2`,children:[i(j,{label:s(`remote.layout.icon`),children:i(ce,{value:c.icon??null,onPick:e=>r(R(t,c.id,{icon:e})),fallbackGlyph:k,categoryLabel:w,labels:b})}),i(j,{label:s(`remote.layout.label`),children:i(M,{value:c.label??``,maxLength:40,onChange:e=>r(R(t,c.id,{label:e.target.value}))})})]}),i(j,{label:s(`remote.layout.appIcon`),children:i(A,{value:Fe(c.icon)?.key??``,options:[{value:``,label:s(`remote.layout.noApp`)},...Re.map(e=>({value:e.key,label:e.label}))],onChange:e=>{let n=e.target.value;n===``?Fe(c.icon)!==void 0&&r(R(t,c.id,{icon:null})):r(R(t,c.id,{icon:B(n)}))},"data-testid":`remote-app-icon`})}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(j,{label:s(`remote.layout.shape`),children:i(A,{value:c.shape??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...O.map(e=>({value:e,label:s(`remote.layout.shapes.${e}`)}))],onChange:e=>{let n=O.find(t=>t===e.target.value);r(Ee(t,c.id,{shape:n??null}))},"data-testid":`remote-shape`})}),i(j,{label:s(`remote.layout.tone`),children:i(A,{value:c.tone??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...C.map(e=>({value:e,label:s(`remote.layout.tones.${e}`)}))],onChange:e=>{let n=C.find(t=>t===e.target.value);r(Ee(t,c.id,{tone:n??null}))},"data-testid":`remote-tone`})})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(j,{label:s(`remote.layout.move`),children:e(`div`,{className:`flex items-center gap-1`,children:[i(N,{icon:h,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveLeft`),onClick:()=>r(z(t,c.id,0,-1))}),i(N,{icon:y,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveUp`),onClick:()=>r(z(t,c.id,-1,0))}),i(N,{icon:p,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveDown`),onClick:()=>r(z(t,c.id,1,0))}),i(N,{icon:_,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveRight`),onClick:()=>r(z(t,c.id,0,1))})]})}),i(j,{label:s(`remote.layout.position`),children:i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`remote-position`,children:s(`remote.layout.positionValue`,{row:c.row+1,col:c.col+1})})}),i(j,{label:s(`remote.layout.height`),children:i(F,{value:c.rowSpan,onDelta:e=>r(ke(t,c.id,c.rowSpan+e,c.colSpan))})}),i(j,{label:s(`remote.layout.width`),children:i(F,{value:c.colSpan,onDelta:e=>r(ke(t,c.id,c.rowSpan,c.colSpan+e))})})]}),e(I,{variant:`danger`,size:`sm`,onClick:a,children:[i(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),s(`remote.layout.removeButton`)]})]})}function Et({grid:t,groupId:n,apply:r,onGone:a}){let{t:o}=L(),s=je(t,n);if(s===void 0)return null;let c=Ne(t,n).length;return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-group-inspector`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:o(`remote.layout.groupSummary`,{frame:o(`remote.layout.frames.${s.frame}`,s.frame),count:c,row:s.row+1,col:s.col+1})}),i(j,{label:o(`remote.layout.groupTitle`),children:i(M,{value:s.title??``,maxLength:40,onChange:e=>r(We(t,s.id,e.target.value)),"data-testid":`remote-group-title`})}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(I,{variant:`outline`,size:`sm`,"data-testid":`remote-group-ungroup`,onClick:()=>{r(Ie(t,s.id,!0)),a()},children:[i(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.ungroup`)]}),e(I,{variant:`danger`,size:`sm`,"data-testid":`remote-group-delete`,onClick:()=>{r(Ie(t,s.id,!1)),a()},children:[i(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.deleteGroup`)]})]})]})}var Dt={remote:{label:e=>e(`remote.templates.kind.remote`),emptyPayload:He,summary:(e,t)=>{let n=Pe(e);return t(`remote.templates.layoutSummary`,{columns:n.columns,rows:n.rows,count:n.buttons.length})},renderEditor:(e,t)=>i(Ct,{value:Pe(e),onChange:t}),isSavable:e=>Ae(Pe(e))!==null,presets:e=>rt.map(t=>({id:t.id,label:e(`remote.templates.preset.${t.id}`),payload:()=>it(t.id)}))}};function $(e){return Dt[e]}var Ot=ne;function kt(e,t){let n=ee(e,t);return n.ok?n.payload:null}s();function At({draft:e,saving:t,error:n,onSave:r,onClose:a}){return i(we,{open:e!==null,onOpenChange:e=>!e&&a(),children:i(Ce,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:e!==null&&i(jt,{draft:e,saving:t,error:n,onSave:r,onClose:a},e.id??`new`)})})}function jt({draft:t,saving:n,error:r,onSave:a,onClose:s}){let{t:c}=L(),[u,d]=o(t.kind),[f,p]=o(t.name),[m,h]=o(t.payload),[g,_]=o(``),v=$(u),y=v.presets(c),b=kt(u,m),x=f.trim()!==``&&b!==null&&v.isSavable(m)&&!n;return e(l,{children:[i(xe,{children:i(de,{children:t.id===null?c(`remote.templates.newTitle`):c(`remote.templates.editTitle`)})}),e(he,{className:`space-y-4`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(j,{label:c(`remote.templates.name`),children:i(M,{value:f,maxLength:120,onChange:e=>p(e.target.value),"data-testid":`template-name`})}),t.id===null&&Ot.length>1&&i(j,{label:c(`remote.templates.kind.label`),children:i(A,{value:u,options:Ot.map(e=>({value:e,label:$(e).label(c)})),onChange:e=>{let t=Ot.find(t=>t===e.target.value);t!==void 0&&(d(t),h($(t).emptyPayload()),_(``))}})}),t.id===null&&y.length>0&&i(j,{label:c(`remote.templates.startFrom`),children:i(A,{value:g,options:[{value:``,label:c(`remote.templates.startBlank`)},...y.map(e=>({value:e.id,label:e.label}))],onChange:e=>{let t=y.find(t=>t.id===e.target.value);_(t?.id??``),h(t===void 0?v.emptyPayload():t.payload()),t!==void 0&&f.trim()===``&&p(t.label)},"data-testid":`template-preset`})})]}),v.renderEditor(m,h),r!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]}),e(oe,{children:[i(I,{variant:`ghost`,onClick:s,children:c(`common.cancel`)}),i(I,{disabled:!x,onClick:()=>a({id:t.id,kind:u,name:f.trim(),payload:b}),"data-testid":`template-save`,children:c(`common.save`)})]})]})}s();var Mt=ne[0];function Nt(){let{t}=L(),r=c(),a=pe({}),s=be(),l=fe(),p=se(),h=v(),_=g(),[y,b]=o(null),[x,S]=o(null),C=()=>void r.invalidateQueries({queryKey:[[`template`]]}),w=async e=>{S(null);try{let t=e.id===null?await s.mutateAsync({kind:e.kind,name:e.name,payload:e.payload}):await l.mutateAsync({id:e.id,name:e.name,payload:e.payload});if(t.status===`refused`){S(t.detail);return}C(),b(null)}catch(e){S(e instanceof Error?e.message:String(e))}},ee=async e=>{try{await s.mutateAsync({kind:e.kind,name:t(`remote.templates.copyName`,{name:e.name}),payload:e.payload}),C()}catch(e){await _({title:t(`remote.templates.duplicateFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},T=async e=>{if(await h({title:t(`remote.templates.deleteTitle`,{name:e.name}),message:t(`remote.templates.deleteMessage`),confirmLabel:t(`common.delete`),variant:`danger`}))try{let n=await p.mutateAsync({id:e.id});if(n.status===`in-use`){await _({title:t(`remote.templates.inUseTitle`,{name:e.name}),message:t(`remote.templates.inUseMessage`,{devices:n.devices.map(e=>e.name).join(`, `)}),variant:`warning`});return}C()}catch(e){await _({title:t(`remote.templates.deleteFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},E=n(()=>[{key:`name`,header:t(`remote.templates.name`),sortValue:e=>e.name.toLowerCase(),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{key:`kind`,header:t(`remote.templates.kind.label`),sortValue:e=>e.kind,render:e=>i(ge,{variant:`neutral`,children:$(e.kind).label(t)})},{key:`summary`,header:t(`remote.templates.summary`),notSortableReason:`A sentence built from the payload.`,render:e=>i(`span`,{className:`text-foreground-muted`,children:$(e.kind).summary(e.payload,t)})},{key:`updated`,header:t(`remote.templates.updated`),sortValue:e=>e.updatedAt,render:e=>i(`span`,{className:`text-foreground-muted`,children:new Date(e.updatedAt).toLocaleDateString()})},{key:`actions`,align:`right`,notSortableReason:`Row actions.`,render:e=>i(Se,{title:t(`remote.templates.actionsFor`,{name:e.name}),items:[{id:`edit`,label:t(`common.edit`),icon:u,onClick:()=>{S(null),b({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}},{id:`duplicate`,label:t(`remote.templates.duplicate`),icon:m,onClick:()=>void ee(e)},{id:`delete`,label:t(`common.delete`),icon:d,danger:!0,onClick:()=>void T(e)}]})}],[t]),D=a.data??[],O=()=>{S(null),b({id:null,kind:Mt,name:``,payload:$(Mt).emptyPayload()})};return e(Te,{icon:re,title:t(`remote.templates.title`),subtitle:t(`remote.templates.subtitle`),actions:e(I,{size:`sm`,onClick:O,"data-testid":`template-new`,children:[i(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`remote.templates.new`)]}),children:[a.status===`error`?i(le,{title:t(`remote.templates.loadFailed`),message:a.error.message,onRetry:()=>void a.refetch()}):a.data===void 0?i(P,{className:`h-32 w-full`}):D.length===0?i(ue,{icon:re,title:t(`remote.templates.emptyTitle`),description:t(`remote.templates.emptyDescription`),action:i(I,{size:`sm`,onClick:O,children:t(`remote.templates.new`)})}):i(ae,{columns:E,rows:D,rowKey:e=>e.id,maxBodyHeight:ve,defaultSort:{columnKey:`name`,dir:`asc`},onRowClick:e=>{S(null),b({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}}),i(At,{draft:y,saving:s.isPending||l.isPending,error:x,onSave:e=>void w(e),onClose:()=>b(null)})]})}export{Nt as TemplatesPage};
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,o as c,x as l}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Hn as u,Ht as d,In as f,aa as p,ai as m,ia as h,ot as g,ra as _,st as v,ta as y,vn as b}from"./player-overlays-Cw_gjG75.js";import{Dr as x,Or as S,Sr as C,ar as w,br as ee,ir as T,kr as E,rr as D,xr as O,yi as te,yr as ne}from"./client-r4i0EpF6.js";import{l as re}from"./video-DXegVNA2.js";import{t as k}from"./shapes-Kj0bK1D8.js";import{t as ie}from"./unlink-DNy8sNAV.js";import{An as ae,Bd as oe,Cr as se,Et as A,Ir as j,Nd as M,Nr as ce,Pr as le,Qu as ue,Rd as N,Tr as de,Xu as fe,Yu as pe,Zn as me,Zu as he,an as P,br as ge,di as _e,jn as ve,mu as ye,oi as be,ri as F,wr as xe,wt as Se,xr as Ce,yr as we,zd as I}from"./src-nnHXOip7.js";import{t as L}from"./useTranslation-BJr-n0es.js";import{t as Te}from"./AdminPage-7avIuDBh.js";import{C as Ee,S as R,T as z,_ as De,a as Oe,b as ke,c as Ae,d as je,f as Me,g as Ne,h as Pe,i as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as B,s as V,t as Ve,u as He,v as Ue,w as We,x as Ge,y as Ke}from"./RemoteGrid-Bz_u9tq6.js";s();var H=12,U=4,W=3,G=(e,t,n,r,i,a={})=>({id:e,role:t,row:n,col:r,colSpan:i,...a}),K=e=>`custom:${e}`;function q(e,t,n=[]){return t.map((t,r)=>G(`r${e}c${r}`,t,e,r*U,U,{...n[r]===void 0?{}:{label:n[r]}}))}function J(e){return[G(`up`,`up`,e,U,U),G(`left`,`left`,e+1,0,U),G(`ok`,`ok`,e+1,U,U),G(`right`,`right`,e+1,2*U,U),G(`down`,`down`,e+2,U,U)]}function Y(e,t){return t.map((t,n)=>G(`app_${t}`,K(`app_${t}`),e,n*W,W,{icon:B(t)}))}var X=(e,t)=>({id:`core:section-divider`,row:e,col:0,options:{scale:{cols:H},title:t}});function qe(e,t,n){let r=V(H,e,t);for(let e of n){let t=w(r,D(e.id),{row:e.row,col:e.col},e.options);if(!t.ok)throw Error(`preset component ${e.id} at ${e.row}:${e.col}: ${t.reason}`);r=t.layout}return r}var Z={scale:{cols:U}},Je={scale:{rows:2,cols:U}},Ye=(e,t,n,r)=>({idSuffix:e,row:3,col:t,rowSpan:1,colSpan:1,role:n,label:r}),Xe=qe(23,[G(`input`,`input`,0,2*U,U),G(`mute`,`mute`,7,U,U),G(`ch_list`,K(`ch_list`),8,U,U,{label:`CH LIST`}),G(`settings`,K(`settings`),9,U,U,{label:`Settings`}),G(`home`,`home`,10,U,U),G(`guide`,`guide`,12,0,U),G(`e_manual`,K(`e_manual`),12,U,U,{label:`e-Manual`}),G(`info`,`info`,12,2*U,U),G(`back`,`back`,17,0,U),G(`exit`,`exit`,17,2*U,U),G(`color_a`,K(`color_a`),19,0,W,{label:`A`}),G(`color_b`,K(`color_b`),19,W,W,{label:`B`}),G(`color_c`,K(`color_c`),19,2*W,W,{label:`C`}),G(`color_d`,K(`color_d`),19,3*W,W,{label:`D`}),G(`pic_size`,K(`pic_size`),20,0,U,{label:`P.SIZE`}),G(`picture`,K(`picture`),20,U,U,{label:`Picture`}),G(`ad_subt`,K(`ad_subt`),20,2*U,U,{label:`AD/SUBT`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},X(1,`Numbers`),{id:`core:keypad`,row:2,col:0,options:{scale:Z.scale,extras:[Ye(`ttx`,0,K(`ttx_mix`),`TTX/MIX`),Ye(`prech`,2,K(`pre_ch`),`PRE-CH`)]}},X(6,`Volume and channels`),{id:`core:rocker-volume-v`,row:7,col:0,options:Je},{id:`core:rocker-channel-v`,row:7,col:2*U,options:Je},X(11,`Menus`),X(13,`Navigation`),{id:`core:dpad`,row:14,col:0,options:Z},X(18,`Colour and picture`),X(21,`Playback`),{id:`core:media-transport`,row:22,col:1,options:{scale:{cols:2}}}]),Ze=[`netflix`,`youtube`,`primevideo`,`disneyplus`,`dazn`,`raiplay`],Qe=qe(20,[G(`input`,`input`,0,2*U,U),...q(4,[`menu`,`home`,`exit`]),G(`guide`,`guide`,6,0,U),G(`info`,`info`,6,2*U,U),G(`back`,`back`,10,0,U),G(`play_pause`,`play_pause`,10,2*U,U),G(`mute`,`mute`,12,U,U),G(`ch_list`,K(`ch_list`),13,U,U,{label:`CH.LIST`}),G(`subtitle`,K(`subtitle`),14,0,6,{label:`Subtitle`}),G(`text`,K(`text`),14,6,6,{label:`Text`})],[{id:`core:power`,row:0,col:0,options:{scale:{cols:2}}},{id:`core:panel`,row:1,col:0,options:{scale:Z.scale,title:`Apps`,extras:Ze.map((e,t)=>({idSuffix:e,row:Math.floor(t/3),col:t%3,rowSpan:1,colSpan:1,role:K(`app_${e}`),icon:B(e)}))}},{id:`core:colour-keys`,row:3,col:0,options:{scale:{cols:W}}},X(5,`Navigation`),{id:`core:dpad`,row:7,col:0,options:Z},X(11,`Volume and channels`),{id:`core:rocker-volume-v`,row:12,col:0,options:Z},{id:`core:rocker-channel-v`,row:12,col:2*U,options:Z},X(15,`Numbers`),{id:`core:keypad`,row:16,col:0,options:Z}]),$e=V(H,8,[G(`power`,`power`,0,0,U),G(`input`,`input`,0,2*U,U),...J(1),...q(4,[`back`,`home`,`play_pause`]),G(`vol_up`,`volume_up`,5,0,U),G(`mute`,`mute`,5,U,U,{rowSpan:2}),G(`ch_up`,`channel_up`,5,2*U,U),G(`vol_down`,`volume_down`,6,0,U),G(`ch_down`,`channel_down`,6,2*U,U),...Y(7,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),et=V(H,9,[G(`power`,`power`,0,0,U),G(`input`,`input`,0,2*U,U),G(`settings`,K(`settings`),1,0,U,{label:`Settings`}),G(`up`,`up`,1,U,U),G(`guide`,`guide`,1,2*U,U),G(`left`,`left`,2,0,U),G(`ok`,`ok`,2,U,U),G(`right`,`right`,2,2*U,U),G(`back`,`back`,3,0,U),G(`down`,`down`,3,U,U),G(`home`,`home`,3,2*U,U),G(`vol_up`,`volume_up`,4,0,U,{rowSpan:2}),G(`vol_down`,`volume_down`,6,0,U,{rowSpan:2}),G(`mute`,`mute`,4,U,U),G(`info`,`info`,5,U,U),G(`menu`,`menu`,6,U,U),G(`exit`,`exit`,7,U,U),G(`ch_up`,`channel_up`,4,2*U,U,{rowSpan:2}),G(`ch_down`,`channel_down`,6,2*U,U,{rowSpan:2}),...Y(8,[`netflix`,`primevideo`,`disneyplus`,`youtube`])]),tt=V(H,8,[G(`assistant`,K(`assistant`),0,0,U,{label:`Assistant`}),G(`input`,`input`,0,U,U),G(`power`,`power`,0,2*U,U),...J(1),...q(4,[`back`,`home`,`guide`]),G(`vol_up`,`volume_up`,5,0,U),G(`mute`,`mute`,5,U,U),G(`ch_up`,`channel_up`,5,2*U,U),G(`vol_down`,`volume_down`,6,0,U),G(`play_pause`,`play_pause`,6,U,U),G(`ch_down`,`channel_down`,6,2*U,U),...Y(7,[`youtube`,`netflix`,`primevideo`,`disneyplus`])]),nt=V(H,7,[G(`siri`,K(`siri`),0,0,U,{label:`Siri`}),G(`power`,`power`,0,2*U,U),...J(1),...q(4,[`back`,`play_pause`,`home`]),G(`vol_up`,`volume_up`,5,0,6),G(`vol_down`,`volume_down`,5,6,6),G(`mute`,`mute`,6,U,U)]),rt=[{id:`samsung-classic`,layout:Xe},{id:`hisense-vidaa`,layout:Qe},{id:`samsung-smart`,layout:$e},{id:`lg-magic`,layout:et},{id:`google-tv`,layout:tt},{id:`apple-tv`,layout:nt}];function it(e){let t=rt.find(t=>t.id===e);return t===void 0?null:{...t.layout,buttons:t.layout.buttons.map(e=>({...e}))}}function at(e){let t=new Map;for(let n of e)for(let e of n)t.has(e.id)||t.set(e.id,e);let n=[...t.values()];return[...n.filter(e=>e.id.startsWith(`core:`)),...n.filter(e=>!e.id.startsWith(`core:`))]}function ot(e,t){let n=e.nameI18n;return n===void 0?e.name:t.startsWith(`it`)?n.it:n.en}function st(e){let t=w({columns:e.size.cols,rows:e.size.rows,buttons:[]},e,{row:0,col:0});return t.ok?t.layout:null}function ct(e,t,n,r){let i=t.trim().toLowerCase();return i===``?[...e]:e.filter(e=>ot(e,n).toLowerCase().includes(i)||r(e.category).toLowerCase().includes(i))}function lt(e,t){let n=T(e,t);return n!==null&&n>1}function ut(e,t,n={}){let r=n.fillWidth===!0?T(e,t):null,i=r===null||r<2?{}:{scale:{cols:r}};if(n.at!==void 0)return w(e,t,n.at,i);let a=w(e,t,{row:0,col:0},i);if(a.ok||a.reason===`outside`||a.reason===`too-many`)return a;for(let n=0;n<e.rows;n+=1)for(let r=0;r<e.columns;r+=1){let a=w(e,t,{row:n,col:r},i);if(a.ok)return a}return a}function dt({open:t,grid:n,onOpenChange:r,onPick:a}){let{t:o,i18n:s}=L();return i(we,{open:t,onOpenChange:r,children:e(Ce,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[i(xe,{children:i(de,{children:o(`remote.palette.title`)})}),i(ge,{children:t&&i(ft,{grid:n,language:s.language,onPick:(e,t)=>{a(e,t),r(!1)}})})]})})}function ft({grid:t,language:r,onPick:a}){let{t:s}=L(),c=ye({}),[l,u]=o(``),[d,f]=o(!1),p=e=>s(`remote.palette.category.${e}`,e),m=ct(n(()=>at(c.data===void 0?[]:[c.data]),[c.data]),l,r,p),h=m.some(e=>lt(t,e));return c.isError?i(ce,{title:s(`remote.palette.errorTitle`),message:c.error.message,onRetry:()=>void c.refetch()}):c.data===void 0?e(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-loading`,children:[i(j,{className:`h-24`}),i(j,{className:`h-24`}),i(j,{className:`h-24`}),i(j,{className:`h-24`})]}):e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[i(b,{className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-foreground-subtle`,"aria-hidden":!0}),i(N,{value:l,className:`pl-8`,placeholder:s(`remote.palette.search`),"aria-label":s(`remote.palette.search`),onChange:e=>u(e.target.value),"data-testid":`palette-search`})]}),h&&e(`label`,{className:`flex items-center gap-2 text-xs text-foreground-muted`,children:[i(me,{checked:d,onChange:e=>f(e.target.checked),"data-testid":`palette-fill-width`}),s(`remote.palette.fillWidth`)]}),m.length===0?i(le,{icon:k,title:s(`remote.palette.emptyTitle`),description:s(`remote.palette.emptyDescription`)}):i(`ul`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`palette-list`,children:m.map(e=>i(`li`,{children:i(pt,{component:e,language:r,category:p(e.category),onPick:()=>a(e,{fillWidth:d})})},e.id))})]})}function pt({component:t,language:r,category:a,onPick:o}){let{t:s}=L(),c=n(()=>st(t),[t]),l=ot(t,r);return e(`button`,{type:`button`,className:`flex h-full w-full items-center gap-3 rounded-lg border border-border bg-surface p-2 text-left hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"data-testid":`palette-item-${t.id}`,onClick:o,children:[i(`span`,{className:`w-20 shrink-0`,children:c!==null&&i(Ve,{grid:c,label:l,compact:!0})}),e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:l}),e(`span`,{className:`block truncate text-xs text-foreground-muted`,children:[a,` ·`,` `,s(`remote.palette.size`,{cols:t.size.cols,rows:t.size.rows})]})]})]})}function Q(e,t){let n=t.kind===`group`?je(e,t.id):e.buttons.find(e=>e.id===t.id);return n===void 0?void 0:{row:n.row,col:n.col,rowSpan:n.rowSpan,colSpan:n.colSpan}}function mt(e,t,n,r){return e.width<=0||e.height<=0?{row:0,col:0}:{col:Math.floor((n-e.left)/e.width*t.columns),row:Math.floor((r-e.top)/e.height*t.rows)}}function ht(e,t,n){return{row:n.row-(t.row-e.row),col:n.col-(t.col-e.col)}}function gt(e,t,n){return t.kind===`group`?Ue(e,t.id,n.row,n.col):De(e,t.id,n.row,n.col)}function _t(e,t,n){let r=Q(e,t);if(r===void 0)return null;let i=gt(e,t,n);return{rect:{...r,row:n.row,col:n.col},valid:i.status===`ok`,reason:i.status===`ok`?null:i.reason}}function vt(e){switch(e){case`ArrowUp`:return{dRow:-1,dCol:0};case`ArrowDown`:return{dRow:1,dCol:0};case`ArrowLeft`:return{dRow:0,dCol:-1};case`ArrowRight`:return{dRow:0,dCol:1};default:return null}}function yt(e,t,n,r){let i=Q(e,t);return i===void 0?{status:`refused`,reason:`unknown-button`}:gt(e,t,{row:i.row+n,col:i.col+r})}s();var bt=4;function xt(e,n,i){let[s,c]=o(null),l=t({grid:e,onDrop:i});l.current={grid:e,onDrop:i};let u=t(null),d=t(!1);return a(()=>()=>u.current?.(),[]),{drag:s,onItemPointerDown:r((e,t)=>{let r=n.current;if(r===null||t.button!==0)return;let i=r.getBoundingClientRect();if(Q(l.current.grid,e)===void 0)return;let a={item:e,startX:t.clientX,startY:t.clientY,grabbed:mt(i,l.current.grid,t.clientX,t.clientY),active:!1,target:null},o=e=>{if(!a.active){if(Math.hypot(e.clientX-a.startX,e.clientY-a.startY)<bt)return;a.active=!0}let t=l.current.grid,n=mt(r.getBoundingClientRect(),t,e.clientX,e.clientY),i=Q(t,a.item);i!==void 0&&(a.target=ht(i,a.grabbed,n),c({item:a.item,preview:_t(t,a.item,a.target)}))},s=e=>{window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,f),window.removeEventListener(`pointercancel`,p),window.removeEventListener(`keydown`,m),u.current=null,c(null),a.active&&(d.current=!0,window.setTimeout(()=>{d.current=!1},0),e&&a.target!==null&&l.current.onDrop(gt(l.current.grid,a.item,a.target)))},f=()=>s(!0),p=()=>s(!1),m=e=>{e.key===`Escape`&&s(!1)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,f),window.addEventListener(`pointercancel`,p),window.addEventListener(`keydown`,m),u.current=()=>s(!1)},[n]),consumeDragClick:r(()=>{let e=d.current;return d.current=!1,e},[])}}s();var St=`__custom__`;function Ct({value:n,onChange:r}){let{t:a}=L(),[s,c]=o(null),[l,u]=o(null),[d,p]=o(!1),m=t(null),h=s?.kind===`button`?s.id:null,g=s?.kind===`group`?s.id:null,_=n.buttons.find(e=>e.id===h)??null,v=g===null?void 0:je(n,g),y=(e,t)=>{if(e.status===`ok`){u(null),r(e.grid),t?.(e.grid);return}u(a(`remote.layout.refusal.${e.reason}`))},b=xt(n,m,e=>y(e));return e(`div`,{className:`grid gap-4 md:grid-cols-[minmax(0,18rem)_minmax(0,1fr)]`,children:[e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`grid grid-cols-2 gap-2`,children:[i(A,{label:a(`remote.layout.columns`),children:i(P,{value:n.columns,onDelta:e=>y(Ge(n,n.columns+e,n.rows))})}),i(A,{label:a(`remote.layout.rows`),children:i(P,{value:n.rows,onDelta:e=>y(Ge(n,n.columns,n.rows+e))})})]}),i(Ve,{grid:n,label:a(`remote.layout.previewLabel`),selectedId:h,selectedGroupId:g,onSelect:e=>{b.consumeDragClick()||c({kind:`button`,id:e})},onSelectGroup:e=>{b.consumeDragClick()||c({kind:`group`,id:e})},showEmptyCells:!0,gridRef:m,drag:b.drag,onItemPointerDown:b.onItemPointerDown,onItemKeyDown:(e,t)=>{let r=vt(t.key);r!==null&&(t.preventDefault(),y(yt(n,e,r.dRow,r.dCol)))}}),i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.dragHint`)}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(F,{variant:`outline`,size:`sm`,onClick:()=>p(!0),"data-testid":`remote-add-component`,children:[i(k,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addComponent`)]}),e(F,{variant:`outline`,size:`sm`,onClick:()=>y(ze(n,`ok`),e=>{let t=e.buttons.at(-1);c(t===void 0?null:{kind:`button`,id:t.id})}),"data-testid":`remote-add-button`,children:[i(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`remote.layout.addButton`)]})]}),l!==null&&i(`p`,{role:`alert`,className:`text-xs text-warning`,"data-testid":`remote-layout-refusal`,children:l})]}),i(`div`,{className:`min-w-0`,children:_===null?v===void 0?i(`p`,{className:`text-xs text-foreground-subtle`,children:a(`remote.layout.selectHint`)}):i(Et,{grid:n,groupId:v.id,apply:y,onGone:()=>c(null)}):i(Tt,{grid:n,buttonId:_.id,apply:y,onRemove:()=>{r(Ke(n,_.id)),c(null),u(null)}})}),i(dt,{open:d,grid:n,onOpenChange:p,onPick:(e,t)=>{let i=ut(n,e,t);if(!i.ok){u(a(`remote.layout.refusal.${i.reason}`));return}u(null),r(i.layout);let o=i.buttonIds[0];c(i.groupId===null?o===void 0?null:{kind:`button`,id:o}:{kind:`group`,id:i.groupId})}})]})}function wt(e){return[...Oe.flatMap(t=>Le(t).map(n=>({value:n,label:e(`remote.role.${n}`,Me(n)),group:e(`remote.roleGroup.${t}`)}))),{value:St,label:e(`remote.layout.customRole`),group:e(`remote.roleGroup.custom`)}]}function Tt({grid:t,buttonId:n,apply:r,onRemove:a}){let{t:s}=L(),c=t.buttons.find(e=>e.id===n),l=c===void 0?null:x(c.role),[u,f]=o(null);if(c===void 0)return null;let m=Be(c.role)||u!==null,g=u??l??``,v=E(g),b={trigger:s(`remote.layout.pickIcon`),panel:s(`remote.layout.iconPanel`),searchPlaceholder:s(`deviceDisplay.iconSearchPlaceholder`),clear:s(`remote.layout.noIcon`),noMatches:s(`deviceDisplay.iconNoMatches`)},w=e=>s(`deviceDisplay.iconCategory.${e}`,{defaultValue:te(e)});return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-inspector`,children:[i(be,{mode:`single`,singleDisplay:`field`,label:s(`remote.layout.role`),options:wt((e,t)=>s(e,t??e)),value:m?St:c.role,onChange:e=>{if(e===St){f(l??``);return}f(null),r(R(t,c.id,{role:e}))}}),m&&i(A,{label:s(`remote.layout.customKey`),...g!==``&&!v?{error:s(`remote.layout.customKeyInvalid`)}:{},children:i(N,{value:g,placeholder:`hdmi_1`,onChange:e=>{let n=e.target.value;f(n),E(n)&&r(R(t,c.id,{role:S(n)}))}})}),e(`div`,{className:`grid grid-cols-[auto_minmax(0,1fr)] items-end gap-2`,children:[i(A,{label:s(`remote.layout.icon`),children:i(oe,{value:c.icon??null,onPick:e=>r(R(t,c.id,{icon:e})),fallbackGlyph:k,categoryLabel:w,labels:b})}),i(A,{label:s(`remote.layout.label`),children:i(N,{value:c.label??``,maxLength:40,onChange:e=>r(R(t,c.id,{label:e.target.value}))})})]}),i(A,{label:s(`remote.layout.appIcon`),children:i(M,{value:Fe(c.icon)?.key??``,options:[{value:``,label:s(`remote.layout.noApp`)},...Re.map(e=>({value:e.key,label:e.label}))],onChange:e=>{let n=e.target.value;n===``?Fe(c.icon)!==void 0&&r(R(t,c.id,{icon:null})):r(R(t,c.id,{icon:B(n)}))},"data-testid":`remote-app-icon`})}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(A,{label:s(`remote.layout.shape`),children:i(M,{value:c.shape??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...O.map(e=>({value:e,label:s(`remote.layout.shapes.${e}`)}))],onChange:e=>{let n=O.find(t=>t===e.target.value);r(Ee(t,c.id,{shape:n??null}))},"data-testid":`remote-shape`})}),i(A,{label:s(`remote.layout.tone`),children:i(M,{value:c.tone??``,options:[{value:``,label:s(`remote.layout.lookDefault`)},...C.map(e=>({value:e,label:s(`remote.layout.tones.${e}`)}))],onChange:e=>{let n=C.find(t=>t===e.target.value);r(Ee(t,c.id,{tone:n??null}))},"data-testid":`remote-tone`})})]}),e(`div`,{className:`grid grid-cols-2 gap-3`,children:[i(A,{label:s(`remote.layout.move`),children:e(`div`,{className:`flex items-center gap-1`,children:[i(I,{icon:h,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveLeft`),onClick:()=>r(z(t,c.id,0,-1))}),i(I,{icon:y,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveUp`),onClick:()=>r(z(t,c.id,-1,0))}),i(I,{icon:p,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveDown`),onClick:()=>r(z(t,c.id,1,0))}),i(I,{icon:_,size:`sm`,variant:`secondary`,"aria-label":s(`remote.layout.moveRight`),onClick:()=>r(z(t,c.id,0,1))})]})}),i(A,{label:s(`remote.layout.position`),children:i(`p`,{className:`text-xs text-foreground-muted`,"data-testid":`remote-position`,children:s(`remote.layout.positionValue`,{row:c.row+1,col:c.col+1})})}),i(A,{label:s(`remote.layout.height`),children:i(P,{value:c.rowSpan,onDelta:e=>r(ke(t,c.id,c.rowSpan+e,c.colSpan))})}),i(A,{label:s(`remote.layout.width`),children:i(P,{value:c.colSpan,onDelta:e=>r(ke(t,c.id,c.rowSpan,c.colSpan+e))})})]}),e(F,{variant:`danger`,size:`sm`,onClick:a,children:[i(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),s(`remote.layout.removeButton`)]})]})}function Et({grid:t,groupId:n,apply:r,onGone:a}){let{t:o}=L(),s=je(t,n);if(s===void 0)return null;let c=Ne(t,n).length;return e(`div`,{className:`space-y-3 rounded-lg border border-border bg-surface p-3`,"data-testid":`remote-group-inspector`,children:[i(`p`,{className:`text-xs text-foreground-muted`,children:o(`remote.layout.groupSummary`,{frame:o(`remote.layout.frames.${s.frame}`,s.frame),count:c,row:s.row+1,col:s.col+1})}),i(A,{label:o(`remote.layout.groupTitle`),children:i(N,{value:s.title??``,maxLength:40,onChange:e=>r(We(t,s.id,e.target.value)),"data-testid":`remote-group-title`})}),e(`div`,{className:`flex flex-wrap gap-2`,children:[e(F,{variant:`outline`,size:`sm`,"data-testid":`remote-group-ungroup`,onClick:()=>{r(Ie(t,s.id,!0)),a()},children:[i(ie,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.ungroup`)]}),e(F,{variant:`danger`,size:`sm`,"data-testid":`remote-group-delete`,onClick:()=>{r(Ie(t,s.id,!1)),a()},children:[i(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),o(`remote.layout.deleteGroup`)]})]})]})}var Dt={remote:{label:e=>e(`remote.templates.kind.remote`),emptyPayload:He,summary:(e,t)=>{let n=Pe(e);return t(`remote.templates.layoutSummary`,{columns:n.columns,rows:n.rows,count:n.buttons.length})},renderEditor:(e,t)=>i(Ct,{value:Pe(e),onChange:t}),isSavable:e=>Ae(Pe(e))!==null,presets:e=>rt.map(t=>({id:t.id,label:e(`remote.templates.preset.${t.id}`),payload:()=>it(t.id)}))}};function $(e){return Dt[e]}var Ot=ne;function kt(e,t){let n=ee(e,t);return n.ok?n.payload:null}s();function At({draft:e,saving:t,error:n,onSave:r,onClose:a}){return i(we,{open:e!==null,onOpenChange:e=>!e&&a(),children:i(Ce,{width:`xl`,placement:`sheet-on-mobile`,scroll:`body`,children:e!==null&&i(jt,{draft:e,saving:t,error:n,onSave:r,onClose:a},e.id??`new`)})})}function jt({draft:t,saving:n,error:r,onSave:a,onClose:s}){let{t:c}=L(),[u,d]=o(t.kind),[f,p]=o(t.name),[m,h]=o(t.payload),[g,_]=o(``),v=$(u),y=v.presets(c),b=kt(u,m),x=f.trim()!==``&&b!==null&&v.isSavable(m)&&!n;return e(l,{children:[i(xe,{children:i(de,{children:t.id===null?c(`remote.templates.newTitle`):c(`remote.templates.editTitle`)})}),e(ge,{className:`space-y-4`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[i(A,{label:c(`remote.templates.name`),children:i(N,{value:f,maxLength:120,onChange:e=>p(e.target.value),"data-testid":`template-name`})}),t.id===null&&Ot.length>1&&i(A,{label:c(`remote.templates.kind.label`),children:i(M,{value:u,options:Ot.map(e=>({value:e,label:$(e).label(c)})),onChange:e=>{let t=Ot.find(t=>t===e.target.value);t!==void 0&&(d(t),h($(t).emptyPayload()),_(``))}})}),t.id===null&&y.length>0&&i(A,{label:c(`remote.templates.startFrom`),children:i(M,{value:g,options:[{value:``,label:c(`remote.templates.startBlank`)},...y.map(e=>({value:e.id,label:e.label}))],onChange:e=>{let t=y.find(t=>t.id===e.target.value);_(t?.id??``),h(t===void 0?v.emptyPayload():t.payload()),t!==void 0&&f.trim()===``&&p(t.label)},"data-testid":`template-preset`})})]}),v.renderEditor(m,h),r!==null&&i(`p`,{role:`alert`,className:`text-xs text-danger`,children:r})]}),e(se,{children:[i(F,{variant:`ghost`,onClick:s,children:c(`common.cancel`)}),i(F,{disabled:!x,onClick:()=>a({id:t.id,kind:u,name:f.trim(),payload:b}),"data-testid":`template-save`,children:c(`common.save`)})]})]})}s();var Mt=ne[0];function Nt(){let{t}=L(),r=c(),a=he({}),s=pe(),l=ue(),p=fe(),h=v(),_=g(),[y,b]=o(null),[x,S]=o(null),C=()=>void r.invalidateQueries({queryKey:[[`template`]]}),w=async e=>{S(null);try{let t=e.id===null?await s.mutateAsync({kind:e.kind,name:e.name,payload:e.payload}):await l.mutateAsync({id:e.id,name:e.name,payload:e.payload});if(t.status===`refused`){S(t.detail);return}C(),b(null)}catch(e){S(e instanceof Error?e.message:String(e))}},ee=async e=>{try{await s.mutateAsync({kind:e.kind,name:t(`remote.templates.copyName`,{name:e.name}),payload:e.payload}),C()}catch(e){await _({title:t(`remote.templates.duplicateFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},T=async e=>{if(await h({title:t(`remote.templates.deleteTitle`,{name:e.name}),message:t(`remote.templates.deleteMessage`),confirmLabel:t(`common.delete`),variant:`danger`}))try{let n=await p.mutateAsync({id:e.id});if(n.status===`in-use`){await _({title:t(`remote.templates.inUseTitle`,{name:e.name}),message:t(`remote.templates.inUseMessage`,{devices:n.devices.map(e=>e.name).join(`, `)}),variant:`warning`});return}C()}catch(e){await _({title:t(`remote.templates.deleteFailed`),message:e instanceof Error?e.message:String(e),variant:`danger`})}},E=n(()=>[{key:`name`,header:t(`remote.templates.name`),sortValue:e=>e.name.toLowerCase(),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.name})},{key:`kind`,header:t(`remote.templates.kind.label`),sortValue:e=>e.kind,render:e=>i(_e,{variant:`neutral`,children:$(e.kind).label(t)})},{key:`summary`,header:t(`remote.templates.summary`),notSortableReason:`A sentence built from the payload.`,render:e=>i(`span`,{className:`text-foreground-muted`,children:$(e.kind).summary(e.payload,t)})},{key:`updated`,header:t(`remote.templates.updated`),sortValue:e=>e.updatedAt,render:e=>i(`span`,{className:`text-foreground-muted`,children:new Date(e.updatedAt).toLocaleDateString()})},{key:`actions`,align:`right`,notSortableReason:`Row actions.`,render:e=>i(Se,{title:t(`remote.templates.actionsFor`,{name:e.name}),items:[{id:`edit`,label:t(`common.edit`),icon:u,onClick:()=>{S(null),b({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}},{id:`duplicate`,label:t(`remote.templates.duplicate`),icon:m,onClick:()=>void ee(e)},{id:`delete`,label:t(`common.delete`),icon:d,danger:!0,onClick:()=>void T(e)}]})}],[t]),D=a.data??[],O=()=>{S(null),b({id:null,kind:Mt,name:``,payload:$(Mt).emptyPayload()})};return e(Te,{icon:re,title:t(`remote.templates.title`),subtitle:t(`remote.templates.subtitle`),actions:e(F,{size:`sm`,onClick:O,"data-testid":`template-new`,children:[i(f,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),t(`remote.templates.new`)]}),children:[a.status===`error`?i(ce,{title:t(`remote.templates.loadFailed`),message:a.error.message,onRetry:()=>void a.refetch()}):a.data===void 0?i(j,{className:`h-32 w-full`}):D.length===0?i(le,{icon:re,title:t(`remote.templates.emptyTitle`),description:t(`remote.templates.emptyDescription`),action:i(F,{size:`sm`,onClick:O,children:t(`remote.templates.new`)})}):i(ae,{columns:E,rows:D,rowKey:e=>e.id,maxBodyHeight:ve,defaultSort:{columnKey:`name`,dir:`asc`},onRowClick:e=>{S(null),b({id:e.id,kind:e.kind,name:e.name,payload:e.payload})}}),i(At,{draft:y,saving:s.isPending||l.isPending,error:x,onSave:e=>void w(e),onClose:()=>b(null)})]})}export{Nt as TemplatesPage};