@camstack/addon-admin-ui 1.2.665 → 1.2.666

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 (92) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/assets/{Addons-Bv5gLMtF.js → Addons-BbdBk9wW.js} +3 -3
  3. package/dist/assets/{AdminPage-B3Kuwjd2.js → AdminPage-CmU7TFpR.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-DChJZzFa.js → AdminSectionedPage-Cm0ZjYDU.js} +1 -1
  5. package/dist/assets/{AiProfiles-C6yQgkJH.js → AiProfiles-HJoGWhcS.js} +2 -2
  6. package/dist/assets/{BootstrapSettingsForm-DuZUGUMa.js → BootstrapSettingsForm-D6UTTbsU.js} +1 -1
  7. package/dist/assets/{Build-fnudV1i4.js → Build-CCW-kQ0l.js} +4 -4
  8. package/dist/assets/{Calendars-DmIcnCIg.js → Calendars-C5NgG8yX.js} +1 -1
  9. package/dist/assets/{CameraGrids-CwedqQkg.js → CameraGrids-B0cBy4w5.js} +1 -1
  10. package/dist/assets/{Cluster-DEjJcxR0.js → Cluster-BCyzfBO3.js} +1 -1
  11. package/dist/assets/{CompositionBlockEditor-CDl_mxCE.js → CompositionBlockEditor-BxZoOOq_.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-BGBF_er3.js → CompositionEditorPage-BDv9rAiM.js} +1 -1
  13. package/dist/assets/{Data-zDT0RKL1.js → Data-D2RM7Tt4.js} +2 -2
  14. package/dist/assets/{DeviceDetail-BHCupF35.js → DeviceDetail-rMZtKYoI.js} +2 -2
  15. package/dist/assets/{Devices-DO_8zuMe.js → Devices-BzJ3Btzd.js} +1 -1
  16. package/dist/assets/EmbedDevicePage-8C99LXxD.js +1 -0
  17. package/dist/assets/{EmbedPlayerPage-DwWdm7ic.js → EmbedPlayerPage-Ca2Sw4bZ.js} +1 -1
  18. package/dist/assets/{History-CZb_UDFA.js → History-xW7LPyUG.js} +1 -1
  19. package/dist/assets/{Identity-B3n3iCvU.js → Identity-DnwYpLFz.js} +1 -1
  20. package/dist/assets/InstancesTable-DdCebknO.js +1 -0
  21. package/dist/assets/{IntegrationDetail-sSYr3Fb0.js → IntegrationDetail-O-kb6--D.js} +1 -1
  22. package/dist/assets/{Integrations-D_AN5A6m.js → Integrations-BDCfdFnN.js} +2 -2
  23. package/dist/assets/Integrations-DSWNrJxB.js +1 -0
  24. package/dist/assets/{Library-_e_sAc6d.js → Library-LsC-lNCD.js} +1 -1
  25. package/dist/assets/{Locations-DeB8hCXi.js → Locations-BYoWfHdo.js} +2 -2
  26. package/dist/assets/{Logs-D-mkm6R8.js → Logs-1wrdl6wt.js} +1 -1
  27. package/dist/assets/{MaskShapeCanvas-Dz6X3A2K.js → MaskShapeCanvas-Bq9CrmvE.js} +1 -1
  28. package/dist/assets/{MotionZonesSettings-CqGBfTay.js → MotionZonesSettings-BBu1rBTV.js} +1 -1
  29. package/dist/assets/MyAccess-xYr4opzQ.js +2 -0
  30. package/dist/assets/{Network-DK9UgXcV.js → Network-CvyVibLV.js} +1 -1
  31. package/dist/assets/{NodeAddonsSettingsPanel-Bf7oMHRP.js → NodeAddonsSettingsPanel-BCe3XXQY.js} +1 -1
  32. package/dist/assets/Notifications-rVhJKRmX.js +1 -0
  33. package/dist/assets/{Pipeline-XbV_d-Cc.js → Pipeline-B_b10-YP.js} +1 -1
  34. package/dist/assets/{PrivacyMaskSettings-Cd3-8Ff_.js → PrivacyMaskSettings-gWcdduy-.js} +1 -1
  35. package/dist/assets/{Recordings-C-72KrtV.js → Recordings-BF59movC.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-DN3ztRlH.js → SceneMonitorEditor-Dx29RcZb.js} +1 -1
  37. package/dist/assets/{SessionsList-C0Rcbhvx.js → SessionsList-DzIluTDz.js} +2 -2
  38. package/dist/assets/{Showroom-C09TlvPE.js → Showroom-CUEMO_di.js} +1 -1
  39. package/dist/assets/{StorageLocationsTable-CcY-iBd8.js → StorageLocationsTable-CSQCOF91.js} +1 -1
  40. package/dist/assets/{System-BgHKlc40.js → System-Bcz-yvym.js} +1 -1
  41. package/dist/assets/{Terminal-4k8JkVD1.js → Terminal-Ah6yfRG5.js} +1 -1
  42. package/dist/assets/{TrainingProviders-CQf16LM_.js → TrainingProviders-ClxXnXpP.js} +1 -1
  43. package/dist/assets/{Viewer-BJE_fWej.js → Viewer-BQrT9RT1.js} +1 -1
  44. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-b2xk_SDh.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DhQkS3-x.js} +1 -1
  45. package/dist/assets/{action-draft-Bu87ThNt.js → action-draft-D31SL5Iv.js} +1 -1
  46. package/dist/assets/{ai-page.helpers-BJXRZxAg.js → ai-page.helpers-0GgLwuhe.js} +1 -1
  47. package/dist/assets/{assignment-candidates-C-vp0GeV.js → assignment-candidates-DqQ8QJRE.js} +1 -1
  48. package/dist/assets/{authed-media-Di9Z7PlD.js → authed-media-VxlsUR-Z.js} +1 -1
  49. package/dist/assets/{board-model-D8_8lFgX.js → board-model-DTatxzz-.js} +1 -1
  50. package/dist/assets/{client-B5Dgc4a1.js → client-CjUsH2ih.js} +3 -3
  51. package/dist/assets/{command-vocab-RptErntq.js → command-vocab-B5lwbaVw.js} +1 -1
  52. package/dist/assets/device-detail-CViRsVSZ.js +1 -0
  53. package/dist/assets/{device-integration-icon-C75O9UaZ.js → device-integration-icon-DRNFGMwO.js} +1 -1
  54. package/dist/assets/device-picker-model-DZUf4A44.js +1 -0
  55. package/dist/assets/{dist-ByTXC7_5.js → dist-B2iUE_dF.js} +3 -3
  56. package/dist/assets/{dist-BzRlGhlN.js → dist-e7zknvUU.js} +1 -1
  57. package/dist/assets/{format-CropjPL0.js → format-DMC9AnIW.js} +1 -1
  58. package/dist/assets/{hostInit-37sk2duA.js → hostInit-qJzSnSvz.js} +1 -1
  59. package/dist/assets/i18n-HP_ZA8Cj.js +1 -0
  60. package/dist/assets/{icons-B41RlJxa.js → icons-LCNDFamy.js} +1 -1
  61. package/dist/assets/{index-Bp_VBVht.js → index-DYgod6XH.js} +3 -3
  62. package/dist/assets/{linked-devices-model-C6UXmrf_.js → linked-devices-model-BD77HUQH.js} +1 -1
  63. package/dist/assets/{mf-entry-bootstrap-0-39d82738.js → mf-entry-bootstrap-0-f14661ef.js} +2 -2
  64. package/dist/assets/mount-DZUf4A44.js +1 -0
  65. package/dist/assets/{notification-rule-status-26Ti2nxE.js → notification-rule-status-DfwVGswl.js} +1 -1
  66. package/dist/assets/{player-overlays-BOFRnllQ.js → player-overlays-cnJlfjp-.js} +1 -1
  67. package/dist/assets/remoteEntry-C5wElYQv.js +1 -0
  68. package/dist/assets/src-Bsetma4r.js +272 -0
  69. package/dist/assets/{sso-popup-aDTs6CN7.js → sso-popup-zd7kZ7M8.js} +1 -1
  70. package/dist/assets/{step-inspector-model-CVpBquc0.js → step-inspector-model-BwX9grtK.js} +1 -1
  71. package/dist/assets/{use-scenes-feed-Pp99Ah_h.js → use-scenes-feed-DLdvcIp2.js} +1 -1
  72. package/dist/assets/{use-stationary-objects-BJuPuMfn.js → use-stationary-objects-CHMJijgk.js} +1 -1
  73. package/dist/assets/{useAdminDeviceRemoval-Dm7XHWnr.js → useAdminDeviceRemoval-am2_G0pf.js} +1 -1
  74. package/dist/assets/useEventInvalidation-DZUf4A44.js +1 -0
  75. package/dist/assets/{useNodeUrlSelection-C24zfVkQ.js → useNodeUrlSelection-CFdknlTi.js} +1 -1
  76. package/dist/assets/{useTemplateSave-G6zfft72.js → useTemplateSave-BxTzxTH2.js} +1 -1
  77. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DTyHuLCz.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BtWTuqL9.js} +2 -2
  78. package/dist/index.html +8 -8
  79. package/dist/server/addon.js +29 -16
  80. package/package.json +2 -2
  81. package/dist/assets/EmbedDevicePage-CsMjCBvF.js +0 -1
  82. package/dist/assets/InstancesTable-D8Us3F4Z.js +0 -1
  83. package/dist/assets/Integrations-BfvgnoX4.js +0 -1
  84. package/dist/assets/MyAccess-DeHDTQ-J.js +0 -2
  85. package/dist/assets/Notifications-CRjWfxzP.js +0 -1
  86. package/dist/assets/device-detail-DvxCspBZ.js +0 -1
  87. package/dist/assets/device-picker-model-Bj0f3vXg.js +0 -1
  88. package/dist/assets/i18n-CUhh5TVT.js +0 -1
  89. package/dist/assets/mount-Bj0f3vXg.js +0 -1
  90. package/dist/assets/remoteEntry-Dl1H5GB8.js +0 -1
  91. package/dist/assets/src-COXzZsML.js +0 -272
  92. package/dist/assets/useEventInvalidation-Bj0f3vXg.js +0 -1
