@camstack/addon-admin-ui 1.2.427 → 1.2.429

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 (167) hide show
  1. package/dist/assets/{AddonAssetIcon-BgXfFdy2.js → AddonAssetIcon-DR35yt0E.js} +1 -1
  2. package/dist/assets/Addons-gkGgGpTC.js +4 -0
  3. package/dist/assets/{AdminPage-C0Zxs_ot.js → AdminPage-DAO24U0w.js} +1 -1
  4. package/dist/assets/AdminSectionedPage-B-qoE6ra.js +1 -0
  5. package/dist/assets/AiProfiles-BXcreqZP.js +3 -0
  6. package/dist/assets/BrokerForm-B3xs9aBj.js +1 -0
  7. package/dist/assets/Build-DeMAJfjN.js +40 -0
  8. package/dist/assets/Calendars-VPH-vy-o.js +1 -0
  9. package/dist/assets/Cluster-B-k0M79z.js +1 -0
  10. package/dist/assets/ClusterStepModel-DaAc_6nI.js +1 -0
  11. package/dist/assets/CompositionEditor-BrtLjoSu.js +1 -0
  12. package/dist/assets/{CompositionEditorPage-CDyW_Buu.js → CompositionEditorPage-D51jS9td.js} +1 -1
  13. package/dist/assets/Data-IfJuKcwc.js +2 -0
  14. package/dist/assets/DeviceDetail-D1qU_p1k.js +2 -0
  15. package/dist/assets/DeviceDoActionFields-B62Nv4K7.js +1 -0
  16. package/dist/assets/Devices-Cf5Exjsk.js +1 -0
  17. package/dist/assets/EmbedPlayerPage-CnEcSJ8D.js +1 -0
  18. package/dist/assets/Identity-DNE80jdX.js +1 -0
  19. package/dist/assets/IntegrationDetail-LKbiJFU3.js +1 -0
  20. package/dist/assets/IntegrationHub-DdjWEObX.js +1 -0
  21. package/dist/assets/Integrations-CU7Ll9U_.js +1 -0
  22. package/dist/assets/Integrations-uZB2ozhn.js +1 -0
  23. package/dist/assets/Library-DSuCaXt6.js +1 -0
  24. package/dist/assets/Locations-BeaznsZS.js +3 -0
  25. package/dist/assets/Logs-cm-1R2Z4.js +1 -0
  26. package/dist/assets/MaskShapeCanvas-CM9D4FOf.js +1 -0
  27. package/dist/assets/MotionZonesSettings-DqS8ndiK.js +1 -0
  28. package/dist/assets/MyAccess-Dxb11B6h.js +2 -0
  29. package/dist/assets/Network-BCDUHSB0.js +1 -0
  30. package/dist/assets/NodeAddonsSettingsPanel-BMat4ckt.js +1 -0
  31. package/dist/assets/Notifications-EPQiEZ1t.js +1 -0
  32. package/dist/assets/PrivacyMaskSettings-Bis0PO01.js +1 -0
  33. package/dist/assets/Recordings-BCeoXxL4.js +1 -0
  34. package/dist/assets/ScanNetworkModal-dHWFmbFe.js +1 -0
  35. package/dist/assets/SceneMonitorEditor-SFMMIopn.js +1 -0
  36. package/dist/assets/SessionsList-BRTwG3uv.js +2 -0
  37. package/dist/assets/{Showroom-Cw-6ZdvC.js → Showroom-Er-hes9K.js} +1 -1
  38. package/dist/assets/System-BDXxfgsq.js +1 -0
  39. package/dist/assets/{Terminal-D-YHBrHK.js → Terminal-B70jnm8e.js} +5 -5
  40. package/dist/assets/{Viewer-BmXiweP2.js → Viewer-BsGL5Dfa.js} +1 -1
  41. package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C7iEnSHU.js +1 -0
  42. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEHpkaJP.js +1 -0
  43. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DdJYWyu3.js +1 -0
  44. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-BsvPG3BX.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom__loadShare__.js-DPkvGqVU.js} +1 -1
  45. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-DtoGixA1.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_dom_mf_1_client__loadShare__.js-Cb2QlpvS.js} +1 -1
  46. package/dist/assets/{_virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-PmiLsYEK.js → _virtual_mf___mfe_internal__admin_ui_host__loadShare__react_mf_2_konva__loadShare__.js-Cyj0Xie_.js} +4 -4
  47. package/dist/assets/{addon-icons-context-CvwUgMRr.js → addon-icons-context--6Hi3qRW.js} +1 -1
  48. package/dist/assets/{archive-Bwv0mNo-.js → archive-DtcjevJM.js} +1 -1
  49. package/dist/assets/{authed-media-0TPg9TTZ.js → authed-media-LCmlAEZ5.js} +1 -1
  50. package/dist/assets/{bell-off-D2KzCQW2.js → bell-off-eQBpwamg.js} +1 -1
  51. package/dist/assets/board-model-wzCmdEKJ.js +1 -0
  52. package/dist/assets/{boxes-BXQUMgws.js → boxes-DikDfAoo.js} +1 -1
  53. package/dist/assets/circle-slash-YVgGJTpJ.js +1 -0
  54. package/dist/assets/client-DYbvGOid.js +358 -0
  55. package/dist/assets/{cloud-upload-BsULjxPu.js → cloud-upload-DI9XunFf.js} +1 -1
  56. package/dist/assets/crop-CxZbpOyK.js +1 -0
  57. package/dist/assets/{device-integration-icon-CCoHGEQZ.js → device-integration-icon-D2lWVDM2.js} +1 -1
  58. package/dist/assets/device-picker-model-C4w1vbly.js +1 -0
  59. package/dist/assets/dist-CPO0KWoy.js +358 -0
  60. package/dist/assets/dist-ChQzskeX.js +1 -0
  61. package/dist/assets/{eraser-DB7_WMyf.js → eraser-Dl5ROV0l.js} +1 -1
  62. package/dist/assets/{file-up-DuqaeMYR.js → file-up-WS3s_T9x.js} +1 -1
  63. package/dist/assets/{hard-drive-download-CKj8xKOz.js → hard-drive-download-B1ard6ym.js} +1 -1
  64. package/dist/assets/{history-V8RQKQAb.js → history-BMhP0SFG.js} +1 -1
  65. package/dist/assets/{hostInit-CdxLRG1l.js → hostInit-FCvre9AW.js} +1 -1
  66. package/dist/assets/i18n-Vb3uBp7P.js +1 -0
  67. package/dist/assets/{icons-CEMmjIEL.js → icons-DocdgFuy.js} +1 -1
  68. package/dist/assets/index-DKqvG7BE.css +2 -0
  69. package/dist/assets/index-DvOECbab.js +4 -0
  70. package/dist/assets/{key-Bj5-ZBrb.js → key-B1M6i1mf.js} +1 -1
  71. package/dist/assets/{key-round-B2I1YisX.js → key-round-yCDTbIQb.js} +1 -1
  72. package/dist/assets/{layers-BARFkXZ5.js → layers-c960YTPf.js} +1 -1
  73. package/dist/assets/linked-devices-model-CB7qgVjI.js +1 -0
  74. package/dist/assets/{list-ordered-9lF0Gp3K.js → list-ordered-C7hEwAd1.js} +1 -1
  75. package/dist/assets/location-owned-usage-D28vwYJT.js +1 -0
  76. package/dist/assets/{log-in-CjtrIfG3.js → log-in-DFfxcqYz.js} +1 -1
  77. package/dist/assets/{memory-stick-B26_SbtH.js → memory-stick-BBfIGrWx.js} +1 -1
  78. package/dist/assets/{message-square-plus-COMrVZEZ.js → message-square-plus-D8ZUT6rz.js} +1 -1
  79. package/dist/assets/{mf-entry-bootstrap-0-ec37d41a.js → mf-entry-bootstrap-0-3035e647.js} +2 -2
  80. package/dist/assets/{mic-off-DBIqFVjg.js → mic-off-w2mFOBi3.js} +1 -1
  81. package/dist/assets/{monitor-off-CTQMySOs.js → monitor-off-DPi_gm_c.js} +1 -1
  82. package/dist/assets/{monitor-smartphone-iBd_3nPv.js → monitor-smartphone-9Ife1Trw.js} +1 -1
  83. package/dist/assets/mount-C4w1vbly.js +1 -0
  84. package/dist/assets/notification-schedule-field-BuLfSYLZ.js +1 -0
  85. package/dist/assets/{octagon-alert-DMjnTemh.js → octagon-alert-C-jH7VH_.js} +1 -1
  86. package/dist/assets/player-overlays-D0U2dNvn.js +1 -0
  87. package/dist/assets/{recycle-BCVF0r6Y.js → recycle-Bbki65G2.js} +1 -1
  88. package/dist/assets/remoteEntry-DYVoozgD.js +1 -0
  89. package/dist/assets/{scan-eye-DRXP3PgB.js → scan-eye-AfIM_Dlr.js} +1 -1
  90. package/dist/assets/{scissors-DUFtPb9T.js → scissors-CnL6g0BO.js} +1 -1
  91. package/dist/assets/{search-x-B3nve3vV.js → search-x-eqJd3G8u.js} +1 -1
  92. package/dist/assets/{send-P2KlabIu.js → send-B72RQ9UL.js} +1 -1
  93. package/dist/assets/{settings-2-reEhyiKz.js → settings-2-CXZ6DVRg.js} +1 -1
  94. package/dist/assets/{speaker-DSNMuvS8.js → speaker-CcCWWecW.js} +1 -1
  95. package/dist/assets/src-CGxdJN_f.js +67 -0
  96. package/dist/assets/{timer-reset-CsRTbSzh.js → timer-reset-B9Lihcw9.js} +1 -1
  97. package/dist/assets/{ungroup-BLeVa8__.js → ungroup-D753owNE.js} +1 -1
  98. package/dist/assets/{unlink-DeNvF8r-.js → unlink-DzoLNfsq.js} +1 -1
  99. package/dist/assets/{usb-CFseVsQJ.js → usb-CuSU-_EY.js} +1 -1
  100. package/dist/assets/{use-scenes-feed-C8frh3hQ.js → use-scenes-feed-CZjJNxfD.js} +1 -1
  101. package/dist/assets/{use-stationary-objects-DNayAuMq.js → use-stationary-objects-BoGqWyLV.js} +1 -1
  102. package/dist/assets/useEventInvalidation-C4w1vbly.js +1 -0
  103. package/dist/assets/useNodeUrlSelection-BA6CgjTU.js +1 -0
  104. package/dist/assets/useTranslation-D3Is_4B6.js +1 -0
  105. package/dist/assets/user-round-CMg3Ndlt.js +1 -0
  106. package/dist/assets/{user-x-CpaZ5HO0.js → user-x-PK8sSsso.js} +1 -1
  107. package/dist/assets/{video--MLJeLNU.js → video-BBtESt54.js} +1 -1
  108. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-1Do_dc2z.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BKfTL-9e.js} +2 -2
  109. package/dist/index.html +12 -11
  110. package/dist/server/addon.js +199 -6
  111. package/package.json +1 -1
  112. package/dist/assets/Addons-BTWw53aT.js +0 -4
  113. package/dist/assets/AdminSectionedPage-D2kYQhvu.js +0 -1
  114. package/dist/assets/AiProfiles-Ca7zuVMp.js +0 -3
  115. package/dist/assets/BrokerForm-6-BwPs-g.js +0 -1
  116. package/dist/assets/Build-BsduavcU.js +0 -40
  117. package/dist/assets/Calendars-DVTk_2iT.js +0 -1
  118. package/dist/assets/Cluster-BPJ4maiI.js +0 -1
  119. package/dist/assets/ClusterStepModel-CjuZ-oml.js +0 -1
  120. package/dist/assets/CompositionEditor-DJcmWU2U.js +0 -1
  121. package/dist/assets/Data-CLLvqZwG.js +0 -1
  122. package/dist/assets/DeviceDetail-BKw1gufS.js +0 -2
  123. package/dist/assets/DeviceDoActionFields-R-ZYIdMv.js +0 -1
  124. package/dist/assets/Devices-CHeb_BTk.js +0 -1
  125. package/dist/assets/EmbedPlayerPage-B4y0Q0wO.js +0 -1
  126. package/dist/assets/Identity-NOlTR-3q.js +0 -1
  127. package/dist/assets/IntegrationDetail-CcZkPlbN.js +0 -1
  128. package/dist/assets/IntegrationHub-CuW7-WRy.js +0 -1
  129. package/dist/assets/Integrations-ACdx4iPR.js +0 -1
  130. package/dist/assets/Integrations-DjnhmLye.js +0 -1
  131. package/dist/assets/Library-B3iyoKdK.js +0 -1
  132. package/dist/assets/Locations-Cs1VwmXB.js +0 -3
  133. package/dist/assets/Logs-BMc6WXCH.js +0 -1
  134. package/dist/assets/MaskShapeCanvas-Dcpby34M.js +0 -1
  135. package/dist/assets/MotionZonesSettings-DjvGw8j4.js +0 -1
  136. package/dist/assets/MyAccess-BfUfTXrv.js +0 -2
  137. package/dist/assets/Network-F2lAIcbT.js +0 -1
  138. package/dist/assets/NodeAddonsSettingsPanel-D3ux_JIo.js +0 -1
  139. package/dist/assets/Notifications-Cp3qo_EC.js +0 -1
  140. package/dist/assets/PrivacyMaskSettings-IK6ytyM8.js +0 -1
  141. package/dist/assets/Recordings-D91q74Ga.js +0 -1
  142. package/dist/assets/ScanNetworkModal-DjU-xM4X.js +0 -1
  143. package/dist/assets/SceneMonitorEditor-V_pHxg3U.js +0 -1
  144. package/dist/assets/SessionsList-DQ7kj8fX.js +0 -2
  145. package/dist/assets/System-DLLa4weE.js +0 -1
  146. package/dist/assets/_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-wt87pCBz.js +0 -1
  147. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js +0 -1
  148. package/dist/assets/_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_trpc_mf_1_react_mf_2_query__loadShare__.js-DX7sYWrs.js +0 -1
  149. package/dist/assets/board-model-Bmts6hrg.js +0 -1
  150. package/dist/assets/circle-slash-DpUtlEnB.js +0 -1
  151. package/dist/assets/client-CjyKfSu1.js +0 -358
  152. package/dist/assets/crop-BtQBZ9jm.js +0 -1
  153. package/dist/assets/device-picker-model-1Z6p3UkP.js +0 -1
  154. package/dist/assets/dist-DQtBl_2T.js +0 -1
  155. package/dist/assets/dist-DWoekMi0.js +0 -358
  156. package/dist/assets/index-D66JvELZ.js +0 -4
  157. package/dist/assets/index-dmZ34NAY.css +0 -2
  158. package/dist/assets/location-owned-usage-CNXQ-Obv.js +0 -1
  159. package/dist/assets/mount-1Z6p3UkP.js +0 -1
  160. package/dist/assets/notification-schedule-field-D8dd67dT.js +0 -1
  161. package/dist/assets/player-overlays-DWMIy1MJ.js +0 -1
  162. package/dist/assets/remoteEntry-RwWzzVu_.js +0 -1
  163. package/dist/assets/src-BLkInT8U.js +0 -67
  164. package/dist/assets/useEventInvalidation-1Z6p3UkP.js +0 -1
  165. package/dist/assets/useNodeUrlSelection-BsLRiUy8.js +0 -1
  166. package/dist/assets/useTranslation-Bc5yH9V9.js +0 -1
  167. package/dist/assets/user-round-BB0VDRnJ.js +0 -1
