@camstack/addon-admin-ui 1.2.626 → 1.2.627

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 (150) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/assets/Addons-cUjIvOvT.js +5 -0
  3. package/dist/assets/{AdminPage-dLt1mKEa.js → AdminPage-BGjbZ_DP.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BYn7-4dT.js → AdminSectionedPage-0BLzsere.js} +1 -1
  5. package/dist/assets/AiProfiles-BmCrxSUR.js +3 -0
  6. package/dist/assets/{Authentication-CykaHfAJ.js → Authentication-BANp-rCQ.js} +1 -1
  7. package/dist/assets/{Build-DvxNre5q.js → Build-CshYezTz.js} +3 -3
  8. package/dist/assets/Calendars-nijSSBBn.js +1 -0
  9. package/dist/assets/{CameraGrids-WkOqz0ai.js → CameraGrids-BhMnY-U6.js} +1 -1
  10. package/dist/assets/Cluster-e11_2684.js +1 -0
  11. package/dist/assets/{CompositionBlockEditor-B6GFdIeM.js → CompositionBlockEditor-Tlz_skRr.js} +2 -2
  12. package/dist/assets/{CompositionEditorPage-B8-97pRO.js → CompositionEditorPage-Ry64j4qy.js} +1 -1
  13. package/dist/assets/{Data-CDo9vIwN.js → Data-CTbC0GG5.js} +2 -2
  14. package/dist/assets/{DeviceDetail-BBanvUVD.js → DeviceDetail-D9HCHrZA.js} +2 -2
  15. package/dist/assets/{DeviceDoActionFields-CAAMOfrL.js → DeviceDoActionFields-fbxUHBmB.js} +1 -1
  16. package/dist/assets/{Devices-CelRF0ak.js → Devices-DTyTQ5cG.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CMOLFarm.js → EmbedPlayerPage-BHG81kfU.js} +1 -1
  18. package/dist/assets/History-C4qZ3gqF.js +1 -0
  19. package/dist/assets/Identity-B1OuI6MD.js +1 -0
  20. package/dist/assets/{InstanceSwitchCell-BQekirNX.js → InstanceSwitchCell-BE6j8roj.js} +1 -1
  21. package/dist/assets/InstancesTable-B7rabb_v.js +1 -0
  22. package/dist/assets/IntegrationDetail-4XDFzceS.js +1 -0
  23. package/dist/assets/{IntegrationHub-jVzJirPk.js → IntegrationHub-Dh_MHAvj.js} +1 -1
  24. package/dist/assets/Integrations-CEP5cZG6.js +2 -0
  25. package/dist/assets/Integrations-CGNp6nto.js +1 -0
  26. package/dist/assets/{Library-DCDTlPnF.js → Library-DUuHG1yU.js} +1 -1
  27. package/dist/assets/Locations-CktpOpxD.js +3 -0
  28. package/dist/assets/{Logs-DOFxrXxZ.js → Logs-BPm2952O.js} +1 -1
  29. package/dist/assets/{MaskShapeCanvas-C6vw0mq_.js → MaskShapeCanvas-CaIwcviU.js} +1 -1
  30. package/dist/assets/{MotionZonesSettings-BPLgHoj3.js → MotionZonesSettings-B8humXZO.js} +1 -1
  31. package/dist/assets/MyAccess-IwGnqYJk.js +2 -0
  32. package/dist/assets/{Network-CRBMMSjJ.js → Network-Bx8pmtNT.js} +1 -1
  33. package/dist/assets/{NodeAddonsSettingsPanel-BGB_St7Q.js → NodeAddonsSettingsPanel-Ch9_AwqF.js} +1 -1
  34. package/dist/assets/Notifications-C8aadgSQ.js +1 -0
  35. package/dist/assets/{Pipeline-CHz7NNm6.js → Pipeline-Bfx8XPU_.js} +1 -1
  36. package/dist/assets/{PrivacyMaskSettings-mpx3kl1W.js → PrivacyMaskSettings-DdMBB4Li.js} +1 -1
  37. package/dist/assets/Recordings-hnmLWqEZ.js +1 -0
  38. package/dist/assets/{ScanSubnetEditor-MFkKIxnM.js → ScanSubnetEditor-DEYVzz3F.js} +1 -1
  39. package/dist/assets/{SceneMonitorEditor-HTEqKGnK.js → SceneMonitorEditor-BsbHr1g7.js} +1 -1
  40. package/dist/assets/SessionsList-zMHONQk5.js +2 -0
  41. package/dist/assets/{Showroom-CyZpVw5e.js → Showroom-CgyJscUi.js} +1 -1
  42. package/dist/assets/{StorageLocationsTable-DznxRZnK.js → StorageLocationsTable-DcJtsyAI.js} +1 -1
  43. package/dist/assets/System-D5Pndm3I.js +1 -0
  44. package/dist/assets/{Templates-DAIsSP23.js → Templates-lRI27MQE.js} +1 -1
  45. package/dist/assets/{Terminal-C1QNo9AN.js → Terminal-BhSCbzcJ.js} +3 -3
  46. package/dist/assets/{TrainingProviders-DbqfB5Q6.js → TrainingProviders-BDa6e9MH.js} +1 -1
  47. package/dist/assets/{Viewer-CZuKd6lk.js → Viewer-CkpAWx9q.js} +1 -1
  48. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CSfv8t1Z.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CumqQOpu.js} +1 -1
  49. package/dist/assets/{addon-icons-context-WCP6A9AS.js → addon-icons-context-6Mrqvr1U.js} +1 -1
  50. package/dist/assets/{ai-page.helpers-CJk-hY0M.js → ai-page.helpers-DSmy92dV.js} +1 -1
  51. package/dist/assets/{archive-CvMfQY3E.js → archive-CfaRqsyD.js} +1 -1
  52. package/dist/assets/{assignment-candidates-DN-VoSTA.js → assignment-candidates-BbMu5YB7.js} +1 -1
  53. package/dist/assets/{authed-media-DkaeZ1M8.js → authed-media-BXlwKDeE.js} +1 -1
  54. package/dist/assets/{bell-off-B4ksiU12.js → bell-off-BxDCQl12.js} +1 -1
  55. package/dist/assets/{board-model-D-CIwcV1.js → board-model-I1a0N13b.js} +1 -1
  56. package/dist/assets/{boxes-C9Y0YvOc.js → boxes-Q4Vaj8rD.js} +1 -1
  57. package/dist/assets/{calendar-clock-CqZRVSc3.js → calendar-clock-CXL7OclM.js} +1 -1
  58. package/dist/assets/circle-slash-BXDMKEqg.js +1 -0
  59. package/dist/assets/client-COYx-TFD.js +809 -0
  60. package/dist/assets/create-composition-Dm3hnlaE.js +2 -0
  61. package/dist/assets/crop-BpJdhjaO.js +1 -0
  62. package/dist/assets/{database-zap-Bk33ph_X.js → database-zap-By2T-LnV.js} +1 -1
  63. package/dist/assets/{device-integration-icon-Duw74rkd.js → device-integration-icon-DxdEgan-.js} +1 -1
  64. package/dist/assets/device-picker-model-B4F-5cg2.js +1 -0
  65. package/dist/assets/dist-BR3ExdiJ.js +809 -0
  66. package/dist/assets/{dist-Dli1FBe2.js → dist-Dqaqf70C.js} +1 -1
  67. package/dist/assets/{eraser-C1LaIkqO.js → eraser-VwId2IQr.js} +1 -1
  68. package/dist/assets/{file-up-CODncsO3.js → file-up-DQifBI2e.js} +1 -1
  69. package/dist/assets/{format-C7beVF9i.js → format-CU8vLl_T.js} +1 -1
  70. package/dist/assets/{hard-drive-download-gFUluoPC.js → hard-drive-download-CQruQQxy.js} +1 -1
  71. package/dist/assets/{hostInit-OZrStRqO.js → hostInit-D3bru2MD.js} +1 -1
  72. package/dist/assets/i18n-CfXX-iuz.js +1 -0
  73. package/dist/assets/{icons-BM3wcj03.js → icons-BrUjXoAZ.js} +1 -1
  74. package/dist/assets/index-BIUMsvsC.js +4 -0
  75. package/dist/assets/{key-BSgMvX5L.js → key-B35noUmR.js} +1 -1
  76. package/dist/assets/{key-square-CX058EfV.js → key-square-DzO9u0uD.js} +1 -1
  77. package/dist/assets/{layers-DgoxyPih.js → layers-BG9W-1M5.js} +1 -1
  78. package/dist/assets/{link-2-off-DmtgBwh-.js → link-2-off-Co-R-jQs.js} +1 -1
  79. package/dist/assets/{linked-devices-model-B_gqV5Gg.js → linked-devices-model-uwG0psGj.js} +1 -1
  80. package/dist/assets/{list-ordered-C0l-Wwk-.js → list-ordered-DIKai4La.js} +1 -1
  81. package/dist/assets/{memory-stick-BSUaqG9H.js → memory-stick-CIR0HAOO.js} +1 -1
  82. package/dist/assets/{message-square-plus-spORh6qX.js → message-square-plus-DOdNu6ys.js} +1 -1
  83. package/dist/assets/{mf-entry-bootstrap-0-762c2049.js → mf-entry-bootstrap-0-686859d1.js} +2 -2
  84. package/dist/assets/{mic-off-DiGyKjsE.js → mic-off-BiujQ8W3.js} +1 -1
  85. package/dist/assets/{monitor-off-CatAL1-V.js → monitor-off-7S_2iZ-C.js} +1 -1
  86. package/dist/assets/{monitor-smartphone-CrChoiUo.js → monitor-smartphone-BLCTjHAL.js} +1 -1
  87. package/dist/assets/mount-B4F-5cg2.js +1 -0
  88. package/dist/assets/{notification-rule-status-BaZr2lCj.js → notification-rule-status-Cb4jx34Y.js} +1 -1
  89. package/dist/assets/{player-overlays-CC-b3--a.js → player-overlays-Dl8i669l.js} +1 -1
  90. package/dist/assets/remoteEntry-DWDUtJXh.js +1 -0
  91. package/dist/assets/{ruler-6Q54d4xt.js → ruler-BeM-m4O5.js} +1 -1
  92. package/dist/assets/{scissors-BBC_GGoc.js → scissors-DY0_cgnp.js} +1 -1
  93. package/dist/assets/{search-x-CHDiifxm.js → search-x-_pziDXsR.js} +1 -1
  94. package/dist/assets/{send-CwDFB9fX.js → send-CUC0A2_t.js} +1 -1
  95. package/dist/assets/{settings-2-C5tt8eea.js → settings-2-BSRK8TEC.js} +1 -1
  96. package/dist/assets/{shapes-C5Nnn9NE.js → shapes-BN2HBJ_3.js} +1 -1
  97. package/dist/assets/{sigma-BSlFNDI5.js → sigma-DfN2Jhy4.js} +1 -1
  98. package/dist/assets/{speaker-ydML9LxI.js → speaker-CHLYh6wT.js} +1 -1
  99. package/dist/assets/src-DzmVXlVl.js +100 -0
  100. package/dist/assets/{sso-popup-C6eP07wS.js → sso-popup-Ch2mRf6V.js} +1 -1
  101. package/dist/assets/{step-inspector-model-CEg8vezx.js → step-inspector-model-DKYOqORK.js} +1 -1
  102. package/dist/assets/{table-2-CeAydAOI.js → table-2-gx6_SlYD.js} +1 -1
  103. package/dist/assets/{timer-reset-B_Ta8kGS.js → timer-reset-Iy3ZgMXB.js} +1 -1
  104. package/dist/assets/{tv-BdJr-riI.js → tv-BXIsODbK.js} +1 -1
  105. package/dist/assets/{unlink-DzO14DVn.js → unlink-B_U8L0Wx.js} +1 -1
  106. package/dist/assets/{usb-W-ktPgHL.js → usb-OCXp5uEl.js} +1 -1
  107. package/dist/assets/{use-device-bound-caps-xJuEMYyg.js → use-device-bound-caps-BOAx-vk3.js} +1 -1
  108. package/dist/assets/{use-scenes-feed-BFZqBAYX.js → use-scenes-feed--8rfo18P.js} +1 -1
  109. package/dist/assets/{use-stationary-objects-CHjUAUSJ.js → use-stationary-objects-CZE5lmtm.js} +1 -1
  110. package/dist/assets/{useAdminDeviceRemoval-YiBXHBHP.js → useAdminDeviceRemoval-D2MzHW1R.js} +1 -1
  111. package/dist/assets/useEventInvalidation-B4F-5cg2.js +1 -0
  112. package/dist/assets/{useNodeUrlSelection-D9CPif56.js → useNodeUrlSelection-DtbPWifx.js} +1 -1
  113. package/dist/assets/{useTemplateSave-DBc8G5sM.js → useTemplateSave-CeQLDKqQ.js} +1 -1
  114. package/dist/assets/user-round-B2WYnao7.js +1 -0
  115. package/dist/assets/{user-x--TnMk2gT.js → user-x-7OBQLt0v.js} +1 -1
  116. package/dist/assets/{variable-Bz8zKWo2.js → variable-CuVMBdXX.js} +1 -1
  117. package/dist/assets/{video-b4uGYAxS.js → video-Cae__dYz.js} +1 -1
  118. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-Cs7a4rE-.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DsLUyALP.js} +2 -2
  119. package/dist/index.html +10 -10
  120. package/dist/server/addon.js +59 -97
  121. package/package.json +2 -2
  122. package/dist/assets/Addons-B4N1LxY8.js +0 -5
  123. package/dist/assets/AiProfiles-DcAkO0SI.js +0 -3
  124. package/dist/assets/Calendars-D_iMy7Yy.js +0 -1
  125. package/dist/assets/Cluster-CyLi0SW_.js +0 -1
  126. package/dist/assets/History-Cvy2subh.js +0 -1
  127. package/dist/assets/Identity-DrFBCRWk.js +0 -1
  128. package/dist/assets/InstancesTable-Bt8qoWMR.js +0 -1
  129. package/dist/assets/IntegrationDetail-DvlDDD_J.js +0 -1
  130. package/dist/assets/Integrations-B9p5_Qf7.js +0 -1
  131. package/dist/assets/Integrations-HUB0bAoi.js +0 -2
  132. package/dist/assets/Locations-1E3b4qVs.js +0 -3
  133. package/dist/assets/MyAccess-CShkG3rs.js +0 -2
  134. package/dist/assets/Notifications-CEls0HQ3.js +0 -1
  135. package/dist/assets/Recordings-Bccg5edp.js +0 -1
  136. package/dist/assets/SessionsList-CLTlUoNj.js +0 -2
  137. package/dist/assets/System-C-k3Rz-I.js +0 -1
  138. package/dist/assets/circle-slash-DDhnvhLN.js +0 -1
  139. package/dist/assets/client-kWeONSGL.js +0 -809
  140. package/dist/assets/create-composition-CNJkzaMb.js +0 -2
  141. package/dist/assets/crop-D1l0Xs25.js +0 -1
  142. package/dist/assets/device-picker-model-DCNN-HPV.js +0 -1
  143. package/dist/assets/dist-DXhYk_uu.js +0 -809
  144. package/dist/assets/i18n-Cmy3cCDH.js +0 -1
  145. package/dist/assets/index-DwCHDODI.js +0 -4
  146. package/dist/assets/mount-DCNN-HPV.js +0 -1
  147. package/dist/assets/remoteEntry-C16PJyFZ.js +0 -1
  148. package/dist/assets/src-DGSNF4l8.js +0 -100
  149. package/dist/assets/useEventInvalidation-DCNN-HPV.js +0 -1
  150. package/dist/assets/user-round-D8euVsR1.js +0 -1
