@trops/dash-core 0.1.682 → 0.1.684

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.
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
2
  import _typeof from '@babel/runtime/helpers/typeof';
3
3
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
4
  import * as DashReact from '@trops/dash-react';
5
- import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, DragComponent, ConfirmationModal, DropComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption2, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge as StatusBadge$1, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, AlgoliaSearchBox, CommandPalette, useSidebar, SectionLabel, SegmentedControl, FilterMenu, CodeEditorInline, Icon2, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
5
+ import { isObject, ThemeContext, FontAwesomeIcon, Modal, deepCopy, MainSection, getUUID, getStylesForItem, themeObjects, Heading, SearchInput, ButtonIcon, SubHeading3, InputText, Button, Tag, Button3, Button2, Paragraph, Sidebar, Panel, Stepper, Tag3, Card2, Card3, Heading3, MenuItem3, FormLabel, SelectMenu, Switch, SelectInput, CodeEditorVS, SettingsModal, SubHeading2, tailwindHeightFractions, Menu3, Panel3, ButtonIcon2, DropdownPanel, MenuItem2, useStatusTokens, Caption2, DragComponent, ConfirmationModal, DropComponent, getStyleName, capitalizeFirstLetter, isHexColor as isHexColor$1, deriveShades, colorTypes, TAILWIND_PALETTE, Toggle, normalizeHex as normalizeHex$1, contrastRatio, Caption, getColorFamilies, getCuratedColorGrid, DashPanel, hexToRgb as hexToRgb$1, themeVariants, SubHeading, Heading2, Paragraph2, Paragraph3, ButtonIcon3, Tag2, Alert, Alert2, Alert3, Toast, Toast2, Toast3, ProgressBar, ProgressBar2, ProgressBar3, MenuItem, Breadcrumbs, Breadcrumbs2, Breadcrumbs3, Caption3, Code, Code2, Code3, Divider, Divider2, Divider3, DashPanel2, DashPanel3, Tabs, Tabs2, Tabs3, Accordion, Accordion2, Accordion3, Toggle2, Toggle3, TextArea, Checkbox, Slider, RadioGroup, AlertBanner, StatusBadge as StatusBadge$1, Skeleton, StatCard, DataList, EmptyState, Card, Panel2, ThemeFromUrlPane, AlgoliaSearchBox, CommandPalette, useSidebar, SectionLabel, SegmentedControl, FilterMenu, CodeEditorInline, Icon2, Navbar, withRouter, Menu as Menu$1 } from '@trops/dash-react';
6
6
  export * from '@trops/dash-react';
7
7
  export { FontAwesomeIcon, ThemeContext } from '@trops/dash-react';
8
8
  import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
@@ -13845,6 +13845,13 @@ function parseEventString(eventString) {
13845
13845
  }
13846
13846
 
13847
13847
  /** Build an event string in the canonical runtime format. */
13848
+ /**
13849
+ * Bots publish on the same bus (`bot:<ref>[<botId>].<event>`); as listener
13850
+ * sources they aren't widgets in the layout (bot-teams TEAM-012).
13851
+ */
13852
+ function isBotSource(component) {
13853
+ return typeof component === "string" && component.startsWith("bot:");
13854
+ }
13848
13855
  function formatEventString(component, itemId, event) {
13849
13856
  return "".concat(component, "[").concat(itemId, "].").concat(event);
13850
13857
  }
@@ -14034,6 +14041,7 @@ function getCurrentWiring(workspace) {
14034
14041
  * message.
14035
14042
  */
14036
14043
  function getOrphanedListeners(workspace, getWidgetConfig) {
14044
+ var botEmitters = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
14037
14045
  var wiring = getCurrentWiring(workspace);
14038
14046
  if (wiring.length === 0) return [];
14039
14047
 
@@ -14065,34 +14073,55 @@ function getOrphanedListeners(workspace, getWidgetConfig) {
14065
14073
  var _iterator2 = _createForOfIteratorHelper$O(wiring),
14066
14074
  _step2;
14067
14075
  try {
14076
+ var _loop = function _loop() {
14077
+ var w = _step2.value;
14078
+ // Bot sources (TEAM-012): judged against the dashboard's bots once they
14079
+ // are known (`botEmitters`); before that, left alone.
14080
+ if (isBotSource(w.sourceComponent)) {
14081
+ if (!Array.isArray(botEmitters)) return 0; // continue
14082
+ var bot = botEmitters.find(function (b) {
14083
+ return b.component === w.sourceComponent && String(b.itemId) === String(w.sourceItemId);
14084
+ });
14085
+ if (!bot) orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14086
+ reason: "bot-missing"
14087
+ }));else if (!bot.events.includes(w.eventName)) {
14088
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14089
+ reason: "event-not-emitted"
14090
+ }));
14091
+ }
14092
+ return 0; // continue
14093
+ }
14094
+ var srcKey = "".concat(w.sourceComponent, "|").concat(w.sourceItemId);
14095
+ var src = byCompositeKey.get(srcKey);
14096
+ if (!src) {
14097
+ // No (component, id) match. If some OTHER widget still owns
14098
+ // this id, the source component changed; otherwise it's truly
14099
+ // missing. Preserves the user's ability to see whether a
14100
+ // rename happened vs. a delete.
14101
+ var fallback = byItemId.get(String(w.sourceItemId));
14102
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14103
+ reason: fallback ? "source-component-mismatch" : "source-missing"
14104
+ }));
14105
+ return 0; // continue
14106
+ }
14107
+ if (!src.events.includes(w.eventName)) {
14108
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14109
+ reason: "event-not-emitted"
14110
+ }));
14111
+ return 0; // continue
14112
+ }
14113
+ var receiverKey = "".concat(w.receiverComponent, "|").concat(w.receiverItemId);
14114
+ var receiver = byCompositeKey.get(receiverKey);
14115
+ if (receiver && !receiver.eventHandlers.includes(w.handlerName)) {
14116
+ orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14117
+ reason: "handler-not-declared"
14118
+ }));
14119
+ }
14120
+ },
14121
+ _ret;
14068
14122
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
14069
- var w = _step2.value;
14070
- var srcKey = "".concat(w.sourceComponent, "|").concat(w.sourceItemId);
14071
- var src = byCompositeKey.get(srcKey);
14072
- if (!src) {
14073
- // No (component, id) match. If some OTHER widget still owns
14074
- // this id, the source component changed; otherwise it's truly
14075
- // missing. Preserves the user's ability to see whether a
14076
- // rename happened vs. a delete.
14077
- var fallback = byItemId.get(String(w.sourceItemId));
14078
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14079
- reason: fallback ? "source-component-mismatch" : "source-missing"
14080
- }));
14081
- continue;
14082
- }
14083
- if (!src.events.includes(w.eventName)) {
14084
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14085
- reason: "event-not-emitted"
14086
- }));
14087
- continue;
14088
- }
14089
- var receiverKey = "".concat(w.receiverComponent, "|").concat(w.receiverItemId);
14090
- var receiver = byCompositeKey.get(receiverKey);
14091
- if (receiver && !receiver.eventHandlers.includes(w.handlerName)) {
14092
- orphans.push(_objectSpread$1b(_objectSpread$1b({}, w), {}, {
14093
- reason: "handler-not-declared"
14094
- }));
14095
- }
14123
+ _ret = _loop();
14124
+ if (_ret === 0) continue;
14096
14125
  }