@@ -5388,7 +5388,7 @@ var ZodIssueCode = {
5388
5388
  var ZodFirstPartyTypeKind;
5389
5389
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5390
5390
  //#endregion
5391
- //#region ../types/dist/sleep-DAX0-2v9.mjs
5391
+ //#region ../types/dist/sleep-DRqxtc0C.mjs
5392
5392
  /**
5393
5393
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5394
5394
  * window to float samples (D455).
@@ -8174,8 +8174,12 @@ method(object({ deviceId: number() }), array(StreamSourceEntrySchema)), method(o
8174
8174
  kind: "mutation",
8175
8175
  auth: "admin"
8176
8176
  }), method(object({ deviceId: number() }), unknown().nullable()), method(object({ deviceId: number() }), RawStateResultSchema.nullable(), { auth: "protected" });
8177
+ object({
8178
+ code: string().regex(/^[a-z][a-z0-9-]*(\.[a-z0-9-]+)+$/),
8179
+ params: record(string(), union([string(), number()])).optional()
8180
+ });
8177
8181
  //#endregion
8178
- //#region ../types/dist/err-msg-DX6i_MY4.mjs
8182
+ //#region ../types/dist/err-msg-DLerKiVO.mjs
8179
8183
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
8180
8184
  DeviceType["Camera"] = "camera";
8181
8185
  DeviceType["Hub"] = "hub";
@@ -8425,6 +8429,22 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8425
8429
  DeviceRole["Nightvision"] = "nightvision";
8426
8430
  DeviceRole["PrivacyMask"] = "privacy-mask";
8427
8431
  DeviceRole["Doorbell"] = "doorbell";
8432
+ /** Interior blind / shade / roller blind. HA `device_class: blind|shade`. */
8433
+ DeviceRole["CoverBlind"] = "cover-blind";
8434
+ /** Exterior roller shutter. HA `device_class: shutter`; Homematic BROLL. */
8435
+ DeviceRole["CoverShutter"] = "cover-shutter";
8436
+ /** Exterior awning. HA `device_class: awning`. */
8437
+ DeviceRole["CoverAwning"] = "cover-awning";
8438
+ /** Curtain / drape. HA `device_class: curtain`. */
8439
+ DeviceRole["CoverCurtain"] = "cover-curtain";
8440
+ /** Garage door. HA `device_class: garage`. A security actuator: exports gate it. */
8441
+ DeviceRole["CoverGarage"] = "cover-garage";
8442
+ /** Gate. HA `device_class: gate`. A security actuator: exports gate it. */
8443
+ DeviceRole["CoverGate"] = "cover-gate";
8444
+ /** Door. HA `device_class: door`. A security actuator: exports gate it. */
8445
+ DeviceRole["CoverDoor"] = "cover-door";
8446
+ /** Window. HA `device_class: window`. */
8447
+ DeviceRole["CoverWindow"] = "cover-window";
8428
8448
  /** Virtual HA toggle (input_boolean.*) — distinguishable from a
8429
8449
  * real Switch device for UI rendering / export adapters. */
8430
8450
  DeviceRole["BinaryHelper"] = "binary-helper";
@@ -8495,7 +8515,7 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
8495
8515
  return DeviceRole;
8496
8516
  }({});
8497
8517
  //#endregion
8498
- //#region ../types/dist/composition-C-WpVYTX.mjs
8518
+ //#region ../types/dist/composition-EQ9Ok0Ee.mjs
8499
8519
  /**
8500
8520
  * The ffmpeg build every CamStack node downloads, per platform and arch.
8501
8521
  *
@@ -12172,6 +12192,8 @@ var ConvertResultSchema = object({
12172
12192
  })).readonly()
12173
12193
  });
12174
12194
  _enum(["new-session", "step-up"]);
12195
+ /** The languages the hub's app landing pages are written in (D858). */
12196
+ var AppPageLangSchema = _enum(["en", "it"]);
12175
12197
  /** How a native app starts one login method (D858), as `auth.listLoginMethods` reports it. */