@@ -1 +0,0 @@
1
- import{C as e,G as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,k as l,o as u,x as d,z as f}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as p,Fr as m,Jn as h,O as ee,Q as g,Rr as te,V as _,ct as ne,en as re,ir as ie,lr as ae,rr as oe,vt as se,ya as v}from"./player-overlays-BOFRnllQ.js";import{Er as y}from"./client-B5Dgc4a1.js";import{t as ce}from"./link-2-off-DmsjRAt7.js";import{Di as b,Dr as le,Ei as ue,Hi as de,Jf as x,Ka as S,Kf as C,Mi as w,Oi as T,Qa as E,Tc as D,Tr as fe,Vf as O,Xf as k,Z as pe,Zr as A,ar as j,br as M,jf as N,ji as P,ma as me,or as F,qf as I,tt as he,ua as ge}from"./src-COXzZsML.js";import{t as L}from"./useTranslation-BJr-n0es.js";import"./mount-Bj0f3vXg.js";import{At as _e,Ct as ve,Dt as ye,Et as R,G as be,Ot as xe,St as z,Tt as Se,_t as Ce,a as we,bt as B,dt as Te,ft as V,gt as Ee,ht as De,kt as Oe,li as H,oi as ke,pt as Ae,si as je,tt as U,vt as W,wt as G,xt as Me}from"./index-Bp_VBVht.js";import{t as K}from"./NodeAddonsSettingsPanel-Bf7oMHRP.js";c();function q(e,t){return e!==void 0&&e!==``?e:t??void 0}function J(e,t,n,r,i){let a=e(`instances.kindIconTip`,`{{kind}} · {{provider}}`,{kind:t,provider:n}),o=new Set((r??[]).map(e=>`${e.field}:${e.instanceId}`)),s=Object.entries(i).filter(([e])=>o.has(e)).map(([,e])=>e);return s.length===0?a:`${a} · ${s.map(t=>e(`instances.sendsVia`,`Sends via {{name}}`,{name:t})).join(` · `)}`}function Ne({addonId:t,label:n,providerName:r,iconUrl:o,links:c}){let{t:l}=L(),u=q(o,U(t)),[d,f]=s({}),p=i((e,t)=>{f(n=>{if(t===null){if(!(e in n))return n;let t={};for(let[r,i]of Object.entries(n))r!==e&&(t[r]=i);return t}return n[e]===t?n:{...n,[e]:t}})},[]),m=J(l,n,r,c,d);return e(`span`,{className:`inline-flex items-center gap-1.5 text-foreground-muted`,children:[e(C,{children:[a(x,{"aria-label":m,"data-testid":`kind-icon`,children:a(Y,{addonId:t,...o===void 0?{}:{iconUrl:o}})}),a(I,{children:m})]}),(c??[]).map(e=>a(Pe,{link:e,ownIcon:u,onFold:p},`${e.field}:${e.instanceId}`)),n]})}function Pe({link:n,ownIcon:r,onFold:i}){let{t:o}=L(),s=B(ge({functionCap:n.cap,...n.kind===void 0?{}:{kind:n.kind}}).data??[],n),c=q(s?.iconUrl,U(s?.addonId)),l=s!==void 0&&c===r,u=`${n.field}:${n.instanceId}`,d=l&&s!==void 0?s.name:null;if(t(()=>{i(u,d)},[d,u,i]),s===void 0||l)return null;let f=o(`instances.sendsVia`,`Sends via {{name}}`,{name:s.name});return e(C,{children:[a(x,{"aria-label":f,"data-testid":`linked-instance-badge`,children:a(Y,{addonId:s.addonId,...s.iconUrl===void 0?{}:{iconUrl:s.iconUrl},small:!0})}),a(I,{children:f})]})}function Y({addonId:e,iconUrl:t,small:n}){let r=U(e),[i,o]=s(new Set),c=[t,r].find(e=>typeof e==`string`&&e!==``&&!i.has(e));return c===void 0?null:a(`img`,{src:g(c),alt:``,className:n===!0?`h-3 w-3 shrink-0 rounded-sm`:`h-4 w-4 shrink-0 rounded`,onError:()=>o(e=>new Set([...e,c]))})}var Fe=[[[`addons`,`listCapabilityProviders`]],[[`addons`,`list`]]],Ie=`text-[10px]`;function X(){let e=u();return S({onSuccess:()=>{for(let t of Fe)e.invalidateQueries({queryKey:t})}})}function Z({addonId:t,displayName:n,message:r}){let{t:i}=L(),o=ne(),s=X(),c=i(`integrationHub.addonControls.restartNamed`,`Restart {{name}}`,{name:n});return e(C,{children:[a(x,{children:a(k,{icon:s.isPending?m:h,variant:`ghost`,size:`sm`,"aria-label":c,disabled:s.isPending,onClick:()=>void o({title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:n}),message:r,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),variant:`danger`}).then(e=>e?s.mutateAsync({addonId:t}):void 0)})}),a(I,{children:c})]})}function Le({addonId:e,displayName:t,iconOnly:n=!1,description:r}){let{t:i}=L(),o=X(),s=r??i(`integrationHub.addonControls.restartingTheAddonBouncesIts`,`Restarting the addon bounces its subprocess — the provider will briefly drop and reconnect automatically.`);return n?a(Z,{addonId:e,displayName:t,message:s}):a(M,{label:i(`integrationHub.addonControls.restart`,`Restart`),icon:h,size:`sm`,title:i(`integrationHub.addonControls.restart2`,`Restart "{{displayName}}"?`,{displayName:t}),description:s,confirmLabel:i(`integrationHub.addonControls.restart`,`Restart`),triggerVariant:`ghost`,confirmVariant:`danger`,disabled:o.isPending,action:()=>o.mutateAsync({addonId:e})})}c();var Re=600,Q=l(null);function ze({id:t,title:r,icon:i,actions:o,framed:s=!1,children:c}){let{t:l}=L(),u=f(Q),p=n(null),m=`integration-section-${t}`;Be(p,u,t);let h=e(d,{children:[u===null?null:a(H,{to:u.sectionHref(t),"aria-label":l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),title:l(`integrationHub.integrationSection.linkTo`,`Link to {{title}}`,{title:r}),className:`rounded p-0.5 text-foreground-subtle/60 hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40`,children:a(te,{className:`h-3 w-3`,"aria-hidden":!0})}),o]});return s?a(`div`,{ref:p,className:`scroll-mt-4`,children:a(fe,{headingId:m,title:r,icon:i,actions:h,children:c})}):e(`section`,{ref:p,"aria-labelledby":m,className:`scroll-mt-4 space-y-2`,children:[e(`header`,{className:`flex min-h-7 flex-wrap items-center gap-2 px-0.5`,children:[i!==void 0&&a(i,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`,"aria-hidden":!0}),a(`h2`,{id:m,className:`${_} min-w-0 flex-1`,children:r}),h]}),c]})}function Be(e,t,n){let r=t?.requestedSection===n,i=t?.integrationId;o(()=>{if(!r)return;let t=()=>e.current?.scrollIntoView?.({block:`start`});t();let n=!1,i=()=>{n=!0},a=[`wheel`,`touchmove`,`keydown`];for(let e of a)window.addEventListener(e,i,{once:!0,passive:!0});let o=window.setTimeout(()=>{n||t()},Re);return()=>{window.clearTimeout(o);for(let e of a)window.removeEventListener(e,i)}},[r,i,e])}c();var Ve=`max-h-72`,He=[{kind:`logs`,labelKey:`common.logs`,icon:p},{kind:`events`,labelKey:`common.events`,icon:v}];function Ue({addonId:t,switcher:n}){let{t:r}=L(),[i,o]=s(`logs`);return e(ze,{id:we,title:r(`integrationHub.addonIntegrationBody.activity`,`Activity`),framed:!0,actions:a(`div`,{className:`flex flex-wrap items-center gap-2`,children:a(`div`,{role:`group`,"aria-label":r(`integrationHub.addonIntegrationBody.activityStream`,`Activity stream`),className:`flex items-center gap-1`,children:He.map(({kind:t,labelKey:n,icon:s})=>e(O,{variant:`unstyled`,type:`button`,"aria-pressed":i===t,onClick:()=>o(t),className:`inline-flex items-center gap-1 rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${i===t?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(s,{className:`h-3 w-3`,"aria-hidden":!0}),r(n)]},t))})}),children:[n!==void 0&&a(`div`,{className:`px-3 pt-2`,children:n}),i===`logs`?a(F,{addonId:t,maxHeight:Ve,showFilters:!1}):a(j,{addonId:t,category:`addon.*`,maxHeight:Ve})]})}function We({addonId:t,title:n=`Settings`,subtitle:r,fieldScope:i,onClose:o}){return a(ue,{open:!0,onOpenChange:e=>!e&&o(),children:e(T,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,className:`md:max-w-3xl`,children:[e(P,{children:[a(w,{children:n}),r&&a(`p`,{className:`text-xs text-foreground-subtle`,children:r})]}),a(b,{children:a(K,{nodeId:null,addonIds:[t],level:`global`,...i===void 0?{}:{fieldScope:i}})})]})})}function Ge({addonId:e,title:t,onClose:n}){return a(We,{addonId:e,title:t,fieldScope:`cluster`,onClose:n})}c();var Ke={md:{tile:`h-10 w-10 rounded-lg`,img:`h-7 w-7 rounded-md p-1`,fallback:`h-5 w-5`},sm:{tile:`h-5 w-5 rounded`,img:`h-5 w-5 rounded p-0.5`,fallback:`h-3.5 w-3.5`}};function qe({addonId:e,fallback:t,tileClassName:n,size:r=`md`}){let[i,o]=s(!1),c=U(e),l=Ke[r];return a(`div`,{className:`${l.tile} flex items-center justify-center shrink-0 ${n}`,children:i||!c?a(t,{className:l.fallback,"aria-hidden":!0}):a(`img`,{src:c,alt:``,className:`${l.img} bg-white ring-1 ring-black/5`,onError:()=>o(!0)})})}var Je={ok:`bg-success`,off:`bg-foreground-subtle/60`,error:`bg-danger`,unknown:`border border-foreground-subtle bg-transparent`};function Ye(e,t){switch(t){case`ok`:return e(`instances.health.ok`,`Healthy`);case`error`:return e(`instances.health.error`,`Error`);case`off`:return e(`instances.health.off`,`Off`);case`unknown`:return e(`instances.health.unknown`,`Unknown`)}}function Xe({pills:t,selected:n,onSelect:r,fallbackIcon:i,install:o}){let{t:s}=L(),c=t.length>1;return!c&&o===void 0?null:a(`div`,{className:`px-3 pt-2`,children:e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[c&&a(`div`,{role:`group`,"aria-label":s(`instances.filterByProvider`,`Filter by provider`),className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:t.map(t=>e(O,{variant:`unstyled`,type:`button`,"aria-pressed":n===t.addonId,"data-testid":`instance-pill-${t.addonId}`,onClick:()=>r(n===t.addonId?null:t.addonId),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 ${n===t.addonId?`border-primary bg-primary/10 text-primary font-medium`:`border-border bg-surface text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:[a(qe,{addonId:t.addonId,fallback:i,tileClassName:``,size:`sm`}),a(`span`,{className:`truncate`,children:t.name}),a(`span`,{className:`shrink-0 text-[10px] font-normal text-foreground-subtle`,children:t.count}),a(`span`,{className:`h-1.5 w-1.5 shrink-0 rounded-full ${Je[t.health]}`,"aria-hidden":!0}),a(`span`,{className:`sr-only`,children:Ye(s,t.health)})]},t.addonId))}),o!==void 0&&e(H,{to:y(o.capability),className:`inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-full border py-1 pl-1 pr-2.5 text-xs transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 border-dashed border-border pl-2 text-foreground-subtle hover:border-primary/50 hover:text-foreground`,children:[a(oe,{className:`h-3.5 w-3.5 shrink-0`,"aria-hidden":!0}),a(`span`,{className:`truncate`,children:o.label})]})]})})}function Ze(e){let t=D({onSuccess:e.onSuccess,onError:t=>e.onError?.(t.message)});return{mutate:e=>t.mutate({...e}),isPending:t.isPending}}c();function Qe({row:t,pinning:n,onChanged:r}){let{t:i}=L(),o=u(),[c,l]=s(null),d=Ze({onSuccess:()=>{l(null),o.invalidateQueries({queryKey:[V]}),r?.()},onError:l}),f=t.notRunning===void 0?null:i(`providerInstances.addonNotRunning`,`{{addon}} is not running: start it first`,{addon:t.providerName});return e(`span`,{className:`flex flex-col items-end gap-1`,title:f??void 0,children:[a(A,{checked:t.enabled,disabled:d.isPending||f!==null,"aria-label":i(`providerInstances.enable`,`Enable {{name}}`,{name:t.name}),"data-testid":`instance-switch-${t.id}`,onCheckedChange:e=>{l(null),d.mutate({addonId:t.addonId,id:t.id,enabled:e})}}),f!==null&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:f}),n>0&&a(`span`,{className:`text-[11px] text-foreground-subtle`,children:i(`providerInstances.pinnedBy`,{count:n})}),c!==null&&a(`span`,{className:`text-[11px] text-danger`,role:`alert`,children:i(`providerInstances.switchFailed`,`Could not change {{name}}: {{message}}`,{name:t.name,message:c})})]})}c();var $e=`instance`;function $(t){return e(C,{children:[a(x,{children:a(k,{...t})}),a(I,{children:t[`aria-label`]})]})}function et(e){let t=[e.status?.detail,e.lastCheckedAt===void 0?void 0:new Date(e.lastCheckedAt).toLocaleString()].filter(e=>e!==void 0&&e.length>0);return t.length>0?t.join(` · `):void 0}function tt({row:t}){let{t:n}=L();return t.enabled?e(`span`,{className:`flex flex-wrap items-center gap-1`,children:[a(N,{variant:t.configured?`success`:`default`,children:t.configured?n(`providerInstances.configured`,`Configured`):n(`providerInstances.notConfigured`,`Not configured`)}),t.status!==void 0&&a(N,{variant:t.status.state===`error`?`danger`:t.status.state===`ok`?`success`:`default`,title:et(t),children:R(t.status)})]}):a(`span`,{className:`flex flex-wrap items-center gap-1`,children:a(N,{variant:`default`,children:n(`providerInstances.off`,`Off`)})})}function nt({row:e,functionCap:t}){let{t:n}=L(),r=u(),i=E({onSuccess:()=>void r.invalidateQueries()});return a(A,{checked:e.isActive,disabled:i.isPending,"aria-label":n(`providerInstances.enable`,`Enable {{name}}`,{name:e.providerName}),onCheckedChange:n=>i.mutate({capName:t,addonId:e.addonId,enabled:n})})}function rt({functionCap:t,icon:n,title:o,subtitle:c,emptyTitle:l,emptyDescription:f,addLabel:p,install:h,extraColumns:g,lead:_,rowActions:v,fixedRowActions:y,canDelete:b,pageActions:ue,typedId:x,rowFilter:S,testLabel:C,testHint:w}){let{t:T}=L(),E=se(),D=u(),k=ne(),A=Ae(t),j=pe({editKey:$e,newKey:`${$e}-new`}),[M,P]=s(null),[F,I]=s(null),R=ge({functionCap:`notification-output`}),z=i(e=>ye(R.data??[],e).length,[R.data]),[Se,we]=s(null),[B,Te]=s(null),H=r(()=>Ee(A.holders),[A.holders]),U=r(()=>ve(A.functionProviders,A.rows,A.displayNames),[A.functionProviders,A.rows,A.displayNames]),G=U.some(e=>e.addonId===B)?B:null,Me=r(()=>{let e=Ce(A.rows,G);return S===void 0?e:e.filter(S)},[A.rows,G,S]),K=i(e=>A.displayNames.get(e)??e,[A.displayNames]),q=i(async e=>{P(e.key),I(null);try{let t=await E.trpcClient.integrationInstances.testInstance.mutate({addonId:e.addonId,id:e.id,values:{}});I({name:e.name,verdict:_e(t)})}catch(t){let n=t instanceof Error?t.message:String(t);I({name:e.name,verdict:{status:`inconclusive`,error:n}})}finally{P(null)}},[E]),J=i(async e=>{let t=ye(R.data??[],e.id),n=t.length>0?` ${T(`providerInstances.deletePinned`,`These notification targets use it and will stop delivering: {{names}}.`,{names:t.join(`, `)})}`:``;if(await k({title:T(`providerInstances.deleteTitle`,`Delete {{name}}?`,{name:e.name}),message:`${T(`providerInstances.deleteMessage`,`The record and its stored credentials are removed.`)}${n}`,confirmLabel:T(`common.delete`,`Delete`),variant:`danger`}))try{await E.trpcClient.integrationInstances.deleteInstance.mutate({addonId:e.addonId,id:e.id}),await D.invalidateQueries({queryKey:[V]})}catch(t){xe({title:T(`providerInstances.deleteFailed`,`Could not delete`),message:`${e.name}: ${t instanceof Error?t.message:String(t)}`,severity:`critical`})}},[k,D,E,T,R.data]),Pe=r(()=>A.rows.some(e=>e.kind===`instance`&&e.kindLabel!==void 0),[A.rows]),Y=i((e,t)=>{e!==void 0&&je(ke(e,t),()=>{D.invalidateQueries({queryKey:[V]})})},[D]),Fe=r(()=>[{key:`name`,nowrap:!1,header:T(`providerInstances.colName`,`Name`),sortValue:e=>e.name,render:t=>e(`span`,{className:`flex flex-col`,children:[a(`span`,{className:`font-medium ${t.kind===`instance`&&!t.enabled?`text-foreground-muted`:`text-foreground`}`,children:t.name}),t.kind===`fixed`&&t.description.length>0&&a(`span`,{className:`line-clamp-2 text-[11px] text-foreground-subtle`,title:t.description,children:t.description})]})},{key:`provider`,header:T(`providerInstances.colProvider`,`Provider`),sortValue:e=>e.providerName,render:e=>a(`span`,{className:`text-foreground-muted`,children:e.providerName})},...Pe?[{key:`kind`,header:T(`providerInstances.colKind`,`Kind`),sortValue:e=>e.kind===`instance`?e.kindLabel??``:``,render:e=>e.kind===`instance`&&e.kindLabel!==void 0&&e.kindLabel.length>0?a(Ne,{addonId:e.addonId,providerName:e.providerName,label:e.kindLabel,...e.kindIconUrl===void 0?{}:{iconUrl:e.kindIconUrl},...e.links===void 0?{}:{links:e.links}}):a(`span`,{className:`text-foreground-muted`})}]:[],{key:`state`,header:T(`instances.colStatus`,`Status`),notSortableReason:T(`providerInstances.stateNotSortable`,`A row carries a badge, not a value to order by.`),render:e=>e.kind===`instance`?a(tt,{row:e}):a(N,{variant:e.isActive?`success`:`default`,children:e.isActive?T(`instances.active`,`Active`):T(`providerInstances.off`,`Off`)})},{key:`on`,header:T(`providerInstances.colOn`,`On`),notSortableReason:T(`providerInstances.onNotSortable`,`A switch is not a value to order by.`),render:e=>e.kind===`fixed`?a(nt,{row:e,functionCap:t}):a(Qe,{row:e,pinning:z(e.id)})},...g??[],{key:`actions`,align:`right`,notSortableReason:T(`providerInstances.actionsNotSortable`,`Row actions are not values.`),render:t=>e(`span`,{className:`inline-flex items-center gap-1`,children:[t.kind===`instance`&&t.connectPath!==void 0&&a($,{icon:te,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.connectRow`,`Connect {{name}}`,{name:t.name}),onClick:()=>Y(t.connectPath,t.id)}),t.kind===`instance`&&t.disconnectPath!==void 0&&a($,{icon:ce,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.disconnectRow`,`Disconnect {{name}}`,{name:t.name}),onClick:()=>Y(t.disconnectPath,t.id)}),t.kind===`instance`&&t.canTest&&a($,{icon:M===t.key?m:ie,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.testRow`,`Test {{name}}`,{name:t.name}),disabled:M!==null,onClick:()=>void q(t)}),t.kind===`instance`&&v?.(t),t.kind===`fixed`&&y?.(t),a($,{icon:ae,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.editRow`,`Edit {{name}}`,{name:t.name}),onClick:()=>j.openEdit(W(t.addonId,t.kind===`instance`?t.id:void 0))}),a(Le,{iconOnly:!0,addonId:t.addonId,displayName:t.providerName,description:T(`providerInstances.restartConfirm`,`Restarts the addon on the hub. If it shares a runner group, every addon in that group restarts with it.`)}),t.kind===`instance`&&(b?.(t)??!0)&&a($,{icon:re,variant:`ghost`,size:`sm`,"aria-label":T(`providerInstances.deleteRow`,`Delete {{name}}`,{name:t.name}),onClick:()=>void J(t)})]})}],[g,j,t,z,v,y,b,J,Y,q,Pe,T,M]),Ie;Ie=A.state===`error`?a(`div`,{className:`p-3`,children:a(me,{title:T(`providerInstances.loadFailed`,`Could not load the list`),message:A.error??``,onRetry:A.refetch})}):A.state===`pending`?e(`div`,{className:`flex items-center gap-2 p-3 text-xs text-foreground-subtle`,children:[a(m,{className:`h-3 w-3 animate-spin`}),T(`providerInstances.loading`,`Loading…`)]}):A.rows.length===0?a(de,{icon:n,title:l,description:f}):a(le,{columns:Fe,rows:Me,rowKey:e=>e.key,bordered:!1,emptyMessage:T(`instances.noneForProvider`,`This provider has no instance yet.`)});let X=A.holders.filter(e=>!H.includes(e)).map(e=>K(e.addonId)),Z=H.length>0?void 0:X.length>0?T(`instances.addBlocked`,`{{names}}: only one instance is allowed and it already exists.`,{names:X.join(`, `)}):T(`instances.addNone`,`No provider here can hold instances.`),Re=H.filter(e=>e.addonId===G),Q=De(Re.length>0?Re:H,K),ze=e(d,{children:[c!==void 0&&a(`p`,{className:`px-3 pt-2 text-xs text-foreground-muted`,children:c}),A.state===`ready`&&Z!==void 0&&a(`p`,{className:`px-3 pt-1 text-[11px] text-foreground-subtle`,children:Z}),A.state===`ready`&&e(d,{children:[e(he,{children:[ue?.(A.rows.filter(e=>e.kind===`instance`)),e(O,{size:`sm`,variant:`primary`,disabled:Z!==void 0,title:Z,onClick:()=>{let e=Q.length===1?Q[0]:void 0;e===void 0?j.openNew():j.openEdit(W(e.addonId,null,e.kind))},children:[a(oe,{className:`h-3.5 w-3.5`}),p]})]}),a(Xe,{pills:U,selected:G,onSelect:Te,fallbackIcon:n,...h===void 0?{}:{install:h}})]}),Ie,A.state===`ready`&&A.rows.length>0&&a(it,{rows:A.rows,selected:Se,onSelect:we}),F!==null&&e(`div`,{className:`space-y-1 p-3`,children:[a(`p`,{className:`text-[11px] font-medium text-foreground`,children:F.name}),a(Oe,{verdict:F.verdict})]}),A.state===`ready`&&j.state.mode===`new`&&a(be,{open:!0,onClose:j.close,pickFrom:{title:p,providers:Q.map(e=>({addonId:e.addonId,name:e.label,description:e.kind===void 0?A.descriptions.get(e.addonId)??``:e.providerName,...e.kind===void 0?{}:{kind:e.kind},...e.iconUrl===void 0?{}:{iconUrl:e.iconUrl}})),onPick:(e,t)=>j.openEdit(W(e,null,t))}}),A.state===`ready`&&j.state.mode===`edit`&&a(at,{refValue:j.state.id,data:A,nameOf:K,onClose:j.close,functionCap:t,onOpen:(e,t)=>j.openEdit(W(e,t)),..._===void 0?{}:{lead:_},...x===void 0?{}:{typedId:x},...C===void 0?{}:{testLabel:C},...w===void 0?{}:{testHint:w}},j.state.id)]});return o===void 0?a(`section`,{"aria-label":p,className:ee,children:ze}):a(fe,{headingId:`provider-instances-${t}`,title:o,icon:n,children:ze})}function it({rows:e,selected:t,onSelect:n}){let{t:i}=L(),o=r(()=>G(e),[e]),s=o[0];if(s===void 0)return null;let c=o.find(e=>e.addonId===t)??s;return a(`div`,{className:`p-3`,children:a(Ue,{addonId:c.addonId,switcher:o.length>1?a(`div`,{role:`group`,"aria-label":i(`providerInstances.activityProvider`,`Activity of`),className:`flex flex-wrap items-center gap-1`,children:o.map(e=>a(O,{variant:`unstyled`,type:`button`,"aria-pressed":e.addonId===c.addonId,onClick:()=>n(e.addonId),className:`rounded px-2 py-0.5 text-[11px] font-medium transition-colors ${e.addonId===c.addonId?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover hover:text-foreground`}`,children:e.name},e.addonId))}):void 0})})}function at({refValue:e,data:t,nameOf:n,onClose:r,onOpen:i,lead:o,typedId:s,functionCap:c,testLabel:l,testHint:u}){let d=z(e);if(d.kind===`fixed`)return a(Ge,{addonId:d.addonId,title:n(d.addonId),onClose:r});let f=t.holders.find(e=>e.addonId===d.addonId);if(f===void 0)return null;let p=d.kind===`instance`?f.instances.find(e=>e.id===d.id)??null:null;if(d.kind===`instance`&&p===null)return null;let m=d.kind===`create`&&d.kindId!==void 0?Se(f.description,c,d.kindId):null,h=m??f.description,ee=m!==null&&Me(f.description)?m.kinds?.[0]?.label:void 0,g=t.rows.find(e=>e.kind===`instance`&&e.addonId===d.addonId&&e.id===p?.id);return a(ot,{addonId:d.addonId,...o!==void 0&&g!==void 0?{lead:o(g)}:{},providerName:ee??n(d.addonId),description:h,instance:p,onClose:r,onOpen:i,...s===void 0?{}:{typedId:s},...l===void 0?{}:{testLabel:l},...u===void 0?{}:{testHint:u}})}function ot(e){let{onOpen:t,onClose:r,onSaved:i,...o}=e,s=n(null),c=e.instance===null;return a(Te,{...o,onSaved:e=>{c&&(s.current=e),i?.(e)},onClose:()=>{s.current===null?r():t(e.addonId,s.current)}})}export{qe as n,Ie as r,rt as t};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,V as i,Y as a,et as o,x as s}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Br as c,Fr as l,Ga as u,Jn as d,Qi as f,Zn as p,ea as m,nr as h,rr as ee,vt as g,zn as _}from"./player-overlays-BOFRnllQ.js";import{t as v}from"./chevron-down-CBb-F8DT.js";import{t as y}from"./table-2-DMxm3oyu.js";import{$o as te,Ac as ne,Ba as re,Cs as ie,Di as ae,Dt as oe,Ei as b,Es as se,Mi as x,Oi as S,Vf as C,W as w,Yf as T,a as ce,gt as le,ht as ue,jc as de,ji as fe,ma as pe,ms as E,nr as me,vt as he}from"./src-COXzZsML.js";import{t as D}from"./i18n-CUhh5TVT.js";import{t as O}from"./useTranslation-BJr-n0es.js";import{$ as ge,G as _e,K as ve,Q as ye,X as be,Y as k,Z as A,ct as xe,di as Se,et as Ce,fi as we,it as Te,mi as Ee,nt as j,rt as De}from"./index-Bp_VBVht.js";import{t as Oe}from"./AdminPage-B3Kuwjd2.js";import"./useEventInvalidation-Bj0f3vXg.js";import{t as ke}from"./device-integration-icon-C75O9UaZ.js";o();function Ae(e){return e.some(e=>e.status===`running`)?`running`:e.some(e=>e.status===`stopped`)?`stopped`:`disabled`}function je(e,t){let n=new Map;for(let t of e){let e=n.get(t.addonId);e===void 0?n.set(t.addonId,[t]):e.push(t)}return[...n.entries()].map(([e,n])=>{let r=t.get(e)?.trim()??``;return{addonId:e,name:r.length>0?r:n[0]?.name??e,instances:n,instanceCount:n.length,deviceCount:n.reduce((e,t)=>e+t.deviceCount,0),status:Ae(n)}})}var Me=3e3,M=new Set([`no-provider`,`node-offline`,`transport-failed`]),N=[`provider not available`,`failed to fetch`,`networkerror`,`load failed`];function Ne(e){if(typeof e!=`object`||!e)return null;let t=Reflect.get(e,`data`);if(typeof t!=`object`||!t)return null;let n=Reflect.get(t,`capRouteReason`);return typeof n==`string`?n:null}function P(e,t){if(e==null||t>10)return!1;let n=Ne(e);if(n!==null)return M.has(n);let r=(e instanceof Error?e.message:String(e)).toLowerCase();return N.some(e=>r.includes(e))}function Pe(e){return P(e.state.error,e.state.errorUpdateCount)?Me:!1}function Fe({providers:n,system:i,onOpen:o,searchPlaceholder:s,emptyLabel:c}){let[l,u]=a(``),d=t(()=>{let e=l.trim().toLowerCase(),t=t=>e.length===0||`${t.name} ${t.addonId} ${t.instances.map(e=>e.name).join(` `)}`.toLowerCase().includes(e);return{providers:n.filter(t),system:i.filter(t)}},[l,n,i]),f=d.providers.length===0&&d.system.length===0;return e(`div`,{className:`space-y-3`,children:[e(`div`,{className:`relative`,children:[r(_,{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}),r(T,{type:`search`,value:l,onChange:e=>u(e.target.value),placeholder:s,"aria-label":s,className:`pl-8`})]}),f?r(`p`,{className:`py-8 text-center text-xs text-foreground-subtle`,children:c}):e(`div`,{className:`space-y-4`,children:[d.providers.length>0&&r(A,{kind:`providers`,children:r(F,{groups:d.providers,onOpen:o})}),d.system.length>0&&r(A,{kind:`system`,children:r(F,{groups:d.system,onOpen:o})})]})]})}function F({groups:e,onOpen:n}){let{t:i,i18n:a}=O();return r(ge,{children:t(()=>j(e,a.language),[e,a.language]).map(e=>r(ye,{testId:`integration-card-${e.addonId}`,addonId:e.addonId,name:e.name,openLabel:i(`integrations.openNamed`,{name:e.name,defaultValue:`Open {{name}}`}),onOpen:()=>n(e),body:r(`p`,{className:`text-xs text-foreground-muted`,children:i(`integrations.addonCard.summary`,{integrations:i(`integrations.addonCard.integrationCount`,{count:e.instanceCount}),devices:i(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount}),defaultValue:`{{integrations}} · {{devices}}`})}),footer:r(w,{status:e.status,className:`shrink-0`})},e.addonId))})}o();var I=`camstack.admin.integrations.view`;function L(e){return e===`table`||e===`grid`}function R(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function z(e=R()){if(e===null)return`table`;try{let t=e.getItem(I);return L(t)?t:`table`}catch{return`table`}}function B(e,t=R()){if(t!==null)try{t.setItem(I,e)}catch{}}function Ie(){let[e,t]=a(()=>z());return[e,n(e=>{t(e),B(e)},[])]}function V({integration:t,expanded:n,onToggleExpand:i}){let{t:a}=O();return e(`div`,{className:`flex items-center gap-2.5`,children:[r(C,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),i(t.addonId)},"aria-label":n?a(`integrations.integrationColumns.collapse`,`Collapse`):a(`integrations.integrationColumns.expand`,`Expand`),"aria-expanded":n,className:`flex h-5 w-5 flex-shrink-0 items-center justify-center rounded text-foreground-subtle transition-colors hover:bg-surface-hover hover:text-foreground`,children:r(n?v:f,{className:`h-3.5 w-3.5`})}),r(Ce,{type:t.addonId,size:`sm`}),e(`div`,{className:`flex min-w-0 flex-col`,children:[r(`span`,{className:`truncate text-xs font-semibold text-foreground`,children:t.name}),r(`span`,{className:`truncate text-[10px] text-foreground-subtle`,children:t.addonId})]})]})}function Le(e){let{isExpanded:t,onToggleExpand:n}=e;return[{key:`name`,header:D.t(`integrations.integrationColumns.integration`,`Integration`),headerClassName:`w-[55%]`,cell:e=>r(V,{integration:e,expanded:t(e),onToggleExpand:n})},{key:`devices`,header:D.t(`integrations.integrationColumns.devices`,`Devices`),headerClassName:`w-[15%]`,cellClassName:`text-[11px] text-foreground-subtle`,cell:e=>D.t(`integrations.integrationColumns.deviceCount`,{count:e.deviceCount})},{key:`status`,header:D.t(`integrations.integrationColumns.status`,`Status`),headerClassName:`w-[15%]`,cell:e=>r(w,{status:e.status})}]}o();var H=6e4;function Re({onSetupIntegration:t}){let{t:n}=O(),[i,o]=a(!1),c=se({},{refetchInterval:H}),l=c.data?.proposals??[];return l.length===0?null:e(s,{children:[e(`div`,{role:`status`,"data-testid":`discovery-banner`,className:`flex flex-wrap items-center gap-2 rounded-lg border border-info/30 bg-info/10 px-3 py-2 text-xs text-foreground`,children:[r(p,{className:`h-3.5 w-3.5 text-info`,"aria-hidden":!0}),r(`span`,{className:`flex-1`,children:n(`integrations.discoveryBanner.count`,{defaultValue_one:`{{count}} new device found`,defaultValue_other:`{{count}} new devices found`,count:l.length})}),r(C,{variant:`secondary`,size:`sm`,onClick:()=>o(!0),children:n(`integrations.discoveryBanner.review`,`Review`)})]}),r(U,{open:i,onClose:()=>o(!1),proposals:l,onChanged:()=>void c.refetch(),onSetupIntegration:e=>{o(!1),t(e)}})]})}function U({open:t,onClose:i,proposals:o,onChanged:c,onSetupIntegration:u}){let{t:d}=O(),f=te(),h=E(),[ee,g]=a(new Set),_=n(async(e,t)=>{g(t=>new Set(t).add(e));try{await t(),c()}catch{}finally{g(t=>{let n=new Set(t);return n.delete(e),n})}},[c]),v=n(async e=>{let t=k(e.addonId,e.candidate);if(t!==null){u(t);return}await _(e.id,()=>f.mutateAsync({addonId:e.addonId,candidate:e.candidate}))},[f,u,_]),y=n(e=>_(e.id,()=>h.mutateAsync({id:e.id})),[h,_]);return r(b,{open:t,onOpenChange:e=>!e&&i(),children:e(S,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[r(fe,{children:r(x,{children:e(`span`,{className:`flex items-center gap-2`,children:[r(p,{className:`h-4 w-4 text-primary`}),d(`integrations.discoveryBanner.title`,`New devices found`)]})})}),r(ae,{className:`space-y-1.5`,children:o.map(t=>e(`div`,{"data-testid":`discovery-proposal`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2`,children:[e(`div`,{className:`min-w-0 flex-1`,children:[r(`p`,{className:`truncate text-sm font-medium text-foreground`,children:t.candidate.suggestedName}),r(`p`,{className:`truncate text-xs text-foreground-muted`,children:t.addonId})]}),ee.has(t.id)?r(l,{className:`h-4 w-4 animate-spin text-foreground-muted`,"aria-hidden":!0}):e(s,{children:[r(C,{variant:`secondary`,size:`sm`,onClick:()=>void y(t),children:d(`integrations.discoveryBanner.dismiss`,`Dismiss`)}),e(C,{size:`sm`,onClick:()=>void v(t),children:[r(m,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),d(`integrations.discoveryBanner.adopt`,`Adopt`)]})]})]},t.id))})]})})}o();function ze(e){if(!e.enabled&&e.switchUnknown!==!0)return`disabled`;switch(e.processState){case`running`:return`running`;default:return`stopped`}}var W=`expand`;function G(){let{t:o}=O(),l=we(),f=Se(),m=g(),[_]=Ee(),[v,te]=Ie(),[ae,b]=a(!1),[se,x]=a(null),S=n(()=>{x(null),b(!0)},[]),w=n(()=>{b(!1),x(null)},[]),T=n(e=>{E(!1),x(e),b(!0)},[]),[fe,E]=a(!1);i(()=>{let e=be(f.state);e!==null&&(x(e),b(!0),l(`/integrations`,{replace:!0,state:null}))},[f.state,l]);let D=_.get(`setup`);i(()=>{D===null||D.length===0||(x({addonId:D,name:D,config:{}}),b(!0))},[D]);let ge=n(()=>E(!0),[]),ye=n(()=>E(!1),[]);ce([`integrations`],[`integration.enabled`,`integration.disabled`,`integration.deleted`,`provider.started`,`provider.stopped`,`addon.installed`,`addon.uninstalled`,`addon.started`,`addon.stopped`,`addon.updated`]),ce([`deviceManager`],[`device.registered`,`device.unregistered`,`device.online`,`device.offline`,`device.disabled`,`device.enabled`]);let{data:k,isLoading:Ce,isError:j,error:Ae,errorUpdateCount:Me,refetch:M}=de(void 0,{refetchInterval:Pe}),{data:N,isLoading:Ne,isError:F,error:I,errorUpdateCount:L,refetch:R}=ie({projection:`slim`},{refetchInterval:Pe}),z=t(()=>N??[],[N]),B=t(()=>k??[],[k]),V=t(()=>oe(z),[z]),H=t(()=>le(k),[k]),U=t(()=>{let e=new Map;for(let t of he(z)){let n=H(t);if(n.kind!==`resolved`)continue;let r=n.integration.id;e.set(r,(e.get(r)??0)+1)}return e},[z,H]),G=t(()=>B.map(e=>({id:e.id,addonId:e.addonId,name:e.name,enabled:e.enabled,status:ze(e),deviceCount:U.get(e.id)??0})),[B,U]),{data:Be}=ne(),Ve=t(()=>new Map((Be??[]).map(e=>[e.addonId,e.name])),[Be]),He=_.get(W),Ue=n(e=>{let t=new URLSearchParams(window.location.search);t.get(W)===e?t.delete(W):t.set(W,e);let n=t.toString(),r=`${window.location.pathname}${n?`?${n}`:``}${window.location.hash}`;window.history.replaceState(window.history.state,``,r),window.dispatchEvent(new PopStateEvent(`popstate`))},[]),{data:We}=re(void 0),K=t(()=>Te(We),[We]),q=t(()=>De(G,K),[G,K]),Ge=t(()=>De(je(G,Ve),K),[G,Ve,K]),Ke=n(e=>l(xe(e.addonId)),[l]),qe=n(e=>l(xe(e.addonId,e.id)),[l]),Je=n(e=>V.get(e)??null,[V]),Ye=n(e=>l(`/devices/${String(e)}`),[l]),Xe=n(e=>r(ue,{context:`integration-detail`,devices:z,trpc:m.trpcClient,integrationOf:H,forceIntegrationId:e.id,urlScope:`nested`,lsKey:`integrations:nested:${e.addonId}`,resolveIntegrationIcon:ke,resolveParent:Je,onNavigate:Ye}),[z,m.trpcClient,H,Je,Ye]),J=n(e=>He===e.addonId,[He]),Ze=t(()=>Le({isExpanded:J,onToggleExpand:Ue}),[J,Ue]),Qe=n(e=>`${e.name} ${e.addonId}`,[]),$e=n(e=>e.id,[]),et=e=>r(ue,{mode:`generic`,items:e,getKey:$e,getSearchText:Qe,columns:Ze,onRowClick:qe,isExpanded:J,renderExpanded:Xe,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),Y=n(()=>{M(),R()},[M,R]),tt=j===!0&&P(Ae,Me),nt=F===!0&&P(I,L),X=tt||nt,Z=j===!0&&!tt||F===!0&&!nt,Q=!Z&&!X&&(Ce||Ne||k===void 0||N===void 0),$=B.length>0,rt=[{id:`table`,label:o(`integrations.viewTable`,`Table`),icon:y},{id:`grid`,label:o(`integrations.viewGrid`,`Grid`),icon:c}];return e(Oe,{icon:h,title:o(`nav.integrations`,`Integrations`),actions:e(s,{children:[r(me,{ariaLabel:o(`integrations.viewLabel`,`Layout`),value:v,onChange:te,options:rt,testId:`integrations-view`}),r(C,{variant:`unstyled`,onClick:Y,disabled:Q,className:`flex items-center gap-1 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors disabled:opacity-50`,title:o(`common.refresh`,`Refresh`),children:r(d,{className:u(`h-3.5 w-3.5`,Q&&`animate-spin`)})}),e(C,{variant:`unstyled`,onClick:ge,className:`flex items-center gap-1.5 rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,title:o(`integrations.scanTheLocalNetworkFor`,`Scan the local network for devices`),children:[r(p,{className:`h-3.5 w-3.5`}),o(`integrations.scanNetwork`,`Scan network`)]}),e(C,{variant:`unstyled`,onClick:S,className:`flex items-center gap-1.5 rounded-lg bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground shadow-sm`,children:[r(ee,{className:`h-3.5 w-3.5`}),o(`integrations.newIntegration`,`New Integration`)]})]}),children:[r(Re,{onSetupIntegration:T}),Z&&r(pe,{message:o(`integrations.loadFailed`,`Integrations could not be loaded.`),onRetry:Y}),X&&!Z&&e(`div`,{role:`status`,"data-testid":`integrations-reconnecting`,className:`flex items-center gap-2 rounded-lg border border-border bg-surface px-3 py-2 text-xs text-foreground-subtle`,children:[r(d,{className:`h-3.5 w-3.5 animate-spin`,"aria-hidden":!0}),o(`integrations.reconnecting`,`An integration is restarting. The list will refresh on its own.`)]}),Q&&r(`div`,{className:`space-y-2`,"data-testid":`integrations-pending`,children:[1,2,3].map(e=>r(`div`,{className:`h-12 rounded-lg border border-border bg-surface animate-pulse`},e))}),!Z&&!Q&&!X&&!$&&e(`div`,{className:`flex flex-col items-center py-20 text-foreground-subtle`,children:[r(`p`,{className:`text-sm`,children:o(`integrations.noIntegrationsConfigured`,`No integrations configured.`)}),r(`p`,{className:`text-xs mt-1`,children:o(`integrations.clickNewIntegrationToConnect`,`Click "New Integration" to connect cameras and devices.`)})]}),!Z&&!Q&&$&&v===`table`&&e(`div`,{className:`space-y-4`,children:[q.providers.length>0&&r(A,{kind:`providers`,children:et(q.providers)}),q.system.length>0&&r(A,{kind:`system`,children:et(q.system)})]}),!Z&&!Q&&$&&v===`grid`&&r(Fe,{providers:Ge.providers,system:Ge.system,onOpen:Ke,searchPlaceholder:o(`integrations.search`,{defaultValue:`Search integrations…`}),emptyLabel:o(`integrations.empty`,{defaultValue:`No integrations found.`})}),r(_e,{open:ae,onClose:w,seed:se}),r(ve,{open:fe,onClose:ye,onSetupIntegration:T})]})}export{G as IntegrationsPage};
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./browser-BHo8W_uH.js","./rolldown-runtime-Cyuzqnbw.js"])))=>i.map(i=>d[i]);
2
- import{a as e}from"./rolldown-runtime-Cyuzqnbw.js";import{t}from"./vite-preload-helper-kNaey6uv.js";import{C as n,J as r,K as i,S as a,V as o,Y as s,a as c,et as l,t as u,x as d}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Di as f,Fr as p,Ki as m,Mn as h,Mr as g,Oa as _,Q as v,Rr as y,Sn as b,Ur as x,Wi as S,Xt as C,Za as w,ct as T,dt as E,en as D,lr as O,pi as k,vt as A}from"./player-overlays-BOFRnllQ.js";import{gi as j,hi as M}from"./client-B5Dgc4a1.js";import{l as ee,o as N}from"./terminal-DU-tvcEm.js";import{t as te}from"./monitor-smartphone-DPI9EQus.js";import{t as ne}from"./unlink-D3-IGpS8.js";import{Qc as re,Ti as ie,Tp as P,Vf as F,Xc as ae,Yf as I,lt as L,ta as R,wi as oe,yr as se}from"./src-COXzZsML.js";import{t as ce}from"./i18n-CUhh5TVT.js";import{t as z}from"./useTranslation-BJr-n0es.js";import"./mount-Bj0f3vXg.js";import{c as le,i as ue,l as B,s as V}from"./sso-popup-aDTs6CN7.js";import{F as H,ci as U,i as W,mi as de,ui as G}from"./index-Bp_VBVht.js";import{t as fe}from"./AdminSectionedPage-DChJZzFa.js";import{t as pe}from"./AdminPage-B3Kuwjd2.js";import{D as me,O as he,_ as ge,a as _e,h as ve,r as ye,t as K,w as be}from"./SessionsList-C0Rcbhvx.js";l();var xe=`${M}/connect`,q={public:0,mesh:1,lan:2,"lan-ipv6":3};function Se(e){switch(e.kind){case`public`:return e.interfaceKind===`vpn`?`mesh`:`public`;case`lan-ipv4`:return`lan`;case`lan-ipv6`:return`lan-ipv6`;case`custom`:return`public`;case`loopback`:case`app-link`:return null}}function J(e){return j(e)}function Ce(e){return e.startsWith(`https://`)}function we(e){let t=e.flatMap(e=>{let t=Se(e),n=J(e.baseUrl);return t===null||n===null?[]:[{endpoint:e,tier:t,origin:n}]}).toSorted((e,t)=>q[e.tier]-q[t.tier]||Number(t.endpoint.plausible)-Number(e.endpoint.plausible)||e.endpoint.priority-t.endpoint.priority),n=new Set;return t.flatMap(({endpoint:e,tier:t,origin:r})=>n.has(r)?[]:(n.add(r),[{origin:r,label:e.label,tier:t,secure:Ce(r),plausible:e.plausible}]))}function Te(e,t,n=null){for(let r of[t,n]){if(r===null)continue;let t=J(r),n=e.find(e=>e.origin===t);if(n!==void 0)return n}return e[0]??null}function Ee(e){let t=new URL(xe);return t.searchParams.set(`hub`,e),t.toString()}var De=176,Y={scheme:`https`};function Oe(){let{t:e}=z(),t=re(Y),r=ae(Y).data?.roles.publicEndpoint.resolved??null;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`connectPhone.title`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`connectPhone.description`)}),t.isPending?n(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),e(`connectPhone.loading`)]}):t.isError?n(`div`,{className:`flex items-start gap-2 text-[11px] text-danger`,children:[a(C,{className:`h-3.5 w-3.5 mt-0.5 shrink-0`}),n(`div`,{className:`flex-1 min-w-0 space-y-1.5`,children:[a(`div`,{className:`break-words`,children:e(`connectPhone.error`,{message:t.error.message})}),a(F,{size:`sm`,variant:`ghost`,onClick:()=>void t.refetch(),children:e(`connectPhone.retry`)})]})]}):a(ke,{candidates:we(t.data.endpoints),preferredOrigin:r})]})]})}function ke({candidates:e,preferredOrigin:t}){let{t:r}=z(),[o,c]=s(null),l=Te(e,o,t),u=i(()=>l?Ee(l.origin):null,[l]);if(l===null||u===null)return a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.empty`)});let d=e=>r(`connectPhone.tier.${e}`),f=e.map(e=>({value:e.origin,label:`${d(e.tier)} — ${e.origin}`}));return n(`div`,{className:`flex flex-col sm:flex-row gap-4`,children:[a(oe,{value:u,size:De,alt:r(`connectPhone.qrAlt`),className:`self-start`}),n(`div`,{className:`flex-1 min-w-0 space-y-3`,children:[n(`label`,{className:`block space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.addressLabel`)}),a(E,{value:l.origin,options:f,onChange:e=>c(e.target.value)}),n(`span`,{className:`block text-[10px] text-foreground-subtle`,children:[d(l.tier),` · `,l.label]})]}),!l.secure&&a(X,{text:r(`connectPhone.insecure`)}),!l.plausible&&a(X,{text:r(`connectPhone.implausible`)}),n(`div`,{className:`space-y-1`,children:[a(`span`,{className:`text-[11px] font-medium text-foreground`,children:r(`connectPhone.linkLabel`)}),n(`div`,{className:`flex items-center gap-1 rounded-md border border-border bg-background px-2 py-1`,children:[a(`code`,{className:`flex-1 min-w-0 font-mono text-[11px] text-foreground break-all select-all`,children:u}),a(se,{value:u,srLabel:r(`connectPhone.linkLabel`)})]})]}),a(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`connectPhone.signInHint`)})]})]})}function X({text:e}){return n(`div`,{className:`flex items-start gap-2 rounded-md border border-warning/30 bg-warning/5 px-2.5 py-1.5 text-[11px] text-foreground`,children:[a(C,{className:`h-3.5 w-3.5 text-warning mt-0.5 shrink-0`}),a(`span`,{children:e})]})}l();function Ae(e){return new Date(e).toLocaleDateString()}function je(){let{t:e}=z(),t=T(),i=P.useUtils(),c=P.auth.listLinkableProviders.useQuery(),l=P.auth.listOwnExternalIdentities.useQuery(),[u,d]=s(null),[f,h]=s(()=>B(window.location.search)),g=r(null),_=W(`Linking a sign-in account`),b=r(null);o(()=>()=>b.current?.(),[]);let[x,C]=s(null);o(()=>{if(f===null)return;let e=new URL(window.location.href);e.searchParams.delete(`linked`),e.searchParams.delete(`linkError`),window.history.replaceState({},``,e.pathname+e.search+e.hash)},[f]);let w=P.auth.beginExternalLink.useMutation({onSuccess:({url:e})=>{let t=g.current;if(g.current=null,t===null||t.closed){window.location.assign(e);return}let n=e=>{C(null),h(B(`?${e}`)),i.auth.listOwnExternalIdentities.invalidate()};b.current?.(),b.current=V(t,{onReturn:e=>{e.target===`profile`&&n(e.query)},onDone:e=>{e.target===`profile`&&n(e.query)},onClosed:()=>{b.current?.(),b.current=null,i.auth.listOwnExternalIdentities.invalidate()}}),t.location.href=v(le(e))},onError:e=>{g.current?.close(),g.current=null,C(null),d(e.message)}}),E=P.auth.unlinkOwnExternalIdentity.useMutation({onSuccess:()=>void i.auth.listOwnExternalIdentities.invalidate(),onError:e=>d(e.message)}),D=c.data??[],O=l.data??[],k=x!==null&&O.some(e=>e.provider===x);if(o(()=>{!k||x===null||(C(null),h({kind:`linked`,provider:x}))},[k,x]),D.length===0&&O.length===0)return null;let A=new Set(O.map(e=>e.provider)),j=e=>D.find(t=>t.provider===e)?.label??e,M=async(n,r)=>{await t({title:e(`users.linkedSignInsSection.unlinkSignInAccount`,`Unlink sign-in account`),message:e(`users.linkedSignInsSection.stopSigningInWithThis`,`Stop signing in with this {{label}} account?`,{label:r}),confirmLabel:e(`users.linkedSignInsSection.unlink`,`Unlink`),variant:`danger`})&&(d(null),E.mutate({provider:n.provider,subject:n.subject}))};return n(`div`,{"data-testid":`linked-sign-ins`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[_.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(y,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`users.linkedSignInsSection.linkedSignInAccounts`,`Linked sign-in accounts`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`users.linkedSignInsSection.signInWithAnExternal`,`Sign in with an external account instead of your password. Only accounts you link here can sign you in; your two-factor authentication still applies.`)}),f?.kind===`linked`&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-emerald-500/30 bg-emerald-500/5 px-3 py-2 text-xs text-foreground`,children:[a(S,{className:`h-3.5 w-3.5 text-emerald-500 shrink-0`}),e(`users.linkedSignIns.linkedNotice`,{provider:j(f.provider)})]}),(f?.kind===`error`||u)&&n(`div`,{className:`flex items-center gap-2 rounded-md border border-danger/20 bg-danger/10 px-3 py-2 text-xs text-danger`,children:[a(m,{className:`h-3.5 w-3.5 shrink-0`}),u??(f?.kind===`error`?f.message:``)]}),O.length>0&&a(`ul`,{className:`divide-y divide-border rounded-md border border-border`,children:O.map(t=>{let r=t.providerLabel??t.provider;return n(`li`,{className:`flex items-center gap-3 px-3 py-2 text-xs`,children:[n(`div`,{className:`flex-1 min-w-0`,children:[n(`div`,{className:`font-medium text-foreground truncate`,children:[r,!t.available&&a(`span`,{className:`ml-2 rounded bg-foreground-subtle/15 px-1.5 py-0.5 text-[10px] font-normal text-foreground-subtle`,children:e(`users.linkedSignInsSection.providerUnavailable`,`provider unavailable`)})]}),a(`div`,{className:`text-[11px] text-foreground-subtle truncate`,children:e(`users.linkedSignIns.linkedOn`,{label:t.label??t.subject,date:Ae(t.linkedAt)})})]}),n(F,{variant:`unstyled`,onClick:()=>void M(t,r),disabled:E.isPending,className:`inline-flex items-center gap-1 rounded px-2 py-1 text-[10px] text-danger hover:bg-danger/10 disabled:opacity-50`,children:[a(ne,{className:`h-3 w-3`}),e(`users.linkedSignInsSection.unlink`,`Unlink`)]})]},`${t.provider}|${t.subject}`)})}),a(`div`,{className:`flex flex-wrap gap-2`,children:D.filter(e=>!A.has(e.provider)).map(t=>n(F,{variant:`unstyled`,onClick:()=>{d(null),h(null),_.requestProof().then(e=>{e!==null&&(g.current=ue(null),C(g.current===null?null:t.provider),w.mutate({provider:t.provider,reauthToken:e}))})},disabled:w.isPending,className:`inline-flex items-center gap-1.5 rounded border border-border px-2.5 py-1 text-[11px] font-medium text-foreground hover:bg-surface-hover disabled:opacity-50`,children:[w.isPending&&w.variables?.provider===t.provider?a(p,{className:`h-3 w-3 animate-spin`}):a(y,{className:`h-3 w-3`}),e(`users.linkedSignIns.link`,{provider:t.label})]},t.provider))})]})]})}l();function Me({value:r,size:i=192}){let{t:c}=z(),[l,u]=s(null),[d,f]=s(null);if(o(()=>{let n=!1;return t(()=>import(`./browser-BHo8W_uH.js`).then(t=>e(t.default,1)).then(async e=>{if(n)return;let t=e.create;if(typeof t!=`function`){f(`qrcode.create() unavailable in installed version`);return}try{let e=t(r,{errorCorrectionLevel:`M`});n||u(e)}catch(e){n||f(e instanceof Error?e.message:`QR generation failed`)}}),__vite__mapDeps([0,1]),import.meta.url).catch(()=>{n||f(`qrcode library not installed`)}),()=>{n=!0}},[r]),d)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle text-center p-4`,style:{width:i,height:i},children:c(`users.totpQrCode.qrRenderingUnavailableUseThe`,`QR rendering unavailable — use the secret below.`)});if(!l)return a(`div`,{className:`flex items-center justify-center text-[10px] text-foreground-subtle animate-pulse`,style:{width:i,height:i},children:c(`users.totpQrCode.generating`,`Generating…`)});let p=l.modules.size,m=i/p,h=[];for(let e=0;e<p;e++)for(let t=0;t<p;t++)l.modules.data[e*p+t]&&h.push(a(`rect`,{x:t*m,y:e*m,width:m,height:m,fill:`currentColor`},`${t}-${e}`));return n(`svg`,{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`text-black`,children:[a(`rect`,{x:0,y:0,width:i,height:i,fill:`white`}),h]})}l();function Ne(){let{t:e}=z(),t=A(),[r,i]=s(``),[o,c]=s(``),[l,d]=s(``),[f,h]=s(null),_=u({mutationFn:e=>t.changeOwnPassword(e),onSuccess:()=>{h({kind:`success`,msg:`Password updated.`}),i(``),c(``),d(``)},onError:e=>{h({kind:`error`,msg:e instanceof Error?e.message:`Update failed`})}}),v=o.length>0&&l.length>0&&o!==l,y=o.length>0&&o.length<8,b=r.length>=1&&o.length>=8&&o===l;return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(ee,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`systemPage.myAccess.changePassword`,`Change password`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(Z,{label:e(`systemPage.myAccess.currentPassword`,`Current password`),value:r,onChange:i,autoComplete:`current-password`}),a(Z,{label:e(`systemPage.myAccess.newPassword`,`New password`),value:o,onChange:c,autoComplete:`new-password`,hint:e(`systemPage.myAccess.atLeast8Characters`,`At least 8 characters.`)}),a(Z,{label:e(`systemPage.myAccess.confirmNewPassword`,`Confirm new password`),value:l,onChange:d,autoComplete:`new-password`}),(v||y)&&a(`div`,{className:`text-[11px] text-danger`,children:v?e(`systemPage.myAccess.passwordsDoNotMatch`,`Passwords do not match.`):e(`systemPage.myAccess.newPasswordMustBeAt`,`New password must be at least 8 characters.`)}),f&&n(`div`,{className:`text-[11px] flex items-center gap-1 ${f.kind===`success`?`text-success`:`text-danger`}`,children:[f.kind===`success`?a(S,{className:`h-3 w-3`}):a(m,{className:`h-3 w-3`}),f.msg]}),a(`div`,{className:`flex justify-end`,children:n(F,{onClick:()=>{h(null),_.mutate({currentPassword:r,newPassword:o})},disabled:!b||_.isPending,children:[_.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(g,{className:`h-3 w-3`}),e(`systemPage.myAccess.updatePassword`,`Update password`)]})})]})]})}function Z({label:e,value:t,onChange:r,autoComplete:i,hint:o}){return n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:e}),a(I,{type:`password`,value:t,onChange:e=>r(e.target.value),autoComplete:i,className:`w-full rounded border border-border bg-background px-2 py-1.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),o&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:o})]})}function Pe({username:e}){let{t}=z(),r=A(),l=c({queryKey:[`auth`,`getOwnTotpStatus`],queryFn:()=>r.getOwnTotpStatus()}),h=l.data,[g,_]=s(null),[v,y]=s(``),[x,C]=s(null),[w,T]=s(!1),E=u({mutationFn:()=>r.setupOwnTotp(),onSuccess:e=>{_({secret:e.secret,otpauthUrl:e.otpauthUrl}),y(``),C(null)},onError:e=>C(e instanceof Error?e.message:`Setup failed`)}),D=u({mutationFn:e=>r.confirmOwnTotp(e),onSuccess:()=>{_(null),y(``),C(null),l.refetch()},onError:e=>C(e instanceof Error?e.message:`Confirmation failed — code did not match`)}),O=W(`Turning off two-factor authentication`),k=u({mutationFn:async()=>{let e=await O.requestProof();return e===null?null:r.disableOwnTotp({reauthToken:e})},onSuccess:()=>{C(null),l.refetch()},onError:e=>C(e instanceof Error?e.message:`Disable failed`)});o(()=>{if(!w)return;let e=setTimeout(()=>T(!1),1500);return()=>clearTimeout(e)},[w]);let j=i(()=>l.isLoading?`loading`:g?`setup_in_progress`:h?.enabled?`enrolled`:`not_enrolled`,[l.isLoading,h?.enabled,g]);return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[O.dialog,n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.twoFactorAuthentication`,`Two-factor authentication`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[j===`loading`&&n(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(p,{className:`h-3.5 w-3.5 animate-spin`}),t(`systemPage.myAccess.checkingStatus`,`Checking status…`)]}),j===`not_enrolled`&&n(d,{children:[a(`div`,{className:`text-xs text-foreground-subtle`,children:t(`systemPage.myAccess.2faIsnTActiveOn`,`2FA isn't active on your account. Enable it to require a 6-digit code from your authenticator app at every login.`)}),a(`div`,{className:`flex justify-end`,children:n(F,{onClick:()=>{C(null),E.mutate()},disabled:E.isPending,children:[E.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),t(`systemPage.myAccess.enable2fa`,`Enable 2FA`)]})})]}),j===`setup_in_progress`&&g&&n(d,{children:[a(`div`,{className:`text-[11px] text-foreground-subtle`,children:a(U,{i18nKey:`systemPage.myAccess.scanQr`,values:{username:e},components:{mono:a(`span`,{className:`font-mono`})}})}),n(`div`,{className:`flex flex-col items-center gap-3`,children:[a(`div`,{className:`rounded-lg border border-border bg-white p-3`,children:a(Me,{value:g.otpauthUrl,size:180})}),n(`div`,{className:`w-full`,children:[a(`div`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle mb-1`,children:t(`systemPage.myAccess.secretManualEntry`,`Secret (manual entry)`)}),n(`div`,{className:`flex items-center gap-2 rounded border border-border bg-surface-hover/30 px-2 py-1.5`,children:[a(`code`,{className:`text-[11px] font-mono text-foreground break-all flex-1`,children:g.secret}),n(F,{variant:`ghost`,onClick:()=>{g&&navigator.clipboard.writeText(g.secret).then(()=>T(!0))},children:[w?a(S,{className:`h-3 w-3 text-success`}):a(f,{className:`h-3 w-3`}),w?t(`systemPage.myAccess.copied`,`Copied`):t(`common.copy`,`Copy`)]})]})]})]}),n(`div`,{className:`space-y-1`,children:[a(`label`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`6-digit code`}),a(I,{type:`text`,inputMode:`numeric`,autoComplete:`one-time-code`,placeholder:`123456`,value:v,onChange:e=>y(e.target.value.replace(/\D/g,``).slice(0,6)),className:`w-full rounded-md border border-border bg-surface px-3 py-2 text-center text-lg font-mono tracking-widest text-foreground focus:outline-none focus:ring-2 focus:ring-primary`})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),x]}),n(`div`,{className:`flex justify-end gap-2`,children:[a(F,{variant:`outline`,onClick:()=>{_(null),C(null),y(``)},children:t(`common.cancel`,`Cancel`)}),n(F,{onClick:()=>{C(null),D.mutate({code:v})},disabled:D.isPending||v.length!==6,children:[D.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(S,{className:`h-3 w-3`}),t(`common.confirm`,`Confirm`)]})]})]}),j===`enrolled`&&h&&n(d,{children:[n(`div`,{className:`rounded-md border border-success/30 bg-success/5 px-3 py-2.5 flex items-start gap-2.5`,children:[a(S,{className:`h-4 w-4 mt-0.5 text-success shrink-0`}),n(`div`,{className:`text-xs text-foreground space-y-0.5`,children:[a(`div`,{className:`font-medium`,children:t(`systemPage.myAccess.2faIsActive`,`2FA is active`)}),a(`div`,{className:`text-foreground-subtle`,children:t(`common.enrolledOn`,{when:h.confirmedAt?new Date(h.confirmedAt).toLocaleString():`—`})})]})]}),x&&n(`div`,{className:`text-[11px] text-danger flex items-center gap-1`,children:[a(m,{className:`h-3 w-3`}),x]}),a(`div`,{className:`flex justify-end`,children:n(F,{variant:`danger`,onClick:()=>{C(null),k.mutate()},disabled:k.isPending,children:[k.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(b,{className:`h-3 w-3`}),t(`systemPage.myAccess.disable2fa`,`Disable 2FA`)]})})]})]})]})}function Fe(){return R(`auth-webauthn/passkey-enrollment`)?a(ie,{widgetId:`auth-webauthn/passkey-enrollment`,host:`dashboard`}):null}l();function Q(e){return e.message.length>0?e.message:ce.t(`auth.authAuditSection.requestFailed`)}function Ie(){let{t:e}=z(),{logout:t}=H(),r=T(),i=P.useUtils(),o=P.auth.listOwnSessions.useQuery(),[c,l]=s(null),u=P.auth.revokeOwnSession.useMutation({onSuccess:()=>void i.auth.listOwnSessions.invalidate(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),d=P.auth.logout.useMutation({onSuccess:()=>t(),onError:e=>l(`Sign out failed: ${Q(e)}`)}),f=async t=>{await r({title:e(`auth.mySessionsSection.signOutThisSession`,`Sign out this session`),message:e(`auth.mySessionsSection.willHaveToSignIn`,`{{label}} will have to sign in again.`,{label:ge(t.client).label}),confirmLabel:e(`auth.mySessionsSection.signOut`,`Sign out`),variant:`danger`})&&(l(null),u.mutate({id:t.id}))},m=async()=>{await r({title:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),message:e(`auth.mySessionsSection.everySessionOfYourAccount`,`Every session of your account ends, this browser included: you will be signed out here too and every device has to sign in again.`),confirmLabel:e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`),variant:`danger`})&&(l(null),d.mutate({everywhere:!0}))};return n(`div`,{"data-testid":`my-sessions`,className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2.5 border-b border-border flex items-center gap-2`,children:[a(te,{className:`h-3.5 w-3.5 text-foreground-subtle`}),a(`div`,{className:`text-xs font-semibold text-foreground`,children:e(`auth.mySessionsSection.activeSessions`,`Active sessions`)})]}),n(`div`,{className:`p-4 space-y-3`,children:[a(`p`,{className:`text-[11px] text-foreground-subtle`,children:e(`auth.mySessionsSection.theBrowsersAndAppsSigned`,`The browsers and apps signed in to your account. Signing one out ends it at once.`)}),c!==null&&a(`div`,{className:`text-[11px] text-danger`,children:c}),a(K,{sessions:o.data??[],isLoading:o.isLoading,loadError:o.isError?o.error?.message??e(`auth.authAuditSection.requestFailed`):null,emptyText:`No active sessions.`,onRevoke:e=>void f(e),revokingId:u.isPending?u.variables?.id??null:null}),a(`div`,{className:`flex justify-end`,children:n(F,{variant:`unstyled`,onClick:()=>void m(),disabled:d.isPending,className:`inline-flex items-center gap-1.5 rounded border border-danger/40 px-2.5 py-1 text-[11px] font-medium text-danger hover:bg-danger/10 disabled:opacity-50`,children:[d.isPending?a(p,{className:`h-3 w-3 animate-spin`}):a(N,{className:`h-3 w-3`}),e(`auth.mySessionsSection.signOutEverywhere`,`Sign out everywhere`)]})})]})]})}l();var Le=`You`;function Re(){let{t:e}=z(),t=T(),n=P.useUtils(),r=P.auth.listOwnDeviceCredentials.useQuery(),[o,c]=s(null),l=P.auth.revokeOwnDeviceCredential.useMutation({onSuccess:e=>{e.revoked||c(`That device could not be revoked - it may already be gone.`),n.auth.listOwnDeviceCredentials.invalidate()},onError:e=>c(`Revoke failed: ${e.message}`)}),u=i(()=>(r.data??[]).map(e=>ye(e,Le)),[r.data]),d=async n=>{await t({title:e(`certificates.myDevicesSection.revoke`,`Revoke "{{name}}"?`,{name:n.name}),message:e(`certificates.myDevicesSection.theDeviceStopsSigningIn`,`The device stops signing in at once and its open sessions end. To use it again you have to pair it anew. This cannot be undone.`),confirmLabel:e(`certificates.myDevicesSection.revoke2`,`Revoke`),variant:`danger`})&&(c(null),l.mutate({id:n.id}))},f={label:e(`certificates.myDevicesSection.revoke2`,`Revoke`),icon:_,isAvailable:_e,onRun:e=>void d(e),busyId:l.isPending?l.variables?.id??null:null,disabled:l.isPending};return a(me,{id:`my-devices`,title:e(`certificates.myDevicesSection.myDevices`,`My devices`),icon:b,description:e(`certificates.myDevicesSection.phonesThatStaySignedIn`,`Phones that stay signed in to your account with a certificate. If one is lost, revoke it here and it is signed out at once.`),notice:he(o),onDismissNotice:()=>c(null),children:a(be,{rows:u,label:e(`certificates.devicesCard.label`),isLoading:r.isPending,loadError:r.error===null?null:r.error.message||`Request failed`,emptyText:`No devices are signed in with a certificate.`,hideOwner:!0,expiresNone:`—`,action:f})})}var $={profile:`profile`,signIn:`sign-in`,sessions:`sessions`,tokens:`tokens`},ze=[`linked`,`linkError`],Be={view:{icon:k,cls:`bg-foreground-subtle/15 text-foreground-subtle`},create:{icon:O,cls:`bg-primary/15 text-primary`},delete:{icon:D,cls:`bg-danger/15 text-danger`}};function Ve(){let{t:e}=z(),{user:t,logout:r}=H(),[i]=de(),o=e(`system.myAccess`,`My access`);if(!t)return a(pe,{icon:h,title:o,children:a(`div`,{className:`text-xs text-foreground-subtle`,children:e(`systemPage.myAccess.notSignedIn`,`Not signed in.`)})});if(i.get(`tab`)===`preferences`)return a(G,{to:`/system/settings`,replace:!0});if(ze.some(e=>i.has(e))&&!i.has(`tab`)){let e=new URLSearchParams(i);return e.set(`tab`,$.signIn),a(G,{to:`?${e.toString()}`,replace:!0})}return a(fe,{icon:h,title:o,subtitle:e(`systemPage.myAccess.subtitle`,`Your account, how you sign in, where you are signed in, and your tokens.`),sectionsLabel:e(`systemPage.myAccess.sectionsLabel`,`My access sections`),defaultSection:$.profile,actions:n(F,{variant:`outline`,onClick:r,children:[a(N,{className:`h-3 w-3`}),e(`systemPage.myAccess.signOut`,`Sign out`)]}),sections:[{id:$.profile,label:e(`systemPage.myAccess.sections.profile`,`Profile`),content:a(He,{user:t})},{id:$.signIn,label:e(`systemPage.myAccess.sections.signIn`,`Sign-in & security`),content:n(`div`,{className:`space-y-4`,children:[a(Ne,{}),a(Pe,{username:t.username}),a(Fe,{}),a(je,{})]})},{id:$.sessions,label:e(`systemPage.myAccess.sections.sessions`,`Sessions & devices`),content:n(`div`,{className:`space-y-4`,children:[a(Ie,{}),a(Re,{}),a(Oe,{})]})},{id:$.tokens,label:e(`systemPage.myAccess.sections.tokens`,`Tokens`),content:a(ve,{ownOnly:!0})}]})}function He({user:e}){let{t}=z(),r=e.isAdmin,i=e.scopes??[];return n(`div`,{className:`space-y-4`,children:[n(`div`,{className:`rounded-lg border border-border bg-surface px-4 py-3 flex items-center gap-3`,children:[a(`div`,{className:`flex h-10 w-10 items-center justify-center rounded-full bg-primary/10 text-primary font-semibold text-base`,children:e.username.slice(0,1).toUpperCase()}),n(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-sm font-semibold text-foreground truncate`,children:e.username}),n(`div`,{className:`text-[11px] text-foreground-subtle`,children:[r?t(`systemPage.myAccess.administrator`,`Administrator`):t(`systemPage.myAccess.user`,`User`),` `,a(U,{i18nKey:`systemPage.myAccess.sessionId`,values:{id:e.id.slice(0,8)},components:{mono:a(`span`,{className:`font-mono`})}})]})]})]}),r&&n(`div`,{className:`rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-xs text-foreground flex items-start gap-2.5`,children:[a(x,{className:`h-4 w-4 text-primary mt-0.5 shrink-0`}),n(`div`,{children:[a(`div`,{className:`font-semibold text-foreground`,children:t(`systemPage.myAccess.unrestrictedAccess`,`Unrestricted access`)}),a(`p`,{className:`text-foreground-subtle mt-0.5`,children:t(`systemPage.myAccess.adminSessionsBypassThePer`,`Admin sessions bypass the per-call scope check. Every protected endpoint is reachable regardless of the list below.`)})]})]}),i.length>0&&a(Ue,{scopes:i})]})}function Ue({scopes:e}){let{t}=z(),r=w();return n(`div`,{className:`rounded-lg border border-border bg-surface overflow-hidden`,children:[n(`div`,{className:`px-4 py-2 border-b border-border`,children:[a(`div`,{className:`text-xs font-semibold text-foreground`,children:t(`systemPage.myAccess.grantedScopes`,`Granted scopes`)}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:t(`systemPage.myAccess.bakedIntoYourSessionToken`,`Baked into your session token at login; sign out + back in to refresh after changes.`)})]}),n(`div`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[a(`div`,{children:t(`systemPage.myAccess.type`,`Type`)}),a(`div`,{children:t(`systemPage.myAccess.target`,`Target`)}),a(`div`,{children:t(`systemPage.myAccess.access`,`Access`)})]}),a(`ul`,{className:`divide-y divide-border`,children:e.map((e,i)=>n(`li`,{className:`grid grid-cols-[100px_1fr_240px] gap-3 px-4 py-2.5 items-center text-xs`,children:[a(`span`,{className:`font-mono text-foreground-subtle`,children:e.type}),a(`span`,{className:`font-mono text-foreground`,children:e.type===`device`?L(e.selector,r):e.target}),a(`div`,{className:`flex items-center gap-1`,children:[`view`,`create`,`delete`].map(r=>{let i=e.access.includes(r),{icon:o,cls:s}=Be[r];return n(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium ${i?s:`bg-transparent text-foreground-subtle/40 line-through`}`,title:i?t(`systemPage.myAccess.can`,`Can {{a}}`,{a:r}):t(`systemPage.myAccess.cannot`,`Cannot {{a}}`,{a:r}),children:[a(o,{className:`h-3 w-3`}),r]},r)})})]},i))})]})}export{Ve as MyAccessPage};