dara-core 1.24.3__py3-none-any.whl → 1.25.0__py3-none-any.whl

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.
@@ -18062,7 +18062,7 @@
18062
18062
  var _a;
18063
18063
  return jsxRuntimeExports.jsxs(Wrapper$8, { className: props.className, style: props.style, children: [jsxRuntimeExports.jsxs(Loader, { color: props.color, size: props.size, children: [jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" }), jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" }), jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" }), jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" }), jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" }), jsxRuntimeExports.jsx("div", { className: "sk-chase-dot" })] }), (props.showText || props.text) && jsxRuntimeExports.jsx(LoadingText, { color: props.color, children: (_a = props.text) !== null && _a !== void 0 ? _a : "LOADING" })] });
18064
18064
  }
18065
- var __rest$8 = function(s, e2) {
18065
+ var __rest$9 = function(s, e2) {
18066
18066
  var t2 = {};
18067
18067
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
18068
18068
  t2[p2] = s[p2];
@@ -18171,7 +18171,7 @@
18171
18171
  secondary: SecondaryButton
18172
18172
  };
18173
18173
  function Button(_a, ref) {
18174
- var { autoFocus, children, className, disabled: disabled2, download, href: href2, loading, id, onClick, outline = false, style, styling = "primary", type = "button" } = _a, props = __rest$8(_a, ["autoFocus", "children", "className", "disabled", "download", "href", "loading", "id", "onClick", "outline", "style", "styling", "type"]);
18174
+ var { autoFocus, children, className, disabled: disabled2, download, href: href2, loading, id, onClick, outline = false, style, styling = "primary", type = "button" } = _a, props = __rest$9(_a, ["autoFocus", "children", "className", "disabled", "download", "href", "loading", "id", "onClick", "outline", "style", "styling", "type"]);
18175
18175
  const currentTheme = useClTheme();
18176
18176
  const Component = stylingMap[styling];
18177
18177
  const content = loading ? jsxRuntimeExports.jsx(StyledLoading, { color: outline ? currentTheme.colors.grey2 : currentTheme.colors.blue1 }) : children;
@@ -25347,7 +25347,7 @@
25347
25347
  return jsxRuntimeExports.jsx(CheckboxWrapper, { "aria-disabled": props.disabled, children: jsxRuntimeExports.jsx(Checkbox, { id: index2, disabled: isSelectPermitted ? props.disabled : ((_a = checkedState.find((option) => option.value === item.value)) === null || _a === void 0 ? void 0 : _a.state) === false, isListStyle: props.isListStyle, label: item.label ? item.label : item.value, onChange: (checked, e2) => onChangeValue(e2), selected: (_b = checkedState.find((option) => option.value === item.value)) === null || _b === void 0 ? void 0 : _b.state }) }, `item-${index2}`);
25348
25348
  })] });
25349
25349
  }
25350
- var __rest$7 = function(s, e2) {
25350
+ var __rest$8 = function(s, e2) {
25351
25351
  var t2 = {};
25352
25352
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
25353
25353
  t2[p2] = s[p2];
@@ -25402,7 +25402,7 @@
25402
25402
  color: ${(props) => props.theme.colors.error};
25403
25403
  `;
25404
25404
  const Input$1 = React$1.forwardRef((_a, ref) => {
25405
- var { type = "text", onChange: onChange2, onKeyDown, keydownFilter, onComplete, maxValue, minValue, errorMsg, className, style, initialValue } = _a, rest = __rest$7(_a, ["type", "onChange", "onKeyDown", "keydownFilter", "onComplete", "maxValue", "minValue", "errorMsg", "className", "style", "initialValue"]);
25405
+ var { type = "text", onChange: onChange2, onKeyDown, keydownFilter, onComplete, maxValue, minValue, errorMsg, className, style, initialValue } = _a, rest = __rest$8(_a, ["type", "onChange", "onKeyDown", "keydownFilter", "onComplete", "maxValue", "minValue", "errorMsg", "className", "style", "initialValue"]);
25406
25406
  const handleChange = (e2) => {
25407
25407
  const target = e2.target;
25408
25408
  if (onChange2) {
@@ -27456,7 +27456,7 @@
27456
27456
  stateReducer: defaultProps$3.stateReducer,
27457
27457
  environment: defaultProps$3.environment
27458
27458
  });
27459
- var __rest$6 = function(s, e2) {
27459
+ var __rest$7 = function(s, e2) {
27460
27460
  var t2 = {};
27461
27461
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
27462
27462
  t2[p2] = s[p2];
@@ -27476,7 +27476,7 @@
27476
27476
  background-color: transparent !important;
27477
27477
  `;
27478
27478
  const ChevronButton = (_a) => {
27479
- var { getToggleButtonProps, disabled: disabled2, isOpen } = _a, props = __rest$6(_a, ["getToggleButtonProps", "disabled", "isOpen"]);
27479
+ var { getToggleButtonProps, disabled: disabled2, isOpen } = _a, props = __rest$7(_a, ["getToggleButtonProps", "disabled", "isOpen"]);
27480
27480
  return jsxRuntimeExports.jsx(StyledChevronButton, Object.assign({}, getToggleButtonProps(), props, { children: jsxRuntimeExports.jsx(Chevron$2, { disabled: disabled2, isOpen }) }));
27481
27481
  };
27482
27482
  const ChevronButton$1 = React$1.memo(ChevronButton);
@@ -27515,7 +27515,7 @@
27515
27515
  }
27516
27516
  var isEmptyExports = requireIsEmpty();
27517
27517
  const isEmpty = /* @__PURE__ */ getDefaultExportFromCjs(isEmptyExports);
27518
- var __rest$5 = function(s, e2) {
27518
+ var __rest$6 = function(s, e2) {
27519
27519
  var t2 = {};
27520
27520
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
27521
27521
  t2[p2] = s[p2];
@@ -27570,7 +27570,7 @@
27570
27570
  }
27571
27571
  `;
27572
27572
  const ListItem = ({ size: size2, title, item, index: index2, getItemProps, itemClass, children, isHighlighted, isSelected }) => {
27573
- const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$5(_a, ["itemClassName"]);
27573
+ const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$6(_a, ["itemClassName"]);
27574
27574
  return jsxRuntimeExports.jsx(StyledListItem, Object.assign({}, itemProps, { className: itemClass ? `${itemClassName} ${itemClass}` : itemClassName, title, size: size2, item, isHighlighted, isSelected, children }));
27575
27575
  };
27576
27576
  ListItem.displayName = "ListItem";
@@ -27789,9 +27789,11 @@
27789
27789
  `;
27790
27790
  styled.div`
27791
27791
  display: flex;
27792
- align-items: center;
27793
27792
  gap: 0.5rem;
27793
+ align-items: center;
27794
+
27794
27795
  width: 100%;
27796
+
27795
27797
  line-height: 1;
27796
27798
  `;
27797
27799
  styled.div`
@@ -31314,7 +31316,7 @@
31314
31316
  }, focusSelectedMonth: false, showPopperArrow: true, excludeScrollbar: true, customTimeInput: null, calendarStartDay: void 0 };
31315
31317
  } }]), a2;
31316
31318
  })(), jt = "input", Ht = "navigate";
31317
- var __rest$4 = function(s, e2) {
31319
+ var __rest$5 = function(s, e2) {
31318
31320
  var t2 = {};
31319
31321
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
31320
31322
  t2[p2] = s[p2];
@@ -31445,7 +31447,7 @@
31445
31447
  }
31446
31448
  `;
31447
31449
  const DatepickerListItem = React__namespace.memo(({ item, index: index2, getItemProps, isSelected, size: size2, isHighlighted }) => {
31448
- const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$4(_a, ["itemClassName"]);
31450
+ const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$5(_a, ["itemClassName"]);
31449
31451
  return jsxRuntimeExports.jsx(StyledDatepickerListItem, Object.assign({}, itemProps, { isSelected, title: item.label, item, index: index2, size: size2, isHighlighted, children: item.label }));
31450
31452
  });
31451
31453
  const StyledDropdownList = React__namespace.memo(styled(DropdownList$1)`
@@ -33753,7 +33755,7 @@
33753
33755
  const stepDown = () => step(amountToStep * -1);
33754
33756
  return jsxRuntimeExports.jsxs(StepperWrapper, { disabled: disabled2, children: [jsxRuntimeExports.jsx(StepperButton, { disabled: disabled2, onClick: stepUp, styling: "ghost", tabIndex: -1, children: jsxRuntimeExports.jsx(ChevronUp, {}) }), jsxRuntimeExports.jsx(StepperButton, { disabled: disabled2, onClick: stepDown, styling: "ghost", tabIndex: -1, children: jsxRuntimeExports.jsx(ChevronDown, {}) })] });
33755
33757
  };
33756
- var __rest$3 = function(s, e2) {
33758
+ var __rest$4 = function(s, e2) {
33757
33759
  var t2 = {};
33758
33760
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
33759
33761
  t2[p2] = s[p2];
@@ -33856,7 +33858,7 @@
33856
33858
  return "";
33857
33859
  };
33858
33860
  React__namespace.forwardRef((_a, ref) => {
33859
- var { value, onChange: onChange2, initialValue } = _a, props = __rest$3(_a, ["value", "onChange", "initialValue"]);
33861
+ var { value, onChange: onChange2, initialValue } = _a, props = __rest$4(_a, ["value", "onChange", "initialValue"]);
33860
33862
  const keydownFilter = React$1.useMemo(() => numericFilter(props.integerOnly), [props.integerOnly]);
33861
33863
  const [input, setInput] = React$1.useState(() => getInitialValue(value, initialValue));
33862
33864
  const step = (v) => {
@@ -34493,7 +34495,7 @@
34493
34495
  display: none;
34494
34496
  }
34495
34497
  `;
34496
- var __rest$2 = function(s, e2) {
34498
+ var __rest$3 = function(s, e2) {
34497
34499
  var t2 = {};
34498
34500
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
34499
34501
  t2[p2] = s[p2];
@@ -34554,7 +34556,7 @@
34554
34556
  }
34555
34557
  const SectionedListItem = ({ item, index: index2, getItemProps, isSelected, isHighlighted }) => {
34556
34558
  const theme2 = useClTheme();
34557
- const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$2(_a, ["itemClassName"]);
34559
+ const _a = getItemProps({ index: index2, item }), { itemClassName } = _a, itemProps = __rest$3(_a, ["itemClassName"]);
34558
34560
  if (item.heading) {
34559
34561
  delete itemProps.onClick;
34560
34562
  }
@@ -39079,7 +39081,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
39079
39081
  style: Object.assign(Object.assign(Object.assign({}, floatingStyles), { maxHeight: 800, minWidth: 150, zIndex: 9999 }), style)
39080
39082
  }), { isOpen, children: jsxRuntimeExports.jsx(SectionedList, { items: allowColumnHiding ? [resetFunctions, columnToggles] : [resetFunctions], onSelect: onOptionSelect }, isOpen ? "open" : "closed") })), document.body)] });
