@camstack/addon-admin-ui 1.2.702 → 1.2.704

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 (114) hide show
  1. package/CHANGELOG.md +14 -2
  2. package/dist/assets/{AccessSection-CNgvvC6Q.js → AccessSection-Bbp4vCnK.js} +1 -1
  3. package/dist/assets/Addons-BfskS1ar.js +5 -0
  4. package/dist/assets/{AdminPage-BkxgjFWW.js → AdminPage-Dyd6hYl8.js} +1 -1
  5. package/dist/assets/{AdminSectionedPage-bGVBepbw.js → AdminSectionedPage-DvahmWYI.js} +1 -1
  6. package/dist/assets/AiProfiles-Di4CMSTf.js +3 -0
  7. package/dist/assets/Archive-B10-SsQm.js +1 -0
  8. package/dist/assets/{BootstrapSettingsForm-jBRoUiPn.js → BootstrapSettingsForm-Cm4-eDgP.js} +1 -1
  9. package/dist/assets/Build-CG3kxG-Q.js +40 -0
  10. package/dist/assets/{Calendars-BBTnm6OG.js → Calendars-BDDqqhdh.js} +1 -1
  11. package/dist/assets/Cluster-BQ_N__Tz.js +1 -0
  12. package/dist/assets/CompositionBlockEditor-CAYxLM7D.js +2 -0
  13. package/dist/assets/{CompositionEditorPage-C5pNxu2M.js → CompositionEditorPage-DX3tmg77.js} +1 -1
  14. package/dist/assets/Data-DdKvcS20.js +2 -0
  15. package/dist/assets/DeviceDetail-DHBkE6sd.js +1 -0
  16. package/dist/assets/{Devices-BJRvDHiT.js → Devices-BzdO_WfX.js} +1 -1
  17. package/dist/assets/EmbedDevicePage-Cyos8BBm.js +1 -0
  18. package/dist/assets/{EmbedPlayerPage-BsxSpEcY.js → EmbedPlayerPage-Cl2Qja7R.js} +1 -1
  19. package/dist/assets/History-CDCxEudX.js +1 -0
  20. package/dist/assets/Identity-C-NUjzGa.js +1 -0
  21. package/dist/assets/InstancesTable-CLf8XbQo.js +1 -0
  22. package/dist/assets/IntegrationDetail-BLtGoHv4.js +1 -0
  23. package/dist/assets/{Integrations-Dpb2V2yu.js → Integrations-D0p7b6sg.js} +1 -1
  24. package/dist/assets/{Integrations-BUOpFqfh.js → Integrations-DKh9soI8.js} +2 -2
  25. package/dist/assets/Library-C5NOjKCt.js +1 -0
  26. package/dist/assets/Locations-CIm3Q3i3.js +3 -0
  27. package/dist/assets/{Logs-CUV00qxb.js → Logs-BdYjeDAx.js} +1 -1
  28. package/dist/assets/{MaskShapeCanvas-D57fCIme.js → MaskShapeCanvas-drW0ZeaQ.js} +1 -1
  29. package/dist/assets/{MotionZonesSettings-w1kFM_O4.js → MotionZonesSettings-VF9WJZWR.js} +1 -1
  30. package/dist/assets/{MyAccess-D87gqxHt.js → MyAccess-bBE9o8UP.js} +1 -1
  31. package/dist/assets/{Network-L7e5c9RP.js → Network-CgYpqnsc.js} +1 -1
  32. package/dist/assets/{NewExportModal-CHwUJ26P.js → NewExportModal-CsSL-XDz.js} +1 -1
  33. package/dist/assets/NodeAddonsSettingsPanel-DNmMoeS5.js +1 -0
  34. package/dist/assets/Notifications-CAl9PqU3.js +1 -0
  35. package/dist/assets/{PanelContent-PhbemYUY.js → PanelContent-Cg1LPl_m.js} +2 -2
  36. package/dist/assets/Pipeline-ffZklufq.js +1 -0
  37. package/dist/assets/{PrivacyMaskSettings-BS29zGkX.js → PrivacyMaskSettings-D-43rQlu.js} +1 -1
  38. package/dist/assets/{SceneMonitorEditor-CosxkmPM.js → SceneMonitorEditor-CIMZOhg6.js} +1 -1
  39. package/dist/assets/SessionsList-BPJsMXCC.js +2 -0
  40. package/dist/assets/{Showroom-0iJ0CCe5.js → Showroom-DrnOtUc4.js} +1 -1
  41. package/dist/assets/StorageLocationsTable-CBvJJKcK.js +1 -0
  42. package/dist/assets/System-CiNhZGIk.js +2 -0
  43. package/dist/assets/TemplateEditorDialog-CPEjtVgr.js +1 -0
  44. package/dist/assets/{Terminal-Cvw2rPrb.js → Terminal-CVqdDb0A.js} +4 -4
  45. package/dist/assets/{TrainingProviders-DcThiLnE.js → TrainingProviders-dcBFMHwS.js} +1 -1
  46. package/dist/assets/{Viewer-BUfnqb0c.js → Viewer-D5ct12iH.js} +1 -1
  47. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-CNNET8uz.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DO_LtV7q.js} +1 -1
  48. package/dist/assets/{action-draft-BTVZLATm.js → action-draft-C0aEYbbJ.js} +1 -1
  49. package/dist/assets/{ai-page.helpers-qxf7BP-v.js → ai-page.helpers-5EBfVv-0.js} +1 -1
  50. package/dist/assets/{assignment-candidates-d-6NU8po.js → assignment-candidates-Cu7cpUBu.js} +1 -1
  51. package/dist/assets/{authed-media-Bqh0pB9D.js → authed-media-CU1WIjD1.js} +1 -1
  52. package/dist/assets/{board-model-CPA2IZpg.js → board-model-Cwi5O7EF.js} +1 -1
  53. package/dist/assets/{camera-block-model-CJ0e2m0o.js → camera-block-model-Dll1DsHk.js} +1 -1
  54. package/dist/assets/client-BDuXx1QP.js +1122 -0
  55. package/dist/assets/{command-vocab-BzBhzE7i.js → command-vocab-BvTOW30-.js} +1 -1
  56. package/dist/assets/{device-integration-icon-VMxiVsqd.js → device-integration-icon-DyN7a2xu.js} +1 -1
  57. package/dist/assets/device-picker-model-CB3W-Dnv.js +1 -0
  58. package/dist/assets/{dist-D7Gew3v3.js → dist-UoOeKkgf.js} +1 -1
  59. package/dist/assets/dist-i_V6azZ-.js +1122 -0
  60. package/dist/assets/{format-BopmTOzZ.js → format-BkE2SPtY.js} +1 -1
  61. package/dist/assets/{hostInit-DuH1KOuD.js → hostInit-Bl-sNtRa.js} +1 -1
  62. package/dist/assets/i18n-CjRpxC0U.js +1 -0
  63. package/dist/assets/{icons-bi-mcO5N.js → icons-BLYFUXaZ.js} +1 -1
  64. package/dist/assets/{index-4KLN9ueQ.css → index-BHfNOQzs.css} +1 -1
  65. package/dist/assets/index-Dx4xn5Ud.js +6 -0
  66. package/dist/assets/{linked-devices-model-Bnz1douR.js → linked-devices-model-BheLRl2H.js} +1 -1
  67. package/dist/assets/{mf-entry-bootstrap-0-ddbe056c.js → mf-entry-bootstrap-0-4f6c0152.js} +2 -2
  68. package/dist/assets/mount-CB3W-Dnv.js +1 -0
  69. package/dist/assets/{notification-rule-status-ai5zWyzt.js → notification-rule-status-CqF6M-em.js} +1 -1
  70. package/dist/assets/{player-overlays-fpbPSPqT.js → player-overlays-BKR7fWEx.js} +1 -1
  71. package/dist/assets/remoteEntry-DDpSLsem.js +1 -0
  72. package/dist/assets/src-BnZKlAAn.js +279 -0
  73. package/dist/assets/{sso-popup-Za4GwQBP.js → sso-popup-CZ9VM6-3.js} +1 -1
  74. package/dist/assets/{step-inspector-model-BAgxIyNV.js → step-inspector-model-42AP-SPE.js} +1 -1
  75. package/dist/assets/{use-scenes-feed-BTNdL7JV.js → use-scenes-feed-Ch3TUt2m.js} +1 -1
  76. package/dist/assets/{useAdminDeviceRemoval-COlTnaF7.js → useAdminDeviceRemoval-CJytKQAy.js} +1 -1
  77. package/dist/assets/useEventInvalidation-CB3W-Dnv.js +1 -0
  78. package/dist/assets/{useNodeUrlSelection-DhtJZEtx.js → useNodeUrlSelection-D6xWhfvx.js} +1 -1
  79. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-R-1W8c6C.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-QyglrCCc.js} +2 -2
  80. package/dist/index.html +9 -9
  81. package/dist/server/addon.js +157 -19
  82. package/package.json +2 -2
  83. package/dist/assets/Addons-Dtx3xcZ2.js +0 -5
  84. package/dist/assets/AiProfiles-BLj-ic5N.js +0 -3
  85. package/dist/assets/Archive-y1aPYCx8.js +0 -1
  86. package/dist/assets/Build-BoiB-nPA.js +0 -40
  87. package/dist/assets/Cluster-DN0Cwciw.js +0 -1
  88. package/dist/assets/CompositionBlockEditor-BloGManS.js +0 -2
  89. package/dist/assets/Data-LT-PQ05n.js +0 -2
  90. package/dist/assets/DeviceDetail-DAvmtNN2.js +0 -1
  91. package/dist/assets/EmbedDevicePage-CyKS-rmB.js +0 -1
  92. package/dist/assets/History-BPF9alct.js +0 -1
  93. package/dist/assets/Identity-dLFVHYZR.js +0 -1
  94. package/dist/assets/InstancesTable-LVQWfz07.js +0 -1
  95. package/dist/assets/IntegrationDetail-C_vN9X7q.js +0 -1
  96. package/dist/assets/Library-D4-BDy54.js +0 -1
  97. package/dist/assets/Locations-DGZ_lrp3.js +0 -3
  98. package/dist/assets/NodeAddonsSettingsPanel-Kqe8X8RH.js +0 -1
  99. package/dist/assets/Notifications-CucZNxjj.js +0 -1
  100. package/dist/assets/Pipeline-9O3YfaWk.js +0 -1
  101. package/dist/assets/SessionsList-OHo3GJ72.js +0 -2
  102. package/dist/assets/StorageLocationsTable-DqTWO4k1.js +0 -1
  103. package/dist/assets/System-DZXA2QSs.js +0 -2
  104. package/dist/assets/TemplateEditorDialog-8D78AUfO.js +0 -1
  105. package/dist/assets/client-Cng2SeYA.js +0 -1122
  106. package/dist/assets/device-detail-Cg2Zt8FL.js +0 -1
  107. package/dist/assets/device-picker-model-B-FI9413.js +0 -1
  108. package/dist/assets/dist-CxrdebAP.js +0 -1122
  109. package/dist/assets/i18n--GTAj4mB.js +0 -1
  110. package/dist/assets/index-DbXFHmBJ.js +0 -6
  111. package/dist/assets/mount-B-FI9413.js +0 -1
  112. package/dist/assets/remoteEntry-g0NfB_lk.js +0 -1
  113. package/dist/assets/src-eL0OacoB.js +0 -279
  114. package/dist/assets/useEventInvalidation-B-FI9413.js +0 -1
@@ -5990,7 +5990,7 @@ var ZodIssueCode = {
5990
5990
  var ZodFirstPartyTypeKind;
5991
5991
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5992
5992
  //#endregion
5993
- //#region ../types/dist/runtime-capabilities-qX7BpOYT.mjs
5993
+ //#region ../types/dist/runtime-capabilities-B36VcCR6.mjs
5994
5994
  /**
5995
5995
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5996
5996
  * window to float samples (D455).
@@ -9817,14 +9817,104 @@ var SubscribeAudioChunksInputSchema = object({
9817
9817
  var SubscribeAudioChunksResultSchema = object({
9818
9818
  /** Opaque id passed to `pullAudioChunks` / `unsubscribeAudioChunks`. */
9819
9819
  subscriptionId: string() });