12176
12198
  var AppLoginPathSchema = discriminatedUnion("kind", [object({ kind: literal("native") }), object({
12177
12199
  kind: literal("browser"),
@@ -12668,7 +12690,9 @@ var ConfigTabDeclarationSchema = object({
12668
12690
  var ConfigSectionWithValuesSchema = object({
12669
12691
  id: string(),
12670
12692
  title: string(),
12693
+ titleKey: string().optional(),
12671
12694
  description: string().optional(),
12695
+ descriptionKey: string().optional(),
12672
12696
  style: _enum(["card", "accordion"]).optional(),
12673
12697
  defaultCollapsed: boolean().optional(),
12674
12698
  columns: union([
@@ -15894,6 +15918,9 @@ method(object({
15894
15918
  }), method(object({ refs: RefListSchema }), KeychainResolveResultSchema, { auth: "admin" }), method(object({ refs: RefListSchema }), object({ deleted: number().int() }), {
15895
15919
  kind: "mutation",
15896
15920
  auth: "admin"
15921
+ }), method(object({ deviceId: number().int() }), object({ refs: array(string()).readonly() }), {
15922
+ kind: "mutation",
15923
+ auth: "admin"
15897
15924
  }), method(object({}), array(KeychainSecretMetaSchema).readonly(), { auth: "admin" }), method(object({}), KeychainStateSchema, { auth: "admin" });
15898
15925
  /**
15899
15926
  * device-history — the ONE mechanism for numeric history (D850).
@@ -37297,6 +37324,38 @@ var DeviceRegisterPayloadSchema = object({
37297
37324
  * omits it and the keyword backstop applies. */
37298
37325
  secretConfigPaths: array(string()).optional()
37299
37326
  });
37327
+ /** One deleted device, kept by device-manager so an addon that missed the
37328
+ * deletion can still learn of it (D865). Written by the delete path ONLY. */
37329
+ var DeviceTombstoneSchema = object({
37330
+ deviceId: number().int().positive(),
37331
+ /** Epoch ms the device was deleted. */
37332
+ deletedAt: number(),
37333
+ /** The addon that owned the device when it was deleted. */
37334
+ providerAddonId: string()
37335
+ });
37336
+ /** Data held for one device that device-manager no longer knows. */
37337
+ var OrphanDeviceDataSchema = object({
37338
+ deviceId: number().int().positive(),
37339
+ /** Rows/files per store (`<addonId>:<store>`). */
37340
+ stores: record(string(), number().int().nonnegative())
37341
+ });
37342
+ var CleanupDeletedDevicesResultSchema = object({
37343
+ /**
37344
+ * `skipped` — the absence check could not be trusted (a device-list read
37345
+ * failed or the two reads disagreed); nothing was listed or deleted.
37346
+ * `dry-run` — `devices` is what a confirmed run would delete.
37347
+ * `cleaned` — `devices` is what was deleted.
37348
+ */
37349
+ status: _enum([
37350
+ "skipped",
37351
+ "dry-run",
37352
+ "cleaned"
37353
+ ]),
37354
+ reason: string().nullable(),
37355
+ devices: array(OrphanDeviceDataSchema),
37356
+ /** Implementers that could not be asked (their stores are not in `devices`). */
37357
+ unreachable: array(string())
37358
+ });
37300
37359
  var DeviceRemovePayloadSchema = object({ deviceId: number() });
37301
37360
  var DevicePersistConfigPayloadSchema = object({
37302
37361
  deviceId: number(),
@@ -37535,6 +37594,9 @@ method(object({
37535
37594
  }), method(object({ deviceId: number() }), object({ success: literal(true) }), {
37536
37595
  kind: "mutation",
37537
37596
  auth: "admin"
37597
+ }), method(object({ sinceMs: number() }), array(DeviceTombstoneSchema).readonly(), { auth: "admin" }), method(object({ confirm: boolean() }), CleanupDeletedDevicesResultSchema, {
37598
+ kind: "mutation",
37599
+ auth: "admin"
37538
37600
  }), method(object({ integrationId: string() }), object({ removed: number() }), {
37539
37601
  kind: "mutation",
37540
37602
  auth: "admin"
@@ -37997,6 +38059,72 @@ method(object({
37997
38059
  auth: "admin"
37998
38060
  });
37999
38061
  /**
38062
+ * `device-removal-hook` — the reliable way an addon learns a device was DELETED,
38063
+ * so it can delete what it keeps for that device (D865).
38064
+ *
38065
+ * ## Why an event was not enough
38066
+ *
38067
+ * `DeviceUnregistered` is telemetry and may be dropped (D8, D11). An addon that
38068
+ * hung its per-device clean-up on it left durable garbage whenever the event was
38069
+ * lost, the addon was down, or it was restarting at that moment — footage,
38070
+ * analytics rows and settings of device 4483 outlived the device. Loss of this
38071
+ * signal corrupts durable state, so it travels by RPC with a recorded fact
38072
+ * behind it (D8: "if loss would corrupt durable state, use RPC plus a reconcile").
38073
+ *
38074
+ * ## The three pieces
38075
+ *
38076
+ * 1. device-manager records a TOMBSTONE per deleted device
38077
+ * (`deviceManager.listDeletedSince`). The tombstone is written by the delete
38078
+ * path only — a device that is unregistered, offline or whose provider is
38079
+ * restarting is NOT deleted and gets none.
38080
+ * 2. After a delete, device-manager calls `onDeviceRemoved` on EVERY provider of
38081
+ * this collection, one by one, with bounded retries, logged.
38082
+ * 3. An implementer that was down asks `deviceManager.listDeletedSince` at start
38083
+ * (and periodically) and runs its own `onDeviceRemoved` for each tombstone it
38084
+ * may have missed. Reconcile is driven by tombstones, never by "the device is
38085
+ * not in the current list": a failed or partial list read must not destroy data.
38086
+ *
38087
+ * ## Contract for an implementer
38088
+ *
38089
+ * - **Idempotent.** It is called again by a retry, by a reconcile and by the
38090
+ * admin cleanup of data that predates tombstones. A device with nothing left
38091
+ * answers zero counts.
38092
+ * - **One key per store** in `counts`, deleted rows/files per store, so the log
38093
+ * line and the admin dry run can say where the data was.
38094
+ * - **Training datasets are NOT device data** and are never deleted by a hook.
38095
+ * - **Per-device SETTINGS are not hooked.** Configuration lives in the standard
38096
+ * per-device store (`ctx.settings.*DeviceStore`), which device-manager clears
38097
+ * for every addon centrally at delete time. This hook is for device DATA
38098
+ * that is not settings: footage, event media, analytics rows, history.
38099
+ * - A provider that cannot tell is allowed to throw; the caller retries it.
38100
+ *
38101
+ * `listDeviceData` is the read side of the admin "Clean data of deleted devices"
38102
+ * action: which device ids this addon holds data for, and how much per store. It
38103
+ * never deletes. device-manager decides which of those ids are absent from the
38104
+ * fleet, from TWO consistent reads of the device list (D49).
38105
+ */
38106
+ /** What a hook is told about the deletion. */
38107
+ var DeviceRemovedInputSchema = object({
38108
+ deviceId: number().int().positive(),
38109
+ /** Epoch ms the device was deleted (the tombstone's `deletedAt`). */
38110
+ deletedAt: number(),
38111
+ /** The addon that owned the device, as device-manager last knew it. */
38112
+ providerAddonId: string()
38113
+ });
38114
+ /** Rows/files/refs deleted, per store this implementer owns. */
38115
+ var DeviceRemovedResultSchema = object({ counts: record(string(), number().int().nonnegative()) });
38116
+ /** One (store, device) pair an implementer holds data for. */
38117
+ var DeviceDataEntrySchema = object({
38118
+ store: string(),
38119
+ deviceId: number().int().positive(),
38120
+ /** Rows (or files) held for the device in the store. */
38121
+ count: number().int().nonnegative()
38122
+ });
38123
+ method(DeviceRemovedInputSchema, DeviceRemovedResultSchema, {
38124
+ kind: "mutation",
38125
+ auth: "admin"
38126
+ }), method(_void(), array(DeviceDataEntrySchema).readonly(), { auth: "admin" });
38127
+ /**
38000
38128
  * `failure-contribution` — the capability an addon reports its OWN losses
38001
38129
  * through, per camera, with the denominator attached. It stores nothing.
38002
38130
  *
@@ -49557,7 +49685,9 @@ var SsoBridgeClaimsSchema = object({
49557
49685
  codeChallenge: string(),
49558
49686
  state: string(),
49559
49687
  purpose: _enum(["new-session", "step-up"]),
49560
- redirect: string()
49688
+ redirect: string(),
49689
+ /** The page language the app asked for (D858); the confirm page speaks it. */
49690
+ lang: _enum(["en", "it"]).optional()
49561
49691
  }).optional()
49562
49692
  });
49563
49693
  method(object({
@@ -58921,6 +59051,21 @@ DeviceType.Switch, DeviceType.Siren, DeviceType.Light, method(object({
58921
59051
  on: boolean(),
58922
59052
  lastChangedAt: number()
58923
59053
  });
59054
+ /** C0 controls, DEL and the C1 range: none of them belongs in a name. */
59055
+ function hasControlCharacter(value) {
59056
+ for (const char of value) {
59057
+ const code = char.codePointAt(0) ?? 0;
59058
+ if (code <= 31 || code >= 127 && code <= 159) return true;
59059
+ }
59060
+ return false;
59061
+ }
59062
+ string().transform((value) => value.trim()).pipe(string().min(1, "The server name cannot be empty").max(48, `The server name is at most 48 characters`).refine((value) => !hasControlCharacter(value), { message: "The server name cannot contain control characters" }));
59063
+ /** What every reader gets: the name to show, and whether the hub chose it itself. */
59064
+ var ServerNameInfoSchema = object({
59065
+ name: string(),
59066
+ /** `true` when nobody named the hub: `name` is the machine hostname. */
59067
+ isDefault: boolean()
59068
+ });
58924
59069
  /**
58925
59070
  * system — system-scoped singleton capability exposing hub-level
58926
59071
  * health, feature flags, network interface enumeration, and the
@@ -58950,6 +59095,12 @@ var FeatureManifestSchema = object({
58950
59095
  backup: boolean(),
58951
59096
  repl: boolean()
58952
59097
  });
59098
+ /**
59099
+ * `system.info`: the feature flags plus the hub's human name (D861). The name is
59100
+ * `{ name, isDefault }` — `isDefault: true` means nobody named the hub and `name`
59101
+ * is the machine hostname.
59102
+ */
59103
+ var SystemInfoSchema = FeatureManifestSchema.extend({ serverName: ServerNameInfoSchema });
58953
59104
  var HealthStatusSchema = object({
58954
59105
  status: literal("ok"),
58955
59106
  uptime: number()
@@ -59422,7 +59573,7 @@ var LoggingSettingsStateSchema = object({
59422
59573
  opsLogRetentionDays: number().int().min(0),
59423
59574
  persisted: boolean()
59424
59575
  });
59425
- method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
59576
+ method(_void(), SystemInfoSchema), method(_void(), HealthStatusSchema), method(_void(), FeatureManifestSchema), method(_void(), array(NetworkAddressSchema).readonly()), method(_void(), unknown().nullable(), { auth: "admin" }), method(record(string(), unknown()), _null(), {
59426
59577
  kind: "mutation",
59427
59578
  auth: "admin"
59428
59579
  }), method(_void(), _void(), {
@@ -62473,6 +62624,12 @@ Object.freeze({
62473
62624
  addonId: null,
62474
62625
  access: "create"
62475
62626
  },
62627
+ "deviceManager.cleanupDeletedDevicesData": {
62628
+ capName: "device-manager",
62629
+ capScope: "system",
62630
+ addonId: null,
62631
+ access: "create"
62632
+ },
62476
62633
  "deviceManager.createDevice": {
62477
62634
  capName: "device-manager",
62478
62635
  capScope: "system",
@@ -62653,6 +62810,12 @@ Object.freeze({
62653
62810
  addonId: null,
62654
62811
  access: "view"
62655
62812
  },
62813
+ "deviceManager.listDeletedSince": {
62814
+ capName: "device-manager",
62815
+ capScope: "system",
62816
+ addonId: null,
62817
+ access: "view"
62818
+ },
62656
62819
  "deviceManager.listDeviceIdsByCaps": {
62657
62820
  capName: "device-manager",
62658
62821
  capScope: "system",
@@ -63061,6 +63224,18 @@ Object.freeze({
63061
63224
  addonId: null,
63062
63225
  access: "create"
63063
63226
  },
63227
+ "deviceRemovalHook.listDeviceData": {
63228
+ capName: "device-removal-hook",
63229
+ capScope: "system",
63230
+ addonId: null,
63231
+ access: "view"
63232
+ },
63233
+ "deviceRemovalHook.onDeviceRemoved": {
63234
+ capName: "device-removal-hook",
63235
+ capScope: "system",
63236
+ addonId: null,
63237
+ access: "create"
63238
+ },
63064
63239
  "deviceState.claimFields": {
63065
63240
  capName: "device-state",
63066
63241
  capScope: "system",
@@ -63493,6 +63668,12 @@ Object.freeze({
63493
63668
  addonId: null,
63494
63669
  access: "delete"
63495
63670
  },
63671
+ "keychain.deleteDeviceScope": {
63672
+ capName: "keychain",
63673
+ capScope: "system",
63674
+ addonId: null,
63675
+ access: "delete"
63676
+ },
63496
63677
  "keychain.getState": {
63497
63678
  capName: "keychain",
63498
63679
  capScope: "system",
@@ -69505,6 +69686,11 @@ Object.freeze({
69505
69686
  form: "single",
69506
69687
  optional: false
69507
69688
  }],
69689
+ "deviceRemovalHook.onDeviceRemoved": [{
69690
+ name: "deviceId",
69691
+ form: "single",
69692
+ optional: false
69693
+ }],
69508
69694
  "deviceState.claimFields": [{
69509
69695
  name: "deviceId",
69510
69696
  form: "single",
@@ -69694,6 +69880,11 @@ Object.freeze({
69694
69880
  form: "single",
69695
69881
  optional: false
69696
69882
  }],
69883
+ "keychain.deleteDeviceScope": [{
69884
+ name: "deviceId",
69885
+ form: "single",
69886
+ optional: false
69887
+ }],
69697
69888
  "lawnMowerControl.dock": [{
69698
69889
  name: "deviceId",
69699
69890
  form: "single",
@@ -72042,6 +72233,8 @@ new Set([
72042
72233
  "audio-tools",
72043
72234
  "audio-silence"
72044
72235
  ]);
72236
+ AppPageLangSchema.options;
72237
+ record(string().min(1), string());
72045
72238
  /**
72046
72239
  * TimelapseRule — the STANDALONE scheduled timelapse producer's rule model.
72047
72240
  *
@@ -72475,7 +72668,7 @@ var AdminUIAddon = class extends BaseAddon {
72475
72668
  capability: adminUiCapability,
72476
72669
  provider: {
72477
72670
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
72478
- getVersion: async () => ({ version: "1.2.427" })
72671
+ getVersion: async () => ({ version: "1.2.429" })
72479
72672
  }
72480
72673
  }];
72481
72674
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.427",
3
+ "version": "1.2.429",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1,4 +0,0 @@
1
- import{I as e,K as t,Q as n,R as r,S as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Hr as d,It as f,Ln as p,Nt as m,On as h,Ot as g,Q as _,ar as v,bi as y,di as b,dn as x,dt as S,en as C,fn as ee,gi as w,ln as T,ri as E,wn as te,yi as D,yn as O}from"./player-overlays-DWMIy1MJ.js";import{c as ne}from"./video--MLJeLNU.js";import{t as k}from"./octagon-alert-DMjnTemh.js";import{wi as A}from"./client-CjyKfSu1.js";import{An as re,Ar as ie,Bn as ae,Br as j,Cr as M,Dn as oe,En as se,Er as ce,Fr as le,Ir as N,Lr as ue,Mr as de,Or as P,Pr as F,Q as fe,Sr as pe,Tn as I,Tr as me,Tt as L,U as R,Vr as he,Xn as z,Xo as B,Zn as ge,ar as V,br as H,du as U,jn as W,jr as G,kn as _e,kr as K,mu as ve,vr as ye,wr as be,wt as q,xr as J,zr as Y}from"./src-BLkInT8U.js";import"./mount-1Z6p3UkP.js";import{Y as X,Z as xe}from"./index-D66JvELZ.js";import{t as Z}from"./AdminPage-C0Zxs_ot.js";import{t as Q}from"./NodeAddonsSettingsPanel-D3ux_JIo.js";import{n as Se,t as Ce}from"./useNodeUrlSelection-BsLRiUy8.js";n();var we={queued:{icon:E,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:v,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:O,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:y,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:k,bg:`bg-danger/10 text-danger`,label:`failed`}};function Te({item:e}){let t=we[e.status],n=t.icon;return i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}var Ee=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),De=new Set([`done`,`failed`,`skipped`]);function Oe(e){return!De.has(e.phase)&&!Ee.has(e.jobState)}function ke(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ee.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 Ae(){let{data:e}=K({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=ve(A.AddonsJobProgress,e=>e.job.jobId);return a(()=>{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 ke([...n.values()],Date.now())},[e,t])}var je={queued:{icon:E,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:v,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:v,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:v,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:v,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:v,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:v,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:y,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:k,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:C,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function Me({progress:e}){let t=je[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return i(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,i(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Ne(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 Pe(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Fe(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(Pe)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Ie(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 Le={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function Re(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)}: ${Le[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 ze={},Be=3e4,Ve=`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 He({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:a}){let o=s(),c=ge(),u=z(),d=P(ze,{staleTime:Be}),p=d.data?.installations??[],m=(d.data?.unreachable??[]).map(e=>e.nodeId),h=Ne(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),_=j({onSettled:()=>{o.invalidateQueries({queryKey:[[`addons`]]}),o.invalidateQueries({queryKey:[[`addonPages`]]}),o.invalidateQueries({queryKey:[[`capabilities`]]}),o.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await u({title:e.success?`${t} uninstalled`:`${t}: not every node was cleaned`,message:Re(e,g),variant:e.success?`default`:`danger`})},y=async n=>{try{await v(await _.mutateAsync({packageName:e,...n}))}catch(e){await u({title:`Uninstall ${t} failed`,message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==n.id);await c({title:`Uninstall ${t} from ${n.name}?`,message:Ie(t,n.name,e),confirmLabel:`Uninstall`,variant:`danger`})&&await y(n.isHub?{}:{nodeId:n.id})},x=async()=>{let n=(await d.refetch()).data;if(n===void 0){await u({title:`Cannot list the nodes`,message:`The hub did not answer which nodes have this package — nothing was removed.`,variant:`danger`});return}let r=Ne(n.installations,e);await c({title:`Uninstall ${t} everywhere?`,message:Fe(t,r,n.unreachable.map(e=>e.nodeId)),confirmLabel:`Uninstall from ${r.length} node(s)`,variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||a===!0;return i(`div`,{className:`flex items-center gap-1.5`,children:[r!==!0&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:Ve,title:`Uninstall from ${n.name}`,children:[l(f,{className:`h-3 w-3`}),_.isPending?`Removing...`:`Uninstall`]}),(h.length>1||r===!0||m.length>0)&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:Ve,title:`Uninstall from every node that has it`,children:[l(ne,{className:`h-3 w-3`}),`Everywhere`,h.length>0?` (${h.length})`:``]})]})}function Ue({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:f,isLoading:p}=be({name:e});return i(`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:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),l(`button`,{type:`button`,onClick:a,className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3 w-3`})})]}),u&&i(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(g,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),i(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[i(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,l(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),p&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(v,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),f&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:f.map(e=>{let n=e.version===t,a=s!==void 0&&e.version===c,u=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=i(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:u?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>l(`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)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?i(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${a?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a?l(y,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:l(d,{className:`h-3 w-3`})})]},e.version)})}),f&&f.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}n();var We=`device-export`;function Ge(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===We)}function Ke(e){return e!==`local`&&e!==`upload`}function qe({isBundle:e,installSource:t,addonId:n,iconPath:r,color:a}){let[o,s]=c(!1),u=a?{backgroundColor:`${a.startsWith(`#`)?a:`#${a}`}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=n&&r?_(`/api/addon-assets/${n}/${r}`):null,m=!!f&&!o;return i(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?l(`img`,{src:f,alt:n,className:`h-4 w-4`,onError:()=>s(!0)}):l(e?p:te,{className:`h-3.5 w-3.5`})}),t===`local`&&l(`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`}),Ke(t)&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`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:l(g,{className:`h-2.5 w-2.5 text-white`})})]})}function Je({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:a,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){if(r)return i(`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:[l(v,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,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:`Update to ${r}`,children:[l(d,{className:`h-3 w-3`}),`Update`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,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:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(D,{className:`h-3 w-3`})]}),u]})}return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,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`,a===`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:`Version ${e} — tap to view all versions`,children:[e,l(D,{className:`h-3 w-3 opacity-50`})]}),u]})}function Ye({addonId:e}){let t=s(),{data:n=`inherit`}=J({addonId:e}),r=N({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{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 Xe={id:`hub`,name:`Hub`,isHub:!0};function Ze({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:d,isUpdating:f,jobProgress:m,bundle:g,bulkItem:_,disabledByBulk:v,isSystem:y,selectedNode:b}){let[x,C]=c(!1),[E,te]=c(!1),[ne,A]=c(!1),[ie,j]=c(null);u(()=>{j(null)},[a]);let M=ie??a,[ce,le]=c(!1),[N,ue]=c(!1),[P,pe]=c(`logs`),R=s(),he=X(),{manifest:z}=e,B=e.installedOn??[],ge=!g&&!z.protected&&z.removable!==!1,V=!!g,H=g?.displayName??z.name,U=g?.packageName??z.packageName,G=g?.version??z.packageVersion??z.version,K=g?.installSource??e.installSource,ve=g?g.bundle?.description??g.addons[0]?.manifest.description:z.description,ye=de({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]})}}),be=me({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]}),R.invalidateQueries({queryKey:[[`addonPages`]]}),R.invalidateQueries({queryKey:[[`capabilities`]]}),R.invalidateQueries({queryKey:[[`integrations`]]})}}),J=F({onSuccess:()=>{R.invalidateQueries({queryKey:[[`addons`]]}),R.invalidateQueries({queryKey:[[`alerts`]]})}}),Y=e.health,xe=Y?.phase===`failed`&&!Y.inGracePeriod,Z=xe&&Y?.nextRetryAt&&!Y.retrying;return i(`div`,{className:`rounded-md border bg-surface overflow-hidden ${xe?`border-red-500/50`:`border-border`}`,children:[xe&&Y&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(k,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,Y.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:Y.lastError?.message??`Unknown error`}),Z&&Y.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(Y.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:J.isPending||Y.retrying,onClick:e=>{e.stopPropagation(),J.mutate({packageName:U})},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:`Reset retry counter and force immediate reload`,children:[l(O,{className:`h-3 w-3 ${J.isPending||Y.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[l(qe,{isBundle:V||!!z.components&&z.components.length>1,installSource:K,addonId:V?g.addons[0]?.manifest.id:z.id,iconPath:V?g.bundle?.icon??g.addons[0]?.manifest.icon:z.icon,color:V?g.addons[0]?.manifest.color:z.color}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:H}),!r&&l(Je,{version:G,availableUpdate:a,...M===void 0?{}:{selectedVersion:M},isUpdating:f,installSource:K,disabled:v,...d&&M!==void 0?{onUpdate:()=>d(M)}:{},onOpenPicker:()=>A(e=>!e),children:ne&&l(Ue,{packageName:U,currentVersion:G,...K?{installSource:K}:{},...a!==void 0&&M!==void 0?{selectedVersion:M,onSelect:e=>{j(e),A(!1)}}:{},onInstall:e=>{A(!1),be.mutate({packageName:U,version:e})},onClose:()=>A(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[U!==H&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:U}),V&&i(`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:[l(p,{className:`h-3 w-3`}),g.addons.length]}),y&&i(`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:`System package — updating restarts the hub`,children:[l(O,{className:`h-3 w-3`}),`System`]}),_!=null&&l(Te,{item:_}),m!=null&&l(Me,{progress:m})]}),ve&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:ve}),!V&&e.process&&i(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`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`?`forked`:`in-process`}),e.process.pid!=null&&i(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`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`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!V&&i(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ye.mutate({addonId:z.id})},disabled:ye.isPending||v,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:[l(O,{className:`h-3 w-3 ${ye.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ce?`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:[l(ee,{className:`h-3 w-3`}),`Logs`]}),!V&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),ue(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${N?`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:[l(T,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),ge&&l(He,{packageName:z.packageName,displayName:z.name,selectedNode:b??Xe,disabled:v})]}),n&&n.nodes.length>1&&!V&&i(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),l(`div`,{className:`space-y-1`,children:n.nodes.map(e=>i(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`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`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),ce&&!V&&i(`div`,{className:`border-t border-border`,children:[i(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[i(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>pe(`logs`),className:`px-2 py-0.5 transition-colors ${P===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>pe(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${P===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),le(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3.5 w-3.5`})})]}),P===`logs`&&l(L,{addonId:z.id,maxHeight:`max-h-64`,showFilters:!1}),P===`events`&&l(q,{addonId:z.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>C(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(x?w:D,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),x&&l(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>l(Ze,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),N&&!V&&l(I,{open:!0,onOpenChange:e=>!e&&ue(!1),children:i(oe,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(re,{children:i(W,{className:`flex items-center gap-2`,children:[l(T,{className:`h-4 w-4 text-primary`}),H,` Settings`]})}),i(se,{className:`space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`}),l(Q,{nodeId:null,addonIds:[z.id],level:`global`,fieldScope:`cluster`,emptyMessage:`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`}),Ge(z)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(fe,{addonId:z.id,onOpenDevice:e=>he(`/devices/${e}`)})]}),Ke(K)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(Ye,{addonId:z.id})]}),z.components&&z.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,z.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:z.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),i(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[B.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),B.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),i(`div`,{className:`relative`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),te(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[l(h,{className:`h-3 w-3`}),`Add agent`]}),E&&i(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!B.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),te(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!B.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(_e,{children:l(ae,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>ue(!1),children:`Close`})})]})})]})}n();var Qe=`.tgz,.tar.gz,.zip`;function $e({onUploadSuccess:n}){let[r,a]=c(!1),s=t(null),u=e(async e=>{a(!0);let t=new FormData;t.append(`file`,e);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(_(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:t})).json()).success&&n()}finally{a(!1)}},[n]);return i(o,{children:[l(`input`,{ref:s,type:`file`,accept:Qe,onChange:e(e=>{let t=e.target.files?.[0];t&&u(t),e.target.value=``},[u]),className:`hidden`}),i(`button`,{type:`button`,onClick:()=>s.current?.click(),disabled:r,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:[r?l(v,{className:`w-3.5 h-3.5 animate-spin`}):l(g,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}var et=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function tt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||et.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 nt({selectedNode:e}){let{data:t}=P(ze,{staleTime:Be});if(t===void 0)return null;let n=tt(t.installations,e),r=t.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return n.length===0&&r.length===0?null:i(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[i(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[l(m,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?`Installed on agents but not on the hub`:`Installed on ${e.name} but not on the hub`]}),r.length>0&&i(`div`,{className:`text-[10px] text-foreground-subtle`,children:[`Could not ask `,r.map(e=>e.nodeId).join(`, `),` — its packages are not listed.`]}),n.map(t=>i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[i(`div`,{className:`min-w-0`,children:[l(`div`,{className:`text-xs font-mono text-foreground break-all`,children:t.packageName}),l(`div`,{className:`text-[10px] text-foreground-subtle`,children:t.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),l(He,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}function rt({addon:e,installing:t,onInstall:n}){return i(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`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()}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?l(V,{variant:`success`,icon:l(y,{className:`h-3 w-3`}),children:e.installedVersion??`Installed`}):i(ae,{size:`sm`,onClick:()=>n(e.name),disabled:t,className:`shrink-0`,children:[t?l(v,{className:`h-3 w-3 animate-spin`}):l(d,{className:`h-3 w-3`}),`Install`]})]})}function it({capability:e,installing:t,onInstall:n}){let{data:r,isPending:a,isError:o}=le({capability:e}),s;if(o)s=l(`div`,{className:`px-3 py-2 text-xs text-danger`,children:`Could not search the npm catalog right now. Try again in a moment.`});else if(a||r===void 0)s=i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[l(v,{className:`h-3 w-3 animate-spin`}),`Searching the npm catalog…`]});else{let i=r.filter(e=>!e.installed);s=i.length===0?l(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:r.length===0?`No published addon declares the "${e}" capability.`:`Every published addon that declares "${e}" is already installed.`}):l(`div`,{className:`divide-y divide-border`,children:i.map(e=>l(rt,{addon:e,installing:t,onInstall:n},e.name))})}return i(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":`Available to install`,children:[l(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:`Available to install`}),s]})}n();function at(e){return e===`npm`||e===`dev`?e:null}var ot=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,st=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,ct=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],lt=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function ut(e){return e!==void 0&&lt.has(e)}var dt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function ft(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function pt(e){return e===`local`?`dev`:`npm`}function mt(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`}: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 ht(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 gt({addons:n,clusterStatus:o,selectedNode:f,onRefresh:p,isRefreshing:m}){let h=s(),[g,_]=c(``),y=r(g),[S,C]=c(!1),ee=t(null);u(()=>{if(!S)return;let e=e=>{ee.current&&!ee.current.contains(e.target)&&C(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[S]);let{data:w}=ie({nodeId:f.id}),T=a(()=>{let e=new Map;for(let t of w??[])e.set(t.name,t.latestVersion);return e},[w]),E=a(()=>(w??[]).filter(e=>!e.isSystem).length,[w]),[te,D]=c(()=>new Set),[ne,k]=c(()=>new Map),A=e(e=>{D(t=>new Set(t).add(e))},[]),re=e(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),ae=e((e,t)=>{k(n=>new Map(n).set(e,t))},[]),j=e(e=>{k(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),oe=he({onMutate:e=>{A(e.name),j(e.name)},onSuccess:(e,t)=>{re(t.name);let n=e;if(n&&n.success===!1){ae(t.name,n.error??`Update failed (no error message returned by server)`);return}h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{re(t.name),ae(t.name,e instanceof Error?e.message:String(e))}}),se=Ae(),ce=t(new Set);u(()=>{let e=new Set;for(let[t,n]of se)Oe(n)&&e.add(t);let t=[...ce.current].some(t=>!e.has(t));ce.current=e,t&&(h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[se,h]);let{data:N}=pe(void 0),de=ye({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),P=ue({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:F,isFetching:fe}=le({query:y||void 0},{enabled:S}),I=Y(),{data:L}=M(void 0),R=L?.requestedAt,[z,B]=c(null),[V,H]=c(!1);u(()=>{if(L?.kind===`framework-bulk-update`&&L.requestedAt!==z){B(L.requestedAt),H(!0);let e=window.setTimeout(()=>H(!1),6e3);return()=>window.clearTimeout(e)}},[R,z,L]),ge();let U=e(async()=>{let e=(w??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!f.isHub){for(let t of e)await oe.mutateAsync({name:t.name,version:t.latestVersion,nodeId:f.id});return}await I.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[f.id]})}},[w,f.id,f.isHub,I,oe]),W=me({onSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),h.invalidateQueries({queryKey:[[`addonPages`]]}),h.invalidateQueries({queryKey:[[`capabilities`]]}),h.invalidateQueries({queryKey:[[`integrations`]]})}}),[G,_e]=c(`type`),[K,ve]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),be=e=>{ve(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[q,J]=xe(),X=q.get(`capability`),Z=q.get(`updatable`)===`1`,Q=at(q.get(`source`)),Se=e(e=>{let t=new URLSearchParams(q);e?t.set(`updatable`,`1`):t.delete(`updatable`),J(t,{replace:!0})},[q,J]),Ce=e(e=>{let t=new URLSearchParams(q);e===null?t.delete(`source`):t.set(`source`,e),J(t,{replace:!0})},[q,J]),we=a(()=>{let e=n.filter(e=>!ut(e.manifest.packageName));return f.isHub||(e=e.filter(e=>ft(e.placement,f.isHub))),X&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===X))),Z&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&T.has(t)})),Q!==null&&(e=e.filter(e=>pt(e.installSource)===Q)),e},[n,f.isHub,X,Z,Q,T]),Te=()=>{let e=new URLSearchParams(q);e.delete(`capability`),J(e,{replace:!0})},Ee=K===`flat`?we:ht(we),De=a(()=>{let e=[...Ee];switch(G){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},[Ee,G]);return i(`div`,{className:`space-y-3`,children:[[...ne.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:i(`div`,{className:`flex items-start justify-between gap-3`,children:[i(`div`,{className:`space-y-0.5`,children:[i(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>j(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),i(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),i(`select`,{value:G,onChange:e=>_e(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:`Bundles first`}),l(`option`,{value:`name`,children:`Name`}),l(`option`,{value:`source`,children:`Install source`})]})]}),i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>be(e),className:`px-2 py-1 transition-colors capitalize ${K===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),f.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(O,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>de.mutate({channel:e}),disabled:de.isPending,className:`px-2 py-1 transition-colors capitalize ${N?.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))})]}),f.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Check every:`}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:N?.updateCheckIntervalSeconds??21600,disabled:P.isPending||N===void 0,onChange:e=>{N!==void 0&&P.mutate({channel:N.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:ct.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),E>0&&i(`button`,{type:`button`,onClick:()=>void U(),disabled:I.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:[I.isPending?l(v,{className:`w-3 h-3 animate-spin`}):l(d,{className:`w-3 h-3`}),I.isPending?`Updating…`:`Update All (${E})`]}),i(`button`,{type:`button`,onClick:p,disabled:m||I.isPending,className:`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`,children:[l(O,{className:`w-3 h-3 ${m?`animate-spin`:``}`}),`Refresh`]})]}),i(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":`Filter installed addons`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Filter:`}),[{id:`updatable`,label:`Updatable`,pressed:Z,toggle:()=>Se(!Z)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>Ce(Q===`npm`?null:`npm`)},{id:`dev`,label:`Dev`,pressed:Q===`dev`,toggle:()=>Ce(Q===`dev`?null:`dev`)}].map(e=>l(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?ot:st,children:e.label},e.id))]}),i(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[i(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:ee,children:[l(x,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:g,onChange:e=>{_(e.target.value),C(!0)},onFocus:()=>C(!0),placeholder:`Search addons on npm...`,disabled:I.isPending,className:`w-full rounded-md border border-border bg-background pl-9 pr-3 py-1.5 text-[11px] text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),fe&&l(v,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),S&&F&&F.length>0&&i(`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:[F.length>0&&i(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,F.length,`)`]}),F&&F.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:F.map(e=>l(rt,{addon:e,installing:W.isPending,onInstall:e=>W.mutate({packageName:e})},e.name))})]})]}),l($e,{onUploadSuccess:()=>{h.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),X&&i(`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:[l(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),l(`span`,{className:`font-mono text-primary font-semibold`,children:X}),l(`button`,{type:`button`,onClick:Te,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),X&&l(it,{capability:X,installing:W.isPending,onInstall:e=>W.mutate({packageName:e})}),X&&we.length>0&&l(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:`Installed`}),V&&i(`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 backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(b,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),we.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:X?`No installed addon declares the "${X}" capability. Any addon you can install appears under "Available to install" above.`:`No addons compatible with ${f.name} (placement filter active)`}),l(`div`,{className:`space-y-1.5`,children:De.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=T.get(t),r=$(e)?e.representative:e,i=n?e=>oe.mutate({name:t,version:e,nodeId:f.id}):void 0,a=se.get(t)??null,s=a!==null&&Oe(a);return l(Ze,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:te.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:I.isPending,selectedNode:f},$(e)?t:e.manifest.id)})})]})}function _t(){let e=s(),{data:n}=B(void 0),{nodes:r}=U(),{selection:a,selectNode:o,requestedNodeId:c}=Ce(r.length>0?r:[dt]),d=a.node??dt,f=d.id,p=r.length>0?a.staleNodeId:null,{data:m,isLoading:h,isError:g}=ce({nodeId:f}),_=H(),v=G(),y=_.isPending||v.isPending,b=async()=>{await _.mutateAsync({nodeId:f}),await v.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},x=t(_);x.current=_;let S=t(c??`hub`);u(()=>{x.current.mutate({nodeId:S.current})},[]);let C=(m??[]).map(mt).filter(e=>e!==null);return i(Z,{children:[i(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[l(R,{selectedNodeId:f,onSelect:o}),i(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!h&&!g&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[C.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void b(),disabled:y,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:`Re-fetch addons + check npm for new versions`,children:[l(O,{className:`w-3 h-3 ${y?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(Se,{staleNodeId:p,shownNodeName:d.name}),l(nt,{selectedNode:d}),h&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),g&&l(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!h&&!g&&l(gt,{addons:C,clusterStatus:n,selectedNode:d,onRefresh:()=>void b(),isRefreshing:y})]})}export{_t as AddonsPage};
@@ -1 +0,0 @@
1
- import{I as e,Q as t,x as n}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{B as r}from"./src-BLkInT8U.js";import{Z as i}from"./index-D66JvELZ.js";t();function a({paramName:t=`tab`,defaultSection:a,sections:o,...s}){let[c,l]=i(),u=a??o[0]?.id??``,d=c.get(t),f=o.some(e=>e.id===d)?d??u:u,p=e((e,n)=>{l(r=>{let i=new URLSearchParams(r);for(let e of n)i.delete(e);return i.set(t,e),i},{replace:!0})},[t,l]);return n(r,{...s,paramName:t,defaultSection:a,sections:o,activeSection:f,onSectionChange:p})}export{a as t};
@@ -1,3 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{D as d,Dn as f,G as p,Hr as m,It as h,Jr as g,Jt as _,Oi as v,On as y,Pn as b,Q as x,Tr as S,Xt as C,Zr as w,ar as T,dn as E,dt as D,kr as ee,ot as O,un as k,wi as A}from"./player-overlays-DWMIy1MJ.js";import{t as te}from"./message-square-plus-COMrVZEZ.js";import{t as j}from"./send-P2KlabIu.js";import{Un as M}from"./client-CjyKfSu1.js";import{Bn as N,Gl as P,Ht as F,L as ne,Ln as re,Pn as ie,U as I,Ut as L,Vt as R,Xl as z,ar as B,bn as V,in as H,ma as U,z as W}from"./src-BLkInT8U.js";import{t as G}from"./useTranslation-Bc5yH9V9.js";import"./mount-1Z6p3UkP.js";import{S as K}from"./index-D66JvELZ.js";import{t as q}from"./AdminSectionedPage-D2kYQhvu.js";import{t as J}from"./AdminPage-C0Zxs_ot.js";n();var ae=[`llm`,`listProfiles`],oe=[`llm`,`listProfileKinds`],se=[`llm`,`getDefaults`],Y=[`llm`,`listRuntimeNodes`],ce=[`llm`,`listModelCatalog`],le=[`llm`,`getUsage`],ue=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],de=new Map(Object.entries({openai:w,anthropic:w,google:w,"openai-compatible":f,"managed-local":g,"apple-foundation":g}));function fe(e){return de.get(e)??null}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function Z(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Q(e){return e===!0}function pe(e){return{model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,supportsVision:e.supportsVision,temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled,contextSize:e.runtime?.contextSize,gpuLayers:e.runtime?.gpuLayers,threads:e.runtime?.threads,parallel:e.runtime?.parallel,idleStopMinutes:e.runtime?.idleStopMinutes,batchSize:e.runtime?.batchSize,ubatchSize:e.runtime?.ubatchSize,flashAttention:e.runtime?.flashAttention,mlock:e.runtime?.mlock,noMmap:e.runtime?.noMmap,cacheTypeK:e.runtime?.cacheTypeK,cacheTypeV:e.runtime?.cacheTypeV,extraArgs:_e(e.runtime?.extraArgs??[])}}var me=[`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`];function he(e){return typeof e==`string`&&me.includes(e)?e:void 0}function ge(e){let t=[],n=``,r=null;for(let i of e){if(r!==null){i===r?r=null:n+=i;continue}if(i===`"`||i===`'`){r=i;continue}if(/\s/.test(i)){n!==``&&t.push(n),n=``;continue}n+=i}return n!==``&&t.push(n),t}function _e(e){return e.map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)}var ve=[`--jinja`,`--cont-batching`];function ye(e,t,n){let r=Z(e.threads),i=Z(e.batchSize),a=Z(e.ubatchSize),o=he(e.cacheTypeK),s=he(e.cacheTypeV);return{nodeId:t,engine:`llama-cpp`,model:n,extraArgs:[...ge(X(e.extraArgs)??``)],contextSize:Z(e.contextSize)??4096,gpuLayers:Z(e.gpuLayers)??0,...r===void 0?{}:{threads:r},parallel:Z(e.parallel)??1,...i===void 0?{}:{batchSize:i},...a===void 0?{}:{ubatchSize:a},flashAttention:Q(e.flashAttention),mlock:Q(e.mlock),noMmap:Q(e.noMmap),...o===void 0?{}:{cacheTypeK:o},...s===void 0?{}:{cacheTypeV:s},autoStart:Q(e.autoStart),idleStopMinutes:Z(e.idleStopMinutes)??30}}function be(e,t,n,r,i){let a={id:n?.id??crypto.randomUUID(),name:t,kind:e,addonId:`ai`,enabled:n?.enabled??!0,model:X(r.model)??n?.model??``,supportsVision:i?.supportsVision??Q(r.supportsVision),timeoutMs:Z(r.timeoutMs)??M.totalMs,connectTimeoutMs:Z(r.connectTimeoutMs)??M.connectMs,firstTokenTimeoutMs:Z(r.firstTokenTimeoutMs)??M.firstTokenMs,idleTimeoutMs:Z(r.idleTimeoutMs)??M.idleMs,retry:{enabled:Q(r.retryEnabled),maxAttempts:Z(r.retryMaxAttempts)??1},toolsEnabled:Q(r.toolsEnabled)},o=X(r.baseUrl),s=X(r.apiKey),c=Z(r.temperature),l=Z(r.topP),u=Z(r.topK),d=Z(r.maxTokens),f=Z(r.contextLength),p=X(r.systemPrompt);return{...a,...o===void 0?{}:{baseUrl:o},...s===void 0?{}:{apiKey:s},...c===void 0?{}:{temperature:c},...l===void 0?{}:{topP:l},...u===void 0?{}:{topK:u},...d===void 0?{}:{maxTokens:d},...f===void 0?{}:{contextLength:f},...p===void 0?{}:{systemPrompt:p},...i===void 0?{}:{model:i.modelId,runtime:ye(r,i.nodeId,i.model)}}}function xe(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Se=`apple-system`;function Ce(e,t,n,r){return{...be(`apple-foundation`,e,t,n),model:Se,supportsVision:!1,appleFoundation:{nodeId:r}}}var we={deviceNotEligible:{key:`ai.appleNotEligible`,text:`not eligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,text:`Apple Intelligence off`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,text:`model downloading`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,text:`macOS too old`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,text:`helper missing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,text:`helper crashed`,tone:`danger`}};function Te(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:`unknown`,detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:`available`,detail:`macOS ${n.osVersion} · ${n.imageInput?`text + images`:`text only`}`,tone:`success`};case`unavailable`:{let t=we[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:t.text,detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:`not a Mac`,detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var Ee=2e3;function $(e){return`${(e/1e9).toFixed(2)} GB`}function De(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Oe({nodeId:e,value:t,onChange:n}){let{t:o}=G(),u=O(),[d,f]=s(``),[p,h]=s(null),[g,_]=s(!1),v=a({queryKey:ce,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),y=a({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:e})}),b=c({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&n({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),x=c({mutationFn:t=>u.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),y.refetch()}}),S=a({queryKey:Y,enabled:x.isPending,refetchInterval:x.isPending?Ee:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,C=i(()=>{let t=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:o(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:$(t.sizeBytes),node:e})})),r=p?.ok===!0?[{value:`custom`,label:`${p.label} · ${$(p.totalBytes)}`}]:[];return[{value:``,label:o(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[v.data,y.data,p,e,o]),w=e=>{if(e===``){n(null);return}if(e===`custom`){if(p?.ok!==!0)return;n({model:p.model,modelId:p.label,supportsVision:p.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),r=v.data?.find(e=>e.id===t);n({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:r?.purpose===`vision`});return}let t=e.slice(5),r=y.data?.find(e=>e.file===t);r?.path!==void 0&&n({model:{kind:`path`,path:r.path},modelId:t,supportsVision:!1})},D=e=>{d.trim()!==``&&b.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return r(`div`,{className:`space-y-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-model`,children:o(`ai.model`,`Model`)}),l(P,{id:`ai-model`,value:De(t),options:C,onChange:e=>w(e.target.value)})]}),r(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2.5`,children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:o(`ai.hfTitle`,`Add a model from Hugging Face`)}),l(`p`,{className:`mb-2 text-[10px] leading-relaxed text-foreground-subtle`,children:o(`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.`)}),r(`div`,{className:`flex gap-2`,children:[l(z,{value:d,onChange:e=>f(e.target.value),placeholder:`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),r(N,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||b.isPending,onClick:()=>D(),children:[b.isPending?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(E,{className:`h-3.5 w-3.5`}),o(`ai.hfCheck`,`Check`)]})]}),b.isError&&l(`p`,{className:`mt-2 text-[11px] text-danger`,children:b.error instanceof Error?b.error.message:o(`common.error`,`Error`)}),p?.ok===!1&&r(`div`,{className:`mt-2 rounded-md border border-danger/40 bg-danger/10 px-2.5 py-2`,children:[l(`p`,{className:`text-[11px] text-danger`,children:p.message}),p.candidates!==void 0&&p.candidates.length>0&&l(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:p.candidates.map(e=>l(`button`,{type:`button`,className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:border-primary/50`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),b.mutate({ref:t})},children:e},e))}),p.requiredBytes!==void 0&&l(N,{size:`sm`,variant:`secondary`,type:`button`,className:`mt-2`,onClick:()=>D(p.requiredBytes),children:o(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(p.requiredBytes)})})]}),p?.ok===!0&&r(`div`,{className:`mt-2 rounded-md border border-border bg-surface px-2.5 py-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`span`,{className:`text-[11px] font-medium text-foreground`,children:p.label}),l(B,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),l(B,{variant:`default`,children:$(p.totalBytes)})]}),p.extraFilenames.length>0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:o(`ai.hfExtras`,`Also downloads: {{files}}`,{files:p.extraFilenames.join(`, `)})}),r(`div`,{className:`mt-2 flex items-center gap-2`,children:[r(N,{size:`sm`,type:`button`,disabled:x.isPending||g,onClick:()=>x.mutate(p.model),children:[x.isPending?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(m,{className:`h-3.5 w-3.5`}),g?o(`ai.hfInstalled`,`Downloaded`):o(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),S!==void 0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:S.phase===`verifying`?o(`ai.hfVerifying`,`verifying {{file}}…`,{file:S.file}):o(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:S.file,index:S.fileIndex,count:S.fileCount,done:$(S.downloadedBytes),total:S.totalBytes===void 0?``:` / ${$(S.totalBytes)}`})})]}),x.isError&&l(`p`,{className:`mt-1.5 text-[11px] text-danger`,children:x.error instanceof Error?x.error.message:o(`common.error`,`Error`)})]})]})]})}function ke({value:e,onChange:t}){let{t:n}=G(),i=O(),o=a({queryKey:Y,queryFn:()=>i.trpcClient.llm.listRuntimeNodes.query({})});return r(`div`,{children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&r(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(T,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&l(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&l(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&l(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(i=>{let a=Te(i),o=a.nodeId===e;return r(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!a.selectable&&!o,onClick:()=>t(a.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 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block font-medium text-foreground`,children:a.nodeId}),a.detail!==null&&l(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:a.detail})]}),l(B,{variant:a.tone,children:n(a.labelKey,a.labelDefault)})]},a.nodeId)})}),l(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`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.`)})]})}n();function Ae({kind:e,className:t}){let n=fe(e.kind);return n===null?l(`span`,{className:t,children:e.icon}):l(n,{className:t})}function je({kinds:e,onPick:t,onCancel:n}){let{t:a}=G(),o=i(()=>xe(e),[e]);return l(W,{open:!0,onClose:n,title:a(`ai.chooseKind`,`Choose a profile type`),width:`lg`,testId:`ai-kind-picker`,children:r(`div`,{className:`space-y-4`,children:[o.length===0&&l(`p`,{className:`text-xs text-foreground-subtle`,children:a(`ai.noKinds`,`No AI provider is installed.`)}),o.map(e=>r(`div`,{children:[l(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.addonId}),l(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.kinds.map(n=>r(`button`,{type:`button`,onClick:()=>t(n),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[l(Ae,{kind:n,className:`h-5 w-5 text-foreground-subtle`}),l(`span`,{className:`font-medium text-foreground`,children:n.label})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]})})}function Me({kind:e,existing:t,onSave:n,onCancel:a,saving:c,error:u}){let{t:d}=G(),f=e.kind===`managed-local`,p=e.kind===`apple-foundation`,[m,h]=s(t?.appleFoundation?.nodeId??null),[g,_]=s(t?.name??e.label),[v,y]=s(()=>t===null?{}:pe(t)),[b,x]=s(t?.runtime?.nodeId??`hub`),[S,C]=s(()=>t?.runtime===void 0?null:{model:t.runtime.model,modelId:t.model,supportsVision:t.supportsVision}),w=i(()=>ge(X(v.extraArgs)??``),[v.extraArgs]),E=()=>{if(p){if(m===null)return;n(Ce(g,t,v,m));return}if(!f){n(be(e.kind,g,t,v));return}S!==null&&n(be(e.kind,g,t,v,{nodeId:b,model:S.model,modelId:S.modelId,supportsVision:S.supportsVision}))},D=c||g.trim()===``||f&&S===null||p&&m===null;return l(W,{open:!0,onClose:a,title:t===null?d(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):d(`ai.editProfile`,`Edit {{name}}`,{name:t.name}),error:u,width:`lg`,testId:`ai-profile-editor`,footer:r(o,{children:[f&&S===null&&l(B,{variant:`warning`,children:d(`ai.pickModelFirst`,`pick a model`)}),p&&m===null&&l(B,{variant:`warning`,children:d(`ai.pickAppleNodeFirst`,`pick a Mac`)}),r(N,{size:`sm`,type:`button`,disabled:D,onClick:E,children:[c&&l(T,{className:`h-3.5 w-3.5 animate-spin`}),t===null?d(`ai.createProfile`,`Create profile`):d(`ai.saveChanges`,`Save changes`)]})]}),children:r(`div`,{className:`space-y-3`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-profile-name`,children:d(`ai.name`,`Name`)}),l(z,{id:`ai-profile-name`,value:g,onChange:e=>_(e.target.value),placeholder:e.label})]}),f&&r(o,{children:[l(I,{selectedNodeId:b,onSelect:x,label:d(`ai.runtimeNode`,`Runtime node`),alwaysShow:!0}),l(Oe,{nodeId:b,value:S,onChange:C}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-extra-args`,children:d(`ai.extraArgs`,`Additional llama-server arguments`)}),l(z,{id:`ai-extra-args`,value:X(v.extraArgs)??``,onChange:e=>y({...v,extraArgs:e.target.value}),placeholder:ve.join(` `)}),w.length>0&&l(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:w.map((e,t)=>l(B,{variant:`default`,children:e},`${e}-${String(t)}`))}),l(`p`,{className:`mt-1 text-[10px] leading-relaxed text-foreground-subtle`,children:d(`ai.extraArgsHint`,`Flags this form does not already own. Vision models generally need --jinja; some language-only models do not like it. Context size, GPU layers, parallel slots, flash attention and the KV-cache types are set in the fields below — repeating one here is rejected at start.`)})]})]}),p&&l(ke,{value:m,onChange:h}),l(V,{schema:e.configSchema,values:v,onChange:y}),t!==null&&l(`p`,{className:`text-[10px] text-foreground-subtle`,children:d(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)})]})})}n();function Ne(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return r(`span`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?l(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):l(Ae,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&l(`span`,{className:`block truncate text-[10px] ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?l(B,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>e.runtime===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(B,{variant:`default`,children:e.runtime.nodeId})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>l(H,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>r(`span`,{className:`flex items-center justify-end gap-1`,children:[l(N,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?l(T,{className:`h-3.5 w-3.5 animate-spin`}):l(j,{className:`h-3.5 w-3.5`})}),l(N,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),title:e.t(`common.edit`,`Edit`),children:l(b,{className:`h-3.5 w-3.5`})}),l(N,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),title:e.t(`common.delete`,`Delete`),children:l(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Pe(){let{t}=G(),n=O(),{state:o,openNew:d,openEdit:f,close:p}=ne(),[m,h]=s(null),[g,_]=s(null),[v,b]=s(null),x=a({queryKey:ae,queryFn:()=>n.trpcClient.llm.listProfiles.query({})}),S=a({queryKey:oe,queryFn:async()=>(await n.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),w=()=>{x.refetch()},E=e(()=>{h(null),b(null),p()},[p]);u(()=>{o.mode===`closed`&&h(null)},[o.mode]);let D=c({mutationFn:e=>n.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{E(),w()},onError:e=>b(e instanceof Error?e.message:t(`ai.saveFailed`,`Save failed`))}),ee=c({mutationFn:e=>n.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:w}),k=c({mutationFn:e=>n.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>_({id:t.id,ok:e.ok,text:e.ok?`${e.text} (${String(e.usage.outputTokens)} tok, ${String(e.latencyMs)}ms)`:`${e.code}: ${e.message}`})}),A=x.data??[],te=i(()=>S.data??[],[S.data]),j=i(()=>{let e=new Map;for(let t of te)e.set(t.kind,t);return e},[te]),M=o.mode===`edit`?A.find(e=>e.id===o.id)??null:null,P=M===null?null:j.get(M.kind)??null,ie=o.mode===`new`&&m===null,I=o.mode===`new`?m:P,L=o.mode===`edit`?M:null,z=I!==null&&(o.mode===`new`||L!==null);return r(J,{embedded:!0,icon:C,title:t(`ai.profilesTitle`,`AI profiles`),subtitle:t(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),children:[l(`div`,{className:`flex justify-end`,children:r(N,{size:`sm`,type:`button`,onClick:()=>{b(null),h(null),d()},children:[l(y,{className:`h-3.5 w-3.5`}),t(`ai.addProfile`,`Add profile`)]})}),x.isError&&l(re,{title:t(`ai.loadFailed`,`Failed to load profiles`),message:x.error instanceof Error?x.error.message:t(`common.error`,`Error`),onRetry:()=>void x.refetch()}),l(Fe,{profiles:A}),x.isLoading&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(T,{className:`h-6 w-6 animate-spin text-primary`})}),!x.isLoading&&A.length===0&&l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:t(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}),A.length>0&&l(R,{headingId:`ai-profiles-list`,title:t(`ai.profilesList`,`Profiles`),children:l(F,{columns:Ne({kindByName:j,testResult:g,testingId:k.isPending?k.variables?.id??null:null,t,onToggle:e=>D.mutate({...e,enabled:!e.enabled,apiKey:`__redacted__`}),onTest:e=>k.mutate(e),onEdit:e=>{j.has(e.kind)&&(b(null),h(null),f(e.id))},onDelete:e=>ee.mutate(e)}),rows:A,rowKey:e=>e.id,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:`max-h-[60vh]`})}),ie&&l(je,{kinds:te,onCancel:E,onPick:e=>{b(null),h(e)}}),z&&I!==null&&l(Me,{kind:I,existing:L,saving:D.isPending,error:v,onSave:e=>D.mutate(e),onCancel:E})]})}function Fe({profiles:e}){let{t}=G(),n=O(),i=a({queryKey:se,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=c({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{i.refetch()}}),s=e=>(i.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return l(R,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:l(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:ue.map(({purpose:n,visionOnly:i})=>{let a=i?e.filter(e=>e.supportsVision):e,c=s(n),d=e.find(e=>e.id===c);return r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`llm-default-${n}`,children:u(n)}),l(P,{id:`llm-default-${n}`,"aria-label":u(n),className:`h-7 text-xs`,value:c,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...c!==``&&!a.some(e=>e.id===c)?[{value:c,label:d?.name??c}]:[],...a.map(e=>({value:e.id,label:`${e.name} · ${e.model}`}))]}),c!==``&&d===void 0&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&l(`p`,{className:`mt-1 text-[10px] text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:String(o.error)})]},n)})})})}n();var Ie=5e3;function Le(e){return`${(e/1e9).toFixed(1)} GB`}function Re(){let{t:e}=G(),t=O(),n=a({queryKey:Y,refetchInterval:Ie,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),o=i(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>l(`span`,{className:`text-sm font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>r(`span`,{className:`flex items-center gap-1.5`,children:[l(B,{variant:t.reachable?`success`:`danger`,children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&l(B,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.disk===void 0?`—`:Le(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=Te(t);return r(`span`,{className:`flex flex-col items-start gap-0.5`,children:[l(B,{variant:n.tone,children:e(n.labelKey,n.labelDefault)}),n.detail!==null&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n.detail})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(`span`,{className:`text-[11px] text-danger`,children:e.error})}],[e]),s=n.data??[];return r(J,{embedded:!0,icon:k,title:e(`ai.runtimesTitle`,`Managed runtimes`),subtitle: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.`),children:[n.isError&&l(re,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:n.error instanceof Error?n.error.message:e(`common.error`,`Error`),onRetry:()=>void n.refetch()}),s.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):l(R,{headingId:`ai-runtimes-list`,title:e(`ai.runtimesList`,`Nodes`),children:l(F,{columns:o,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:L})})]})}var ze=x(`/addon/ai/test-chat`),Be=x(`/addon/ai/test-chat/chats`),Ve=6e5;function He(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Ve)}function Ue(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function We(e){if(!Ue(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 Ge=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ke(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Ue(t))return null;switch(t.kind){case`status`:{let e=Ge.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:We(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:`the provider returned an error`};default:return null}}async function*qe(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=Ke(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Ke(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Je(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Ye(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Xe(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 Ze(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 Qe(e,t){switch(e){case`resolving-image`:return`fetching the picture…`;case`connecting`:return`connecting to the provider…`;case`first-token-wait`:return t>0?`the model is loading / thinking — a cold load can take minutes (up to ${String(Math.round(t/1e3))}s)`:`the model is loading / thinking — a cold load can take minutes`;case`streaming`:return`answering…`}}n();var $e=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],et=360*60*1e3,tt=40,nt=160,rt={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function it(){let{t:n}=G(),o=O(),[c,d]=s(``),[f,p]=s(``),[m,g]=s(``),[y,b]=s([]),[x,S]=s(null),[C,w]=s(`none`),[T,E]=s(`throwaway`),[k,M]=s(null),[F,ne]=s([]),[I,L]=s(null),[R,B]=s(null),V=t(null);u(()=>()=>V.current?.abort(),[]);let H=e(async()=>{let e=await fetch(Be,{credentials:`same-origin`});e.ok&&ne((await e.json()).chats??[])},[]);u(()=>{T===`persistent`&&H()},[T,H]);let U=a({queryKey:ae,queryFn:()=>o.trpcClient.llm.listProfiles.query({})}),W=i(()=>(U.data??[]).filter(e=>e.enabled),[U.data]),K=W.find(e=>e.id===c)??null,q=R!==null,oe=e(async(e,t)=>{let r=new AbortController;V.current=r,L(null);let i=He(K??{});B({...rt,firstTokenTimeoutMs:i??0});let a=``,o=null,s,l=null,u=null,d;try{let n=await fetch(ze,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:c,messages:e,...f.trim()===``?{}:{system:f.trim()},...t===void 0?{}:{attachment:t},...i===void 0?{}:{firstTokenTimeoutMs:i},...T===`persistent`?{persist:!0,...k===null?{}:{conversationId:k}}:{}})});if(!n.ok||n.body===null){let e=await n.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(n.status)}`)}for await(let e of qe(n.body))switch(e.kind){case`status`:B(t=>({...t??rt,phase:e.phase}));break;case`meta`:o=e.mediaSent,s=e.model,B(t=>({...t??rt,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:a+=e.text,B(e=>({...e??rt,text:a}));break;case`done`:u={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){r.signal.aborted||L(e instanceof Error?e.message:n(`common.error`,`Error`))}finally{V.current=null,B(null)}d!==void 0&&(M(d),H());let p=r.signal.aborted&&a.length>0;l===null&&a.length===0&&!p||b(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??a,...l===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&l===null?{model:s}:{},...u===null?{}:u}])},[T,k,K,c,H,f,n]),se=e(()=>{let e=m.trim();if(e===``||c===``||q)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...x===null?{}:{attachmentLabel:x.label,attachmentKind:x.ref.kind}},n=[...y,t];b(n),g(``);let r=x?.ref;S(null),w(`none`),oe(T===`persistent`&&k!==null?[{role:`user`,content:e}]:Je(n),r)},[T,k,m,x,c,oe,q,y]),Y=()=>V.current?.abort(),ce=()=>{V.current?.abort(),b([]),S(null),g(``),L(null),B(null),M(null)},le=async e=>{V.current?.abort();let t=await fetch(`${Be}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();M(e),b(Xe(n)),B(null),L(null)};return r(J,{embedded:!0,icon:ee,title:n(`ai.testTitle`,`Test chat`),subtitle:n(T===`persistent`?`ai.testSubtitlePersistent`:`ai.testSubtitle`,T===`persistent`?`Conversations are saved for you and can be reopened. Throwaway mode is still available.`:`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.`),children:[l(`div`,{className:`flex justify-end`,children:r(N,{size:`sm`,variant:`secondary`,type:`button`,disabled:y.length===0&&x===null,onClick:ce,children:[l(h,{className:`h-3.5 w-3.5`}),n(`ai.clearChat`,`Clear`)]})}),r(ie,{className:`space-y-3 p-4`,children:[r(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-profile`,children:n(`ai.profile`,`Profile`)}),l(P,{id:`ai-test-profile`,value:c,onChange:e=>d(e.target.value),options:[{value:``,label:n(`ai.selectProfile`,`Select a profile…`)},...W.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),W.length===0&&!U.isLoading&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-system`,children:n(`ai.systemPrompt`,`System prompt (optional)`)}),l(z,{id:`ai-test-system`,value:f,onChange:e=>p(e.target.value),placeholder:n(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l(N,{size:`sm`,variant:T===`throwaway`?`primary`:`outline`,type:`button`,onClick:()=>{E(`throwaway`),M(null)},children:n(`ai.throwawayMode`,`Throwaway`)}),l(N,{size:`sm`,variant:T===`persistent`?`primary`:`outline`,type:`button`,onClick:()=>E(`persistent`),children:n(`ai.saveConversation`,`Save conversation`)})]}),T===`persistent`&&r(`div`,{className:`space-y-2`,children:[l(`div`,{className:`flex items-center gap-2`,children:r(N,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[l(te,{className:`h-3.5 w-3.5`}),n(`ai.newChat`,`New chat`)]})}),F.length>0&&l(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:F.map(e=>l(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover ${e.id===k?`bg-primary/10`:``}`,children:l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),l(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`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.`)}),K!==null&&!K.supportsVision&&l(`p`,{className:`text-[10px] text-warning`,children:n(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]}),I!==null&&l(re,{title:n(`ai.chatFailed`,`The test call failed`),message:I}),l(at,{turns:y,live:R}),r(ie,{className:`space-y-2 p-3`,children:[x!==null&&r(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface px-2.5 py-1.5`,children:[x.ref.kind===`snapshot`?l(A,{className:`h-3.5 w-3.5 text-foreground-subtle`}):l(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground`,children:x.label}),l(N,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>S(null),children:l(D,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(N,{size:`sm`,variant:C===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>w(C===`snapshot`?`none`:`snapshot`),children:[l(A,{className:`h-3.5 w-3.5`}),n(`ai.attachSnapshot`,`Camera snapshot`)]}),r(N,{size:`sm`,variant:C===`track`?`primary`:`outline`,type:`button`,onClick:()=>w(C===`track`?`none`:`track`),children:[l(v,{className:`h-3.5 w-3.5`}),n(`ai.attachTrack`,`Recent track`)]})]}),C===`snapshot`&&l(ct,{onPick:e=>{S({ref:{kind:`snapshot`,deviceId:e.id},label:n(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:e.name})}),w(`none`)}}),C===`track`&&l(ut,{onPick:(e,t)=>{S({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:n(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),w(`none`)}}),r(`div`,{className:`flex items-center gap-2`,children:[l(z,{value:m,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),se())},placeholder:n(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":n(`ai.message`,`Message`)}),q?r(N,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[l(_,{className:`h-3.5 w-3.5`}),n(`ai.stop`,`Stop`)]}):r(N,{size:`sm`,type:`button`,disabled:m.trim()===``||c===``,onClick:se,children:[l(j,{className:`h-3.5 w-3.5`}),n(`ai.send`,`Send`)]})]})]})]})}function at({turns:e,live:t}){let{t:n}=G();return e.length===0&&t===null?l(`div`,{className:`py-12 text-center text-xs text-foreground-subtle`,children:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):l(ie,{children:r(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto p-3`,children:[e.map(e=>l(ot,{turn:e},e.id)),t!==null&&r(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&l(st,{attachment:t.mediaSent}),t.text.length>0&&l(ot,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),r(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[l(T,{className:`h-3.5 w-3.5 animate-spin`}),Qe(t.phase,t.firstTokenTimeoutMs)]})]})]})})}function ot({turn:e,streaming:t=!1}){let n=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return l(`div`,{className:`flex ${n?`justify-end`:`justify-start`}`,children:r(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${n?`border-primary/40 bg-primary/10`:i}`,children:[r(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&l(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&l(st,{attachment:e.attachment}),e.attachmentLabel!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?l(v,{className:`h-3 w-3`}):l(A,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?l(A,{className:`h-3 w-3`}):l(v,{className:`h-3 w-3`}),Ze(e.attachment)]}),e.model!==void 0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`${e.model} · ${String(e.outputTokens??0)} tok · ${String(e.latencyMs??0)} ms`})]})})}function st({attachment:e}){let t=Ye(e);return t===null?null:l(`img`,{src:t,alt:`sent to the model`,className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function ct({onPick:e}){let{t}=G(),n=U({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?l(T,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):l(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>l(lt,{device:t,onPick:e},t.id))})}function lt({device:e,onPick:t}){let{src:n}=p(e.id,{width:nt});return r(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[l(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:n!==null&&l(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),r(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&l(B,{variant:`warning`,children:`off`}),l(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function ut({onPick:e}){let{t}=G(),n=O(),o=U({isCamera:!0,projection:`slim`}),s=i(()=>(o.data??[]).map(e=>e.id),[o.data]),c=i(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=a({queryKey:[...$e,s.length],enabled:s.length>0,queryFn:()=>n.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-et,limit:tt,projection:`slim`})});if(o.isLoading||u.isLoading)return l(T,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):l(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>r(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[l(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}n();var dt=1440*60*1e3,ft=[1,7,30,90];function pt(){let{t:e}=G(),t=O(),[n,o]=s(7),c=i(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(n-1)*dt},[n]),u=a({queryKey:ae,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=a({queryKey:[...le,n],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),f=i(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),p=i(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>e.day},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:f.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>String(e.calls)},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:e.errorCalls>0?`text-danger`:void 0,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>`${String(e.inputTokens)} / ${String(e.outputTokens)}`},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>String(Math.round(e.avgLatencyMs))}],[f,e]),m=d.data??[];return r(J,{embedded:!0,icon:S,title:e(`ai.usageTitle`,`Usage`),subtitle: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.`),actions:l(`div`,{className:`w-40`,children:l(P,{"aria-label":e(`ai.window`,`Window`),value:String(n),options:ft.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>o(Number(e.target.value))})}),children:[d.isError&&l(re,{title:e(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:e(`common.error`,`Error`),onRetry:()=>void d.refetch()}),m.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noUsage`,`No AI calls in this window.`)}):l(R,{headingId:`ai-usage-list`,title:e(`ai.usageList`,`Rollup`),children:l(F,{columns:p,rows:m,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,mobileMode:`scroll`,maxBodyHeight:L})})]})}function mt(){let{t:e}=G(),t=K(`/system/ai`,{t:e,isAdmin:!0})??{icon:C,title:e(`system.ai`,`AI`)};return l(q,{icon:t.icon,title:t.title,defaultSection:`profiles`,sectionsLabel:`${t.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:l(Pe,{})},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:l(Re,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:l(pt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:l(it,{})}]})}export{mt as AiProfilesPage,mt as default};
@@ -1 +0,0 @@
1
- import{Q as e,S as t,W as n,q as r,x as i,z as a}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{ar as o}from"./player-overlays-DWMIy1MJ.js";import{vi as s}from"./client-CjyKfSu1.js";import{Bn as c,Sn as l,bi as u,pi as d}from"./src-BLkInT8U.js";import{F as f}from"./index-D66JvELZ.js";e();function p(e,t){let n=e=>e.map(e=>e.type===`group`?{...e,fields:n(e.fields)}:e.type===`sub-tabs`?{...e,tabs:e.tabs.map(e=>({...e,fields:n(e.fields)}))}:e.type===`info`&&typeof e.content==`string`?{...e,content:e.content.split(`{{brokerId}}`).join(t)}:e);return{...e,sections:e.sections.map(e=>({...e,fields:n(e.fields)}))}}function m(e,t){if(!e)return t;let n=new Set;for(let r of e.sections){let e=r.fields;for(let r of e)!(`key`in r)||typeof r.key!=`string`||l(r,t,e)&&n.add(r.key)}let r={};for(let[e,i]of Object.entries(t))n.has(e)&&(r[e]=i);return r}function h({kind:e,addonId:l,brokerId:h,initialValues:g,onSubmit:_,onCancel:v,submitLabel:y,disabled:b}){let[x,S]=r(g??{}),[C,w]=r(null),T=d({kind:e,...l===void 0?{}:{addonId:l}}),E=n(()=>{let e=T.data;if(e&&typeof e==`object`&&`sections`in e&&Array.isArray(e.sections)){let t=e;return s(h===void 0?t:p(t,h),x)}},[T.data,h,x]);a(()=>{g!==void 0&&S(g)},[g]);let D=u(),O=async()=>{w(null);let t=m(E,x);try{let n=await D.mutateAsync({kind:e,settings:t,...l===void 0?{}:{addonId:l}});w(n.ok?{ok:!0}:{ok:!1,error:n.error})}catch(e){w({ok:!1,error:e instanceof Error?e.message:String(e)})}};return t(`div`,{className:`space-y-3`,children:[T.isLoading&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(o,{className:`h-3.5 w-3.5 animate-spin`}),` Loading schema…`]}),E&&i(f,{schema:E,values:x,onChange:S}),T.isError&&t(`div`,{className:`rounded border border-danger/30 bg-danger/5 text-danger px-3 py-2 text-[11px]`,children:[`Failed to load settings schema:`,` `,T.error instanceof Error?T.error.message:`Unknown error`]}),!E&&!T.isLoading&&!T.isError&&t(`div`,{className:`rounded border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-[11px] text-amber-700 dark:text-amber-300`,children:[`No settings schema available for kind `,i(`code`,{className:`font-mono`,children:e}),`. Its broker addon may not be installed or running.`]}),C&&i(`div`,{className:`rounded border px-3 py-2 text-[11px] ${C.ok?`border-success/30 bg-success/5 text-success`:`border-danger/30 bg-danger/5 text-danger`}`,children:C.ok?`Connection OK.`:`Test failed: ${C.error??`unknown error`}`}),t(`div`,{className:`flex items-center justify-between gap-2 pt-1`,children:[i(c,{variant:`outline`,size:`sm`,onClick:v,children:`Cancel`}),t(`div`,{className:`flex items-center gap-2`,children:[i(c,{variant:`outline`,size:`sm`,onClick:()=>{O()},disabled:D.isPending||!E,children:D.isPending?`Testing…`:`Test connection`}),i(c,{variant:`primary`,size:`sm`,onClick:()=>{let{_calendarCatalog:e,...t}=m(E,x);_(t)},disabled:!E||b,children:y??`Save`})]})]})]})}export{h as t};