39081
39083
  };
39082
- var __rest$1 = function(s, e2) {
39084
+ var __rest$2 = function(s, e2) {
39083
39085
  var t2 = {};
39084
39086
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
39085
39087
  t2[p2] = s[p2];
@@ -39202,7 +39204,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
39202
39204
  throttledClickRow(row.original);
39203
39205
  }
39204
39206
  };
39205
- const _a = row.getRowProps({ style: renderRowStyle }), { style: rowStyle } = _a, restRow = __rest$1(_a, ["style"]);
39207
+ const _a = row.getRowProps({ style: renderRowStyle }), { style: rowStyle } = _a, restRow = __rest$2(_a, ["style"]);
39206
39208
  return React$1.createElement(Row, Object.assign({}, restRow, { key: `row-${index2}`, onClick, onClickRow, style: Object.assign(Object.assign({}, rowStyle), { top: (index2 + 1) * ROW_HEIGHT, width: totalColumnsWidth > width ? totalColumnsWidth : "100%" }) }), row.cells.map((cell, colIdx) => {
39207
39209
  var _a2;
39208
39210
  const cellProps = cell.getCellProps();
@@ -39220,7 +39222,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
39220
39222
  );
39221
39223
  }));
39222
39224
  }, arePropsEqual);
39223
- var __rest = function(s, e2) {
39225
+ var __rest$1 = function(s, e2) {
39224
39226
  var t2 = {};
39225
39227
  for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
39226
39228
  t2[p2] = s[p2];
@@ -39486,7 +39488,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
39486
39488
  const tableProps = getTableBodyProps();
39487
39489
  const renderTable = React$1.useCallback(
39488
39490
  (_a) => {
39489
- var { children, style: tableStyle } = _a, rest = __rest(_a, ["children", "style"]);
39491
+ var { children, style: tableStyle } = _a, rest = __rest$1(_a, ["children", "style"]);
39490
39492
  return jsxRuntimeExports.jsxs("div", { children: [jsxRuntimeExports.jsx(Header, { style: { width: `max(${totalColumnsWidth}px, 100%)` }, children: headerGroups.map((headerGroup, gidx) => React$1.createElement(HeaderRow, Object.assign({}, headerGroup.getHeaderGroupProps(), { key: `group-${gidx}` }), headerGroup.headers.map((col, cidx) => {
39491
39493
  const headerProps = col.getHeaderProps();
39492
39494
  const sortProps = col.getSortByToggleProps();
@@ -47208,7 +47210,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
47208
47210
  }
47209
47211
  return result2;
47210
47212
  }
47211
- function concat() {
47213
+ function concat2() {
47212
47214
  var length = arguments.length;
47213
47215
  if (!length) {
47214
47216
  return [];
@@ -49056,7 +49058,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
49056
49058
  lodash2.chain = chain;
49057
49059
  lodash2.chunk = chunk;
49058
49060
  lodash2.compact = compact;
49059
- lodash2.concat = concat;
49061
+ lodash2.concat = concat2;
49060
49062
  lodash2.cond = cond;
49061
49063
  lodash2.conforms = conforms;
49062
49064
  lodash2.constant = constant;
@@ -50776,6 +50778,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50776
50778
  function isStateVariable(variable) {
50777
50779
  return isVariable(variable) && variable.__typename === "StateVariable";
50778
50780
  }
50781
+ function isStreamVariable(variable) {
50782
+ return isVariable(variable) && variable.__typename === "StreamVariable";
50783
+ }
50779
50784
  function isResolvedDerivedVariable(value) {
50780
50785
  return value && typeof value === "object" && "values" in value && "type" in value && value.type === "derived" && "uid" in value;
50781
50786
  }
@@ -50940,6 +50945,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50940
50945
  const selectorRegistry = /* @__PURE__ */ new Map();
50941
50946
  const selectorFamilyRegistry = /* @__PURE__ */ new Map();
50942
50947
  const selectorFamilyMembersRegistry = /* @__PURE__ */ new Map();
50948
+ const streamAtomRegistry = /* @__PURE__ */ new Map();
50943
50949
  const depsRegistry = /* @__PURE__ */ new Map();
50944
50950
  const SHARED_KEY_TYPES = ["result-selector", "derived-selector"];
50945
50951
  function getRegistryKey(variable, type) {
@@ -50958,7 +50964,8 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50958
50964
  selectorRegistry,
50959
50965
  depsRegistry,
50960
50966
  selectorFamilyRegistry,
50961
- selectorFamilyMembersRegistry
50967
+ selectorFamilyMembersRegistry,
50968
+ streamAtomRegistry
50962
50969
  ]) {
50963
50970
  registry2.clear();
50964
50971
  }
@@ -50983,6 +50990,14 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50983
50990
  const key = getRegistryKey(variable, "selector-nested");
50984
50991
  return selectorFamilyRegistry.has(key);
50985
50992
  }
50993
+ case "StreamVariable": {
50994
+ for (const atomKey of streamAtomRegistry.keys()) {
50995
+ if (atomKey.includes(`"uid":"${variable.uid}"`)) {
50996
+ return true;
50997
+ }
50998
+ }
50999
+ return false;
51000
+ }
50986
51001
  default:
50987
51002
  return false;
50988
51003
  }
@@ -64576,6 +64591,9 @@ ${String(error)}`;
64576
64591
  const referrable = lookup[obj.__ref];
64577
64592
  return denormalize(referrable, lookup);
64578
64593
  }
64594
+ if (typeof obj !== "object") {
64595
+ return obj;
64596
+ }
64579
64597
  const output = Array.isArray(obj) ? [] : {};
64580
64598
  for (const [key, val] of getEntries(obj)) {
64581
64599
  if (val !== null && typeof val === "object") {
@@ -69813,7 +69831,7 @@ ${String(error)}`;
69813
69831
  if (!isVariable(v)) {
69814
69832
  return Promise.resolve(v);
69815
69833
  }
69816
- return resolveVariable(v, wsClient, taskContext, currentExtras);
69834
+ return resolveVariable(v, wsClient, taskContext, extrasSerializable.extras);
69817
69835
  })
69818
69836
  );
69819
69837
  const selfTrigger = get(getOrRegisterTrigger(variable));
@@ -70047,168 +70065,193 @@ ${String(error)}`;
70047
70065
  useInterval(trigger, variable.polling_interval);
70048
70066
  return dvSelector;
70049
70067
  }
70050
- var clone_1;
70051
- var hasRequiredClone;
70052
- function requireClone() {
70053
- if (hasRequiredClone) return clone_1;
70054
- hasRequiredClone = 1;
70055
- var baseClone = require_baseClone();
70056
- var CLONE_SYMBOLS_FLAG = 4;
70057
- function clone2(value) {
70058
- return baseClone(value, CLONE_SYMBOLS_FLAG);
70068
+ async function getBytes(stream, onChunk) {
70069
+ const reader = stream.getReader();
70070
+ let result;
70071
+ while (!(result = await reader.read()).done) {
70072
+ onChunk(result.value);
70059
70073
  }
70060
- clone_1 = clone2;
70061
- return clone_1;
70062
70074
  }
70063
- var cloneExports = requireClone();
70064
- const clone = /* @__PURE__ */ getDefaultExportFromCjs(cloneExports);
70065
- function resolveNested(obj, nested) {
70066
- if (!nested || nested.length === 0) {
70067
- return obj;
70068
- }
70069
- if (!obj || !(typeof obj === "object" && !Array.isArray(obj))) {
70070
- return obj;
70071
- }
70072
- let returnVal = obj;
70073
- for (const key of nested) {
70074
- if (!Object.keys(returnVal).includes(key)) {
70075
- return null;
70075
+ function getLines(onLine) {
70076
+ let buffer;
70077
+ let position;
70078
+ let fieldLength;
70079
+ let discardTrailingNewline = false;
70080
+ return function onChunk(arr) {
70081
+ if (buffer === void 0) {
70082
+ buffer = arr;
70083
+ position = 0;
70084
+ fieldLength = -1;
70085
+ } else {
70086
+ buffer = concat(buffer, arr);
70076
70087
  }
70077
- returnVal = returnVal[key];
70078
- }
70079
- return returnVal;
70080
- }
70081
- function setNested(obj, nested, newValue) {
70082
- if (!nested || nested.length === 0) {
70083
- return copy(obj);
70084
- }
70085
- if (!obj || !(typeof obj === "object" && !Array.isArray(obj))) {
70086
- return copy(obj);
70087
- }
70088
- const cloned = clone(obj);
70089
- const key = nested[0];
70090
- if (!Object.keys(obj).includes(key)) {
70091
- cloned[key] = {};
70092
- }
70093
- cloned[key] = nested.length === 1 ? newValue : setNested(cloned[key], nested.slice(1), newValue);
70094
- return cloned;
70095
- }
70096
- async function resolveVariable(variable, client2, taskContext, extras, resolver = (state) => Promise.resolve(state)) {
70097
- if (isDerivedVariable(variable)) {
70098
- getOrRegisterDerivedVariable(variable, client2, taskContext, extras);
70099
- const values = await Promise.all(
70100
- variable.variables.map((v) => resolveVariable(v, client2, taskContext, extras, resolver))
70101
- );
70102
- const deps = variable.deps.map((dep) => variable.variables.findIndex((v) => v.uid === dep.uid));
70103
- return {
70104
- deps,
70105
- type: "derived",
70106
- uid: variable.uid,
70107
- values,
70108
- nested: variable.nested
70109
- };
70110
- }
70111
- if (isServerVariable(variable)) {
70112
- getOrRegisterServerVariable(variable, extras);
70113
- return resolveServerVariable(variable, extras, resolver);
70114
- }
70115
- if (isSwitchVariable(variable)) {
70116
- let resolvedValue = isVariable(variable.value) ? await resolveVariable(variable.value, client2, taskContext, extras, resolver) : variable.value;
70117
- if (isCondition(resolvedValue)) {
70118
- resolvedValue = {
70119
- ...resolvedValue,
70120
- variable: await resolveVariable(resolvedValue.variable, client2, taskContext, extras, resolver)
70121
- };
70088
+ const bufLength = buffer.length;
70089
+ let lineStart = 0;
70090
+ while (position < bufLength) {
70091
+ if (discardTrailingNewline) {
70092
+ if (buffer[position] === 10) {
70093
+ lineStart = ++position;
70094
+ }
70095
+ discardTrailingNewline = false;
70096
+ }
70097
+ let lineEnd = -1;
70098
+ for (; position < bufLength && lineEnd === -1; ++position) {
70099
+ switch (buffer[position]) {
70100
+ case 58:
70101
+ if (fieldLength === -1) {
70102
+ fieldLength = position - lineStart;
70103
+ }
70104
+ break;
70105
+ case 13:
70106
+ discardTrailingNewline = true;
70107
+ case 10:
70108
+ lineEnd = position;
70109
+ break;
70110
+ }
70111
+ }
70112
+ if (lineEnd === -1) {
70113
+ break;
70114
+ }
70115
+ onLine(buffer.subarray(lineStart, lineEnd), fieldLength);
70116
+ lineStart = position;
70117
+ fieldLength = -1;
70122
70118
  }
70123
- const resolvedValueMap = isVariable(variable.value_map) ? await resolveVariable(variable.value_map, client2, taskContext, extras, resolver) : variable.value_map;
70124
- const resolvedDefault = isVariable(variable.default) ? await resolveVariable(variable.default, client2, taskContext, extras, resolver) : variable.default;
70125
- return {
70126
- type: "switch",
70127
- uid: variable.uid,
70128
- value: resolvedValue,
70129
- value_map: resolvedValueMap,
70130
- default: resolvedDefault
70131
- };
70132
- }
70133
- if (isStateVariable(variable)) {
70134
- throw new Error("StateVariable should not be resolved - it should be handled by useVariable hook");
70135
- }
70136
- return resolver(getOrRegisterPlainVariable(variable, client2, taskContext, extras));
70119
+ if (lineStart === bufLength) {
70120
+ buffer = void 0;
70121
+ } else if (lineStart !== 0) {
70122
+ buffer = buffer.subarray(lineStart);
70123
+ position -= lineStart;
70124
+ }
70125
+ };
70137
70126
  }
70138
- function resolveVariableStatic(variable, snapshot, params) {
70139
- if (isDerivedVariable(variable)) {
70140
- const values = variable.variables.map((v) => resolveVariableStatic(v, snapshot, params));
70141
- const deps = variable.deps.map((dep) => variable.variables.findIndex((v) => v.uid === dep.uid));
70142
- return {
70143
- deps,
70144
- type: "derived",
70145
- uid: variable.uid,
70146
- values,
70147
- nested: variable.nested
70148
- };
70149
- }
70150
- if (isServerVariable(variable)) {
70151
- return resolveServerVariableStatic(variable, snapshot);
70152
- }
70153
- if (isSwitchVariable(variable)) {
70154
- let resolvedValue = isVariable(variable.value) ? resolveVariableStatic(variable.value, snapshot, params) : variable.value;
70155
- if (isCondition(resolvedValue)) {
70156
- resolvedValue = {
70157
- ...resolvedValue,
70158
- variable: resolveVariableStatic(resolvedValue.variable, snapshot, params)
70159
- };
70127
+ function getMessages(onId, onRetry, onMessage) {
70128
+ let message = newMessage();
70129
+ const decoder = new TextDecoder();
70130
+ return function onLine(line, fieldLength) {
70131
+ if (line.length === 0) {
70132
+ onMessage === null || onMessage === void 0 ? void 0 : onMessage(message);
70133
+ message = newMessage();
70134
+ } else if (fieldLength > 0) {
70135
+ const field = decoder.decode(line.subarray(0, fieldLength));
70136
+ const valueOffset = fieldLength + (line[fieldLength + 1] === 32 ? 2 : 1);
70137
+ const value = decoder.decode(line.subarray(valueOffset));
70138
+ switch (field) {
70139
+ case "data":
70140
+ message.data = message.data ? message.data + "\n" + value : value;
70141
+ break;
70142
+ case "event":
70143
+ message.event = value;
70144
+ break;
70145
+ case "id":
70146
+ onId(message.id = value);
70147
+ break;
70148
+ case "retry":
70149
+ const retry = parseInt(value, 10);
70150
+ if (!isNaN(retry)) {
70151
+ onRetry(message.retry = retry);
70152
+ }
70153
+ break;
70154
+ }
70160
70155
  }
70161
- const resolvedValueMap = isVariable(variable.value_map) ? resolveVariableStatic(variable.value_map, snapshot, params) : variable.value_map;
70162
- const resolvedDefault = isVariable(variable.default) ? resolveVariableStatic(variable.default, snapshot, params) : variable.default;
70163
- return {
70164
- type: "switch",
70165
- uid: variable.uid,
70166
- value: resolvedValue,
70167
- value_map: resolvedValueMap,
70168
- default: resolvedDefault
70169
- };
70170
- }
70171
- if (isStateVariable(variable)) {
70172
- throw new Error("StateVariable should not be resolved - it should be handled by useVariable hook");
70173
- }
70174
- let result = resolvePlainVariableStatic(variable, snapshot, params);
70175
- while (isDerivedVariable(result)) {
70176
- result = resolveVariableStatic(result, snapshot, params);
70177
- }
70178
- return result;
70156
+ };
70179
70157
  }
70180
- function cleanValue(value, forceKeyOverride) {
70181
- if (isResolvedDerivedVariable(value)) {
70182
- const { deps, ...rest } = value;
70183
- const cleanedValues = value.values.map((v) => cleanValue(v));
70184
- return {
70185
- ...rest,
70186
- // Use override if provided, otherwise use the embedded force_key from the resolved variable
70187
- force_key: forceKeyOverride ?? (value.force_key || null),
70188
- values: cleanedValues
70189
- };
70190
- }
70191
- if (isResolvedSwitchVariable(value)) {
70192
- return {
70193
- ...value,
70194
- value: cleanValue(value.value, forceKeyOverride),
70195
- value_map: cleanValue(value.value_map, forceKeyOverride),
70196
- default: cleanValue(value.default, forceKeyOverride)
70197
- };
70198
- }
70199
- return value;
70158
+ function concat(a2, b2) {
70159
+ const res = new Uint8Array(a2.length + b2.length);
70160
+ res.set(a2);
70161
+ res.set(b2, a2.length);
70162
+ return res;
70200
70163
  }
70201
- function cleanKwargs(kwargs, forceKeyOverride) {
70202
- return Object.keys(kwargs).reduce(
70203
- (acc, k) => {
70204
- acc[k] = cleanValue(kwargs[k], forceKeyOverride);
70205
- return acc;
70206
- },
70207
- {}
70208
- );
70164
+ function newMessage() {
70165
+ return {
70166
+ data: "",
70167
+ event: "",
70168
+ id: "",
70169
+ retry: void 0
70170
+ };
70209
70171
  }
70210
- function cleanArgs(values, forceKeyOverride) {
70211
- return values.map((val) => cleanValue(val, forceKeyOverride));
70172
+ var __rest = function(s, e2) {
70173
+ var t2 = {};
70174
+ for (var p2 in s) if (Object.prototype.hasOwnProperty.call(s, p2) && e2.indexOf(p2) < 0)
70175
+ t2[p2] = s[p2];
70176
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
70177
+ for (var i2 = 0, p2 = Object.getOwnPropertySymbols(s); i2 < p2.length; i2++) {
70178
+ if (e2.indexOf(p2[i2]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p2[i2]))
70179
+ t2[p2[i2]] = s[p2[i2]];
70180
+ }
70181
+ return t2;
70182
+ };
70183
+ const EventStreamContentType = "text/event-stream";
70184
+ const DefaultRetryInterval = 1e3;
70185
+ const LastEventId = "last-event-id";
70186
+ function fetchEventSource(input, _a) {
70187
+ var { signal: inputSignal, headers: inputHeaders, onopen: inputOnOpen, onmessage, onclose, onerror, openWhenHidden, fetch: inputFetch } = _a, rest = __rest(_a, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
70188
+ return new Promise((resolve, reject) => {
70189
+ const headers = Object.assign({}, inputHeaders);
70190
+ if (!headers.accept) {
70191
+ headers.accept = EventStreamContentType;
70192
+ }
70193
+ let curRequestController;
70194
+ function onVisibilityChange() {
70195
+ curRequestController.abort();
70196
+ if (!document.hidden) {
70197
+ create();
70198
+ }
70199
+ }
70200
+ if (!openWhenHidden) {
70201
+ document.addEventListener("visibilitychange", onVisibilityChange);
70202
+ }
70203
+ let retryInterval = DefaultRetryInterval;
70204
+ let retryTimer = 0;
70205
+ function dispose() {
70206
+ document.removeEventListener("visibilitychange", onVisibilityChange);
70207
+ window.clearTimeout(retryTimer);
70208
+ curRequestController.abort();
70209
+ }
70210
+ inputSignal === null || inputSignal === void 0 ? void 0 : inputSignal.addEventListener("abort", () => {
70211
+ dispose();
70212
+ resolve();
70213
+ });
70214
+ const fetch2 = inputFetch !== null && inputFetch !== void 0 ? inputFetch : window.fetch;
70215
+ const onopen = inputOnOpen !== null && inputOnOpen !== void 0 ? inputOnOpen : defaultOnOpen;
70216
+ async function create() {
70217
+ var _a2;
70218
+ curRequestController = new AbortController();
70219
+ try {
70220
+ const response = await fetch2(input, Object.assign(Object.assign({}, rest), { headers, signal: curRequestController.signal }));
70221
+ await onopen(response);
70222
+ await getBytes(response.body, getLines(getMessages((id) => {
70223
+ if (id) {
70224
+ headers[LastEventId] = id;
70225
+ } else {
70226
+ delete headers[LastEventId];
70227
+ }
70228
+ }, (retry) => {
70229
+ retryInterval = retry;
70230
+ }, onmessage)));
70231
+ onclose === null || onclose === void 0 ? void 0 : onclose();
70232
+ dispose();
70233
+ resolve();
70234
+ } catch (err2) {
70235
+ if (!curRequestController.signal.aborted) {
70236
+ try {
70237
+ const interval = (_a2 = onerror === null || onerror === void 0 ? void 0 : onerror(err2)) !== null && _a2 !== void 0 ? _a2 : retryInterval;
70238
+ window.clearTimeout(retryTimer);
70239
+ retryTimer = window.setTimeout(create, interval);
70240
+ } catch (innerErr) {
70241
+ dispose();
70242
+ reject(innerErr);
70243
+ }
70244
+ }
70245
+ }
70246
+ }
70247
+ create();
70248
+ });
70249
+ }
70250
+ function defaultOnOpen(response) {
70251
+ const contentType = response.headers.get("content-type");
70252
+ if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith(EventStreamContentType))) {
70253
+ throw new Error(`Expected content-type to be ${EventStreamContentType}, Actual: ${contentType}`);
70254
+ }
70212
70255
  }
70213
70256
  /*!
70214
70257
  * https://github.com/Starcounter-Jack/JSON-Patch
@@ -70846,6 +70889,581 @@ ${String(error)}`;
70846
70889
  escapePathComponent,
70847
70890
  unescapePathComponent
70848
70891
  });
70892
+ var getExports = requireGet();
70893
+ const getPath = /* @__PURE__ */ getDefaultExportFromCjs(getExports);
70894
+ function extractKey(item, keyAccessor) {
70895
+ if (item === null || item === void 0) {
70896
+ return void 0;
70897
+ }
70898
+ const key = getPath(item, keyAccessor);
70899
+ if (typeof key === "string" || typeof key === "number") {
70900
+ return key;
70901
+ }
70902
+ return void 0;
70903
+ }
70904
+ function applyStreamEvent(currentState, event, keyAccessor) {
70905
+ switch (event.type) {
70906
+ // === Keyed mode events ===
70907
+ case "add": {
70908
+ if (keyAccessor === null) {
70909
+ console.warn(
70910
+ "StreamVariable: add() event received but no key_accessor is set. Use json_snapshot/json_patch instead."
70911
+ );
70912
+ return currentState;
70913
+ }
70914
+ const items = Array.isArray(event.data) ? event.data : [event.data];
70915
+ let newData = currentState.data ?? {};
70916
+ for (const item of items) {
70917
+ const key = extractKey(item, keyAccessor);
70918
+ if (key === void 0) {
70919
+ console.warn(
70920
+ `StreamVariable: Could not extract key using accessor '${keyAccessor}' from item:`,
70921
+ item
70922
+ );
70923
+ continue;
70924
+ }
70925
+ newData = { ...newData, [key]: item };
70926
+ }
70927
+ return {
70928
+ ...currentState,
70929
+ data: newData,
70930
+ status: "connected",
70931
+ error: void 0
70932
+ };
70933
+ }
70934
+ case "remove": {
70935
+ if (keyAccessor === null) {
70936
+ console.warn(
70937
+ "StreamVariable: remove() event received but no key_accessor is set. Use json_snapshot/json_patch instead."
70938
+ );
70939
+ return currentState;
70940
+ }
70941
+ const keys = Array.isArray(event.data) ? event.data : [event.data];
70942
+ const currentData = currentState.data ?? {};
70943
+ const newData = { ...currentData };
70944
+ for (const key of keys) {
70945
+ if (typeof key === "string" || typeof key === "number") {
70946
+ delete newData[key];
70947
+ }
70948
+ }
70949
+ return {
70950
+ ...currentState,
70951
+ data: newData,
70952
+ status: "connected",
70953
+ error: void 0
70954
+ };
70955
+ }
70956
+ case "clear": {
70957
+ return {
70958
+ ...currentState,
70959
+ data: {},
70960
+ status: "connected",
70961
+ error: void 0
70962
+ };
70963
+ }
70964
+ case "replace": {
70965
+ if (keyAccessor === null) {
70966
+ console.warn(
70967
+ "StreamVariable: replace() event received but no key_accessor is set. Use json_snapshot instead."
70968
+ );
70969
+ return currentState;
70970
+ }
70971
+ const items = Array.isArray(event.data) ? event.data : [];
70972
+ const newData = {};
70973
+ for (const item of items) {
70974
+ const key = extractKey(item, keyAccessor);
70975
+ if (key === void 0) {
70976
+ console.warn(
70977
+ `StreamVariable: Could not extract key using accessor '${keyAccessor}' from item:`,
70978
+ item
70979
+ );
70980
+ continue;
70981
+ }
70982
+ newData[key] = item;
70983
+ }
70984
+ return {
70985
+ ...currentState,
70986
+ data: newData,
70987
+ status: "connected",
70988
+ error: void 0
70989
+ };
70990
+ }
70991
+ // === Custom state mode events ===
70992
+ case "json_snapshot":
70993
+ return {
70994
+ ...currentState,
70995
+ data: event.data,
70996
+ status: "connected",
70997
+ error: void 0
70998
+ };
70999
+ case "json_patch": {
71000
+ if (currentState.data === void 0 || currentState.data === null) {
71001
+ console.warn(
71002
+ "StreamVariable: json_patch event received but no state exists. Send a json_snapshot first."
71003
+ );
71004
+ return currentState;
71005
+ }
71006
+ try {
71007
+ const operations = event.data;
71008
+ const { newDocument } = applyPatch(currentState.data, operations, true, false);
71009
+ return {
71010
+ ...currentState,
71011
+ data: newDocument,
71012
+ status: "connected",
71013
+ error: void 0
71014
+ };
71015
+ } catch (e2) {
71016
+ console.error("StreamVariable: Failed to apply json_patch:", e2);
71017
+ return {
71018
+ ...currentState,
71019
+ status: "error",
71020
+ error: `Patch failed: ${String(e2)}`
71021
+ };
71022
+ }
71023
+ }
71024
+ // === Control events ===
71025
+ case "reconnect":
71026
+ return {
71027
+ ...currentState,
71028
+ status: "reconnecting"
71029
+ };
71030
+ case "error":
71031
+ return {
71032
+ ...currentState,
71033
+ status: "error",
71034
+ error: typeof event.data === "string" ? event.data : "Unknown error"
71035
+ };
71036
+ default:
71037
+ console.warn(`StreamVariable: Unknown event type: ${event.type}`);
71038
+ return currentState;
71039
+ }
71040
+ }
71041
+ function getStreamValue(state, keyAccessor) {
71042
+ if (keyAccessor !== null && state.data !== null && typeof state.data === "object" && !Array.isArray(state.data)) {
71043
+ return Object.values(state.data);
71044
+ }
71045
+ return state.data;
71046
+ }
71047
+ const MAX_RETRIES = 5;
71048
+ const BASE_DELAY_MS = 1e3;
71049
+ const MAX_DELAY_MS = 3e4;
71050
+ function getBackoffDelay(retryCount) {
71051
+ return Math.min(BASE_DELAY_MS * 2 ** retryCount, MAX_DELAY_MS);
71052
+ }
71053
+ function serializeAtomParams(params) {
71054
+ return JSON.stringify(params);
71055
+ }
71056
+ function deserializeAtomParams(key) {
71057
+ return JSON.parse(key);
71058
+ }
71059
+ const activeConnections = /* @__PURE__ */ new Map();
71060
+ const INITIAL_CONNECTED_STATE = {
71061
+ data: void 0,
71062
+ status: "connected"
71063
+ };
71064
+ function startStreamConnection(params, callbacks) {
71065
+ const connectionKey = serializeAtomParams(params);
71066
+ const existingController = activeConnections.get(connectionKey);
71067
+ if (existingController) {
71068
+ existingController.abort();
71069
+ }
71070
+ const controller = new AbortController();
71071
+ activeConnections.set(connectionKey, controller);
71072
+ let retryCount = 0;
71073
+ let isFirstMessage = true;
71074
+ let currentState = INITIAL_CONNECTED_STATE;
71075
+ const normalizedValues = normalizeRequest(params.resolvedValues, params.variables);
71076
+ fetchEventSource(`/api/core/stream/${params.uid}`, {
71077
+ method: HTTP_METHOD.POST,
71078
+ body: JSON.stringify({ values: normalizedValues }),
71079
+ signal: controller.signal,
71080
+ // eslint-disable-next-line @typescript-eslint/require-await
71081
+ onopen: async (response) => {
71082
+ if (response.ok) {
71083
+ retryCount = 0;
71084
+ return;
71085
+ }
71086
+ const error = new Error(`Stream request failed: ${response.status} ${response.statusText}`);
71087
+ throw error;
71088
+ },
71089
+ onmessage: (msg) => {
71090
+ let event;
71091
+ try {
71092
+ event = JSON.parse(msg.data);
71093
+ } catch (parseError) {
71094
+ console.error("Failed to parse SSE event:", parseError, msg.data);
71095
+ return;
71096
+ }
71097
+ if (event.type === "reconnect") {
71098
+ console.info("StreamVariable: Server requested reconnect, reconnecting...");
71099
+ throw new Error("Server requested reconnect");
71100
+ }
71101
+ currentState = applyStreamEvent(currentState, event, params.keyAccessor);
71102
+ if (isFirstMessage) {
71103
+ isFirstMessage = false;
71104
+ callbacks.onFirstData(currentState);
71105
+ } else {
71106
+ callbacks.onUpdate(currentState);
71107
+ }
71108
+ },
71109
+ onerror: (err2) => {
71110
+ if (controller.signal.aborted) {
71111
+ return;
71112
+ }
71113
+ retryCount++;
71114
+ if (retryCount > MAX_RETRIES) {
71115
+ callbacks.onError(err2 instanceof Error ? err2.message : String(err2));
71116
+ return;
71117
+ }
71118
+ const delay2 = getBackoffDelay(retryCount - 1);
71119
+ console.warn(`Stream connection failed, retrying in ${delay2}ms (attempt ${retryCount}/${MAX_RETRIES})...`);
71120
+ return delay2;
71121
+ },
71122
+ onclose: () => {
71123
+ },
71124
+ // Use our request wrapper for auth headers
71125
+ // @ts-expect-error - fetch signature differs slightly but works
71126
+ fetch: request,
71127
+ // Pass through extras (headers, etc.)
71128
+ ...params.extras,
71129
+ // @ts-expect-error - Headers type doesn't match exactly
71130
+ headers: params.extras.headers
71131
+ });
71132
+ return () => {
71133
+ controller.abort();
71134
+ activeConnections.delete(connectionKey);
71135
+ };
71136
+ }
71137
+ function streamConnectionEffect(atomKey) {
71138
+ return ({ setSelf }) => {
71139
+ const params = deserializeAtomParams(atomKey);
71140
+ let resolveInitialData = null;
71141
+ let rejectInitialData = null;
71142
+ const initialDataPromise = new Promise((resolve, reject) => {
71143
+ resolveInitialData = resolve;
71144
+ rejectInitialData = reject;
71145
+ });
71146
+ setSelf(initialDataPromise);
71147
+ const cleanup = startStreamConnection(params, {
71148
+ onFirstData: (state) => {
71149
+ if (resolveInitialData) {
71150
+ resolveInitialData(state);
71151
+ resolveInitialData = null;
71152
+ rejectInitialData = null;
71153
+ }
71154
+ setSelf(state);
71155
+ },
71156
+ onUpdate: (state) => {
71157
+ setSelf(state);
71158
+ },
71159
+ onError: (error) => {
71160
+ if (rejectInitialData) {
71161
+ rejectInitialData(new Error(error));
71162
+ resolveInitialData = null;
71163
+ rejectInitialData = null;
71164
+ } else {
71165
+ setSelf({
71166
+ data: void 0,
71167
+ status: "error",
71168
+ error
71169
+ });
71170
+ }
71171
+ }
71172
+ });
71173
+ return cleanup;
71174
+ };
71175
+ }
71176
+ const streamAtomFamily = Recoil_index_10({
71177
+ key: "StreamVariable/state",
71178
+ effects: (atomKey) => [streamConnectionEffect(atomKey)]
71179
+ });
71180
+ function getStreamRegistryKey(variable, suffix) {
71181
+ return `StreamVariable:${getUniqueIdentifier(variable, { useNested: false })}:${suffix}`;
71182
+ }
71183
+ function getOrRegisterStreamVariableParams(variable, client2, taskContext, extras) {
71184
+ const key = getStreamRegistryKey(variable, "params-selector");
71185
+ if (!selectorFamilyRegistry.has(key)) {
71186
+ selectorFamilyRegistry.set(
71187
+ key,
71188
+ Recoil_index_11({
71189
+ key: nanoid$1(),
71190
+ get: (extrasSerializable) => async ({ get }) => {
71191
+ const resolvedVariables = await Promise.all(
71192
+ variable.variables.map(async (v) => {
71193
+ if (!isVariable(v)) {
71194
+ return v;
71195
+ }
71196
+ return resolveVariable(v, client2, taskContext, extrasSerializable.extras);
71197
+ })
71198
+ );
71199
+ const triggerList = buildTriggerList(variable.variables);
71200
+ registerChildTriggers(triggerList, get);
71201
+ const resolvedValues = resolvedVariables.map((v) => resolveValue(v, get));
71202
+ const params = {
71203
+ uid: variable.uid,
71204
+ resolvedValues,
71205
+ variables: variable.variables,
71206
+ keyAccessor: variable.key_accessor,
71207
+ extras: extrasSerializable.extras
71208
+ };
71209
+ return serializeAtomParams(params);
71210
+ }
71211
+ })
71212
+ );
71213
+ }
71214
+ const family = selectorFamilyRegistry.get(key);
71215
+ const serializableExtras = new RequestExtrasSerializable(extras);
71216
+ const selectorInstance = family(serializableExtras);
71217
+ if (!selectorFamilyMembersRegistry.has(family)) {
71218
+ selectorFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
71219
+ }
71220
+ selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
71221
+ return selectorInstance;
71222
+ }
71223
+ function getOrRegisterStreamVariableValue(variable, client2, taskContext, extras) {
71224
+ const key = getStreamRegistryKey(variable, "value-selector");
71225
+ if (!selectorFamilyRegistry.has(key)) {
71226
+ selectorFamilyRegistry.set(
71227
+ key,
71228
+ Recoil_index_11({
71229
+ key: nanoid$1(),
71230
+ get: (extrasSerializable) => ({ get }) => {
71231
+ const paramsSelector = getOrRegisterStreamVariableParams(
71232
+ variable,
71233
+ client2,
71234
+ taskContext,
71235
+ extrasSerializable.extras
71236
+ );
71237
+ const atomKey = get(paramsSelector);
71238
+ const atom2 = streamAtomFamily(atomKey);
71239
+ if (!streamAtomRegistry.has(atomKey)) {
71240
+ streamAtomRegistry.set(atomKey, atom2);
71241
+ }
71242
+ const streamState = get(atom2);
71243
+ return getStreamValue(streamState, variable.key_accessor);
71244
+ }
71245
+ })
71246
+ );
71247
+ }
71248
+ const family = selectorFamilyRegistry.get(key);
71249
+ const serializableExtras = new RequestExtrasSerializable(extras);
71250
+ const selectorInstance = family(serializableExtras);
71251
+ if (!selectorFamilyMembersRegistry.has(family)) {
71252
+ selectorFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
71253
+ }
71254
+ selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
71255
+ return selectorInstance;
71256
+ }
71257
+ function getOrRegisterStreamVariable(variable, client2, taskContext, extras) {
71258
+ const key = `StreamVariable:${getUniqueIdentifier(variable, { useNested: true })}:nested-selector`;
71259
+ if (!selectorFamilyRegistry.has(key)) {
71260
+ selectorFamilyRegistry.set(
71261
+ key,
71262
+ Recoil_index_11({
71263
+ key: nanoid$1(),
71264
+ get: (extrasSerializable) => ({ get }) => {
71265
+ const valueSelector = getOrRegisterStreamVariableValue(
71266
+ variable,
71267
+ client2,
71268
+ taskContext,
71269
+ extrasSerializable.extras
71270
+ );
71271
+ const value = get(valueSelector);
71272
+ return "nested" in variable ? resolveNested(value, variable.nested) : value;
71273
+ }
71274
+ })
71275
+ );
71276
+ }
71277
+ const family = selectorFamilyRegistry.get(key);
71278
+ const serializableExtras = new RequestExtrasSerializable(extras);
71279
+ const selectorInstance = family(serializableExtras);
71280
+ if (!selectorFamilyMembersRegistry.has(family)) {
71281
+ selectorFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
71282
+ }
71283
+ selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
71284
+ return selectorInstance;
71285
+ }
71286
+ var clone_1;
71287
+ var hasRequiredClone;
71288
+ function requireClone() {
71289
+ if (hasRequiredClone) return clone_1;
71290
+ hasRequiredClone = 1;
71291
+ var baseClone = require_baseClone();
71292
+ var CLONE_SYMBOLS_FLAG = 4;
71293
+ function clone2(value) {
71294
+ return baseClone(value, CLONE_SYMBOLS_FLAG);
71295
+ }
71296
+ clone_1 = clone2;
71297
+ return clone_1;
71298
+ }
71299
+ var cloneExports = requireClone();
71300
+ const clone = /* @__PURE__ */ getDefaultExportFromCjs(cloneExports);
71301
+ function resolveNested(obj, nested) {
71302
+ if (!nested || nested.length === 0) {
71303
+ return obj;
71304
+ }
71305
+ if (!obj || !(typeof obj === "object" && !Array.isArray(obj))) {
71306
+ return obj;
71307
+ }
71308
+ let returnVal = obj;
71309
+ for (const key of nested) {
71310
+ if (!Object.keys(returnVal).includes(key)) {
71311
+ return null;
71312
+ }
71313
+ returnVal = returnVal[key];
71314
+ }
71315
+ return returnVal;
71316
+ }
71317
+ function setNested(obj, nested, newValue) {
71318
+ if (!nested || nested.length === 0) {
71319
+ return copy(obj);
71320
+ }
71321
+ if (!obj || !(typeof obj === "object" && !Array.isArray(obj))) {
71322
+ return copy(obj);
71323
+ }
71324
+ const cloned = clone(obj);
71325
+ const key = nested[0];
71326
+ if (!Object.keys(obj).includes(key)) {
71327
+ cloned[key] = {};
71328
+ }
71329
+ cloned[key] = nested.length === 1 ? newValue : setNested(cloned[key], nested.slice(1), newValue);
71330
+ return cloned;
71331
+ }
71332
+ class PreloadSkipError extends Error {
71333
+ constructor(message) {
71334
+ super(message);
71335
+ this.name = "PreloadSkipError";
71336
+ }
71337
+ }
71338
+ async function resolveVariable(variable, client2, taskContext, extras, resolver = (state) => Promise.resolve(state)) {
71339
+ if (isDerivedVariable(variable)) {
71340
+ getOrRegisterDerivedVariable(variable, client2, taskContext, extras);
71341
+ const values = await Promise.all(
71342
+ variable.variables.map((v) => resolveVariable(v, client2, taskContext, extras, resolver))
71343
+ );
71344
+ const deps = variable.deps.map((dep) => variable.variables.findIndex((v) => v.uid === dep.uid));
71345
+ return {
71346
+ deps,
71347
+ type: "derived",
71348
+ uid: variable.uid,
71349
+ values,
71350
+ nested: variable.nested
71351
+ };
71352
+ }
71353
+ if (isServerVariable(variable)) {
71354
+ getOrRegisterServerVariable(variable, extras);
71355
+ return resolveServerVariable(variable, extras, resolver);
71356
+ }
71357
+ if (isSwitchVariable(variable)) {
71358
+ let resolvedValue = isVariable(variable.value) ? await resolveVariable(variable.value, client2, taskContext, extras, resolver) : variable.value;
71359
+ if (isCondition(resolvedValue)) {
71360
+ resolvedValue = {
71361
+ ...resolvedValue,
71362
+ variable: await resolveVariable(resolvedValue.variable, client2, taskContext, extras, resolver)
71363
+ };
71364
+ }
71365
+ const resolvedValueMap = isVariable(variable.value_map) ? await resolveVariable(variable.value_map, client2, taskContext, extras, resolver) : variable.value_map;
71366
+ const resolvedDefault = isVariable(variable.default) ? await resolveVariable(variable.default, client2, taskContext, extras, resolver) : variable.default;
71367
+ return {
71368
+ type: "switch",
71369
+ uid: variable.uid,
71370
+ value: resolvedValue,
71371
+ value_map: resolvedValueMap,
71372
+ default: resolvedDefault
71373
+ };
71374
+ }
71375
+ if (isStateVariable(variable)) {
71376
+ throw new Error("StateVariable should not be resolved - it should be handled by useVariable hook");
71377
+ }
71378
+ if (isStreamVariable(variable)) {
71379
+ return resolver(
71380
+ getOrRegisterStreamVariable(variable, client2, taskContext, extras)
71381
+ );
71382
+ }
71383
+ return resolver(getOrRegisterPlainVariable(variable, client2, taskContext, extras));
71384
+ }
71385
+ function resolveVariableStatic(variable, snapshot, params) {
71386
+ if (isDerivedVariable(variable)) {
71387
+ const values = variable.variables.map((v) => resolveVariableStatic(v, snapshot, params));
71388
+ const deps = variable.deps.map((dep) => variable.variables.findIndex((v) => v.uid === dep.uid));
71389
+ return {
71390
+ deps,
71391
+ type: "derived",
71392
+ uid: variable.uid,
71393
+ values,
71394
+ nested: variable.nested
71395
+ };
71396
+ }
71397
+ if (isServerVariable(variable)) {
71398
+ return resolveServerVariableStatic(variable, snapshot);
71399
+ }
71400
+ if (isSwitchVariable(variable)) {
71401
+ let resolvedValue = isVariable(variable.value) ? resolveVariableStatic(variable.value, snapshot, params) : variable.value;
71402
+ if (isCondition(resolvedValue)) {
71403
+ resolvedValue = {
71404
+ ...resolvedValue,
71405
+ variable: resolveVariableStatic(resolvedValue.variable, snapshot, params)
71406
+ };
71407
+ }
71408
+ const resolvedValueMap = isVariable(variable.value_map) ? resolveVariableStatic(variable.value_map, snapshot, params) : variable.value_map;
71409
+ const resolvedDefault = isVariable(variable.default) ? resolveVariableStatic(variable.default, snapshot, params) : variable.default;
71410
+ return {
71411
+ type: "switch",
71412
+ uid: variable.uid,
71413
+ value: resolvedValue,
71414
+ value_map: resolvedValueMap,
71415
+ default: resolvedDefault
71416
+ };
71417
+ }
71418
+ if (isStateVariable(variable)) {
71419
+ throw new PreloadSkipError(
71420
+ "StateVariable cannot be used in on_load actions or preloaded. StateVariables track DerivedVariable loading/error state and are only available at runtime."
71421
+ );
71422
+ }
71423
+ if (isStreamVariable(variable)) {
71424
+ throw new PreloadSkipError(
71425
+ "StreamVariable cannot be used in on_load actions or preloaded. StreamVariables receive data via server-sent events and are only available at runtime."
71426
+ );
71427
+ }
71428
+ let result = resolvePlainVariableStatic(variable, snapshot, params);
71429
+ while (isDerivedVariable(result)) {
71430
+ result = resolveVariableStatic(result, snapshot, params);
71431
+ }
71432
+ return result;
71433
+ }
71434
+ function cleanValue(value, forceKeyOverride) {
71435
+ if (isResolvedDerivedVariable(value)) {
71436
+ const { deps, ...rest } = value;
71437
+ const cleanedValues = value.values.map((v) => cleanValue(v));
71438
+ return {
71439
+ ...rest,
71440
+ // Use override if provided, otherwise use the embedded force_key from the resolved variable
71441
+ force_key: forceKeyOverride ?? (value.force_key || null),
71442
+ values: cleanedValues
71443
+ };
71444
+ }
71445
+ if (isResolvedSwitchVariable(value)) {
71446
+ return {
71447
+ ...value,
71448
+ value: cleanValue(value.value, forceKeyOverride),
71449
+ value_map: cleanValue(value.value_map, forceKeyOverride),
71450
+ default: cleanValue(value.default, forceKeyOverride)
71451
+ };
71452
+ }
71453
+ return value;
71454
+ }
71455
+ function cleanKwargs(kwargs, forceKeyOverride) {
71456
+ return Object.keys(kwargs).reduce(
71457
+ (acc, k) => {
71458
+ acc[k] = cleanValue(kwargs[k], forceKeyOverride);
71459
+ return acc;
71460
+ },
71461
+ {}
71462
+ );
71463
+ }
71464
+ function cleanArgs(values, forceKeyOverride) {
71465
+ return values.map((val) => cleanValue(val, forceKeyOverride));
71466
+ }
70849
71467
  function cleanSessionCache(sessionToken) {
70850
71468
  for (const storage of [sessionStorage, localStorage]) {
70851
71469
  const keys = Object.keys(storage);
@@ -73423,57 +74041,80 @@ Inferred class string: "${iconClasses}."`
73423
74041
  actions = [route.on_load];
73424
74042
  }
73425
74043
  const actionPayloads = actions.filter(isAnnotatedAction).map((a2) => {
73426
- const kwargs = cleanKwargs(
73427
- Object.fromEntries(
73428
- Object.entries(a2.dynamic_kwargs).map(([k, v]) => {
73429
- return [k, resolveVariableStatic(v, snapshot, params)];
73430
- })
73431
- ),
73432
- null
73433
- );
73434
- return {
73435
- uid: a2.uid,
73436
- definition_uid: a2.definition_uid,
73437
- values: normalizeRequest(kwargs, a2.dynamic_kwargs)
73438
- };
74044
+ try {
74045
+ const kwargs = cleanKwargs(
74046
+ Object.fromEntries(
74047
+ Object.entries(a2.dynamic_kwargs).map(([k, v]) => {
74048
+ return [k, resolveVariableStatic(v, snapshot, params)];
74049
+ })
74050
+ ),
74051
+ null
74052
+ );
74053
+ return {
74054
+ uid: a2.uid,
74055
+ definition_uid: a2.definition_uid,
74056
+ values: normalizeRequest(kwargs, a2.dynamic_kwargs)
74057
+ };
74058
+ } catch (e2) {
74059
+ if (e2 instanceof PreloadSkipError) {
74060
+ throw new UserError(
74061
+ `on_load action cannot use StreamVariable or StateVariable. These variables are only available at runtime after the page has loaded. Consider using a regular action triggered by user interaction instead.`
74062
+ );
74063
+ }
74064
+ throw e2;
74065
+ }
73439
74066
  });
73440
74067
  const dvHandles = Object.values(route.dependency_graph?.derived_variables ?? {}).flatMap((dv) => {
73441
- const handle = preloadDerivedVariable(dv, snapshot, params);
73442
- if (!handle) {
73443
- return [];
73444
- }
73445
- return {
73446
- ...handle,
73447
- dv,
73448
- payload: {
73449
- values: normalizeRequest(cleanArgs(handle.result.values, null), dv.variables),
73450
- uid: dv.uid
74068
+ try {
74069
+ const handle = preloadDerivedVariable(dv, snapshot, params);
74070
+ if (!handle) {
74071
+ return [];
73451
74072
  }
73452
- };
74073
+ return {
74074
+ ...handle,
74075
+ dv,
74076
+ payload: {
74077
+ values: normalizeRequest(cleanArgs(handle.result.values, null), dv.variables),
74078
+ uid: dv.uid
74079
+ }
74080
+ };
74081
+ } catch (e2) {
74082
+ if (e2 instanceof PreloadSkipError) {
74083
+ return [];
74084
+ }
74085
+ throw e2;
74086
+ }
73453
74087
  });
73454
74088
  const pyHandles = Object.values(route.dependency_graph?.py_components ?? {}).flatMap((py) => {
73455
- const handle = preloadServerComponent(py, snapshot, params);
73456
- if (!handle) {
73457
- return [];
73458
- }
73459
- const kwargValues = cleanKwargs(
73460
- Object.keys(py.props.dynamic_kwargs).reduce(
73461
- (acc, k, idx) => {
73462
- acc[k] = handle.result.values[idx];
73463
- return acc;
73464
- },
73465
- {}
73466
- )
73467
- );
73468
- return {
73469
- ...handle,
73470
- py,
73471
- payload: {
73472
- uid: py.uid,
73473
- name: py.name,
73474
- values: normalizeRequest(kwargValues, py.props.dynamic_kwargs)
74089
+ try {
74090
+ const handle = preloadServerComponent(py, snapshot, params);
74091
+ if (!handle) {
74092
+ return [];
73475
74093
  }
73476
- };
74094
+ const kwargValues = cleanKwargs(
74095
+ Object.keys(py.props.dynamic_kwargs).reduce(
74096
+ (acc, k, idx) => {
74097
+ acc[k] = handle.result.values[idx];
74098
+ return acc;
74099
+ },
74100
+ {}
74101
+ )
74102
+ );
74103
+ return {
74104
+ ...handle,
74105
+ py,
74106
+ payload: {
74107
+ uid: py.uid,
74108
+ name: py.name,
74109
+ values: normalizeRequest(kwargValues, py.props.dynamic_kwargs)
74110
+ }
74111
+ };
74112
+ } catch (e2) {
74113
+ if (e2 instanceof PreloadSkipError) {
74114
+ return [];
74115
+ }
74116
+ throw e2;
74117
+ }
73477
74118
  });
73478
74119
  const dvHandlesByUid = dvHandles.reduce(
73479
74120
  (acc, h) => ({ ...acc, [h.dv.uid]: h }),
@@ -74048,6 +74689,12 @@ Inferred class string: "${iconClasses}."`
74048
74689
  });
74049
74690
  return [data2?.[0] ?? null, warnUpdateOnDerivedState];
74050
74691
  }
74692
+ if (isStreamVariable(variable)) {
74693
+ const selector2 = getOrRegisterStreamVariable(variable, wsClient, taskContext, extras);
74694
+ const selectorLoadable = Recoil_index_21(selector2);
74695
+ const deferred22 = useDeferLoadable(selectorLoadable, opts.suspend);
74696
+ return [deferred22, warnUpdateOnDerivedState];
74697
+ }
74051
74698
  const recoilState = getOrRegisterPlainVariable(variable, wsClient, taskContext, extras);
74052
74699
  if (!isDerivedVariable(variable.default)) {
74053
74700
  const [value, setValue] = Recoil_index_22(recoilState);
@@ -75093,6 +75740,7 @@ body,
75093
75740
  } else if (isSwitchVariable(variable)) ;
75094
75741
  else if (isStateVariable(variable)) ;
75095
75742
  else if (isServerVariable(variable)) ;
75743
+ else if (isStreamVariable(variable)) ;
75096
75744
  else {
75097
75745
  const plainAtom = getOrRegisterPlainVariable(variable, ctx.wsClient, ctx.taskCtx, ctx.extras);
75098
75746
  if (variable.store?.__typename === "QueryParamStore") {
@@ -99151,6 +99799,7 @@ body,
99151
99799
  exports.isServerVariable = isServerVariable;
99152
99800
  exports.isSingleVariable = isSingleVariable;
99153
99801
  exports.isStateVariable = isStateVariable;
99802
+ exports.isStreamVariable = isStreamVariable;
99154
99803
  exports.isSwitchVariable = isSwitchVariable;
99155
99804
  exports.isTaskResponse = isTaskResponse$1;
99156
99805
  exports.isVariable = isVariable;
@@ -99169,6 +99818,7 @@ body,
99169
99818
  exports.resolveServerVariable = resolveServerVariable;
99170
99819
  exports.resolveServerVariableStatic = resolveServerVariableStatic;
99171
99820
  exports.resolveTheme = resolveTheme;
99821
+ exports.resolveValue = resolveValue;
99172
99822
  exports.revokeSession = revokeSession;
99173
99823
  exports.selectorFamilyMembersRegistry = selectorFamilyMembersRegistry;
99174
99824
  exports.selectorFamilyRegistry = selectorFamilyRegistry;
@@ -99176,6 +99826,7 @@ body,
99176
99826
  exports.setNested = setNested;
99177
99827
  exports.setSessionToken = setSessionToken;
99178
99828
  exports.setupWebsocket = setupWebsocket;
99829
+ exports.streamAtomRegistry = streamAtomRegistry;
99179
99830
  exports.useAction = useAction;
99180
99831
  exports.useActionIsLoading = useActionIsLoading;
99181
99832
  exports.useComponentStyles = useComponentStyles;