9820
- var BrokerStatsSchema = object({
9821
- status: _enum([
9822
- "idle",
9823
- "connecting",
9824
- "streaming",
9825
- "error",
9826
- "stopped"
9820
+ var BrokerStatusSchema = _enum([
9821
+ "idle",
9822
+ "connecting",
9823
+ "streaming",
9824
+ "error",
9825
+ "stopped"
9826
+ ]);
9827
+ /**
9828
+ * The encode a derived stream's feeder was last spawned with — the read-only
9829
+ * "effective encode". Read off the ffmpeg argv that runs, so it cannot drift
9830
+ * from what the operator's profile and the carrier's rules resolved to.
9831
+ */
9832
+ var DerivedEffectiveEncodeSchema = object({
9833
+ /** `-c:v` of the argv (`libx264`, a hardware encoder, `copy`); null when absent. */
9834
+ encoder: string().nullable(),
9835
+ /** Output frame rate; null when the source cadence passes through unmeasured. */
9836
+ fps: number$1().nullable(),
9837
+ gopFrames: number$1(),
9838
+ /** ABR target (`-b:v`), kbps. */
9839
+ targetKbps: number$1().nullable(),
9840
+ /** Ceiling (`-maxrate`), kbps. */
9841
+ capKbps: number$1().nullable(),
9842
+ bufsizeKbps: number$1().nullable(),
9843
+ /**
9844
+ * `copy` = source audio untouched, `aac` = re-encoded, `profile` = operator's
9845
+ * encode, `none` = the operator dropped the track.
9846
+ */
9847
+ audio: _enum([
9848
+ "copy",
9849
+ "aac",
9850
+ "profile",
9851
+ "none"
9852
+ ])
9853
+ });
9854
+ /**
9855
+ * A derived stream's source: a **profile** slot (follows whatever physical
9856
+ * stream that profile is assigned to) or a **camStream** (pinned to one
9857
+ * physical stream regardless of assignment).
9858
+ */
9859
+ var DerivedSourceRefSchema = union([object({
9860
+ kind: literal("profile"),
9861
+ profile: _enum([
9862
+ "high",
9863
+ "mid",
9864
+ "low"
9865
+ ])
9866
+ }), object({
9867
+ kind: literal("camStream"),
9868
+ camStreamId: string()
9869
+ })]);
9870
+ object({
9871
+ width: number$1().nullable(),
9872
+ height: number$1().nullable(),
9873
+ fps: number$1().nullable(),
9874
+ idrIntervalMs: number$1().nullable(),
9875
+ /** `h264` / `h265` when observed. */
9876
+ videoCodec: _enum(["h264", "h265"]).nullable(),
9877
+ /** Upper-cased SDP name (`AAC`, `PCMU`) when the source has an audio track. */
9878
+ audioCodec: string().nullable()
9879
+ });
9880
+ /**
9881
+ * The full effective encode of a derived-stream profile: the stats the broker
9882
+ * publishes in `getBrokerStats.derivedEncode` plus the resolved geometry, the
9883
+ * flags that say WHY a number differs from the request, and the ffmpeg output
9884
+ * argv. One function (`computeDerivedEncode`) produces it for both the
9885
+ * broker's start path and `previewDerivedEncode`.
9886
+ */
9887
+ var DerivedEncodePreviewSchema = DerivedEffectiveEncodeSchema.extend({
9888
+ /** Final picture size; `null` when neither the profile nor the source names it. */
9889
+ width: number$1().nullable(),
9890
+ height: number$1().nullable(),
9891
+ /** `h264` / `h265` re-encode, `copy` remux; `null` is never returned (the encoder always resolves). */
9892
+ videoCodec: _enum([
9893
+ "h264",
9894
+ "h265",
9895
+ "copy"
9827
9896
  ]),
9897
+ requestedFps: number$1().nullable(),
9898
+ /** The requested fps exceeded the source and the source cadence won. */
9899
+ fpsClampedToSource: boolean(),
9900
+ /** Lowest bitrate accepted for this geometry x fps; `null` when unknown. */
9901
+ floorKbps: number$1().nullable(),
9902
+ /** The explicit bitrate was below the floor and was raised to it. */
9903
+ raisedToFloor: boolean(),
9904
+ /** What the profile asked for when it was raised; `null` otherwise. */
9905
+ requestedKbps: number$1().nullable(),
9906
+ /** Seconds between keyframes; `null` when the output cadence is unknown. */
9907
+ keyframeIntervalSec: number$1().nullable(),
9908
+ /** The ffmpeg argv, with the source loopback URL in `-i`. */
9909
+ args: array(string())
9910
+ });
9911
+ /** Result of `previewDerivedEncode`: a plan, or the reason there is none. */
9912
+ var PreviewDerivedEncodeResultSchema = discriminatedUnion("kind", [object({
9913
+ kind: literal("preview"),
9914
+ preview: DerivedEncodePreviewSchema
9915
+ }), object({ kind: literal("no-source") })]);
9916
+ var BrokerStatsSchema = object({
9917
+ status: BrokerStatusSchema,
9828
9918
  inputFps: number$1(),
9829
9919
  encodedSubscribers: number$1(),
9830
9920
  uptimeMs: number$1(),
@@ -9864,7 +9954,9 @@ var BrokerStatsSchema = object({
9864
9954
  * alone that the mute is on the packet path and not merely persisted.
9865
9955
  */
9866
9956
  audioMuted: boolean().optional(),
9867
- audioMutedDropped: number$1().optional()
9957
+ audioMutedDropped: number$1().optional(),
9958
+ /** Present for a derived broker once its feeder has spawned at least once. */
9959
+ derivedEncode: DerivedEffectiveEncodeSchema.optional()
9868
9960
  });
9869
9961
  /**
9870
9962
  * Exporter-facing "profile restream" entry. Returned by
@@ -22278,7 +22370,7 @@ Object.freeze({
22278
22370
  }
22279
22371
  });
22280
22372
  //#endregion
22281
- //#region ../types/dist/implemented-methods-wFScvZ40.mjs
22373
+ //#region ../types/dist/implemented-methods-BUBqZ2a0.mjs
22282
22374
  /**
22283
22375
  * The ffmpeg build every CamStack node downloads, per platform and arch.
22284
22376
  *
@@ -24882,10 +24974,16 @@ looseObject({
24882
24974
  TargetSchema.omit({ id: true });
24883
24975
  var EncodeProfileSchema = object({
24884
24976
  video: object({
24977
+ /**
24978
+ * `h264` / `h265` re-encode into that codec; `source` re-encodes in whatever
24979
+ * codec the source speaks (a resize that keeps the codec); `copy` remuxes
24980
+ * with no encode at all (so no resize either).
24981
+ */
24885
24982
  codec: _enum([
24886
24983
  "h264",
24887
24984
  "h265",
24888
- "copy"
24985
+ "copy",
24986
+ "source"
24889
24987
  ]),
24890
24988
  profile: _enum([
24891
24989
  "baseline",
@@ -24937,12 +25035,14 @@ var EncodeProfileSchema = object({
24937
25035
  singleSlicePerFrame: boolean().optional()
24938
25036
  }),
24939
25037
  audio: union([literal("passthrough"), object({
25038
+ /** `none` drops the audio track (`-an`); `copy` carries the source's. */
24940
25039
  codec: _enum([
24941
25040
  "opus",
24942
25041
  "aac",
24943
25042
  "pcmu",
24944
25043
  "pcma",
24945
- "copy"
25044
+ "copy",
25045
+ "none"
24946
25046
  ]),
24947
25047
  bitrateKbps: number$1().int().positive().optional(),
24948
25048
  sampleRateHz: number$1().int().positive().optional(),
@@ -54608,7 +54708,11 @@ method(object({
54608
54708
  }).nullable(), {
54609
54709
  kind: "mutation",
54610
54710
  auth: "admin"
54611
- }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({ brokerId: string() }), object({
54711
+ }), method(_void(), array(CameraStreamSchema).readonly()), method(_void(), array(ProfileSlotSchema).readonly()), method(object({ brokerId: string() }), BrokerStatsSchema), method(object({
54712
+ deviceId: number$1().int().nonnegative(),
54713
+ profile: EncodeProfileSchema,
54714
+ source: DerivedSourceRefSchema.optional()
54715
+ }), PreviewDerivedEncodeResultSchema), method(object({ brokerId: string() }), object({
54612
54716
  probed: boolean(),
54613
54717
  summary: string()
54614
54718
  }), {
@@ -71854,7 +71958,13 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
71854
71958
  /** Pool deaths inside the current window. */
71855
71959
  deaths: number$1(),
71856
71960
  /** The last death's message. */
71857
- lastError: string()
71961
+ lastError: string(),
71962
+ /**
71963
+ * Present when the device is ABSENT rather than dead: the runtime
71964
+ * itself enumerates no such device (`no-gpu-device` — OpenVINO sees
71965
+ * no supported GPU; driver/runtime does not support this iGPU).
71966
+ */
71967
+ absentReason: _enum(["no-gpu-device"]).optional()
71858
71968
  })).readonly() })), method(object({
71859
71969
  nodeId: string(),
71860
71970
  deviceKey: string()
@@ -72700,7 +72810,8 @@ var StatelessStepRefusalSchema = _enum([
72700
72810
  "unknown-step",
72701
72811
  "model-not-servable",
72702
72812
  "unreadable-frame",
72703
- "execution-failed"
72813
+ "execution-failed",
72814
+ "no-eligible-device"
72704
72815
  ]);
72705
72816
  /**
72706
72817
  * Answer to `runStatelessStep` — a discriminated union rather than a nullable
@@ -79312,7 +79423,8 @@ var InferenceDeviceExclusionReasonSchema = _enum([
79312
79423
  "unavailable",
79313
79424
  "cannot-host-camera-root",
79314
79425
  "accelerator-preferred",
79315
- "root-switched-off"
79426
+ "root-switched-off",
79427
+ "no-gpu-device"
79316
79428
  ]);
79317
79429
  var NodeInferenceDeviceSchema = object({
79318
79430
  /** Stable per-node device key, e.g. `openvino:npu`, `edgetpu:usb`, `cpu`. */
@@ -79345,7 +79457,13 @@ var NodeInferenceDeviceSchema = object({
79345
79457
  enabled: boolean(),
79346
79458
  /** Relative balancer weight for the enabled device (default 1). */
79347
79459
  weight: number$1(),
79348
- /** Per-device concurrent-session cap; null = unlimited (multi-device C4). */
79460
+ /**
79461
+ * Per-device concurrent-session cap; null = unlimited (multi-device C4). A
79462
+ * limit: a camera no device can take within its cap stays on the node's
79463
+ * default pool — EXCEPT when that default pool is an excluded device
79464
+ * (`defaultPoolExcluded`), where it goes over the cap on the least-loaded
79465
+ * eligible device instead (#610).
79466
+ */
79349
79467
  maxSessions: number$1().nullable(),
79350
79468
  /** Object-detection model the executor defaults to for this deviceKey. */
79351
79469
  defaultModelId: string(),
@@ -79395,7 +79513,15 @@ var NodeInferenceDevicesSchema = object({
79395
79513
  nodeId: string(),
79396
79514
  /** False when the node's platform-probe was unreachable (no live device set). */
79397
79515
  reachable: boolean(),
79398
- devices: array(NodeInferenceDeviceSchema).readonly()
79516
+ devices: array(NodeInferenceDeviceSchema).readonly(),
79517
+ /**
79518
+ * The election left NO device and one was excluded because the operator
79519
+ * turned it off or it is not functional (#610): the runner's default pool is
79520
+ * that device, so work with no explicit device (a stateless step, a bench with
79521
+ * no `deviceKey`) is refused rather than run there. Absent = an orchestrator
79522
+ * older than the field, or an unreachable node: nothing is claimed (D315).
79523
+ */
79524
+ defaultPoolExcluded: boolean().optional()
79399
79525
  });
79400
79526
  /**
79401
79527
  * The CLUSTER switch of one pipeline step (D1065):
@@ -101692,6 +101818,13 @@ Object.freeze({
101692
101818
  access: "view",
101693
101819
  role: "admin"
101694
101820
  },
101821
+ "streamBroker.previewDerivedEncode": {
101822
+ capName: "stream-broker",
101823
+ capScope: "system",
101824
+ addonId: null,
101825
+ access: "view",
101826
+ role: "admin"
101827
+ },
101695
101828
  "streamBroker.probeStream": {
101696
101829
  capName: "stream-broker",
101697
101830
  capScope: "system",
@@ -105995,6 +106128,11 @@ Object.freeze({
105995
106128
  form: "single",
105996
106129
  optional: false
105997
106130
  }],
106131
+ "streamBroker.previewDerivedEncode": [{
106132
+ name: "deviceId",
106133
+ form: "single",
106134
+ optional: false
106135
+ }],
105998
106136
  "streamBroker.produceEventMedia": [{
105999
106137
  name: "deviceId",
106000
106138
  form: "single",
@@ -107846,7 +107984,7 @@ var AdminUIAddon = class extends BaseAddon {
107846
107984
  capability: adminUiCapability,
107847
107985
  provider: {
107848
107986
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
107849
- getVersion: async () => ({ version: "1.2.702" })
107987
+ getVersion: async () => ({ version: "1.2.704" })
107850
107988
  }
107851
107989
  }];
107852
107990
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.702",
3
+ "version": "1.2.704",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -50,7 +50,7 @@
50
50
  }
51
51
  ],
52
52
  "requires": {
53
- "server": ">=1.2.904"
53
+ "server": ">=1.2.906"
54
54
  }
55
55
  },
56
56
  "scripts": {
@@ -1,5 +0,0 @@
1
- import{B as e,C as t,J as n,K as r,R as i,S as a,V as o,Y as s,et as c,o as l,x as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,Gt as f,Hi as p,In as m,Q as h,Tn as g,Tt as _,Vn as v,Xi as y,Yn as b,Zt as x,ct as ee,er as S,ft as C,hr as te,ia as ne,ot as w,sa as T,tn as E,wi as D,zr as O}from"./player-overlays-fpbPSPqT.js";import{ul as re}from"./client-Cng2SeYA.js";import{t as ie}from"./chevron-down-CBb-F8DT.js";import{i as ae,u as k}from"./terminal-DZ5OZpgC.js";import{Eo as oe,Gi as se,Ji as ce,So as le,Sp as ue,To as A,Ui as de,Wi as fe,Xp as j,Yi as pe,_o as me,ai as M,ao as N,bo as he,ci as P,cl as ge,co as F,ct as I,do as L,go as _e,ho as R,io as z,ka as B,lo as V,mi as ve,mo as ye,mp as H,mr as be,no as U,nu as W,oi as xe,oo as G,po as Se,pr as Ce,qi as we,qp as Te,si as Ee,so as De,uo as Oe,vt as ke,wo as Ae,xo as je,yo as Me}from"./src-eL0OacoB.js";import{t as K}from"./useTranslation-BJr-n0es.js";import"./mount-B-FI9413.js";import{Si as Ne,gt as Pe,ht as Fe,vi as Ie,wi as Le}from"./index-DbXFHmBJ.js";import{t as q}from"./NodeAddonsSettingsPanel-Kqe8X8RH.js";import{t as J}from"./AdminPage-BkxgjFWW.js";import{i as Re,r as ze,t as Be}from"./addon-kind-filter-CEGKkC1O.js";import{n as Y,r as Ve,t as He}from"./useNodeUrlSelection-DhtJZEtx.js";function Ue(e){if(e===void 0)return null;switch(e.state){case`failed`:case`refused`:case`missing`:case`crashed`:return{kind:e.state,...e.reason===void 0?{}:{reason:e.reason}};default:return null}}c();var X=`a singleton role: Roles & nodes is the one picker for it`,Z=[{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline`,sectionIds:[`cluster-step-models`,`face-rescore`,`detail-crop`,`native-lease`,`load`,`failover`]},{cap:`pipeline-orchestrator`,addonId:`pipeline-orchestrator`,surface:`pipeline-roles`,fieldKeys:[`ingestNode`,`audioNode`,`motionNode`],reason:X},{cap:`face-gallery`,addonId:`pipeline-analytics`,surface:`pipeline`},{cap:`stream-broker`,addonId:`stream-broker`,surface:`pipeline`},{cap:`snapshot`,addonId:`snapshot`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline`},{cap:`recording`,addonId:`recorder`,surface:`pipeline-roles`,fieldKeys:[`recordingNodeId`],reason:X},{cap:`embedding-encoder`,addonId:`embedding-encoder`,surface:`pipeline`},{cap:`device-history`,addonId:`device-history`,surface:`history`},{cap:`alerts`,addonId:`alert-center`,surface:`notifications`},{cap:`metrics-provider`,addonId:`metrics-native`,surface:`nodes`},{cap:`login-method`,addonId:`auth-webauthn`,surface:`provider-page`},{cap:`llm`,addonId:`ai`,surface:`provider-page`},{cap:`log-destination`,addonId:`console-logging`,surface:`provider-page`},{cap:`core-blocks`,addonId:`core-blocks`,surface:`provider-page`},{cap:`custom-model-registry`,addonId:`model-studio`,surface:`addon-card`},{cap:`osd-manager`,addonId:`osd-manager`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`addon-card`},{cap:`pipeline-analytics`,addonId:`pipeline-analytics`,surface:`pipeline-roles`,fieldKeys:[`postProcessingNodeId`],reason:X},{cap:`detection-pipeline`,addonId:`detection-pipeline`,surface:`addon-card`}],Q={pipeline:`/system/pipeline?view=nodes&node=__cluster__&ctab=settings`,"pipeline-roles":`/system/pipeline?view=nodes&node=__cluster__&ctab=roles-nodes`,history:`/system/history`,notifications:`/system/notifications?tab=settings`,nodes:`/system/nodes`};function We(e){return e.sectionIds===void 0&&e.fieldKeys===void 0}function Ge(e){return Z.filter(t=>t.addonId===e&&Q[t.surface]!==void 0)}function Ke(e){let t=Z.filter(t=>t.addonId===e),n=new Set(t.filter(e=>e.surface===`addon-card`&&We(e)).map(e=>e.cap));return{capabilities:[...new Set(t.map(e=>e.cap))].filter(e=>!n.has(e)),fieldKeys:t.filter(e=>n.has(e.cap)&&e.surface!==`addon-card`).flatMap(e=>e.fieldKeys??[])}}function qe({addonId:e,onOpen:n}){let{t:r}=K(),i=Ke(e),o=Ge(e).length>0;return t(u,{children:[a(Je,{addonId:e,onOpen:n}),a(q,{nodeId:null,addonIds:[e],level:`global`,fieldScope:`cluster`,omitCapabilities:i.capabilities,omitFieldKeys:i.fieldKeys,emptyMessage:o?r(`addons.addonCard.allClusterSettingsElsewhere`,`Its cluster-wide settings are on the page linked above.`):r(`addons.addonCard.thisAddonExposesNoCluster`,`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`)})]})}function Je({addonId:e,onOpen:n}){let{t:r}=K(),i=[...new Set(Ge(e).map(e=>e.surface))];if(i.length===0)return null;let o=e=>{switch(e){case`pipeline`:return r(`addons.addonCard.surface.pipeline`,`Pipeline → Settings`);case`pipeline-roles`:return r(`addons.addonCard.surface.pipelineRoles`,`Pipeline → Roles & nodes`);case`history`:return r(`addons.addonCard.surface.history`,`History`);case`notifications`:return r(`addons.addonCard.surface.notifications`,`Notifications → Settings`);case`nodes`:return r(`addons.addonCard.surface.nodes`,`Nodes`);default:return e}};return t(`div`,{className:`mb-2 flex flex-wrap items-center gap-2 text-[10px] text-foreground-subtle`,children:[a(`span`,{children:r(`addons.addonCard.settingsElsewhere`,`More of this addon's settings are on:`)}),i.map(e=>{let t=Q[e];return t===void 0?null:a(H,{type:`button`,size:`sm`,variant:`outline`,onClick:()=>n(t),children:o(e)},e)})]})}var Ye={queued:{icon:p,bg:`bg-muted text-foreground-subtle`,labelKey:`addons.addonRowBadge.queued`},updating:{icon:O,bg:`bg-primary/10 text-primary`,labelKey:`addons.addonRowBadge.updating`,spin:!0},"done-pending-restart":{icon:b,bg:`bg-amber-500/10 text-amber-700`,labelKey:`addons.addonRowBadge.pendingRestart`},done:{icon:T,bg:`bg-success/10 text-success`,labelKey:`addons.addonRowBadge.done`},failed:{icon:ae,bg:`bg-danger/10 text-danger`,labelKey:`addons.addonRowBadge.failed`}};function Xe({item:e}){let{t:n}=K(),r=Ye[e.status],i=r.icon;return t(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${r.bg}`,title:e.error,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey)]})}var Ze=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),Qe=new Set([`done`,`failed`,`skipped`]);function $e(e){return!Qe.has(e.phase)&&!Ze.has(e.jobState)}function et(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=Ze.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 tt(){let{data:e}=ye({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=j(re.AddonsJobProgress,e=>e.job.jobId);return r(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return et([...n.values()],Date.now())},[e,t])}var nt={queued:{icon:p,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.queued`},fetching:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.fetching`,spin:!0},staged:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.staged`,spin:!0},validating:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.validating`,spin:!0},applying:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.applying`,spin:!0},restarting:{icon:O,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,labelKey:`addons.jobProgress.restarting`,spin:!0},applied:{icon:O,cls:`bg-primary/10 text-primary`,labelKey:`addons.jobProgress.finalizing`,spin:!0},done:{icon:T,cls:`bg-success/10 text-success`,labelKey:`addons.jobProgress.updated`},failed:{icon:ae,cls:`bg-danger/10 text-danger`,labelKey:`addons.jobProgress.failed`},skipped:{icon:g,cls:`bg-muted text-foreground-subtle`,labelKey:`addons.jobProgress.skipped`}};function rt({progress:e}){let{t:n}=K(),r=nt[e.phase],i=r.icon,o=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return t(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${r.cls}`,title:o,children:[a(i,{className:`w-2.5 h-2.5 ${r.spin?`animate-spin`:``}`}),n(r.labelKey),t(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function it(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 at(e){let t=e.version===null?``:` ${e.version}`,n=e.isOnline?``:` (offline: removed when it reconnects)`;return`- ${e.nodeName}${t}${n}`}function ot(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(at)];return n.length>0&&r.push(`Could not ask: ${n.join(`, `)} — not included.`),r.push(`This cannot be undone.`),r.join(`
2
- `)}function st(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 ct={uninstalled:`uninstalled`,"not-installed":`was not installed`,refused:`REFUSED`,failed:`FAILED`,"pending-reconnect":`offline — removed when it reconnects`};function lt(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)}: ${ct[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 ut={},dt=3e4,ft=`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 pt({packageName:e,displayName:n,selectedNode:r,hideNodeAction:i,disabled:o}){let{t:s}=K(),c=l(),u=ee(),d=w(),f=Se(ut,{staleTime:dt}),p=f.data?.installations??[],m=(f.data?.unreachable??[]).map(e=>e.nodeId),h=it(p,e),g=e=>h.find(t=>t.nodeId===e)?.nodeName??(e===r.id?r.name:e),_=A({onSettled:()=>{c.invalidateQueries({queryKey:[[`addons`]]}),c.invalidateQueries({queryKey:[[`addonPages`]]}),c.invalidateQueries({queryKey:[[`capabilities`]]}),c.invalidateQueries({queryKey:[[`nodes`]]})}}),v=async e=>{await d({title:e.success?s(`addons.addonUninstallControls.uninstalled`,`{{displayName}} uninstalled`,{displayName:n}):s(`addons.addonUninstallControls.notEveryNodeWasCleaned`,`{{displayName}}: not every node was cleaned`,{displayName:n}),message:lt(e,g),variant:e.success?`default`:`danger`})},y=async t=>{try{await v(await _.mutateAsync({packageName:e,...t}))}catch(e){await d({title:s(`addons.addonUninstallControls.uninstallFailed`,`Uninstall {{displayName}} failed`,{displayName:n}),message:e instanceof Error?e.message:String(e),variant:`danger`})}},b=async()=>{let e=h.filter(e=>e.nodeId!==r.id);await u({title:s(`addons.addonUninstallControls.uninstallFrom`,`Uninstall {{displayName}} from {{name}}?`,{displayName:n,name:r.name}),message:st(n,r.name,e),confirmLabel:s(`addons.addonUninstallControls.uninstall`,`Uninstall`),variant:`danger`})&&await y(r.isHub?{}:{nodeId:r.id})},x=async()=>{let t=(await f.refetch()).data;if(t===void 0){await d({title:s(`addons.addonUninstallControls.cannotListTheNodes`,`Cannot list the nodes`),message:s(`addons.addonUninstallControls.theHubDidNotAnswer`,`The hub did not answer which nodes have this package — nothing was removed.`),variant:`danger`});return}let r=it(t.installations,e);await u({title:s(`addons.addonUninstallControls.uninstallEverywhere`,`Uninstall {{displayName}} everywhere?`,{displayName:n}),message:ot(n,r,t.unreachable.map(e=>e.nodeId)),confirmLabel:s(`addons.addonUninstallControls.uninstallFromNodeS`,`Uninstall from {{length}} node(s)`,{length:r.length}),variant:`danger`})&&await y({everywhere:!0})},S=_.isPending||o===!0;return t(`div`,{className:`flex items-center gap-1.5`,children:[i!==!0&&t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),b()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFrom2`,`Uninstall from {{name}}`,{name:r.name}),children:[a(E,{className:`h-3 w-3`}),_.isPending?s(`addons.addonUninstallControls.removing`,`Removing...`):s(`addons.addonUninstallControls.uninstall`,`Uninstall`)]}),(h.length>1||i===!0||m.length>0)&&t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),x()},disabled:S,className:ft,title:s(`addons.addonUninstallControls.uninstallFromEveryNodeThat`,`Uninstall from every node that has it`),children:[a(k,{className:`h-3 w-3`}),h.length>0?s(`addons.uninstallControls.everywhereCount`,{count:h.length}):s(`addons.uninstallControls.everywhere`)]})]})}function mt(e){return typeof e.deprecated==`string`&&e.deprecated.length>0}function ht(e,t){return t?e:e.filter(e=>e.distTags.includes(`latest`)||!mt(e))}function gt(e){return e.length-ht(e,!1).length}c();function _t({packageName:e,currentVersion:n,installSource:r,onInstall:i,onClose:o,onSelect:c,selectedVersion:l}){let{t:d}=K(),p=r===`upload`||r===`local`,[m,h]=s(!1),{data:g,isLoading:v,isError:y}=V({name:e}),b=g?ht(g,m):[],x=g?gt(g):0;return t(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[t(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[a(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:d(`addons.versionPicker.versions`,`Versions`)}),a(H,{variant:`unstyled`,type:`button`,onClick:o,className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3 w-3`})})]}),p&&t(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[a(f,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),t(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[a(`span`,{className:`font-semibold`,children:d(`addons.versionPicker.inPlace`,{kind:r===`upload`?d(`addons.versionPicker.uploadedCopy`,`Uploaded copy`):d(`addons.versionPicker.localCopy`,`Local copy`)})}),` `,a(Ie,{i18nKey:`addons.versionPicker.reinstall`,values:{version:n},components:{mono:a(`span`,{className:`font-mono`})}})]})]}),v&&t(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[a(O,{className:`h-3.5 w-3.5 animate-spin`}),d(`addons.versionPicker.loadingVersions`,`Loading versions...`)]}),y&&a(`div`,{className:`px-3 py-4 text-center text-[10px] text-danger`,children:d(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),b.length>0&&a(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:b.map(e=>{let r=e.version===n,o=c!==void 0&&e.version===l,s=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=t(u,{children:[a(`span`,{className:`font-mono flex-1 text-left ${r?`text-primary font-semibold`:s?`text-amber-400`:`text-foreground`}`,children:e.version}),r&&a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:d(`common.current`)}),e.distTags.map(e=>a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),mt(e)&&a(`span`,{className:`text-[9px] text-red-400 line-through`,children:d(`common.deprecated`)}),a(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return c?t(H,{variant:`unstyled`,type:`button`,"aria-label":d(`addons.versionPicker.select`,`Select {{version}}`,{version:e.version}),onClick:()=>c(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${o?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,o?a(T,{className:`h-3 w-3 text-primary shrink-0`}):a(`span`,{className:`w-3 shrink-0`})]},e.version):t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${r?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a(H,{variant:`unstyled`,type:`button`,onClick:()=>i(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:r?d(`addons.versionPicker.reInstallFromNpm`,`Re-install {{version}} from npm`,{version:e.version}):d(`addons.versionPicker.install`,`Install {{version}}`,{version:e.version}),children:a(D,{className:`h-3 w-3`})})]},e.version)})}),!v&&!y&&g&&g.length===0&&a(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:d(`addons.versionPicker.noVersionsFound`,`No versions found`)}),x>0&&a(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto w-full justify-start rounded-none border-t border-border px-3 py-2 text-left text-[10px] font-normal text-foreground-subtle`,onClick:()=>h(e=>!e),children:m?d(`addons.versionPicker.hideOlder`,`Hide older versions`):d(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:x})})]})}c();var vt=`device-export`;function yt(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===vt)}function bt(e){return e!==`local`&&e!==`upload`}function xt({isBundle:e,installSource:n,addonId:r,iconPath:i,color:o}){let[c,l]=s(!1),u=o?{backgroundColor:`${o.startsWith(`#`)?o:`#${o}`}26`}:void 0,d=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=r&&i?h(`/api/addon-assets/${r}/${i}`):null,m=!!p&&!c;return t(`div`,{className:`relative flex-shrink-0`,children:[a(`div`,{className:`h-8 w-8 rounded-md flex items-center justify-center ${u?``:d}`,style:u,children:m?a(`img`,{src:p,alt:r,className:`h-4 w-4`,onError:()=>l(!0)}):a(e?te:S,{className:`h-3.5 w-3.5`})}),n===`local`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),bt(n)&&a(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:a(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:a(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),n===`upload`&&a(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:a(f,{className:`h-2.5 w-2.5 text-white`})})]})}function St({version:e,availableUpdate:n,selectedVersion:r,isUpdating:i,installSource:o,disabled:s,onUpdate:c,onOpenPicker:l,children:u}){let{t:d}=K();if(i)return t(`span`,{className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[a(O,{className:`h-3 w-3 animate-spin`}),d(`addons.addonCard.updating`,`Updating…`)]});if(n){let i=r??n;return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[c&&t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:s,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:d(`addons.addonCard.updateTo`,`Update to {{target}}`,{target:i}),children:[a(D,{className:`h-3 w-3`}),d(`addons.addonCard.update`,`Update`)]}),t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,"aria-label":d(`addons.addonCard.selectVersionToInstall`,`Select version to install`),title:d(`addons.addonCard.installedUpdateAvailableSelectedTap`,`Installed {{version}} — update available. Selected {{target}}; tap to choose another version.`,{version:e,target:i}),className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[a(`span`,{className:`font-normal opacity-70`,children:e}),a(`span`,{className:`font-normal opacity-70`,children:`→`}),i,a(ie,{className:`h-3 w-3`})]}),u]})}return t(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),l()},disabled:s,className:[`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,o===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:d(`addons.addonCard.versionTapToViewAll`,`Version {{version}} — tap to view all versions`,{version:e}),children:[e,a(ie,{className:`h-3 w-3 opacity-50`})]}),u]})}function Ct({addonId:e}){let t=l(),{data:n=`inherit`}=N({addonId:e}),r=je({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return a(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>a(H,{variant:`unstyled`,type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}var wt={id:`hub`,name:`Hub`,isHub:!0};function Tt({addon:e,clusterStatus:n,hideVersion:r,availableUpdate:i,blockedUpdate:c,onUpdateServer:d,onUpdate:f,isUpdating:p,jobProgress:h,bundle:g,bulkItem:y,disabledByBulk:x,isSystem:ee,selectedNode:S}){let{t:C}=K(),[w,T]=s(!1),[E,D]=s(!1),[O,re]=s(null);o(()=>{re(null)},[i]);let k=O??i,[oe,le]=s(!1),[ue,A]=s(!1),[j,M]=s(`logs`),N=l(),he=Ne(),{manifest:P}=e,ge=!g&&!P.protected&&P.removable!==!1,F=!!g,I=g?.displayName??P.name,L=g?.packageName??P.packageName,_e=g?.version??P.packageVersion??P.version,R=g?.installSource??e.installSource,z=g?g.bundle?.description??g.addons[0]?.manifest.description:P.description,V=me({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]})}}),ve=Oe({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`addonPages`]]}),N.invalidateQueries({queryKey:[[`capabilities`]]}),N.invalidateQueries({queryKey:[[`integrations`]]})}}),ye=Me({onSuccess:()=>{N.invalidateQueries({queryKey:[[`addons`]]}),N.invalidateQueries({queryKey:[[`alerts`]]})}}),U=e.health,W=U?.phase===`failed`&&!U.inGracePeriod,xe=W&&U?.nextRetryAt&&!U.retrying,G=Ue(e.process);return t(`div`,{className:`rounded-md border bg-surface overflow-hidden ${W?`border-red-500/50`:`border-border`}`,children:[W&&U&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(ae,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.failedToLoad`,{attempt:U.retryCount})}),a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:U.lastError?.message??C(`addons.addonCard.unknownError`,`Unknown error`)}),xe&&U.nextRetryAt&&a(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:C(`addons.addonCard.autoRetryAt`,{time:new Date(U.nextRetryAt).toLocaleTimeString()})})]}),t(H,{variant:`unstyled`,type:`button`,disabled:ye.isPending||U.retrying,onClick:e=>{e.stopPropagation(),ye.mutate({packageName:L})},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:C(`addons.addonCard.resetRetryCounterAndForce`,`Reset retry counter and force immediate reload`),children:[a(b,{className:`h-3 w-3 ${ye.isPending||U.retrying?`animate-spin`:``}`}),C(`addons.addonCard.retryNow`,`Retry now`)]})]}),G!==null&&t(`div`,{className:`bg-danger/10 border-b border-danger/30 px-3 py-2 flex items-start gap-2`,children:[a(ae,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),t(`div`,{className:`flex-1 min-w-0`,children:[a(`div`,{className:`text-xs font-semibold text-danger`,children:C(`addons.addonCard.processProblem.${G.kind}`)}),G.reason!==void 0&&a(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:G.reason})]})]}),t(`div`,{className:`flex items-start gap-2.5 px-3 py-2`,children:[a(xt,{isBundle:F||!!P.components&&P.components.length>1,installSource:R,addonId:F?g.addons[0]?.manifest.id:P.id,iconPath:F?g.bundle?.icon??g.addons[0]?.manifest.icon:P.icon,color:F?g.addons[0]?.manifest.color:P.color}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-start justify-between gap-2`,children:[a(`span`,{className:`text-xs font-semibold text-foreground truncate min-w-0`,children:I}),!r&&a(St,{version:_e,availableUpdate:i,...k===void 0?{}:{selectedVersion:k},isUpdating:p,installSource:R,disabled:x,...f&&k!==void 0?{onUpdate:()=>f(k)}:{},onOpenPicker:()=>D(e=>!e),children:E&&a(_t,{packageName:L,currentVersion:_e,...R?{installSource:R}:{},...i!==void 0&&k!==void 0?{selectedVersion:k,onSelect:e=>{re(e),D(!1)}}:{},onInstall:e=>{D(!1),ve.mutate({packageName:L,version:e})},onClose:()=>D(!1)})})]}),t(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[L!==I&&a(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:L}),F&&t(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[a(te,{className:`h-3 w-3`}),g.addons.length]}),ee&&t(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:C(`addons.addonCard.systemPackageUpdatingRestartsThe`,`System package — updating restarts the hub`),children:[a(b,{className:`h-3 w-3`}),C(`addons.addonCard.system`,`System`)]}),y!=null&&a(Xe,{item:y}),c!==void 0&&a(B,{variant:`warning`,title:C(`addons.addonCard.updateHeldTitle`,{defaultValue:`{{latest}} is held until the server is {{required}} or newer`,latest:c.latestVersion,required:c.requiredServer}),children:C(`addons.addonCard.requiresServer`,{defaultValue:`requires server ≥ {{version}}`,version:c.requiredServer})}),c!==void 0&&d!==void 0&&a(H,{type:`button`,size:`sm`,variant:`secondary`,onClick:d,children:C(`clusterUpdate.updateServer`,`Update server`)}),h!=null&&a(rt,{progress:h})]}),z&&a(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:z}),!F&&e.process&&t(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?C(`addons.addonCard.forked`):C(`addons.addonCard.inProcess`)}),e.process.pid!=null&&t(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),a(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:G===null?`bg-gray-500/15 text-gray-400`:`bg-red-500/15 text-red-400`}`,children:e.process.state})]})]})]}),!F&&t(`div`,{className:`flex items-center gap-1 px-3 py-1 border-t border-border/50 bg-surface-hover/20`,children:[t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),V.mutate({addonId:P.id})},disabled:V.isPending||x,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[a(b,{className:`h-3 w-3 ${V.isPending?`animate-spin`:``}`}),C(`addons.addonCard.restart`,`Restart`)]}),t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),le(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${oe?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(v,{className:`h-3 w-3`}),C(`addons.addonCard.logs`,`Logs`)]}),!F&&t(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] font-medium border transition-colors ${ue?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[a(m,{className:`h-3 w-3`}),C(`addons.addonCard.settings`,`Settings`)]}),a(`div`,{className:`flex-1`}),ge&&a(pt,{packageName:P.packageName,displayName:P.name,selectedNode:S??wt,disabled:x})]}),n&&n.nodes.length>1&&!F&&t(`div`,{className:`border-t border-border px-3 py-1.5 bg-muted/10`,children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:C(`addons.addonCard.clusterDeployment`,`Cluster Deployment`)}),a(`div`,{className:`space-y-1`,children:n.nodes.map(e=>t(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[a(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),a(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),a(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:C(`addons.addonCard.outdated`)}),e.status===`offline`&&a(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:C(`common.offline`)}),e.synced&&e.status!==`offline`&&a(`span`,{className:`text-[9px] text-success`,children:C(`common.synced`)})]},e.nodeId))})]}),oe&&!F&&t(`div`,{className:`border-t border-border`,children:[t(`div`,{className:`flex items-center px-3 py-0.5 bg-surface-hover/20 border-b border-border/50`,children:[t(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[a(H,{variant:`unstyled`,type:`button`,onClick:()=>M(`logs`),className:`px-2 py-0.5 transition-colors ${j===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.logs`,`Logs`)}),a(H,{variant:`unstyled`,type:`button`,onClick:()=>M(`events`),className:`px-2 py-0.5 border-l border-border transition-colors ${j===`events`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:C(`addons.addonCard.events`,`Events`)})]}),a(`div`,{className:`flex-1`}),a(H,{variant:`unstyled`,type:`button`,onClick:e=>{e.stopPropagation(),le(!1)},className:`text-foreground-subtle hover:text-foreground`,children:a(_,{className:`h-3.5 w-3.5`})})]}),j===`logs`&&a(be,{addonId:P.id,maxHeight:`max-h-64`,showFilters:!1}),j===`events`&&a(Ce,{addonId:P.id,category:`addon.*`,maxHeight:`max-h-64`})]}),F&&t(u,{children:[a(H,{variant:`unstyled`,type:`button`,onClick:()=>T(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:a(w?ne:ie,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),w&&a(`div`,{className:`border-t border-border px-2.5 py-1.5 space-y-1.5`,children:g.addons.map(e=>a(Tt,{addon:e,hideVersion:!0},e.manifest.id))})]}),ue&&!F&&a(de,{open:!0,onOpenChange:e=>!e&&A(!1),children:t(se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ce,{children:t(pe,{className:`flex items-center gap-2`,children:[a(m,{className:`h-4 w-4 text-primary`}),C(`addons.addonCard.settingsTitle`,{name:I})]})}),t(fe,{className:`space-y-4`,children:[a(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:C(`addons.addonCard.clusterWideSettingsOneValue`,`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`)}),a(qe,{addonId:P.id,onOpen:e=>he(e)}),yt(P)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.deviceExport`,`Device export`)}),a(ke,{addonId:P.id,onOpenDevice:e=>he(`/devices/${e}`)})]}),bt(R)&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.autoUpdate`,`Auto-Update`)}),a(Ct,{addonId:P.id})]}),P.components&&P.components.length>0&&t(`div`,{children:[a(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:C(`addons.addonCard.components`,{count:P.components.length})}),a(`div`,{className:`flex flex-wrap gap-1`,children:P.components.map(e=>a(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]})]}),a(we,{children:a(H,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>A(!1),children:C(`common.close`,`Close`)})})]})})]})}c();var Et=`.tgz,.tar.gz,.zip`;function Dt({onUploadSuccess:e}){let{t:r}=K(),[o,c]=s(!1),l=n(null),d=i(async t=>{c(!0);let n=new FormData;n.append(`file`,t);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(h(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:n})).json()).success&&e()}finally{c(!1)}},[e]);return t(u,{children:[a(ve,{ref:l,accept:Et,onChange:i(e=>{let t=e.target.files?.[0];t&&d(t),e.target.value=``},[d]),className:`hidden`}),t(H,{variant:`unstyled`,type:`button`,onClick:()=>l.current?.click(),disabled:o,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[o?a(O,{className:`w-3.5 h-3.5 animate-spin`}):a(f,{className:`w-3.5 h-3.5`}),o?r(`addons.addonUploadZone.uploading`,`Uploading...`):r(`addons.addonUploadZone.upload`,`Upload`)]})]})}var Ot=/```[^\n]*\n([\s\S]*?)```/g;function kt(e){let t=[],n=0;for(let r of e.matchAll(Ot)){let i=r.index??0;i>n&&t.push({kind:`text`,body:e.slice(n,i)}),t.push({kind:`code`,body:r[1]??``}),n=i+r[0].length}return n<e.length&&t.push({kind:`text`,body:e.slice(n)}),t}function At(e){let t=e.trim();return t.startsWith(`https://`)||t.startsWith(`http://`)?t:null}function jt(e,t){let n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\))/g,i=0,o=0;for(let s of e.matchAll(r)){let r=s.index??0;r>i&&n.push(e.slice(i,r));let c=s[0],l=`${t}-${o}`;if(o+=1,c.startsWith(`**`))n.push(a(`strong`,{children:c.slice(2,-2)},l));else if(c.startsWith("`"))n.push(a(`code`,{className:`font-mono text-[0.9em]`,children:c.slice(1,-1)},l));else{let e=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(c),t=e?.[1]??c,r=e?At(e[2]??``):null;n.push(r?a(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:`text-primary underline`,children:t},l):a(`span`,{children:t},l))}i=r+c.length}return i<e.length&&n.push(e.slice(i)),n}function Mt(e,t){let n=e.split(`
5
- `),r=[],i=[],o=[],s=0,c=()=>{if(i.length===0)return;let e=i.join(` `).trim();i=[],e.length!==0&&(r.push(a(`p`,{className:`mb-2 last:mb-0`,children:jt(e,`${t}-p-${s}`)},`${t}-p-${s}`)),s+=1)},l=()=>{if(o.length===0)return;let e=o;o=[],r.push(a(`ul`,{className:`mb-2 list-disc pl-4 last:mb-0`,children:e.map((e,n)=>a(`li`,{children:jt(e,`${t}-li-${s}-${n}`)},`${t}-li-${s}-${n}`))},`${t}-ul-${s}`)),s+=1};for(let e of n){let n=/^(#{1,3})\s+(.*)$/.exec(e),u=/^\s*[-*]\s+(.*)$/.exec(e);if(n){c(),l();let e=n[1]?.length??1,i=jt(n[2]??``,`${t}-h-${s}`),o=e===1?`text-sm font-semibold mb-2`:`text-xs font-semibold mb-1.5 mt-2`;r.push(a(e===1?`h3`:`h4`,{className:o,children:i},`${t}-h-${s}`)),s+=1;continue}if(u){c(),o=[...o,u[1]??``];continue}if(e.trim().length===0){c(),l();continue}l(),i=[...i,e.trim()]}return c(),l(),r}function Nt({markdown:e}){return a(`div`,{className:`text-xs text-foreground leading-relaxed`,children:kt(e).map((e,t)=>e.kind===`code`?a(`pre`,{className:`mb-2 overflow-auto rounded-md bg-surface-hover p-2 font-mono text-[10px] last:mb-0`,children:e.body.replace(/\n$/,``)},`code-${t}`):a(`div`,{children:Mt(e.body,`b${t}`)},`text-${t}`))})}c();function Pt(e){return e.replace(/^@camstack\/(addon-)?/,``)}function Ft(e,t,n){let r=ht(e,n);return r.some(e=>e.version===t)?r:[{version:t,distTags:[],deprecated:void 0},...r]}function It({pending:e,failed:n,body:r,missing:i}){let{t:o}=K();return e?t(`div`,{className:`flex items-center gap-2 py-6 text-xs text-foreground-subtle`,children:[a(O,{className:`h-3.5 w-3.5 animate-spin`}),o(`addons.installDialog.loadingDocument`,`Loading…`)]}):n||r===void 0?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.couldNotLoadDocument`,`Could not load this file from the registry.`)}):r.status===`ok`&&r.markdown!==void 0?a(Nt,{markdown:r.markdown}):r.status===`error`?a(`p`,{className:`py-4 text-xs text-danger`,children:o(`addons.installDialog.documentError`,`Could not load this file. {{message}}`,{message:r.message??``})}):a(`p`,{className:`py-4 text-xs text-foreground-subtle`,children:i})}function Lt({target:e,installing:n,installError:r,onClose:i,onInstall:o}){let{t:c}=K(),[l,u]=s(e.version),[d,f]=s(!1),p=V({name:e.name}),m=F({name:e.name,version:l}),h=p.data??[],g=gt(h),_=Ft(h,l,d),v=m.data;return a(de,{open:!0,onOpenChange:e=>!e&&i(),children:t(se,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[a(ce,{children:a(pe,{children:c(`addons.installDialog.title`,`Install {{name}}`,{name:Pt(e.name)})})}),t(fe,{className:`space-y-3`,children:[a(`p`,{className:`font-mono text-[10px] text-foreground-subtle`,children:e.name}),e.description.length>0&&a(`p`,{className:`text-xs text-foreground`,children:e.description}),t(`div`,{className:`space-y-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:c(`addons.installDialog.version`,`Version`)}),a(C,{"aria-label":c(`addons.installDialog.version`,`Version`),value:l,options:_.map(e=>({value:e.version,label:mt(e)?c(`addons.installDialog.deprecatedVersion`,`{{version}} (deprecated)`,{version:e.version}):e.version})),onChange:e=>u(e.target.value)}),p.isError&&a(`p`,{className:`text-[10px] text-danger`,children:c(`addons.versionPicker.registryError`,`Could not load versions from the registry.`)}),g>0&&a(H,{type:`button`,variant:`ghost`,size:`sm`,className:`h-auto justify-start px-0 text-[10px] font-normal text-foreground-subtle underline`,onClick:()=>f(e=>!e),children:d?c(`addons.versionPicker.hideOlder`,`Hide older versions`):c(`addons.versionPicker.showOlder`,`Show older versions ({{count}})`,{count:g})})]}),t(M,{defaultValue:`readme`,children:[t(Ee,{children:[a(P,{value:`readme`,children:c(`addons.installDialog.readme`,`README`)}),a(P,{value:`changelog`,children:c(`addons.installDialog.changelog`,`CHANGELOG`)})]}),a(xe,{value:`readme`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(It,{pending:m.isPending,failed:m.isError,body:v?.readme,missing:c(`addons.installDialog.missingReadme`,`This package has no README.`)})})}),a(xe,{value:`changelog`,children:a(`div`,{className:`max-h-80 overflow-auto rounded-md border border-border bg-background p-3`,children:a(It,{pending:m.isPending,failed:m.isError,body:v?.changelog,missing:c(`addons.installDialog.missingChangelog`,`This package has no CHANGELOG.`)})})})]}),r!=null&&r.length>0&&a(`p`,{className:`text-xs text-danger`,children:r})]}),t(we,{children:[a(H,{type:`button`,variant:`outline`,size:`sm`,onClick:i,children:c(`common.cancel`,`Cancel`)}),a(H,{type:`button`,size:`sm`,disabled:n||l.length===0,onClick:()=>o(e.name,l),children:n?a(O,{className:`h-3.5 w-3.5 animate-spin`}):c(`addons.installDialog.install`,`Install`)})]})]})})}function Rt(e,t){let n=new Map;for(let r of e){if(r.isHub||r.onHub||Pe(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 zt({selectedNode:e}){let{t:n}=K(),{data:r}=Se(ut,{staleTime:dt});if(r===void 0)return null;let i=Rt(r.installations,e),o=r.unreachable.filter(t=>e.isHub||t.nodeId===e.id);return i.length===0&&o.length===0?null:t(`div`,{className:`rounded-lg border border-warning/30 bg-warning/5 px-3 py-2.5 space-y-2`,children:[t(`div`,{className:`flex items-center gap-2 text-[11px] font-semibold text-foreground`,children:[a(x,{className:`h-3.5 w-3.5 text-warning`}),e.isHub?n(`addons.nodeOnlyPackagesPanel.installedOnAgentsButNot`,`Installed on agents but not on the hub`):n(`addons.nodeOnlyPackagesPanel.installedOnButNotOn`,`Installed on {{name}} but not on the hub`,{name:e.name})]}),o.length>0&&a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n(`addons.nodeOnlyPackagesPanel.unreachable`,{nodes:o.map(e=>e.nodeId).join(`, `)})}),i.map(n=>t(`div`,{className:`flex items-center justify-between gap-3 flex-wrap rounded-md border border-border bg-surface px-3 py-2`,children:[t(`div`,{className:`min-w-0`,children:[a(`div`,{className:`text-xs font-mono text-foreground break-all`,children:n.packageName}),a(`div`,{className:`text-[10px] text-foreground-subtle`,children:n.rows.map(e=>`${e.nodeName}${e.version===null?``:` ${e.version}`}${e.isOnline?``:` (offline)`}`).join(` · `)})]}),a(pt,{packageName:n.packageName,displayName:n.packageName,selectedNode:e,hideNodeAction:e.isHub})]},n.packageName))]})}function Bt({addon:e,installing:n,onInstall:r}){let{t:i}=K();return t(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[a(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),t(`div`,{className:`flex-1 min-w-0`,children:[t(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[a(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),t(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),a(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&a(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?a(B,{variant:`success`,icon:a(T,{className:`h-3 w-3`}),children:e.installedVersion??i(`system.capabilityCatalog.installed`,`Installed`)}):t(H,{size:`sm`,onClick:()=>r(e),disabled:n,className:`shrink-0`,children:[n?a(O,{className:`h-3 w-3 animate-spin`}):a(D,{className:`h-3 w-3`}),i(`system.capabilityCatalog.install`,`Install`)]})]})}function Vt({capability:e,installing:n,onInstall:r}){let{t:i}=K(),{data:o,isPending:s,isError:c}=he({capability:e}),l;if(c)l=a(`div`,{className:`px-3 py-2 text-xs text-danger`,children:i(`system.capabilityCatalog.couldNotSearchTheNpm`,`Could not search the npm catalog right now. Try again in a moment.`)});else if(s||o===void 0)l=t(`div`,{className:`flex items-center gap-2 px-3 py-2 text-xs text-foreground-subtle`,children:[a(O,{className:`h-3 w-3 animate-spin`}),i(`system.capabilityCatalog.searchingTheNpmCatalog`,`Searching the npm catalog…`)]});else{let t=o.filter(e=>!e.installed);l=t.length===0?a(`div`,{className:`px-3 py-2 text-xs text-foreground-subtle`,children:o.length===0?i(`system.capabilityCatalog.noPublishedAddonDeclaresThe`,`No published addon declares the "{{capability}}" capability.`,{capability:e}):i(`system.capabilityCatalog.everyPublishedAddonThatDeclares`,`Every published addon that declares "{{capability}}" is already installed.`,{capability:e})}):a(`div`,{className:`divide-y divide-border`,children:t.map(e=>a(Bt,{addon:e,installing:n,onInstall:r},e.name))})}return t(`section`,{className:`rounded-md border border-border bg-surface overflow-hidden`,"aria-label":i(`system.capabilityCatalog.availableToInstall`,`Available to install`),children:[a(`h2`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:i(`system.capabilityCatalog.availableToInstall`,`Available to install`)}),l]})}c();function Ht(e){return e===`npm`||e===`dev`?e:null}var Ut=`rounded-full border border-primary bg-primary/10 px-2 py-0.5 text-[10px] text-foreground`,Wt=`rounded-full border border-border px-2 py-0.5 text-[10px] text-foreground-muted hover:bg-surface-hover`,Gt=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Kt={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function qt(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Jt(e){return e===`local`?`dev`:`npm`}function Yt(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`,...r.reason===void 0?{}:{reason:r.reason}}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Xt(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 Zt({addons:c,clusterStatus:u,selectedNode:f,onRefresh:p,listPhase:m}){let{t:h}=K(),g=l(),[_,v]=s(``),[x,S]=s(!1),te=e(_),[ne,w]=s(!1),T=n(null);o(()=>{if(!ne)return;let e=e=>{T.current&&!T.current.contains(e.target)&&w(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[ne]);let{data:E}=R({nodeId:f.id}),re=r(()=>{let e=new Map;for(let t of E??[])t.blockedBy===void 0&&e.set(t.name,t.latestVersion);return e},[E]),ie=r(()=>{let e=new Map;for(let t of E??[]){let n=t.blockedBy?.find(e=>e.kind===`server-too-old`);n!==void 0&&e.set(t.name,{latestVersion:t.latestVersion,requiredServer:n.required})}return e},[E]),ae=r(()=>(E??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0).length,[E]),[k,se]=s(()=>new Set),[ce,A]=s(()=>new Map),de=i(e=>{se(t=>new Set(t).add(e))},[]),fe=i(e=>{se(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),j=i((e,t)=>{A(n=>new Map(n).set(e,t))},[]),pe=i(e=>{A(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),me=oe({onMutate:e=>{de(e.name),pe(e.name)},onSuccess:(e,t)=>{fe(t.name);let n=e;if(n&&n.success===!1){j(t.name,n.error??`Update failed (no error message returned by server)`);return}g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{fe(t.name),j(t.name,e instanceof Error?e.message:String(e))}}),M=tt(),N=n(new Set);o(()=>{let e=new Set;for(let[t,n]of M)$e(n)&&e.add(t);let t=[...N.current].some(t=>!e.has(t));N.current=e,t&&(g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[M,g]);let{data:P}=G(void 0),F=U({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),I=le({onSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:L,isFetching:_e}=he({query:te||void 0},{enabled:ne}),z=Ae(),{data:B}=De(void 0),V=B?.requestedAt,[ve,ye]=s(null),[be,W]=s(!1);o(()=>{if(B?.kind===`framework-bulk-update`&&B.requestedAt!==ve){ye(B.requestedAt),W(!0);let e=window.setTimeout(()=>W(!1),6e3);return()=>window.clearTimeout(e)}},[V,ve,B]),ee();let xe=i(async()=>{let e=(E??[]).filter(e=>!e.isSystem&&e.blockedBy===void 0);if(e.length!==0){if(!f.isHub){for(let t of e)await me.mutateAsync({name:t.name,version:t.latestVersion,nodeId:f.id});return}await z.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[f.id]})}},[E,f.id,f.isHub,z,me]),[Se,Ce]=s(null),[we,Te]=s(null),Ee=e=>{Te(null),Ce(e)},ke=Oe({onSuccess:()=>{Ce(null),Te(null),g.invalidateQueries({queryKey:[[`addons`]]}),g.invalidateQueries({queryKey:[[`addonPages`]]}),g.invalidateQueries({queryKey:[[`capabilities`]]}),g.invalidateQueries({queryKey:[[`integrations`]]})},onError:e=>{Te(e instanceof Error?e.message:`Install failed`)}}),[je,Me]=s(`type`),[Ne,Pe]=s(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),Ie=e=>{Pe(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[q,J]=Le(),Y=q.get(`capability`),He=q.get(`updatable`)===`1`,X=q.get(`error`)===`1`,Z=Ht(q.get(`source`)),Q=Re(q.get(Be))===`integration`,{data:We}=ge(void 0,{enabled:Q}),Ge=r(()=>We===void 0?null:new Set(We.map(e=>e.addonId)),[We]),Ke=i(e=>{let t=new URLSearchParams(q);e?t.set(Be,`integration`):t.delete(Be),J(t,{replace:!0})},[q,J]),qe=i(e=>{let t=new URLSearchParams(q);e?t.set(`updatable`,`1`):t.delete(`updatable`),J(t,{replace:!0})},[q,J]),Je=i(e=>{let t=new URLSearchParams(q);e?t.set(`error`,`1`):t.delete(`error`),J(t,{replace:!0})},[q,J]),Ye=i(e=>{let t=new URLSearchParams(q);e===null?t.delete(`source`):t.set(`source`,e),J(t,{replace:!0})},[q,J]),Xe=r(()=>c.filter(e=>Ue(e.process)!==null).length,[c]),Ze=r(()=>{let e=c.filter(e=>!Fe(e.manifest.packageName));return f.isHub||(e=e.filter(e=>qt(e.placement,f.isHub))),Y&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Y))),Q&&(e=[...ze(e,Ge)]),He&&(e=e.filter(e=>{let t=e.manifest.packageName;return t!==void 0&&re.has(t)})),Z!==null&&(e=e.filter(e=>Jt(e.installSource)===Z)),X&&(e=e.filter(e=>Ue(e.process)!==null)),e},[c,f.isHub,Y,He,Z,X,Q,Ge,re]),Qe=()=>{let e=new URLSearchParams(q);e.delete(`capability`),J(e,{replace:!0})},et=Ne===`flat`?Ze:Xt(Ze),nt=r(()=>{let e=[...et];switch(je){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},[et,je]);return t(`div`,{className:`space-y-3`,children:[a(Ve,{open:x,onOpenChange:S}),[...ce.entries()].map(([e,n])=>a(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-2.5 py-1.5 text-[11px]`,children:t(`div`,{className:`flex items-start justify-between gap-3`,children:[t(`div`,{className:`space-y-0.5`,children:[a(`div`,{className:`font-medium text-danger`,children:h(`systemPage.addons.updateFailed`,{name:e})}),a(`div`,{className:`text-foreground-subtle font-mono`,children:n})]}),a(H,{variant:`unstyled`,type:`button`,onClick:()=>pe(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:h(`common.dismiss`)})]})},e)),t(`div`,{className:`flex items-center gap-x-2 gap-y-1.5 flex-wrap`,children:[t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.sort`,`Sort:`)}),t(C,{wrapperClassName:`inline-block w-auto`,value:je,onChange:e=>Me(e.target.value),children:[a(`option`,{value:`type`,children:h(`admin.system.addons.bundlesFirst`,`Bundles first`)}),a(`option`,{value:`name`,children:h(`admin.system.addons.name`,`Name`)}),a(`option`,{value:`source`,children:h(`admin.system.addons.installSource`,`Install source`)})]})]}),t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.view`,`View:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>a(H,{variant:`unstyled`,type:`button`,onClick:()=>Ie(e),className:`px-2 py-1 transition-colors capitalize ${Ne===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?h(`admin.system.addons.groupMultiAddonPackagesInto`,`Group multi-addon packages into a bundle card`):h(`admin.system.addons.showEveryAddonAsIts`,`Show every addon as its own card`),children:e},e))})]}),f.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(b,{className:`h-3 w-3 text-foreground-subtle`}),a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.autoUpdate`,`Auto-Update:`)}),a(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>a(H,{variant:`unstyled`,type:`button`,onClick:()=>F.mutate({channel:e}),disabled:F.isPending,className:`px-2 py-1 transition-colors capitalize ${P?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),f.isHub&&t(`div`,{className:`flex items-center gap-1.5`,children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.checkEvery`,`Check every:`)}),a(C,{wrapperClassName:`inline-block w-auto`,className:`font-medium text-foreground-subtle`,value:P?.updateCheckIntervalSeconds??21600,disabled:I.isPending||P===void 0,onChange:e=>{P!==void 0&&I.mutate({channel:P.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:Gt.map(e=>a(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ae>0&&t(H,{variant:`unstyled`,type:`button`,onClick:()=>void xe(),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?a(O,{className:`w-3 h-3 animate-spin`}):a(D,{className:`w-3 h-3`}),z.isPending?h(`admin.system.addons.updating`,`Updating…`):h(`admin.system.addons.updateAll`,`Update All ({{nonSystemUpdateCount}})`,{nonSystemUpdateCount:ae})]})]}),t(`div`,{className:`flex flex-wrap items-center gap-1.5`,role:`group`,"aria-label":h(`admin.system.addons.filterInstalledAddons`,`Filter installed addons`),children:[a(`span`,{className:`text-[10px] text-foreground-subtle`,children:h(`admin.system.addons.filter`,`Filter:`)}),[{id:`integrations`,label:h(`admin.system.addons.integrations`,`Integrations`),pressed:Q,toggle:()=>Ke(!Q)},{id:`updatable`,label:h(`admin.system.addons.updatable`,`Updatable`),pressed:He,toggle:()=>qe(!He)},{id:`error`,label:h(`admin.system.addons.inError`,`In error ({{count}})`,{count:Xe}),pressed:X,toggle:()=>Je(!X)},{id:`npm`,label:`npm`,pressed:Z===`npm`,toggle:()=>Ye(Z===`npm`?null:`npm`)},{id:`dev`,label:h(`admin.system.addons.dev`,`Dev`),pressed:Z===`dev`,toggle:()=>Ye(Z===`dev`?null:`dev`)}].map(e=>a(H,{variant:`unstyled`,type:`button`,"aria-pressed":e.pressed,onClick:e.toggle,className:e.pressed?Ut:Wt,children:e.label},e.id))]}),t(`div`,{className:`flex flex-col gap-1.5 sm:flex-row sm:items-center sm:gap-2`,children:[t(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:T,children:[a(ue,{type:`text`,searchHotkey:!0,value:_,onChange:e=>{v(e.target.value),w(!0)},onFocus:()=>w(!0),placeholder:h(`admin.system.addons.searchAddonsOnNpm`,`Search addons on npm...`),"aria-label":h(`admin.system.addons.searchAddonsOnNpm2`,`Search addons on npm`),disabled:z.isPending,leftSlot:a(d,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),rightSlot:_e?a(O,{className:`h-3 w-3 animate-spin`}):void 0}),ne&&L&&L.length>0&&t(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-md border border-border bg-surface shadow-xl overflow-hidden`,children:[L.length>0&&a(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:h(`systemPage.addons.npmResults`,{count:L.length})}),L&&L.length>0&&a(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:L.map(e=>a(Bt,{addon:e,installing:ke.isPending,onInstall:e=>Ee({name:e.name,version:e.version,description:e.description})},e.name))})]})]}),a(Dt,{onUploadSuccess:()=>{g.invalidateQueries({queryKey:[[`addons`]]}),p()}})]}),Y&&t(`div`,{className:`flex items-center gap-2 px-2.5 py-1.5 rounded-md bg-primary/10 border border-primary/30 text-xs`,children:[a(`span`,{className:`text-foreground-subtle`,children:h(`admin.system.addons.filteringByCapability`,`Filtering by capability:`)}),a(`span`,{className:`font-mono text-primary font-semibold`,children:Y}),a(H,{variant:`unstyled`,type:`button`,onClick:Qe,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:h(`admin.system.addons.clear`,`Clear`)})]}),Y&&a(Vt,{capability:Y,installing:ke.isPending,onInstall:e=>Ee({name:e.name,version:e.version,description:e.description})}),Y&&Ze.length>0&&a(`h2`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle`,children:h(`admin.system.addons.installed`,`Installed`)}),be&&t(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg max-w-sm pointer-events-auto`,children:[a(y,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),t(`div`,{children:[a(`div`,{className:`text-[11px] font-semibold text-foreground`,children:h(`admin.system.addons.bulkUpdateCompleted`,`Bulk update completed`)}),a(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:h(`admin.system.addons.systemPackagesUpdatedHubRestarted`,`System packages updated — hub restarted successfully.`)})]})]}),m===`pending`&&t(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[a(O,{className:`h-3 w-3 animate-spin`}),h(`admin.system.addons.loadingInstalled`,`Loading installed addons…`)]}),m===`error`&&a(`div`,{className:`text-xs text-danger`,children:h(`admin.system.addons.failedToLoadAddons`,`Failed to load addons`)}),m===`ready`&&Ze.length===0&&a(`div`,{className:`text-xs text-foreground-subtle`,children:c.length===0?h(`admin.system.addons.noAddonsInstalled`,`No addons installed`):Y?h(`admin.system.addons.noInstalledAddonDeclaresThe`,`No installed addon declares the "{{capabilityFilter}}" capability. Any addon you can install appears under "Available to install" above.`,{capabilityFilter:Y}):h(`admin.system.addons.noAddonsCompatibleWithPlacement`,`No addons compatible with {{name}} (placement filter active)`,{name:f.name})}),a(`div`,{className:`space-y-1.5`,children:m===`ready`&&nt.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=re.get(t),r=ie.get(t),i=$(e)?e.representative:e,o=n?e=>me.mutate({name:t,version:e,nodeId:f.id}):void 0,s=M.get(t)??null,c=s!==null&&$e(s);return a(Tt,{addon:i,clusterStatus:u?.[i.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,...r===void 0?{}:{blockedUpdate:r},...r===void 0?{}:{onUpdateServer:()=>S(!0)},isUpdating:k.has(t)||c,jobProgress:s,onUpdate:o,disabledByBulk:z.isPending,selectedNode:f},$(e)?t:e.manifest.id)})}),Se!==null&&a(Lt,{target:Se,installing:ke.isPending,installError:we,onClose:()=>Ce(null),onInstall:(e,t)=>ke.mutate({packageName:e,version:t})})]})}function Qt(){let{t:e}=K(),r=l(),{data:i}=W(void 0),{nodes:s}=Te(),{selection:c,selectNode:u,requestedNodeId:d}=He(s.length>0?s:[Kt]),f=c.node??Kt,p=f.id,m=s.length>0?c.staleNodeId:null,{data:h,isLoading:g,isError:_}=L({nodeId:p}),v=z(),y=_e(),x=v.isPending||y.isPending,ee=async()=>{await v.mutateAsync({nodeId:p}),await y.mutateAsync(),r.invalidateQueries({queryKey:[[`addons`]]})},S=n(v);S.current=v;let C=n(d??`hub`);o(()=>{S.current.mutate({nodeId:C.current})},[]);let te=(h??[]).map(Yt).filter(e=>e!==null);return t(J,{children:[t(`div`,{className:`flex items-center justify-between gap-2 flex-wrap`,children:[a(I,{selectedNodeId:p,onSelect:u}),t(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[!g&&!_&&a(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:e(`systemPage.addons.installedCount`,{count:te.length})}),t(H,{variant:`unstyled`,type:`button`,onClick:()=>void ee(),disabled:x,className:`inline-flex items-center gap-1 px-2 py-1 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:e(`admin.system.addons.reFetchAddonsCheckNpm`,`Re-fetch addons + check npm for new versions`),children:[a(b,{className:`w-3 h-3 ${x?`animate-spin`:``}`}),e(`admin.system.addons.checkForUpdates`,`Check for updates`)]})]})]}),a(Y,{staleNodeId:m,shownNodeName:f.name}),a(zt,{selectedNode:f}),a(Zt,{addons:te,clusterStatus:i,selectedNode:f,onRefresh:()=>void ee(),listPhase:g?`pending`:_?`error`:`ready`})]})}export{Qt as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{C as e,J as t,K as n,R as r,S as i,V as a,Y as o,a as s,et as c,o as l,t as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-CEyXHAdg.js";import{Bn as d,D as f,G as p,L as m,Q as h,Rn as g,Tt as _,ba as v,ci as y,fa as b,ft as x,mn as S,tn as C,wi as w,yn as T,yt as E,zn as D,zr as O}from"./player-overlays-fpbPSPqT.js";import{Di as k}from"./client-Cng2SeYA.js";import{t as A}from"./flask-conical-D7tbJQpj.js";import{t as j}from"./message-square-plus-_aGccjyj.js";import{Aa as M,Br as N,Ca as ee,Cp as te,Da as P,Ia as F,Ir as I,Kp as ne,Sa as re,Sp as ie,Zs as L,gi as ae,ka as R,la as z,mp as B,q as oe,ut as V,zr as H}from"./src-eL0OacoB.js";import{t as U}from"./i18n--GTAj4mB.js";import{t as W}from"./useTranslation-BJr-n0es.js";import"./mount-B-FI9413.js";import{St as G,b as K,wi as q}from"./index-DbXFHmBJ.js";import{t as J}from"./AdminSectionedPage-bGVBepbw.js";import{t as se}from"./InstancesTable-LVQWfz07.js";import{t as ce}from"./AdminPage-BkxgjFWW.js";import{a as le,c as ue,d as de,f as fe,i as pe,l as Y,n as me,o as he,p as ge,r as _e,s as X,t as ve,u as ye}from"./ai-page.helpers-qxf7BP-v.js";c();function be(){let{t}=W(),n=E(),r=ee({functionCap:`llm`}).data??[],a=s({queryKey:me,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=u({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{a.refetch()}}),c=e=>(a.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,l=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return i(I,{headingId:`ai-profiles-defaults`,title:t(`ai.defaultsTitle`,`Defaults`),children:i(`div`,{className:`${f} grid gap-4 sm:grid-cols-2`,children:_e.map(({purpose:n,visionOnly:a})=>{let s=a?r.filter(Y):r,u=c(n),d=r.find(e=>e.id===u);return e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`llm-default-${n}`,children:l(n)}),i(x,{id:`llm-default-${n}`,"aria-label":l(n),value:u,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),options:[{value:``,label:t(`ai.none`,`None`)},...u!==``&&!s.some(e=>e.id===u)?[{value:u,label:d?.name??u}]:[],...s.map(e=>({value:e.id,label:X(e)===``?e.name:`${e.name} · ${X(e)}`}))]}),u!==``&&d===void 0&&i(`p`,{className:`mt-1 text-xs text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&i(`p`,{className:`mt-1 text-xs text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:String(o.error)})]},n)})})})}var xe=2e3;function Z(e){return U.t(`system.aiModelPicker.sizeGb`,{value:(e/1e9).toFixed(2)})}function Se(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function Ce({nodeId:t,value:r,onChange:a}){let{t:c}=W(),l=E(),[f,p]=o(``),[m,h]=o(null),[g,_]=o(!1),v=s({queryKey:ve,queryFn:()=>l.trpcClient.llm.listModelCatalog.query({})}),y=s({queryKey:[`llm`,`listNodeModels`,t],queryFn:()=>l.trpcClient.llm.listNodeModels.query({nodeId:t})}),b=u({mutationFn:e=>l.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&a({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),S=u({mutationFn:e=>l.trpcClient.llm.installModel.mutate({nodeId:t,model:e}),onSuccess:()=>{_(!0),y.refetch()}}),C=s({queryKey:pe,enabled:S.isPending,refetchInterval:S.isPending?xe:!1,queryFn:()=>l.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(e=>e.nodeId===t)?.status?.download,T=n(()=>{let e=(v.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${Z(e.sizeBytes)}`})),n=(y.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(e=>({value:`node:${e.file}`,label:c(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:e.file,size:Z(e.sizeBytes),node:t})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${Z(m.totalBytes)}`}]:[];return[{value:``,label:c(`ai.selectModel`,`Select a model…`)},...e,...n,...r]},[v.data,y.data,m,t,c]),D=e=>{if(e===``){a(null);return}if(e===`custom`){if(m?.ok!==!0)return;a({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),n=v.data?.find(e=>e.id===t);a({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:n?.purpose===`vision`});return}let t=e.slice(5),n=y.data?.find(e=>e.file===t);n?.path!==void 0&&a({model:{kind:`path`,path:n.path},modelId:t,supportsVision:!1})},k=e=>{f.trim()!==``&&b.mutate({ref:f.trim(),...e===void 0?{}:{maxBytes:e}})};return e(`div`,{className:`space-y-3`,children:[i(V,{label:c(`ai.model`,`Model`),required:!0,children:i(x,{id:`ai-model`,"aria-label":c(`ai.model`,`Model`),value:Se(r),options:T,onChange:e=>D(e.target.value)})}),i(V,{label:c(`ai.hfTitle`,`Add a model from Hugging Face`),description:c(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`),children:e(`div`,{className:`flex gap-2`,children:[i(ie,{"aria-label":c(`ai.hfTitle`,`Add a model from Hugging Face`),value:f,onChange:e=>p(e.target.value),placeholder:c(`system.aiModelPicker.unslothQwen3635bA3b`,`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),k())}}),e(B,{size:`sm`,variant:`secondary`,type:`button`,disabled:f.trim()===``||b.isPending,onClick:()=>k(),children:[b.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(d,{className:`h-3.5 w-3.5`}),c(`ai.hfCheck`,`Check`)]})]})}),b.isError&&i(P,{message:b.error instanceof Error?b.error.message:c(`common.error`,`Error`)}),m?.ok===!1&&i(P,{message:m.message,action:e(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(m.candidates??[]).map(e=>i(B,{size:`sm`,variant:`outline`,type:`button`,onClick:()=>{let t=`${f.trim().split(`:`)[0]??``}:${e}`;p(t),b.mutate({ref:t})},children:e},e)),m.requiredBytes!==void 0&&i(B,{size:`sm`,variant:`secondary`,type:`button`,onClick:()=>k(m.requiredBytes),children:c(`ai.hfOverride`,`Install anyway ({{size}})`,{size:Z(m.requiredBytes)})})]})}),m?.ok===!0&&e(`div`,{className:`space-y-2 rounded-md border border-border bg-surface p-2.5`,children:[e(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[i(`span`,{className:`text-[11px] font-medium text-foreground`,children:m.label}),i(R,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),i(R,{variant:`default`,children:Z(m.totalBytes)})]}),m.extraFilenames.length>0&&i(`p`,{className:`text-[10px] text-foreground-subtle`,children:c(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),e(`div`,{className:`flex items-center gap-2`,children:[e(B,{size:`sm`,type:`button`,disabled:S.isPending||g,onClick:()=>S.mutate(m.model),children:[S.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):i(w,{className:`h-3.5 w-3.5`}),g?c(`ai.hfInstalled`,`Downloaded`):c(`ai.hfInstall`,`Download to {{node}}`,{node:t})]}),C!==void 0&&i(`span`,{className:`text-[10px] text-foreground-subtle`,children:C.phase===`verifying`?c(`ai.hfVerifying`,`verifying {{file}}…`,{file:C.file}):c(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:C.file,index:C.fileIndex,count:C.fileCount,done:Z(C.downloadedBytes),total:C.totalBytes===void 0?``:` / ${Z(C.totalBytes)}`})})]}),S.isError&&i(P,{message:S.error instanceof Error?S.error.message:c(`common.error`,`Error`)})]})]})}function we({value:t,onChange:n}){let{t:r}=W(),a=E(),o=s({queryKey:pe,queryFn:()=>a.trpcClient.llm.listRuntimeNodes.query({})});return e(`div`,{children:[i(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:r(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&e(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),r(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&i(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:r(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&i(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(a=>{let o=he(a),s=o.nodeId===t;return e(B,{variant:`unstyled`,type:`button`,role:`radio`,"aria-checked":s,disabled:!o.selectable&&!s,onClick:()=>n(o.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${s?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[e(`span`,{className:`min-w-0`,children:[i(`span`,{className:`block font-medium text-foreground`,children:o.nodeId}),o.detail!==null&&i(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:o.detail})]}),i(R,{variant:o.tone,children:r(o.labelKey,o.labelDefault)})]},o.nodeId)})}),i(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:r(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}function Te(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Ee({providerConfig:e,onProviderConfigChange:t}){return i(we,{value:Te(e,`nodeId`),onChange:n=>t({...e,nodeId:n})})}function De({providerConfig:e,onProviderConfigChange:t,model:n,onModelChange:r}){let a=k.safeParse(e.model),o=a.success?{model:a.data,modelId:n.id,supportsVision:n.supportsVision}:null;return i(Ce,{nodeId:Te(e,`nodeId`)??`hub`,value:o,onChange:n=>{if(n===null){let{model:n,...i}=e;t(i),r({id:``,supportsVision:!1});return}t({...e,model:n.model}),r({id:n.modelId,supportsVision:n.supportsVision})}})}var Oe=new Map([[`ai/apple-node`,Ee],[`ai/managed-model`,De]]);function ke(e){return Oe.get(e)??null}c();function Q(e,t){let n=e[t];return typeof n==`string`?n:``}function Ae({row:a}){let{t:c}=W(),d=E(),f=l(),p=s({queryKey:n(()=>[G,a.addonId,`ai-lead`,a.id],[a]),queryFn:async()=>{let e=d.trpcClient.integrationInstances,[t,n]=await Promise.all([e.describe.query({addonId:a.addonId}),e.getInstance.query({addonId:a.addonId,id:a.id})]);return{description:t,instance:n}}}),[m,h]=o({}),g=t({}),_=t(!1),v=u({mutationFn:e=>d.trpcClient.integrationInstances.updateInstance.mutate({addonId:a.addonId,id:a.id,values:e}),onSuccess:async()=>{await f.invalidateQueries({queryKey:[G]}),await f.invalidateQueries({queryKey:[re]}),h({})}}),y=r(e=>{g.current={...g.current,...e},h(t=>({...t,...e})),!_.current&&(_.current=!0,queueMicrotask(()=>{let e=g.current;g.current={},_.current=!1,v.mutate(e)}))},[v]),b=p.data?.description.kinds?.find(e=>e.id===a.kindId),S=p.data?.instance?.formValues,C=n(()=>({...S,...m}),[S,m]),w=b?.widgets??[],T=w.some(e=>e.placement===`model`),D=n(()=>({...Q(C,`nodeId`)===``?{}:{nodeId:Q(C,`nodeId`)},...typeof C.modelRef==`object`&&C.modelRef!==null?{model:C.modelRef}:{}}),[C]),k={id:Q(C,`model`),supportsVision:C.supportsVision===!0},A=u({mutationFn:()=>d.trpcClient.llm.listModels.mutate({addonId:a.addonId,kind:a.kindId??``,profileId:a.id})});if(p.isPending)return null;if(p.isError)return i(P,{variant:`warning`,message:p.error.message});let j=A.data?.ok===!0?A.data.models:[],M=A.data?.ok===!1?A.data:null,N=e=>{let t=j.find(t=>t.id===e);y({model:e,...t?.features?.vision===void 0?{}:{supportsVision:t.features.vision}})};return e(`div`,{className:`space-y-3`,"data-testid":`ai-profile-lead`,children:[w.map(({id:e})=>{let t=ke(e);return t===null?i(P,{variant:`warning`,message:c(`ai.unknownWidget`,`This provider needs an editor part this build does not have ({{id}}).`,{id:e})},e):i(t,{providerConfig:D,onProviderConfigChange:e=>y({...Q(e,`nodeId`)===Q(D,`nodeId`)?{}:{nodeId:Q(e,`nodeId`)},...e.model!==void 0&&e.model!==D.model?{modelRef:e.model}:{}}),model:k,onModelChange:e=>y({model:e.id,supportsVision:e.supportsVision})},e)}),!T&&e(V,{label:c(`ai.model`,`Model`),children:[e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(B,{size:`sm`,variant:`secondary`,type:`button`,disabled:A.isPending,onClick:()=>A.mutate(),children:[A.isPending?i(O,{className:`h-3.5 w-3.5 animate-spin`}):null,c(`ai.loadModels`,`Load models`)]}),j.length>0&&i(x,{"aria-label":c(`ai.model`,`Model`),value:k.id,onChange:e=>N(e.target.value),options:[...j.some(e=>e.id===k.id)||k.id===``?[]:[{value:k.id,label:k.id}],...j.map(e=>({value:e.id,label:e.label??e.id}))]})]}),M!==null&&i(`p`,{className:`mt-1 text-xs text-danger`,children:M.message}),A.isError&&i(`p`,{className:`mt-1 text-xs text-danger`,children:A.error.message})]}),v.isError&&i(P,{variant:`warning`,message:v.error.message})]})}c();var je=5e3;function Me(e){return U.t(`system.aiRuntimes.sizeGb`,{value:(e/1e9).toFixed(1)})}function Ne(){let{t}=W(),r=E(),a=s({queryKey:pe,refetchInterval:je,queryFn:()=>r.trpcClient.llm.listRuntimeNodes.query({})}),o=n(()=>[{key:`node`,header:t(`ai.colNode`,`Node`),render:e=>i(`span`,{className:`font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:t(`ai.colState`,`State`),nowrap:!0,render:n=>e(`span`,{className:`flex items-center gap-1.5`,children:[i(R,{variant:ge(n),children:t(fe(n))}),n.status?.downloadProgress!==void 0&&i(R,{variant:`info`,children:`${String(Math.round(n.status.downloadProgress*100))}%`})]})},{key:`model`,header:t(`ai.colModel`,`Model`),render:e=>i(`span`,{className:`text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:t(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums text-foreground-muted`,children:e.disk===void 0?`—`:Me(e.disk.modelsBytes)})},{key:`features`,header:t(`ai.colFeature`,`Feature`),render:n=>{let r=de(n);if(r.length===0)return i(`span`,{className:`text-foreground-subtle`,children:`—`});let a=r.flatMap(e=>e.detail===null?[]:[e.detail]);return e(`span`,{className:`flex flex-col items-start gap-0.5`,children:[i(`span`,{className:`flex flex-wrap gap-1`,children:r.map(e=>i(R,{variant:e.tone,children:t(e.labelKey)},e.id))}),a.length>0&&i(`span`,{className:`text-foreground-subtle`,children:a.join(` · `)})]})}},{key:`error`,header:t(`ai.colError`,`Error`),render:e=>e.error===void 0?i(`span`,{className:`text-foreground-subtle`,children:`—`}):i(`span`,{className:`text-danger`,children:e.error})}],[t]),c=a.data??[];return i(I,{headingId:`ai-runtimes-list`,title:t(`ai.runtimesList`,`Nodes`),children:a.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-runtimes-loading`,children:[i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`})]}):a.isError?i(`div`,{className:f,children:i(P,{title:t(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:a.error instanceof Error?a.error.message:t(`common.error`,`Error`),onRetry:()=>void a.refetch()})}):c.length===0?i(z,{icon:g,title:t(`ai.noRuntimesTitle`,`No runtime nodes`),description:t(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):i(H,{columns:o,rows:c,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,maxBodyHeight:N})})}var Pe=h(`/addon/ai/test-chat`),Fe=h(`/addon/ai/test-chat/chats`),Ie=6e5;function Le(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),Ie)}function Re(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ze(e){if(!Re(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 Be=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ve(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Re(t))return null;switch(t.kind){case`status`:{let e=Be.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:ze(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:U.t(`helpers.aiTestChat.providerError`)};default:return null}}async function*He(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=Ve(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Ve(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ue(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function We(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function Ge(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 Ke(e){let t=e.sizeBytes<1024*1024?`${(e.sizeBytes/1024).toFixed(0)} KB`:`${(e.sizeBytes/(1024*1024)).toFixed(1)} MB`,n=[e.kind===`snapshot`?`camera snapshot`:`track best-shot`,t];return e.mediaKind!==void 0&&n.push(e.mediaKind),e.capturedAt!==void 0&&n.push(new Date(e.capturedAt).toLocaleTimeString()),n.join(` · `)}function qe(e,t){switch(e){case`resolving-image`:return U.t(`helpers.aiTestChat.phaseImage`);case`connecting`:return U.t(`helpers.aiTestChat.phaseConnecting`);case`first-token-wait`:return t>0?U.t(`helpers.aiTestChat.phaseWaitUpTo`,{seconds:Math.round(t/1e3)}):U.t(`helpers.aiTestChat.phaseWait`);case`streaming`:return U.t(`helpers.aiTestChat.phaseAnswering`)}}c();var Je=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],Ye=360*60*1e3,Xe=40,Ze=160,$={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function Qe(){let{t:s}=W();E();let[c,l]=o(``),[u,d]=o(``),[p,h]=o(``),[g,y]=o([]),[w,T]=o(null),[O,k]=o(`none`),[A,M]=o(`throwaway`),[N,F]=o(null),[ne,re]=o([]),[L,R]=o(null),[z,V]=o(null),H=t(null);a(()=>()=>H.current?.abort(),[]);let U=r(async()=>{let e=await fetch(Fe,{credentials:`same-origin`});e.ok&&re((await e.json()).chats??[])},[]);a(()=>{A===`persistent`&&U()},[A,U]);let G=ee({functionCap:`llm`}),K=n(()=>(G.data??[]).filter(e=>e.enabled),[G.data]),q=K.find(e=>e.id===c)??null,J=z!==null,se=r(async(e,t)=>{let n=new AbortController;H.current=n,R(null);let r=Le(q===null?{}:ye(q));V({...$,firstTokenTimeoutMs:r??0});let i=``,a=null,o,l=null,d=null,f;try{let s=await fetch(Pe,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:n.signal,body:JSON.stringify({profileId:c,messages:e,...u.trim()===``?{}:{system:u.trim()},...t===void 0?{}:{attachment:t},...r===void 0?{}:{firstTokenTimeoutMs:r},...A===`persistent`?{persist:!0,...N===null?{}:{conversationId:N}}:{}})});if(!s.ok||s.body===null){let e=await s.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(s.status)}`)}for await(let e of He(s.body))switch(e.kind){case`status`:V(t=>({...t??$,phase:e.phase}));break;case`meta`:a=e.mediaSent,o=e.model,V(t=>({...t??$,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:i+=e.text,V(e=>({...e??$,text:i}));break;case`done`:d={outputTokens:e.outputTokens,latencyMs:e.latencyMs},f=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){n.signal.aborted||R(e instanceof Error?e.message:s(`common.error`,`Error`))}finally{H.current=null,V(null)}f!==void 0&&(F(f),U());let p=n.signal.aborted&&i.length>0;l===null&&i.length===0&&!p||y(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??i,...l===null?{}:{failed:!0},...a===null?{}:{attachment:a},...o!==void 0&&l===null?{model:o}:{},...d===null?{}:d}])},[A,N,q,c,U,u,s]),ce=r(()=>{let e=p.trim();if(e===``||c===``||J)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...w===null?{}:{attachmentLabel:w.label,attachmentKind:w.ref.kind}},n=[...g,t];y(n),h(``);let r=w?.ref;T(null),k(`none`),se(A===`persistent`&&N!==null?[{role:`user`,content:e}]:Ue(n),r)},[A,N,p,w,c,se,J,g]),le=()=>H.current?.abort(),ue=()=>{H.current?.abort(),y([]),T(null),h(``),R(null),V(null),F(null)},de=async e=>{H.current?.abort();let t=await fetch(`${Fe}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();F(e),y(Ge(n)),V(null),R(null)};return e(`div`,{className:m,children:[i(I,{headingId:`ai-test-setup`,title:s(`ai.testSetup`,`Setup`),children:e(`div`,{className:`${f} space-y-3`,children:[e(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-profile`,children:s(`ai.profile`,`Profile`)}),i(x,{id:`ai-test-profile`,value:c,onChange:e=>l(e.target.value),options:[{value:``,label:s(`ai.selectProfile`,`Select a profile…`)},...K.map(e=>({value:e.id,label:`${e.name} · ${X(e)}${Y(e)?` · vision`:``}`}))]}),K.length===0&&!G.isLoading&&i(`p`,{className:`mt-1 text-xs text-foreground-subtle`,children:s(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),e(`div`,{children:[i(ae,{className:`mb-1 block`,htmlFor:`ai-test-system`,children:s(`ai.systemPrompt`,`System prompt (optional)`)}),i(ie,{id:`ai-test-system`,value:u,onChange:e=>d(e.target.value),placeholder:s(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),i(oe,{label:s(`ai.chatMode`,`Conversation mode`),value:A,options:[{value:`throwaway`,label:s(`ai.throwawayMode`,`Throwaway`)},{value:`persistent`,label:s(`ai.saveConversation`,`Save conversation`)}],onChange:e=>{M(e),e===`throwaway`&&F(null)}}),A===`persistent`&&e(`div`,{className:`space-y-2`,children:[i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.testSubtitlePersistent`,`Conversations are saved for you and can be reopened. Throwaway mode is still available.`)}),e(B,{size:`sm`,variant:`secondary`,type:`button`,onClick:ue,children:[i(j,{className:`h-3.5 w-3.5`}),s(`ai.newChat`,`New chat`)]}),ne.length>0&&i(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:ne.map(e=>i(`button`,{type:`button`,onClick:()=>void de(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-xs hover:bg-surface-hover ${e.id===N?`bg-primary/10`:``}`,children:i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),i(`p`,{className:`text-xs text-foreground-subtle`,children:s(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),q!==null&&!Y(q)&&i(`p`,{className:`text-xs text-warning`,children:s(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]})}),L!==null&&i(P,{title:s(`ai.chatFailed`,`The test call failed`),message:L}),e(I,{headingId:`ai-test-conversation`,title:s(`ai.testConversation`,`Conversation`),actions:e(B,{size:`sm`,variant:`ghost`,type:`button`,disabled:g.length===0&&w===null,onClick:ue,children:[i(C,{className:`h-3.5 w-3.5`}),s(`ai.clearChat`,`Clear`)]}),children:[i($e,{turns:g,live:z}),e(`div`,{className:`${f} space-y-2 border-t border-border`,children:[w!==null&&e(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-background px-2.5 py-1.5`,children:[w.ref.kind===`snapshot`?i(b,{className:`h-3.5 w-3.5 text-foreground-subtle`}):i(v,{className:`h-3.5 w-3.5 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground`,children:w.label}),i(te,{size:`sm`,variant:`ghost`,type:`button`,icon:_,"aria-label":s(`ai.removeAttachment`,`Remove attachment`),onClick:()=>T(null)})]}),e(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e(B,{size:`sm`,variant:O===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`snapshot`?`none`:`snapshot`),children:[i(b,{className:`h-3.5 w-3.5`}),s(`ai.attachSnapshot`,`Camera snapshot`)]}),e(B,{size:`sm`,variant:O===`track`?`primary`:`outline`,type:`button`,onClick:()=>k(O===`track`?`none`:`track`),children:[i(v,{className:`h-3.5 w-3.5`}),s(`ai.attachTrack`,`Recent track`)]})]}),O===`snapshot`&&i(nt,{onPick:(e,t)=>{T({ref:{kind:`snapshot`,deviceId:e.id},label:s(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:t})}),k(`none`)}}),O===`track`&&i(it,{onPick:(e,t)=>{T({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:s(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),k(`none`)}}),e(`div`,{className:`flex items-center gap-2`,children:[i(ie,{value:p,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),ce())},placeholder:s(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":s(`ai.message`,`Message`)}),J?e(B,{size:`sm`,variant:`secondary`,type:`button`,onClick:le,children:[i(S,{className:`h-3.5 w-3.5`}),s(`ai.stop`,`Stop`)]}):e(B,{size:`sm`,type:`button`,disabled:p.trim()===``||c===``,onClick:ce,children:[i(D,{className:`h-3.5 w-3.5`}),s(`ai.send`,`Send`)]})]})]})]})]})}function $e({turns:t,live:n}){let{t:r}=W();return t.length===0&&n===null?i(z,{icon:A,title:r(`ai.chatEmptyTitle`,`No messages yet`),description:r(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):e(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto ${f}`,children:[t.map(e=>i(et,{turn:e},e.id)),n!==null&&e(`div`,{className:`space-y-1`,children:[n.mediaSent!==null&&i(tt,{attachment:n.mediaSent}),n.text.length>0&&i(et,{turn:{id:`live`,role:`assistant`,content:n.text},streaming:!0}),e(`div`,{className:`flex items-center gap-2 text-xs text-foreground-subtle`,children:[i(O,{className:`h-3.5 w-3.5 animate-spin`}),qe(n.phase,n.firstTokenTimeoutMs)]})]})]})}function et({turn:t,streaming:n=!1}){let{t:r}=W(),a=t.role===`user`,o=t.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return i(`div`,{className:`flex ${a?`justify-end`:`justify-start`}`,children:e(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${a?`border-primary/40 bg-primary/10`:o}`,children:[e(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[t.content,n&&i(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),t.attachment!==void 0&&i(tt,{attachment:t.attachment}),t.attachmentLabel!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachmentKind===`track`?i(v,{className:`h-3 w-3`}):i(b,{className:`h-3 w-3`}),t.attachmentLabel]}),t.attachment!==void 0&&e(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[t.attachment.kind===`snapshot`?i(b,{className:`h-3 w-3`}):i(v,{className:`h-3 w-3`}),Ke(t.attachment)]}),t.model!==void 0&&i(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:r(`system.aiTestChat.tokMs`,`{{model}} · {{value2}} tok · {{value3}} ms`,{model:t.model,value2:String(t.outputTokens??0),value3:String(t.latencyMs??0)})})]})})}function tt({attachment:e}){let{t}=W(),n=We(e);return n===null?null:i(`img`,{src:n,alt:t(`system.aiTestChat.sentToTheModel`,`sent to the model`),className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function nt({onPick:e}){let{t}=W(),n=L({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):i(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>i(rt,{device:t,onPick:e},t.id))})}function rt({device:t,onPick:n}){let{t:r}=W(),a=F(t,`compact`),{src:o}=p(t.id,{width:Ze});return e(`button`,{type:`button`,onClick:()=>n(t,a),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[i(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:o!==null&&i(`img`,{src:o,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),e(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!t.online&&i(R,{variant:`warning`,children:r(`common.off`)}),i(`span`,{className:`truncate text-[10px] text-foreground`,children:a})]})]})}function it({onPick:t}){let{t:r}=W(),a=E(),o=L({isCamera:!0,projection:`slim`}),c=n(()=>(o.data??[]).map(e=>e.id),[o.data]),l=n(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=s({queryKey:[...Je,c.length],enabled:c.length>0,queryFn:()=>a.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...c],since:Date.now()-Ye,limit:Xe,projection:`slim`})});if(o.isLoading||u.isLoading)return i(O,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?i(`p`,{className:`text-[11px] text-foreground-subtle`,children:r(`ai.noTracks`,`No track in the last 6 hours.`)}):i(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(n=>e(`button`,{type:`button`,onClick:()=>t(n,l.get(n.deviceId)??String(n.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[i(v,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),i(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:n.label??n.className}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:l.get(n.deviceId)??n.deviceId}),i(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(n.lastSeen).toLocaleTimeString()})]},n.trackId))})}c();var at=1440*60*1e3,ot=[1,7,30,90];function st(){let{t}=W(),r=E(),[a,c]=o(7),l=n(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(a-1)*at},[a]),u=ee({functionCap:`llm`}),d=s({queryKey:[...le,a],queryFn:()=>r.trpcClient.llm.getUsage.query({since:l})}),p=n(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=n(()=>[{key:`day`,header:t(`ai.colDay`,`Day`),nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:e.day})},{key:`consumer`,header:t(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>i(`span`,{className:`text-foreground`,children:e.consumer})},{key:`profile`,header:t(`ai.colProfile`,`Profile`),render:e=>i(`span`,{className:`text-foreground`,children:p.get(e.profileId)??e.profileId})},{key:`calls`,header:t(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(e.calls)})},{key:`okErr`,header:t(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums ${e.errorCalls>0?`text-danger`:``}`,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:t(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:`${String(e.inputTokens)} / ${String(e.outputTokens)}`})},{key:`latency`,header:t(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>i(`span`,{className:`tabular-nums`,children:String(Math.round(e.avgLatencyMs))})}],[p,t]),h=d.data??[],g=i(`div`,{className:`w-36`,children:i(x,{"aria-label":t(`ai.window`,`Window`),value:String(a),options:ot.map(e=>({value:String(e),label:t(`ai.lastDays`,`Last {{days}} days`,{days:e})})),onChange:e=>c(Number(e.target.value))})});return i(I,{headingId:`ai-usage-list`,title:t(`ai.usageList`,`Rollup`),actions:g,children:d.isPending?e(`div`,{className:`${f} space-y-2`,"data-testid":`ai-usage-loading`,children:[i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`}),i(M,{className:`h-8 w-full`})]}):d.isError?i(`div`,{className:f,children:i(P,{title:t(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:t(`common.error`,`Error`),onRetry:()=>void d.refetch()})}):h.length===0?i(z,{icon:y,title:t(`ai.noUsage`,`No AI calls in this window.`)}):i(H,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,maxBodyHeight:N})})}c();var ct=`llm`,lt=[`profiles`,`runtimes`,`usage`,`test`],ut=[`instance`,`instance-new`];function dt(e){return lt.some(t=>t===e)}function ft(){let{t:e}=W(),t=ne(ct),[n]=q(),r=K(`/system/ai`,{t:e,isAdmin:!0})??{icon:T,title:e(`system.ai`,`AI`)};if(t!==`present`)return i(ce,{icon:r.icon,title:r.title,children:i(gt,{presence:t})});let a=n.get(`tab`),o=dt(a)?a:`profiles`,s={profiles:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),runtimes:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),usage:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),test:e(`ai.testSubtitle`,`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`)};return i(J,{icon:r.icon,title:r.title,subtitle:s[o],defaultSection:`profiles`,sectionsLabel:`${r.title} sections`,sections:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),content:i(ht,{}),ownedParams:ut},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),content:i(Ne,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),content:i(st,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),content:i(Qe,{})}]})}function pt(e,t,n){let r=e.kind===`instance`?t.get(e.id):void 0;return r===void 0?void 0:n(r)}function mt(e,t){let n=t=>pt(t,e,X)??``,r=t=>pt(t,e,Y)??!1,a=t=>pt(t,e,ue)??``;return[{key:`model`,header:t(`ai.colModel`,`Model`),sortValue:n,render:e=>i(`span`,{className:`font-mono text-xs text-foreground-muted`,children:n(e)||`—`})},{key:`vision`,header:t(`ai.colVision`,`Vision`),sortValue:e=>+!!r(e),render:e=>r(e)?i(R,{variant:`info`,children:t(`ai.vision`,`vision`)}):null},{key:`node`,header:t(`ai.colNode`,`Node`),sortValue:a,render:e=>i(`span`,{className:`text-xs text-foreground-muted`,children:a(e)||`—`})}]}function ht(){let{t}=W(),r=ee({functionCap:ct}),a=n(()=>new Map((r.data??[]).map(e=>[e.id,e])),[r.data]),o=n(()=>mt(a,t),[a,t]);return e(`div`,{className:m,children:[i(be,{}),i(se,{functionCap:ct,icon:T,title:t(`ai.profilesList`,`Profiles`),subtitle:t(`ai.profilesTableSubtitle`,`Each profile is one model endpoint; switch one off to keep it without using it.`),emptyTitle:t(`ai.noProfilesTitle`,`No AI profiles yet`),emptyDescription:t(`ai.noProfilesDescription`,`Add a profile to give features a model to talk to.`),addLabel:t(`ai.addProfile`,`Add profile`),extraColumns:o,lead:e=>i(Ae,{row:e})})]})}function gt({presence:t}){let{t:n}=W();return t===`pending`?e(`div`,{className:`space-y-3`,"data-testid":`ai-presence-pending`,children:[i(M,{className:`h-8 w-64`}),i(M,{className:`h-40 w-full`})]}):t===`unknown`?i(P,{title:n(`ai.presenceUnknownTitle`,`Could not check whether AI is installed`),message:n(`ai.presenceUnknown`,`The hub did not answer the capability check. Reload the page to try again.`)}):i(z,{icon:T,title:n(`ai.absentTitle`,`AI is not installed`),description:n(`ai.absentDescription`,`Install the AI addon from System → Addons to add model profiles.`)})}export{ft as AiProfilesPage,ft as default};