@@ -5880,7 +5880,7 @@ var ZodIssueCode = {
5880
5880
  var ZodFirstPartyTypeKind;
5881
5881
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5882
5882
  //#endregion
5883
- //#region ../types/dist/sleep-CS5Xp1iQ.mjs
5883
+ //#region ../types/dist/sleep-CkinsFFb.mjs
5884
5884
  /**
5885
5885
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5886
5886
  * window to float samples (D455).
@@ -8011,16 +8011,6 @@ var BaseAddon = class {
8011
8011
  return null;
8012
8012
  }
8013
8013
  /**
8014
- * The form schema of ONE integration instance, or `null` to use the scoped form.
8015
- *
8016
- * Override it only when an `instanceMode: multiple` addon's instances differ: an NVR integration
8017
- * needs its connection fields, the default integration the addon's own sections. It is the
8018
- * SHAPE of the form only — the values live on the instance record.
8019
- */
8020
- async integrationFormSchema(_instance) {
8021
- return null;
8022
- }
8023
- /**
8024
8014
  * D986 scoped settings: the form shape of the CLUSTER-wide settings one capability this addon
8025
8015
  * provides owns, or `null` when it has none. `cap` is a capability name the addon's manifest
8026
8016
  * declares. Stored as `addon-settings` rows `<addonId>.<field>`. The keys of this schema, of
@@ -8048,8 +8038,7 @@ var BaseAddon = class {
8048
8038
  }
8049
8039
  /**
8050
8040
  * The host's read of the scoped declarations: the schema one capability declares for `scope`,
8051
- * or `null`. Beside {@link getIntegrationFormSchema}, the same shape: the hook is protected, the
8052
- * host asks this method.
8041
+ * or `null`. The hook is protected, the host asks this method.
8053
8042
  */
8054
8043
  async getScopedSettingsSchema(scope, cap) {
8055
8044
  switch (scope) {
@@ -8217,22 +8206,6 @@ var BaseAddon = class {
8217
8206
  return Object.fromEntries([...collectHydratedFieldValues(form)].filter(([, value]) => value !== void 0));
8218
8207
  }
8219
8208
  /**
8220
- * What the create wizard and the integration edit page render for one instance: the addon's
8221
- * per-instance schema when it declares one, else its global schema (what they always showed).
8222
- */
8223
- async getIntegrationFormSchema(instance, nodeId) {
8224
- const scoped = await this.integrationFormSchema(instance);
8225
- if (scoped === null) return this.scopedForm(nodeId);
8226
- return hydrateSchema(scoped, {}, { inlineSecretsAsViews: true });
8227
- }
8228
- /** The form of the scoped schemas this addon declared, hydrated from its store. */
8229
- async scopedForm(nodeId) {
8230
- await this.loadScopedSchemas();
8231
- const schema = this.scopedFormSchema();
8232
- if (!schema) return { sections: [] };
8233
- return hydrateSchema(schema, await this.readRawProjectedStore(nodeId), { inlineSecretsAsViews: true });
8234
- }
8235
- /**
8236
8209
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
8237
8210
  * every `perNode: true` field carries THAT node's scoped value on its bare
8238
8211
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -8419,12 +8392,6 @@ var BaseAddon = class {
8419
8392
  this._nodeKeysByCap = /* @__PURE__ */ new Map();
8420
8393
  this._addonSecretTree = null;
8421
8394
  }
8422
- /** The form of an addon's scoped schemas: their sections, each shown once. */
8423
- scopedFormSchema(cap) {
8424
- const byId = /* @__PURE__ */ new Map();
8425
- for (const entry of this.loadedScopedSchemas(cap)) for (const section of entry.schema.sections) if (!byId.has(section.id)) byId.set(section.id, section);
8426
- return byId.size === 0 ? null : { sections: [...byId.values()] };
8427
- }
8428
8395
  /** Every loaded scoped schema of `cap`, or of every loaded capability. */
8429
8396
  loadedScopedSchemas(cap) {
8430
8397
  if (cap !== void 0) return this._scopedByCap.get(cap) ?? [];
@@ -9014,6 +8981,10 @@ function normalizeAddonInitResult(result) {
9014
8981
  if (Array.isArray(result)) return { providers: result };
9015
8982
  return result;
9016
8983
  }
8984
+ object({
8985
+ code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
8986
+ params: record(string(), union([string(), number$1()])).optional()
8987
+ });
9017
8988
  object({
9018
8989
  field: string().min(1),
9019
8990
  on: literal("advance")
@@ -9090,12 +9061,6 @@ function systemMethod(input, output, options) {
9090
9061
  systemOnly: true
9091
9062
  };
9092
9063
  }
9093
- /**
9094
- * A method a SOURCE of a collection cap may legitimately not serve — OPTIONAL
9095
- * on `InferProvider`. The `providerOptional: true` literal is what
9096
- * `InferProvider` keys on; see {@link CapabilityMethodSchema.providerOptional}
9097
- * for when this is the honest answer and when it is a soft stub.
9098
- */
9099
9064
  function optionalMethod(input, output, options) {
9100
9065
  return {
9101
9066
  ...method(input, output, options),
@@ -16318,10 +16283,6 @@ Object.freeze({
16318
16283
  "uploadDataset": 72e5
16319
16284
  }
16320
16285
  });
16321
- object({
16322
- code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
16323
- params: record(string(), union([string(), number$1()])).optional()
16324
- });
16325
16286
  //#endregion
16326
16287
  //#region ../types/dist/composition-CXCX78IR.mjs
16327
16288
  /**
@@ -18033,25 +17994,6 @@ var RequiredAddonUpdateSchema = object({
18033
17994
  installed: string().nullable()
18034
17995
  });
18035
17996
  /**
18036
- * Which integration instance a settings form is for. An addon that serves several instances
18037
- * (`instanceMode: multiple`) can show a different form per instance — an NVR integration
18038
- * needs its connection, the default integration needs the addon's own sections.
18039
- *
18040
- * - `integrationId` is `null` in the create wizard: nothing exists yet, the operator is
18041
- * setting up a NEW instance.
18042
- * - `mode` is the wizard mode of the integration type (`getAvailableTypes`).
18043
- * - `candidateStableId` is the discovery candidate a wizard was seeded from, if any.
18044
- */
18045
- var IntegrationInstanceRefSchema = object({
18046
- integrationId: string().nullable(),
18047
- mode: _enum([
18048
- "standalone",
18049
- "account",
18050
- "broker"
18051
- ]),
18052
- candidateStableId: string().optional()
18053
- });
18054
- /**
18055
17997
  * notification-output — canonical, capability-gated notification delivery.
18056
17998
  *
18057
17999
  * Apprise-derived model (see
@@ -44137,10 +44079,6 @@ method(object({
44137
44079
  scope: ScopedSettingsScopeSchema,
44138
44080
  nodeId: string().optional()
44139
44081
  }), record(string(), unknown()).nullable()), method(object({
44140
- addonId: string(),
44141
- nodeId: string().optional(),
44142
- instance: IntegrationInstanceRefSchema
44143
- }), SettingsSchemaWithValuesSchema.nullable()), method(object({
44144
44082
  addonId: string(),
44145
44083
  nodeId: string().optional()
44146
44084
  }), object({ keys: array(string()) }).nullable(), { auth: "admin" }), method(object({
@@ -54507,6 +54445,12 @@ var IntegrationWithStateSchema = object({
54507
54445
  name: string(),
54508
54446
  /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54509
54447
  enabled: boolean(),
54448
+ /**
54449
+ * True when the addon that holds the switch did not answer (down, failed, or keeps no record for
54450
+ * this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
54451
+ * must not draw it as on or off (D315).
54452
+ */
54453
+ switchUnknown: literal(true).optional(),
54510
54454
  info: record(string(), unknown()).readonly(),
54511
54455
  /** The discovery candidate this integration was set up from (D984). */
54512
54456
  originStableId: string().optional(),
@@ -54520,6 +54464,12 @@ var IntegrationLiteSchema = object({
54520
54464
  name: string(),
54521
54465
  /** A projection of the instance body's switch (`setInstanceEnabled` is the only writer). */
54522
54466
  enabled: boolean(),
54467
+ /**
54468
+ * True when the addon that holds the switch did not answer (down, failed, or keeps no record for
54469
+ * this row): `enabled` is then the stored registry flag, a stale value, not the state. A reader
54470
+ * must not draw it as on or off (D315).
54471
+ */
54472
+ switchUnknown: literal(true).optional(),
54523
54473
  info: record(string(), unknown()).readonly(),
54524
54474
  /** The discovery candidate this integration was set up from (D984). */
54525
54475
  originStableId: string().optional(),
@@ -54618,9 +54568,9 @@ var UpdateIntegrationInputSchema = object({
54618
54568
  id: string(),
54619
54569
  name: string().optional(),
54620
54570
  /**
54621
- * Accepted for a FIXED builtin only (`info.fixed`: alarm panel, camera grid, core blocks,
54622
- * terminal), which keeps no instance record: the registry flag is its one store. Any other
54623
- * integration is switched through `integration-instances.setInstanceEnabled`.
54571
+ * Honoured ONLY for a fixed builtin (`info.fixed`), whose switch is the hub's own registry flag
54572
+ * and works while its addon is down. Any other row is refused (a typed `BAD_REQUEST`): its
54573
+ * switch is `integration-instances.setInstanceEnabled`.
54624
54574
  */
54625
54575
  enabled: boolean().optional(),
54626
54576
  info: record(string(), unknown()).optional()
@@ -54654,6 +54604,12 @@ method(_void(), array(IntegrationWithStateSchema)), method(object({ id: string()
54654
54604
  * the form as a `SecretFieldView`, never text (D789). A patch value omitted, `''`
54655
54605
  * or the redaction token KEEPS the stored secret; `{ $secretClear: true }`
54656
54606
  * clears it.
54607
+ *
54608
+ * Who may call (epic #440): every method but `describe` and `instanceFormSchema` is open to any
54609
+ * session (`caller: 'scoped'`) and default-denies. An admin passes everywhere. A non-admin passes
54610
+ * only on a call pinned to one addon whose `describe().userScoped` is true, and that provider
54611
+ * filters every row on the `caller` the router injected (a notification target is somebody's
54612
+ * phone: a user sees and changes only their own). An addon that says nothing keeps the admin door.
54657
54613
  */
54658
54614
  var ConfigSchemaPassthrough$2 = custom();
54659
54615
  var IntegrationInstanceIdSchema = string().min(1);
@@ -54767,7 +54723,15 @@ var IntegrationInstanceDescriptionSchema = object({
54767
54723
  */
54768
54724
  mintsId: boolean().optional(),
54769
54725
  /** The links to other instances the provider's kinds declare; absent means none. */
54770
- links: array(IntegrationInstanceLinkSchema).optional()
54726
+ links: array(IntegrationInstanceLinkSchema).optional(),
54727
+ /**
54728
+ * The rows belong to individual users (a notification target is somebody's phone). The router
54729
+ * then opens `listInstances`, `getInstance`, `createInstance`, `updateInstance`,
54730
+ * `setInstanceEnabled`, `deleteInstance` and `testInstance` to a NON-admin session on a call
54731
+ * pinned to this addon, and hands the provider the `caller` so it keeps a user to their own rows.
54732
+ * Absent means admin only, as it always was.
54733
+ */
54734
+ userScoped: boolean().optional()
54771
54735
  });
54772
54736
  var IntegrationInstanceStatusSchema = object({
54773
54737
  state: _enum([
@@ -54817,7 +54781,13 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
54817
54781
  ]).optional(),
54818
54782
  /** The discovery candidate the wizard was seeded from (`stableId`), if any. */
54819
54783
  candidateStableId: string().min(1).optional()
54820
- }), ConfigSchemaPassthrough$2, { auth: "admin" }), method(_void(), array(IntegrationInstanceSchema).readonly(), { auth: "admin" }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), { auth: "admin" }), method(object({
54784
+ }), ConfigSchemaPassthrough$2, { auth: "admin" }), method(looseObject({}), array(IntegrationInstanceSchema).readonly(), {
54785
+ auth: "protected",
54786
+ caller: "scoped"
54787
+ }), method(object({ id: IntegrationInstanceIdSchema }), IntegrationInstanceSchema.nullable(), {
54788
+ auth: "protected",
54789
+ caller: "scoped"
54790
+ }), method(object({
54821
54791
  id: IntegrationInstanceIdSchema.optional(),
54822
54792
  name: string().min(1),
54823
54793
  kind: string().min(1).optional(),
@@ -54839,19 +54809,23 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
54839
54809
  seed: object({ info: record(string(), unknown()) }).optional()
54840
54810
  }), object({ id: string() }), {
54841
54811
  kind: "mutation",
54842
- auth: "admin"
54812
+ auth: "protected",
54813
+ caller: "scoped"
54843
54814
  }), method(IntegrationInstancePatchSchema, object({ ok: literal(true) }), {
54844
54815
  kind: "mutation",
54845
- auth: "admin"
54816
+ auth: "protected",
54817
+ caller: "scoped"
54846
54818
  }), method(object({
54847
54819
  id: IntegrationInstanceIdSchema,
54848
54820
  enabled: boolean()
54849
54821
  }), object({ ok: literal(true) }), {
54850
54822
  kind: "mutation",
54851
- auth: "admin"
54823
+ auth: "protected",
54824
+ caller: "scoped"
54852
54825
  }), method(object({ id: IntegrationInstanceIdSchema }), object({ ok: literal(true) }), {
54853
54826
  kind: "mutation",
54854
- auth: "admin"
54827
+ auth: "protected",
54828
+ caller: "scoped"
54855
54829
  }), optionalMethod(object({
54856
54830
  id: IntegrationInstanceIdSchema.nullable(),
54857
54831
  values: record(string(), unknown()),
@@ -54859,7 +54833,8 @@ method(_void(), IntegrationInstanceDescriptionSchema, { auth: "admin" }), method
54859
54833
  kind: string().min(1).optional()
54860
54834
  }), TestConnectionResultSchema, {
54861
54835
  kind: "mutation",
54862
- auth: "admin"
54836
+ auth: "protected",
54837
+ caller: "scoped"
54863
54838
  });
54864
54839
  /**
54865
54840
  * Two-way audio / talk-back cap. Clients open a WebRTC audio-only
@@ -72707,6 +72682,11 @@ var SendEmailResultSchema = object({
72707
72682
  var SmtpStatusSchema = object({
72708
72683
  /** True iff the addon has successfully verified the relay. */
72709
72684
  ready: boolean(),
72685
+ /**
72686
+ * The tri-state behind `ready` (D315): true when the last send worked, false when it failed,
72687
+ * ABSENT when the relay has not sent yet (unknown, never "not verified").
72688
+ */
72689
+ verified: boolean().optional(),
72710
72690
  /** Operator-visible host string (no credentials). */
72711
72691
  host: string(),
72712
72692
  /** Last error message reported by the relay, when not ready. */
@@ -72718,10 +72698,6 @@ method(SendEmailInputSchema, SendEmailResultSchema, {
72718
72698
  kind: "mutation",
72719
72699
  auth: "admin",
72720
72700
  access: "create"
72721
- }), method(RelayPinSchema, SmtpStatusSchema, {
72722
- kind: "mutation",
72723
- auth: "admin",
72724
- access: "view"
72725
72701
  }), method(RelayPinSchema, SmtpStatusSchema, { auth: "admin" });
72726
72702
  /**
72727
72703
  * A single device snapshot returned as base64 JPEG/PNG.
@@ -79390,13 +79366,6 @@ Object.freeze({
79390
79366
  access: "view",
79391
79367
  role: "admin"
79392
79368
  },
79393
- "addonSettings.getIntegrationFormSchema": {
79394
- capName: "addon-settings",
79395
- capScope: "system",
79396
- addonId: null,
79397
- access: "view",
79398
- role: "admin"
79399
- },
79400
79369
  "addonSettings.getScopedSettings": {
79401
79370
  capName: "addon-settings",
79402
79371
  capScope: "system",
@@ -87419,13 +87388,6 @@ Object.freeze({
87419
87388
  access: "create",
87420
87389
  role: "admin"
87421
87390
  },
87422
- "smtpProvider.verify": {
87423
- capName: "smtp-provider",
87424
- capScope: "system",
87425
- addonId: null,
87426
- access: "view",
87427
- role: "admin"
87428
- },
87429
87391
  "snapshot.applyDeviceSettingsPatch": {
87430
87392
  capName: "snapshot",
87431
87393
  capScope: "device",
@@ -93799,7 +93761,7 @@ var AdminUIAddon = class extends BaseAddon {
93799
93761
  capability: adminUiCapability,
93800
93762
  provider: {
93801
93763
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
93802
- getVersion: async () => ({ version: "1.2.626" })
93764
+ getVersion: async () => ({ version: "1.2.627" })
93803
93765
  }
93804
93766
  }];
93805
93767
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.626",
3
+ "version": "1.2.627",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -50,7 +50,7 @@
50
50
  }
51
51
  ],
52
52
  "requires": {
53
- "server": ">=1.2.819"
53
+ "server": ">=1.2.820"
54
54
  }
55
55
  },
56
56
  "scripts": {
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o 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{Cn as d,Di as f,Fi as p,Ii as m,Kt as h,Mi as g,Pn as _,Q as v,Qn as y,Rt as b,Ut as x,br as S,bt as C,ct as w,dn as T,ii as E,ot as ee,ut as D,wn as O,xn as te,yi as ne,zn as re}from"./player-overlays-CC-b3--a.js";import{As as k}from"./client-kWeONSGL.js";import{a as A,p as ie}from"./video-b4uGYAxS.js";import{$i as ae,Af as oe,Br as se,Di as ce,Fr as le,Hc as j,Ht as ue,Ir as de,Lr as M,Mt as N,Nf as fe,Vr as P,Xs as F,Zi as pe,_a as I,_n as me,aa as he,ba as L,ca as R,da as ge,ea as z,fa as _e,ga as ve,ha as B,ia as V,ir as H,la as ye,ma as be,na as xe,nr as U,oa as W,or as Se,ra as G,rr as Ce,sf as we,ta as Te,tr as Ee,ua as De,vn as Oe,xa as ke,ya as Ae,yi as K,zr as je}from"./src-DGSNF4l8.js";import{t as q}from"./useTranslation-BJr-n0es.js";import"./mount-DCNN-HPV.js";import{Br as Me,Pr as Ne,Rr as J}from"./index-DwCHDODI.js";import{t as Y}from"./AdminPage-dLt1mKEa.js";import{i as Pe,r as Fe,t as Ie}from"./addon-kind-filter-CEGKkC1O.js";import{t as Le}from"./framework-packages-DoBKjjer.js";import{t as X}from"./NodeAddonsSettingsPanel-BGB_St7Q.js";import{n as Re,t as ze}from"./useNodeUrlSelection-D9CPif56.js";function Be(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var Z={queued:{icon:ne,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:S,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:_,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:m,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:A,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Q({item:e}){let{t:n}=q(),r=Z[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Ve=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),He=new Set([`done`,`failed`,`skipped`]);function Ue(e){return!He.has(e.phase)&&!Ve.has(e.jobState)}function We(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ve.has(e.state);for(let i of e.tasks)r&&i.finishedAtMs!==null&&t-i.finishedAtMs>6e4||n.set(i.packageName,{jobId:e.jobId,packageName:i.packageName,phase:i.phase,fromVersion:i.fromVersion,toVersion:i.toVersion,error:i.error,jobState:e.state,finishedAtMs:i.finishedAtMs})}return n}function Ge(){let{data:e}=ye({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=fe(k.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return We([...n.values()],Date.now())},[e,t])}var Ke={queued:{icon:ne,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:S,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:S,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:S,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:S,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:S,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:S,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:m,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:A,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:T,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function qe({progress:e}){let{t:n}=q(),r=Ke[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Je(e,t){return e.filter(e=>e.packageName===t).slice().sort((e,t)=>e.isHub===t.isHub?e.nodeName.localeCompare(t.nodeName):e.isHub?-1:1)}function Ye(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Xe(e,t,n){let r=[`${e} will be uninstalled from ${t.length} node(s). Its runners stop, its capabilities are deregistered and its code is deleted:`,...t.map(Ye)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Ze(e,t,n){let r=[`${e} will be uninstalled from ${t}: its runners stop and its code is deleted.`];return n.length>0&&r.push(`It stays installed on: ${n.map(e=>e.nodeName).join(`, `)}. Use "Everywhere" to remove it from every node.`),r.push(`This cannot be undone.`),r.join(`
3
- `)}var Qe={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function $e(e,t){let n=[];for(let r of e.results){let e=r.runnersStopped.length>0?` (stopped ${r.runnersStopped.join(`, `)})`:``;n.push(`${t(r.nodeId)}: ${Qe[r.outcome]}${e}`),r.error!==void 0&&n.push(` ${r.error}`);for(let e of r.warnings)n.push(` ${e}`)}return n.join(`
4
- `)}var et={},tt=3e4,nt=`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-red-400 hover:border-red-500/30 hover:bg-red-500/10 disabled:opacity-50 transition-colors`;function rt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=q(),c=l(),u=w(),d=ee(),f=R(et,{staleTime:tt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),g=Je(p,e),_=e=>g.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),v=L({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),y=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:$e(e,_),variant:e.success?`default`:`danger`})},b=async t=>{try{await y(await v.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},x=async()=>{let e=g.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:Ze(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await b(r.isHub?{}:{nodeId:r.id})},S=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=Je(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:Xe(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await b({everywhere:!0})},C=v.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:C,className:nt,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(h,{className:`h-3 w-3`}),v.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(g.length>1||i===!0||m.length>0)&&t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),S()},disabled:C,className:nt,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(ie,{className:`h-3 w-3`}),g.length>0?s(`addons.uninstallControls.everywhereCount`,{count:g.length}):s(`addons.uninstallControls.everywhere`)]})]})}function it(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function at(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!it(e))}function ot(e){return e.length-at(e,!1).length}c();function st({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=q(),f=r===`upload`||r===`local`,[p,h]=s(!1),{data:g,isLoading:_,isError:v}=V({name:e}),y=g?at(g,p):[],x=g?ot(g):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(K,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(C,{className:`h-3 w-3`})})]}),f&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(b,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Ne,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),_&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(S,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),v&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),y.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:y.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),it(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(K,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(m,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(K,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(E,{className:`h-3 w-3`})})]},e.version)})}),!_&&!v&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),x>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:p?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:x})})]})}c();var ct=`device-export`;function lt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===ct)}function ut(e){return e!==`local`&&e!==`upload`}function dt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,f=r&&i?v(`/api/addon-assets/${r}/${i}`):null,p=!!f&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:p?a(`img`,{src:f,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?y:re,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),ut(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(b,{className:`h-2.5 w-2.5 text-white`})})]})}function ft({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=q();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(S,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(E,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(p,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(p,{className:`h-3 w-3 opacity-50`})]}),u]})}function pt({addonId:e}){let t=l(),{data:n=`inherit`}=z({addonId:e}),r=ve({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(K,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var mt={id:`hub`,name:`Hub`,isHub:!0};function ht({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdate:d,isUpdating:f,jobProgress:m,bundle:h,bulkItem:v,disabledByBulk:b,isSystem:x,selectedNode:S}){let{t:w}=q(),[T,E]=s(!1),[ee,D]=s(!1),[ne,re]=s(null);o(()=>{re(null)},[i]);let k=ne??i,[ie,ae]=s(!1),[oe,j]=s(!1),[N,fe]=s(`logs`),F=l(),pe=J(),{manifest:I}=e,L=!h&&!I.protected&&I.removable!==!1,R=!!h,ge=h?.displayName??I.name,z=h?.packageName??I.packageName,ve=h?.version??I.packageVersion??I.version,B=h?.installSource??e.installSource,V=h?h.bundle?.description??h.addons[0]?.manifest.description:I.description,H=_e({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]})}}),ye=he({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`addonPages`]]}),F.invalidateQueries({queryKey:[[`capabilities`]]}),F.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=be({onSuccess:()=>{F.invalidateQueries({queryKey:[[`addons`]]}),F.invalidateQueries({queryKey:[[`alerts`]]})}}),U=e.health,W=U?.phase===`failed`&&!U.inGracePeriod,Se=W&&U?.nextRetryAt&&!U.retrying,G=Be(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${W?`border-red-500/50`:`border-border`}`,children:[W&&U&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.failedToLoad`,{attempt:U.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.lastError?.message??w(`addons.addonCard.unknownError`,`Unknown error`)}),Se&&U.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:w(`addons.addonCard.autoRetryAt`,{time:new Date(U.nextRetryAt).toLocaleTimeString()})})]}),t(K,{variant:`unstyled`,type:`button`,disabled:xe.isPending||U.retrying,onClick:e=>{e.stopPropagation(),xe.mutate({packageName:z})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:w(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(_,{className:`h-3 w-3 ${xe.isPending||U.retrying?`animate-spin`:``}`}),w(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(A,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:w(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(dt,{isBundle:R||!!I.components&&I.components.length>1,installSource:B,addonId:R?h.addons[0]?.manifest.id:I.id,iconPath:R?h.bundle?.icon??h.addons[0]?.manifest.icon:I.icon,color:R?h.addons[0]?.manifest.color:I.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:ge}),!r&&a(ft,{version:ve,availableUpdate:i,...k===void 0?{}:{selectedVersion:k},isUpdating:f,installSource:B,disabled:b,...d&&k!==void 0?{onUpdate:()=>d(k)}:{},onOpenPicker:()=>D(e=>!e),children:ee&&a(st,{packageName:z,currentVersion:ve,...B?{installSource:B}:{},...i!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{re(e),D(!1)}}:{},onInstall:e=>{D(!1),ye.mutate({packageName:z,version:e})},onClose:()=>D(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[z!==ge&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:z}),R&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(y,{className:`h-3 w-3`}),h.addons.length]}),x&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:w(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(_,{className:`h-3 w-3`}),w(`addons.addonCard.system`,`System`)]}),v!=null&&a(Q,{item:v}),c!==void 0&&a(ce,{variant:`warning`,title:w(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:w(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),m!=null&&a(qe,{progress:m})]}),V&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:V}),!R&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?w(`addons.addonCard.forked`):w(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!R&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),H.mutate({addonId:I.id})},disabled:H.isPending||b,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(_,{className:`h-3 w-3 ${H.isPending?`animate-spin`:``}`}),w(`addons.addonCard.restart`,`Restart`)]}),t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ae(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ie?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(O,{className:`h-3 w-3`}),w(`addons.addonCard.logs`,`Logs`)]}),!R&&t(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),j(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${oe?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(te,{className:`h-3 w-3`}),w(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),L&&a(rt,{packageName:I.packageName,displayName:I.name,selectedNode:S??mt,disabled:b})]}),n&&n.nodes.length>1&&!R&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:w(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:w(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:w(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:w(`common.synced`)})]},e.nodeId))})]}),ie&&!R&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(K,{variant:`unstyled`,type:`button`,onClick:()=>fe(`logs`),className:`px-2 py-0.5 transition-colors ${N===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.logs`,`Logs`)}),a(K,{variant:`unstyled`,type:`button`,onClick:()=>fe(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${N===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:w(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(K,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),ae(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(C,{className:`h-3.5 w-3.5`})})]}),N===`logs`&&a(Oe,{addonId:I.id,maxHeight:`max-h-64`,showFilters:!1}),N===`events`&&a(me,{addonId:I.id,category:`addon.*`,maxHeight:`max-h-64`})]}),R&&t(u,{children:[a(K,{variant:`unstyled`,type:`button`,onClick:()=>E(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(T?g:p,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),T&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:h.addons.map(e=>a(ht,{addon:e,hideVersion:!0},e.manifest.id))})]}),oe&&!R&&a(le,{open:!0,onOpenChange:e=>!e&&j(!1),children:t(M,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(se,{children:t(P,{className:`flex items-center gap-2`,children:[a(te,{className:`h-4 w-4 text-primary`}),w(`addons.addonCard.settingsTitle`,{name:ge})]})}),t(de,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:w(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(X,{nodeId:null,addonIds:[I.id],level:`global`,fieldScope:`cluster`,emptyMessage:w(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)}),lt(I)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.deviceExport`,`Device export`)}),a(ue,{addonId:I.id,onOpenDevice:e=>pe(`/devices/${e}`)})]}),ut(B)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(pt,{addonId:I.id})]}),I.components&&I.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:w(`addons.addonCard.components`,{count:I.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:I.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(je,{children:a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>j(!1),children:w(`common.close`,`Close`)})})]})})]})}c();var gt=`.tgz,.tar.gz,.zip`;function _t({onUploadSuccess:e}){let{t:r}=q(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(v(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(Se,{ref:l,accept:gt,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(K,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(S,{className:`w-3.5 h-3.5 animate-spin`}):a(b,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var vt=/```[^\n]*\n([\s\S]*?)```/g;function yt(e){let t=[],n=0;for(let r of e.matchAll(vt)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function bt(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function xt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?bt(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function St(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:xt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:xt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=xt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Ct({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:yt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:St(e.body,`b${t}`)},`text-${t}`))})}c();function wt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Tt(e,t,n){let r=at(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function Et({pending:e,failed:n,body:r,missing:i}){let{t:o}=q();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(S,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Ct,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function Dt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=q(),[l,u]=s(e.version),[d,f]=s(!1),p=V({name:e.name}),m=G({name:e.name,version:l}),h=p.data??[],g=ot(h),_=Tt(h,l,d),v=m.data;return a(le,{open:!0,onOpenChange:e=>!e&&i(),children:t(M,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(se,{children:a(P,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:wt(e.name)})})}),t(de,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(D,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:it(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(K,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(Ee,{defaultValue:`readme`,children:[t(Ce,{children:[a(H,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(H,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(U,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(U,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(Et,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(je,{children:[a(K,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(K,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(S,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}var Ot=new Set([`@camstack/server`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function kt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Ot.has(r.packageName)||!t.isHub&&r.nodeId!==t.id)continue;let e=n.get(r.packageName)??[];e.push(r),n.set(r.packageName,e)}return[...n].map(([e,t])=>({packageName:e,rows:t})).sort((e,t)=>e.packageName.localeCompare(t.packageName))}function At({selectedNode:e}){let{t:n}=q(),{data:r}=R(et,{staleTime:tt});if(r===void 0)return null;let i=kt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(x,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(rt,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function jt({addon:e,installing:n,onInstall:r}){let{t:i}=q();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(ce,{variant:`success`,icon:a(m,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(K,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(S,{className:`h-3 w-3 animate-spin`}):a(E,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Mt({capability:e,installing:n,onInstall:r}){let{t:i}=q(),{data:o,isPending:s,isError:c}=B({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(S,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(jt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Nt(e){return e===`npm`||e===`dev`?e:null}var Pt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,Ft=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,It=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Lt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Rt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function zt(e){return e===`local`?`dev`:`npm`}function Bt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Vt(e){let t=new Map,n=[];for(let r of e){let e=r.manifest.packageName;if(!e){n.push(r);continue}let i=t.get(e);if(i)i.addons.push(r);else{let n=r.manifest.bundle,i={packageName:e,displayName:n?.displayName??r.manifest.packageDisplayName??r.manifest.name,version:r.manifest.packageVersion,addons:[r],...r.installSource===void 0?{}:{installSource:r.installSource},...n===void 0?{}:{bundle:n}};t.set(e,i)}}let r=[];for(let e of t.values())e.bundle!==void 0||e.addons.length>=2?r.push({bundle:e,representative:e.addons[0]}):r.push(e.addons[0]);return r.push(...n),r}function $(e){return`bundle`in e}function Ht({addons:c,clusterStatus:u,selectedNode:p,onRefresh:m,listPhase:h}){let{t:g}=q(),v=l(),[y,b]=s(``),x=e(y),[C,T]=s(!1),ee=n(null);o(()=>{if(!C)return;let e=e=>{ee.current&&!ee.current.contains(e.target)&&T(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[C]);let{data:O}=De({nodeId:p.id}),te=r(()=>{let e=new Map;for(let t of O??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[O]),ne=r(()=>{let e=new Map;for(let t of O??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[O]),re=r(()=>(O??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[O]),[k,A]=s(()=>new Set),[ie,ae]=s(()=>new Map),oe=i(e=>{A(t=>new Set(t).add(e))},[]),se=i(e=>{A(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),ce=i((e,t)=>{ae(n=>new Map(n).set(e,t))},[]),le=i(e=>{ae(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),j=ke({onMutate:e=>{oe(e.name),le(e.name)},onSuccess:(e,t)=>{se(t.name);let n=e;if(n&&n.success===!1){ce(t.name,n.error??`Update failed (no error message returned by server)`);return}v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{se(t.name),ce(t.name,e instanceof Error?e.message:String(e))}}),ue=Ge(),de=n(new Set);o(()=>{let e=new Set;for(let[t,n]of ue)Ue(n)&&e.add(t);let t=[...de.current].some(t=>!e.has(t));de.current=e,t&&(v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[ue,v]);let{data:M}=Te(void 0),N=pe({onSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),fe=I({onSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:P,isFetching:me}=B({query:x||void 0},{enabled:C}),L=Ae(),{data:R}=xe(void 0),ge=R?.requestedAt,[z,_e]=s(null),[ve,V]=s(!1);o(()=>{if(R?.kind===`framework-bulk-update`&&R.requestedAt!==z){_e(R.requestedAt),V(!0);let e=window.setTimeout(()=>V(!1),6e3);return()=>window.clearTimeout(e)}},[ge,z,R]),w();let H=i(async()=>{let e=(O??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!p.isHub){for(let t of e)await j.mutateAsync({name:t.name,version:t.latestVersion,nodeId:p.id});return}await L.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[p.id]})}},[O,p.id,p.isHub,L,j]),[ye,be]=s(null),[U,W]=s(null),Se=e=>{W(null),be(e)},G=he({onSuccess:()=>{be(null),W(null),v.invalidateQueries({queryKey:[[`addons`]]}),v.invalidateQueries({queryKey:[[`addonPages`]]}),v.invalidateQueries({queryKey:[[`capabilities`]]}),v.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{W(e instanceof Error?e.message:`Install failed`)}}),[Ce,Ee]=s(`type`),[Oe,je]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ne=e=>{je(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,Y]=Me(),X=J.get(`capability`),Re=J.get(`updatable`)===`1`,ze=J.get(`error`)===`1`,Z=Nt(J.get(`source`)),Q=Pe(J.get(Ie))===`integration`,{data:Ve}=F(void 0,{enabled:Q}),He=r(()=>Ve===void 0?null:new Set(Ve.map(e=>e.addonId)),[Ve]),We=i(e=>{let t=new URLSearchParams(J);e?t.set(Ie,`integration`):t.delete(Ie),Y(t,{replace:!0})},[J,Y]),Ke=i(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[J,Y]),qe=i(e=>{let t=new URLSearchParams(J);e?t.set(`error`,`1`):t.delete(`error`),Y(t,{replace:!0})},[J,Y]),Je=i(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[J,Y]),Ye=r(()=>c.filter(e=>Be(e.process)!==null).length,[c]),Xe=r(()=>{let e=c.filter(e=>!Le(e.manifest.packageName));return p.isHub||(e=e.filter(e=>Rt(e.placement,p.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Q&&(e=[...Fe(e,He)]),Re&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&te.has(t)})),Z!==null&&(e=e.filter(e=>zt(e.installSource)===Z)),ze&&(e=e.filter(e=>Be(e.process)!==null)),e},[c,p.isHub,X,Re,Z,ze,Q,He,te]),Ze=()=>{let e=new URLSearchParams(J);e.delete(`capability`),Y(e,{replace:!0})},Qe=Oe===`flat`?Xe:Vt(Xe),$e=r(()=>{let e=[...Qe];switch(Ce){case`type`:e.sort((e,t)=>{let n=+!$(e),r=+!$(t);if(n!==r)return n-r;let i=$(e)?e.bundle.displayName:e.manifest.name,a=$(t)?t.bundle.displayName:t.manifest.name;return i.localeCompare(a)});break;case`name`:e.sort((e,t)=>{let n=$(e)?e.bundle.displayName:e.manifest.name,r=$(t)?t.bundle.displayName:t.manifest.name;return n.localeCompare(r)});break;case`source`:e.sort((e,t)=>{let n=$(e)?e.bundle.installSource??``:e.installSource??``,r=$(t)?t.bundle.installSource??``:t.installSource??``;return n.localeCompare(r)});break}return e},[Qe,Ce]);return t(`div`,{className:`space-y-3`,children:[[...ie.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:g(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(K,{variant:`unstyled`,type:`button`,onClick:()=>le(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:g(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.sort`,`Sort:`)}),t(D,{wrapperClassName:`inline-block w-auto`,value:Ce,onChange:e=>Ee(e.target.value),children:[a(`option`,{value:`type`,children:g(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:g(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:g(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(K,{variant:`unstyled`,type:`button`,onClick:()=>Ne(e),className:`px-2 py-1 transition-colors capitalize ${Oe===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?g(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):g(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),p.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(_,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(K,{variant:`unstyled`,type:`button`,onClick:()=>N.mutate({channel:e}),disabled:N.isPending,className:`px-2 py-1 transition-colors capitalize ${M?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),p.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.checkEvery`,`Check every:`)}),a(D,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:M?.updateCheckIntervalSeconds??21600,disabled:fe.isPending||M===void 0,onChange:e=>{M!==void 0&&fe.mutate({channel:M.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:It.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),re>0&&t(K,{variant:`unstyled`,type:`button`,onClick:()=>void H(),disabled:L.isPending,className:`flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 border border-blue-500/30 disabled:opacity-50 transition-colors font-medium`,children:[L.isPending?a(S,{className:`w-3 h-3 animate-spin`}):a(E,{className:`w-3 h-3`}),L.isPending?g(`admin.system.addons.updating`,`Updating…`):g(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:re})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":g(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:g(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:g(`admin.system.addons.integrations`,`Integrations`),pressed:Q,toggle:()=>We(!Q)},{id:`updatable`,label:g(`admin.system.addons.updatable`,`Updatable`),pressed:Re,toggle:()=>Ke(!Re)},{id:`error`,label:g(`admin.system.addons.inError`,`In error ({{count}})`,{count:Ye}),pressed:ze,toggle:()=>qe(!ze)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Je(Z===`npm`?null:`npm`)},{id:`dev`,label:g(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Je(Z===`dev`?null:`dev`)}].map(e=>a(K,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Pt:Ft,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:ee,children:[a(we,{type:`text`,searchHotkey:!0,value:y,onChange:e=>{b(e.target.value),T(!0)},onFocus:()=>T(!0),placeholder:g(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":g(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:L.isPending,leftSlot:a(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:me?a(S,{className:`h-3 w-3 animate-spin`}):void 0}),C&&P&&P.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[P.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:g(`systemPage.addons.npmResults`,{count:P.length})}),P&&P.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:P.map(e=>a(jt,{addon:e,installing:G.isPending,onInstall:e=>Se({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(_t,{onUploadSuccess:()=>{v.invalidateQueries({queryKey:[[`addons`]]}),m()}})]}),X&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:g(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:X}),a(K,{variant:`unstyled`,type:`button`,onClick:Ze,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:g(`admin.system.addons.clear`,`Clear`)})]}),X&&a(Mt,{capability:X,installing:G.isPending,onInstall:e=>Se({name:e.name,version:e.version,description:e.description})}),X&&Xe.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:g(`admin.system.addons.installed`,`Installed`)}),ve&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(f,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:g(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:g(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),h===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(S,{className:`h-3 w-3 animate-spin`}),g(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),h===`error`&&a(`div`,{className:`text-xs text-danger`,children:g(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),h===`ready`&&Xe.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?g(`admin.system.addons.noAddonsInstalled`,`No addons installed`):X?g(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:X}):g(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:p.name})}),a(`div`,{className:`space-y-1.5`,children:h===`ready`&&$e.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=te.get(t),r=ne.get(t),i=$(e)?e.representative:e,o=n?e=>j.mutate({name:t,version:e,nodeId:p.id}):void 0,s=ue.get(t)??null,c=s!==null&&Ue(s);return a(ht,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},isUpdating:k.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:L.isPending,selectedNode:p},$(e)?t:e.manifest.id)})}),ye!==null&&a(Dt,{target:ye,installing:G.isPending,installError:U,onClose:()=>be(null),onInstall:(e,t)=>G.mutate({packageName:e,version:t})})]})}function Ut(){let{t:e}=q(),r=l(),{data:i}=j(void 0),{nodes:s}=oe(),{selection:c,selectNode:u,requestedNodeId:d}=ze(s.length>0?s:[Lt]),f=c.node??Lt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:v}=W({nodeId:p}),y=ae(),b=ge(),x=y.isPending||b.isPending,S=async()=>{await y.mutateAsync({nodeId:p}),await b.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},C=n(y);C.current=y;let w=n(d??`hub`);o(()=>{C.current.mutate({nodeId:w.current})},[]);let T=(h??[]).map(Bt).filter(e=>e!==null);return t(Y,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(N,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!v&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:T.length})}),t(K,{variant:`unstyled`,type:`button`,onClick:()=>void S(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(_,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Re,{staleNodeId:m,shownNodeName:f.name}),a(At,{selectedNode:f}),a(Ht,{addons:T,clusterStatus:i,selectedNode:f,onRefresh:()=>void S(),listPhase:g?`pending`:v?`error`:`ready`})]})}export{Ut as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t 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{Cn as d,D as f,G as p,Gi as m,Hr as h,Kt as g,L as _,Q as v,Sn as y,Vi as b,an as x,br as S,bt as C,ht as w,ii as T,sn as E,ut as D}from"./player-overlays-CC-b3--a.js";import{ci as O}from"./client-kWeONSGL.js";import{n as k,t as A}from"./send-CwDFB9fX.js";import{t as j}from"./message-square-plus-spORh6qX.js";import{Bn as M,Di as N,Ft as P,Go as F,Ln as I,Oi as ee,Qr as L,Xr as R,Yr as z,Zr as te,ai as B,cf as ne,dr as re,gt as ie,ki as V,sf as ae,yi as H,zn as U}from"./src-DGSNF4l8.js";import{t as W}from"./i18n-Cmy3cCDH.js";import{t as G}from"./useTranslation-BJr-n0es.js";import"./mount-DCNN-HPV.js";import{Br as K,J as q,S as J}from"./index-DwCHDODI.js";import{t as Y}from"./AdminSectionedPage-BYn7-4dT.js";import{t as oe}from"./AdminPage-dLt1mKEa.js";import{t as se}from"./InstancesTable-Bt8qoWMR.js";import{a as ce,c as le,d as ue,f as de,i as fe,l as X,n as pe,o as me,p as he,r as ge,s as Z,t as _e,u as ve}from"./ai-page.helpers-CJk-hY0M.js";c();function ye(){let{t}=G(),n=w(),r=V({functionCap:`llm`}).data??[],a=s({queryKey:pe,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(I,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:ge.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(X):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(D,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:Z(e)===``?e.name:`${e.name} · ${Z(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},n)})})})}var be=2e3;function Q(e){return W.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function xe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Se({nodeId:t,value:r,onChange:a}){let{t:c}=G(),l=w(),[f,p]=o(``),[m,h]=o(null),[g,_]=o(!1),v=s({queryKey:_e,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),x=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),C=s({queryKey:fe,enabled:x.isPending,refetchInterval:x.isPending?be:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,E=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Q(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Q(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Q(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,m,t,c]),O=e=>{if(e===``){a(null);return}if(e===`custom`){if(m?.ok!==!0)return;a({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&b.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(P,{label:c(`ai.model`,`Model`),required:!0,children:i(D,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:xe(r),options:E,onChange:e=>O(e.target.value)})}),i(P,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(ae,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:f,onChange:e=>p(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),k())}}),e(H,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||b.isPending,onClick:()=>k(),children:[b.isPending?i(S,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(z,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(z,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(H,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),b.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Q(m.requiredBytes)})})]})}),m?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:m.label}),i(N,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(N,{variant:`default`,children:Q(m.totalBytes)})]}),m.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(H,{size:`sm`,type:`button`,disabled:x.isPending||g,onClick:()=>x.mutate(m.model),children:[x.isPending?i(S,{className:`h-3.5 w-3.5 animate-spin`}):i(T,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),C!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:C.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:C.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:C.file,index:C.fileIndex,count:C.fileCount,done:Q(C.downloadedBytes),total:C.totalBytes===void 0?``:` / ${Q(C.totalBytes)}`})})]}),x.isError&&i(z,{message:x.error instanceof Error?x.error.message:c(`common.error`,`Error`)})]})]})}function Ce({value:t,onChange:n}){let{t:r}=G(),a=w(),o=s({queryKey:fe,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(S,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=me(a),s=o.nodeId===t;return e(H,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(N,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function we(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Te({providerConfig:e,onProviderConfigChange:t}){return i(Ce,{value:we(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function Ee({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=O.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Se,{nodeId:we(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var De=new Map([[`ai/apple-node`,Te],[`ai/managed-model`,Ee]]);function Oe(e){return De.get(e)??null}c();function $(e,t){let n=e[t];return typeof n==`string`?n:``}function ke({row:a}){let{t:c}=G(),d=w(),f=l(),p=s({queryKey:n(()=>[q,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,h]=o({}),g=t({}),_=t(!1),v=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[q]}),await f.invalidateQueries({queryKey:[ee]}),h({})}}),y=r(e=>{g.current={...g.current,...e},h(t=>({...t,...e})),!_.current&&(_.current=!0,queueMicrotask(()=>{let e=g.current;g.current={},_.current=!1,v.mutate(e)}))},[v]),b=p.data?.description.kinds?.find(e=>e.id===a.kindId),x=p.data?.instance?.formValues,C=n(()=>({...x,...m}),[x,m]),T=b?.widgets??[],E=T.some(e=>e.placement===`model`),O=n(()=>({...$(C,`nodeId`)===``?{}:{nodeId:$(C,`nodeId`)},...typeof C.modelRef==`object`&&C.modelRef!==null?{model:C.modelRef}:{}}),[C]),k={id:$(C,`model`),supportsVision:C.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(z,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);y({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[T.map(({id:e})=>{let t=Oe(e);return t===null?i(z,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:O,onProviderConfigChange:e=>y({...$(e,`nodeId`)===$(O,`nodeId`)?{}:{nodeId:$(e,`nodeId`)},...e.model!==void 0&&e.model!==O.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>y({model:e.id,supportsVision:e.supportsVision})},e)}),!E&&e(P,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(H,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(S,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(D,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),v.isError&&i(z,{variant:`warning`,message:v.error.message})]})}c();var Ae=5e3;function je(e){return W.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Me(){let{t}=G(),r=w(),a=s({queryKey:fe,refetchInterval:Ae,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(N,{variant:he(n),children:t(de(n))}),n.status?.downloadProgress!==void 0&&i(N,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:je(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=ue(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(N,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(I,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(L,{className:`h-8 w-full`}),i(L,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(z,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(R,{icon:y,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(U,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:M})})}var Ne=v(`/addon/ai/test-chat`),Pe=v(`/addon/ai/test-chat/chats`),Fe=6e5;function Ie(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Fe)}function Le(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Re(e){if(!Le(e))return null;let t=e.kind;return t!==`snapshot`&&t!==`track`||typeof e.mimeType!=`string`||typeof e.sizeBytes!=`number`?null:{kind:t,mimeType:e.mimeType,sizeBytes:e.sizeBytes,...typeof e.mediaKind==`string`?{mediaKind:e.mediaKind}:{},...typeof e.capturedAt==`number`?{capturedAt:e.capturedAt}:{},...typeof e.thumbnailBase64==`string`?{thumbnailBase64:e.thumbnailBase64}:{}}}var ze=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Be(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Le(t))return null;switch(t.kind){case`status`:{let e=ze.find(e=>e===t.phase);return e===void 0?null:{kind:`status`,phase:e}}case`meta`:return typeof t.profileName!=`string`||typeof t.model!=`string`?null:{kind:`meta`,profileName:t.profileName,model:t.model,mediaSent:Re(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:W.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*Ve(e){let t=e.getReader(),n=new TextDecoder,r=``;try{for(;;){let{done:e,value:i}=await t.read();if(e)break;r+=n.decode(i,{stream:!0});let a=r.indexOf(`
2
- `);for(;a>=0;){let e=r.slice(0,a).trim();if(r=r.slice(a+1),e.length>0){let t=Be(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Be(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function He(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ue(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function We(e){return e.messages.map((t,n)=>{let r=t.mediaSent??void 0;return{id:`${e.id}-${String(n)}`,role:t.role,content:t.content,...t.attachment===void 0?{}:{attachmentRef:t.attachment,attachmentKind:t.attachment.kind},...r===void 0?{}:{attachment:r}}})}function Ge(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function Ke(e,t){switch(e){case`resolving-image`:return W.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return W.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?W.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):W.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return W.t(`helpers.aiTestChat.phaseAnswering`)}}c();var qe=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Je=360*60*1e3,Ye=40,Xe=160,Ze={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=G();w();let[c,l]=o(``),[u,d]=o(``),[p,h]=o(``),[v,y]=o([]),[S,T]=o(null),[E,O]=o(`none`),[k,M]=o(`throwaway`),[N,P]=o(null),[F,ee]=o([]),[L,R]=o(null),[te,B]=o(null),U=t(null);a(()=>()=>U.current?.abort(),[]);let W=r(async()=>{let e=await fetch(Pe,{credentials:`same-origin`});e.ok&&ee((await e.json()).chats??[])},[]);a(()=>{k===`persistent`&&W()},[k,W]);let K=V({functionCap:`llm`}),q=n(()=>(K.data??[]).filter(e=>e.enabled),[K.data]),J=q.find(e=>e.id===c)??null,Y=te!==null,oe=r(async(e,t)=>{let n=new AbortController;U.current=n,R(null);let r=Ie(J===null?{}:ve(J));B({...Ze,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Ne,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...k===`persistent`?{persist:!0,...N===null?{}:{conversationId:N}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of Ve(s.body))switch(e.kind){case`status`:B(t=>({...t??Ze,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,B(t=>({...t??Ze,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,B(e=>({...e??Ze,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||R(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{U.current=null,B(null)}f!==void 0&&(P(f),W());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||y(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[k,N,J,c,W,u,s]),se=r(()=>{let e=p.trim();if(e===``||c===``||Y)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...S===null?{}:{attachmentLabel:S.label,attachmentKind:S.ref.kind}},n=[...v,t];y(n),h(``);let r=S?.ref;T(null),O(`none`),oe(k===`persistent`&&N!==null?[{role:`user`,content:e}]:He(n),r)},[k,N,p,S,c,oe,Y,v]),ce=()=>U.current?.abort(),le=()=>{U.current?.abort(),y([]),T(null),h(``),R(null),B(null),P(null)},ue=async e=>{U.current?.abort();let t=await fetch(`${Pe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();P(e),y(We(n)),B(null),R(null)};return e(`div`,{className:_,children:[i(I,{headingId:`ai-test-setup`,title:s(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${f} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(D,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...q.map(e=>({value:e.id,label:`${e.name} · ${Z(e)}${X(e)?` · vision`:``}`}))]}),q.length===0&&!K.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(re,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(ae,{id:`ai-test-system`,value:u,onChange:e=>d(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(ie,{label:s(`ai.chatMode`,`Conversation mode`),value:k,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{M(e),e===`throwaway`&&P(null)}}),k===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),F.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:F.map(e=>i(`button`,{type:`button`,onClick:()=>void ue(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===N?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),J!==null&&!X(J)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),L!==null&&i(z,{title:s(`ai.chatFailed`,`The test call failed`),message:L}),e(I,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(H,{size:`sm`,variant:`ghost`,type:`button`,disabled:v.length===0&&S===null,onClick:le,children:[i(g,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:v,live:te}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[S!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[S.ref.kind===`snapshot`?i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(m,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:S.label}),i(ne,{size:`sm`,variant:`ghost`,type:`button`,icon:C,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(H,{size:`sm`,variant:E===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`snapshot`?`none`:`snapshot`),children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(H,{size:`sm`,variant:E===`track`?`primary`:`outline`,type:`button`,onClick:()=>O(E===`track`?`none`:`track`),children:[i(m,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),E===`snapshot`&&i(nt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),O(`none`)}}),E===`track`&&i(it,{onPick:(e,t)=>{T({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),O(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ae,{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),Y?e(H,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[i(x,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(H,{size:`sm`,type:`button`,disabled:p.trim()===``||c===``,onClick:se,children:[i(A,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=G();return t.length===0&&n===null?i(R,{icon:k,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${f}`,children:[t.map(e=>i(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(S,{className:`h-3.5 w-3.5 animate-spin`}),Ke(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=G(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(tt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(m,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(b,{className:`h-3 w-3`}):i(m,{className:`h-3 w-3`}),Ge(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function tt({attachment:e}){let{t}=G(),n=Ue(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function nt({onPick:e}){let{t}=G(),n=F({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(S,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=G(),a=B(t,`compact`),{src:o}=p(t.id,{width:Xe});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(N,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=G(),a=w(),o=F({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...qe,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Je,limit:Ye,projection:`slim`})});if(o.isLoading||u.isLoading)return i(S,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(m,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=G(),r=w(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=V({functionCap:`llm`}),d=s({queryKey:[...ce,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),g=d.data??[],_=i(`div`,{className:`w-36`,children:i(D,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(I,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:_,children:d.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(L,{className:`h-8 w-full`}),i(L,{className:`h-8 w-full`}),i(L,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(z,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):g.length===0?i(R,{icon:h,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(U,{columns:m,rows:g,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:M})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=G(),t=te(ct),[n]=K(),r=J(`/system/ai`,{t:e,isAdmin:!0})??{icon:E,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(oe,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:e(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)};return i(Y,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Me,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,Z)??``,r=t=>pt(t,e,X)??!1,a=t=>pt(t,e,le)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(N,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=G(),r=V({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:_,children:[i(ye,{}),i(se,{functionCap:ct,icon:E,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(ke,{row:e})})]})}function gt({presence:t}){let{t:n}=G();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(L,{className:`h-8 w-64`}),i(L,{className:`h-40 w-full`})]}):t===`unknown`?i(z,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(R,{icon:E,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};
@@ -1 +0,0 @@
1
- import{C as e,K as t,R as n,S as r,Y as i,et as a,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{Ni as c,Pi as l}from"./player-overlays-CC-b3--a.js";import{Fa as u,Pa as d}from"./client-kWeONSGL.js";import{y as f}from"./video-b4uGYAxS.js";import{Br as p,Fr as m,Ir as h,Ja as g,Lr as _,Vr as v,Xa as ee,Ya as y,qa as b,sf as x,ur as S,yi as C,zr as w}from"./src-DGSNF4l8.js";import{t as T}from"./i18n-Cmy3cCDH.js";import{t as E}from"./useTranslation-BJr-n0es.js";import{Fr as te,Pr as ne,Y as D}from"./index-DwCHDODI.js";import{t as re}from"./AdminPage-dLt1mKEa.js";import{t as O}from"./InstanceSwitchCell-BQekirNX.js";a();function k(e,t){return e.flatMap(e=>e.instances.map(n=>({addonId:e.addonId,id:n.id,name:n.name,enabled:n.enabled!==!1,providerName:t.get(e.addonId)??e.addonId})))}function A(e,t,n){let r=new Set,i=(e,t)=>`${e}\u0000${t}`,a=e.map(e=>{let a=e.instanceId===void 0?null:t.find(t=>t.addonId===e.providerAddonId&&t.id===e.instanceId)??null;return a!==null&&r.add(i(a.addonId,a.id)),{key:a===null?e.id:`instance:${a.addonId}:${a.id}`,name:e.name,providerName:a?.providerName??n(e),calendar:e,instance:a}});for(let e of t)r.has(i(e.addonId,e.id))||a.push({key:`instance:${e.addonId}:${e.id}`,name:e.name,providerName:e.providerName,calendar:null,instance:e});return a}var j=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`];function M(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function N(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function P(e){let t=e.getDay();return M(N(e,t===0?-6:1-t))}function F(e,t){if(t===`day`){let t=M(e);return{startMs:t.getTime(),endMs:N(t,1).getTime()}}if(t===`week`){let t=P(e);return{startMs:t.getTime(),endMs:N(t,7).getTime()}}let n=new Date(e.getFullYear(),e.getMonth(),1),r=new Date(e.getFullYear(),e.getMonth()+1,0),i=P(n),a=N(P(r),7);return{startMs:i.getTime(),endMs:a.getTime()}}function I(e,t){if(t===`day`)return e.toLocaleDateString(void 0,{weekday:`long`,year:`numeric`,month:`long`,day:`numeric`});if(t===`week`){let t=P(e),n=N(t,6),r={month:`short`,day:`numeric`};return`${t.toLocaleDateString(void 0,r)} – ${n.toLocaleDateString(void 0,{...r,year:`numeric`})}`}return e.toLocaleDateString(void 0,{month:`long`,year:`numeric`})}function L(e,t,n){return t===`day`?N(e,n):t===`week`?N(e,n*7):new Date(e.getFullYear(),e.getMonth()+n,1)}function R(e,t){if(t===void 0)return e;let n=t.calendars[e.id];return n===void 0?e:{...e,visible:n.visible??e.visible,color:n.color??e.defaultColor}}function z(e){return e.providerAddonId!==void 0&&e.providerAddonId.length>0?e.providerAddonId:e.source===`ha`?`Home Assistant`:e.source}function B(e){if(e.allDay===!0)return T.t(`systemPage.calendars.allDay`);let t=new Date(e.startMs),n=new Date(e.endMs),r={hour:`2-digit`,minute:`2-digit`};return`${t.toLocaleTimeString([],r)} – ${n.toLocaleTimeString([],r)}`}function V(e){let t=d(e),n=new Date(t.startMs),r=new Date(t.endMs),i={weekday:`short`,year:`numeric`,month:`short`,day:`numeric`};if(e.allDay===!0){let e=M(n),t=N(M(r),-1);return G(e,t)?T.t(`systemPage.calendars.dayAllDay`,{date:n.toLocaleDateString(void 0,i)}):T.t(`systemPage.calendars.rangeAllDay`,{from:n.toLocaleDateString(void 0,i),to:t.toLocaleDateString(void 0,i)})}let a={hour:`2-digit`,minute:`2-digit`};return G(n,r)?`${n.toLocaleDateString(void 0,i)} · ${n.toLocaleTimeString([],a)} – ${r.toLocaleTimeString([],a)}`:`${n.toLocaleString(void 0,{...i,...a})} – ${r.toLocaleString(void 0,{...i,...a})}`}function H({label:t,children:n}){return e(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-x-3 gap-y-1 text-sm`,children:[r(`dt`,{className:`text-foreground-subtle`,children:t}),r(`dd`,{className:`min-w-0 break-words text-foreground`,children:n})]})}function U({ev:t,calendarName:n,color:i,onClose:a}){let{t:o}=E();return r(m,{open:!0,onOpenChange:e=>!e&&a(),children:e(_,{width:`md`,placement:`sheet-on-mobile`,scroll:`body`,"data-testid":`calendars-event-detail`,children:[r(p,{children:e(`div`,{className:`flex min-w-0 items-start gap-2.5`,children:[r(`span`,{className:`mt-1.5 h-3 w-3 shrink-0 rounded-full`,style:{backgroundColor:i},"aria-hidden":!0}),r(v,{className:`min-w-0 break-words`,children:t.title})]})}),r(h,{children:e(`dl`,{className:`space-y-3`,children:[r(H,{label:o(`systemPage.calendars.when`,`When`),children:V(t)}),r(H,{label:o(`systemPage.calendars.calendar`,`Calendar`),children:n}),t.location!==void 0&&t.location.length>0?r(H,{label:o(`systemPage.calendars.location`,`Location`),children:t.location}):null,t.description!==void 0&&t.description.length>0?r(H,{label:o(`systemPage.calendars.description`,`Description`),children:r(`span`,{className:`whitespace-pre-wrap`,children:t.description})}):null]})}),r(w,{children:r(C,{type:`button`,size:`sm`,variant:`secondary`,onClick:a,children:o(`common.close`,`Close`)})})]})})}function W(e,t){return e.filter(e=>u(e,t))}function G(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ie({mode:e,onChange:t}){let{t:n}=E(),i=[{id:`month`,label:n(`systemPage.calendars.month`,`Month`)},{id:`week`,label:n(`systemPage.calendars.week`,`Week`)},{id:`day`,label:n(`systemPage.calendars.day`,`Day`)}];return r(`div`,{className:`inline-flex rounded-lg border border-border bg-surface p-0.5`,role:`group`,"aria-label":n(`systemPage.calendars.calendarView`,`Calendar view`),children:i.map(n=>r(C,{variant:`unstyled`,type:`button`,className:e===n.id?`rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground`:`rounded-md px-2.5 py-1 text-xs font-medium text-foreground-subtle hover:text-foreground`,"aria-pressed":e===n.id,onClick:()=>t(n.id),"data-testid":`calendars-view-${n.id}`,children:n.label},n.id))})}function K({rows:t,onToggleVisible:n,onColorChange:i,onSwitched:a,busy:o}){let{t:c}=E();return e(`aside`,{className:`w-full shrink-0 space-y-2 lg:w-56 xl:w-64`,"data-testid":`calendars-legend`,children:[r(`h2`,{className:`text-xs font-medium text-foreground-subtle`,children:c(`systemPage.calendars.calendars`,`Calendars`)}),r(`ul`,{className:`space-y-1`,children:t.map(t=>{let l=t.calendar,u=t.instance!==null&&!t.instance.enabled;return e(`li`,{className:`flex items-start gap-2 rounded-md px-1.5 py-1.5 hover:bg-surface ${u?`opacity-60`:``}`,"data-testid":`calendars-row-${t.key}`,children:[l!==null&&!u?e(s,{children:[r(S,{className:`mt-1 h-3.5 w-3.5 shrink-0 accent-primary`,checked:l.visible,disabled:o,onChange:e=>n(l.id,e.target.checked),"aria-label":c(`systemPage.calendars.show`,`Show {{name}}`,{name:t.name}),"data-testid":`calendars-visible-${l.id}`}),r(x,{type:`color`,className:`mt-0.5 h-6 w-6 shrink-0 cursor-pointer rounded border border-border bg-transparent p-0`,value:l.color,disabled:o,onChange:e=>i(l.id,e.target.value.toUpperCase()),"aria-label":c(`systemPage.calendars.colourFor`,`Colour for {{name}}`,{name:t.name}),"data-testid":`calendars-color-${l.id}`})]}):null,e(`div`,{className:`min-w-0 flex-1`,children:[r(`div`,{className:`truncate text-sm font-medium ${l?.visible===!0&&!u?`text-foreground`:`text-foreground-subtle`}`,children:t.name}),e(`div`,{className:`truncate text-[11px] text-foreground-subtle`,children:[t.providerName,u?` · ${c(`systemPage.calendars.switchedOff`)}`:``,l!==null&&!l.enabled?` · ${c(`systemPage.calendars.unavailableAtSource`)}`:``]})]}),t.instance===null?null:r(O,{row:t.instance,pinning:0,onChanged:a})]},t.key)})})]})}function q({ev:t,color:n,compact:i,onSelect:a}){return r(C,{variant:`unstyled`,type:`button`,className:i?`block w-full truncate rounded px-1 py-0.5 text-left text-[10px] leading-tight text-white hover:brightness-110`:`block w-full rounded-md px-2 py-1.5 text-left text-xs text-white hover:brightness-110`,style:{backgroundColor:n},title:t.title,onClick:()=>a(t),"data-testid":`calendars-event-${t.id}`,children:i?t.title:e(s,{children:[r(`div`,{className:`font-medium`,children:t.title}),r(`div`,{className:`opacity-90`,children:B(t)})]})})}function ae({anchor:t,events:n,colorById:i,today:a,onSelectEvent:o}){let{t:s}=E(),{startMs:c,endMs:l}=F(t,`month`),u=[];for(let e=new Date(c);e.getTime()<l;e=N(e,1))u.push(e);let d=t.getMonth();return e(`div`,{"data-testid":`calendars-month`,children:[r(`div`,{className:`mb-1 grid grid-cols-7 gap-px`,children:j.map(e=>r(`div`,{className:`px-1 py-1 text-center text-[11px] font-medium text-foreground-subtle`,children:e},e))}),r(`div`,{className:`grid grid-cols-7 gap-px overflow-hidden rounded-lg border border-border bg-border`,children:u.map(t=>{let c=M(t).getTime(),l=W(n,c),u=t.getMonth()!==d,f=G(t,a);return e(`div`,{className:`min-h-[5.5rem] bg-background p-1 ${u?`opacity-45`:``}`,children:[r(`div`,{className:f?`mb-1 inline-flex h-5 w-5 items-center justify-center rounded-full bg-primary text-[11px] font-semibold text-primary-foreground`:`mb-1 text-[11px] font-medium text-foreground-subtle`,children:t.getDate()}),e(`div`,{className:`space-y-0.5`,children:[l.slice(0,3).map(e=>r(q,{ev:e,color:i.get(e.calendarId)??`#64748B`,compact:!0,onSelect:o},e.id)),l.length>3?r(`div`,{className:`text-[10px] text-foreground-subtle`,children:s(`common.moreCount`,{count:l.length-3})}):null]})]},c)})})]})}function oe({anchor:t,events:n,colorById:i,today:a,onSelectEvent:o}){let s=P(t);return r(`div`,{className:`grid grid-cols-1 gap-2 sm:grid-cols-7 sm:gap-px sm:overflow-hidden sm:rounded-lg sm:border sm:border-border sm:bg-border`,"data-testid":`calendars-week`,children:Array.from({length:7},(e,t)=>N(s,t)).map(t=>{let s=M(t).getTime(),c=W(n,s);return e(`div`,{className:`min-h-[8rem] bg-background p-2 sm:min-h-[12rem]`,children:[r(`div`,{className:G(t,a)?`mb-2 text-xs font-semibold text-primary`:`mb-2 text-xs font-medium text-foreground-subtle`,children:t.toLocaleDateString(void 0,{weekday:`short`,day:`numeric`})}),r(`div`,{className:`space-y-1`,children:c.length===0?r(`p`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):c.map(e=>r(q,{ev:e,color:i.get(e.calendarId)??`#64748B`,onSelect:o},e.id))})]},s)})})}function se({anchor:t,events:n,colorById:i,calName:a,onSelectEvent:o}){let{t:s}=E(),c=W(n,M(t).getTime());return c.length===0?r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-day-empty`,children:s(`systemPage.calendars.noEventsOnThisDay`,`No events on this day.`)}):r(`ul`,{className:`divide-y divide-border rounded-lg border border-border`,"data-testid":`calendars-day`,children:c.map(t=>r(`li`,{children:e(C,{variant:`unstyled`,type:`button`,className:`flex w-full items-start gap-3 px-3 py-3 text-left hover:bg-surface`,onClick:()=>o(t),"data-testid":`calendars-event-${t.id}`,children:[r(`span`,{className:`mt-1 h-2.5 w-2.5 shrink-0 rounded-full`,style:{backgroundColor:i.get(t.calendarId)??`#64748B`}}),e(`div`,{className:`min-w-0`,children:[r(`div`,{className:`font-medium text-sm text-foreground`,children:t.title}),e(`div`,{className:`text-xs text-foreground-subtle`,children:[B(t),` · `,a.get(t.calendarId)??t.calendarId]}),t.location!==void 0&&t.location.length>0?r(`div`,{className:`mt-0.5 text-xs text-foreground-subtle`,children:t.location}):null]})]})},t.id))})}function J(){let{t:a}=E(),s=g(),u=b({}),d=ee(),p=o(),m=D(`calendar-source`),[h,_]=i(`month`),[v,x]=i(()=>M(new Date)),[S,w]=i(null),T=t(()=>M(new Date),[]),O=s.isSuccess,j=u.isSuccess&&u.data!==void 0?u.data:void 0,N=t(()=>!O||s.data===void 0?[]:s.data.map(e=>R(e,j)),[O,s.data,j]),P=t(()=>N.filter(e=>e.visible),[N]),B=t(()=>P.map(e=>e.id),[P]),V=t(()=>F(v,h),[v,h]),H=y({startMs:V.startMs,endMs:V.endMs,calendarIds:[...B]},{enabled:O&&B.length>0}),W=H.data??[],G=t(()=>{let e=new Map;for(let t of N)e.set(t.id,t.color);return e},[N]),q=t(()=>{let e=new Map;for(let t of N)e.set(t.id,t.name);return e},[N]),J=t(()=>A(N,k(m.holders,m.displayNames),z),[N,m.holders,m.displayNames]),Y=n(()=>void p.invalidateQueries({queryKey:[[`calendars`]]}),[p]),X=n((e,t)=>{d.mutateAsync({calendarId:e,visible:t}).then(()=>u.refetch())},[u,d]),Z=n((e,t)=>{/^#[0-9A-Fa-f]{6}$/.test(t)&&d.mutateAsync({calendarId:e,color:t}).then(()=>u.refetch())},[u,d]),ce=n(()=>x(M(new Date)),[]),le=n(()=>x(e=>L(e,h,-1)),[h]),ue=n(()=>x(e=>L(e,h,1)),[h]),Q=`inline-flex h-8 w-8 items-center justify-center rounded-lg border border-border bg-surface text-foreground hover:bg-primary/5 disabled:opacity-50`,$;return $=s.isPending||m.state===`pending`?r(`p`,{className:`text-sm text-foreground-subtle`,children:a(`systemPage.calendars.loadingCalendars`,`Loading calendars…`)}):s.isError?e(`p`,{className:`text-sm text-destructive`,children:[a(`systemPage.calendars.couldNotListCalendars`,`Could not list calendars:`),` `,s.error.message]}):m.state===`error`&&J.length===0?e(`p`,{className:`text-sm text-danger`,children:[a(`systemPage.calendars.couldNotListCalendars`,`Could not list calendars:`),` `,m.error]}):J.length===0?r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-empty-sources`,children:r(ne,{i18nKey:`systemPage.calendars.emptySources`,components:{link:r(te,{to:`/system/integrations?tab=calendars`,className:`text-accent underline-offset-2 hover:underline`})}})}):B.length===0?e(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start`,children:[r(K,{rows:J,onToggleVisible:X,onColorChange:Z,onSwitched:Y,busy:d.isPending}),r(`p`,{className:`text-sm text-foreground-subtle`,"data-testid":`calendars-empty-hidden`,children:N.length===0?a(`systemPage.calendars.allSwitchedOff`):a(`systemPage.calendars.allCalendarsAreHiddenTurn`,`All calendars are hidden. Turn one on in the legend to see events.`)})]}):e(`div`,{className:`flex flex-col gap-4 lg:flex-row lg:items-start`,children:[r(K,{rows:J,onToggleVisible:X,onColorChange:Z,onSwitched:Y,busy:d.isPending}),e(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(ie,{mode:h,onChange:_}),e(`div`,{className:`flex items-center gap-1`,children:[r(C,{variant:`unstyled`,type:`button`,className:Q,onClick:le,"aria-label":a(`systemPage.calendars.previous`,`Previous`),"data-testid":`calendars-prev`,children:r(l,{className:`h-4 w-4`})}),r(C,{variant:`unstyled`,type:`button`,className:`inline-flex items-center rounded-lg border border-border bg-surface px-2.5 py-1.5 text-xs font-medium text-foreground hover:bg-primary/5`,onClick:ce,"data-testid":`calendars-today`,children:a(`systemPage.calendars.today`,`Today`)}),r(C,{variant:`unstyled`,type:`button`,className:Q,onClick:ue,"aria-label":a(`common.next`,`Next`),"data-testid":`calendars-next`,children:r(c,{className:`h-4 w-4`})})]}),r(`span`,{className:`text-sm font-medium text-foreground`,"data-testid":`calendars-period`,children:I(v,h)})]}),H.isPending?r(`p`,{className:`text-sm text-foreground-subtle`,children:a(`systemPage.calendars.loadingEvents`,`Loading events…`)}):H.isError?e(`p`,{className:`text-sm text-destructive`,children:[a(`systemPage.calendars.couldNotListEvents`,`Could not list events:`),` `,H.error.message]}):h===`month`?r(ae,{anchor:v,events:W,colorById:G,today:T,onSelectEvent:w}):h===`week`?r(oe,{anchor:v,events:W,colorById:G,today:T,onSelectEvent:w}):r(se,{anchor:v,events:W,colorById:G,calName:q,onSelectEvent:w})]})]}),e(re,{icon:f,title:a(`systemPage.calendars.calendars`,`Calendars`),subtitle:a(`systemPage.calendars.calendarsFromConnectedSourcesUsed`,`Calendars from connected sources. Used by Calendar events notification rules.`),children:[m.state===`error`&&J.length>0?e(`p`,{className:`mb-3 text-sm text-warning`,role:`status`,"data-testid":`calendars-switches-unavailable`,children:[a(`systemPage.calendars.switchesUnavailable`,`The calendar switches could not be loaded, so they are hidden. Calendars switched off are not listed until they load.`),` `,m.error]}):null,$,S===null?null:r(U,{ev:S,calendarName:q.get(S.calendarId)??S.calendarId,color:G.get(S.calendarId)??`#64748B`,onClose:()=>w(null)})]})}export{J as CalendarsPage,J as default};