@camstack/addon-admin-ui 1.2.409 → 1.2.411

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 (104) hide show
  1. package/dist/assets/{AddonAssetIcon-KJCtp42U.js → AddonAssetIcon-D8iI-KCZ.js} +1 -1
  2. package/dist/assets/Addons-C5JY2AfL.js +4 -0
  3. package/dist/assets/{AdminPage-R4K39PzI.js → AdminPage-ag0ooKaL.js} +1 -1
  4. package/dist/assets/{AdminSectionedPage-BoWdF1ZC.js → AdminSectionedPage-CAC1tbqj.js} +1 -1
  5. package/dist/assets/AiProfiles-nF-d_2b-.js +3 -0
  6. package/dist/assets/{BrokerForm-C1K8cn2X.js → BrokerForm-D-veZ8r_.js} +1 -1
  7. package/dist/assets/Build-BO-c5rW0.js +40 -0
  8. package/dist/assets/{Calendars-C4QYfydi.js → Calendars-BMuzFS5L.js} +1 -1
  9. package/dist/assets/Cluster-B5LvOBTI.js +1 -0
  10. package/dist/assets/ClusterStepModel-DnSR4tlP.js +1 -0
  11. package/dist/assets/{CompositionEditor-Bx2LmaUP.js → CompositionEditor-UGFbz15p.js} +1 -1
  12. package/dist/assets/{CompositionEditorPage-D8jTF1c4.js → CompositionEditorPage-C5_CkU8D.js} +1 -1
  13. package/dist/assets/Data-Dm-IMaz-.js +1 -0
  14. package/dist/assets/DeviceDetail-DXYeAub5.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-C1jGp-mA.js → DeviceDoActionFields-Bi8ACMvr.js} +1 -1
  16. package/dist/assets/{Devices-_dbgbucP.js → Devices-yzpwWXqp.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-DGzoqqeD.js → EmbedPlayerPage-DjeW_rTr.js} +1 -1
  18. package/dist/assets/Identity-Dx31w2Vy.js +1 -0
  19. package/dist/assets/IntegrationDetail-BEEj3VrA.js +1 -0
  20. package/dist/assets/{IntegrationHub-D-aRvLOD.js → IntegrationHub-DjC2oVp0.js} +1 -1
  21. package/dist/assets/Integrations-CAbitj49.js +1 -0
  22. package/dist/assets/{Integrations-iSBQbbQt.js → Integrations-WyRK4N1k.js} +1 -1
  23. package/dist/assets/Library-CZpqcnrI.js +1 -0
  24. package/dist/assets/Locations-CxcAxmGc.js +3 -0
  25. package/dist/assets/{Logs-CiWybGXO.js → Logs-CknEKxXB.js} +1 -1
  26. package/dist/assets/{MotionZonesSettings-DhMK0JPN.js → MotionZonesSettings-evsXZ-jK.js} +1 -1
  27. package/dist/assets/{MyAccess-BFtpfycT.js → MyAccess-CQf-w9GX.js} +1 -1
  28. package/dist/assets/Network-M1v_DQYy.js +1 -0
  29. package/dist/assets/{NodeAddonsSettingsPanel-DO4Hfmpb.js → NodeAddonsSettingsPanel-BkE4c6Nf.js} +1 -1
  30. package/dist/assets/Notifications-DtZ4UX1O.js +1 -0
  31. package/dist/assets/{PrivacyMaskSettings-Cak09YC0.js → PrivacyMaskSettings-C0Di56NN.js} +1 -1
  32. package/dist/assets/Recordings-V-A6EoJs.js +1 -0
  33. package/dist/assets/{ScanNetworkModal-B2ilodO7.js → ScanNetworkModal-DaHDtE3d.js} +1 -1
  34. package/dist/assets/{SceneMonitorEditor-CZ5solPA.js → SceneMonitorEditor-BzZ9SeCX.js} +1 -1
  35. package/dist/assets/{SessionsList-DPlgw82K.js → SessionsList-BWWW0tpL.js} +2 -2
  36. package/dist/assets/{Showroom-Cb5NnI-I.js → Showroom-C6kvHxpc.js} +1 -1
  37. package/dist/assets/System-fYBzKo6o.js +1 -0
  38. package/dist/assets/{Terminal-Dpp6Pvp9.js → Terminal-DGCOOqZt.js} +5 -5
  39. package/dist/assets/{Viewer-Bln4zwVN.js → Viewer-CHTg541S.js} +1 -1
  40. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C2E5u9h7.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-C0V_Ve84.js} +1 -1
  41. package/dist/assets/{archive-DYTHbsU8.js → archive-Bzv2DmvH.js} +1 -1
  42. package/dist/assets/{authed-media-D-WNx3kT.js → authed-media-BnZp89Ya.js} +1 -1
  43. package/dist/assets/{boxes-2Ii8Cw-P.js → boxes-2dkn6KvM.js} +1 -1
  44. package/dist/assets/circle-slash-BXiLL6q3.js +1 -0
  45. package/dist/assets/client-Bug9W0HP.js +357 -0
  46. package/dist/assets/crop-jpDa83SU.js +1 -0
  47. package/dist/assets/{device-integration-icon-7CvdEsXK.js → device-integration-icon-D59GdgtP.js} +1 -1
  48. package/dist/assets/device-picker-model-NCEu1Koc.js +1 -0
  49. package/dist/assets/{dist-CbS8Wt77.js → dist-XfP6nUa1.js} +1 -1
  50. package/dist/assets/dist-m91QqM3B.js +357 -0
  51. package/dist/assets/{format-size-ByLX8H4V.js → format-size-BmGEgtZE.js} +1 -1
  52. package/dist/assets/{history-8a1zQ_IL.js → history-Bfo51EO_.js} +1 -1
  53. package/dist/assets/{hostInit-BncFFvvZ.js → hostInit-DExLXr0I.js} +1 -1
  54. package/dist/assets/index-DgpFlZtW.js +4 -0
  55. package/dist/assets/{index-CpWRVftE.css → index-rqr1SRyg.css} +1 -1
  56. package/dist/assets/{layers-BQApB38m.js → layers-JXtgkqKO.js} +1 -1
  57. package/dist/assets/{location-owned-usage-oH3gIpK5.js → location-owned-usage-BwuAy59Z.js} +1 -1
  58. package/dist/assets/{log-in-DQztm9HI.js → log-in-CLHMAmC6.js} +1 -1
  59. package/dist/assets/{mf-entry-bootstrap-0-2047ccad.js → mf-entry-bootstrap-0-92776d52.js} +2 -2
  60. package/dist/assets/{monitor-smartphone--t7IlgKO.js → monitor-smartphone-vRItleqP.js} +1 -1
  61. package/dist/assets/mount-NCEu1Koc.js +1 -0
  62. package/dist/assets/notification-schedule-field-HuSVn6TA.js +1 -0
  63. package/dist/assets/{octagon-alert-D_UEMtBK.js → octagon-alert-BMnKz1If.js} +1 -1
  64. package/dist/assets/{player-overlays-BzBTCjWR.js → player-overlays-DuTESHep.js} +1 -1
  65. package/dist/assets/remoteEntry-BsBo0iQF.js +1 -0
  66. package/dist/assets/{send-C5kLO34E.js → send-DNGz2E6E.js} +1 -1
  67. package/dist/assets/{settings-2-CnztS9Vg.js → settings-2-BWgwUK0a.js} +1 -1
  68. package/dist/assets/{src-DTW2ew69.js → src-CQqBpUBT.js} +17 -17
  69. package/dist/assets/{use-scenes-feed-DX7Oajuk.js → use-scenes-feed-DgIBL35t.js} +1 -1
  70. package/dist/assets/{use-stationary-objects-BDMOQ0As.js → use-stationary-objects-Dhz2_wZf.js} +1 -1
  71. package/dist/assets/useEventInvalidation-NCEu1Koc.js +1 -0
  72. package/dist/assets/{useNodeUrlSelection-BsOqZeMQ.js → useNodeUrlSelection-DC4zvSpS.js} +1 -1
  73. package/dist/assets/user-round-CZhaQwMK.js +1 -0
  74. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-DDYwkDjw.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-BeJNZsYC.js} +2 -2
  75. package/dist/index.html +8 -8
  76. package/dist/server/addon.js +248 -6
  77. package/package.json +1 -1
  78. package/dist/assets/Addons-Cf-Dyck1.js +0 -4
  79. package/dist/assets/AiProfiles-BP3poExj.js +0 -3
  80. package/dist/assets/Build-BLkaHIJM.js +0 -40
  81. package/dist/assets/Cluster-Bd-CmBSd.js +0 -1
  82. package/dist/assets/ClusterStepModel-CIfgLb6o.js +0 -1
  83. package/dist/assets/Data-Czxp6lZi.js +0 -1
  84. package/dist/assets/DeviceDetail-B3Wc5I0m.js +0 -2
  85. package/dist/assets/Identity-3mHyrOOC.js +0 -1
  86. package/dist/assets/IntegrationDetail-DDeDSMEg.js +0 -1
  87. package/dist/assets/Integrations-CZaPcjNr.js +0 -1
  88. package/dist/assets/Library-Dvfx2TdY.js +0 -1
  89. package/dist/assets/Locations-BLp4xpak.js +0 -3
  90. package/dist/assets/Network-Bh_tfjTi.js +0 -1
  91. package/dist/assets/Notifications-DUDKlbWb.js +0 -1
  92. package/dist/assets/Recordings-BhQgjum7.js +0 -1
  93. package/dist/assets/System-_78LWf0j.js +0 -1
  94. package/dist/assets/circle-slash-O1R3fbRQ.js +0 -1
  95. package/dist/assets/client-5au8Dz4T.js +0 -357
  96. package/dist/assets/crop-CQKehVwH.js +0 -1
  97. package/dist/assets/device-picker-model-DFS6Au1R.js +0 -1
  98. package/dist/assets/dist-DX2-N4Ok.js +0 -357
  99. package/dist/assets/index-BOZXWZFq.js +0 -4
  100. package/dist/assets/mount-DFS6Au1R.js +0 -1
  101. package/dist/assets/notification-schedule-field-BPNXphLN.js +0 -1
  102. package/dist/assets/remoteEntry-CBgDnSiW.js +0 -1
  103. package/dist/assets/useEventInvalidation-DFS6Au1R.js +0 -1
  104. package/dist/assets/user-round-sBwbE8j8.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-vWTnHq9G.mjs
