@camstack/addon-admin-ui 1.2.328 → 1.2.330

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 (112) hide show
  1. package/dist/assets/{AddonCollectionPage-B8snF_lU.js → AddonCollectionPage-BGvPXFd4.js} +1 -1
  2. package/dist/assets/Addons-BE5HX8Kh.js +1 -0
  3. package/dist/assets/{AdminTabs-Bpqqvbac.js → AdminTabs-BFluDHSH.js} +1 -1
  4. package/dist/assets/AiProfiles-BtP_LFHX.js +3 -0
  5. package/dist/assets/{BrokerForm-UsfH8ouM.js → BrokerForm-f8H7gEpR.js} +1 -1
  6. package/dist/assets/Build-dd9955Wj.js +40 -0
  7. package/dist/assets/{Calendars-BwIEPJsY.js → Calendars-C927RnBR.js} +1 -1
  8. package/dist/assets/{Capabilities-CXL89VYm.js → Capabilities-BtJb_WbI.js} +1 -1
  9. package/dist/assets/Cluster-B4GCwbTO.js +11 -0
  10. package/dist/assets/CompositionEditor-BmBT-tSk.js +1 -0
  11. package/dist/assets/{CompositionEditorPage-B6ZRZeKR.js → CompositionEditorPage-BWjd2jy7.js} +1 -1
  12. package/dist/assets/Data-B3iSwwht.js +1 -0
  13. package/dist/assets/DetectionIntelligence-qyghT3Ii.js +1 -0
  14. package/dist/assets/DeviceDetail-BZ7nk5VG.js +2 -0
  15. package/dist/assets/{DeviceDoActionFields-BkOLKBZj.js → DeviceDoActionFields-B19O_9BT.js} +1 -1
  16. package/dist/assets/{Devices-BmDtzRtT.js → Devices-BBtYW5yf.js} +1 -1
  17. package/dist/assets/{EmbedPlayerPage-CIHIXf6A.js → EmbedPlayerPage-ec76Ypbl.js} +1 -1
  18. package/dist/assets/Events-BzcQa4ah.js +1 -0
  19. package/dist/assets/Identity-CVrfKg6B.js +1 -0
  20. package/dist/assets/IntegrationDetail-CqtmCE70.js +1 -0
  21. package/dist/assets/{Integrations-CuYC2ksu.js → Integrations-C_YdoSjA.js} +1 -1
  22. package/dist/assets/Integrations-CtB9iyXd.js +1 -0
  23. package/dist/assets/Locations-CBtkkmU4.js +3 -0
  24. package/dist/assets/{Logs-B9F_i6jL.js → Logs-McOzfwf5.js} +1 -1
  25. package/dist/assets/{MotionZonesSettings-yUFzAS0j.js → MotionZonesSettings-C_FvegYU.js} +1 -1
  26. package/dist/assets/MyAccess-CsJBJSi-.js +2 -0
  27. package/dist/assets/Network-ZXyeOelt.js +1 -0
  28. package/dist/assets/{NodeAddonsSettingsPanel-CwHRAUlB.js → NodeAddonsSettingsPanel-C56sPvtL.js} +1 -1
  29. package/dist/assets/NodeInferenceDevices-Bqo-7570.js +1 -0
  30. package/dist/assets/Notifications-YukSowyX.js +1 -0
  31. package/dist/assets/Pipeline-DLRmcN_Q.js +1 -0
  32. package/dist/assets/Plates-DmFSQNFe.js +1 -0
  33. package/dist/assets/{PrivacyMaskSettings-e-q-iS5G.js → PrivacyMaskSettings-DYJX-Ljr.js} +1 -1
  34. package/dist/assets/Recordings-PkJ0G8NB.js +1 -0
  35. package/dist/assets/{ScanNetworkModal-6o_Q-QY0.js → ScanNetworkModal-DKwhvvYq.js} +1 -1
  36. package/dist/assets/{SceneMonitorEditor-Cy_ctsoP.js → SceneMonitorEditor-B4-zs3WA.js} +1 -1
  37. package/dist/assets/{Scenes-CKYsrW-w.js → Scenes-BJHNURPw.js} +1 -1
  38. package/dist/assets/{Settings-VY_r8tRj.js → Settings-DahXgC20.js} +1 -1
  39. package/dist/assets/{Showroom-DZxLnLe2.js → Showroom-DHNwi9pE.js} +1 -1
  40. package/dist/assets/{StorageLocationsPanel-Ds7Z-XYx.js → StorageLocationsPanel-Bu7c32vF.js} +1 -1
  41. package/dist/assets/{Terminal-BS23MTT3.js → Terminal-AF4QYRZZ.js} +3 -3
  42. package/dist/assets/{Viewer-Pl82jxG0.js → Viewer-C1-4AVSD.js} +1 -1
  43. package/dist/assets/{_virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DY3UZzEG.js → _virtual_mf-localSharedImportMap___mfe_internal__admin_ui_host-DXbI3DPG.js} +1 -1
  44. package/dist/assets/{archive-BSV_Edqx.js → archive-gWBFIT2D.js} +1 -1
  45. package/dist/assets/{authed-media-CYOU3z5k.js → authed-media-CkAe7M1O.js} +1 -1
  46. package/dist/assets/{boxes-4oXlPoua.js → boxes-BMaw7T0C.js} +1 -1
  47. package/dist/assets/circle-slash-exzl9yW0.js +1 -0
  48. package/dist/assets/{debounced-invalidate-cC8_G6hW.js → debounced-invalidate-C04KV_wn.js} +1 -1
  49. package/dist/assets/{device-integration-icon-CbPa1yFn.js → device-integration-icon-C4GjLB9n.js} +1 -1
  50. package/dist/assets/device-picker-model-Ds54E7eB.js +1 -0
  51. package/dist/assets/dist-2wXmuZBO.js +357 -0
  52. package/dist/assets/{dist-B0PPWfPE.js → dist-DK0k4z5N.js} +1 -1
  53. package/dist/assets/{face-bbox-BTuIosno.js → face-bbox-Dg6C7OMO.js} +1 -1
  54. package/dist/assets/{hard-drive-download-Dwddfgke.js → hard-drive-download-Cpu8d8G_.js} +1 -1
  55. package/dist/assets/{hostInit-kDKlKojp.js → hostInit-D-LMJAGD.js} +1 -1
  56. package/dist/assets/index-CfVrkT4q.js +4 -0
  57. package/dist/assets/index-DQbnU8cj.css +2 -0
  58. package/dist/assets/{layers-dcoNdv3X.js → layers-ByvtFPPP.js} +1 -1
  59. package/dist/assets/{location-owned-usage-BQE3nGax.js → location-owned-usage-1THZb4ah.js} +1 -1
  60. package/dist/assets/{mf-entry-bootstrap-0-c3f1a18e.js → mf-entry-bootstrap-0-7d1d99d4.js} +2 -2
  61. package/dist/assets/mount-Ds54E7eB.js +1 -0
  62. package/dist/assets/notification-schedule-field-D6mKEw0W.js +1 -0
  63. package/dist/assets/player-overlays-CEHVDSJu.js +1 -0
  64. package/dist/assets/remoteEntry-xb8EJH2S.js +1 -0
  65. package/dist/assets/{send-D8FSzLx_.js → send-DagoqhTj.js} +1 -1
  66. package/dist/assets/{settings-2-CNe1vvNy.js → settings-2-b3j8Pwfi.js} +1 -1
  67. package/dist/assets/{square-check-big-D-z4gacg.js → square-check-big-CN0Jzq_i.js} +1 -1
  68. package/dist/assets/src-CQ9R75CO.js +67 -0
  69. package/dist/assets/src-DDxhrhKR.js +357 -0
  70. package/dist/assets/{use-scenes-feed-DERSlhov.js → use-scenes-feed-Dptn_Cyw.js} +1 -1
  71. package/dist/assets/{use-stationary-objects-BThWmCzz.js → use-stationary-objects-CxxpG4_u.js} +1 -1
  72. package/dist/assets/useEventInvalidation-Ds54E7eB.js +1 -0
  73. package/dist/assets/{useNodeUrlSelection-DakfxYEQ.js → useNodeUrlSelection-DUkN1GGf.js} +1 -1
  74. package/dist/assets/user-round-CkMm4TOh.js +1 -0
  75. package/dist/assets/{virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CCfc8O8I.js → virtual_mf-REMOTE_ENTRY_ID___mfe_internal__admin_ui_host__remoteEntry-_hash_-CnR6eZYL.js} +2 -2
  76. package/dist/index.html +8 -8
  77. package/dist/server/addon.js +123 -77
  78. package/package.json +1 -1
  79. package/dist/assets/Addons-CcTmj3Q3.js +0 -1
  80. package/dist/assets/AiProfiles-CtWiawbr.js +0 -3
  81. package/dist/assets/Build-WsXnQiq2.js +0 -40
  82. package/dist/assets/Cluster-CTpJYzzU.js +0 -11
  83. package/dist/assets/CompositionEditor-BLwFGQbi.js +0 -1
  84. package/dist/assets/Data-BCHG0qI2.js +0 -1
  85. package/dist/assets/DetectionIntelligence-yFqq3Yo9.js +0 -1
  86. package/dist/assets/DeviceDetail-B4KB91wg.js +0 -2
  87. package/dist/assets/Events-BLe75d9R.js +0 -1
  88. package/dist/assets/Identity-wzc-BhZV.js +0 -1
  89. package/dist/assets/IntegrationDetail-DFoBibNQ.js +0 -1
  90. package/dist/assets/Integrations-CjbLn7QH.js +0 -1
  91. package/dist/assets/Locations-BW_tC9KS.js +0 -3
  92. package/dist/assets/ModelLicenses-IAznNU0d.js +0 -1
  93. package/dist/assets/MyAccess-C0ksEgOm.js +0 -2
  94. package/dist/assets/Network-CQoqzSGE.js +0 -1
  95. package/dist/assets/NodeInferenceDevices-CwI-yFzL.js +0 -1
  96. package/dist/assets/Notifications-4yMchvmK.js +0 -1
  97. package/dist/assets/Pipeline-BbYQzBPi.js +0 -1
  98. package/dist/assets/Plates-D3R7IBT6.js +0 -1
  99. package/dist/assets/Recordings-CafcuyaF.js +0 -1
  100. package/dist/assets/circle-slash-Dv1fvn11.js +0 -1
  101. package/dist/assets/device-picker-model-BIE3EBc7.js +0 -1
  102. package/dist/assets/dist-NV_sDPNr.js +0 -356
  103. package/dist/assets/index-BF2TDr1R.js +0 -4
  104. package/dist/assets/index-ZqdYeoA9.css +0 -2
  105. package/dist/assets/mount-BIE3EBc7.js +0 -1
  106. package/dist/assets/notification-schedule-field-WV5egiCv.js +0 -1
  107. package/dist/assets/player-overlays-D16jpLuq.js +0 -1
  108. package/dist/assets/remoteEntry-CQ4ZppGP.js +0 -1
  109. package/dist/assets/src-BMs7x0zW.js +0 -356
  110. package/dist/assets/src-DBvNufmZ.js +0 -67
  111. package/dist/assets/useEventInvalidation-BIE3EBc7.js +0 -1
  112. package/dist/assets/user-round-B24IGs8J.js +0 -1