14097
14126
  } catch (err) {
14098
14127
  _iterator2.e(err);
@@ -14184,7 +14213,9 @@ function pruneDeadListenerReferences(workspace) {
14184
14213
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
14185
14214
  var raw = _step6.value;
14186
14215
  var parsed = parseEventString(raw);
14187
- if (parsed && liveKeys.has("".concat(parsed.component, "|").concat(parsed.itemId))) {
14216
+ if (parsed && (
14217
+ // Bot sources live outside the layout — never pruned here.
14218
+ isBotSource(parsed.component) || liveKeys.has("".concat(parsed.component, "|").concat(parsed.itemId)))) {
14188
14219
  kept.push(raw);
14189
14220
  } else {
14190
14221
  removed += 1;
@@ -14347,7 +14378,7 @@ function applyToItem(listeners, _ref2) {
14347
14378
  var _iterator0 = _createForOfIteratorHelper$O(removes),
14348
14379
  _step0;
14349
14380
  try {
14350
- var _loop = function _loop() {
14381
+ var _loop2 = function _loop2() {
14351
14382
  var r = _step0.value;
14352
14383
  var target = r.handlerName;
14353
14384
  if (!target) return 0; // continue
@@ -14363,10 +14394,10 @@ function applyToItem(listeners, _ref2) {
14363
14394
  next[target] = filtered;
14364
14395
  }
14365
14396
  },
14366
- _ret;
14397
+ _ret2;
14367
14398
  for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
14368
- _ret = _loop();
14369
- if (_ret === 0) continue;
14399
+ _ret2 = _loop2();
14400
+ if (_ret2 === 0) continue;
14370
14401
  }
14371
14402
  } catch (err) {
14372
14403
  _iterator0.e(err);
@@ -19722,6 +19753,18 @@ var WidgetCardStatusBar = function WidgetCardStatusBar(_ref) {
19722
19753
  _useState4 = _slicedToArray(_useState3, 2),
19723
19754
  now = _useState4[0],
19724
19755
  setNow = _useState4[1];
19756
+ // Theme tokens + light/dark status colors so the strip follows the
19757
+ // active theme (hardcoded grays rendered dark-only).
19758
+ var _useContext = useContext(ThemeContext),
19759
+ currentTheme = _useContext.currentTheme;
19760
+ var statusTokens = useStatusTokens();
19761
+ var t = function t(key) {
19762
+ return (currentTheme === null || currentTheme === void 0 ? void 0 : currentTheme[key]) || "";
19763
+ };
19764
+ // The strip renders as a sibling below the widget's Panel, so it takes
19765
+ // the Panel's corner radius and sits slightly apart from it rather
19766
+ // than butting a square edge against the rounded card.
19767
+ var panelRadius = getStylesForItem(themeObjects.PANEL, currentTheme, {}).borderRadius || "rounded-lg";
19725
19768
 
19726
19769
  // Check if widget declares scheduledTasks in its config
19727
19770
  var widgetConfig = item !== null && item !== void 0 && item.component ? ComponentManager.config(item.component, item) : null;
@@ -19788,27 +19831,28 @@ var WidgetCardStatusBar = function WidgetCardStatusBar(_ref) {
19788
19831
  summaryText = "".concat(tasks.length, " timers \xB7 next in ").concat(formatCountdown(soonestMs));
19789
19832
  }
19790
19833
  return /*#__PURE__*/jsxs("div", {
19791
- className: "border-t border-gray-700/50 bg-gray-900/30 select-none ".concat(className),
19834
+ className: "mt-1 border ".concat(panelRadius, " overflow-hidden ").concat(t("border-primary-dark"), " ").concat(t("bg-primary-dark"), " select-none ").concat(className),
19792
19835
  children: [/*#__PURE__*/jsxs("button", {
19793
19836
  type: "button",
19794
19837
  onClick: function onClick() {
19795
19838
  return setExpanded(!expanded);
19796
19839
  },
19797
- className: "flex items-center w-full px-3 py-1 text-xs gap-2 cursor-pointer transition-colors hover:bg-gray-800/40 ".concat(allPaused ? "text-gray-500" : "text-blue-400"),
19840
+ className: "flex items-center w-full px-3 py-1 text-xs gap-2 cursor-pointer transition-colors ".concat(t("hover-bg-primary-dark"), " ").concat(allPaused ? "".concat(t("text-primary-medium"), " opacity-60") : t("text-secondary-medium")),
19798
19841
  children: [/*#__PURE__*/jsx(FontAwesomeIcon, {
19799
19842
  icon: "clock",
19800
- className: "text-[10px] shrink-0"
19843
+ className: "text-xs shrink-0"
19801
19844
  }), /*#__PURE__*/jsx("span", {
19802
19845
  className: "truncate flex-1 text-left",
19803
19846
  children: summaryText
19804
19847
  }), /*#__PURE__*/jsx(FontAwesomeIcon, {
19805
19848
  icon: expanded ? "chevron-up" : "chevron-down",
19806
- className: "text-[10px] text-gray-500 shrink-0"
19849
+ className: "text-xs opacity-60 shrink-0"
19807
19850
  })]
19808
19851
  }), expanded && /*#__PURE__*/jsxs("div", {
19809
19852
  className: "px-3 pb-2 pt-1 space-y-2",
19810
- children: [/*#__PURE__*/jsx("div", {
19811
- className: "text-[10px] font-semibold text-gray-400 uppercase tracking-wider",
19853
+ children: [/*#__PURE__*/jsx(Caption2, {
19854
+ block: true,
19855
+ className: "font-semibold uppercase tracking-wider",
19812
19856
  children: "Scheduled Tasks"
19813
19857
  }), tasks.map(function (task) {
19814
19858
  var remaining = task.enabled && task.nextFireAt ? task.nextFireAt - now : null;
@@ -19820,39 +19864,40 @@ var WidgetCardStatusBar = function WidgetCardStatusBar(_ref) {
19820
19864
  children: [/*#__PURE__*/jsxs("div", {
19821
19865
  className: "flex items-center gap-1.5",
19822
19866
  children: [/*#__PURE__*/jsx("span", {
19823
- className: "inline-block w-1.5 h-1.5 rounded-full ".concat(task.enabled ? "bg-green-500" : "bg-gray-600")
19867
+ className: "inline-block w-1.5 h-1.5 rounded-full ".concat(task.enabled ? statusTokens.success.solidBg : t("bg-primary-medium"))
19824
19868
  }), /*#__PURE__*/jsx("span", {
19825
- className: task.enabled ? "text-gray-200" : "text-gray-500",
19869
+ className: "".concat(t("text-primary-medium"), " ").concat(task.enabled ? "" : "opacity-60"),
19826
19870
  children: task.displayName || task.taskKey
19827
- }), !task.enabled && /*#__PURE__*/jsx("span", {
19828
- className: "text-gray-600 text-[10px]",
19871
+ }), !task.enabled && /*#__PURE__*/jsx(Caption2, {
19872
+ className: "opacity-70",
19829
19873
  children: "(paused)"
19830
19874
  })]
19831
- }), /*#__PURE__*/jsx("span", {
19832
- className: "text-gray-500 text-[10px]",
19875
+ }), /*#__PURE__*/jsx(Caption2, {
19833
19876
  children: formatScheduleDescription(task)
19834
19877
  })]
19835
- }), task.enabled && /*#__PURE__*/jsxs("div", {
19836
- className: "text-[10px] text-gray-500 pl-4 flex items-center gap-1.5",
19878
+ }), task.enabled && /*#__PURE__*/jsxs(Caption2, {
19879
+ block: true,
19880
+ className: "pl-4 flex items-center gap-1.5",
19837
19881
  children: [/*#__PURE__*/jsxs("span", {
19838
19882
  children: ["Next in ", formatCountdown(remaining)]
19839
19883
  }), lastFiredText && /*#__PURE__*/jsxs(Fragment, {
19840
19884
  children: [/*#__PURE__*/jsx("span", {
19841
- className: "text-gray-700",
19885
+ className: "opacity-50",
19842
19886
  children: "\xB7"
19843
19887
  }), /*#__PURE__*/jsxs("span", {
19844
19888
  children: ["Last: ", lastFiredText]
19845
19889
  })]
19846
19890
  }), task.fireCount > 0 && /*#__PURE__*/jsxs(Fragment, {
19847
19891
  children: [/*#__PURE__*/jsx("span", {
19848
- className: "text-gray-700",
19892
+ className: "opacity-50",
19849
19893
  children: "\xB7"
19850
19894
  }), /*#__PURE__*/jsxs("span", {
19851
19895
  children: ["#", task.fireCount]
19852
19896
  })]
19853
19897
  })]
19854
- }), !task.enabled && /*#__PURE__*/jsx("div", {
19855
- className: "text-[10px] text-gray-600 pl-4",
19898
+ }), !task.enabled && /*#__PURE__*/jsx(Caption2, {
19899
+ block: true,
19900
+ className: "pl-4 opacity-70",
19856
19901
  children: formatScheduleDescription(task)
19857
19902
  })]
19858
19903
  }, task.taskId);
@@ -48493,6 +48538,443 @@ function SharedFieldRow(_ref6) {
48493
48538
  function _createForOfIteratorHelper$q(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$q(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
48494
48539
  function _unsupportedIterableToArray$q(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$q(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$q(r, a) : void 0; } }
48495
48540
  function _arrayLikeToArray$q(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
48541
+
48542
+ /**
48543
+ * @param {Array<object>} workspaces dashboards (each with id, name, layout/pages)
48544
+ * @param {(component: string) => object|null} getWidgetConfig
48545
+ * @returns {Array<{ workspaceId: string, name: string,
48546
+ * widgets: Array<{ ref: string, instanceId: string, label: string, events: string[] }> }>}
48547
+ * dashboards with at least one event-emitting widget
48548
+ */
48549
+ function buildWidgetEventCatalog(workspaces, getWidgetConfig) {
48550
+ if (!Array.isArray(workspaces)) return [];
48551
+ var out = [];
48552
+ var _iterator = _createForOfIteratorHelper$q(workspaces),
48553
+ _step;
48554
+ try {
48555
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
48556
+ var ws = _step.value;
48557
+ if (!ws || ws.id === undefined || ws.id === null) continue;
48558
+ var widgets = getEmitters(ws, getWidgetConfig).filter(function (e) {
48559
+ return e.itemId != null && e.events.length;
48560
+ }).map(function (e) {
48561
+ return {
48562
+ ref: e.component,
48563
+ instanceId: String(e.itemId),
48564
+ label: e.label || e.component,
48565
+ events: e.events
48566
+ };
48567
+ });
48568
+ if (!widgets.length) continue;
48569
+ out.push({
48570
+ workspaceId: String(ws.id),
48571
+ name: ws.name || "Dashboard ".concat(ws.id),
48572
+ widgets: widgets
48573
+ });
48574
+ }
48575
+ // Dashboards can share a name (e.g. copies of "Kitchen Sink"); number the
48576
+ // duplicates so each picker entry is distinguishable.
48577
+ } catch (err) {
48578
+ _iterator.e(err);
48579
+ } finally {
48580
+ _iterator.f();
48581
+ }
48582
+ var totals = {};
48583
+ for (var _i = 0, _out = out; _i < _out.length; _i++) {
48584
+ var w = _out[_i];
48585
+ totals[w.name] = (totals[w.name] || 0) + 1;
48586
+ }
48587
+ var seen = {};
48588
+ for (var _i2 = 0, _out2 = out; _i2 < _out2.length; _i2++) {
48589
+ var _w = _out2[_i2];
48590
+ if (totals[_w.name] > 1) {
48591
+ seen[_w.name] = (seen[_w.name] || 0) + 1;
48592
+ _w.name = "".concat(_w.name, " (").concat(seen[_w.name], ")");
48593
+ }
48594
+ }
48595
+ return out;
48596
+ }
48597
+
48598
+ /** A subscription to one widget event, picked from the catalog. */
48599
+ function widgetSubscription(workspace, widget, event) {
48600
+ return {
48601
+ eventType: formatEventString(widget.ref, widget.instanceId, event),
48602
+ source: {
48603
+ kind: "widget",
48604
+ ref: widget.ref,
48605
+ instanceId: widget.instanceId,
48606
+ event: event,
48607
+ workspaceId: workspace.workspaceId
48608
+ },
48609
+ label: "".concat(workspace.name, " \u203A ").concat(widget.label, " \u203A ").concat(event)
48610
+ };
48611
+ }
48612
+
48613
+ /**
48614
+ * How to show a saved subscription: its label from the live catalog, and
48615
+ * whether its widget/event is gone (`missing`). Subscriptions saved before
48616
+ * the picker (bare eventType) get a friendly label when they still resolve;
48617
+ * otherwise they show as typed.
48618
+ */
48619
+ function describeSubscription(sub, catalog) {
48620
+ var botCatalog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
48621
+ var eventType = sub && sub.eventType;
48622
+ // Bot subscriptions resolve against the bot catalog; `kind` lets the form
48623
+ // say "bot missing" instead of "widget missing".
48624
+ if (sub && sub.source && sub.source.kind === "bot") {
48625
+ var _iterator2 = _createForOfIteratorHelper$q(botCatalog || []),
48626
+ _step2;
48627
+ try {
48628
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
48629
+ var b = _step2.value;
48630
+ var _iterator3 = _createForOfIteratorHelper$q(b.events),
48631
+ _step3;
48632
+ try {
48633
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
48634
+ var ev = _step3.value;
48635
+ var s = botSubscription(b, ev);
48636
+ if (s.eventType === eventType) {
48637
+ return {
48638
+ label: s.label,
48639
+ missing: false,
48640
+ kind: "bot"
48641
+ };
48642
+ }
48643
+ }
48644
+ } catch (err) {
48645
+ _iterator3.e(err);
48646
+ } finally {
48647
+ _iterator3.f();
48648
+ }
48649
+ }
48650
+ } catch (err) {
48651
+ _iterator2.e(err);
48652
+ } finally {
48653
+ _iterator2.f();
48654
+ }
48655
+ return {
48656
+ label: sub.label || eventType,
48657
+ missing: true,
48658
+ kind: "bot"
48659
+ };
48660
+ }
48661
+ var _iterator4 = _createForOfIteratorHelper$q(catalog || []),
48662
+ _step4;
48663
+ try {
48664
+ for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
48665
+ var ws = _step4.value;
48666
+ var _iterator5 = _createForOfIteratorHelper$q(ws.widgets),
48667
+ _step5;
48668
+ try {
48669
+ for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
48670
+ var w = _step5.value;
48671
+ var _iterator6 = _createForOfIteratorHelper$q(w.events),
48672
+ _step6;
48673
+ try {
48674
+ for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
48675
+ var _ev = _step6.value;
48676
+ if (formatEventString(w.ref, w.instanceId, _ev) === eventType) {
48677
+ return {
48678
+ label: widgetSubscription(ws, w, _ev).label,
48679
+ missing: false
48680
+ };
48681
+ }
48682
+ }
48683
+ } catch (err) {
48684
+ _iterator6.e(err);
48685
+ } finally {
48686
+ _iterator6.f();
48687
+ }
48688
+ }
48689
+ } catch (err) {
48690
+ _iterator5.e(err);
48691
+ } finally {
48692
+ _iterator5.f();
48693
+ }
48694
+ }
48695
+ } catch (err) {
48696
+ _iterator4.e(err);
48697
+ } finally {
48698
+ _iterator4.f();
48699
+ }
48700
+ if (sub && sub.source) {
48701
+ return {
48702
+ label: sub.label || eventType,
48703
+ missing: true
48704
+ };
48705
+ }
48706
+ return {
48707
+ label: eventType || "",
48708
+ missing: false
48709
+ };
48710
+ }
48711
+
48712
+ /**
48713
+ * Events other bots publish (bot:<ref>[<botId>].<event>, PRD US-010), for the
48714
+ * "Another bot" side of the picker. Derived from each bot's settings — never
48715
+ * hand-declared: Completed, Failed, and one `tool.<providerType>.<tool>` per
48716
+ * tool the bot may use (the provider's tools, narrowed by the bot's
48717
+ * selection). Providers with no known type or tool list are skipped.
48718
+ *
48719
+ * @param {Array<object>} bots
48720
+ * @param {Array<{name, type, tools}>} toolSources bots.listToolSources()
48721
+ * @param {string} [excludeBotId] the bot being edited — can't trigger itself
48722
+ */
48723
+ function buildBotEventCatalog(bots, toolSources) {
48724
+ var excludeBotId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
48725
+ if (!Array.isArray(bots)) return [];
48726
+ var sources = Array.isArray(toolSources) ? toolSources : [];
48727
+ var out = [];
48728
+ var _iterator7 = _createForOfIteratorHelper$q(bots),
48729
+ _step7;
48730
+ try {
48731
+ for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
48732
+ var bot = _step7.value;
48733
+ if (!bot || !bot.id || !bot.ref || bot.id === excludeBotId) continue;
48734
+ var events = [{
48735
+ event: "completed",
48736
+ label: "Completed"
48737
+ }, {
48738
+ event: "failed",
48739
+ label: "Failed"
48740
+ }];
48741
+ var _iterator8 = _createForOfIteratorHelper$q(bot.mcpServers || []),
48742
+ _step8;
48743
+ try {
48744
+ var _loop = function _loop() {
48745
+ var provider = _step8.value;
48746
+ var src = sources.find(function (s) {
48747
+ return s && s.name === provider;
48748
+ });
48749
+ if (!src || !src.type || !Array.isArray(src.tools)) return 1; // continue
48750
+ var sel = bot.toolSelections && bot.toolSelections[provider];
48751
+ var tools = Array.isArray(sel) ? src.tools.filter(function (t) {
48752
+ return sel.includes(t);
48753
+ }) : src.tools;
48754
+ var _iterator9 = _createForOfIteratorHelper$q(tools),
48755
+ _step9;
48756
+ try {
48757
+ for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
48758
+ var tool = _step9.value;
48759
+ events.push({
48760
+ event: "tool.".concat(src.type, ".").concat(tool),
48761
+ label: "".concat(provider, " \u203A ").concat(tool)
48762
+ });
48763
+ }
48764
+ } catch (err) {
48765
+ _iterator9.e(err);
48766
+ } finally {
48767
+ _iterator9.f();
48768
+ }
48769
+ };
48770
+ for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
48771
+ if (_loop()) continue;
48772
+ }
48773
+ } catch (err) {
48774
+ _iterator8.e(err);
48775
+ } finally {
48776
+ _iterator8.f();
48777
+ }
48778
+ out.push({
48779
+ botId: bot.id,
48780
+ ref: bot.ref,
48781
+ name: bot.name || bot.id,
48782
+ events: events
48783
+ });
48784
+ }
48785
+ } catch (err) {
48786
+ _iterator7.e(err);
48787
+ } finally {
48788
+ _iterator7.f();
48789
+ }
48790
+ return out;
48791
+ }
48792
+
48793
+ /** A subscription to one bot event, picked from the bot catalog. */
48794
+ function botSubscription(botEntry, ev) {
48795
+ return {
48796
+ eventType: "bot:".concat(botEntry.ref, "[").concat(botEntry.botId, "].").concat(ev.event),
48797
+ source: {
48798
+ kind: "bot",
48799
+ ref: botEntry.ref,
48800
+ instanceId: botEntry.botId,
48801
+ event: ev.event
48802
+ },
48803
+ label: "".concat(botEntry.name, " \u203A ").concat(ev.label)
48804
+ };
48805
+ }
48806
+ function botEventLabel(ev) {
48807
+ if (!ev.event.startsWith("tool.")) return ev.label;
48808
+ // Tool events are labelled "<provider> › <tool>" in the catalog.
48809
+ var _String$split = String(ev.label).split(" › "),
48810
+ _String$split2 = _slicedToArray(_String$split, 2),
48811
+ provider = _String$split2[0],
48812
+ tool = _String$split2[1];
48813
+ return tool ? "uses ".concat(tool, " (").concat(provider, ")") : ev.label;
48814
+ }
48815
+
48816
+ /**
48817
+ * Everything that can trigger a bot, flattened for one "Runs when…" picker
48818
+ * (bot-teams TEAM-012): `{ value, label, group, subscription }`, value = the
48819
+ * subscription's eventType.
48820
+ *
48821
+ * A team bot only runs on its own dashboard's events, so it's offered that
48822
+ * dashboard's widgets ("Widgets on <dashboard>") and its teammates ("Bots on
48823
+ * this team"). An unassigned bot is offered every dashboard's widgets and
48824
+ * every bot ("Bots", labelled with their dashboard). The bot itself and
48825
+ * triggers it already has are left out; two copies of one widget are
48826
+ * numbered.
48827
+ *
48828
+ * @param {{ team: string|null, workspaces: object[], getWidgetConfig: Function,
48829
+ * bots: object[], toolSources: object[], botId?: string,
48830
+ * existing?: string[] }} input
48831
+ */
48832
+ function buildTriggerOptions(_ref) {
48833
+ var _ref$team = _ref.team,
48834
+ team = _ref$team === void 0 ? null : _ref$team,
48835
+ _ref$workspaces = _ref.workspaces,
48836
+ workspaces = _ref$workspaces === void 0 ? [] : _ref$workspaces,
48837
+ _ref$getWidgetConfig = _ref.getWidgetConfig,
48838
+ getWidgetConfig = _ref$getWidgetConfig === void 0 ? null : _ref$getWidgetConfig,
48839
+ _ref$bots = _ref.bots,
48840
+ bots = _ref$bots === void 0 ? [] : _ref$bots,
48841
+ _ref$toolSources = _ref.toolSources,
48842
+ toolSources = _ref$toolSources === void 0 ? [] : _ref$toolSources,
48843
+ _ref$botId = _ref.botId,
48844
+ botId = _ref$botId === void 0 ? null : _ref$botId,
48845
+ _ref$existing = _ref.existing,
48846
+ existing = _ref$existing === void 0 ? [] : _ref$existing;
48847
+ var teamKey = team === null || team === undefined || team === "" ? null : String(team);
48848
+ var taken = new Set(existing || []);
48849
+ var out = [];
48850
+
48851
+ // Widgets.
48852
+ var wsList = (Array.isArray(workspaces) ? workspaces : []).filter(function (ws) {
48853
+ return ws && (teamKey === null || String(ws.id) === teamKey);
48854
+ });
48855
+ var _iterator0 = _createForOfIteratorHelper$q(buildWidgetEventCatalog(wsList, getWidgetConfig)),
48856
+ _step0;
48857
+ try {
48858
+ for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
48859
+ var ws = _step0.value;
48860
+ var group = "Widgets on ".concat(ws.name);
48861
+ var seen = {};
48862
+ var _iterator10 = _createForOfIteratorHelper$q(ws.widgets),
48863
+ _step10;
48864
+ try {
48865
+ for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
48866
+ var widget = _step10.value;
48867
+ seen[widget.label] = (seen[widget.label] || 0) + 1;
48868
+ var name = seen[widget.label] > 1 ? "".concat(widget.label, " (").concat(seen[widget.label], ")") : widget.label;
48869
+ var _iterator11 = _createForOfIteratorHelper$q(widget.events),
48870
+ _step11;
48871
+ try {
48872
+ for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
48873
+ var event = _step11.value;
48874
+ var subscription = widgetSubscription(ws, widget, event);
48875
+ if (taken.has(subscription.eventType)) continue;
48876
+ out.push({
48877
+ value: subscription.eventType,
48878
+ label: "".concat(name, " \u203A ").concat(event),
48879
+ group: group,
48880
+ subscription: subscription
48881
+ });
48882
+ }
48883
+ } catch (err) {
48884
+ _iterator11.e(err);
48885
+ } finally {
48886
+ _iterator11.f();
48887
+ }
48888
+ }
48889
+ } catch (err) {
48890
+ _iterator10.e(err);
48891
+ } finally {
48892
+ _iterator10.f();
48893
+ }
48894
+ }
48895
+
48896
+ // Bots.
48897
+ } catch (err) {
48898
+ _iterator0.e(err);
48899
+ } finally {
48900
+ _iterator0.f();
48901
+ }
48902
+ var nameOfWs = new Map((Array.isArray(workspaces) ? workspaces : []).filter(Boolean).map(function (ws) {
48903
+ return [String(ws.id), ws.name || "Dashboard ".concat(ws.id)];
48904
+ }));
48905
+ var candidates = (Array.isArray(bots) ? bots : []).filter(function (b) {
48906
+ return b && (teamKey === null || b.workspaceId !== null && b.workspaceId !== undefined && String(b.workspaceId) === teamKey);
48907
+ });
48908
+ var wsOf = new Map(candidates.map(function (b) {
48909
+ return [b.id, b.workspaceId];
48910
+ }));
48911
+ var _iterator1 = _createForOfIteratorHelper$q(buildBotEventCatalog(candidates, toolSources, botId)),
48912
+ _step1;
48913
+ try {
48914
+ for (_iterator1.s(); !(_step1 = _iterator1.n()).done;) {
48915
+ var entry = _step1.value;
48916
+ var where = teamKey === null && wsOf.get(entry.botId) !== null && wsOf.get(entry.botId) !== undefined ? " (".concat(nameOfWs.get(String(wsOf.get(entry.botId))) || "another dashboard", ")") : "";
48917
+ var _iterator12 = _createForOfIteratorHelper$q(entry.events),
48918
+ _step12;
48919
+ try {
48920
+ for (_iterator12.s(); !(_step12 = _iterator12.n()).done;) {
48921
+ var ev = _step12.value;
48922
+ var _subscription = botSubscription(entry, ev);
48923
+ if (taken.has(_subscription.eventType)) continue;
48924
+ out.push({
48925
+ value: _subscription.eventType,
48926
+ label: "".concat(entry.name).concat(where, " \u203A ").concat(botEventLabel(ev)),
48927
+ group: teamKey === null ? "Bots" : "Bots on this team",
48928
+ subscription: _subscription
48929
+ });
48930
+ }
48931
+ } catch (err) {
48932
+ _iterator12.e(err);
48933
+ } finally {
48934
+ _iterator12.f();
48935
+ }
48936
+ }
48937
+ } catch (err) {
48938
+ _iterator1.e(err);
48939
+ } finally {
48940
+ _iterator1.f();
48941
+ }
48942
+ return out;
48943
+ }
48944
+
48945
+ /**
48946
+ * A dashboard's bots as Dashboard Config › Listeners sources (bot-teams
48947
+ * TEAM-012), shaped like getEmitters() entries: component `bot:<ref>`,
48948
+ * itemId = bot id, so a wired handler stores `bot:<ref>[<botId>].<event>` —
48949
+ * exactly what bots publish on the bus.
48950
+ *
48951
+ * @param {object[]} bots
48952
+ * @param {object[]} toolSources bots.listToolSources()
48953
+ * @param {string|number} workspaceId
48954
+ */
48955
+ function getBotEmitters(bots, toolSources, workspaceId) {
48956
+ if (workspaceId === null || workspaceId === undefined || workspaceId === "") {
48957
+ return [];
48958
+ }
48959
+ var team = (Array.isArray(bots) ? bots : []).filter(function (b) {
48960
+ return b && b.workspaceId !== null && b.workspaceId !== undefined && String(b.workspaceId) === String(workspaceId);
48961
+ });
48962
+ return buildBotEventCatalog(team, toolSources).map(function (entry) {
48963
+ return {
48964
+ key: "bot:".concat(entry.ref, "|").concat(entry.botId),
48965
+ component: "bot:".concat(entry.ref),
48966
+ itemId: entry.botId,
48967
+ label: "".concat(entry.name, " (bot)"),
48968
+ events: entry.events.map(function (e) {
48969
+ return e.event;
48970
+ })
48971
+ };
48972
+ });
48973
+ }
48974
+
48975
+ function _createForOfIteratorHelper$p(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$p(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
48976
+ function _unsupportedIterableToArray$p(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$p(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$p(r, a) : void 0; } }
48977
+ function _arrayLikeToArray$p(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
48496
48978
  var PermissionsTab = function PermissionsTab(_ref) {
48497
48979
  var workspace = _ref.workspace;
48498
48980
  var _React$useContext = React__default.useContext(AppContext),
@@ -48719,7 +49201,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48719
49201
  return _context4.abrupt("return");
48720
49202
  case 3:
48721
49203
  next = currentGrant;
48722
- _iterator = _createForOfIteratorHelper$q(declaredTools);
49204
+ _iterator = _createForOfIteratorHelper$p(declaredTools);
48723
49205
  try {
48724
49206
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
48725
49207
  tool = _step.value;
@@ -48879,7 +49361,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48879
49361
  }
48880
49362
  }
48881
49363
  targets = labels.length > 0 ? labels : [serverName];
48882
- _iterator2 = _createForOfIteratorHelper$q(targets);
49364
+ _iterator2 = _createForOfIteratorHelper$p(targets);
48883
49365
  _context8.prev = 1;
48884
49366
  _iterator2.s();
48885
49367
  case 2:
@@ -48935,7 +49417,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48935
49417
  case 0:
48936
49418
  setBusy(true);
48937
49419
  _context9.prev = 1;
48938
- _iterator3 = _createForOfIteratorHelper$q(filteredRows);
49420
+ _iterator3 = _createForOfIteratorHelper$p(filteredRows);
48939
49421
  _context9.prev = 2;
48940
49422
  _iterator3.s();
48941
49423
  case 3:
@@ -48994,7 +49476,7 @@ var PermissionsTab = function PermissionsTab(_ref) {
48994
49476
  case 0:
48995
49477
  setBusy(true);
48996
49478
  _context0.prev = 1;
48997
- _iterator4 = _createForOfIteratorHelper$q(filteredRows);
49479
+ _iterator4 = _createForOfIteratorHelper$p(filteredRows);
48998
49480
  _context0.prev = 2;
48999
49481
  _iterator4.s();
49000
49482
  case 3:
@@ -49154,9 +49636,9 @@ var PermissionsTab = function PermissionsTab(_ref) {
49154
49636
  });
49155
49637
  };
49156
49638
 
49157
- function _createForOfIteratorHelper$p(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$p(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49158
- function _unsupportedIterableToArray$p(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$p(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$p(r, a) : void 0; } }
49159
- function _arrayLikeToArray$p(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
49639
+ function _createForOfIteratorHelper$o(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$o(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49640
+ function _unsupportedIterableToArray$o(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$o(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$o(r, a) : void 0; } }
49641
+ function _arrayLikeToArray$o(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
49160
49642
  /**
49161
49643
  * teamUtils.js
49162
49644
  *
@@ -49189,7 +49671,7 @@ function dashboardOptions(workspaces) {
49189
49671
  return w && norm(w.id) !== null;
49190
49672
  });
49191
49673
  var totals = {};
49192
- var _iterator = _createForOfIteratorHelper$p(list),
49674
+ var _iterator = _createForOfIteratorHelper$o(list),
49193
49675
  _step;
49194
49676
  try {
49195
49677
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -49236,7 +49718,7 @@ function groupBotsByTeam(bots, workspaces) {
49236
49718
  label: "Unassigned",
49237
49719
  bots: []
49238
49720
  };
49239
- var _iterator2 = _createForOfIteratorHelper$p(list),
49721
+ var _iterator2 = _createForOfIteratorHelper$o(list),
49240
49722
  _step2;
49241
49723
  try {
49242
49724
  var _loop = function _loop() {
@@ -49977,9 +50459,9 @@ var BotsTab = function BotsTab(_ref2) {
49977
50459
  });
49978
50460
  };
49979
50461
 
49980
- function _createForOfIteratorHelper$o(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$o(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
49981
- function _unsupportedIterableToArray$o(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$o(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$o(r, a) : void 0; } }
49982
- function _arrayLikeToArray$o(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
50462
+ function _createForOfIteratorHelper$n(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$n(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
50463
+ function _unsupportedIterableToArray$n(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$n(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$n(r, a) : void 0; } }
50464
+ function _arrayLikeToArray$n(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
49983
50465
  function ownKeys$A(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
49984
50466
  function _objectSpread$A(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$A(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$A(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
49985
50467
  var ConfigTab = function ConfigTab(_ref) {
@@ -50138,7 +50620,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50138
50620
  };
50139
50621
  if (!appProviders) return byType;
50140
50622
  if (Array.isArray(appProviders)) {
50141
- var _iterator = _createForOfIteratorHelper$o(appProviders),
50623
+ var _iterator = _createForOfIteratorHelper$n(appProviders),
50142
50624
  _step;
50143
50625
  try {
50144
50626
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
@@ -50204,7 +50686,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50204
50686
  });
50205
50687
  }
50206
50688
  if (Array.isArray(workspace === null || workspace === void 0 ? void 0 : workspace.pages)) {
50207
- var _iterator2 = _createForOfIteratorHelper$o(workspace.pages),
50689
+ var _iterator2 = _createForOfIteratorHelper$n(workspace.pages),
50208
50690
  _step2;
50209
50691
  try {
50210
50692
  for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
@@ -50231,7 +50713,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50231
50713
  var visitedByLocation = new WeakSet();
50232
50714
  var _collect = function collect(items, location) {
50233
50715
  if (!Array.isArray(items)) return;
50234
- var _iterator3 = _createForOfIteratorHelper$o(items),
50716
+ var _iterator3 = _createForOfIteratorHelper$n(items),
50235
50717
  _step3;
50236
50718
  try {
50237
50719
  for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
@@ -50302,9 +50784,33 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50302
50784
  return null;
50303
50785
  };
50304
50786
  }, [getWidgetConfig]);
50787
+ // This dashboard's bots as Listeners sources (TEAM-012); null until
50788
+ // loaded so their wiring isn't judged before the bots are known.
50789
+ var _useState9 = useState(null),
50790
+ _useState0 = _slicedToArray(_useState9, 2),
50791
+ botEmitters = _useState0[0],
50792
+ setBotEmitters = _useState0[1];
50793
+ var workspaceId = workspace ? workspace.id : null;
50794
+ useEffect(function () {
50795
+ var _window$mainApi;
50796
+ var bots = typeof window !== "undefined" && ((_window$mainApi = window.mainApi) === null || _window$mainApi === void 0 ? void 0 : _window$mainApi.bots);
50797
+ if (!isOpen || !bots || !bots.list || workspaceId == null) return undefined;
50798
+ var alive = true;
50799
+ Promise.all([bots.list(), bots.listToolSources ? bots.listToolSources() : Promise.resolve([])]).then(function (_ref5) {
50800
+ var _ref6 = _slicedToArray(_ref5, 2),
50801
+ list = _ref6[0],
50802
+ sources = _ref6[1];
50803
+ if (alive) setBotEmitters(getBotEmitters(list, sources, workspaceId));
50804
+ })["catch"](function () {
50805
+ if (alive) setBotEmitters([]);
50806
+ });
50807
+ return function () {
50808
+ alive = false;
50809
+ };
50810
+ }, [isOpen, workspaceId]);
50305
50811
  var emitters = useMemo(function () {
50306
- return getEmitters(workspace, wConfig);
50307
- }, [workspace, wConfig]);
50812
+ return [].concat(_toConsumableArray(getEmitters(workspace, wConfig)), _toConsumableArray(botEmitters || []));
50813
+ }, [workspace, wConfig, botEmitters]);
50308
50814
  var receivers = useMemo(function () {
50309
50815
  return getReceivers(workspace, wConfig);
50310
50816
  }, [workspace, wConfig]);
@@ -50312,8 +50818,8 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50312
50818
  return getCurrentWiring(workspace);
50313
50819
  }, [workspace]);
50314
50820
  var orphans = useMemo(function () {
50315
- return getOrphanedListeners(workspace, wConfig);
50316
- }, [workspace, wConfig]);
50821
+ return getOrphanedListeners(workspace, wConfig, botEmitters);
50822
+ }, [workspace, wConfig, botEmitters]);
50317
50823
  var effectiveWiring = useMemo(function () {
50318
50824
  // Apply staged removes/adds to the persisted wiring for an
50319
50825
  // accurate "what will be there after save" view, then annotate
@@ -50329,7 +50835,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50329
50835
  }
50330
50836
  if (stagedListeners.adds.length > 0) {
50331
50837
  // Append; avoid duplicates against current state.
50332
- var _iterator4 = _createForOfIteratorHelper$o(stagedListeners.adds),
50838
+ var _iterator4 = _createForOfIteratorHelper$n(stagedListeners.adds),
50333
50839
  _step4;
50334
50840
  try {
50335
50841
  var _loop = function _loop() {
@@ -50353,7 +50859,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50353
50859
  }
50354
50860
  if (orphans.length === 0) return next;
50355
50861
  var orphanIndex = new Map();
50356
- var _iterator5 = _createForOfIteratorHelper$o(orphans),
50862
+ var _iterator5 = _createForOfIteratorHelper$n(orphans),
50357
50863
  _step5;
50358
50864
  try {
50359
50865
  for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
@@ -50395,7 +50901,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50395
50901
  function stagePrefFieldForAll(targetWidgets, key, value) {
50396
50902
  setStagedPrefs(function (prev) {
50397
50903
  var next = _objectSpread$A({}, prev);
50398
- var _iterator6 = _createForOfIteratorHelper$o(targetWidgets),
50904
+ var _iterator6 = _createForOfIteratorHelper$n(targetWidgets),
50399
50905
  _step6;
50400
50906
  try {
50401
50907
  for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
@@ -50440,7 +50946,7 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50440
50946
  });
50441
50947
  setStaged(function (prev) {
50442
50948
  var next = _objectSpread$A({}, prev);
50443
- var _iterator7 = _createForOfIteratorHelper$o(affected),
50949
+ var _iterator7 = _createForOfIteratorHelper$n(affected),
50444
50950
  _step7;
50445
50951
  try {
50446
50952
  for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
@@ -50741,29 +51247,29 @@ var DashboardConfigModal = function DashboardConfigModal(_ref2) {
50741
51247
  * write fails the user can re-toggle. No staging — the bulk modal
50742
51248
  * doesn't gate the user behind a Save button for boolean prefs.
50743
51249
  */
50744
- function NotificationsTab(_ref5) {
50745
- var workspace = _ref5.workspace;
51250
+ function NotificationsTab(_ref7) {
51251
+ var workspace = _ref7.workspace;
50746
51252
  var _useConfigTokens3 = useConfigTokens(),
50747
51253
  muted = _useConfigTokens3.muted,
50748
51254
  hairline = _useConfigTokens3.hairline;
50749
- var _useState9 = useState(""),
50750
- _useState0 = _slicedToArray(_useState9, 2),
50751
- searchQuery = _useState0[0],
50752
- setSearchQuery = _useState0[1];
51255
+ var _useState1 = useState(""),
51256
+ _useState10 = _slicedToArray(_useState1, 2),
51257
+ searchQuery = _useState10[0],
51258
+ setSearchQuery = _useState10[1];
50753
51259
  // Local mirror of widgetUuid -> { typeKey: bool }. Seeded from the
50754
51260
  // main process on mount; updated optimistically on toggle.
50755
- var _useState1 = useState({}),
50756
- _useState10 = _slicedToArray(_useState1, 2),
50757
- prefs = _useState10[0],
50758
- setPrefs = _useState10[1];
50759
- var _useState11 = useState(false),
51261
+ var _useState11 = useState({}),
50760
51262
  _useState12 = _slicedToArray(_useState11, 2),
50761
- loaded = _useState12[0],
50762
- setLoaded = _useState12[1];
51263
+ prefs = _useState12[0],
51264
+ setPrefs = _useState12[1];
51265
+ var _useState13 = useState(false),
51266
+ _useState14 = _slicedToArray(_useState13, 2),
51267
+ loaded = _useState14[0],
51268
+ setLoaded = _useState14[1];
50763
51269
  React__default.useEffect(function () {
50764
- var _window$mainApi;
51270
+ var _window$mainApi2;
50765
51271
  var cancelled = false;
50766
- if (!((_window$mainApi = window.mainApi) !== null && _window$mainApi !== void 0 && (_window$mainApi = _window$mainApi.notifications) !== null && _window$mainApi !== void 0 && _window$mainApi.getPreferences)) {
51272
+ if (!((_window$mainApi2 = window.mainApi) !== null && _window$mainApi2 !== void 0 && (_window$mainApi2 = _window$mainApi2.notifications) !== null && _window$mainApi2 !== void 0 && _window$mainApi2.getPreferences)) {
50767
51273
  setLoaded(true);
50768
51274
  return function () {
50769
51275
  cancelled = true;
@@ -50857,11 +51363,11 @@ function NotificationsTab(_ref5) {
50857
51363
  return !!defaultEnabled;
50858
51364
  };
50859
51365
  var setOne = function setOne(uuid, typeKey, value) {
50860
- var _window$mainApi2;
51366
+ var _window$mainApi3;
50861
51367
  setPrefs(function (prev) {
50862
51368
  return _objectSpread$A(_objectSpread$A({}, prev), {}, _defineProperty({}, uuid, _objectSpread$A(_objectSpread$A({}, prev[uuid] || {}), {}, _defineProperty({}, typeKey, value))));
50863
51369
  });
50864
- (_window$mainApi2 = window.mainApi) === null || _window$mainApi2 === void 0 || (_window$mainApi2 = _window$mainApi2.notifications) === null || _window$mainApi2 === void 0 || _window$mainApi2.setPreferences(uuid, _defineProperty({}, typeKey, value));
51370
+ (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || _window$mainApi3.setPreferences(uuid, _defineProperty({}, typeKey, value));
50865
51371
  };
50866
51372
  var setAllVisible = function setAllVisible(value) {
50867
51373
  // Update local state in one pass + fire one IPC per widget.
@@ -50877,12 +51383,12 @@ function NotificationsTab(_ref5) {
50877
51383
  return next;
50878
51384
  });
50879
51385
  filtered.forEach(function (wi) {
50880
- var _window$mainApi3;
51386
+ var _window$mainApi4;
50881
51387
  var update = {};
50882
51388
  wi.notifications.forEach(function (n) {
50883
51389
  update[n.key] = value;
50884
51390
  });
50885
- (_window$mainApi3 = window.mainApi) === null || _window$mainApi3 === void 0 || (_window$mainApi3 = _window$mainApi3.notifications) === null || _window$mainApi3 === void 0 || _window$mainApi3.setPreferences(wi.uuid, update);
51391
+ (_window$mainApi4 = window.mainApi) === null || _window$mainApi4 === void 0 || (_window$mainApi4 = _window$mainApi4.notifications) === null || _window$mainApi4 === void 0 || _window$mainApi4.setPreferences(wi.uuid, update);
50886
51392
  });
50887
51393
  };
50888
51394
  if (!loaded) {
@@ -50986,12 +51492,12 @@ function NotificationsTab(_ref5) {
50986
51492
  * dot per-type when any widget of that type is unresolved). Column 2
50987
51493
  * shows the selected type's bulk dropdown + per-widget dropdowns.
50988
51494
  */
50989
- function ProvidersTab(_ref6) {
51495
+ function ProvidersTab(_ref8) {
50990
51496
  var _typeEntries$, _selectedRows$;
50991
- var grouped = _ref6.grouped,
50992
- providersByType = _ref6.providersByType,
50993
- onBulk = _ref6.onBulk,
50994
- onPerWidget = _ref6.onPerWidget;
51497
+ var grouped = _ref8.grouped,
51498
+ providersByType = _ref8.providersByType,
51499
+ onBulk = _ref8.onBulk,
51500
+ onPerWidget = _ref8.onPerWidget;
50995
51501
  var _useConfigTokens4 = useConfigTokens(),
50996
51502
  muted = _useConfigTokens4.muted,
50997
51503
  hairline = _useConfigTokens4.hairline,
@@ -50999,10 +51505,10 @@ function ProvidersTab(_ref6) {
50999
51505
  var typeEntries = useMemo(function () {
51000
51506
  return Array.from(grouped.entries());
51001
51507
  }, [grouped]);
51002
- var _useState13 = useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
51003
- _useState14 = _slicedToArray(_useState13, 2),
51004
- selectedType = _useState14[0],
51005
- setSelectedType = _useState14[1];
51508
+ var _useState15 = useState(((_typeEntries$ = typeEntries[0]) === null || _typeEntries$ === void 0 ? void 0 : _typeEntries$[0]) || null),
51509
+ _useState16 = _slicedToArray(_useState15, 2),
51510
+ selectedType = _useState16[0],
51511
+ setSelectedType = _useState16[1];
51006
51512
 
51007
51513
  // If the selected type disappears (workspace changed), fall back.
51008
51514
  useMemo(function () {
@@ -51032,10 +51538,10 @@ function ProvidersTab(_ref6) {
51032
51538
  children: "Provider Types"
51033
51539
  }), /*#__PURE__*/jsx("div", {
51034
51540
  className: "overflow-y-auto flex-1 flex flex-col gap-1",
51035
- children: typeEntries.map(function (_ref7) {
51036
- var _ref8 = _slicedToArray(_ref7, 2),
51037
- providerType = _ref8[0],
51038
- rows = _ref8[1];
51541
+ children: typeEntries.map(function (_ref9) {
51542
+ var _ref0 = _slicedToArray(_ref9, 2),
51543
+ providerType = _ref0[0],
51544
+ rows = _ref0[1];
51039
51545
  var unresolvedHere = rows.filter(function (r) {
51040
51546
  return r.required && !r.resolvedProviderName;
51041
51547
  }).length;
@@ -51178,8 +51684,8 @@ function ProvidersTab(_ref6) {
51178
51684
  * package (no `config.id` / `config.package` / item.workspace hint).
51179
51685
  * Usually this is a stale layout item whose widget got uninstalled.
51180
51686
  */
51181
- function DependenciesTab(_ref0) {
51182
- var dependencies = _ref0.dependencies;
51687
+ function DependenciesTab(_ref10) {
51688
+ var dependencies = _ref10.dependencies;
51183
51689
  var _useConfigTokens5 = useConfigTokens(),
51184
51690
  muted = _useConfigTokens5.muted,
51185
51691
  hairline = _useConfigTokens5.hairline;
@@ -51256,24 +51762,24 @@ function sameWiringEntry(a, b) {
51256
51762
  * adjusts wiring per handler from a single dropdown of all emitters'
51257
51763
  * (widget × event) pairs.
51258
51764
  */
51259
- function ListenersTab(_ref1) {
51765
+ function ListenersTab(_ref11) {
51260
51766
  var _receivers$;
51261
- var emitters = _ref1.emitters,
51262
- receivers = _ref1.receivers,
51263
- wiring = _ref1.wiring,
51264
- onAdd = _ref1.onAdd,
51265
- onRemove = _ref1.onRemove;
51767
+ var emitters = _ref11.emitters,
51768
+ receivers = _ref11.receivers,
51769
+ wiring = _ref11.wiring,
51770
+ onAdd = _ref11.onAdd,
51771
+ onRemove = _ref11.onRemove;
51266
51772
  var _useConfigTokens6 = useConfigTokens(),
51267
51773
  muted = _useConfigTokens6.muted,
51268
51774
  hairline = _useConfigTokens6.hairline;
51269
- var _useState17 = useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
51270
- _useState18 = _slicedToArray(_useState17, 2),
51271
- selectedReceiverKey = _useState18[0],
51272
- setSelectedReceiverKey = _useState18[1];
51273
- var _useState19 = useState(null),
51775
+ var _useState19 = useState(((_receivers$ = receivers[0]) === null || _receivers$ === void 0 ? void 0 : _receivers$.key) || null),
51274
51776
  _useState20 = _slicedToArray(_useState19, 2),
51275
- selectedHandler = _useState20[0],
51276
- setSelectedHandler = _useState20[1];
51777
+ selectedReceiverKey = _useState20[0],
51778
+ setSelectedReceiverKey = _useState20[1];
51779
+ var _useState21 = useState(null),
51780
+ _useState22 = _slicedToArray(_useState21, 2),
51781
+ selectedHandler = _useState22[0],
51782
+ setSelectedHandler = _useState22[1];
51277
51783
 
51278
51784
  // Re-anchor selection if the previously-selected widget disappeared
51279
51785
  // (workspace switched, widget deleted, etc.).
@@ -51289,7 +51795,7 @@ function ListenersTab(_ref1) {
51289
51795
  // Receiver lookup (by composite key) for label resolution in chips.
51290
51796
  var receiverByKey = useMemo(function () {
51291
51797
  var m = new Map();
51292
- var _iterator8 = _createForOfIteratorHelper$o(receivers),
51798
+ var _iterator8 = _createForOfIteratorHelper$n(receivers),
51293
51799
  _step8;
51294
51800
  try {
51295
51801
  for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
@@ -51372,14 +51878,14 @@ function ListenersTab(_ref1) {
51372
51878
  * third column. Matches the left-column look from
51373
51879
  * PanelEditItemHandlers.
51374
51880
  */
51375
- function HandlersColumn(_ref11) {
51376
- var receiver = _ref11.receiver,
51377
- myWiring = _ref11.myWiring,
51378
- selectedHandler = _ref11.selectedHandler,
51379
- onSelectHandler = _ref11.onSelectHandler;
51881
+ function HandlersColumn(_ref13) {
51882
+ var receiver = _ref13.receiver,
51883
+ myWiring = _ref13.myWiring,
51884
+ selectedHandler = _ref13.selectedHandler,
51885
+ onSelectHandler = _ref13.onSelectHandler;
51380
51886
  var countsByHandler = useMemo(function () {
51381
51887
  var m = new Map();
51382
- var _iterator9 = _createForOfIteratorHelper$o(myWiring),
51888
+ var _iterator9 = _createForOfIteratorHelper$n(myWiring),
51383
51889
  _step9;
51384
51890
  try {
51385
51891
  for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
@@ -51441,13 +51947,13 @@ function HandlersColumn(_ref11) {
51441
51947
  * Checked = wired; toggling commits an add/remove. Mirrors the
51442
51948
  * right-column UX of PanelEditItemHandlers.
51443
51949
  */
51444
- function EventsColumn(_ref12) {
51445
- var receiver = _ref12.receiver,
51446
- handlerName = _ref12.handlerName,
51447
- myWiring = _ref12.myWiring,
51448
- emitters = _ref12.emitters,
51449
- onAdd = _ref12.onAdd,
51450
- onRemove = _ref12.onRemove;
51950
+ function EventsColumn(_ref14) {
51951
+ var receiver = _ref14.receiver,
51952
+ handlerName = _ref14.handlerName,
51953
+ myWiring = _ref14.myWiring,
51954
+ emitters = _ref14.emitters,
51955
+ onAdd = _ref14.onAdd,
51956
+ onRemove = _ref14.onRemove;
51451
51957
  var _useConfigTokens8 = useConfigTokens(),
51452
51958
  muted = _useConfigTokens8.muted,
51453
51959
  hairline = _useConfigTokens8.hairline;
@@ -51456,7 +51962,7 @@ function EventsColumn(_ref12) {
51456
51962
  var wiredHere = useMemo(function () {
51457
51963
  var seen = new Set();
51458
51964
  var out = [];
51459
- var _iterator0 = _createForOfIteratorHelper$o(myWiring),
51965
+ var _iterator0 = _createForOfIteratorHelper$n(myWiring),
51460
51966
  _step0;
51461
51967
  try {
51462
51968
  for (_iterator0.s(); !(_step0 = _iterator0.n()).done;) {
@@ -51533,7 +52039,7 @@ function EventsColumn(_ref12) {
51533
52039
  className: "flex-1 overflow-y-auto p-4 flex flex-col gap-3",
51534
52040
  children: emittersForList.length === 0 ? /*#__PURE__*/jsx("div", {
51535
52041
  className: "text-sm ".concat(muted),
51536
- children: "No other widgets in this dashboard emit events."
52042
+ children: "Nothing else on this dashboard emits events \u2014 no widgets or bots."
51537
52043
  }) : emittersForList.map(function (e) {
51538
52044
  return /*#__PURE__*/jsxs("div", {
51539
52045
  className: "rounded-lg border px-3 py-2 flex flex-col gap-1 ".concat(hairline),
@@ -52511,296 +53017,8 @@ function parseCron(cron) {
52511
53017
  };
52512
53018
  }
52513
53019
 
52514
- function _createForOfIteratorHelper$n(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray$n(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
52515
- function _unsupportedIterableToArray$n(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray$n(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray$n(r, a) : void 0; } }
52516
- function _arrayLikeToArray$n(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
52517
-
52518
- /**
52519
- * @param {Array<object>} workspaces dashboards (each with id, name, layout/pages)
52520
- * @param {(component: string) => object|null} getWidgetConfig
52521
- * @returns {Array<{ workspaceId: string, name: string,
52522
- * widgets: Array<{ ref: string, instanceId: string, label: string, events: string[] }> }>}
52523
- * dashboards with at least one event-emitting widget
52524
- */
52525
- function buildWidgetEventCatalog(workspaces, getWidgetConfig) {
52526
- if (!Array.isArray(workspaces)) return [];
52527
- var out = [];
52528
- var _iterator = _createForOfIteratorHelper$n(workspaces),
52529
- _step;
52530
- try {
52531
- for (_iterator.s(); !(_step = _iterator.n()).done;) {
52532
- var ws = _step.value;
52533
- if (!ws || ws.id === undefined || ws.id === null) continue;
52534
- var widgets = getEmitters(ws, getWidgetConfig).filter(function (e) {
52535
- return e.itemId != null && e.events.length;
52536
- }).map(function (e) {
52537
- return {
52538
- ref: e.component,
52539
- instanceId: String(e.itemId),
52540
- label: e.label || e.component,
52541
- events: e.events
52542
- };
52543
- });
52544
- if (!widgets.length) continue;
52545
- out.push({
52546
- workspaceId: String(ws.id),
52547
- name: ws.name || "Dashboard ".concat(ws.id),
52548
- widgets: widgets
52549
- });
52550
- }
52551
- // Dashboards can share a name (e.g. copies of "Kitchen Sink"); number the
52552
- // duplicates so each picker entry is distinguishable.
52553
- } catch (err) {
52554
- _iterator.e(err);
52555
- } finally {
52556
- _iterator.f();
52557
- }
52558
- var totals = {};
52559
- for (var _i = 0, _out = out; _i < _out.length; _i++) {
52560
- var w = _out[_i];
52561
- totals[w.name] = (totals[w.name] || 0) + 1;
52562
- }
52563
- var seen = {};
52564
- for (var _i2 = 0, _out2 = out; _i2 < _out2.length; _i2++) {
52565
- var _w = _out2[_i2];
52566
- if (totals[_w.name] > 1) {
52567
- seen[_w.name] = (seen[_w.name] || 0) + 1;
52568
- _w.name = "".concat(_w.name, " (").concat(seen[_w.name], ")");
52569
- }
52570
- }
52571
- return out;
52572
- }
52573
-
52574
- /** A subscription to one widget event, picked from the catalog. */
52575
- function widgetSubscription(workspace, widget, event) {
52576
- return {
52577
- eventType: formatEventString(widget.ref, widget.instanceId, event),
52578
- source: {
52579
- kind: "widget",
52580
- ref: widget.ref,
52581
- instanceId: widget.instanceId,
52582
- event: event,
52583
- workspaceId: workspace.workspaceId
52584
- },
52585
- label: "".concat(workspace.name, " \u203A ").concat(widget.label, " \u203A ").concat(event)
52586
- };
52587
- }
52588
-
52589
- /**
52590
- * How to show a saved subscription: its label from the live catalog, and
52591
- * whether its widget/event is gone (`missing`). Subscriptions saved before
52592
- * the picker (bare eventType) get a friendly label when they still resolve;
52593
- * otherwise they show as typed.
52594
- */
52595
- function describeSubscription(sub, catalog) {
52596
- var botCatalog = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
52597
- var eventType = sub && sub.eventType;
52598
- // Bot subscriptions resolve against the bot catalog; `kind` lets the form
52599
- // say "bot missing" instead of "widget missing".
52600
- if (sub && sub.source && sub.source.kind === "bot") {
52601
- var _iterator2 = _createForOfIteratorHelper$n(botCatalog || []),
52602
- _step2;
52603
- try {
52604
- for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
52605
- var b = _step2.value;
52606
- var _iterator3 = _createForOfIteratorHelper$n(b.events),
52607
- _step3;
52608
- try {
52609
- for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
52610
- var ev = _step3.value;
52611
- var s = botSubscription(b, ev);
52612
- if (s.eventType === eventType) {
52613
- return {
52614
- label: s.label,
52615
- missing: false,
52616
- kind: "bot"
52617
- };
52618
- }
52619
- }
52620
- } catch (err) {
52621
- _iterator3.e(err);
52622
- } finally {
52623
- _iterator3.f();
52624
- }
52625
- }
52626
- } catch (err) {
52627
- _iterator2.e(err);
52628
- } finally {
52629
- _iterator2.f();
52630
- }
52631
- return {
52632
- label: sub.label || eventType,
52633
- missing: true,
52634
- kind: "bot"
52635
- };
52636
- }
52637
- var _iterator4 = _createForOfIteratorHelper$n(catalog || []),
52638
- _step4;
52639
- try {
52640
- for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
52641
- var ws = _step4.value;
52642
- var _iterator5 = _createForOfIteratorHelper$n(ws.widgets),
52643
- _step5;
52644
- try {
52645
- for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
52646
- var w = _step5.value;
52647
- var _iterator6 = _createForOfIteratorHelper$n(w.events),
52648
- _step6;
52649
- try {
52650
- for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
52651
- var _ev = _step6.value;
52652
- if (formatEventString(w.ref, w.instanceId, _ev) === eventType) {
52653
- return {
52654
- label: widgetSubscription(ws, w, _ev).label,
52655
- missing: false
52656
- };
52657
- }
52658
- }
52659
- } catch (err) {
52660
- _iterator6.e(err);
52661
- } finally {
52662
- _iterator6.f();
52663
- }
52664
- }
52665
- } catch (err) {
52666
- _iterator5.e(err);
52667
- } finally {
52668
- _iterator5.f();
52669
- }
52670
- }
52671
- } catch (err) {
52672
- _iterator4.e(err);
52673
- } finally {
52674
- _iterator4.f();
52675
- }
52676
- if (sub && sub.source) {
52677
- return {
52678
- label: sub.label || eventType,
52679
- missing: true
52680
- };
52681
- }
52682
- return {
52683
- label: eventType || "",
52684
- missing: false
52685
- };
52686
- }
52687
-
52688
- /**
52689
- * Events other bots publish (bot:<ref>[<botId>].<event>, PRD US-010), for the
52690
- * "Another bot" side of the picker. Derived from each bot's settings — never
52691
- * hand-declared: Completed, Failed, and one `tool.<providerType>.<tool>` per
52692
- * tool the bot may use (the provider's tools, narrowed by the bot's
52693
- * selection). Providers with no known type or tool list are skipped.
52694
- *
52695
- * @param {Array<object>} bots
52696
- * @param {Array<{name, type, tools}>} toolSources bots.listToolSources()
52697
- * @param {string} [excludeBotId] the bot being edited — can't trigger itself
52698
- */
52699
- function buildBotEventCatalog(bots, toolSources) {
52700
- var excludeBotId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
52701
- if (!Array.isArray(bots)) return [];
52702
- var sources = Array.isArray(toolSources) ? toolSources : [];
52703
- var out = [];
52704
- var _iterator7 = _createForOfIteratorHelper$n(bots),
52705
- _step7;
52706
- try {
52707
- for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
52708
- var bot = _step7.value;
52709
- if (!bot || !bot.id || !bot.ref || bot.id === excludeBotId) continue;
52710
- var events = [{
52711
- event: "completed",
52712
- label: "Completed"
52713
- }, {
52714
- event: "failed",
52715
- label: "Failed"
52716
- }];
52717
- var _iterator8 = _createForOfIteratorHelper$n(bot.mcpServers || []),
52718
- _step8;
52719
- try {
52720
- var _loop = function _loop() {
52721
- var provider = _step8.value;
52722
- var src = sources.find(function (s) {
52723
- return s && s.name === provider;
52724
- });
52725
- if (!src || !src.type || !Array.isArray(src.tools)) return 1; // continue
52726
- var sel = bot.toolSelections && bot.toolSelections[provider];
52727
- var tools = Array.isArray(sel) ? src.tools.filter(function (t) {
52728
- return sel.includes(t);
52729
- }) : src.tools;
52730
- var _iterator9 = _createForOfIteratorHelper$n(tools),
52731
- _step9;
52732
- try {
52733
- for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
52734
- var tool = _step9.value;
52735
- events.push({
52736
- event: "tool.".concat(src.type, ".").concat(tool),
52737
- label: "".concat(provider, " \u203A ").concat(tool)
52738
- });
52739
- }
52740
- } catch (err) {
52741
- _iterator9.e(err);
52742
- } finally {
52743
- _iterator9.f();
52744
- }
52745
- };
52746
- for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
52747
- if (_loop()) continue;
52748
- }
52749
- } catch (err) {
52750
- _iterator8.e(err);
52751
- } finally {
52752
- _iterator8.f();
52753
- }
52754
- out.push({
52755
- botId: bot.id,
52756
- ref: bot.ref,
52757
- name: bot.name || bot.id,
52758
- events: events
52759
- });
52760
- }
52761
- } catch (err) {
52762
- _iterator7.e(err);
52763
- } finally {
52764
- _iterator7.f();
52765
- }
52766
- return out;
52767
- }
52768
-
52769
- /** A subscription to one bot event, picked from the bot catalog. */
52770
- function botSubscription(botEntry, ev) {
52771
- return {
52772
- eventType: "bot:".concat(botEntry.ref, "[").concat(botEntry.botId, "].").concat(ev.event),
52773
- source: {
52774
- kind: "bot",
52775
- ref: botEntry.ref,
52776
- instanceId: botEntry.botId,
52777
- event: ev.event
52778
- },
52779
- label: "".concat(botEntry.name, " \u203A ").concat(ev.label)
52780
- };
52781
- }
52782
-
52783
53020
  function ownKeys$y(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
52784
53021
  function _objectSpread$y(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys$y(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys$y(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
52785
- var EVENT_FROM_OPTIONS = [{
52786
- value: "widget",
52787
- label: "A dashboard widget"
52788
- }, {
52789
- value: "bot",
52790
- label: "Another bot"
52791
- }];
52792
-
52793
- /**
52794
- * BotDetail — create/edit form for a Bot Factory bot (Settings → Bots).
52795
- *
52796
- * Built for a non-technical user: Providers (the user's Dash MCP providers —
52797
- * what the bot can use), the AI model, and the schedule are all
52798
- * pick-from-a-list, never free text. "Provider" always means a Dash provider;
52799
- * the LLM choice is labelled "Model source". The raw cron lives behind an "Advanced"
52800
- * toggle for power users. All inputs are @trops/dash-react primitives.
52801
- */
52802
-
52803
- // Friendly, Title-case provider labels for the dropdown.
52804
53022
  var PROVIDER_LABELS = {
52805
53023
  anthropic: "Anthropic",
52806
53024
  openai: "OpenAI",
@@ -53110,19 +53328,15 @@ var BotDetail = function BotDetail(_ref) {
53110
53328
  var eventCatalog = useMemo(function () {
53111
53329
  return buildWidgetEventCatalog(workspaces, getWidgetConfig);
53112
53330
  }, [workspaces, getWidgetConfig]);
53113
- var _useState41 = useState("widget"),
53114
- _useState42 = _slicedToArray(_useState41, 2),
53115
- pickFrom = _useState42[0],
53116
- setPickFrom = _useState42[1];
53117
53331
  // Team = the dashboard this bot belongs to ("" = Unassigned). A bot on a
53118
53332
  // team only hears its own dashboard's events (bot-teams TEAM-001).
53119
- var _useState43 = useState(function () {
53333
+ var _useState41 = useState(function () {
53120
53334
  var id = bot ? bot.workspaceId : defaultWorkspaceId;
53121
53335
  return id === undefined || id === null || id === "" ? "" : String(id);
53122
53336
  }),
53123
- _useState44 = _slicedToArray(_useState43, 2),
53124
- team = _useState44[0],
53125
- setTeam = _useState44[1];
53337
+ _useState42 = _slicedToArray(_useState41, 2),
53338
+ team = _useState42[0],
53339
+ setTeam = _useState42[1];
53126
53340
  var teamOptions = useMemo(function () {
53127
53341
  return [{
53128
53342
  value: "",
@@ -53130,40 +53344,33 @@ var BotDetail = function BotDetail(_ref) {
53130
53344
  }].concat(_toConsumableArray(dashboardOptions(workspaces)));
53131
53345
  }, [workspaces]);
53132
53346
  var offTeam = offTeamSubscriptions(subscriptions, team);
53133
- // The event picker opens on the bot's own dashboard.
53134
- var _useState45 = useState(team),
53347
+ // "Runs when…" (TEAM-012): one picker of everything that can trigger the
53348
+ // bot; a just-added trigger reminds the user to Save.
53349
+ var _useState43 = useState(""),
53350
+ _useState44 = _slicedToArray(_useState43, 2),
53351
+ pickTrigger = _useState44[0],
53352
+ setPickTrigger = _useState44[1];
53353
+ var _useState45 = useState(false),
53135
53354
  _useState46 = _slicedToArray(_useState45, 2),
53136
- pickWorkspace = _useState46[0],
53137
- setPickWorkspace = _useState46[1];
53138
- var _useState47 = useState(""),
53139
- _useState48 = _slicedToArray(_useState47, 2),
53140
- pickWidget = _useState48[0],
53141
- setPickWidget = _useState48[1];
53142
- var _useState49 = useState(""),
53143
- _useState50 = _slicedToArray(_useState49, 2),
53144
- pickBot = _useState50[0],
53145
- setPickBot = _useState50[1];
53146
- var _useState51 = useState(""),
53147
- _useState52 = _slicedToArray(_useState51, 2),
53148
- pickEvent = _useState52[0],
53149
- setPickEvent = _useState52[1];
53355
+ triggerAdded = _useState46[0],
53356
+ setTriggerAdded = _useState46[1];
53150
53357
  var _ref3 = useContext(ThemeContext) || {},
53151
53358
  _ref3$currentTheme = _ref3.currentTheme,
53152
53359
  currentTheme = _ref3$currentTheme === void 0 ? {} : _ref3$currentTheme;
53153
53360
  var hairline = currentTheme["border-neutral-dark"] || "border-gray-700";
53154
- var _useState53 = useState(false),
53155
- _useState54 = _slicedToArray(_useState53, 2),
53156
- saving = _useState54[0],
53157
- setSaving = _useState54[1];
53158
- var _useState55 = useState(null),
53159
- _useState56 = _slicedToArray(_useState55, 2),
53160
- error = _useState56[0],
53161
- setError = _useState56[1];
53361
+ var _useState47 = useState(false),
53362
+ _useState48 = _slicedToArray(_useState47, 2),
53363
+ saving = _useState48[0],
53364
+ setSaving = _useState48[1];
53365
+ var _useState49 = useState(null),
53366
+ _useState50 = _slicedToArray(_useState49, 2),
53367
+ error = _useState50[0],
53368
+ setError = _useState50[1];
53162
53369
  // "Saved" shows after a successful save until the next edit.
53163
- var _useState57 = useState(false),
53164
- _useState58 = _slicedToArray(_useState57, 2),
53165
- justSaved = _useState58[0],
53166
- setJustSaved = _useState58[1];
53370
+ var _useState51 = useState(false),
53371
+ _useState52 = _slicedToArray(_useState51, 2),
53372
+ justSaved = _useState52[0],
53373
+ setJustSaved = _useState52[1];
53167
53374
 
53168
53375
  // Unsaved changes: the editable fields now vs. when the form opened (or
53169
53376
  // last saved).
@@ -53186,10 +53393,10 @@ var BotDetail = function BotDetail(_ref) {
53186
53393
  subscriptions: subscriptions,
53187
53394
  team: team
53188
53395
  });
53189
- var _useState59 = useState(snapshot),
53190
- _useState60 = _slicedToArray(_useState59, 2),
53191
- baseline = _useState60[0],
53192
- setBaseline = _useState60[1];
53396
+ var _useState53 = useState(snapshot),
53397
+ _useState54 = _slicedToArray(_useState53, 2),
53398
+ baseline = _useState54[0],
53399
+ setBaseline = _useState54[1];
53193
53400
  var dirty = snapshot !== baseline;
53194
53401
  useEffect(function () {
53195
53402
  if (dirty) setJustSaved(false);
@@ -53349,35 +53556,39 @@ var BotDetail = function BotDetail(_ref) {
53349
53556
  });
53350
53557
  };
53351
53558
 
53352
- // Cascading picker options. A widget's option value is "ref|instanceId".
53353
- var pickedWs = eventCatalog.find(function (w) {
53354
- return w.workspaceId === pickWorkspace;
53355
- });
53356
- var pickedWidget = pickedWs ? pickedWs.widgets.find(function (w) {
53357
- return "".concat(w.ref, "|").concat(w.instanceId) === pickWidget;
53358
- }) : null;
53359
-
53360
- // Other bots' events, derived from their providers + tools (this bot
53361
- // excluded — it can't trigger itself).
53559
+ // Other bots' events (this bot excluded — it can't trigger itself), for
53560
+ // labelling the triggers already on the bot.
53362
53561
  var botCatalog = useMemo(function () {
53363
53562
  return buildBotEventCatalog(bots, toolSources, (bot === null || bot === void 0 ? void 0 : bot.id) || null);
53364
53563
  }, [bots, toolSources, bot === null || bot === void 0 ? void 0 : bot.id]);
53365
- var pickedBot = botCatalog.find(function (b) {
53366
- return b.botId === pickBot;
53564
+
53565
+ // Everything that can trigger this bot, grouped (TEAM-012).
53566
+ var triggerOptions = useMemo(function () {
53567
+ return buildTriggerOptions({
53568
+ team: team || null,
53569
+ workspaces: workspaces,
53570
+ getWidgetConfig: getWidgetConfig,
53571
+ bots: bots,
53572
+ toolSources: toolSources,
53573
+ botId: (bot === null || bot === void 0 ? void 0 : bot.id) || null,
53574
+ existing: subscriptions.map(function (s) {
53575
+ return s.eventType;
53576
+ })
53577
+ });
53578
+ }, [team, workspaces, getWidgetConfig, bots, toolSources, bot === null || bot === void 0 ? void 0 : bot.id, subscriptions]);
53579
+ var pickedTrigger = triggerOptions.find(function (o) {
53580
+ return o.value === pickTrigger;
53367
53581
  }) || null;
53368
- var pickedBotEvent = pickedBot ? pickedBot.events.find(function (e) {
53369
- return e.event === pickEvent;
53370
- }) || null : null;
53371
- var canAddEvent = pickFrom === "bot" ? !!pickedBotEvent : !!(pickedWidget && pickEvent);
53372
53582
  var addSubscription = function addSubscription() {
53373
- if (!canAddEvent) return;
53374
- var sub = pickFrom === "bot" ? botSubscription(pickedBot, pickedBotEvent) : widgetSubscription(pickedWs, pickedWidget, pickEvent);
53583
+ if (!pickedTrigger) return;
53584
+ var sub = pickedTrigger.subscription;
53375
53585
  setSubscriptions(function (prev) {
53376
53586
  return prev.some(function (s) {
53377
53587
  return s.eventType === sub.eventType;
53378
53588
  }) ? prev : [].concat(_toConsumableArray(prev), [sub]);
53379
53589
  });
53380
- setPickEvent("");
53590
+ setPickTrigger("");
53591
+ setTriggerAdded(true);
53381
53592
  };
53382
53593
  var removeSubscription = function removeSubscription(eventType) {
53383
53594
  setSubscriptions(function (prev) {
@@ -53749,101 +53960,32 @@ var BotDetail = function BotDetail(_ref) {
53749
53960
  }) : /*#__PURE__*/jsx("span", {
53750
53961
  className: "text-xs opacity-50",
53751
53962
  children: "This bot doesn't run on any events yet."
53752
- }), /*#__PURE__*/jsx(SelectInput, {
53753
- label: "From",
53754
- value: pickFrom,
53755
- onChange: function onChange(v) {
53756
- setPickFrom(v);
53757
- setPickEvent("");
53758
- },
53759
- options: EVENT_FROM_OPTIONS
53760
- }), pickFrom === "bot" ? botCatalog.length ? /*#__PURE__*/jsxs("div", {
53963
+ }), triggerOptions.length ? /*#__PURE__*/jsxs("div", {
53761
53964
  className: "flex flex-col gap-2",
53762
53965
  children: [/*#__PURE__*/jsx(SelectInput, {
53763
- label: "Bot",
53764
- value: pickBot,
53765
- onChange: function onChange(v) {
53766
- setPickBot(v);
53767
- setPickEvent("");
53768
- },
53769
- placeholder: "Choose a bot\u2026",
53770
- options: botCatalog.map(function (b) {
53771
- return {
53772
- value: b.botId,
53773
- label: b.name
53774
- };
53775
- })
53776
- }), /*#__PURE__*/jsx(SelectInput, {
53777
- label: "Event",
53778
- value: pickEvent,
53779
- onChange: setPickEvent,
53780
- placeholder: "Choose an event\u2026",
53781
- options: (pickedBot ? pickedBot.events : []).map(function (e) {
53966
+ label: "Runs when\u2026",
53967
+ value: pickTrigger,
53968
+ onChange: setPickTrigger,
53969
+ placeholder: "Choose what triggers this bot\u2026",
53970
+ options: triggerOptions.map(function (o) {
53782
53971
  return {
53783
- value: e.event,
53784
- label: e.label
53972
+ value: o.value,
53973
+ label: o.label,
53974
+ group: o.group
53785
53975
  };
53786
53976
  })
53787
53977
  }), /*#__PURE__*/jsx(Button, {
53788
- title: "Add event",
53978
+ title: "Add trigger",
53789
53979
  onClick: addSubscription,
53790
53980
  size: "sm",
53791
- disabled: !canAddEvent
53792
- })]
53793
- }) : /*#__PURE__*/jsx("span", {
53794
- className: "text-xs opacity-50",
53795
- children: "No other bots yet. Create another bot to trigger this one when it finishes or uses a tool."
53796
- }) : eventCatalog.length ? /*#__PURE__*/jsxs("div", {
53797
- className: "flex flex-col gap-2",
53798
- children: [/*#__PURE__*/jsx(SelectInput, {
53799
- label: "Dashboard",
53800
- value: pickWorkspace,
53801
- onChange: function onChange(v) {
53802
- setPickWorkspace(v);
53803
- setPickWidget("");
53804
- setPickEvent("");
53805
- },
53806
- placeholder: "Choose a dashboard\u2026",
53807
- options: eventCatalog.map(function (w) {
53808
- return {
53809
- value: w.workspaceId,
53810
- label: w.name
53811
- };
53812
- })
53813
- }), /*#__PURE__*/jsx(SelectInput, {
53814
- label: "Widget",
53815
- value: pickWidget,
53816
- onChange: function onChange(v) {
53817
- setPickWidget(v);
53818
- setPickEvent("");
53819
- },
53820
- placeholder: "Choose a widget\u2026",
53821
- options: (pickedWs ? pickedWs.widgets : []).map(function (w) {
53822
- return {
53823
- value: "".concat(w.ref, "|").concat(w.instanceId),
53824
- label: w.label
53825
- };
53826
- })
53827
- }), /*#__PURE__*/jsx(SelectInput, {
53828
- label: "Event",
53829
- value: pickEvent,
53830
- onChange: setPickEvent,
53831
- placeholder: "Choose an event\u2026",
53832
- options: (pickedWidget ? pickedWidget.events : []).map(function (ev) {
53833
- return {
53834
- value: ev,
53835
- label: ev
53836
- };
53837
- })
53838
- }), /*#__PURE__*/jsx(Button, {
53839
- title: "Add event",
53840
- onClick: addSubscription,
53841
- size: "sm",
53842
- disabled: !pickedWidget || !pickEvent
53843
- })]
53981
+ disabled: !pickedTrigger
53982
+ }), triggerAdded && dirty ? /*#__PURE__*/jsx("span", {
53983
+ className: "text-xs opacity-70",
53984
+ children: "Save to keep this trigger."
53985
+ }) : null]
53844
53986
  }) : /*#__PURE__*/jsx("span", {
53845
53987
  className: "text-xs opacity-50",
53846
- children: "No widgets on your dashboards publish events yet. Add a widget that publishes events to a dashboard to trigger this bot from it."
53988
+ children: team ? "Nothing can trigger this bot yet. Add a widget that publishes events to this dashboard, or another bot to its team." : "Nothing can trigger this bot yet. Add a widget that publishes events to a dashboard, or create another bot."
53847
53989
  }), /*#__PURE__*/jsx("span", {
53848
53990
  className: "text-xs opacity-50",
53849
53991
  children: "The bot runs automatically when one of these events fires."
@@ -70502,6 +70644,11 @@ function pruneListeners(listeners, liveCanonicalKeys) {
70502
70644
  continue;
70503
70645
  }
70504
70646
  var kept = value.filter(function (eventStr) {
70647
+ var _parseEventString;
70648
+ // Bots aren't layout widgets, so they never appear in
70649
+ // liveCanonicalKeys. Their wiring is checked against the bot list
70650
+ // in the Listeners tab instead.
70651
+ if (isBotSource((_parseEventString = parseEventString(eventStr)) === null || _parseEventString === void 0 ? void 0 : _parseEventString.component)) return true;
70505
70652
  var key = eventStringToCanonicalKey(eventStr);
70506
70653
  if (!key) return true; // unparseable — leave alone
70507
70654
  return liveCanonicalKeys.has(key);