5391
+ //#region ../types/dist/sleep-BBF1iXUi.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).
@@ -10122,6 +10122,15 @@ discriminatedUnion("type", [
10122
10122
  message: string()
10123
10123
  })
10124
10124
  ]);
10125
+ /** Every status, in the order a summary lists them. */
10126
+ var RETRAIN_REVIEW_STATUSES = [
10127
+ "unchanged",
10128
+ "adjusted",
10129
+ "reclassified",
10130
+ "added",
10131
+ "removed",
10132
+ "model-error"
10133
+ ];
10125
10134
  /**
10126
10135
  * What the gate decided about a birth, from the CALLER's point of view.
10127
10136
  *
@@ -13885,6 +13894,16 @@ var BrokerClientsSchema = object({
13885
13894
  /** Total encoded + raw-RTP callback subscriber count (sum of `encoded[].length`). */
13886
13895
  encodedSubscribers: number()
13887
13896
  });
13897
+ /**
13898
+ * How many people are watching one camera LIVE right now — see
13899
+ * `getLiveViewerCounts`. A camera with nobody watching is absent from the list
13900
+ * (so `viewers` is always at least 1): the listing carries the cameras that
13901
+ * have viewers, never a row of zeros.
13902
+ */
13903
+ var LiveViewerCountSchema = object({
13904
+ deviceId: number().int().nonnegative(),
13905
+ viewers: number().int().positive()
13906
+ });
13888
13907
  _enum([
13889
13908
  "reconnecting",
13890
13909
  "sleeping",
@@ -14245,7 +14264,7 @@ method(object({
14245
14264
  }), {
14246
14265
  kind: "mutation",
14247
14266
  auth: "admin"
14248
- }), method(object({ brokerId: string() }), BrokerClientsSchema), method(object({
14267
+ }), method(object({ brokerId: string() }), BrokerClientsSchema), method(_void(), array(LiveViewerCountSchema).readonly()), method(object({
14249
14268
  brokerId: string(),
14250
14269
  channel: _enum(["rtsp", "audio"]),
14251
14270
  handle: string()
@@ -15193,6 +15212,38 @@ var BulkRecordSchema = object({
15193
15212
  data: record(string(), unknown())
15194
15213
  });
15195
15214
  /**
15215
+ * One write inside a {@link settingsStoreCapability.methods.transact} call.
15216
+ * Only the three that a "replace this set, bump that revision" write needs.
15217
+ */
15218
+ var TransactOpSchema = discriminatedUnion("op", [
15219
+ object({
15220
+ op: literal("deleteWhere"),
15221
+ collection: string(),
15222
+ filter: MutationFilterSchema
15223
+ }),
15224
+ object({
15225
+ op: literal("insertMany"),
15226
+ collection: string(),
15227
+ records: array(BulkRecordSchema).readonly()
15228
+ }),
15229
+ object({
15230
+ op: literal("update"),
15231
+ collection: string(),
15232
+ id: string(),
15233
+ data: record(string(), unknown())
15234
+ })
15235
+ ]);
15236
+ /**
15237
+ * The precondition of a transaction: the row `key` of `collection` must hold
15238
+ * `equals` in `column`, read INSIDE the transaction.
15239
+ */
15240
+ var TransactGuardSchema = object({
15241
+ collection: string(),
15242
+ key: string(),
15243
+ column: string(),
15244
+ equals: unknown()
15245
+ });
15246
+ /**
15196
15247
  * Column declaration for a structured (SQL-backed) collection.
15197
15248
  *
15198
15249
  * Logical types — the backend translates each to the matching SQLite
@@ -15283,6 +15334,16 @@ id: union([string(), number()]) }), {
15283
15334
  }), object({ inserted: number().int() }), {
15284
15335
  kind: "mutation",
15285
15336
  auth: "admin"
15337
+ }), method(object({
15338
+ namespace: string().optional(),
15339
+ guard: TransactGuardSchema.optional(),
15340
+ ops: array(TransactOpSchema).readonly()
15341
+ }), object({
15342
+ applied: boolean(),
15343
+ current: unknown().optional()
15344
+ }), {
15345
+ kind: "mutation",
15346
+ auth: "admin"
15286
15347
  }), method(object({
15287
15348
  namespace: string().optional(),
15288
15349
  collection: string(),
@@ -15431,6 +15492,16 @@ id: union([string(), number()]) }), {
15431
15492
  }), object({ inserted: number().int() }), {
15432
15493
  kind: "mutation",
15433
15494
  auth: "admin"
15495
+ }), method(object({
15496
+ namespace: string().optional(),
15497
+ guard: TransactGuardSchema.optional(),
15498
+ ops: array(TransactOpSchema).readonly()
15499
+ }), object({
15500
+ applied: boolean(),
15501
+ current: unknown().optional()
15502
+ }), {
15503
+ kind: "mutation",
15504
+ auth: "admin"
15434
15505
  }), method(object({
15435
15506
  namespace: string().optional(),
15436
15507
  collection: string(),
@@ -23843,6 +23914,55 @@ var RetrainBboxSchema = object({
23843
23914
  h: number()
23844
23915
  });
23845
23916
  /**
23917
+ * What a box LOOKED LIKE when it was offered, snapshotted at the moment the
23918
+ * operator accepted it. The saved row keeps only the final rectangle; this is
23919
+ * the other half of the pair, and the pair is what says whether the operator
23920
+ * accepted, nudged, relabelled or replaced a proposal (`retrain-review.ts`).
23921
+ *
23922
+ * `ref` names the proposal inside its frame: `pipeline:<trackId>` for a box the
23923
+ * live pipeline drew, `assist:<n>` for the n-th box of a detector or LLM run,
23924
+ * and anything unique for an operator-drawn box (`operator:<n>`). Re-derived
23925
+ * pipeline boxes carry the same ref every time, which is what lets a dismissal
23926
+ * stay dismissed.
23927
+ */
23928
+ var RetrainOriginSchema = object({
23929
+ source: RetrainAnnotationSourceSchema,
23930
+ ref: string().min(1),
23931
+ bbox: RetrainBboxSchema,
23932
+ macroClass: RetrainMacroClassSchema,
23933
+ label: string().optional(),
23934
+ score: number().optional(),
23935
+ modelId: string().optional()
23936
+ });
23937
+ /**
23938
+ * A proposal the operator deleted. Durable on the frame, so a deleted pipeline
23939
+ * box does not come back as a draft every time the frame is reopened, and so
23940
+ * the deletion itself is a recorded fact rather than an absence.
23941
+ */
23942
+ var RetrainDismissedSchema = object({
23943
+ ref: string().min(1),
23944
+ snapshot: RetrainOriginSchema
23945
+ });
23946
+ /** What the operator did with a proposal (see `retrain-review.ts`). */
23947
+ var RetrainReviewStatusSchema = _enum(RETRAIN_REVIEW_STATUSES);
23948
+ var RetrainFrameReviewSchema = object({
23949
+ boxes: array(object({
23950
+ ref: string(),
23951
+ savedId: string().optional(),
23952
+ status: RetrainReviewStatusSchema,
23953
+ /** The baseline was re-derived, not snapshotted (a pre-origin row). */
23954
+ approximate: boolean(),
23955
+ origin: RetrainOriginSchema.optional(),
23956
+ iou: number().optional()
23957
+ })).readonly(),
23958
+ summary: object({
23959
+ counts: record(RetrainReviewStatusSchema, number().int()),
23960
+ total: number().int(),
23961
+ changed: number().int(),
23962
+ approximate: boolean()
23963
+ })
23964
+ });
23965
+ /**
23846
23966
  * One annotated subject.
23847
23967
  *
23848
23968
  * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
@@ -23866,6 +23986,9 @@ var RetrainAnnotationSchema = object({
23866
23986
  /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
23867
23987
  assistModelId: string().optional(),
23868
23988
  assistScore: number().optional(),
23989
+ /** The proposal this box started from, snapshotted at accept time. `null` on
23990
+ * a row saved before origins existed; absent on a draft nobody snapshotted. */
23991
+ origin: RetrainOriginSchema.nullable().optional(),
23869
23992
  exportedInBatch: string().optional(),
23870
23993
  createdAt: number()
23871
23994
  });
@@ -23958,7 +24081,19 @@ var RetrainFrameSchema = object({
23958
24081
  * empty when nothing the track store holds can be placed on it. */
23959
24082
  pipelineBoxes: array(RetrainPipelineBoxSchema).readonly().optional(),
23960
24083
  /** The named collections this frame belongs to. Present on list answers. */
23961
- collectionIds: array(string()).readonly().optional()
24084
+ collectionIds: array(string()).readonly().optional(),
24085
+ /** Bumped by every annotation save. A save that names a stale
24086
+ * `expectedRevision` is refused, so two surfaces cannot overwrite each other. */
24087
+ revision: number().int().optional(),
24088
+ /** Proposals the operator deleted — never re-seeded as drafts. */
24089
+ dismissed: array(RetrainDismissedSchema).readonly().optional(),
24090
+ /** What the operator did with the proposals, computed by the server. */
24091
+ review: RetrainFrameReviewSchema.optional(),
24092
+ /** The frame's pixels over the admin data plane (full size). Fetch with the
24093
+ * admin bearer token; relative to the hub root. */
24094
+ imageUrl: string().optional(),
24095
+ /** The same, as a ~480 px thumbnail for grids. */
24096
+ thumbnailUrl: string().optional()
23962
24097
  });
23963
24098
  /** Why a copy-on-select could not be honoured — named, never a silent skip. */
23964
24099
  var RetrainCopyRefusalSchema = _enum([
@@ -25037,10 +25172,33 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
25037
25172
  /** The frame's track, when it has one — checked against the frame. */
25038
25173
  trackId: string().optional(),
25039
25174
  frameId: string(),
25040
- annotations: array(RetrainAnnotationDraftSchema)
25175
+ annotations: array(RetrainAnnotationDraftSchema),
25176
+ /** The frame's `revision` the caller saw. A different current revision
25177
+ * refuses the save with a `retrain-revision-conflict` error
25178
+ * (`parseRetrainRevisionConflict`). Absent ⇒ last write wins. */
25179
+ expectedRevision: number().int().optional(),
25180
+ /** The proposals the operator deleted. Absent ⇒ keep the frame's
25181
+ * current set; present ⇒ replace it (an empty array un-dismisses). */
25182
+ dismissed: array(RetrainDismissedSchema).optional()
25041
25183
  }), array(RetrainAnnotationSchema).readonly(), {
25042
25184
  kind: "mutation",
25043
25185
  auth: "admin"
25186
+ }), method(object({
25187
+ deviceId: number(),
25188
+ trackId: string().optional(),
25189
+ frameId: string(),
25190
+ expectedRevision: number().int().optional(),
25191
+ origins: array(object({
25192
+ annotationId: string(),
25193
+ origin: RetrainOriginSchema
25194
+ })).min(1).max(500)
25195
+ }), object({
25196
+ updated: number().int(),
25197
+ skipped: number().int(),
25198
+ revision: number().int()
25199
+ }), {
25200
+ kind: "mutation",
25201
+ auth: "admin"
25044
25202
  }), method(object({
25045
25203
  deviceId: number(),
25046
25204
  trackId: string()
@@ -27656,6 +27814,12 @@ var CameraStepOverridePatchSchema = object({
27656
27814
  settings: record(string(), unknown()).readonly().optional()
27657
27815
  });
27658
27816
  var CameraStepSettingsSchema = record(string(), record(string(), unknown()).readonly());
27817
+ /** The three root-detector choices a camera has (D507: at most one root). */
27818
+ var CameraDetectionSourceSchema = _enum([
27819
+ "pipeline",
27820
+ "onboard",
27821
+ "none"
27822
+ ]);
27659
27823
  var CameraPipelineSettingsSchema = object({
27660
27824
  stepToggles: record(string(), boolean()).optional(),
27661
27825
  stepSettings: CameraStepSettingsSchema.optional(),
@@ -28233,6 +28397,26 @@ method(object({
28233
28397
  }), object({ success: literal(true) }), {
28234
28398
  kind: "mutation",
28235
28399
  auth: "admin"
28400
+ }), method(object({ deviceId: number() }), object({
28401
+ source: CameraDetectionSourceSchema,
28402
+ explicit: boolean(),
28403
+ onboard: object({
28404
+ /** The camera has an onboard detector this system can read. */
28405
+ available: boolean(),
28406
+ /** What its detections carry — a camera with no box cannot be a root step. */
28407
+ geometry: _enum([
28408
+ "boxed",
28409
+ "while-streaming",
28410
+ "flag-only",
28411
+ "unknown"
28412
+ ])
28413
+ })
28414
+ })), method(object({
28415
+ deviceId: number(),
28416
+ source: CameraDetectionSourceSchema
28417
+ }), object({ success: literal(true) }), {
28418
+ kind: "mutation",
28419
+ auth: "admin"
28236
28420
  }), method(object({ deviceId: number() }), record(string(), record(string(), record(string(), CameraStepOverridePatchSchema))).nullable()), method(object({
28237
28421
  deviceId: number(),
28238
28422
  agentNodeId: string(),
@@ -34790,7 +34974,14 @@ var TopologyNodeSchema = object({
34790
34974
  * completed a mutual-TLS handshake, `clear` otherwise. Absent for the hub,
34791
34975
  * for offline rows and when the hub cannot tell.
34792
34976
  */
34793
- meshTransport: _enum(["tls", "clear"]).optional()
34977
+ meshTransport: _enum(["tls", "clear"]).optional(),
34978
+ /**
34979
+ * Whether the hub holds this online AGENT's capability registration (its
34980
+ * `registerNode` manifest). `false` = online in the mesh but not ready: the
34981
+ * hub dropped the registration on a disconnect only it saw and the agent has
34982
+ * not re-sent it. Absent for the hub and offline rows.
34983
+ */
34984
+ capabilitiesRegistered: boolean().optional()
34794
34985
  });
34795
34986
  var CapUsageEdgeSchema = object({
34796
34987
  callerAddonId: string(),
@@ -41328,6 +41519,12 @@ Object.freeze({
41328
41519
  addonId: null,
41329
41520
  access: "create"
41330
41521
  },
41522
+ "dataStoreProvider.transact": {
41523
+ capName: "data-store-provider",
41524
+ capScope: "system",
41525
+ addonId: null,
41526
+ access: "create"
41527
+ },
41331
41528
  "dataStoreProvider.update": {
41332
41529
  capName: "data-store-provider",
41333
41530
  capScope: "system",
@@ -44172,6 +44369,12 @@ Object.freeze({
44172
44369
  addonId: null,
44173
44370
  access: "create"
44174
44371
  },
44372
+ "pipelineAnalytics.backfillRetrainOrigins": {
44373
+ capName: "pipeline-analytics",
44374
+ capScope: "device",
44375
+ addonId: null,
44376
+ access: "create"
44377
+ },
44175
44378
  "pipelineAnalytics.cancelRelocateMedia": {
44176
44379
  capName: "pipeline-analytics",
44177
44380
  capScope: "device",
@@ -44952,6 +45155,12 @@ Object.freeze({
44952
45155
  addonId: null,
44953
45156
  access: "view"
44954
45157
  },
45158
+ "pipelineOrchestrator.getCameraDetectionSource": {
45159
+ capName: "pipeline-orchestrator",
45160
+ capScope: "system",
45161
+ addonId: null,
45162
+ access: "view"
45163
+ },
44955
45164
  "pipelineOrchestrator.getCameraMetrics": {
44956
45165
  capName: "pipeline-orchestrator",
44957
45166
  capScope: "system",
@@ -45180,6 +45389,12 @@ Object.freeze({
45180
45389
  addonId: null,
45181
45390
  access: "create"
45182
45391
  },
45392
+ "pipelineOrchestrator.setCameraDetectionSource": {
45393
+ capName: "pipeline-orchestrator",
45394
+ capScope: "system",
45395
+ addonId: null,
45396
+ access: "create"
45397
+ },
45183
45398
  "pipelineOrchestrator.setCameraPipelineForAgent": {
45184
45399
  capName: "pipeline-orchestrator",
45185
45400
  capScope: "system",
@@ -46152,6 +46367,12 @@ Object.freeze({
46152
46367
  addonId: null,
46153
46368
  access: "create"
46154
46369
  },
46370
+ "settingsStore.transact": {
46371
+ capName: "settings-store",
46372
+ capScope: "system",
46373
+ addonId: null,
46374
+ access: "create"
46375
+ },
46155
46376
  "settingsStore.update": {
46156
46377
  capName: "settings-store",
46157
46378
  capScope: "system",
@@ -46632,6 +46853,12 @@ Object.freeze({
46632
46853
  addonId: null,
46633
46854
  access: "view"
46634
46855
  },
46856
+ "streamBroker.getLiveViewerCounts": {
46857
+ capName: "stream-broker",
46858
+ capScope: "system",
46859
+ addonId: null,
46860
+ access: "view"
46861
+ },
46635
46862
  "streamBroker.getPreBufferInfo": {
46636
46863
  capName: "stream-broker",
46637
46864
  capScope: "system",
@@ -50472,6 +50699,11 @@ Object.freeze({
50472
50699
  form: "single",
50473
50700
  optional: false
50474
50701
  }],
50702
+ "pipelineAnalytics.backfillRetrainOrigins": [{
50703
+ name: "deviceId",
50704
+ form: "single",
50705
+ optional: false
50706
+ }],
50475
50707
  "pipelineAnalytics.clearTrackRelation": [{
50476
50708
  name: "deviceId",
50477
50709
  form: "single",
@@ -50777,6 +51009,11 @@ Object.freeze({
50777
51009
  form: "single",
50778
51010
  optional: false
50779
51011
  }],
51012
+ "pipelineOrchestrator.getCameraDetectionSource": [{
51013
+ name: "deviceId",
51014
+ form: "single",
51015
+ optional: false
51016
+ }],
50780
51017
  "pipelineOrchestrator.getCameraMetrics": [{
50781
51018
  name: "deviceId",
50782
51019
  form: "single",
@@ -50837,6 +51074,11 @@ Object.freeze({
50837
51074
  form: "single",
50838
51075
  optional: false
50839
51076
  }],
51077
+ "pipelineOrchestrator.setCameraDetectionSource": [{
51078
+ name: "deviceId",
51079
+ form: "single",
51080
+ optional: false
51081
+ }],
50840
51082
  "pipelineOrchestrator.setCameraPipelineForAgent": [{
50841
51083
  name: "deviceId",
50842
51084
  form: "single",
@@ -52833,7 +53075,7 @@ var AdminUIAddon = class extends BaseAddon {
52833
53075
  capability: adminUiCapability,
52834
53076
  provider: {
52835
53077
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
52836
- getVersion: async () => ({ version: "1.2.409" })
53078
+ getVersion: async () => ({ version: "1.2.411" })
52837
53079
  }
52838
53080
  }];
52839
53081
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.409",
3
+ "version": "1.2.411",
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{Q as d,_t as f,ct as p}from"./player-overlays-BzBTCjWR.js";import{$u as m,An as h,Ar as g,Br as _,Cr as v,Dr as y,Ed as b,Er as x,Eu as S,Fn as C,Fr as ee,Gn as te,Gr as w,Hr as ne,In as T,Ir as E,Kr as re,Lr as ie,Mn as ae,Nr as D,Or as oe,Pn as se,Pr as O,Q as ce,Qu as k,Tr as A,Tt as le,U as j,Uu as M,Vr as N,Wr as ue,Xu as de,Yd as P,ad as F,cd as I,dd as fe,es as pe,ff as L,hd as R,jn as me,jr as z,kr as B,ku as V,mu as he,nf as H,nr as U,sf as ge,su as W,tr as G,uf as _e,uu as K,wt as ve,zr as ye}from"./src-DTW2ew69.js";import{t as q}from"./octagon-alert-D_UEMtBK.js";import{yi as be}from"./client-5au8Dz4T.js";import"./mount-DFS6Au1R.js";import{$ as xe,Z as Se,rt as J}from"./index-BOZXWZFq.js";import{t as Y}from"./AdminPage-R4K39PzI.js";import{t as X}from"./NodeAddonsSettingsPanel-DO4Hfmpb.js";import{n as Z,t as Q}from"./useNodeUrlSelection-BsOqZeMQ.js";n();var Ce={queued:{icon:H,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:b,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:F,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:L,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:q,bg:`bg-danger/10 text-danger`,label:`failed`}};function we({item:e}){let t=Ce[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 Te=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Ee=new Set([`done`,`failed`,`skipped`]);function De(e){return!Ee.has(e.phase)&&!Te.has(e.jobState)}function Oe(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Te.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 ke(){let{data:e}=O({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=K(be.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 Oe([...n.values()],Date.now())},[e,t])}var Ae={queued:{icon:H,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:b,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:b,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:b,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:b,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:b,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:b,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:L,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:q,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:M,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function je({progress:e}){let t=Ae[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 Me(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 Ne(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function Pe(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(Ne)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function Fe(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 Ie={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function Le(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)}: ${Ie[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 Re={},ze=3e4,Be=`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 Ve({packageName:e,displayName:t,selectedNode:n,hideNodeAction:r,disabled:a}){let o=s(),c=U(),u=G(),d=D(Re,{staleTime:ze}),f=d.data?.installations??[],m=(d.data?.unreachable??[]).map(e=>e.nodeId),h=Me(f,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===n.id?n.name:e),_=w({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:Le(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:Fe(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=Me(n.installations,e);await c({title:`Uninstall ${t} everywhere?`,message:Pe(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:Be,title:`Uninstall from ${n.name}`,children:[l(p,{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:Be,title:`Uninstall from every node that has it`,children:[l(J,{className:`h-3 w-3`}),`Everywhere`,h.length>0?` (${h.length})`:``]})]})}function He({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:d,isLoading:f}=B({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(he,{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(S,{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.`]})]}),f&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(b,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),d&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:d.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),d=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:[d,a?l(L,{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:[d,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(P,{className:`h-3 w-3`})})]},e.version)})}),d&&d.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}n();var Ue=`device-export`;function We(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Ue)}function Ge(e){return e!==`local`&&e!==`upload`}function Ke({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,f=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=n&&r?d(`/api/addon-assets/${n}/${r}`):null,m=!!p&&!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?``:f}`,style:u,children:m?l(`img`,{src:p,alt:n,className:`h-4 w-4`,onError:()=>s(!0)}):l(e?R:I,{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`}),Ge(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(S,{className:`h-2.5 w-2.5 text-white`})})]})}function qe({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(b,{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(P,{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(f,{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(f,{className:`h-3 w-3 opacity-50`})]}),u]})}function Je({addonId:e}){let t=s(),{data:n=`inherit`}=x({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 Ye={id:`hub`,name:`Hub`,isHub:!0};function Xe({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:d,isUpdating:p,jobProgress:_,bundle:v,bulkItem:y,disabledByBulk:b,isSystem:x,selectedNode:S}){let[ee,w]=c(!1),[ne,E]=c(!1),[re,D]=c(!1),[oe,O]=c(null);u(()=>{O(null)},[a]);let k=oe??a,[A,j]=c(!1),[M,N]=c(!1),[ue,P]=c(`logs`),I=s(),pe=Se(),{manifest:L}=e,z=e.installedOn??[],B=!v&&!L.protected&&L.removable!==!1,V=!!v,H=v?.displayName??L.name,U=v?.packageName??L.packageName,ge=v?.version??L.packageVersion??L.version,W=v?.installSource??e.installSource,G=v?v.bundle?.description??v.addons[0]?.manifest.description:L.description,K=ie({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]})}}),be=g({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`addonPages`]]}),I.invalidateQueries({queryKey:[[`capabilities`]]}),I.invalidateQueries({queryKey:[[`integrations`]]})}}),xe=ye({onSuccess:()=>{I.invalidateQueries({queryKey:[[`addons`]]}),I.invalidateQueries({queryKey:[[`alerts`]]})}}),J=e.health,Y=J?.phase===`failed`&&!J.inGracePeriod,Z=Y&&J?.nextRetryAt&&!J.retrying;return i(`div`,{className:`rounded-md border bg-surface overflow-hidden ${Y?`border-red-500/50`:`border-border`}`,children:[Y&&J&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[l(q,{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 #`,J.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:J.lastError?.message??`Unknown error`}),Z&&J.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(J.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:xe.isPending||J.retrying,onClick:e=>{e.stopPropagation(),xe.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(F,{className:`h-3 w-3 ${xe.isPending||J.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[l(Ke,{isBundle:V||!!L.components&&L.components.length>1,installSource:W,addonId:V?v.addons[0]?.manifest.id:L.id,iconPath:V?v.bundle?.icon??v.addons[0]?.manifest.icon:L.icon,color:V?v.addons[0]?.manifest.color:L.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(qe,{version:ge,availableUpdate:a,...k===void 0?{}:{selectedVersion:k},isUpdating:p,installSource:W,disabled:b,...d&&k!==void 0?{onUpdate:()=>d(k)}:{},onOpenPicker:()=>D(e=>!e),children:re&&l(He,{packageName:U,currentVersion:ge,...W?{installSource:W}:{},...a!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{O(e),D(!1)}}:{},onInstall:e=>{D(!1),be.mutate({packageName:U,version:e})},onClose:()=>D(!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(R,{className:`h-3 w-3`}),v.addons.length]}),x&&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(F,{className:`h-3 w-3`}),`System`]}),y!=null&&l(we,{item:y}),_!=null&&l(je,{progress:_})]}),G&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:G}),!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(),K.mutate({addonId:L.id})},disabled:K.isPending||b,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(F,{className:`h-3 w-3 ${K.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),j(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${A?`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(m,{className:`h-3 w-3`}),`Logs`]}),!V&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),N(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${M?`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(de,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),B&&l(Ve,{packageName:L.packageName,displayName:L.name,selectedNode:S??Ye,disabled:b})]}),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))})]}),A&&!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:()=>P(`logs`),className:`px-2 py-0.5 transition-colors ${ue===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>P(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${ue===`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(),j(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(he,{className:`h-3.5 w-3.5`})})]}),ue===`logs`&&l(le,{addonId:L.id,maxHeight:`max-h-64`,showFilters:!1}),ue===`events`&&l(ve,{addonId:L.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>w(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(ee?_e:f,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),ee&&l(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:v.addons.map(e=>l(Xe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),M&&!V&&l(h,{open:!0,onOpenChange:e=>!e&&N(!1),children:i(ae,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(C,{children:i(T,{className:`flex items-center gap-2`,children:[l(de,{className:`h-4 w-4 text-primary`}),H,` Settings`]})}),i(me,{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(X,{nodeId:null,addonIds:[L.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.`}),We(L)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(ce,{addonId:L.id,onOpenDevice:e=>pe(`/devices/${e}`)})]}),Ge(W)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(Je,{addonId:L.id})]}),L.components&&L.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,L.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:L.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:[z.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),z.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(),E(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(fe,{className:`h-3 w-3`}),`Add agent`]}),ne&&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&&!z.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),E(!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&&!z.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(se,{children:l(te,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>N(!1),children:`Close`})})]})})]})}n();var Ze=`.tgz,.tar.gz,.zip`;function Qe({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(d(`/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:Ze,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(b,{className:`w-3.5 h-3.5 animate-spin`}):l(S,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}var $e=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/ui-library`,`@camstack/addon-agent-ui`]);function et(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||$e.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 tt({selectedNode:e}){let{data:t}=D(Re,{staleTime:ze});if(t===void 0)return null;let n=et(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(V,{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(Ve,{packageName:t.packageName,displayName:t.packageName,selectedNode:e,hideNodeAction:e.isHub})]},t.packageName))]})}n();function nt(e){return e===`npm`||e===`dev`?e:null}var rt=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,it=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,at=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],ot=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function st(e){return e!==void 0&&ot.has(e)}var ct={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function lt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function ut(e){return e===`local`?`dev`:`npm`}function dt(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 ft(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 pt({addons:n,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let m=s(),[h,x]=c(``),S=r(h),[C,te]=c(!1),w=t(null);u(()=>{if(!C)return;let e=e=>{w.current&&!w.current.contains(e.target)&&te(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[C]);let{data:T}=ee({nodeId:d.id}),E=a(()=>{let e=new Map;for(let t of T??[])e.set(t.name,t.latestVersion);return e},[T]),ie=a(()=>(T??[]).filter(e=>!e.isSystem).length,[T]),[ae,D]=c(()=>new Set),[se,O]=c(()=>new Map),ce=e(e=>{D(t=>new Set(t).add(e))},[]),A=e(e=>{D(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),le=e((e,t)=>{O(n=>new Map(n).set(e,t))},[]),j=e(e=>{O(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=re({onMutate:e=>{ce(e.name),j(e.name)},onSuccess:(e,t)=>{A(t.name);let n=e;if(n&&n.success===!1){le(t.name,n.error??`Update failed (no error message returned by server)`);return}m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{A(t.name),le(t.name,e instanceof Error?e.message:String(e))}}),N=ke(),de=t(new Set);u(()=>{let e=new Set;for(let[t,n]of N)De(n)&&e.add(t);let t=[...de.current].some(t=>!e.has(t));de.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,m]);let{data:I}=y(void 0),fe=v({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),pe=ne({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:R,isFetching:me}=_({query:S||void 0},{enabled:C}),z=ue(),{data:B}=oe(void 0),V=B?.requestedAt,[he,H]=c(null),[W,G]=c(!1);u(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==he){H(B.requestedAt),G(!0);let e=window.setTimeout(()=>G(!1),6e3);return()=>window.clearTimeout(e)}},[V,he,B]),U();let _e=e(async()=>{let e=(T??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await z.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[T,d.id,d.isHub,z,M]),K=g({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addonPages`]]}),m.invalidateQueries({queryKey:[[`capabilities`]]}),m.invalidateQueries({queryKey:[[`integrations`]]})}}),[ve,ye]=c(`type`),[q,be]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Se=e=>{be(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[J,Y]=xe(),X=J.get(`capability`),Z=J.get(`updatable`)===`1`,Q=nt(J.get(`source`)),Ce=e(e=>{let t=new URLSearchParams(J);e?t.set(`updatable`,`1`):t.delete(`updatable`),Y(t,{replace:!0})},[J,Y]),we=e(e=>{let t=new URLSearchParams(J);e===null?t.delete(`source`):t.set(`source`,e),Y(t,{replace:!0})},[J,Y]),Te=a(()=>{let e=n.filter(e=>!st(e.manifest.packageName));return d.isHub||(e=e.filter(e=>lt(e.placement,d.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&&E.has(t)})),Q!==null&&(e=e.filter(e=>ut(e.installSource)===Q)),e},[n,d.isHub,X,Z,Q,E]),Ee=()=>{let e=new URLSearchParams(J);e.delete(`capability`),Y(e,{replace:!0})},Oe=q===`flat`?Te:ft(Te),Ae=a(()=>{let e=[...Oe];switch(ve){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},[Oe,ve]);return i(`div`,{className:`space-y-3`,children:[[...se.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:ve,onChange:e=>ye(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:()=>Se(e),className:`px-2 py-1 transition-colors capitalize ${q===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))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(F,{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:()=>fe.mutate({channel:e}),disabled:fe.isPending,className:`px-2 py-1 transition-colors capitalize ${I?.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))})]}),d.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:I?.updateCheckIntervalSeconds??21600,disabled:pe.isPending||I===void 0,onChange:e=>{I!==void 0&&pe.mutate({channel:I.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:at.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ie>0&&i(`button`,{type:`button`,onClick:()=>void _e(),disabled:z.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:[z.isPending?l(b,{className:`w-3 h-3 animate-spin`}):l(P,{className:`w-3 h-3`}),z.isPending?`Updating…`:`Update All (${ie})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||z.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(F,{className:`w-3 h-3 ${p?`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:()=>Ce(!Z)},{id:`npm`,label:`npm`,pressed:Q===`npm`,toggle:()=>we(Q===`npm`?null:`npm`)},{id:`dev`,label:`Dev`,pressed:Q===`dev`,toggle:()=>we(Q===`dev`?null:`dev`)}].map(e=>l(`button`,{type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?rt:it,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:w,children:[l(k,{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:h,onChange:e=>{x(e.target.value),te(!0)},onFocus:()=>te(!0),placeholder:`Search addons on npm...`,disabled:z.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`}),me&&l(b,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),C&&R&&R.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:[R.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 (`,R.length,`)`]}),R&&R.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:R.map(e=>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?i(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[l(L,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):i(`button`,{type:`button`,onClick:()=>K.mutate({packageName:e.name}),disabled:K.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[K.isPending?l(b,{className:`h-3 w-3 animate-spin`}):l(P,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Qe,{onUploadSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),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:Ee,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),W&&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(ge,{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.`})]})]}),Te.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:X?`No installed addons declare the "${X}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${d.name} (placement filter active)`}),l(`div`,{className:`space-y-1.5`,children:Ae.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=E.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,a=N.get(t)??null,s=a!==null&&De(a);return l(Xe,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:ae.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:z.isPending,selectedNode:d},$(e)?t:e.manifest.id)})})]})}function mt(){let e=s(),{data:n}=pe(void 0),{nodes:r}=W(),{selection:a,selectNode:o,requestedNodeId:c}=Q(r.length>0?r:[ct]),d=a.node??ct,f=d.id,p=r.length>0?a.staleNodeId:null,{data:m,isLoading:h,isError:g}=z({nodeId:f}),_=A(),v=E(),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(dt).filter(e=>e!==null);return i(Y,{children:[i(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[l(j,{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(F,{className:`w-3 h-3 ${y?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(Z,{staleNodeId:p,shownNodeName:d.name}),l(tt,{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(pt,{addons:C,clusterStatus:n,selectedNode:d,onRefresh:()=>void b(),isRefreshing:y})]})}export{mt as AddonsPage};
@@ -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,G as f,Q as p,ct as m,lt as h,ot as g,vt as _,yt as v}from"./player-overlays-BzBTCjWR.js";import{Bd as y,Ed as b,Gn as x,Hn as S,Ht as C,L as w,Qd as T,Ql as E,Qu as D,Ru as O,Tn as k,U as A,Ut as j,Vt as M,Yd as N,Zu as P,_f as F,dd as ee,ef as I,ln as L,md as R,mu as te,ql as z,ud as B,ur as V,va as H,z as U,zd as W,zn as ne}from"./src-DTW2ew69.js";import{t as re}from"./send-C5kLO34E.js";import{Wn as G}from"./client-5au8Dz4T.js";import{t as K}from"./useTranslation-Bc5yH9V9.js";import"./mount-DFS6Au1R.js";import{C as q}from"./index-BOZXWZFq.js";import{t as ie}from"./AdminSectionedPage-BoWdF1ZC.js";import{t as J}from"./AdminPage-R4K39PzI.js";var ae=v(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]);n();var oe=[`llm`,`listProfiles`],se=[`llm`,`listProfileKinds`],ce=[`llm`,`getDefaults`],Y=[`llm`,`listRuntimeNodes`],le=[`llm`,`listModelCatalog`],ue=[`llm`,`getUsage`],de=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],fe=new Map(Object.entries({openai:I,anthropic:I,google:I,"openai-compatible":B,"managed-local":T,"apple-foundation":T}));function pe(e){return fe.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 me(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:ve(e.runtime?.extraArgs??[])}}var he=[`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`];function ge(e){return typeof e==`string`&&he.includes(e)?e:void 0}function _e(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 ve(e){return e.map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)}var ye=[`--jinja`,`--cont-batching`];function be(e,t,n){let r=Z(e.threads),i=Z(e.batchSize),a=Z(e.ubatchSize),o=ge(e.cacheTypeK),s=ge(e.cacheTypeV);return{nodeId:t,engine:`llama-cpp`,model:n,extraArgs:[..._e(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 xe(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)??G.totalMs,connectTimeoutMs:Z(r.connectTimeoutMs)??G.connectMs,firstTokenTimeoutMs:Z(r.firstTokenTimeoutMs)??G.firstTokenMs,idleTimeoutMs:Z(r.idleTimeoutMs)??G.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:be(r,i.nodeId,i.model)}}}function Se(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 Ce=`apple-system`;function we(e,t,n,r){return{...xe(`apple-foundation`,e,t,n),model:Ce,supportsVision:!1,appleFoundation:{nodeId:r}}}var Te={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 Ee(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=Te[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 De=2e3;function $(e){return`${(e/1e9).toFixed(2)} GB`}function Oe(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function ke({nodeId:e,value:t,onChange:n}){let{t:o}=K(),u=g(),[d,f]=s(``),[p,m]=s(null),[h,_]=s(!1),v=a({queryKey:le,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),y=a({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:e})}),S=c({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{m(e),_(!1),e.ok&&n({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),C=c({mutationFn:t=>u.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),y.refetch()}}),w=a({queryKey:Y,enabled:C.isPending,refetchInterval:C.isPending?De:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,T=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]),O=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})},k=e=>{d.trim()!==``&&S.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(z,{id:`ai-model`,value:Oe(t),options:T,onChange:e=>O(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(E,{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(),k())}}),r(x,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||S.isPending,onClick:()=>k(),children:[S.isPending?l(b,{className:`h-3.5 w-3.5 animate-spin`}):l(D,{className:`h-3.5 w-3.5`}),o(`ai.hfCheck`,`Check`)]})]}),S.isError&&l(`p`,{className:`mt-2 text-[11px] text-danger`,children:S.error instanceof Error?S.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),S.mutate({ref:t})},children:e},e))}),p.requiredBytes!==void 0&&l(x,{size:`sm`,variant:`secondary`,type:`button`,className:`mt-2`,onClick:()=>k(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(V,{variant:p.purpose===`vision`?`info`:`default`,children:p.purpose}),l(V,{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(x,{size:`sm`,type:`button`,disabled:C.isPending||h,onClick:()=>C.mutate(p.model),children:[C.isPending?l(b,{className:`h-3.5 w-3.5 animate-spin`}):l(N,{className:`h-3.5 w-3.5`}),h?o(`ai.hfInstalled`,`Downloaded`):o(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),w!==void 0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?o(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):o(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:$(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${$(w.totalBytes)}`})})]}),C.isError&&l(`p`,{className:`mt-1.5 text-[11px] text-danger`,children:C.error instanceof Error?C.error.message:o(`common.error`,`Error`)})]})]})]})}function Ae({value:e,onChange:t}){let{t:n}=K(),i=g(),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(b,{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=Ee(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(V,{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 je({kind:e,className:t}){let n=pe(e.kind);return n===null?l(`span`,{className:t,children:e.icon}):l(n,{className:t})}function Me({kinds:e,onPick:t,onCancel:n}){let{t:a}=K(),o=i(()=>Se(e),[e]);return l(U,{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(je,{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 Ne({kind:e,existing:t,onSave:n,onCancel:a,saving:c,error:u}){let{t:d}=K(),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?{}:me(t)),[S,C]=s(t?.runtime?.nodeId??`hub`),[w,T]=s(()=>t?.runtime===void 0?null:{model:t.runtime.model,modelId:t.model,supportsVision:t.supportsVision}),D=i(()=>_e(X(v.extraArgs)??``),[v.extraArgs]),O=()=>{if(p){if(m===null)return;n(we(g,t,v,m));return}if(!f){n(xe(e.kind,g,t,v));return}w!==null&&n(xe(e.kind,g,t,v,{nodeId:S,model:w.model,modelId:w.modelId,supportsVision:w.supportsVision}))},j=c||g.trim()===``||f&&w===null||p&&m===null;return l(U,{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&&w===null&&l(V,{variant:`warning`,children:d(`ai.pickModelFirst`,`pick a model`)}),p&&m===null&&l(V,{variant:`warning`,children:d(`ai.pickAppleNodeFirst`,`pick a Mac`)}),r(x,{size:`sm`,type:`button`,disabled:j,onClick:O,children:[c&&l(b,{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(E,{id:`ai-profile-name`,value:g,onChange:e=>_(e.target.value),placeholder:e.label})]}),f&&r(o,{children:[l(A,{selectedNodeId:S,onSelect:C,label:d(`ai.runtimeNode`,`Runtime node`),alwaysShow:!0}),l(ke,{nodeId:S,value:w,onChange:T}),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(E,{id:`ai-extra-args`,value:X(v.extraArgs)??``,onChange:e=>y({...v,extraArgs:e.target.value}),placeholder:ye.join(` `)}),D.length>0&&l(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:D.map((e,t)=>l(V,{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(Ae,{value:m,onChange:h}),l(k,{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 Pe(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(je,{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(V,{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(V,{variant:`default`,children:e.runtime.nodeId})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>l(L,{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(x,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?l(b,{className:`h-3.5 w-3.5 animate-spin`}):l(re,{className:`h-3.5 w-3.5`})}),l(x,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),title:e.t(`common.edit`,`Edit`),children:l(R,{className:`h-3.5 w-3.5`})}),l(x,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),title:e.t(`common.delete`,`Delete`),children:l(m,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Fe(){let{t}=K(),n=g(),{state:o,openNew:d,openEdit:f,close:p}=w(),[m,h]=s(null),[_,v]=s(null),[y,T]=s(null),E=a({queryKey:oe,queryFn:()=>n.trpcClient.llm.listProfiles.query({})}),D=a({queryKey:se,queryFn:async()=>(await n.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),k=()=>{E.refetch()},A=e(()=>{h(null),T(null),p()},[p]);u(()=>{o.mode===`closed`&&h(null)},[o.mode]);let j=c({mutationFn:e=>n.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{A(),k()},onError:e=>T(e instanceof Error?e.message:t(`ai.saveFailed`,`Save failed`))}),N=c({mutationFn:e=>n.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:k}),P=c({mutationFn:e=>n.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>v({id:t.id,ok:e.ok,text:e.ok?`${e.text} (${String(e.usage.outputTokens)} tok, ${String(e.latencyMs)}ms)`:`${e.code}: ${e.message}`})}),F=E.data??[],I=i(()=>D.data??[],[D.data]),L=i(()=>{let e=new Map;for(let t of I)e.set(t.kind,t);return e},[I]),R=o.mode===`edit`?F.find(e=>e.id===o.id)??null:null,te=R===null?null:L.get(R.kind)??null,z=o.mode===`new`&&m===null,B=o.mode===`new`?m:te,V=o.mode===`edit`?R:null,H=B!==null&&(o.mode===`new`||V!==null);return r(J,{embedded:!0,icon:O,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(x,{size:`sm`,type:`button`,onClick:()=>{T(null),h(null),d()},children:[l(ee,{className:`h-3.5 w-3.5`}),t(`ai.addProfile`,`Add profile`)]})}),E.isError&&l(S,{title:t(`ai.loadFailed`,`Failed to load profiles`),message:E.error instanceof Error?E.error.message:t(`common.error`,`Error`),onRetry:()=>void E.refetch()}),l(Ie,{profiles:F}),E.isLoading&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(b,{className:`h-6 w-6 animate-spin text-primary`})}),!E.isLoading&&F.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.`)}),F.length>0&&l(M,{headingId:`ai-profiles-list`,title:t(`ai.profilesList`,`Profiles`),children:l(C,{columns:Pe({kindByName:L,testResult:_,testingId:P.isPending?P.variables?.id??null:null,t,onToggle:e=>j.mutate({...e,enabled:!e.enabled,apiKey:`__redacted__`}),onTest:e=>P.mutate(e),onEdit:e=>{L.has(e.kind)&&(T(null),h(null),f(e.id))},onDelete:e=>N.mutate(e)}),rows:F,rowKey:e=>e.id,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:`max-h-[60vh]`})}),z&&l(Me,{kinds:I,onCancel:A,onPick:e=>{T(null),h(e)}}),H&&B!==null&&l(Ne,{kind:B,existing:V,saving:j.isPending,error:y,onSave:e=>j.mutate(e),onCancel:A})]})}function Ie({profiles:e}){let{t}=K(),n=g(),i=a({queryKey:ce,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(M,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:l(`div`,{className:`${d} grid gap-4 sm:grid-cols-2`,children:de.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(z,{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 Le=5e3;function Re(e){return`${(e/1e9).toFixed(1)} GB`}function ze(){let{t:e}=K(),t=g(),n=a({queryKey:Y,refetchInterval:Le,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(V,{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(V,{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?`—`:Re(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=Ee(t);return r(`span`,{className:`flex flex-col items-start gap-0.5`,children:[l(V,{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:P,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(S,{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(M,{headingId:`ai-runtimes-list`,title:e(`ai.runtimesList`,`Nodes`),children:l(C,{columns:o,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:j})})]})}var Be=p(`/addon/ai/test-chat`),Ve=p(`/addon/ai/test-chat/chats`),He=6e5;function Ue(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),He)}function We(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ge(e){if(!We(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 Ke=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function qe(e){let t;try{t=JSON.parse(e)}catch{return null}if(!We(t))return null;switch(t.kind){case`status`:{let e=Ke.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:Ge(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*Je(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=qe(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=qe(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ye(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Xe(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Ze(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 Qe(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 $e(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 et=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],tt=360*60*1e3,nt=40,rt=160,it={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function at(){let{t:n}=K(),o=g(),[c,d]=s(``),[f,p]=s(``),[v,b]=s(``),[C,w]=s([]),[T,D]=s(null),[O,k]=s(`none`),[A,j]=s(`throwaway`),[M,N]=s(null),[P,ee]=s([]),[I,L]=s(null),[R,B]=s(null),V=t(null);u(()=>()=>V.current?.abort(),[]);let H=e(async()=>{let e=await fetch(Ve,{credentials:`same-origin`});e.ok&&ee((await e.json()).chats??[])},[]);u(()=>{A===`persistent`&&H()},[A,H]);let U=a({queryKey:oe,queryFn:()=>o.trpcClient.llm.listProfiles.query({})}),W=i(()=>(U.data??[]).filter(e=>e.enabled),[U.data]),G=W.find(e=>e.id===c)??null,q=R!==null,ie=e(async(e,t)=>{let r=new AbortController;V.current=r,L(null);let i=Ue(G??{});B({...it,firstTokenTimeoutMs:i??0});let a=``,o=null,s,l=null,u=null,d;try{let n=await fetch(Be,{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},...A===`persistent`?{persist:!0,...M===null?{}:{conversationId:M}}:{}})});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 Je(n.body))switch(e.kind){case`status`:B(t=>({...t??it,phase:e.phase}));break;case`meta`:o=e.mediaSent,s=e.model,B(t=>({...t??it,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:a+=e.text,B(e=>({...e??it,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&&(N(d),H());let p=r.signal.aborted&&a.length>0;l===null&&a.length===0&&!p||w(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}])},[A,M,G,c,H,f,n]),se=e(()=>{let e=v.trim();if(e===``||c===``||q)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...T===null?{}:{attachmentLabel:T.label,attachmentKind:T.ref.kind}},n=[...C,t];w(n),b(``);let r=T?.ref;D(null),k(`none`),ie(A===`persistent`&&M!==null?[{role:`user`,content:e}]:Ye(n),r)},[A,M,v,T,c,ie,q,C]),ce=()=>V.current?.abort(),Y=()=>{V.current?.abort(),w([]),D(null),b(``),L(null),B(null),N(null)},le=async e=>{V.current?.abort();let t=await fetch(`${Ve}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();N(e),w(Ze(n)),B(null),L(null)};return r(J,{embedded:!0,icon:y,title:n(`ai.testTitle`,`Test chat`),subtitle:n(A===`persistent`?`ai.testSubtitlePersistent`:`ai.testSubtitle`,A===`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(x,{size:`sm`,variant:`secondary`,type:`button`,disabled:C.length===0&&T===null,onClick:Y,children:[l(m,{className:`h-3.5 w-3.5`}),n(`ai.clearChat`,`Clear`)]})}),r(ne,{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(z,{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(E,{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(x,{size:`sm`,variant:A===`throwaway`?`primary`:`outline`,type:`button`,onClick:()=>{j(`throwaway`),N(null)},children:n(`ai.throwawayMode`,`Throwaway`)}),l(x,{size:`sm`,variant:A===`persistent`?`primary`:`outline`,type:`button`,onClick:()=>j(`persistent`),children:n(`ai.saveConversation`,`Save conversation`)})]}),A===`persistent`&&r(`div`,{className:`space-y-2`,children:[l(`div`,{className:`flex items-center gap-2`,children:r(x,{size:`sm`,variant:`secondary`,type:`button`,onClick:Y,children:[l(ae,{className:`h-3.5 w-3.5`}),n(`ai.newChat`,`New chat`)]})}),P.length>0&&l(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:P.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===M?`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.`)}),G!==null&&!G.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(S,{title:n(`ai.chatFailed`,`The test call failed`),message:I}),l(ot,{turns:C,live:R}),r(ne,{className:`space-y-2 p-3`,children:[T!==null&&r(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface px-2.5 py-1.5`,children:[T.ref.kind===`snapshot`?l(_,{className:`h-3.5 w-3.5 text-foreground-subtle`}):l(F,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground`,children:T.label}),l(x,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>D(null),children:l(te,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(x,{size:`sm`,variant:O===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`snapshot`?`none`:`snapshot`),children:[l(_,{className:`h-3.5 w-3.5`}),n(`ai.attachSnapshot`,`Camera snapshot`)]}),r(x,{size:`sm`,variant:O===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`track`?`none`:`track`),children:[l(F,{className:`h-3.5 w-3.5`}),n(`ai.attachTrack`,`Recent track`)]})]}),O===`snapshot`&&l(lt,{onPick:e=>{D({ref:{kind:`snapshot`,deviceId:e.id},label:n(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:e.name})}),k(`none`)}}),O===`track`&&l(dt,{onPick:(e,t)=>{D({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:n(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),k(`none`)}}),r(`div`,{className:`flex items-center gap-2`,children:[l(E,{value:v,onChange:e=>b(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(x,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[l(h,{className:`h-3.5 w-3.5`}),n(`ai.stop`,`Stop`)]}):r(x,{size:`sm`,type:`button`,disabled:v.trim()===``||c===``,onClick:se,children:[l(re,{className:`h-3.5 w-3.5`}),n(`ai.send`,`Send`)]})]})]})]})}function ot({turns:e,live:t}){let{t:n}=K();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(ne,{children:r(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto p-3`,children:[e.map(e=>l(st,{turn:e},e.id)),t!==null&&r(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&l(ct,{attachment:t.mediaSent}),t.text.length>0&&l(st,{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(b,{className:`h-3.5 w-3.5 animate-spin`}),$e(t.phase,t.firstTokenTimeoutMs)]})]})]})})}function st({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(ct,{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(F,{className:`h-3 w-3`}):l(_,{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(_,{className:`h-3 w-3`}):l(F,{className:`h-3 w-3`}),Qe(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 ct({attachment:e}){let t=Xe(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 lt({onPick:e}){let{t}=K(),n=H({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?l(b,{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(ut,{device:t,onPick:e},t.id))})}function ut({device:e,onPick:t}){let{src:n}=f(e.id,{width:rt});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(V,{variant:`warning`,children:`off`}),l(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function dt({onPick:e}){let{t}=K(),n=g(),o=H({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:[...et,s.length],enabled:s.length>0,queryFn:()=>n.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-tt,limit:nt,projection:`slim`})});if(o.isLoading||u.isLoading)return l(b,{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(F,{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 ft=1440*60*1e3,pt=[1,7,30,90];function mt(){let{t:e}=K(),t=g(),[n,o]=s(7),c=i(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(n-1)*ft},[n]),u=a({queryKey:oe,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=a({queryKey:[...ue,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:W,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(z,{"aria-label":e(`ai.window`,`Window`),value:String(n),options:pt.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(S,{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(M,{headingId:`ai-usage-list`,title:e(`ai.usageList`,`Rollup`),children:l(C,{columns:p,rows:m,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,mobileMode:`scroll`,maxBodyHeight:j})})]})}function ht(){let{t:e}=K(),t=q(`/system/ai`,{t:e,isAdmin:!0})??{icon:O,title:e(`system.ai`,`AI`)};return l(ie,{icon:t.icon,title:t.title,defaultSection:`profiles`,sectionsLabel:`${t.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:l(Fe,{})},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:l(ze,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:l(mt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:l(at,{})}]})}export{ht as AiProfilesPage,ht as default};