@@ -10539,11 +10539,11 @@ var ModelVariantGroupSchema = object({
10539
10539
  /** Quantization axis. Omit ⇒ the fp32 base build. */
10540
10540
  precision: _enum(["fp32", "int8"]).optional(),
10541
10541
  /**
10542
- * Speed-optimization axis. Omit ⇒ the standard build. `fast` marks a
10543
- * latency-optimized export (e.g. ReLU-activation variant) — the slot the
10544
- * future performance variants plug into.
10542
+ * Training / latency-variant axis. Omit ⇒ the standard build. `test` marks
10543
+ * an alternate training of the same family (Scrypted `relu_test`); chip
10544
+ * label is "Test".
10545
10545
  */
10546
- optimization: _enum(["standard", "fast"]).optional(),
10546
+ optimization: _enum(["standard", "test"]).optional(),
10547
10547
  /**
10548
10548
  * Input-resolution axis (square input side, px). Omit ⇒ the family's native
10549
10549
  * resolution (640 for yolo26). Reduced-input builds (320 / 256) are a big,
@@ -10566,9 +10566,10 @@ var ModelProviderIdSchema = _enum([
10566
10566
  * are per upstream. A persisted custom-model row written when this field was a
10567
10567
  * string still parses — the string is lifted into `{ weights }`.
10568
10568
  *
10569
- * Every licence surface (the admin "Models and licenses" page,
10570
- * `THIRD_PARTY_MODELS.md`, the Hugging Face model table) is GENERATED from
10571
- * these records by `scripts/gen-model-licenses.ts` (D661).
10569
+ * Every machine licence surface (`THIRD_PARTY_MODELS.md`, the Hugging Face
10570
+ * model table) is GENERATED from these records by
10571
+ * `scripts/gen-model-licenses.ts` (D661). Operator-facing docs live in
10572
+ * `camstack/docs` → `/docs/detection/models`.
10572
10573
  */
10573
10574
  var ModelLicenseSchema = preprocess((value) => typeof value === "string" ? { weights: value } : value, object({
10574
10575
  /** SPDX id of the WEIGHTS' terms, a `LicenseRef-*` for non-SPDX terms, or `UNKNOWN`. */
@@ -14097,7 +14098,7 @@ DeviceType.Camera;
14097
14098
  * This matters here more than anywhere else in the repo, because every provider
14098
14099
  * that knows a device's host knows its PASSWORD too: `{ host, port, username,
14099
14100
  * password }` sit in one object on Hikvision, Amcrest, Reolink and ONVIF alike,
14100
- * and `http://admin:hunter2@192.168.x.x/` is a URL a browser accepts. The
14101
+ * and `http://admin:hunter2@192.168.60.139/` is a URL a browser accepts. The
14101
14102
  * camera's own page will ask for its own login. That is correct, and pre-
14102
14103
  * filling it is the operator's business, not ours.
14103
14104
  *
@@ -17081,7 +17082,7 @@ method(object({
17081
17082
  timeoutMs: 6e5
17082
17083
  });
17083
17084
  method(object({
17084
- nodeId: string(),
17085
+ targetNodeId: string(),
17085
17086
  modelId: string(),
17086
17087
  format: _enum(MODEL_FORMATS),
17087
17088
  entry: ModelCatalogEntrySchema
@@ -19547,8 +19548,9 @@ var NcRuleSchema = NcRuleInputSchema.extend({
19547
19548
  disabledTargetIds: array(string()).default([])
19548
19549
  });
19549
19550
  /**
19550
- * The state-summary SECTIONS (D647 / D698): the D637 kind groups that report a
19551
- * still-true state. `backups-exports` and `alarm` are not sections — a completed
19551
+ * The state-summary SECTIONS (D647 / D698 / D708): the D637 kind groups that
19552
+ * report a still-true state. `addons` is the crash-looped addons only and
19553
+ * `addon-updates` the addons that are behind (D708 split them). `backups-exports` and `alarm` are not sections — a completed
19552
19554
  * job is not an open state, and the alarm stays instant.
19553
19555
  */
19554
19556
  var NcStateSummarySectionIdSchema = _enum([
@@ -19560,6 +19562,7 @@ var NcStateSummarySectionIdSchema = _enum([
19560
19562
  "detection-blind",
19561
19563
  "nodes",
19562
19564
  "addons",
19565
+ "addon-updates",
19563
19566
  "updates"
19564
19567
  ]);
19565
19568
  /** One section of a previewed state summary. `unavailable` = its state could not be read. */
@@ -20040,7 +20043,19 @@ var NcAlarmModeDelaysListSchema = array(object({
20040
20043
  * When this mode may be armed. Absent / null = always allowed (same as a
20041
20044
  * rule with no `schedule`). Evaluated with {@link isScheduleActive}.
20042
20045
  */
20043
- schedule: NcScheduleSchema.optional()
20046
+ schedule: NcScheduleSchema.optional(),
20047
+ /**
20048
+ * D706: while this mode's ENTRY DELAY runs, do the alarm rules' own pushes go out (as an
20049
+ * intrusion naming the locations)? Absent = false — the entry-delay notification is the
20050
+ * only one, and the matches ride the triggered notification's mosaic (D705).
20051
+ */
20052
+ notifyDuringEntryDelay: boolean().optional(),
20053
+ /**
20054
+ * D706: notify "watched again" when a sensor this arm bypassed closes and opens again.
20055
+ * Absent = false (logged, not sent). Even when true it is not sent when that same sensor
20056
+ * is the one that starts the entry delay — the entry-delay notification already names it.
20057
+ */
20058
+ notifySensorRewatched: boolean().optional()
20044
20059
  })).max(8).refine(uniqueModes, { message: "modeDelays: at most one entry per arm mode" });
20045
20060
  var NcAlarmModeDelaysEditListSchema = array(object({
20046
20061
  mode: AlarmArmModeSchema,
@@ -20049,7 +20064,11 @@ var NcAlarmModeDelaysEditListSchema = array(object({
20049
20064
  triggeredDurationSec: NcAlarmTriggeredSecSchema.nullable().optional(),
20050
20065
  postTriggeredAction: NcAlarmPostTriggeredActionSchema.nullable().optional(),
20051
20066
  /** Set a schedule, or `null` to clear (mode always allowed again). */
20052
- schedule: NcScheduleSchema.nullable().optional()
20067
+ schedule: NcScheduleSchema.nullable().optional(),
20068
+ /** D706: set the switch, or `null` to clear it (back to the default, false). */
20069
+ notifyDuringEntryDelay: boolean().nullable().optional(),
20070
+ /** D706: set the switch, or `null` to clear it (back to the default, false). */
20071
+ notifySensorRewatched: boolean().nullable().optional()
20053
20072
  })).max(8).refine(uniqueModes, { message: "modeDelays: at most one edit per arm mode" });
20054
20073
  /** One switch of the alarm table: put ONE device on, or take it off, ONE mode's list. */
20055
20074
  var NcAlarmNonBlockingEditSchema = object({
@@ -21010,39 +21029,19 @@ Object.freeze(Object.fromEntries([{
21010
21029
  label: "Face recognition model",
21011
21030
  defaultModelId: "auraface-r100",
21012
21031
  indexName: "the enrolled face gallery",
21013
- options: [
21014
- {
21015
- id: "auraface-r100",
21016
- label: "AuraFace R100"
21017
- },
21018
- {
21019
- id: "arcface-r100",
21020
- label: "ArcFace (ResNet34)"
21021
- },
21022
- {
21023
- id: "inception-resnet-v1",
21024
- label: "Inception ResNet V1"
21025
- }
21026
- ]
21032
+ options: [{
21033
+ id: "auraface-r100",
21034
+ label: "AuraFace R100"
21035
+ }]
21027
21036
  }, {
21028
21037
  stepId: "clip-embedding",
21029
21038
  label: "Semantic search model",
21030
- defaultModelId: "mobileclip-s1",
21039
+ defaultModelId: "siglip2-b16-224",
21031
21040
  indexName: "the object semantic-search index",
21032
- options: [
21033
- {
21034
- id: "mobileclip-s1",
21035
- label: "MobileCLIP S1"
21036
- },
21037
- {
21038
- id: "mobileclip-s2",
21039
- label: "MobileCLIP S2"
21040
- },
21041
- {
21042
- id: "siglip2-b16-224",
21043
- label: "SigLIP2 B/16 (Apache-2.0)"
21044
- }
21045
- ]
21041
+ options: [{
21042
+ id: "siglip2-b16-224",
21043
+ label: "SigLIP2 B/16 (Apache-2.0)"
21044
+ }]
21046
21045
  }].map((s) => [s.stepId, s.defaultModelId])));
21047
21046
  var CLUSTER_STEP_SETTING_FIELDS = [{
21048
21047
  stepId: "face-embedding",
@@ -23890,6 +23889,22 @@ var MotionSourceEnum = _enum([
23890
23889
  "device-activity"
23891
23890
  ]);
23892
23891
  /**
23892
+ * What opened an on-motion detection SESSION: the motion source that passed the
23893
+ * camera's `motionSources` gate, and what raised it (the camera itself, or a
23894
+ * sensor the operator attached — D672). `sensorName` is the attached sensor's
23895
+ * device name as the orchestrator's camera-sensors resolution last read it;
23896
+ * absent when unknown or when the camera itself triggered.
23897
+ *
23898
+ * Carried on the session attach ONLY so the runner's `DetectionPhaseTransition`
23899
+ * can say what started the session (D672 rule 11, amended 2026-10-06). The
23900
+ * runner never decides anything on it.
23901
+ */
23902
+ var SessionTriggerSchema = object({
23903
+ source: MotionSourceEnum,
23904
+ triggeredBy: MotionTriggeredBySchema,
23905
+ sensorName: string().optional()
23906
+ });
23907
+ /**
23893
23908
  * List of motion sources active on a camera. Empty array is valid:
23894
23909
  * "no source" — happens for battery cams without firmware motion when
23895
23910
  * the operator hasn't opted into the SW analyzer (would hold the
@@ -24141,6 +24156,14 @@ var RunnerCameraConfigSchema = object({
24141
24156
  */
24142
24157
  motionSources: MotionSourcesSchema.default(["analyzer"]),
24143
24158
  /**
24159
+ * What opened this attach, on a SESSION attach only (see
24160
+ * {@link SessionTriggerSchema}). OPTIONAL with no default: absent on a
24161
+ * standing attach, an occupancy burst, a re-dispatch with no motion event
24162
+ * behind it, and every attach from an orchestrator older than the field — the
24163
+ * runner then names no source on the phase event.
24164
+ */
24165
+ sessionTrigger: SessionTriggerSchema.optional(),
24166
+ /**
24144
24167
  * WHICH root detector runs for this camera. The detection counterpart of
24145
24168
  * {@link motionSources}, same shape and same discipline: a per-camera list
24146
24169
  * of sources the system understands, vendor-agnostic, owned here.
@@ -30364,7 +30387,7 @@ var LocalInterfaceSchema = object({
30364
30387
  name: string(),
30365
30388
  family: _enum(["IPv4", "IPv6"]),
30366
30389
  address: string(),
30367
- /** CIDR shorthand (e.g. `192.168.x.x/24`). Empty when OS doesn't expose. */
30390
+ /** CIDR shorthand (e.g. `192.168.10.10/24`). Empty when OS doesn't expose. */
30368
30391
  cidr: string(),
30369
30392
  /** OS netmask. Stable across calls so the SDK can hash on it. */
30370
30393
  netmask: string(),
@@ -30418,7 +30441,8 @@ var ConnectionEndpointSchema = object({
30418
30441
  "lan-ipv4",
30419
30442
  "lan-ipv6",
30420
30443
  "public",
30421
- "loopback"
30444
+ "loopback",
30445
+ "app-link"
30422
30446
  ]),
30423
30447
  /**
30424
30448
  * Originating-interface kind — `lan`/`wifi`/`docker`/`vpn`/`other`/
@@ -30487,15 +30511,27 @@ var GetConnectionEndpointsResultSchema = object({
30487
30511
  localPort: AdvertisedLocalPortSchema
30488
30512
  });
30489
30513
  /**
30490
- * The chosen outbound endpoint for notification artifacts. `baseUrl: null` =
30491
- * AUTO (resolved from the candidate ranking at send time); `resolved` reports
30492
- * what AUTO currently picks, so the UI can show the effective value either way.
30514
+ * The address flagged for notification links. `baseUrl: null` = AUTO, which
30515
+ * since D709 is the CamStack app link; `resolved` reports the effective value,
30516
+ * so the UI can show it either way.
30493
30517
  */
30494
30518
  var NotificationEndpointSchema = object({
30495
30519
  /** The operator's explicit choice, or null for AUTO. */
30496
30520
  baseUrl: string().nullable(),
30497
- /** What the ranking currently resolves to (null when nothing is reachable). */
30498
- resolved: string().nullable()
30521
+ /**
30522
+ * The effective flagged address: the explicit choice, else (AUTO) the
30523
+ * CamStack app link `https://camstack.zentik.app` (D709). A pre-D709 hub
30524
+ * answered the public tunnel / mesh here, or null.
30525
+ */
30526
+ resolved: string().nullable(),
30527
+ /**
30528
+ * The hub origin an app link carries as `hub=` (D709): the hub's best
30529
+ * public HTTPS address — the tunnel, then the mesh (Tailscale MagicDNS) —
30530
+ * picked from this cap's own palette by `pickAppLinkHub`. `null` when the
30531
+ * hub advertises neither; the app link is then minted without `hub=`.
30532
+ * Absent on a pre-D709 hub.
30533
+ */
30534
+ appLinkHub: string().nullable()
30499
30535
  });
30500
30536
  /**
30501
30537
  * The URLs the SDK / viewer should race for API access. `baseUrls` empty =
@@ -30549,7 +30585,11 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
30549
30585
  * Pass `'https'` when the caller is itself loaded over HTTPS
30550
30586
  * to avoid mixed-content blocks in the browser. The public
30551
30587
  * tunnel always emits `https://` regardless. */
30552
- scheme: _enum(["http", "https"]).optional()
30588
+ scheme: _enum(["http", "https"]).optional(),
30589
+ /** Append the CamStack app link entry (`kind: 'app-link'`, D709) —
30590
+ * an address notification links can be flagged with, not a hub
30591
+ * route. Default `false`: racers and rankers never see it. */
30592
+ includeAppLink: boolean().optional()
30553
30593
  }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), ViewerEndpointsSchema), method(object({ baseUrls: array(string()).readonly() }), ViewerEndpointsSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" }), method(_void(), TlsStatusSchema), method(object({ reason: string().optional() }), TlsStatusSchema, {
30554
30594
  kind: "mutation",
30555
30595
  auth: "admin"
@@ -30810,7 +30850,7 @@ var MeshPeerSchema = object({
30810
30850
  tags: array(string()).readonly(),
30811
30851
  /** True when the peer advertises itself as an exit-node candidate. */
30812
30852
  exitNodeOption: boolean(),
30813
- /** Subnet routes the peer advertises (e.g. `["192.168.x.x/24"]`). */
30853
+ /** Subnet routes the peer advertises (e.g. `["192.168.10.0/24"]`). */
30814
30854
  advertisedRoutes: array(string()).readonly(),
30815
30855
  /** Owner account login (e.g. `foo@example.com`). Null for tagged peers. */
30816
30856
  userLogin: string().nullable(),
@@ -31754,7 +31794,13 @@ var OsdStatusSchema = object({ overlays: array(object({
31754
31794
  */
31755
31795
  availablePositions: array(OsdPositionEnum).readonly(),
31756
31796
  /** Firmware does not allow editing the `text` field (e.g. timestamp). */
31757
- readOnly: boolean().optional()
31797
+ readOnly: boolean().optional(),
31798
+ /**
31799
+ * Firmware text ceiling for this overlay. Absent = no known limit.
31800
+ * The OSD manager truncates here on every write — never stores its own
31801
+ * copy on the binding.
31802
+ */
31803
+ maxCharacters: number().int().positive().optional()
31758
31804
  })).readonly() });
31759
31805
  var OsdOverlayPatchSchema = object({
31760
31806
  enabled: boolean().optional(),
@@ -31805,7 +31851,9 @@ var OsdTemplateBindingSchema = object({
31805
31851
  valuePath: string().min(1).max(64),
31806
31852
  /** Convert TO this unit at render (`tryConvertUnit`). Absent = source unit. */
31807
31853
  displayUnit: string().max(16).optional(),
31808
- maxDecimals: number().int().min(0).max(4).default(1)
31854
+ maxDecimals: number().int().min(0).max(4).default(1),
31855
+ /** Raw value → display text (same shape as slot binding). Empty string hides. */
31856
+ valueMap: record(string(), string()).optional()
31809
31857
  });
31810
31858
  /**
31811
31859
  * A named template: bindings (alias → leaf field) + a parser that
@@ -31855,18 +31903,11 @@ var OsdSlotBindingSchema = object({
31855
31903
  source: OsdSourceSchema,
31856
31904
  /** `${value}` and `${unit}` are substituted; every occurrence. */
31857
31905
  template: string().max(96).default("${value}"),
31858
- /** Truncate with an ellipsis past this length. Absent = no limit. */
31859
- maxCharacters: number().int().min(4).max(64).optional(),
31860
31906
  /**
31861
31907
  * Decimal places for a numeric value. `0` yields an integer — the
31862
31908
  * documented workaround for firmwares that reject `.` in overlay text.
31863
31909
  */
31864
31910
  maxDecimals: number().int().min(0).max(4).default(1),
31865
- /**
31866
- * Appended via `${unit}` when no unit conversion produces a label.
31867
- * Prefer `source.displayUnit` for converted device-state values.
31868
- */
31869
- unitLabel: string().max(8).optional(),
31870
31911
  /** Raw value → display text, e.g. `{"true":"MOTION","false":""}`. */
31871
31912
  valueMap: record(string(), string()).optional(),
31872
31913
  /** Time windows in which the slot is shown. Absent = always. */
@@ -31875,9 +31916,7 @@ var OsdSlotBindingSchema = object({
31875
31916
  * Display gate, in the notification centre's condition vocabulary.
31876
31917
  * Only the keys reported by `getConditionSupport` are accepted.
31877
31918
  */
31878
- conditions: NcConditionsSchema.optional(),
31879
- /** Rendered when the gate is closed or the value unreadable. Empty = hide. */
31880
- fallbackText: string().max(64).default("")
31919
+ conditions: NcConditionsSchema.optional()
31881
31920
  });
31882
31921
  /** One camera slot, as the operator sees it: firmware truth + our binding. */
31883
31922
  var OsdSlotViewSchema = object({
@@ -47554,12 +47593,14 @@ var NC_SYSTEM_EVENT_KIND_GROUP_SPECS = [
47554
47593
  {
47555
47594
  id: "addons",
47556
47595
  family: "system",
47557
- label: "Addons",
47558
- kinds: [
47559
- "addon-crash-loop",
47560
- "addon-update-available",
47561
- "addon-updated"
47562
- ]
47596
+ label: "Addons stopped",
47597
+ kinds: ["addon-crash-loop"]
47598
+ },
47599
+ {
47600
+ id: "addon-updates",
47601
+ family: "system",
47602
+ label: "Addon updates",
47603
+ kinds: ["addon-update-available", "addon-updated"]
47563
47604
  },
47564
47605
  {
47565
47606
  id: "updates",
@@ -47719,13 +47760,15 @@ var STATE_SUMMARY_SECTION_VARS = [
47719
47760
  },
47720
47761
  {
47721
47762
  name: "summaryAddons",
47722
- label: "Summary: addons",
47723
- example: "@camstack/addon-recorder 1.2.3 → 1.2.4",
47724
- kinds: [
47725
- "addon-crash-loop",
47726
- "addon-update-available",
47727
- "addon-updated"
47728
- ]
47763
+ label: "Summary: addons stopped",
47764
+ example: "hub — recorder stopped after repeated crashes",
47765
+ kinds: ["addon-crash-loop"]
47766
+ },
47767
+ {
47768
+ name: "summaryAddonUpdates",
47769
+ label: "Summary: addon updates",
47770
+ example: "hub:\n• @camstack/addon-recorder 1.2.3 → 1.2.4",
47771
+ kinds: ["addon-update-available", "addon-updated"]
47729
47772
  },
47730
47773
  {
47731
47774
  name: "summaryUpdates",
@@ -47809,6 +47852,7 @@ var STATE_SUMMARY_VARS = [
47809
47852
  [...RULE_BODY_ONLY],
47810
47853
  [...RULE_TEXT],
47811
47854
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
47855
+ ([...RULE_TEXT], [...COMBINED_ALARM]),
47812
47856
  ([...RULE_TEXT], [...DEVICE_EVENTS]),
47813
47857
  ([...RULE_TEXT], [...BATTERY, ...CONSUMABLE]),
47814
47858
  ([...RULE_TEXT], [...CONSUMABLE]),
@@ -47849,6 +47893,8 @@ var STATE_SUMMARY_VARS = [
47849
47893
  [...RULE_TEXT],
47850
47894
  [...RULE_TEXT],
47851
47895
  [...RULE_TEXT],
47896
+ [...RULE_TEXT],
47897
+ [...RULE_TEXT],
47852
47898
  ...STATE_SUMMARY_VARS
47853
47899
  ];
47854
47900
  new Set([
@@ -48387,7 +48433,7 @@ var AdminUIAddon = class extends BaseAddon {
48387
48433
  capability: adminUiCapability,
48388
48434
  provider: {
48389
48435
  getStaticDir: async () => ({ staticDir: resolveAdminUiDistDir() }),
48390
- getVersion: async () => ({ version: "1.2.328" })
48436
+ getVersion: async () => ({ version: "1.2.330" })
48391
48437
  }
48392
48438
  }];
48393
48439
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-admin-ui",
3
- "version": "1.2.328",
3
+ "version": "1.2.330",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "description": "Admin UI — Vite frontend build and server-side addon",
@@ -1 +0,0 @@
1
- import{I as e,K as t,Q as n,R as r,S as i,W as a,b as o,o as s,q as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{Z as d,_t as f,st as p,yt as m}from"./player-overlays-D16jpLuq.js";import{Ml as h,Mn as ee,Qn as g,Qu as _,R as v,Yl as y,_u as b,ar as te,au as x,bl as S,br as ne,bu as C,cr as re,dd as ie,dr as ae,du as w,er as oe,gd as T,gl as se,gr as E,hr as ce,ht as le,ir as ue,iu as D,ju as O,k,lr as de,md as fe,mo as A,mr as j,mt as M,mu as N,nr as P,nu as F,od as I,or as L,pl as R,pr as z,rr as B,tr as pe,ur as V,vr as me,yr as H}from"./src-DBvNufmZ.js";import{jr as U}from"./src-BMs7x0zW.js";import"./mount-BIE3EBc7.js";import{F as he,N as ge}from"./index-BF2TDr1R.js";import{t as W}from"./AdminPage-CiKtOLQm.js";import{t as _e}from"./NodeAddonsSettingsPanel-CwHRAUlB.js";import{r as G,t as K}from"./useNodeUrlSelection-DakfxYEQ.js";var q=m(`octagon-alert`,[[`path`,{d:`M12 16h.01`,key:`1drbdi`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z`,key:`1fd625`}]]);n();var J=new Set([`completed`,`failed`,`partially-failed`,`cancelled`]),ve=new Set([`done`,`failed`,`skipped`]);function Y(e){return!ve.has(e.phase)&&!J.has(e.jobState)}function X(e,t){let n=new Map,r=[...e].sort((e,t)=>e.createdAtMs-t.createdAtMs);for(let e of r){let r=J.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 ye(){let{data:e}=re({activeOnly:!0},{refetchOnWindowFocus:!1,refetchInterval:e=>(e.state.data?.length??0)>0?3e3:!1}),{map:t}=se(U.AddonsJobProgress,e=>e.job.jobId);return a(()=>{let n=new Map;for(let t of e??[])n.set(t.jobId,t);for(let[e,r]of t)n.set(e,r.job);return X([...n.values()],Date.now())},[e,t])}var be={queued:{icon:I,cls:`bg-muted text-foreground-subtle`,label:`queued`},fetching:{icon:O,cls:`bg-primary/10 text-primary`,label:`fetching`,spin:!0},staged:{icon:O,cls:`bg-primary/10 text-primary`,label:`staged`,spin:!0},validating:{icon:O,cls:`bg-primary/10 text-primary`,label:`validating`,spin:!0},applying:{icon:O,cls:`bg-primary/10 text-primary`,label:`applying`,spin:!0},restarting:{icon:O,cls:`bg-amber-500/10 text-amber-600 dark:text-amber-400`,label:`restarting`,spin:!0},applied:{icon:O,cls:`bg-primary/10 text-primary`,label:`finalizing`,spin:!0},done:{icon:T,cls:`bg-success/10 text-success`,label:`updated`},failed:{icon:q,cls:`bg-danger/10 text-danger`,label:`failed`},skipped:{icon:y,cls:`bg-muted text-foreground-subtle`,label:`skipped`}};function xe({progress:e}){let t=be[e.phase],n=t.icon,r=e.error??`${e.packageName}: ${e.fromVersion??`?`} → ${e.toVersion}`;return i(`span`,{"data-testid":`addon-job-progress`,className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded shrink-0 ${t.cls}`,title:r,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label,i(`span`,{className:`font-mono`,children:[`→ `,e.toVersion]})]})}function Se({packageName:e,currentVersion:t,installSource:n,onInstall:r,onClose:a,onSelect:s,selectedVersion:c}){let u=n===`upload`||n===`local`,{data:d,isLoading:f}=ue({name:e});return i(`div`,{className:`fixed z-50 w-72 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,style:{top:`auto`,bottom:`auto`},ref:e=>{if(!e)return;let t=e.parentElement?.getBoundingClientRect();if(!t)return;let n=window.innerHeight-t.bottom,r=t.top;n<280&&r>n?(e.style.bottom=`${window.innerHeight-t.top+4}px`,e.style.top=`auto`):(e.style.top=`${t.bottom+4}px`,e.style.bottom=`auto`),e.style.right=`${window.innerWidth-t.right}px`},onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-border`,children:[l(`span`,{className:`text-[10px] uppercase tracking-wide text-foreground-subtle font-medium`,children:`Versions`}),l(`button`,{type:`button`,onClick:a,className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3 w-3`})})]}),u&&i(`div`,{className:`flex items-start gap-2 px-3 py-2 border-b border-border bg-cyan-500/10 text-[10px]`,children:[l(h,{className:`h-3 w-3 mt-0.5 text-cyan-500 shrink-0`}),i(`div`,{className:`text-cyan-700 dark:text-cyan-200`,children:[i(`span`,{className:`font-semibold`,children:[n===`upload`?`Uploaded copy`:`Local copy`,` in place.`]}),` `,`Re-install `,l(`span`,{className:`font-mono`,children:t}),` from npm to track upstream releases again.`]})]}),f&&i(`div`,{className:`flex items-center justify-center gap-2 py-6 text-[10px] text-foreground-subtle`,children:[l(O,{className:`h-3.5 w-3.5 animate-spin`}),`Loading versions...`]}),d&&l(`div`,{className:`max-h-64 overflow-auto divide-y divide-border`,children:d.map(e=>{let n=e.version===t,a=s!==void 0&&e.version===c,d=/-(alpha|beta|rc|dev|canary|next)/i.test(e.version),f=i(o,{children:[l(`span`,{className:`font-mono flex-1 text-left ${n?`text-primary font-semibold`:d?`text-amber-400`:`text-foreground`}`,children:e.version}),n&&l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium bg-primary/10 text-primary`,children:`current`}),e.distTags.map(e=>l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e===`latest`?`bg-emerald-500/15 text-emerald-400`:e===`beta`?`bg-amber-500/15 text-amber-400`:`bg-gray-500/15 text-gray-400`}`,children:e},e)),e.deprecated&&l(`span`,{className:`text-[9px] text-red-400 line-through`,children:`deprecated`}),l(`span`,{className:`text-[9px] text-foreground-subtle shrink-0`,children:new Date(e.publishedAt).toLocaleDateString()})]});return s?i(`button`,{type:`button`,"aria-label":`Select ${e.version}`,onClick:()=>s(e.version),className:`w-full flex items-center gap-2 px-3 py-2 text-[11px] ${a?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,a?l(T,{className:`h-3 w-3 text-primary shrink-0`}):l(`span`,{className:`w-3 shrink-0`})]},e.version):i(`div`,{className:`flex items-center gap-2 px-3 py-2 text-[11px] ${n?`bg-primary/5`:`hover:bg-surface-hover`} transition-colors`,children:[f,n&&!u?l(T,{className:`h-3 w-3 text-primary shrink-0`}):l(`button`,{type:`button`,onClick:()=>r(e.version),className:`shrink-0 rounded p-0.5 hover:bg-primary/20 text-foreground-subtle hover:text-primary transition-colors`,title:n?`Re-install ${e.version} from npm`:`Install ${e.version}`,children:l(_,{className:`h-3 w-3`})})]},e.version)})}),d&&d.length===0&&l(`div`,{className:`py-4 text-center text-[10px] text-foreground-subtle`,children:`No versions found`})]})}var Ce={queued:{icon:I,bg:`bg-muted text-foreground-subtle`,label:`queued`},updating:{icon:O,bg:`bg-primary/10 text-primary`,label:`updating`,spin:!0},"done-pending-restart":{icon:w,bg:`bg-amber-500/10 text-amber-700`,label:`pending restart`},done:{icon:T,bg:`bg-success/10 text-success`,label:`done`},failed:{icon:q,bg:`bg-danger/10 text-danger`,label:`failed`}};function Z({item:e}){let t=Ce[e.status],n=t.icon;return i(`span`,{className:`inline-flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded ${t.bg}`,title:e.error,children:[l(n,{className:`w-2.5 h-2.5 ${t.spin?`animate-spin`:``}`}),t.label]})}n();var Q=`device-export`;function we(e){return e.capabilities.some(e=>(typeof e==`string`?e:e.name)===Q)}function Te({isBundle:e,installSource:t,addonId:n,iconPath:r,color:a}){let[o,s]=c(!1),u=a?{backgroundColor:`${a.startsWith(`#`)?a:`#${a}`}26`}:void 0,f=e?`bg-indigo-500/20 text-indigo-700 dark:text-indigo-300`:`bg-purple-500/20 text-purple-700 dark:text-purple-300`,p=n&&r?d(`/api/addon-assets/${n}/${r}`):null,m=!!p&&!o;return i(`div`,{className:`relative flex-shrink-0`,children:[l(`div`,{className:`h-9 w-9 rounded-lg flex items-center justify-center ${u?``:f}`,style:u,children:m?l(`img`,{src:p,alt:n,className:`h-5 w-5`,onError:()=>s(!0)}):l(e?C:N,{className:`h-4 w-4`})}),t===`local`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 text-[7px] font-bold leading-none bg-orange-500 text-white px-1 py-0.5 rounded -rotate-12 shadow-sm`,children:`DEV`}),t===`npm`&&l(`span`,{className:`absolute -top-1 -left-1 w-4 h-4 rounded bg-[#cb3837] flex items-center justify-center -rotate-12 shadow-sm`,children:l(`svg`,{viewBox:`0 0 780 250`,className:`w-[11px] h-[11px]`,children:l(`path`,{fill:`#fff`,d:`M240 250h100V50h100v200h340V0H0v250z`})})}),t===`upload`&&l(`span`,{className:`absolute -top-1.5 -left-1.5 flex items-center justify-center h-4 w-4 rounded bg-cyan-500 -rotate-12 shadow-sm`,children:l(h,{className:`h-2.5 w-2.5 text-white`})})]})}function Ee({version:e,availableUpdate:t,selectedVersion:n,isUpdating:r,installSource:a,disabled:o,onUpdate:s,onOpenPicker:c,children:u}){if(r)return i(`span`,{className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-blue-500/30 bg-blue-500/10 text-blue-400 shrink-0`,children:[l(O,{className:`h-3 w-3 animate-spin`}),`Updating…`]});if(t){let r=n??t;return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[s&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),s()},disabled:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-semibold border border-blue-500/30 bg-blue-500/10 text-blue-400 hover:bg-blue-500/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,title:`Update to ${r}`,children:[l(_,{className:`h-3 w-3`}),`Update`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,"aria-label":`Select version to install`,title:`Installed ${e} — update available. Selected ${r}; tap to choose another version.`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border border-amber-500/40 bg-amber-500/15 text-amber-500 hover:bg-amber-500/25 animate-pulse disabled:opacity-50 disabled:cursor-not-allowed transition-colors`,children:[l(`span`,{className:`font-normal opacity-70`,children:e}),l(`span`,{className:`font-normal opacity-70`,children:`→`}),r,l(f,{className:`h-3 w-3`})]}),u]})}return i(`div`,{className:`relative inline-flex items-center gap-1 shrink-0`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c()},disabled:o,className:[`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-bold font-mono border transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,a===`local`?`border-orange-500/30 bg-orange-500/10 text-orange-400 hover:bg-orange-500/20`:`border-emerald-500/30 bg-emerald-500/10 text-emerald-400 hover:bg-emerald-500/20`].join(` `),title:`Version ${e} — tap to view all versions`,children:[e,l(f,{className:`h-3 w-3 opacity-50`})]}),u]})}function De({addonId:e}){let t=s(),{data:n=`inherit`}=pe({addonId:e}),r=ce({onSuccess:()=>{t.invalidateQueries({queryKey:[[`addons`,`getAddonAutoUpdate`]]})}});return l(`div`,{className:`flex rounded-lg border border-border overflow-hidden text-[10px] font-medium`,children:[`inherit`,`off`,`latest`,`beta`].map(t=>l(`button`,{type:`button`,onClick:n=>{n.stopPropagation(),r.mutate({addonId:e,channel:t})},disabled:r.isPending,className:`px-2.5 py-1 transition-colors capitalize ${n===t?t===`inherit`?`bg-gray-700/50 text-gray-700 dark:text-gray-300`:t===`off`?`bg-gray-700 text-gray-700 dark:text-gray-300`:t===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${t===`inherit`?``:`border-l border-border`}`,children:t},t))})}function Oe({addon:e,agents:t=[],clusterStatus:n,hideVersion:r,availableUpdate:a,onUpdate:d,isUpdating:m,jobProgress:h,bundle:g,bulkItem:_,disabledByBulk:y,isSystem:ne}){let[re,ie]=c(!1),[oe,T]=c(!1),[se,E]=c(!1),[ce,ue]=c(null);u(()=>{ue(null)},[a]);let D=ce??a,[O,k]=c(!1),[de,A]=c(!1),[j,N]=c(`logs`),P=s(),I=ge(),L=ee(),{manifest:R}=e,B=e.installedOn??[],pe=!g&&!R.protected&&R.removable!==!1,V=!!g,me=g?.displayName??R.name,U=g?.packageName??R.packageName,he=g?.version??R.packageVersion??R.version,W=g?.installSource??e.installSource,G=g?g.bundle?.description??g.addons[0]?.manifest.description:R.description,K=H({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]})}}),J=ae({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]})}}),ve=te({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`addonPages`]]}),P.invalidateQueries({queryKey:[[`capabilities`]]}),P.invalidateQueries({queryKey:[[`integrations`]]})}}),Y=z({onSuccess:()=>{P.invalidateQueries({queryKey:[[`addons`]]}),P.invalidateQueries({queryKey:[[`alerts`]]})}}),X=e.health,ye=X?.phase===`failed`&&!X.inGracePeriod,be=ye&&X?.nextRetryAt&&!X.retrying;return i(`div`,{className:`rounded-lg border bg-surface overflow-hidden ${ye?`border-red-500/50`:`border-border`}`,children:[ye&&X&&i(`div`,{className:`bg-danger/10 border-b border-danger/30 px-4 py-2.5 flex items-start gap-2.5`,children:[l(q,{className:`h-4 w-4 text-danger shrink-0 mt-0.5`}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`text-xs font-semibold text-danger`,children:[`Failed to load (attempt #`,X.retryCount,`)`]}),l(`div`,{className:`text-[11px] text-foreground mt-0.5 break-words font-mono`,children:X.lastError?.message??`Unknown error`}),be&&X.nextRetryAt&&i(`div`,{className:`text-[10px] text-foreground-subtle mt-1`,children:[`Auto-retry at `,new Date(X.nextRetryAt).toLocaleTimeString()]})]}),i(`button`,{type:`button`,disabled:Y.isPending||X.retrying,onClick:e=>{e.stopPropagation(),Y.mutate({packageName:U})},className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-semibold border border-red-400/40 bg-red-400/10 text-red-700 dark:text-red-300 hover:bg-red-400/20 disabled:opacity-50 disabled:cursor-not-allowed transition-colors shrink-0`,title:`Reset retry counter and force immediate reload`,children:[l(w,{className:`h-3 w-3 ${Y.isPending||X.retrying?`animate-spin`:``}`}),`Retry now`]})]}),i(`div`,{className:`flex items-start gap-3 px-4 py-3`,children:[l(Te,{isBundle:V||!!R.components&&R.components.length>1,installSource:W,addonId:V?g.addons[0]?.manifest.id:R.id,iconPath:V?g.bundle?.icon??g.addons[0]?.manifest.icon:R.icon,color:V?g.addons[0]?.manifest.color:R.color}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-start justify-between gap-2`,children:[l(`span`,{className:`text-sm font-semibold text-foreground truncate min-w-0`,children:me}),!r&&l(Ee,{version:he,availableUpdate:a,...D===void 0?{}:{selectedVersion:D},isUpdating:m,installSource:W,disabled:y,...d&&D!==void 0?{onUpdate:()=>d(D)}:{},onOpenPicker:()=>E(e=>!e),children:se&&l(Se,{packageName:U,currentVersion:he,...W?{installSource:W}:{},...a!==void 0&&D!==void 0?{selectedVersion:D,onSelect:e=>{ue(e),E(!1)}}:{},onInstall:e=>{E(!1),ve.mutate({packageName:U,version:e})},onClose:()=>E(!1)})})]}),i(`div`,{className:`flex flex-wrap items-center gap-x-1.5 gap-y-1 mt-0.5`,children:[U!==me&&l(`span`,{className:`text-[10px] text-foreground-subtle font-mono truncate max-w-full`,children:U}),V&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,children:[l(C,{className:`h-3 w-3`}),g.addons.length]}),ne&&i(`span`,{className:`text-[10px] rounded-full bg-amber-500/15 text-amber-700 dark:text-amber-300 px-2 py-0.5 font-medium shrink-0 inline-flex items-center gap-1`,title:`System package — updating restarts the hub`,children:[l(w,{className:`h-3 w-3`}),`System`]}),_!=null&&l(Z,{item:_}),h!=null&&l(xe,{progress:h})]}),G&&l(`p`,{className:`text-[10px] text-foreground-subtle mt-1 line-clamp-1`,children:G}),!V&&e.process&&i(`div`,{className:`flex flex-wrap items-center gap-1.5 mt-1`,children:[l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.mode===`forked`?`bg-blue-500/15 text-blue-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.mode===`forked`?`forked`:`in-process`}),e.process.pid!=null&&i(`span`,{className:`text-[9px] font-mono text-foreground-subtle`,children:[`PID `,e.process.pid]}),l(`span`,{className:`text-[9px] rounded-full px-1.5 py-0.5 font-medium ${e.process.state===`running`?`bg-emerald-500/15 text-emerald-400`:e.process.state===`crashed`||e.process.state===`failed`?`bg-red-500/15 text-red-400`:`bg-gray-500/15 text-gray-400`}`,children:e.process.state})]})]})]}),!V&&i(`div`,{className:`flex items-center gap-1 px-4 py-1.5 border-t border-border/50 bg-surface-hover/20`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),J.mutate({addonId:R.id})},disabled:J.isPending||y,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border border-border text-foreground-subtle hover:text-blue-400 hover:border-blue-500/30 hover:bg-blue-500/10 disabled:opacity-50 transition-colors`,children:[l(w,{className:`h-3 w-3 ${J.isPending?`animate-spin`:``}`}),`Restart`]}),i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(e=>!e)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${O?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(x,{className:`h-3 w-3`}),`Logs`]}),!V&&i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),A(!0)},className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[10px] font-medium border transition-colors ${de?`border-primary/30 bg-primary/10 text-primary`:`border-border text-foreground-subtle hover:text-foreground hover:border-primary/30 hover:bg-primary/10`}`,children:[l(F,{className:`h-3 w-3`}),`Settings`]}),l(`div`,{className:`flex-1`}),pe&&i(`button`,{type:`button`,onClick:async e=>{e.stopPropagation(),await L({title:`Uninstall ${R.name}?`,message:`This will remove the addon package and all its data. This action cannot be undone.`,confirmLabel:`Uninstall`,variant:`danger`})&&K.mutate({packageName:R.packageName})},disabled:K.isPending||y,className:`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`,children:[l(p,{className:`h-3 w-3`}),K.isPending?`Removing...`:`Uninstall`]})]}),n&&n.nodes.length>1&&!V&&i(`div`,{className:`border-t border-border px-4 py-2 bg-muted/10`,children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle mb-1.5`,children:`Cluster Deployment`}),l(`div`,{className:`space-y-1`,children:n.nodes.map(e=>i(`div`,{className:`flex items-center gap-2 text-[10px]`,children:[l(`div`,{className:`h-1.5 w-1.5 rounded-full shrink-0 ${e.status===`offline`?`bg-muted-foreground/30`:e.synced?`bg-success`:`bg-amber-500`}`}),l(`span`,{className:`font-medium text-foreground min-w-[60px]`,children:e.name}),l(`span`,{className:`font-mono text-foreground-subtle`,children:e.version}),!e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-amber-500/10 text-amber-400 border border-amber-500/20`,children:`outdated`}),e.status===`offline`&&l(`span`,{className:`text-[9px] px-1 py-0.5 rounded bg-muted text-muted-foreground`,children:`offline`}),e.synced&&e.status!==`offline`&&l(`span`,{className:`text-[9px] text-success`,children:`synced`})]},e.nodeId))})]}),O&&!V&&i(`div`,{className:`border-t border-border`,children:[i(`div`,{className:`flex items-center px-4 py-1 bg-surface-hover/20 border-b border-border/50`,children:[i(`div`,{className:`flex rounded border border-border overflow-hidden text-[9px]`,children:[l(`button`,{type:`button`,onClick:()=>N(`logs`),className:`px-2 py-0.5 transition-colors ${j===`logs`?`bg-primary/10 text-primary`:`text-foreground-subtle hover:bg-surface-hover`}`,children:`Logs`}),l(`button`,{type:`button`,onClick:()=>N(`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:`Events`})]}),l(`div`,{className:`flex-1`}),l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),k(!1)},className:`text-foreground-subtle hover:text-foreground`,children:l(S,{className:`h-3.5 w-3.5`})})]}),j===`logs`&&l(le,{addonId:R.id,maxHeight:`max-h-64`,showFilters:!1}),j===`events`&&l(M,{addonId:R.id,category:`addon.*`,maxHeight:`max-h-64`})]}),V&&i(o,{children:[l(`button`,{type:`button`,onClick:()=>ie(e=>!e),className:`w-full flex items-center justify-center border-t border-border py-1 hover:bg-surface-hover/50 transition-colors`,children:l(re?fe:f,{className:`h-3.5 w-3.5 text-foreground-subtle`})}),re&&l(`div`,{className:`border-t border-border px-3 py-2 space-y-2`,children:g.addons.map(e=>l(Oe,{addon:e,agents:t,hideVersion:!0},e.manifest.id))})]}),de&&!V&&l(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm p-4`,onClick:()=>A(!1),children:i(`div`,{className:`w-full max-w-lg max-h-[80vh] rounded-xl border border-border bg-surface shadow-2xl flex flex-col overflow-hidden`,onClick:e=>e.stopPropagation(),children:[i(`div`,{className:`flex items-center justify-between px-5 py-3 border-b border-border flex-shrink-0`,children:[i(`div`,{className:`flex items-center gap-2`,children:[l(F,{className:`h-4 w-4 text-primary`}),i(`h2`,{className:`text-sm font-semibold text-foreground`,children:[me,` Settings`]})]}),l(`button`,{onClick:()=>A(!1),className:`text-foreground-subtle hover:text-foreground transition-colors p-1 rounded`,children:l(S,{className:`h-4 w-4`})})]}),i(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[l(`div`,{className:`text-[10px] text-foreground-subtle mb-2`,children:`Cluster-wide settings — one value for every node. Per-node settings live under Cluster → the node → Settings.`}),l(_e,{nodeId:null,addonIds:[R.id],level:`global`,fieldScope:`cluster`,emptyMessage:`This addon exposes no cluster-wide settings. Anything it can configure is per-node — open it from Cluster → the node → Settings.`}),we(R)&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Device export`}),l(v,{addonId:R.id,onOpenDevice:e=>I(`/devices/${e}`)})]}),W===`npm`&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Auto-Update`}),l(De,{addonId:R.id})]}),R.components&&R.components.length>0&&i(`div`,{children:[i(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:[`Components (`,R.components.length,`)`]}),l(`div`,{className:`flex flex-wrap gap-1`,children:R.components.map(e=>l(`span`,{className:`text-[10px] rounded bg-background border border-border px-1.5 py-0.5 text-foreground-subtle font-mono`,children:e},e))})]}),t.length>=2&&i(`div`,{children:[l(`div`,{className:`text-[10px] font-medium text-foreground-subtle uppercase tracking-wide mb-2`,children:`Installed on`}),i(`div`,{className:`flex items-center gap-1.5 flex-wrap`,children:[B.length===0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Hub (local)`}),B.map(e=>l(`span`,{className:`rounded-full bg-surface-hover border border-border px-2 py-0.5 text-[10px] text-foreground-subtle`,children:e},e)),i(`div`,{className:`relative`,children:[i(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(e=>!e)},className:`inline-flex items-center gap-1 rounded-full border border-dashed border-border px-2 py-0.5 text-[10px] text-foreground-subtle hover:text-foreground hover:border-primary transition-colors`,title:`Install on more agents`,children:[l(b,{className:`h-3 w-3`}),`Add agent`]}),oe&&i(`div`,{className:`absolute left-0 top-full mt-1 z-10 min-w-[160px] rounded-md border border-border bg-surface shadow-lg overflow-hidden`,children:[t.filter(e=>!e.isHub&&!B.includes(e.name)).map(e=>l(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),T(!1)},className:`w-full text-left px-3 py-1.5 text-[10px] text-foreground hover:bg-surface-hover transition-colors`,children:e.name},e.id)),t.filter(e=>!e.isHub&&!B.includes(e.name)).length===0&&l(`div`,{className:`px-3 py-1.5 text-[10px] text-foreground-subtle`,children:`No available agents`})]})]})]})]})]}),l(`div`,{className:`flex items-center justify-end px-5 py-3 border-t border-border flex-shrink-0`,children:l(`button`,{type:`button`,onClick:()=>A(!1),className:`rounded-lg border border-border px-3 py-1.5 text-xs font-medium text-foreground-subtle hover:text-foreground hover:bg-surface-hover transition-colors`,children:`Close`})})]})})]})}n();var ke=`.tgz,.tar.gz,.zip`;function Ae({onUploadSuccess:n}){let[r,a]=c(!1),s=t(null),u=e(async e=>{a(!0);let t=new FormData;t.append(`file`,e);let r=localStorage.getItem(`camstack_admin_token`)??``;try{(await(await fetch(d(`/api/addons/upload`),{method:`POST`,headers:{Authorization:`Bearer ${r}`},body:t})).json()).success&&n()}finally{a(!1)}},[n]);return i(o,{children:[l(`input`,{ref:s,type:`file`,accept:ke,onChange:e(e=>{let t=e.target.files?.[0];t&&u(t),e.target.value=``},[u]),className:`hidden`}),i(`button`,{type:`button`,onClick:()=>s.current?.click(),disabled:r,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[r?l(O,{className:`w-3.5 h-3.5 animate-spin`}):l(h,{className:`w-3.5 h-3.5`}),r?`Uploading...`:`Upload`]})]})}n();var je=[{seconds:900,label:`15m`},{seconds:3600,label:`1h`},{seconds:21600,label:`6h`},{seconds:43200,label:`12h`},{seconds:86400,label:`24h`}],Me=new Set([`@camstack/system`,`@camstack/types`,`@camstack/sdk`,`@camstack/shm-ring`,`@camstack/ui-library`]);function Ne(e){return e!==void 0&&Me.has(e)}var Pe={id:`hub`,name:`Hub`,isHub:!0,isOnline:!0};function Fe(e,t){let n=e??`hub-only`;return n===`any-node`?!0:n===`hub-only`?t:!t}function Ie(e){let t=e;if(!t?.manifest)return null;let n={...t.manifest,name:t.manifest.name??t.manifest.id,version:t.manifest.version??`0.0.0`,capabilities:t.manifest.capabilities??[]},r=t.process,i=r?{pid:r.pid,mode:r.mode===`forked`?`forked`:`in-process`,state:r.state??`unknown`}:void 0,a=t.health,o=t.declaration?.execution,s=t.manifest.execution,c=o?.placement??s?.placement;return{manifest:n,enabled:!0,source:t.source,installSource:t.installSource,installedOn:[],...i?{process:i}:{},hasBackup:t.hasBackup,...a?{health:a}:{},...c?{placement:c}:{}}}function Le(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 Re({addons:n,clusterStatus:o,selectedNode:d,onRefresh:f,isRefreshing:p}){let m=s(),[h,v]=c(``),y=r(h),[b,x]=c(!1),S=t(null);u(()=>{if(!b)return;let e=e=>{S.current&&!S.current.contains(e.target)&&x(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[b]);let{data:C}=de({nodeId:d.id}),re=a(()=>{let e=new Map;for(let t of C??[])e.set(t.name,t.latestVersion);return e},[C]),ae=a(()=>(C??[]).filter(e=>!e.isSystem).length,[C]),[oe,se]=c(()=>new Set),[ce,le]=c(()=>new Map),ue=e(e=>{se(t=>new Set(t).add(e))},[]),k=e(e=>{se(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n})},[]),fe=e((e,t)=>{le(n=>new Map(n).set(e,t))},[]),A=e(e=>{le(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),M=ne({onMutate:e=>{ue(e.name),A(e.name)},onSuccess:(e,t)=>{k(t.name);let n=e;if(n&&n.success===!1){fe(t.name,n.error??`Update failed (no error message returned by server)`);return}m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]})},onError:(e,t)=>{k(t.name),fe(t.name,e instanceof Error?e.message:String(e))}}),N=ye(),F=t(new Set);u(()=>{let e=new Set;for(let[t,n]of N)Y(n)&&e.add(t);let t=[...F.current].some(t=>!e.has(t));F.current=e,t&&(m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addons`,`listUpdates`]]}))},[N,m]);let{data:I}=P(void 0),L=g({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),R=E({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`,`getAutoUpdateSettings`]]})}}),{data:z,isFetching:pe}=j({query:y||void 0},{enabled:b}),V=me(),{data:H}=B(void 0),U=H?.requestedAt,[ge,W]=c(null),[_e,G]=c(!1);u(()=>{if(H?.kind===`framework-bulk-update`&&H.requestedAt!==ge){W(H.requestedAt),G(!0);let e=window.setTimeout(()=>G(!1),6e3);return()=>window.clearTimeout(e)}},[U,ge,H]),ee();let K=e(async()=>{let e=(C??[]).filter(e=>!e.isSystem);if(e.length!==0){if(!d.isHub){for(let t of e)await M.mutateAsync({name:t.name,version:t.latestVersion,nodeId:d.id});return}await V.mutateAsync({kind:`update`,targets:e.map(e=>({name:e.name,version:e.latestVersion})),nodeIds:[d.id]})}},[C,d.id,d.isHub,V,M]),q=te({onSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),m.invalidateQueries({queryKey:[[`addonPages`]]}),m.invalidateQueries({queryKey:[[`capabilities`]]}),m.invalidateQueries({queryKey:[[`integrations`]]})}}),[J,ve]=c(`type`),[X,be]=c(()=>typeof window>`u`?`grouped`:window.localStorage.getItem(`camstack.addons.viewMode`)===`flat`?`flat`:`grouped`),xe=e=>{be(e),typeof window<`u`&&window.localStorage.setItem(`camstack.addons.viewMode`,e)},[Se,Ce]=he(),Z=Se.get(`capability`),Q=a(()=>{let e=n.filter(e=>!Ne(e.manifest.packageName));return d.isHub||(e=e.filter(e=>Fe(e.placement,d.isHub))),Z&&(e=e.filter(e=>(e.manifest.capabilities??[]).some(e=>(typeof e==`string`?e:e.name)===Z))),e},[n,d.isHub,Z]),we=()=>{let e=new URLSearchParams(Se);e.delete(`capability`),Ce(e,{replace:!0})},Te=X===`flat`?Q:Le(Q),Ee=a(()=>{let e=[...Te];switch(J){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},[Te,J]);return i(`div`,{className:`space-y-4`,children:[[...ce.entries()].map(([e,t])=>l(`div`,{className:`rounded-md border border-danger/30 bg-danger/5 px-3 py-2 text-[11px]`,children:i(`div`,{className:`flex items-start justify-between gap-3`,children:[i(`div`,{className:`space-y-0.5`,children:[i(`div`,{className:`font-medium text-danger`,children:[`Failed to update `,e]}),l(`div`,{className:`text-foreground-subtle font-mono`,children:t})]}),l(`button`,{type:`button`,onClick:()=>A(e),className:`text-foreground-subtle hover:text-foreground text-[10px]`,children:`dismiss`})]})},e)),i(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Sort:`}),i(`select`,{value:J,onChange:e=>ve(e.target.value),className:`rounded-md border border-border bg-surface px-2 py-1.5 text-[11px] text-foreground focus:outline-none focus:border-primary/50`,children:[l(`option`,{value:`type`,children:`Bundles first`}),l(`option`,{value:`name`,children:`Name`}),l(`option`,{value:`source`,children:`Install source`})]})]}),i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`View:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`grouped`,`flat`].map(e=>l(`button`,{type:`button`,onClick:()=>xe(e),className:`px-2.5 py-1.5 transition-colors capitalize ${X===e?`bg-primary/10 text-primary`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`}`,title:e===`grouped`?`Group multi-addon packages into a bundle card`:`Show every addon as its own card`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(w,{className:`h-3 w-3 text-foreground-subtle`}),l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Auto-Update:`}),l(`div`,{className:`flex rounded-md border border-border overflow-hidden text-[10px] font-medium`,children:[`off`,`latest`,`beta`].map(e=>l(`button`,{type:`button`,onClick:()=>L.mutate({channel:e}),disabled:L.isPending,className:`px-2.5 py-1.5 transition-colors capitalize ${I?.channel===e?e===`off`?`bg-gray-700 text-gray-200`:e===`latest`?`bg-blue-500/20 text-blue-400`:`bg-amber-500/20 text-amber-400`:`bg-transparent text-foreground-subtle hover:bg-surface-hover`} ${e===`off`?``:`border-l border-border`}`,children:e},e))})]}),d.isHub&&i(`div`,{className:`flex items-center gap-1.5`,children:[l(`span`,{className:`text-[10px] text-foreground-subtle`,children:`Check every:`}),l(`select`,{className:`rounded-md border border-border bg-transparent px-1.5 py-1 text-[10px] font-medium text-foreground-subtle`,value:I?.updateCheckIntervalSeconds??21600,disabled:R.isPending||I===void 0,onChange:e=>{I!==void 0&&R.mutate({channel:I.channel,updateCheckIntervalSeconds:Number(e.target.value)})},children:je.map(e=>l(`option`,{value:e.seconds,children:e.label},e.seconds))})]}),ae>0&&i(`button`,{type:`button`,onClick:()=>void K(),disabled:V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 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:[V.isPending?l(O,{className:`w-3 h-3 animate-spin`}):l(_,{className:`w-3 h-3`}),V.isPending?`Updating…`:`Update All (${ae})`]}),i(`button`,{type:`button`,onClick:f,disabled:p||V.isPending,className:`flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,children:[l(w,{className:`w-3 h-3 ${p?`animate-spin`:``}`}),`Refresh`]})]}),i(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[i(`div`,{className:`relative flex-1 min-w-0 sm:min-w-[200px]`,ref:S,children:[l(D,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-foreground-subtle`}),l(`input`,{type:`text`,value:h,onChange:e=>{v(e.target.value),x(!0)},onFocus:()=>x(!0),placeholder:`Search addons on npm...`,disabled:V.isPending,className:`w-full rounded-lg border border-border bg-background pl-9 pr-3 py-2 text-xs text-foreground placeholder:text-foreground-subtle focus:outline-none focus:ring-1 focus:ring-primary disabled:opacity-50 disabled:cursor-not-allowed`}),pe&&l(O,{className:`absolute right-2.5 top-1/2 -translate-y-1/2 h-3 w-3 text-foreground-subtle animate-spin`}),b&&z&&z.length>0&&i(`div`,{className:`absolute left-0 right-0 top-full mt-1 z-40 rounded-lg border border-border bg-surface shadow-xl overflow-hidden`,children:[z.length>0&&i(`div`,{className:`px-3 py-1.5 text-[10px] uppercase tracking-wide text-foreground-subtle border-b border-border`,children:[`npm results (`,z.length,`)`]}),z&&z.length>0&&l(`div`,{className:`max-h-72 overflow-auto divide-y divide-border`,children:z.map(e=>i(`div`,{className:`flex items-center gap-3 px-3 py-2 hover:bg-surface-hover transition-colors`,children:[l(`div`,{className:`w-6 h-6 rounded-md bg-primary/10 flex items-center justify-center text-primary text-[9px] font-bold shrink-0`,children:e.name.replace(`@camstack/addon-`,``).charAt(0).toUpperCase()}),i(`div`,{className:`flex-1 min-w-0`,children:[i(`div`,{className:`flex items-baseline gap-2 min-w-0`,children:[l(`span`,{className:`text-[11px] font-semibold break-words`,children:e.name.replace(/^@camstack\/(addon-)?/,``)}),i(`span`,{className:`text-[10px] text-foreground-subtle shrink-0`,children:[`v`,e.version]})]}),l(`div`,{className:`font-mono text-[9px] text-foreground-subtle/80 truncate`,children:e.name}),e.description&&l(`div`,{className:`text-[10px] text-foreground-subtle truncate`,children:e.description})]}),e.installed?i(`span`,{className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md border border-emerald-500/30 bg-emerald-500/10 text-emerald-400 shrink-0`,children:[l(T,{className:`h-3 w-3`}),e.installedVersion??`Installed`]}):i(`button`,{type:`button`,onClick:()=>q.mutate({packageName:e.name}),disabled:q.isPending,className:`inline-flex items-center gap-1 px-2 py-1 text-[10px] font-medium rounded-md bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition-colors shrink-0`,children:[q.isPending?l(O,{className:`h-3 w-3 animate-spin`}):l(_,{className:`h-3 w-3`}),`Install`]})]},e.name))})]})]}),l(Ae,{onUploadSuccess:()=>{m.invalidateQueries({queryKey:[[`addons`]]}),f()}})]}),Z&&i(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg bg-primary/10 border border-primary/30 text-sm`,children:[l(`span`,{className:`text-foreground-subtle`,children:`Filtering by capability:`}),l(`span`,{className:`font-mono text-primary font-semibold`,children:Z}),l(`button`,{type:`button`,onClick:we,className:`ml-auto text-xs text-foreground-subtle hover:text-foreground underline`,children:`Clear`})]}),_e&&i(`div`,{className:`fixed top-[calc(env(safe-area-inset-top)+1rem)] right-[calc(env(safe-area-inset-right)+1rem)] z-50 flex items-start gap-2 px-3 py-2.5 rounded-md border border-green-500/30 bg-green-500/10 shadow-lg backdrop-blur-sm max-w-sm pointer-events-auto`,children:[l(ie,{className:`w-4 h-4 shrink-0 mt-0.5 text-green-400`}),i(`div`,{children:[l(`div`,{className:`text-[11px] font-semibold text-foreground`,children:`Bulk update completed`}),l(`div`,{className:`text-[10px] text-foreground-subtle mt-0.5`,children:`System packages updated — hub restarted successfully.`})]})]}),Q.length===0&&l(`div`,{className:`text-xs text-foreground-subtle`,children:n.length===0?`No addons installed`:Z?`No installed addons declare the "${Z}" capability. Browse the npm catalog above to find a compatible addon.`:`No addons compatible with ${d.name} (placement filter active)`}),l(`div`,{className:`space-y-2`,children:Ee.map(e=>{let t=$(e)?e.bundle.packageName:e.manifest.packageName,n=re.get(t),r=$(e)?e.representative:e,i=n?e=>M.mutate({name:t,version:e,nodeId:d.id}):void 0,a=N.get(t)??null,s=a!==null&&Y(a);return l(Oe,{addon:r,clusterStatus:o?.[r.manifest.id],bundle:$(e)?e.bundle:void 0,availableUpdate:n,isUpdating:oe.has(t)||s,jobProgress:a,onUpdate:i,disabledByBulk:V.isPending},$(e)?t:e.manifest.id)})})]})}function ze(){let e=s(),{data:n,isLoading:r,isError:a}=L(),{data:o}=A(void 0),{nodes:c}=R(),{selection:d,selectNode:f,requestedNodeId:p}=K(c.length>0?c:[Pe]),m=d.node??Pe,h=m.id,ee=c.length>0?d.staleNodeId:null,g=oe(),_=V(),v=g.isPending||_.isPending,y=async()=>{await g.mutateAsync({nodeId:h}),await _.mutateAsync(),e.invalidateQueries({queryKey:[[`addons`]]})},b=t(g);b.current=g;let te=t(p??`hub`);u(()=>{b.current.mutate({nodeId:te.current})},[]);let x=(n??[]).map(Ie).filter(e=>e!==null);return i(W,{children:[i(`div`,{className:`flex items-center justify-between gap-3 flex-wrap`,children:[l(k,{selectedNodeId:h,onSelect:f}),i(`div`,{className:`flex items-center gap-3 flex-wrap`,children:[!r&&!a&&i(`span`,{className:`text-[10px] rounded-full bg-primary/10 text-primary px-2 py-0.5 font-medium`,children:[x.length,` installed`]}),i(`button`,{type:`button`,onClick:()=>void y(),disabled:v,className:`inline-flex items-center gap-1.5 px-2.5 py-1.5 text-[11px] rounded-md bg-surface hover:bg-surface-hover border border-border disabled:opacity-50 transition-colors`,title:`Re-fetch addons + check npm for new versions`,children:[l(w,{className:`w-3 h-3 ${v?`animate-spin`:``}`}),`Check for updates`]})]})]}),l(G,{staleNodeId:ee,shownNodeName:m.name}),!m.isHub&&i(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 px-3 py-2 text-[11px] text-foreground-subtle`,children:[`Showing only addons compatible with`,` `,l(`span`,{className:`font-medium text-foreground`,children:m.name}),` — agents only run`,` `,l(`code`,{className:`font-mono`,children:`agent-only`}),` and`,` `,l(`code`,{className:`font-mono`,children:`any-node`}),` addons. Install / uninstall is hub-driven; agents auto-sync from the hub.`]}),r&&l(`div`,{className:`text-xs text-foreground-subtle animate-pulse`,children:`Loading…`}),a&&l(`div`,{className:`text-xs text-danger`,children:`Failed to load addons`}),!r&&!a&&l(Re,{addons:x,clusterStatus:o,selectedNode:m,onRefresh:()=>void y(),isRefreshing:v})]})}export{ze as AddonsPage};
@@ -1,3 +0,0 @@
1
- import{I as e,K as t,Q as n,S as r,W as i,a,b as o,q as s,t as c,x as l,z as u}from"./_virtual_mf___mfe_internal__admin_ui_host__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-DhP-Lgiq.js";import{W as d,Z as f,at as p,ct as m,st as h,vt as g,yt as _}from"./player-overlays-D16jpLuq.js";import{Bn as v,Gt as y,Hu as b,Kt as x,Qt as S,Qu as C,Tt as w,Ui as T,Uu as E,Wl as D,Xt as O,Yt as k,Zt as A,_u as j,bl as ee,bn as te,en as M,gu as ne,hn as N,id as P,iu as F,ju as I,k as L,ln as R,qt as z,ru as B,td as V,vn as H,wt as U,xd as W,xn as G,yu as K}from"./src-DBvNufmZ.js";import{t as re}from"./boxes-4oXlPoua.js";import{t as ie}from"./send-D8FSzLx_.js";import{xn as q}from"./src-BMs7x0zW.js";import{t as J}from"./useTranslation-Bc5yH9V9.js";import"./mount-BIE3EBc7.js";import{t as Y}from"./AdminPage-CiKtOLQm.js";import{t as ae}from"./AdminTabs-Bpqqvbac.js";var oe=_(`message-square-plus`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M12 8v6`,key:`1ib9pf`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}]]);n();var se=[`llm`,`listProfiles`],ce=[`llm`,`listProfileKinds`],le=[`llm`,`getDefaults`],ue=[`llm`,`listRuntimeNodes`],de=[`llm`,`listModelCatalog`],fe=[`llm`,`getUsage`],pe=[{purpose:`vision`,visionOnly:!0},{purpose:`text`,visionOnly:!1}],me=new Map(Object.entries({openai:P,anthropic:P,google:P,"openai-compatible":ne,"managed-local":V,"apple-foundation":V}));function he(e){return me.get(e)??null}function X(e){return typeof e==`string`&&e.length>0?e:void 0}function Z(e){if(typeof e==`number`&&Number.isFinite(e))return e;if(typeof e==`string`&&e.trim()!==``){let t=Number(e);return Number.isFinite(t)?t:void 0}}function Q(e){return e===!0}function ge(e){return{model:e.model,baseUrl:e.baseUrl,apiKey:e.apiKey,supportsVision:e.supportsVision,temperature:e.temperature,topP:e.topP,topK:e.topK,maxTokens:e.maxTokens,contextLength:e.contextLength,systemPrompt:e.systemPrompt,timeoutMs:e.timeoutMs,connectTimeoutMs:e.connectTimeoutMs,firstTokenTimeoutMs:e.firstTokenTimeoutMs,idleTimeoutMs:e.idleTimeoutMs,retryEnabled:e.retry.enabled,retryMaxAttempts:e.retry.maxAttempts,toolsEnabled:e.toolsEnabled,contextSize:e.runtime?.contextSize,gpuLayers:e.runtime?.gpuLayers,threads:e.runtime?.threads,parallel:e.runtime?.parallel,idleStopMinutes:e.runtime?.idleStopMinutes,batchSize:e.runtime?.batchSize,ubatchSize:e.runtime?.ubatchSize,flashAttention:e.runtime?.flashAttention,mlock:e.runtime?.mlock,noMmap:e.runtime?.noMmap,cacheTypeK:e.runtime?.cacheTypeK,cacheTypeV:e.runtime?.cacheTypeV,extraArgs:be(e.runtime?.extraArgs??[])}}var _e=[`f32`,`f16`,`q8_0`,`q5_1`,`q5_0`,`q4_1`,`q4_0`];function ve(e){return typeof e==`string`&&_e.includes(e)?e:void 0}function ye(e){let t=[],n=``,r=null;for(let i of e){if(r!==null){i===r?r=null:n+=i;continue}if(i===`"`||i===`'`){r=i;continue}if(/\s/.test(i)){n!==``&&t.push(n),n=``;continue}n+=i}return n!==``&&t.push(n),t}function be(e){return e.map(e=>/\s/.test(e)?`"${e}"`:e).join(` `)}var xe=[`--jinja`,`--cont-batching`];function Se(e,t,n){let r=Z(e.threads),i=Z(e.batchSize),a=Z(e.ubatchSize),o=ve(e.cacheTypeK),s=ve(e.cacheTypeV);return{nodeId:t,engine:`llama-cpp`,model:n,extraArgs:[...ye(X(e.extraArgs)??``)],contextSize:Z(e.contextSize)??4096,gpuLayers:Z(e.gpuLayers)??0,...r===void 0?{}:{threads:r},parallel:Z(e.parallel)??1,...i===void 0?{}:{batchSize:i},...a===void 0?{}:{ubatchSize:a},flashAttention:Q(e.flashAttention),mlock:Q(e.mlock),noMmap:Q(e.noMmap),...o===void 0?{}:{cacheTypeK:o},...s===void 0?{}:{cacheTypeV:s},autoStart:Q(e.autoStart),idleStopMinutes:Z(e.idleStopMinutes)??30}}function Ce(e,t,n,r,i){let a={id:n?.id??crypto.randomUUID(),name:t,kind:e,addonId:`ai`,enabled:n?.enabled??!0,model:X(r.model)??n?.model??``,supportsVision:i?.supportsVision??Q(r.supportsVision),timeoutMs:Z(r.timeoutMs)??q.totalMs,connectTimeoutMs:Z(r.connectTimeoutMs)??q.connectMs,firstTokenTimeoutMs:Z(r.firstTokenTimeoutMs)??q.firstTokenMs,idleTimeoutMs:Z(r.idleTimeoutMs)??q.idleMs,retry:{enabled:Q(r.retryEnabled),maxAttempts:Z(r.retryMaxAttempts)??1},toolsEnabled:Q(r.toolsEnabled)},o=X(r.baseUrl),s=X(r.apiKey),c=Z(r.temperature),l=Z(r.topP),u=Z(r.topK),d=Z(r.maxTokens),f=Z(r.contextLength),p=X(r.systemPrompt);return{...a,...o===void 0?{}:{baseUrl:o},...s===void 0?{}:{apiKey:s},...c===void 0?{}:{temperature:c},...l===void 0?{}:{topP:l},...u===void 0?{}:{topK:u},...d===void 0?{}:{maxTokens:d},...f===void 0?{}:{contextLength:f},...p===void 0?{}:{systemPrompt:p},...i===void 0?{}:{model:i.modelId,runtime:Se(r,i.nodeId,i.model)}}}function we(e){let t=new Map;for(let n of e){let e=t.get(n.addonId)??[];e.push(n),t.set(n.addonId,e)}return[...t.entries()].map(([e,t])=>({addonId:e,kinds:t}))}var Te=`apple-system`;function Ee(e,t,n,r){return{...Ce(`apple-foundation`,e,t,n),model:Te,supportsVision:!1,appleFoundation:{nodeId:r}}}var De={deviceNotEligible:{key:`ai.appleNotEligible`,text:`not eligible`,tone:`default`},appleIntelligenceNotEnabled:{key:`ai.appleIntelligenceOff`,text:`Apple Intelligence off`,tone:`warning`},modelNotReady:{key:`ai.appleModelNotReady`,text:`model downloading`,tone:`warning`},osTooOld:{key:`ai.appleOsTooOld`,text:`macOS too old`,tone:`default`},helperMissing:{key:`ai.appleHelperMissing`,text:`helper missing`,tone:`danger`},helperCrashed:{key:`ai.appleHelperCrashed`,text:`helper crashed`,tone:`danger`}};function Oe(e){let t=t=>({nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleUnknown`,labelDefault:`unknown`,detail:t,tone:`default`});if(!e.reachable)return t(e.error??null);let n=e.apple;if(n===void 0)return t(null);switch(n.state){case`available`:return{nodeId:e.nodeId,selectable:!0,labelKey:`ai.appleAvailable`,labelDefault:`available`,detail:`macOS ${n.osVersion} · ${n.imageInput?`text + images`:`text only`}`,tone:`success`};case`unavailable`:{let t=De[n.reason];return{nodeId:e.nodeId,selectable:!1,labelKey:t.key,labelDefault:t.text,detail:n.detail,tone:t.tone}}case`unsupported-platform`:return{nodeId:e.nodeId,selectable:!1,labelKey:`ai.appleNotMac`,labelDefault:`not a Mac`,detail:n.platform,tone:`default`};case`unknown`:return t(n.error)}}var ke=2e3;function $(e){return`${(e/1e9).toFixed(2)} GB`}function Ae(e){return e===null?``:e.model.kind===`catalog`?`catalog:${e.model.catalogId}`:e.model.kind===`path`?`node:${e.modelId}`:`custom`}function je({nodeId:e,value:t,onChange:n}){let{t:o}=J(),u=p(),[d,f]=s(``),[m,h]=s(null),[g,_]=s(!1),y=a({queryKey:de,queryFn:()=>u.trpcClient.llm.listModelCatalog.query({})}),b=a({queryKey:[`llm`,`listNodeModels`,e],queryFn:()=>u.trpcClient.llm.listNodeModels.query({nodeId:e})}),x=c({mutationFn:e=>u.trpcClient.llm.resolveModelRef.mutate(e),onSuccess:e=>{h(e),_(!1),e.ok&&n({model:e.model,modelId:e.label,supportsVision:e.purpose===`vision`})}}),S=c({mutationFn:t=>u.trpcClient.llm.installModel.mutate({nodeId:e,model:t}),onSuccess:()=>{_(!0),b.refetch()}}),w=a({queryKey:ue,enabled:S.isPending,refetchInterval:S.isPending?ke:!1,queryFn:()=>u.trpcClient.llm.listRuntimeNodes.query({})}).data?.find(t=>t.nodeId===e)?.status?.download,T=i(()=>{let t=(y.data??[]).map(e=>({value:`catalog:${e.id}`,label:`${e.label} · ${e.quantization} · ${$(e.sizeBytes)}`})),n=(b.data??[]).filter(e=>e.catalogId===void 0&&e.path!==void 0).map(t=>({value:`node:${t.file}`,label:o(`ai.onNode`,`{{file}} · {{size}} · on {{node}}`,{file:t.file,size:$(t.sizeBytes),node:e})})),r=m?.ok===!0?[{value:`custom`,label:`${m.label} · ${$(m.totalBytes)}`}]:[];return[{value:``,label:o(`ai.selectModel`,`Select a model…`)},...t,...n,...r]},[y.data,b.data,m,e,o]),E=e=>{if(e===``){n(null);return}if(e===`custom`){if(m?.ok!==!0)return;n({model:m.model,modelId:m.label,supportsVision:m.purpose===`vision`});return}if(e.startsWith(`catalog:`)){let t=e.slice(8),r=y.data?.find(e=>e.id===t);n({model:{kind:`catalog`,catalogId:t},modelId:t,supportsVision:r?.purpose===`vision`});return}let t=e.slice(5),r=b.data?.find(e=>e.file===t);r?.path!==void 0&&n({model:{kind:`path`,path:r.path},modelId:t,supportsVision:!1})},D=e=>{d.trim()!==``&&x.mutate({ref:d.trim(),...e===void 0?{}:{maxBytes:e}})};return r(`div`,{className:`space-y-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-model`,children:o(`ai.model`,`Model`)}),l(te,{id:`ai-model`,value:Ae(t),options:T,onChange:e=>E(e.target.value)})]}),r(`div`,{className:`rounded-md border border-border bg-surface-subtle px-3 py-2.5`,children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:o(`ai.hfTitle`,`Add a model from Hugging Face`)}),l(`p`,{className:`mb-2 text-[10px] leading-relaxed text-foreground-subtle`,children:o(`ai.hfHint`,`Paste a GGUF file URL, or type org/repo — add :QUANT (e.g. unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M) when the repo publishes more than one quantization.`)}),r(`div`,{className:`flex gap-2`,children:[l(M,{value:d,onChange:e=>f(e.target.value),placeholder:`unsloth/Qwen3.6-35B-A3B-GGUF:UD-Q4_K_M`,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())}}),r(G,{size:`sm`,variant:`secondary`,type:`button`,disabled:d.trim()===``||x.isPending,onClick:()=>D(),children:[x.isPending?l(I,{className:`h-3.5 w-3.5 animate-spin`}):l(F,{className:`h-3.5 w-3.5`}),o(`ai.hfCheck`,`Check`)]})]}),x.isError&&l(`p`,{className:`mt-2 text-[11px] text-danger`,children:x.error instanceof Error?x.error.message:o(`common.error`,`Error`)}),m?.ok===!1&&r(`div`,{className:`mt-2 rounded-md border border-danger/40 bg-danger/10 px-2.5 py-2`,children:[l(`p`,{className:`text-[11px] text-danger`,children:m.message}),m.candidates!==void 0&&m.candidates.length>0&&l(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:m.candidates.map(e=>l(`button`,{type:`button`,className:`rounded border border-border bg-surface px-1.5 py-0.5 text-[10px] text-foreground hover:border-primary/50`,onClick:()=>{let t=`${d.trim().split(`:`)[0]??``}:${e}`;f(t),x.mutate({ref:t})},children:e},e))}),m.requiredBytes!==void 0&&l(G,{size:`sm`,variant:`secondary`,type:`button`,className:`mt-2`,onClick:()=>D(m.requiredBytes),children:o(`ai.hfOverride`,`Install anyway ({{size}})`,{size:$(m.requiredBytes)})})]}),m?.ok===!0&&r(`div`,{className:`mt-2 rounded-md border border-border bg-surface px-2.5 py-2`,children:[r(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[l(`span`,{className:`text-[11px] font-medium text-foreground`,children:m.label}),l(v,{variant:m.purpose===`vision`?`info`:`default`,children:m.purpose}),l(v,{variant:`default`,children:$(m.totalBytes)})]}),m.extraFilenames.length>0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:o(`ai.hfExtras`,`Also downloads: {{files}}`,{files:m.extraFilenames.join(`, `)})}),r(`div`,{className:`mt-2 flex items-center gap-2`,children:[r(G,{size:`sm`,type:`button`,disabled:S.isPending||g,onClick:()=>S.mutate(m.model),children:[S.isPending?l(I,{className:`h-3.5 w-3.5 animate-spin`}):l(C,{className:`h-3.5 w-3.5`}),g?o(`ai.hfInstalled`,`Downloaded`):o(`ai.hfInstall`,`Download to {{node}}`,{node:e})]}),w!==void 0&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:w.phase===`verifying`?o(`ai.hfVerifying`,`verifying {{file}}…`,{file:w.file}):o(`ai.hfDownloading`,`{{file}} ({{index}}/{{count}}) — {{done}}{{total}}`,{file:w.file,index:w.fileIndex,count:w.fileCount,done:$(w.downloadedBytes),total:w.totalBytes===void 0?``:` / ${$(w.totalBytes)}`})})]}),S.isError&&l(`p`,{className:`mt-1.5 text-[11px] text-danger`,children:S.error instanceof Error?S.error.message:o(`common.error`,`Error`)})]})]})]})}function Me({value:e,onChange:t}){let{t:n}=J(),i=p(),o=a({queryKey:ue,queryFn:()=>i.trpcClient.llm.listRuntimeNodes.query({})});return r(`div`,{children:[l(`div`,{className:`mb-1 text-[11px] font-medium text-foreground`,children:n(`ai.appleNode`,`Mac that runs it`)}),o.isPending&&r(`div`,{className:`flex items-center gap-1.5 text-[11px] text-foreground-subtle`,children:[l(I,{className:`h-3.5 w-3.5 animate-spin`}),n(`ai.appleAsking`,`Asking the nodes…`)]}),o.isError&&l(`p`,{className:`text-[11px] text-danger`,children:o.error instanceof Error?o.error.message:n(`ai.runtimesFailed`,`Failed to read runtime nodes`)}),o.isSuccess&&o.data.length===0&&l(`p`,{className:`text-[11px] text-foreground-subtle`,children:n(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}),o.isSuccess&&o.data.length>0&&l(`div`,{role:`radiogroup`,className:`space-y-1.5`,children:o.data.map(i=>{let a=Oe(i),o=a.nodeId===e;return r(`button`,{type:`button`,role:`radio`,"aria-checked":o,disabled:!a.selectable&&!o,onClick:()=>t(a.nodeId),className:`flex w-full items-center justify-between gap-2 rounded-md border px-3 py-2 text-left text-xs transition-colors disabled:cursor-not-allowed disabled:opacity-60 ${o?`border-primary bg-primary/10`:`border-border bg-surface hover:bg-surface-hover`}`,children:[r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block font-medium text-foreground`,children:a.nodeId}),a.detail!==null&&l(`span`,{className:`block truncate text-[10px] text-foreground-subtle`,children:a.detail})]}),l(v,{variant:a.tone,children:n(a.labelKey,a.labelDefault)})]},a.nodeId)})}),l(`p`,{className:`mt-1.5 text-[10px] leading-relaxed text-foreground-subtle`,children:n(`ai.appleHint`,`Text only for now — notification titles and summaries. Apple refuses prompts framed as surveillance; when it does, the next profile in the chain answers instead.`)})]})}n();function Ne({kind:e,className:t}){let n=he(e.kind);return n===null?l(`span`,{className:t,children:e.icon}):l(n,{className:t})}function Pe({kinds:e,onPick:t,onCancel:n}){let{t:a}=J(),o=i(()=>we(e),[e]);return l(y,{open:!0,onOpenChange:e=>!e&&n(),children:r(z,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(O,{children:l(A,{children:a(`ai.chooseKind`,`Choose a profile type`)})}),r(x,{className:`space-y-4 pr-1`,children:[o.length===0&&l(`p`,{className:`text-xs text-foreground-subtle`,children:a(`ai.noKinds`,`No AI provider is installed.`)}),o.map(e=>r(`div`,{children:[l(`div`,{className:`mb-1.5 text-[10px] font-semibold uppercase tracking-wider text-foreground-subtle`,children:e.addonId}),l(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3`,children:e.kinds.map(n=>r(`button`,{type:`button`,onClick:()=>t(n),className:`flex flex-col items-center gap-1.5 rounded-lg border border-border bg-surface px-3 py-3 text-xs transition-colors hover:border-primary/50 hover:bg-surface-hover`,children:[l(Ne,{kind:n,className:`h-5 w-5 text-foreground-subtle`}),l(`span`,{className:`font-medium text-foreground`,children:n.label})]},`${e.addonId}:${n.kind}`))})]},e.addonId))]}),l(k,{children:l(G,{size:`sm`,variant:`secondary`,type:`button`,onClick:n,children:a(`common.cancel`,`Cancel`)})})]})})}function Fe({kind:e,existing:t,onSave:n,onCancel:a,saving:c,error:u}){let{t:d}=J(),f=e.kind===`managed-local`,p=e.kind===`apple-foundation`,[m,h]=s(t?.appleFoundation?.nodeId??null),[g,_]=s(t?.name??e.label),[b,S]=s(()=>t===null?{}:ge(t)),[C,w]=s(t?.runtime?.nodeId??`hub`),[T,E]=s(()=>t?.runtime===void 0?null:{model:t.runtime.model,modelId:t.model,supportsVision:t.supportsVision}),D=i(()=>ye(X(b.extraArgs)??``),[b.extraArgs]),j=()=>{if(p){if(m===null)return;n(Ee(g,t,b,m));return}if(!f){n(Ce(e.kind,g,t,b));return}T!==null&&n(Ce(e.kind,g,t,b,{nodeId:C,model:T.model,modelId:T.modelId,supportsVision:T.supportsVision}))},ee=c||g.trim()===``||f&&T===null||p&&m===null;return l(y,{open:!0,onOpenChange:e=>!e&&a(),children:r(z,{width:`lg`,placement:`sheet-on-mobile`,scroll:`body`,children:[l(O,{children:r(A,{className:`flex items-center gap-2`,children:[l(Ne,{kind:e,className:`h-4 w-4 text-foreground-subtle`}),t===null?d(`ai.newProfile`,`New {{kind}} profile`,{kind:e.label}):d(`ai.editProfile`,`Edit {{name}}`,{name:t.name})]})}),r(x,{className:`space-y-3 pr-1`,children:[u!==null&&l(`div`,{className:`rounded-md border border-danger/40 bg-danger/10 px-3 py-2 text-xs text-danger`,children:u}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-profile-name`,children:d(`ai.name`,`Name`)}),l(M,{id:`ai-profile-name`,value:g,onChange:e=>_(e.target.value),placeholder:e.label})]}),f&&r(o,{children:[l(L,{selectedNodeId:C,onSelect:w,label:d(`ai.runtimeNode`,`Runtime node`),alwaysShow:!0}),l(je,{nodeId:C,value:T,onChange:E}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-extra-args`,children:d(`ai.extraArgs`,`Additional llama-server arguments`)}),l(M,{id:`ai-extra-args`,value:X(b.extraArgs)??``,onChange:e=>S({...b,extraArgs:e.target.value}),placeholder:xe.join(` `)}),D.length>0&&l(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:D.map((e,t)=>l(v,{variant:`default`,children:e},`${e}-${String(t)}`))}),l(`p`,{className:`mt-1 text-[10px] leading-relaxed text-foreground-subtle`,children:d(`ai.extraArgsHint`,`Flags this form does not already own. Vision models generally need --jinja; some language-only models do not like it. Context size, GPU layers, parallel slots, flash attention and the KV-cache types are set in the fields below — repeating one here is rejected at start.`)})]})]}),p&&l(Me,{value:m,onChange:h}),l(R,{schema:e.configSchema,values:b,onChange:S}),t!==null&&l(`p`,{className:`text-[10px] text-foreground-subtle`,children:d(`ai.secretHint`,`A stored API key is never shown. Leave it as-is to keep it; type a new value to replace it.`)})]}),r(k,{children:[f&&T===null&&l(v,{variant:`warning`,children:d(`ai.pickModelFirst`,`pick a model`)}),p&&m===null&&l(v,{variant:`warning`,children:d(`ai.pickAppleNodeFirst`,`pick a Mac`)}),l(G,{size:`sm`,variant:`secondary`,type:`button`,onClick:a,children:d(`common.cancel`,`Cancel`)}),r(G,{size:`sm`,type:`button`,disabled:ee,onClick:j,children:[c&&l(I,{className:`h-3.5 w-3.5 animate-spin`}),t===null?d(`ai.createProfile`,`Create profile`):d(`ai.saveChanges`,`Save changes`)]})]})]})})}n();function Ie(e){return[{key:`name`,header:e.t(`ai.colProfile`,`Profile`),render:t=>{let n=e.kindByName.get(t.kind);return r(`span`,{className:`flex items-center gap-2`,children:[l(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-surface`,title:n?.label??t.kind,children:n===void 0?l(`span`,{className:`text-xs text-foreground-subtle`,children:`?`}):l(Ne,{kind:n,className:`h-4 w-4 text-foreground-subtle`})}),r(`span`,{className:`min-w-0`,children:[l(`span`,{className:`block truncate text-sm font-medium text-foreground`,children:t.name}),e.testResult?.id===t.id&&l(`span`,{className:`block truncate text-[10px] ${e.testResult.ok?`text-success`:`text-danger`}`,children:e.testResult.text})]})]})}},{key:`kind`,header:e.t(`ai.colKind`,`Kind`),nowrap:!0,render:t=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.kindByName.get(t.kind)?.label??t.kind})},{key:`model`,header:e.t(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.model})},{key:`vision`,header:e.t(`ai.colVision`,`Vision`),align:`center`,nowrap:!0,render:t=>t.supportsVision?l(v,{variant:`info`,style:`outline`,children:e.t(`ai.vision`,`vision`)}):l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`})},{key:`node`,header:e.t(`ai.colNode`,`Node`),nowrap:!0,render:e=>e.runtime===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(v,{variant:`default`,children:e.runtime.nodeId})},{key:`enabled`,header:e.t(`ai.colOn`,`On`),align:`center`,nowrap:!0,render:t=>l(S,{checked:t.enabled,onCheckedChange:()=>e.onToggle(t),"aria-label":`toggle ${t.name}`})},{key:`actions`,header:``,align:`right`,nowrap:!0,render:t=>r(`span`,{className:`flex items-center justify-end gap-1`,children:[l(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onTest(t),title:e.t(`ai.test`,`Test`),children:e.testingId===t.id?l(I,{className:`h-3.5 w-3.5 animate-spin`}):l(ie,{className:`h-3.5 w-3.5`})}),l(G,{size:`sm`,variant:`ghost`,type:`button`,disabled:!e.kindByName.has(t.kind),onClick:()=>e.onEdit(t),title:e.t(`common.edit`,`Edit`),children:l(K,{className:`h-3.5 w-3.5`})}),l(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>e.onDelete(t),title:e.t(`common.delete`,`Delete`),children:l(h,{className:`h-3.5 w-3.5 text-danger`})})]})}]}function Le(){let{t:e}=J(),t=p(),[n,o]=s({mode:`closed`}),[u,d]=s(null),[f,m]=s(null),h=a({queryKey:se,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),g=a({queryKey:ce,queryFn:async()=>(await t.trpcClient.llm.listProfileKinds.query({})).map(e=>({...e,configSchema:e.configSchema}))}),_=()=>{h.refetch()},v=c({mutationFn:e=>t.trpcClient.llm.upsertProfile.mutate({profile:e}),onSuccess:()=>{o({mode:`closed`}),m(null),_()},onError:t=>m(t instanceof Error?t.message:e(`ai.saveFailed`,`Save failed`))}),y=c({mutationFn:e=>t.trpcClient.llm.deleteProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:_}),b=c({mutationFn:e=>t.trpcClient.llm.testProfile.mutate({addonId:e.addonId,profileId:e.id}),onSuccess:(e,t)=>d({id:t.id,ok:e.ok,text:e.ok?`${e.text} (${String(e.usage.outputTokens)} tok, ${String(e.latencyMs)}ms)`:`${e.code}: ${e.message}`})}),x=h.data??[],S=i(()=>g.data??[],[g.data]),C=i(()=>{let e=new Map;for(let t of S)e.set(t.kind,t);return e},[S]);return r(Y,{icon:D,title:e(`ai.profilesTitle`,`AI profiles`),subtitle:e(`ai.profilesSubtitle`,`One row = one usable model endpoint. The defaults below decide who answers when a feature names no profile.`),actions:r(G,{size:`sm`,type:`button`,onClick:()=>{m(null),o({mode:`pick-kind`})},children:[l(j,{className:`h-3.5 w-3.5`}),e(`ai.addProfile`,`Add profile`)]}),children:[h.isError&&l(H,{title:e(`ai.loadFailed`,`Failed to load profiles`),message:h.error instanceof Error?h.error.message:e(`common.error`,`Error`),onRetry:()=>void h.refetch()}),l(Re,{profiles:x}),h.isLoading&&l(`div`,{className:`flex items-center justify-center py-16`,children:l(I,{className:`h-6 w-6 animate-spin text-primary`})}),!h.isLoading&&x.length===0&&l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noProfiles`,`No AI profiles yet. Click "Add profile" to configure one.`)}),x.length>0&&l(N,{children:l(U,{columns:Ie({kindByName:C,testResult:u,testingId:b.isPending?b.variables?.id??null:null,t:e,onToggle:e=>v.mutate({...e,enabled:!e.enabled,apiKey:`__redacted__`}),onTest:e=>b.mutate(e),onEdit:e=>{let t=C.get(e.kind);t!==void 0&&(m(null),o({mode:`form`,kind:t,profile:e}))},onDelete:e=>y.mutate(e)}),rows:x,rowKey:e=>e.id,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:`max-h-[60vh]`})}),n.mode===`pick-kind`&&l(Pe,{kinds:S,onCancel:()=>o({mode:`closed`}),onPick:e=>o({mode:`form`,kind:e,profile:null})}),n.mode===`form`&&l(Fe,{kind:n.kind,existing:n.profile,saving:v.isPending,error:f,onSave:e=>v.mutate(e),onCancel:()=>o({mode:`closed`})})]})}function Re({profiles:e}){let{t}=J(),n=p(),i=a({queryKey:le,queryFn:()=>n.trpcClient.llm.getDefaults.query({})}),o=c({mutationFn:e=>n.trpcClient.llm.setDefault.mutate({selector:{purpose:e.purpose},profileId:e.profileId}),onSuccess:()=>{i.refetch()}}),s=e=>(i.data??[]).find(t=>`purpose`in t.selector&&t.selector.purpose===e)?.profileId??``,u=e=>e===`vision`?t(`ai.defaultVision`,`Default vision profile`):t(`ai.defaultText`,`Default text profile`);return l(N,{children:l(`div`,{className:`grid gap-4 p-4 sm:grid-cols-2`,children:pe.map(({purpose:n,visionOnly:i})=>{let a=i?e.filter(e=>e.supportsVision):e,c=s(n),d=e.find(e=>e.id===c);return r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`llm-default-${n}`,children:u(n)}),r(`select`,{id:`llm-default-${n}`,"aria-label":u(n),className:`h-7 w-full rounded-md border border-border bg-surface px-2.5 text-xs text-foreground focus:outline-none focus:ring-1 focus:ring-primary`,value:c,onChange:e=>o.mutate({purpose:n,profileId:e.target.value===``?null:e.target.value}),children:[l(`option`,{value:``,children:t(`ai.none`,`None`)}),c!==``&&!a.some(e=>e.id===c)&&l(`option`,{value:c,children:d?.name??c}),a.map(e=>r(`option`,{value:e.id,children:[e.name,` · `,e.model]},e.id))]}),c!==``&&d===void 0&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:t(`ai.defaultMissing`,`This default names a profile that no longer exists.`)}),d!==void 0&&!d.enabled&&l(`p`,{className:`mt-1 text-[10px] text-warning`,children:t(`ai.defaultDisabled`,`This default profile is disabled — callers resolve to no profile.`)}),o.error!=null&&l(`p`,{className:`mt-1 text-[10px] text-danger`,children:String(o.error)})]},n)})})})}n();var ze=5e3;function Be(e){return`${(e/1e9).toFixed(1)} GB`}function Ve(){let{t:e}=J(),t=p(),n=a({queryKey:ue,refetchInterval:ze,queryFn:()=>t.trpcClient.llm.listRuntimeNodes.query({})}),o=i(()=>[{key:`node`,header:e(`ai.colNode`,`Node`),render:e=>l(`span`,{className:`text-sm font-medium text-foreground`,children:e.nodeId})},{key:`state`,header:e(`ai.colState`,`State`),nowrap:!0,render:t=>r(`span`,{className:`flex items-center gap-1.5`,children:[l(v,{variant:t.reachable?`success`:`danger`,children:t.reachable?t.status?.state??e(`ai.ready`,`ready`):e(`ai.unreachable`,`unreachable`)}),t.status?.downloadProgress!==void 0&&l(v,{variant:`info`,children:`${String(Math.round(t.status.downloadProgress*100))}%`})]})},{key:`model`,header:e(`ai.colModel`,`Model`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.status?.modelId??`—`})},{key:`disk`,header:e(`ai.colDisk`,`On disk`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground-subtle`,children:e.disk===void 0?`—`:Be(e.disk.modelsBytes)})},{key:`apple`,header:e(`ai.colApple`,`Apple on-device`),render:t=>{let n=Oe(t);return r(`span`,{className:`flex flex-col items-start gap-0.5`,children:[l(v,{variant:n.tone,children:e(n.labelKey,n.labelDefault)}),n.detail!==null&&l(`span`,{className:`text-[10px] text-foreground-subtle`,children:n.detail})]})}},{key:`error`,header:e(`ai.colError`,`Error`),render:e=>e.error===void 0?l(`span`,{className:`text-[11px] text-foreground-subtle`,children:`—`}):l(`span`,{className:`text-[11px] text-danger`,children:e.error})}],[e]),s=n.data??[];return r(Y,{icon:B,title:e(`ai.runtimesTitle`,`Managed runtimes`),subtitle:e(`ai.runtimesSubtitle`,`Nodes advertising the llm-runtime capability: what each has loaded, what it is downloading, and how much model data sits on its disk.`),children:[n.isError&&l(H,{title:e(`ai.runtimesFailed`,`Failed to read runtime nodes`),message:n.error instanceof Error?n.error.message:e(`common.error`,`Error`),onRetry:()=>void n.refetch()}),s.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noRuntimes`,`No node advertises the llm-runtime capability.`)}):l(N,{children:l(U,{columns:o,rows:s,rowKey:e=>e.nodeId,minWidthPx:760,bordered:!1,mobileMode:`scroll`,maxBodyHeight:w})})]})}var He=f(`/addon/ai/test-chat`),Ue=f(`/addon/ai/test-chat/chats`),We=6e5;function Ge(e){let t=e.firstTokenTimeoutMs;if(!(typeof t!=`number`||!Number.isFinite(t)||t<=0))return Math.min(Math.round(t),We)}function Ke(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function qe(e){if(!Ke(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 Je=[`resolving-image`,`connecting`,`first-token-wait`,`streaming`];function Ye(e){let t;try{t=JSON.parse(e)}catch{return null}if(!Ke(t))return null;switch(t.kind){case`status`:{let e=Je.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:qe(t.mediaSent),streamed:t.streamed===!0,firstTokenTimeoutMs:typeof t.firstTokenTimeoutMs==`number`?t.firstTokenTimeoutMs:0};case`token`:return typeof t.text==`string`?{kind:`token`,text:t.text}:null;case`done`:return{kind:`done`,inputTokens:typeof t.inputTokens==`number`?t.inputTokens:0,outputTokens:typeof t.outputTokens==`number`?t.outputTokens:0,latencyMs:typeof t.latencyMs==`number`?t.latencyMs:0,truncated:t.truncated===!0,...typeof t.conversationId==`string`?{conversationId:t.conversationId}:{}};case`error`:return{kind:`error`,code:typeof t.code==`string`?t.code:`adapter-error`,message:typeof t.message==`string`?t.message:`the provider returned an error`};default:return null}}async function*Xe(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=Ye(e);t!==null&&(yield t)}a=r.indexOf(`
3
- `)}}let e=r.trim();if(e.length>0){let t=Ye(e);t!==null&&(yield t)}}finally{t.releaseLock()}}function Ze(e){return e.filter(e=>e.failed!==!0&&e.content.length>0).map(e=>({role:e.role,content:e.content}))}function Qe(e){return e.thumbnailBase64===void 0||e.thumbnailBase64.length===0?null:`data:${e.mimeType};base64,${e.thumbnailBase64}`}function $e(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 et(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 tt(e,t){switch(e){case`resolving-image`:return`fetching the picture…`;case`connecting`:return`connecting to the provider…`;case`first-token-wait`:return t>0?`the model is loading / thinking — a cold load can take minutes (up to ${String(Math.round(t/1e3))}s)`:`the model is loading / thinking — a cold load can take minutes`;case`streaming`:return`answering…`}}n();var nt=[`pipelineAnalytics`,`listRecentTracks`,`ai-test`],rt=360*60*1e3,it=40,at=160,ot={phase:`connecting`,firstTokenTimeoutMs:0,text:``,mediaSent:null};function st(){let{t:n}=J(),o=p(),[c,d]=s(``),[f,_]=s(``),[v,y]=s(``),[b,x]=s([]),[S,C]=s(null),[w,T]=s(`none`),[D,O]=s(`throwaway`),[k,A]=s(null),[j,ne]=s([]),[P,F]=s(null),[I,L]=s(null),R=t(null);u(()=>()=>R.current?.abort(),[]);let z=e(async()=>{let e=await fetch(Ue,{credentials:`same-origin`});e.ok&&ne((await e.json()).chats??[])},[]);u(()=>{D===`persistent`&&z()},[D,z]);let B=a({queryKey:se,queryFn:()=>o.trpcClient.llm.listProfiles.query({})}),V=i(()=>(B.data??[]).filter(e=>e.enabled),[B.data]),U=V.find(e=>e.id===c)??null,K=I!==null,re=e(async(e,t)=>{let r=new AbortController;R.current=r,F(null);let i=Ge(U??{});L({...ot,firstTokenTimeoutMs:i??0});let a=``,o=null,s,l=null,u=null,d;try{let n=await fetch(He,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,signal:r.signal,body:JSON.stringify({profileId:c,messages:e,...f.trim()===``?{}:{system:f.trim()},...t===void 0?{}:{attachment:t},...i===void 0?{}:{firstTokenTimeoutMs:i},...D===`persistent`?{persist:!0,...k===null?{}:{conversationId:k}}:{}})});if(!n.ok||n.body===null){let e=await n.text().catch(()=>``);throw Error(e.length>0?e:`HTTP ${String(n.status)}`)}for await(let e of Xe(n.body))switch(e.kind){case`status`:L(t=>({...t??ot,phase:e.phase}));break;case`meta`:o=e.mediaSent,s=e.model,L(t=>({...t??ot,firstTokenTimeoutMs:e.firstTokenTimeoutMs,mediaSent:e.mediaSent}));break;case`token`:a+=e.text,L(e=>({...e??ot,text:a}));break;case`done`:u={outputTokens:e.outputTokens,latencyMs:e.latencyMs},d=e.conversationId;break;case`error`:l=`${e.code}: ${e.message}`;break}}catch(e){r.signal.aborted||F(e instanceof Error?e.message:n(`common.error`,`Error`))}finally{R.current=null,L(null)}d!==void 0&&(A(d),z());let p=r.signal.aborted&&a.length>0;l===null&&a.length===0&&!p||x(e=>[...e,{id:`a-${String(Date.now())}`,role:`assistant`,content:l??a,...l===null?{}:{failed:!0},...o===null?{}:{attachment:o},...s!==void 0&&l===null?{model:s}:{},...u===null?{}:u}])},[D,k,U,c,z,f,n]),q=e(()=>{let e=v.trim();if(e===``||c===``||K)return;let t={id:`u-${String(Date.now())}`,role:`user`,content:e,...S===null?{}:{attachmentLabel:S.label,attachmentKind:S.ref.kind}},n=[...b,t];x(n),y(``);let r=S?.ref;C(null),T(`none`),re(D===`persistent`&&k!==null?[{role:`user`,content:e}]:Ze(n),r)},[D,k,v,S,c,re,K,b]),ae=()=>R.current?.abort(),ce=()=>{R.current?.abort(),x([]),C(null),y(``),F(null),L(null),A(null)},le=async e=>{R.current?.abort();let t=await fetch(`${Ue}/${e}`,{credentials:`same-origin`});if(!t.ok)return;let n=await t.json();A(e),x($e(n)),L(null),F(null)};return r(Y,{icon:E,title:n(`ai.testTitle`,`Test chat`),subtitle:n(D===`persistent`?`ai.testSubtitlePersistent`:`ai.testSubtitle`,D===`persistent`?`Conversations are saved for you and can be reopened. Throwaway mode is still available.`:`A throwaway conversation with one profile. Attach a live camera snapshot or a recent track to check the model can actually read a picture. Nothing is saved — only the usage row.`),actions:r(G,{size:`sm`,variant:`secondary`,type:`button`,disabled:b.length===0&&S===null,onClick:ce,children:[l(h,{className:`h-3.5 w-3.5`}),n(`ai.clearChat`,`Clear`)]}),children:[r(N,{className:`space-y-3 p-4`,children:[r(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-profile`,children:n(`ai.profile`,`Profile`)}),l(te,{id:`ai-test-profile`,value:c,onChange:e=>d(e.target.value),options:[{value:``,label:n(`ai.selectProfile`,`Select a profile…`)},...V.map(e=>({value:e.id,label:`${e.name} · ${e.model}${e.supportsVision?` · vision`:``}`}))]}),V.length===0&&!B.isLoading&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:n(`ai.noEnabledProfiles`,`No enabled profile. Add one on the Profiles tab.`)})]}),r(`div`,{children:[l(`label`,{className:`mb-1 block text-[11px] font-medium text-foreground`,htmlFor:`ai-test-system`,children:n(`ai.systemPrompt`,`System prompt (optional)`)}),l(M,{id:`ai-test-system`,value:f,onChange:e=>_(e.target.value),placeholder:n(`ai.systemPlaceholder`,`Answer in one short sentence.`)})]})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[l(G,{size:`sm`,variant:D===`throwaway`?`primary`:`outline`,type:`button`,onClick:()=>{O(`throwaway`),A(null)},children:n(`ai.throwawayMode`,`Throwaway`)}),l(G,{size:`sm`,variant:D===`persistent`?`primary`:`outline`,type:`button`,onClick:()=>O(`persistent`),children:n(`ai.saveConversation`,`Save conversation`)})]}),D===`persistent`&&r(`div`,{className:`space-y-2`,children:[l(`div`,{className:`flex items-center gap-2`,children:r(G,{size:`sm`,variant:`secondary`,type:`button`,onClick:ce,children:[l(oe,{className:`h-3.5 w-3.5`}),n(`ai.newChat`,`New chat`)]})}),j.length>0&&l(`div`,{className:`max-h-36 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:j.map(e=>l(`button`,{type:`button`,onClick:()=>void le(e.id),className:`flex w-full px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover ${e.id===k?`bg-primary/10`:``}`,children:l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:e.title})},e.id))})]}),l(`p`,{className:`text-[10px] text-foreground-subtle`,children:n(`ai.streamNote`,`The answer streams as the model produces it. A cold model can take a while to load — the status line says which phase it is in.`)}),U!==null&&!U.supportsVision&&l(`p`,{className:`text-[10px] text-warning`,children:n(`ai.notVision`,`This profile is not vision-capable — an attached image will be refused before anything is read.`)})]}),P!==null&&l(H,{title:n(`ai.chatFailed`,`The test call failed`),message:P}),l(ct,{turns:b,live:I}),r(N,{className:`space-y-2 p-3`,children:[S!==null&&r(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-surface px-2.5 py-1.5`,children:[S.ref.kind===`snapshot`?l(g,{className:`h-3.5 w-3.5 text-foreground-subtle`}):l(W,{className:`h-3.5 w-3.5 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-[11px] text-foreground`,children:S.label}),l(G,{size:`sm`,variant:`ghost`,type:`button`,onClick:()=>C(null),children:l(ee,{className:`h-3.5 w-3.5`})})]}),r(`div`,{className:`flex flex-wrap items-center gap-2`,children:[r(G,{size:`sm`,variant:w===`snapshot`?`primary`:`outline`,type:`button`,onClick:()=>T(w===`snapshot`?`none`:`snapshot`),children:[l(g,{className:`h-3.5 w-3.5`}),n(`ai.attachSnapshot`,`Camera snapshot`)]}),r(G,{size:`sm`,variant:w===`track`?`primary`:`outline`,type:`button`,onClick:()=>T(w===`track`?`none`:`track`),children:[l(W,{className:`h-3.5 w-3.5`}),n(`ai.attachTrack`,`Recent track`)]})]}),w===`snapshot`&&l(dt,{onPick:e=>{C({ref:{kind:`snapshot`,deviceId:e.id},label:n(`ai.snapshotOf`,`Snapshot of {{name}}`,{name:e.name})}),T(`none`)}}),w===`track`&&l(pt,{onPick:(e,t)=>{C({ref:{kind:`track`,trackId:e.trackId,deviceId:e.deviceId},label:n(`ai.trackOf`,`{{class}} on {{name}}`,{class:e.label??e.className,name:t})}),T(`none`)}}),r(`div`,{className:`flex items-center gap-2`,children:[l(M,{value:v,onChange:e=>y(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),q())},placeholder:n(`ai.messagePlaceholder`,`Ask the model something…`),"aria-label":n(`ai.message`,`Message`)}),K?r(G,{size:`sm`,variant:`secondary`,type:`button`,onClick:ae,children:[l(m,{className:`h-3.5 w-3.5`}),n(`ai.stop`,`Stop`)]}):r(G,{size:`sm`,type:`button`,disabled:v.trim()===``||c===``,onClick:q,children:[l(ie,{className:`h-3.5 w-3.5`}),n(`ai.send`,`Send`)]})]})]})]})}function ct({turns:e,live:t}){let{t:n}=J();return e.length===0&&t===null?l(`div`,{className:`py-12 text-center text-xs text-foreground-subtle`,children:n(`ai.chatEmpty`,`Pick a profile, optionally attach a camera snapshot or a recent track, and send a message. Nothing here is saved.`)}):l(N,{children:r(`div`,{className:`max-h-[50vh] space-y-2 overflow-y-auto p-3`,children:[e.map(e=>l(lt,{turn:e},e.id)),t!==null&&r(`div`,{className:`space-y-1`,children:[t.mediaSent!==null&&l(ut,{attachment:t.mediaSent}),t.text.length>0&&l(lt,{turn:{id:`live`,role:`assistant`,content:t.text},streaming:!0}),r(`div`,{className:`flex items-center gap-2 text-[11px] text-foreground-subtle`,children:[l(I,{className:`h-3.5 w-3.5 animate-spin`}),tt(t.phase,t.firstTokenTimeoutMs)]})]})]})})}function lt({turn:e,streaming:t=!1}){let n=e.role===`user`,i=e.failed===!0?`border-danger/40 bg-danger/10`:`border-border bg-surface`;return l(`div`,{className:`flex ${n?`justify-end`:`justify-start`}`,children:r(`div`,{className:`max-w-[85%] rounded-lg border px-3 py-2 ${n?`border-primary/40 bg-primary/10`:i}`,children:[r(`p`,{className:`whitespace-pre-wrap break-words text-xs text-foreground`,children:[e.content,t&&l(`span`,{className:`ml-0.5 animate-pulse text-primary`,children:`▌`})]}),e.attachment!==void 0&&l(ut,{attachment:e.attachment}),e.attachmentLabel!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachmentKind===`track`?l(W,{className:`h-3 w-3`}):l(g,{className:`h-3 w-3`}),e.attachmentLabel]}),e.attachment!==void 0&&r(`p`,{className:`mt-1 flex items-center gap-1 text-[10px] text-foreground-subtle`,children:[e.attachment.kind===`snapshot`?l(g,{className:`h-3 w-3`}):l(W,{className:`h-3 w-3`}),et(e.attachment)]}),e.model!==void 0&&l(`p`,{className:`mt-1 text-[10px] text-foreground-subtle`,children:`${e.model} · ${String(e.outputTokens??0)} tok · ${String(e.latencyMs??0)} ms`})]})})}function ut({attachment:e}){let t=Qe(e);return t===null?null:l(`img`,{src:t,alt:`sent to the model`,className:`mt-1 max-h-32 rounded-md border border-border object-contain`})}function dt({onPick:e}){let{t}=J(),n=T({isCamera:!0,projection:`slim`}),r=(n.data??[]).filter(e=>!e.disabled);return n.isLoading?l(I,{className:`h-4 w-4 animate-spin text-foreground-subtle`}):r.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noCameras`,`No camera found.`)}):l(`div`,{className:`grid max-h-56 grid-cols-2 gap-2 overflow-y-auto sm:grid-cols-4`,children:r.map(t=>l(ft,{device:t,onPick:e},t.id))})}function ft({device:e,onPick:t}){let{src:n}=d(e.id,{width:at});return r(`button`,{type:`button`,onClick:()=>t(e),className:`overflow-hidden rounded-md border border-border bg-surface text-left transition-colors hover:border-primary/50`,children:[l(`span`,{className:`block aspect-video w-full bg-background-elevated`,children:n!==null&&l(`img`,{src:n,alt:``,className:`h-full w-full object-cover`,loading:`lazy`})}),r(`span`,{className:`flex items-center gap-1 px-2 py-1`,children:[!e.online&&l(v,{variant:`warning`,children:`off`}),l(`span`,{className:`truncate text-[10px] text-foreground`,children:e.name})]})]})}function pt({onPick:e}){let{t}=J(),n=p(),o=T({isCamera:!0,projection:`slim`}),s=i(()=>(o.data??[]).map(e=>e.id),[o.data]),c=i(()=>{let e=new Map;for(let t of o.data??[])e.set(t.id,t.name);return e},[o.data]),u=a({queryKey:[...nt,s.length],enabled:s.length>0,queryFn:()=>n.trpcClient.pipelineAnalytics.listRecentTracks.query({deviceIds:[...s],since:Date.now()-rt,limit:it,projection:`slim`})});if(o.isLoading||u.isLoading)return l(I,{className:`h-4 w-4 animate-spin text-foreground-subtle`});let d=u.data?.tracks??[];return d.length===0?l(`p`,{className:`text-[11px] text-foreground-subtle`,children:t(`ai.noTracks`,`No track in the last 6 hours.`)}):l(`div`,{className:`max-h-56 divide-y divide-border overflow-y-auto rounded-md border border-border`,children:d.map(t=>r(`button`,{type:`button`,onClick:()=>e(t,c.get(t.deviceId)??String(t.deviceId)),className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-[11px] hover:bg-surface-hover`,children:[l(W,{className:`h-3.5 w-3.5 shrink-0 text-foreground-subtle`}),l(`span`,{className:`min-w-0 flex-1 truncate text-foreground`,children:t.label??t.className}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:c.get(t.deviceId)??t.deviceId}),l(`span`,{className:`shrink-0 text-foreground-subtle`,children:new Date(t.lastSeen).toLocaleTimeString()})]},t.trackId))})}n();var mt=1440*60*1e3,ht=[1,7,30,90];function gt(){let{t:e}=J(),t=p(),[n,o]=s(7),c=i(()=>{let e=new Date;return e.setHours(0,0,0,0),e.getTime()-(n-1)*mt},[n]),u=a({queryKey:se,queryFn:()=>t.trpcClient.llm.listProfiles.query({})}),d=a({queryKey:[...fe,n],queryFn:()=>t.trpcClient.llm.getUsage.query({since:c})}),f=i(()=>{let e=new Map;for(let t of u.data??[])e.set(t.id,t.name);return e},[u.data]),m=i(()=>[{key:`day`,header:e(`ai.colDay`,`Day`),nowrap:!0,render:e=>e.day},{key:`consumer`,header:e(`ai.colConsumer`,`Consumer`),nowrap:!0,render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:e.consumer})},{key:`profile`,header:e(`ai.colProfile`,`Profile`),render:e=>l(`span`,{className:`text-[11px] text-foreground`,children:f.get(e.profileId)??e.profileId})},{key:`calls`,header:e(`ai.colCalls`,`Calls`),align:`right`,nowrap:!0,render:e=>String(e.calls)},{key:`okErr`,header:e(`ai.colOkErr`,`OK / err`),align:`right`,nowrap:!0,render:e=>l(`span`,{className:e.errorCalls>0?`text-danger`:void 0,children:`${String(e.okCalls)} / ${String(e.errorCalls)}`})},{key:`tokens`,header:e(`ai.colTokens`,`In / out tok`),align:`right`,nowrap:!0,render:e=>`${String(e.inputTokens)} / ${String(e.outputTokens)}`},{key:`latency`,header:e(`ai.colAvgMs`,`Avg ms`),align:`right`,nowrap:!0,render:e=>String(Math.round(e.avgLatencyMs))}],[f,e]),h=d.data??[];return r(Y,{icon:b,title:e(`ai.usageTitle`,`Usage`),subtitle:e(`ai.usageSubtitle`,`Server-side rollup per day, consumer and profile — never raw call rows. Errors are counted, so a profile that always fails is visible here before a feature reports it.`),actions:l(`div`,{className:`w-40`,children:l(te,{"aria-label":e(`ai.window`,`Window`),value:String(n),options:ht.map(t=>({value:String(t),label:e(`ai.lastDays`,`Last {{days}} days`,{days:t})})),onChange:e=>o(Number(e.target.value))})}),children:[d.isError&&l(H,{title:e(`ai.usageFailed`,`Failed to read usage`),message:d.error instanceof Error?d.error.message:e(`common.error`,`Error`),onRetry:()=>void d.refetch()}),h.length===0?l(`div`,{className:`py-16 text-center text-xs text-foreground-subtle`,children:e(`ai.noUsage`,`No AI calls in this window.`)}):l(N,{children:l(U,{columns:m,rows:h,rowKey:e=>`${e.day}|${e.consumer}|${e.profileId}`,minWidthPx:720,bordered:!1,mobileMode:`scroll`,maxBodyHeight:w})})]})}function _t(){let{t:e}=J();return l(`div`,{className:`flex flex-col p-4`,children:l(ae,{tabs:[{id:`profiles`,label:e(`ai.tabProfiles`,`Profiles`),icon:re,content:l(Le,{})},{id:`runtimes`,label:e(`ai.tabRuntimes`,`Runtimes`),icon:B,content:l(Ve,{})},{id:`usage`,label:e(`ai.tabUsage`,`Usage`),icon:b,content:l(gt,{})},{id:`test`,label:e(`ai.tabTest`,`Test`),icon:E,content:l(st,{})}]})})}export{_t as AiProfilesPage,_t as default};