dara-core 1.16.20__py3-none-any.whl → 1.16.21__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.
@@ -33,7 +33,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
33
33
  (function(global2, factory) {
34
34
  typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react"), require("@tanstack/react-query"), require("react-dom"), require("styled-components")) : typeof define === "function" && define.amd ? define(["exports", "react", "@tanstack/react-query", "react-dom", "styled-components"], factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, factory((global2.dara = global2.dara || {}, global2.dara.core = {}), global2.React, global2.ReactQuery, global2.ReactDOM, global2.styled));
35
35
  })(this, function(exports, React, reactQuery, ReactDOM, styled) {
36
- var _locks, _subscribers, _events$, _parentBus, _pingInterval, _socketUrl, _reconnectCount, _instance, _observers;
36
+ var _locks, _subscribers, _pingInterval, _socketUrl, _reconnectCount, _events$, _parentBus, _instance, _observers;
37
37
  "use strict";
38
38
  const _interopDefaultLegacy = (e2) => e2 && typeof e2 === "object" && "default" in e2 ? e2 : { default: e2 };
39
39
  function _interopNamespace(e2) {
@@ -4936,14 +4936,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
4936
4936
  useEffect: useEffect$1$1,
4937
4937
  useRef: useRef$2$1
4938
4938
  } = React__default.default;
4939
- function usePrevious$1(value) {
4939
+ function usePrevious$2(value) {
4940
4940
  const ref = useRef$2$1();
4941
4941
  useEffect$1$1(() => {
4942
4942
  ref.current = value;
4943
4943
  });
4944
4944
  return ref.current;
4945
4945
  }
4946
- var Recoil_usePrevious$1 = usePrevious$1;
4946
+ var Recoil_usePrevious$1 = usePrevious$2;
4947
4947
  const {
4948
4948
  useStoreRef: useStoreRef$1
4949
4949
  } = Recoil_RecoilRoot;
@@ -11897,14 +11897,14 @@ var __privateWrapper = (obj, member, setter, getter) => ({
11897
11897
  useEffect: useEffect$2,
11898
11898
  useRef: useRef$2
11899
11899
  } = React__default.default;
11900
- function usePrevious(value) {
11900
+ function usePrevious$1(value) {
11901
11901
  const ref = useRef$2();
11902
11902
  useEffect$2(() => {
11903
11903
  ref.current = value;
11904
11904
  });
11905
11905
  return ref.current;
11906
11906
  }
11907
- var Recoil_usePrevious = usePrevious;
11907
+ var Recoil_usePrevious = usePrevious$1;
11908
11908
  const {
11909
11909
  DefaultValue: DefaultValue$2
11910
11910
  } = Recoil_index;
@@ -50034,12 +50034,26 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
50034
50034
  localStorage.setItem(getTokenKey(), token);
50035
50035
  return token;
50036
50036
  }
50037
+ function useSession(body = {}) {
50038
+ return reactQuery.useQuery({
50039
+ queryFn: async () => {
50040
+ return requestSessionToken(body);
50041
+ },
50042
+ queryKey: ["session"],
50043
+ refetchOnMount: false
50044
+ });
50045
+ }
50037
50046
  async function verifySessionToken() {
50038
50047
  const res = await request("/api/auth/verify-session", {
50039
50048
  method: HTTP_METHOD.POST
50040
50049
  });
50041
50050
  return res.ok;
50042
50051
  }
50052
+ var AuthType = /* @__PURE__ */ ((AuthType2) => {
50053
+ AuthType2["BASIC"] = "BASIC";
50054
+ AuthType2["SSO"] = "SSO";
50055
+ return AuthType2;
50056
+ })(AuthType || {});
50043
50057
  var ComponentType = /* @__PURE__ */ ((ComponentType2) => {
50044
50058
  ComponentType2["JS"] = "js";
50045
50059
  ComponentType2["PY"] = "py";
@@ -51143,6 +51157,7 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
51143
51157
  const atomRegistry = /* @__PURE__ */ new Map();
51144
51158
  const atomFamilyRegistry = /* @__PURE__ */ new Map();
51145
51159
  const atomFamilyMembersRegistry = /* @__PURE__ */ new Map();
51160
+ const selectorRegistry = /* @__PURE__ */ new Map();
51146
51161
  const selectorFamilyRegistry = /* @__PURE__ */ new Map();
51147
51162
  const selectorFamilyMembersRegistry = /* @__PURE__ */ new Map();
51148
51163
  const depsRegistry = /* @__PURE__ */ new Map();
@@ -51154,6 +51169,20 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
51154
51169
  }
51155
51170
  return `${getUniqueIdentifier(variable)}-${type}-${extras}`;
51156
51171
  }
51172
+ function clearRegistries_TEST() {
51173
+ for (const registry of [
51174
+ dataRegistry,
51175
+ atomRegistry,
51176
+ atomFamilyRegistry,
51177
+ atomFamilyMembersRegistry,
51178
+ selectorRegistry,
51179
+ depsRegistry,
51180
+ selectorFamilyRegistry,
51181
+ selectorFamilyMembersRegistry
51182
+ ]) {
51183
+ registry.clear();
51184
+ }
51185
+ }
51157
51186
  function isRegistered(variable) {
51158
51187
  if (!isVariable(variable)) {
51159
51188
  return false;
@@ -51395,247 +51424,1066 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
51395
51424
  console.warn("No valid theme was found. Defaulting to light theme.");
51396
51425
  return theme;
51397
51426
  }
51398
- class EventBus {
51399
- constructor(parentBus) {
51400
- __privateAdd(this, _events$, new Subject());
51401
- __privateAdd(this, _parentBus, null);
51402
- __privateSet(this, _parentBus, parentBus != null ? parentBus : null);
51403
- }
51404
- publish(type, data) {
51405
- __privateGet(this, _events$).next({ type, data });
51406
- if (__privateGet(this, _parentBus)) {
51407
- __privateGet(this, _parentBus).publish(type, data);
51427
+ function useDeferLoadable(loadable) {
51428
+ const { suspend } = useFallbackCtx();
51429
+ const [availableState, setAvailableState] = React.useState(() => loadable.getValue());
51430
+ const timerId = React.useRef(null);
51431
+ const isFirstRender = React.useRef(true);
51432
+ const [showFallback, setShowFallback] = React.useState(false);
51433
+ React.useEffect(() => {
51434
+ if (isFirstRender.current) {
51435
+ isFirstRender.current = false;
51436
+ return;
51408
51437
  }
51409
- }
51410
- subscribe(callback) {
51411
- const sub = __privateGet(this, _events$).pipe().subscribe(callback);
51412
- return () => sub.unsubscribe();
51413
- }
51414
- }
51415
- _events$ = new WeakMap();
51416
- _parentBus = new WeakMap();
51417
- const DEFAULT_BUS = new EventBus();
51418
- const EventBusContext = React__namespace.createContext(DEFAULT_BUS);
51419
- function useEventBus() {
51420
- return React__namespace.useContext(EventBusContext);
51421
- }
51422
- function EventCapturer({ children, onEvent }) {
51423
- const parentBus = useEventBus();
51424
- const bus = React__namespace.useMemo(() => new EventBus(parentBus), [parentBus]);
51425
- React__namespace.useEffect(() => {
51426
- return bus.subscribe(onEvent);
51427
- }, [bus, onEvent]);
51428
- return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, children);
51429
- }
51430
- function err(message) {
51431
- const error = new Error(message);
51432
- if (error.stack === void 0) {
51433
- try {
51434
- throw error;
51435
- } catch (_) {
51438
+ if (loadable.state === "loading" && typeof suspend === "number") {
51439
+ timerId.current = setTimeout(() => {
51440
+ setShowFallback(true);
51441
+ }, suspend);
51442
+ }
51443
+ return () => {
51444
+ if (timerId.current) {
51445
+ clearTimeout(timerId.current);
51446
+ }
51447
+ };
51448
+ }, [loadable.state, suspend]);
51449
+ React.useEffect(() => {
51450
+ if (loadable.state === "hasValue") {
51451
+ if (timerId.current) {
51452
+ clearTimeout(timerId.current);
51453
+ }
51454
+ setShowFallback(false);
51455
+ setAvailableState(loadable.valueOrThrow());
51436
51456
  }
51457
+ }, [loadable]);
51458
+ if (suspend === true || showFallback) {
51459
+ return loadable.getValue();
51437
51460
  }
51438
- return error;
51461
+ return availableState;
51439
51462
  }
51440
- var err_1 = err;
51441
- var Recoil_err = err_1;
51442
- function raiseError(suffix, resultFailure) {
51443
- if (resultFailure != null) {
51444
- const path = resultFailure.path.toString();
51445
- const message = resultFailure.message;
51446
- throw Recoil_err(`[refine.js (path=${path}, message=${message})]: ${suffix}`);
51447
- }
51448
- throw Recoil_err(`[refine.js (null result)]: ${suffix}`);
51463
+ const interAttemptTimeout = 500;
51464
+ const maxDisconnectedTime = 1e4;
51465
+ const interPingInterval = 5e3;
51466
+ const maxAttempts = Math.round(maxDisconnectedTime / interAttemptTimeout);
51467
+ function isInitMessage(message) {
51468
+ return message.type === "init";
51449
51469
  }
51450
- function assertion(checker, errorMessage = "assertion error") {
51451
- return (value) => {
51452
- const result = checker(value);
51453
- return result.type === "success" ? result.value : raiseError(errorMessage, result);
51454
- };
51470
+ function isTaskNotification(message) {
51471
+ return message.type === "message" && "status" in message.message && "task_id" in message.message;
51455
51472
  }
51456
- function coercion(checker, onResult) {
51457
- return (value) => {
51458
- const result = checker(value);
51459
- if (onResult != null) {
51460
- onResult(result);
51461
- }
51462
- return result.type === "success" ? result.value : null;
51463
- };
51473
+ function isServerTriggerMessage(message) {
51474
+ return message.type === "message" && "data_id" in message.message;
51464
51475
  }
51465
- var Refine_API = {
51466
- assertion,
51467
- coercion
51468
- };
51469
- function _defineProperty(obj, key, value) {
51470
- if (key in obj) {
51471
- Object.defineProperty(obj, key, {
51472
- value,
51473
- enumerable: true,
51474
- configurable: true,
51475
- writable: true
51476
- });
51477
- } else {
51478
- obj[key] = value;
51479
- }
51480
- return obj;
51476
+ function isServerErrorMessage(message) {
51477
+ return message.type === "message" && "error" in message.message;
51481
51478
  }
51482
- class Path {
51483
- constructor(parent = null, field = "<root>") {
51484
- _defineProperty(this, "parent", void 0);
51485
- _defineProperty(this, "field", void 0);
51486
- this.parent = parent;
51487
- this.field = field;
51488
- }
51489
- extend(field) {
51490
- return new Path(this, field);
51491
- }
51492
- toString() {
51493
- const pieces = [];
51494
- let current = this;
51495
- while (current != null) {
51496
- const {
51497
- field,
51498
- parent
51499
- } = current;
51500
- pieces.push(field);
51501
- current = parent;
51502
- }
51503
- return pieces.reverse().join("");
51504
- }
51479
+ function isVariableRequestMessage(message) {
51480
+ return message.type === "message" && "variable" in message.message;
51505
51481
  }
51506
- function success(value, warnings) {
51507
- return {
51508
- type: "success",
51509
- value,
51510
- warnings
51511
- };
51482
+ function isActionMessage(message) {
51483
+ return message.type === "message" && "action" in message.message;
51512
51484
  }
51513
- function failure(message, path) {
51514
- return {
51515
- type: "failure",
51516
- message,
51517
- path
51518
- };
51485
+ function isBackendStoreMessage(message) {
51486
+ return message.type === "message" && "store_uid" in message.message && "value" in message.message;
51519
51487
  }
51520
- function compose(checker, next) {
51521
- return (value, path = new Path()) => {
51522
- const result = checker(value, path);
51523
- return result.type === "failure" ? result : next(result, path);
51524
- };
51488
+ function isBackendStorePatchMessage(message) {
51489
+ return message.type === "message" && "store_uid" in message.message && "patches" in message.message;
51525
51490
  }
51526
- var Refine_Checkers = {
51527
- Path,
51528
- success,
51529
- failure,
51530
- compose
51491
+ function isCustomMessage(message) {
51492
+ return message.type === "custom";
51493
+ }
51494
+ const pingMessage = {
51495
+ message: null,
51496
+ type: "ping"
51531
51497
  };
51532
- var Refine_Checkers_1 = Refine_Checkers.Path;
51533
- var Refine_Checkers_2 = Refine_Checkers.success;
51534
- var Refine_Checkers_3 = Refine_Checkers.failure;
51535
- var Refine_Checkers_4 = Refine_Checkers.compose;
51536
- var Refine_Checkers$1 = /* @__PURE__ */ Object.freeze({
51537
- __proto__: null,
51538
- Path: Refine_Checkers_1,
51539
- success: Refine_Checkers_2,
51540
- failure: Refine_Checkers_3,
51541
- compose: Refine_Checkers_4
51542
- });
51543
- const {
51544
- Path: Path$1,
51545
- compose: compose$1,
51546
- failure: failure$1,
51547
- success: success$1
51548
- } = Refine_Checkers$1;
51549
- function isPlainObject$1(value) {
51550
- if (Object.prototype.toString.call(value) !== "[object Object]") {
51551
- return false;
51498
+ class WebSocketClient {
51499
+ constructor(_socketUrl2, _token, _liveReload = false) {
51500
+ __publicField(this, "channel");
51501
+ __publicField(this, "messages$");
51502
+ __publicField(this, "socket");
51503
+ __publicField(this, "token");
51504
+ __publicField(this, "liveReload");
51505
+ __publicField(this, "closeHandler");
51506
+ __publicField(this, "maxAttempts");
51507
+ __privateAdd(this, _pingInterval, void 0);
51508
+ __privateAdd(this, _socketUrl, void 0);
51509
+ __privateAdd(this, _reconnectCount, void 0);
51510
+ this.token = _token;
51511
+ this.liveReload = _liveReload;
51512
+ this.messages$ = new Subject();
51513
+ this.closeHandler = this.onClose.bind(this);
51514
+ this.maxAttempts = maxAttempts;
51515
+ __privateSet(this, _socketUrl, _socketUrl2);
51516
+ __privateSet(this, _reconnectCount, 0);
51517
+ __privateSet(this, _pingInterval, null);
51518
+ this.channel = Promise.resolve("");
51519
+ this.socket = this.initialize();
51552
51520
  }
51553
- const prototype = Object.getPrototypeOf(value);
51554
- return prototype === null || prototype === Object.prototype;
51555
- }
51556
- function array(valueChecker) {
51557
- return (value, path = new Path$1()) => {
51558
- if (!Array.isArray(value)) {
51559
- return failure$1("value is not an array", path);
51560
- }
51561
- const len = value.length;
51562
- const out = new Array(len);
51563
- const warnings = [];
51564
- for (let i2 = 0; i2 < len; i2++) {
51565
- const element = value[i2];
51566
- const result = valueChecker(element, path.extend(`[${i2}]`));
51567
- if (result.type === "failure") {
51568
- return failure$1(result.message, result.path);
51521
+ initialize(isReconnect = false) {
51522
+ const url = new URL(__privateGet(this, _socketUrl));
51523
+ this.token = store.getValueSync(getTokenKey());
51524
+ url.searchParams.set("token", this.token);
51525
+ const socket = new WebSocket(url);
51526
+ __privateSet(this, _pingInterval, setInterval(() => {
51527
+ if (socket.readyState === WebSocket.OPEN) {
51528
+ socket.send(JSON.stringify(pingMessage));
51569
51529
  }
51570
- out[i2] = result.value;
51571
- if (result.warnings.length !== 0) {
51572
- warnings.push(...result.warnings);
51530
+ }, interPingInterval));
51531
+ socket.addEventListener("error", () => {
51532
+ if (__privateGet(this, _pingInterval)) {
51533
+ clearInterval(__privateGet(this, _pingInterval));
51573
51534
  }
51535
+ });
51536
+ socket.addEventListener("message", (ev) => {
51537
+ const msg = JSON.parse(ev.data);
51538
+ this.messages$.next(msg);
51539
+ });
51540
+ this.channel = new Promise((resolve) => {
51541
+ const handler = (ev) => {
51542
+ var _a;
51543
+ const msg = JSON.parse(ev.data);
51544
+ if (msg.type === "init") {
51545
+ __privateSet(this, _reconnectCount, 0);
51546
+ this.messages$.next(msg);
51547
+ socket.removeEventListener("message", handler);
51548
+ resolve((_a = msg.message) == null ? void 0 : _a.channel);
51549
+ if (this.liveReload && isReconnect) {
51550
+ window.location.reload();
51551
+ }
51552
+ }
51553
+ };
51554
+ socket.addEventListener("message", handler);
51555
+ });
51556
+ socket.addEventListener("close", this.closeHandler);
51557
+ return socket;
51558
+ }
51559
+ onClose() {
51560
+ if (__privateGet(this, _reconnectCount) >= this.maxAttempts) {
51561
+ console.error("Could not reconnect the websocket to the server");
51562
+ const handler = () => {
51563
+ if (document.visibilityState === "visible") {
51564
+ __privateSet(this, _reconnectCount, 0);
51565
+ this.socket = this.initialize();
51566
+ document.removeEventListener("visibilitychange", handler);
51567
+ }
51568
+ };
51569
+ document.addEventListener("visibilitychange", handler);
51570
+ return;
51574
51571
  }
51575
- return success$1(out, warnings);
51576
- };
51577
- }
51578
- function tuple(...checkers) {
51579
- return (value, path = new Path$1()) => {
51580
- if (!Array.isArray(value)) {
51581
- return failure$1("value is not an array", path);
51572
+ setTimeout(() => {
51573
+ __privateWrapper(this, _reconnectCount)._++;
51574
+ this.socket = this.initialize(true);
51575
+ }, interAttemptTimeout);
51576
+ }
51577
+ close() {
51578
+ if (__privateGet(this, _pingInterval)) {
51579
+ clearInterval(__privateGet(this, _pingInterval));
51582
51580
  }
51583
- const out = new Array(checkers.length);
51584
- const warnings = [];
51585
- for (const [i2, checker] of checkers.entries()) {
51586
- const result = checker(value[i2], path.extend(`[${i2}]`));
51587
- if (result.type === "failure") {
51588
- return failure$1(result.message, result.path);
51589
- }
51590
- out[i2] = result.value;
51591
- if (result.warnings.length !== 0) {
51592
- warnings.push(...result.warnings);
51593
- }
51581
+ this.socket.removeEventListener("close", this.closeHandler);
51582
+ this.socket.close();
51583
+ }
51584
+ getChannel() {
51585
+ return this.channel;
51586
+ }
51587
+ backendStoreMessages$() {
51588
+ return this.messages$.pipe(
51589
+ filter(isBackendStoreMessage),
51590
+ map$2((msg) => msg.message)
51591
+ );
51592
+ }
51593
+ backendStorePatchMessages$() {
51594
+ return this.messages$.pipe(
51595
+ filter(isBackendStorePatchMessage),
51596
+ map$2((msg) => msg.message)
51597
+ );
51598
+ }
51599
+ channel$() {
51600
+ return this.messages$.pipe(
51601
+ filter((msg) => isInitMessage(msg)),
51602
+ map$2((msg) => msg.message.channel)
51603
+ );
51604
+ }
51605
+ taskStatusUpdates$(...task_ids) {
51606
+ return this.messages$.pipe(
51607
+ filter(
51608
+ (msg) => isTaskNotification(msg) && task_ids.includes(msg.message.task_id)
51609
+ ),
51610
+ map$2((msg) => msg.message.status)
51611
+ );
51612
+ }
51613
+ progressUpdates$(...task_ids) {
51614
+ return this.messages$.pipe(
51615
+ filter(
51616
+ (msg) => isTaskNotification(msg) && msg.message.status === "PROGRESS" && task_ids.includes(msg.message.task_id)
51617
+ )
51618
+ );
51619
+ }
51620
+ serverTriggers$(dataId) {
51621
+ return this.messages$.pipe(
51622
+ filter(isServerTriggerMessage),
51623
+ filter((msg) => {
51624
+ var _a;
51625
+ return ((_a = msg.message) == null ? void 0 : _a.data_id) === dataId;
51626
+ })
51627
+ );
51628
+ }
51629
+ serverErrors$() {
51630
+ return this.messages$.pipe(filter(isServerErrorMessage));
51631
+ }
51632
+ variableRequests$() {
51633
+ return this.messages$.pipe(filter(isVariableRequestMessage));
51634
+ }
51635
+ actionMessages$(executionId) {
51636
+ return this.messages$.pipe(
51637
+ filter((msg) => isActionMessage(msg) && msg.message.uid === executionId),
51638
+ map$2((msg) => msg.message.action)
51639
+ );
51640
+ }
51641
+ customMessages$() {
51642
+ return this.messages$.pipe(filter(isCustomMessage));
51643
+ }
51644
+ waitForTask(task_id) {
51645
+ return this.messages$.pipe(
51646
+ filter(
51647
+ (msg) => {
51648
+ var _a;
51649
+ return isTaskNotification(msg) && ((_a = msg.message) == null ? void 0 : _a.task_id) === task_id && msg.message.status !== "PROGRESS";
51650
+ }
51651
+ ),
51652
+ map$2((msg) => {
51653
+ if (isTaskNotification(msg) && msg.message.status === "CANCELED") {
51654
+ throw new Error("CANCELED");
51655
+ }
51656
+ return msg;
51657
+ }),
51658
+ take(1)
51659
+ ).toPromise();
51660
+ }
51661
+ sendVariable(value, channel) {
51662
+ this.sendMessage(value, channel);
51663
+ }
51664
+ sendMessage(value, channel, chunkCount) {
51665
+ if (this.socket.readyState === WebSocket.OPEN) {
51666
+ this.socket.send(
51667
+ JSON.stringify({
51668
+ channel,
51669
+ chunk_count: chunkCount != null ? chunkCount : null,
51670
+ message: value,
51671
+ type: "message"
51672
+ })
51673
+ );
51594
51674
  }
51595
- return success$1(out, warnings);
51596
- };
51597
- }
51598
- function dict(valueChecker) {
51599
- return (value, path = new Path$1()) => {
51600
- if (typeof value !== "object" || value === null || !isPlainObject$1(value)) {
51601
- return failure$1("value is not an object", path);
51675
+ }
51676
+ updateToken(newToken) {
51677
+ this.token = newToken;
51678
+ if (this.socket.readyState === WebSocket.OPEN) {
51679
+ this.socket.send(
51680
+ JSON.stringify({
51681
+ message: newToken,
51682
+ type: "token_update"
51683
+ })
51684
+ );
51602
51685
  }
51603
- const out = {};
51604
- const warnings = [];
51605
- for (const [key, element] of Object.entries(value)) {
51606
- const result = valueChecker(element, path.extend(`.${key}`));
51607
- if (result.type === "failure") {
51608
- return failure$1(result.message, result.path);
51609
- }
51610
- out[key] = result.value;
51611
- if (result.warnings.length !== 0) {
51612
- warnings.push(...result.warnings);
51686
+ }
51687
+ sendCustomMessage(kind, data, awaitResponse = false) {
51688
+ if (this.socket.readyState === WebSocket.OPEN) {
51689
+ if (awaitResponse) {
51690
+ const rchan = nanoid();
51691
+ return new Promise((resolve) => {
51692
+ const subscription = this.customMessages$().pipe().subscribe({
51693
+ next: (msg) => {
51694
+ if (msg.message.__response_for === rchan) {
51695
+ resolve(msg);
51696
+ subscription.unsubscribe();
51697
+ }
51698
+ }
51699
+ });
51700
+ this.socket.send(
51701
+ JSON.stringify({
51702
+ message: {
51703
+ data,
51704
+ kind,
51705
+ __rchan: rchan
51706
+ },
51707
+ type: "custom"
51708
+ })
51709
+ );
51710
+ });
51613
51711
  }
51712
+ this.socket.send(
51713
+ JSON.stringify({
51714
+ message: {
51715
+ data,
51716
+ kind
51717
+ },
51718
+ type: "custom"
51719
+ })
51720
+ );
51721
+ return Promise.resolve(null);
51614
51722
  }
51615
- return success$1(out, warnings);
51616
- };
51617
- }
51618
- class OptionalProperty {
51619
- constructor(checker) {
51620
- _defineProperty(this, "checker", void 0);
51621
- this.checker = checker;
51723
+ return Promise.resolve(null);
51622
51724
  }
51623
51725
  }
51624
- function optional(checker) {
51625
- return new OptionalProperty((value, path = new Path$1()) => {
51626
- const result = checker(value, path);
51627
- if (result.type === "failure") {
51628
- return {
51629
- ...result,
51630
- message: "(optional property) " + result.message
51631
- };
51632
- } else {
51633
- return result;
51726
+ _pingInterval = new WeakMap();
51727
+ _socketUrl = new WeakMap();
51728
+ _reconnectCount = new WeakMap();
51729
+ function setupWebsocket(sessionToken, liveReload) {
51730
+ var _a;
51731
+ let { host } = window.location;
51732
+ if ((_a = window.dara) == null ? void 0 : _a.base_url) {
51733
+ const baseUrl = new URL(window.dara.base_url, window.origin);
51734
+ let { pathname } = baseUrl;
51735
+ if (pathname.endsWith("/")) {
51736
+ pathname = pathname.slice(0, -1);
51634
51737
  }
51635
- });
51636
- }
51637
- function object(checkers) {
51638
- const checkerProperties = Object.keys(checkers);
51738
+ host = baseUrl.host + pathname;
51739
+ }
51740
+ const socketUrl = `${window.location.protocol === "https:" ? "wss://" : "ws://"}${host}/api/core/ws`;
51741
+ const url = new URL(socketUrl);
51742
+ url.searchParams.set("token", sessionToken);
51743
+ return new WebSocketClient(socketUrl, sessionToken, liveReload);
51744
+ }
51745
+ function useComponentRegistry(maxRetries = 5) {
51746
+ const { componentRegistry: components, refetchComponents } = React.useContext(registriesCtx);
51747
+ const extras = useRequestExtras();
51748
+ const get2 = React.useCallback(
51749
+ async (instance) => {
51750
+ let component = null;
51751
+ let registry = { ...components };
51752
+ let i2 = 0;
51753
+ while (i2 < maxRetries) {
51754
+ if (registry && registry[instance.name]) {
51755
+ component = registry[instance.name];
51756
+ break;
51757
+ }
51758
+ if (i2 === 0) {
51759
+ const res = await request(
51760
+ `/api/core/components?name=${instance.name}`,
51761
+ { method: HTTP_METHOD.GET },
51762
+ extras
51763
+ );
51764
+ await handleAuthErrors(res, true);
51765
+ await validateResponse(res, "Failed to fetch the config for this app");
51766
+ registry = await res.json();
51767
+ } else {
51768
+ await new Promise((resolve) => setTimeout(resolve, 500));
51769
+ const { data } = await refetchComponents();
51770
+ registry = data;
51771
+ }
51772
+ i2++;
51773
+ }
51774
+ if (!component) {
51775
+ throw new Error(`Attempted to load a component (${instance.name}) that is not in the registry`);
51776
+ }
51777
+ return component;
51778
+ },
51779
+ [components]
51780
+ );
51781
+ return { get: get2 };
51782
+ }
51783
+ function useInterval(callback, delay2) {
51784
+ React.useEffect(
51785
+ () => {
51786
+ if (delay2) {
51787
+ const id = setInterval(callback, delay2 * 1e3);
51788
+ return () => clearInterval(id);
51789
+ }
51790
+ },
51791
+ useDeepCompare([delay2, callback])
51792
+ );
51793
+ }
51794
+ function usePrevious(value, initialValue) {
51795
+ const ref = React.useRef(initialValue);
51796
+ React.useEffect(() => {
51797
+ ref.current = value;
51798
+ });
51799
+ return ref.current;
51800
+ }
51801
+ function useWindowTitle(pageTitle) {
51802
+ const { data: config2 } = useConfig();
51803
+ React.useEffect(() => {
51804
+ if (!config2) {
51805
+ return;
51806
+ }
51807
+ if (!pageTitle) {
51808
+ document.title = config2.title;
51809
+ return;
51810
+ }
51811
+ document.title = `${config2.title} - ${pageTitle}`;
51812
+ }, [config2, config2 == null ? void 0 : config2.title, pageTitle]);
51813
+ }
51814
+ const all_min = "";
51815
+ const BaseRawCssInject = styled__default.default.div`
51816
+ ${(props) => props.$rawCss}
51817
+ `;
51818
+ function injectCss(component) {
51819
+ if (typeof component === "string") {
51820
+ if (component === "div") {
51821
+ return BaseRawCssInject;
51822
+ }
51823
+ return BaseRawCssInject.withComponent(component);
51824
+ }
51825
+ return styled__default.default(component)`
51826
+ ${(props) => props.$rawCss}
51827
+ `;
51828
+ }
51829
+ const Icon = injectCss("i");
51830
+ function getIcon(icon2) {
51831
+ let iconClasses = icon2;
51832
+ if (typeof icon2 === "string" && !icon2.includes("fa-")) {
51833
+ const inferredIconName = icon2.replace(/([A-Z])/g, " $1").trim().toLowerCase().split(" ").join("-");
51834
+ iconClasses = `fa-solid fa-${inferredIconName}`;
51835
+ console.warn(
51836
+ `Invalid fontawesome class string "${icon2}" provided to getIcon(). This behaviour is deprecated and will be removed in the next version, please use "dara_core.css.get_icon" method.
51837
+ Inferred class string: "${iconClasses}."`
51838
+ );
51839
+ }
51840
+ return (props) => {
51841
+ var _a;
51842
+ return /* @__PURE__ */ React__default.default.createElement(Icon, { ...props, className: `${String((_a = props.className) != null ? _a : "")} ${iconClasses}` });
51843
+ };
51844
+ }
51845
+ function flexStyles(props, displayCtx2, useDisplayContext) {
51846
+ let flexBasis = props.basis;
51847
+ let flexShrink = props.shrink;
51848
+ let flexGrow = props.grow;
51849
+ if (useDisplayContext) {
51850
+ if (props.width && displayCtx2.direction === "horizontal") {
51851
+ flexBasis != null ? flexBasis : flexBasis = props.width;
51852
+ flexShrink != null ? flexShrink : flexShrink = "0";
51853
+ flexGrow != null ? flexGrow : flexGrow = "0";
51854
+ }
51855
+ if (props.height && displayCtx2.direction === "vertical") {
51856
+ flexBasis != null ? flexBasis : flexBasis = props.height;
51857
+ flexShrink != null ? flexShrink : flexShrink = "0";
51858
+ flexGrow != null ? flexGrow : flexGrow = "0";
51859
+ }
51860
+ }
51861
+ if (props.hug || props.hug !== false && displayCtx2.hug) {
51862
+ flexBasis != null ? flexBasis : flexBasis = "content";
51863
+ flexShrink != null ? flexShrink : flexShrink = "1";
51864
+ flexGrow != null ? flexGrow : flexGrow = "0";
51865
+ }
51866
+ return { flexBasis, flexGrow, flexShrink };
51867
+ }
51868
+ function parseRawCss(rawCss) {
51869
+ const isRawObject = typeof rawCss === "object" && rawCss !== null && rawCss !== void 0;
51870
+ const componentCss = !isRawObject && typeof rawCss === "string" ? rawCss : "";
51871
+ const styles2 = isRawObject ? rawCss : {};
51872
+ return [styles2, componentCss];
51873
+ }
51874
+ function useComponentStyles(props, useDisplayContext = true) {
51875
+ const [rawStyles, rawCss] = parseRawCss(props.raw_css);
51876
+ const displayCtx$1 = React.useContext(displayCtx);
51877
+ const flexProps = flexStyles(props, displayCtx$1, useDisplayContext);
51878
+ const styles2 = React.useMemo(() => {
51879
+ var _a;
51880
+ const stylesObj = {
51881
+ backgroundColor: props.background,
51882
+ border: props.border,
51883
+ borderRadius: props.border_radius,
51884
+ color: props.color,
51885
+ fontFamily: props.font,
51886
+ fontSize: props.font_size,
51887
+ fontStyle: props.italic ? "italic" : "normal",
51888
+ fontWeight: props.bold ? "bold" : "normal",
51889
+ gap: props.gap,
51890
+ height: props.height,
51891
+ margin: props.margin,
51892
+ maxHeight: props.max_height,
51893
+ maxWidth: props.max_width,
51894
+ minHeight: props.min_height,
51895
+ minWidth: props.min_width,
51896
+ overflow: props.overflow,
51897
+ padding: props.padding,
51898
+ position: props.position,
51899
+ textDecoration: props.underline ? "underline" : "none",
51900
+ width: props.width,
51901
+ ...flexProps,
51902
+ ...rawStyles,
51903
+ ...(_a = props.style) != null ? _a : {}
51904
+ };
51905
+ return Object.fromEntries(Object.entries(stylesObj).filter(([, v2]) => v2 !== null && v2 !== void 0));
51906
+ }, [useDeepCompare(props)]);
51907
+ return [styles2, rawCss];
51908
+ }
51909
+ function useUrlSync(options) {
51910
+ const urlSerializer = React.useCallback((val) => {
51911
+ if (val === void 0 || val === null) {
51912
+ return "";
51913
+ }
51914
+ if (["string", "number", "boolean"].includes(typeof val)) {
51915
+ return String(val);
51916
+ }
51917
+ return JSON.stringify(val);
51918
+ }, []);
51919
+ const urlDeserializer = React.useCallback((val) => {
51920
+ if (val === "") {
51921
+ return void 0;
51922
+ }
51923
+ try {
51924
+ return JSON.parse(val);
51925
+ } catch {
51926
+ return val;
51927
+ }
51928
+ }, []);
51929
+ const listenChangeURL = React.useCallback((handler) => {
51930
+ const unregister = options.history.listen(() => {
51931
+ handler();
51932
+ });
51933
+ return () => unregister();
51934
+ }, []);
51935
+ const memoryOptions = {
51936
+ getURL: () => {
51937
+ return window.location.origin + options.history.location.pathname + options.history.location.search;
51938
+ },
51939
+ pushURL: (url) => {
51940
+ options.history.push(url.replace(window.location.origin, ""));
51941
+ },
51942
+ replaceURL: (url) => {
51943
+ options.history.replace(url.replace(window.location.origin, ""));
51944
+ }
51945
+ };
51946
+ return {
51947
+ browserInterface: {
51948
+ listenChangeURL,
51949
+ ...options.memory_TEST ? memoryOptions : {}
51950
+ },
51951
+ deserialize: urlDeserializer,
51952
+ location: { part: "queryParams" },
51953
+ serialize: urlSerializer
51954
+ };
51955
+ }
51956
+ const Wrapper$2 = styled__default.default.div`
51957
+ display: flex;
51958
+ align-items: center;
51959
+ justify-content: center;
51960
+
51961
+ width: 100%;
51962
+ height: 100%;
51963
+ `;
51964
+ const FlashingDots = styled__default.default.div`
51965
+ position: relative;
51966
+
51967
+ width: 10px;
51968
+ height: 10px;
51969
+
51970
+ color: ${(props) => props.theme.colors.grey4};
51971
+
51972
+ background-color: ${(props) => props.theme.colors.grey4};
51973
+ border-radius: 5px;
51974
+
51975
+ animation: dot-flashing 1s infinite linear alternate;
51976
+ animation-delay: 0.5s;
51977
+
51978
+ &::before,
51979
+ &::after {
51980
+ content: '';
51981
+ position: absolute;
51982
+ top: 0;
51983
+ display: inline-block;
51984
+ }
51985
+
51986
+ &::before {
51987
+ left: -15px;
51988
+
51989
+ width: 10px;
51990
+ height: 10px;
51991
+
51992
+ color: ${(props) => props.theme.colors.grey4};
51993
+
51994
+ background-color: ${(props) => props.theme.colors.grey4};
51995
+ border-radius: 5px;
51996
+
51997
+ animation: dot-flashing 1s infinite alternate;
51998
+ animation-delay: 0s;
51999
+ }
52000
+
52001
+ &::after {
52002
+ left: 15px;
52003
+
52004
+ width: 10px;
52005
+ height: 10px;
52006
+
52007
+ color: ${(props) => props.theme.colors.grey4};
52008
+
52009
+ background-color: ${(props) => props.theme.colors.grey4};
52010
+ border-radius: 5px;
52011
+
52012
+ animation: dot-flashing 1s infinite alternate;
52013
+ animation-delay: 1s;
52014
+ }
52015
+
52016
+ @keyframes dot-flashing {
52017
+ 0% {
52018
+ background-color: ${(props) => props.theme.colors.grey4};
52019
+ }
52020
+
52021
+ 50%,
52022
+ 100% {
52023
+ background-color: ${(props) => props.theme.colors.grey3};
52024
+ }
52025
+ }
52026
+ `;
52027
+ function Dots(props) {
52028
+ return /* @__PURE__ */ React__default.default.createElement(Wrapper$2, { className: props.className, style: props.style }, /* @__PURE__ */ React__default.default.createElement(FlashingDots, { "data-testid": "LOADING" }));
52029
+ }
52030
+ const StyledDots$1 = injectCss(Dots);
52031
+ function DefaultFallback(props) {
52032
+ const [style, css2] = useComponentStyles(props);
52033
+ return /* @__PURE__ */ React__default.default.createElement(StyledDots$1, { $rawCss: css2, style });
52034
+ }
52035
+ const Center = styled__default.default.div`
52036
+ overflow: hidden;
52037
+ display: flex;
52038
+ flex-direction: column;
52039
+ align-items: center;
52040
+ justify-content: center;
52041
+
52042
+ width: 100%;
52043
+ height: 100%;
52044
+
52045
+ background: ${(props) => props.colored ? props.theme.colors.blue1 : ""};
52046
+ `;
52047
+ const CenteredDivWithGap = styled__default.default(Center)`
52048
+ gap: 0.6rem;
52049
+ margin: 10px;
52050
+ text-align: center;
52051
+ `;
52052
+ const errorMessages = {
52053
+ "403": {
52054
+ description: "You are not authorised to access this application. Please contact the application owner to enable access.",
52055
+ styling: "error",
52056
+ title: "We were not able to authenticate you"
52057
+ },
52058
+ default: {
52059
+ description: "Your login session may have expired. Try again.",
52060
+ styling: "primary",
52061
+ title: "We were not able to authenticate you"
52062
+ }
52063
+ };
52064
+ function ErrorPage() {
52065
+ const { search } = useLocation();
52066
+ const query = React.useMemo(() => new URLSearchParams(search), [search]);
52067
+ const code = query.get("code");
52068
+ const errorConfig = code && errorMessages[code] || errorMessages.default;
52069
+ return /* @__PURE__ */ React__default.default.createElement(CenteredDivWithGap, null, /* @__PURE__ */ React__default.default.createElement("h1", null, errorConfig.title), /* @__PURE__ */ React__default.default.createElement("p", null, errorConfig.description), /* @__PURE__ */ React__default.default.createElement(Button$1, { href: "/login", styling: errorConfig.styling }, "Retry"));
52070
+ }
52071
+ function onTokenChange(cb) {
52072
+ return store.subscribe(getTokenKey(), cb);
52073
+ }
52074
+ function getSessionToken() {
52075
+ return store.getValueSync(getTokenKey());
52076
+ }
52077
+ function setSessionToken(token) {
52078
+ store.setValue(getTokenKey(), token);
52079
+ }
52080
+ function useSessionToken() {
52081
+ return React__namespace.useSyncExternalStore(onTokenChange, getSessionToken);
52082
+ }
52083
+ class EventBus {
52084
+ constructor(parentBus) {
52085
+ __privateAdd(this, _events$, new Subject());
52086
+ __privateAdd(this, _parentBus, null);
52087
+ __privateSet(this, _parentBus, parentBus != null ? parentBus : null);
52088
+ }
52089
+ publish(type, data) {
52090
+ __privateGet(this, _events$).next({ type, data });
52091
+ if (__privateGet(this, _parentBus)) {
52092
+ __privateGet(this, _parentBus).publish(type, data);
52093
+ }
52094
+ }
52095
+ subscribe(callback) {
52096
+ const sub = __privateGet(this, _events$).pipe().subscribe(callback);
52097
+ return () => sub.unsubscribe();
52098
+ }
52099
+ }
52100
+ _events$ = new WeakMap();
52101
+ _parentBus = new WeakMap();
52102
+ const DEFAULT_BUS = new EventBus();
52103
+ const EventBusContext = React__namespace.createContext(DEFAULT_BUS);
52104
+ function useEventBus() {
52105
+ return React__namespace.useContext(EventBusContext);
52106
+ }
52107
+ function EventCapturer({ children, onEvent }) {
52108
+ const parentBus = useEventBus();
52109
+ const bus = React__namespace.useMemo(() => new EventBus(parentBus), [parentBus]);
52110
+ React__namespace.useEffect(() => {
52111
+ return bus.subscribe(onEvent);
52112
+ }, [bus, onEvent]);
52113
+ return /* @__PURE__ */ React__namespace.createElement(EventBusContext.Provider, { value: bus }, children);
52114
+ }
52115
+ function useActionRegistry() {
52116
+ const { actionRegistry: actions } = React.useContext(registriesCtx);
52117
+ const get2 = React.useCallback(
52118
+ (impl) => {
52119
+ if (actions && actions[impl.name]) {
52120
+ return actions[impl.name];
52121
+ }
52122
+ throw new Error(`Attempted to load an action (${impl.name}) that is not in the registry`);
52123
+ },
52124
+ [actions]
52125
+ );
52126
+ return React.useMemo(() => ({ get: get2 }), [get2]);
52127
+ }
52128
+ const _StateSynchronizer = class {
52129
+ constructor() {
52130
+ __privateAdd(this, _observers, /* @__PURE__ */ new Map());
52131
+ }
52132
+ static getInstance() {
52133
+ if (!__privateGet(_StateSynchronizer, _instance)) {
52134
+ __privateSet(_StateSynchronizer, _instance, new _StateSynchronizer());
52135
+ }
52136
+ return __privateGet(_StateSynchronizer, _instance);
52137
+ }
52138
+ register(key, defaultValue) {
52139
+ if (!__privateGet(this, _observers).has(key)) {
52140
+ __privateGet(this, _observers).set(key, new BehaviorSubject({ type: "initial", value: defaultValue }));
52141
+ }
52142
+ }
52143
+ isRegistered(key) {
52144
+ return __privateGet(this, _observers).has(key);
52145
+ }
52146
+ getCurrentState(key) {
52147
+ if (!this.isRegistered(key)) {
52148
+ return null;
52149
+ }
52150
+ return __privateGet(this, _observers).get(key).getValue();
52151
+ }
52152
+ subscribe(key, subscription) {
52153
+ if (!this.isRegistered(key)) {
52154
+ this.register(key, null);
52155
+ }
52156
+ const sub = __privateGet(this, _observers).get(key).subscribe(subscription);
52157
+ return () => {
52158
+ sub.unsubscribe();
52159
+ if (__privateGet(this, _observers).get(key).observers.length === 0) {
52160
+ __privateGet(this, _observers).delete(key);
52161
+ }
52162
+ };
52163
+ }
52164
+ notify(key, update) {
52165
+ if (!this.isRegistered(key)) {
52166
+ this.register(key, null);
52167
+ }
52168
+ __privateGet(this, _observers).get(key).next(update);
52169
+ }
52170
+ };
52171
+ let StateSynchronizer = _StateSynchronizer;
52172
+ _instance = new WeakMap();
52173
+ _observers = new WeakMap();
52174
+ __privateAdd(StateSynchronizer, _instance, void 0);
52175
+ function getOrRegisterPlainVariable(variable, wsClient, taskContext, extras) {
52176
+ const isNested = variable.nested && variable.nested.length > 0;
52177
+ const isDefaultDerived = isDerivedVariable(variable.default);
52178
+ if (!atomFamilyRegistry.has(variable.uid)) {
52179
+ atomFamilyRegistry.set(
52180
+ variable.uid,
52181
+ Recoil_index_10({
52182
+ default: isDefaultDerived ? (extrasSerializable2) => getOrRegisterDerivedVariableValue(
52183
+ variable.default,
52184
+ wsClient,
52185
+ taskContext,
52186
+ extrasSerializable2.extras
52187
+ ) : variable.default,
52188
+ effects: (extrasSerializable2) => {
52189
+ const familySync = ({ onSet, setSelf, resetSelf, node }) => {
52190
+ if (!StateSynchronizer.getInstance().isRegistered(variable.uid)) {
52191
+ StateSynchronizer.getInstance().register(variable.uid, variable.default);
52192
+ } else {
52193
+ const currentState = StateSynchronizer.getInstance().getCurrentState(variable.uid);
52194
+ if (!isDefaultDerived || (currentState == null ? void 0 : currentState.type) !== "initial") {
52195
+ setSelf(currentState == null ? void 0 : currentState.value);
52196
+ }
52197
+ }
52198
+ const unsub = StateSynchronizer.getInstance().subscribe(variable.uid, (update) => {
52199
+ if (update.type === "initial") {
52200
+ return;
52201
+ }
52202
+ if (update.nodeKey === node.key) {
52203
+ return;
52204
+ }
52205
+ if (update.isReset) {
52206
+ resetSelf();
52207
+ } else {
52208
+ setSelf(update.value);
52209
+ }
52210
+ });
52211
+ onSet((newValue, oldValue, isReset) => {
52212
+ StateSynchronizer.getInstance().notify(variable.uid, {
52213
+ isReset,
52214
+ nodeKey: node.key,
52215
+ oldValue,
52216
+ type: "update",
52217
+ value: newValue
52218
+ });
52219
+ });
52220
+ return unsub;
52221
+ };
52222
+ const effects = [familySync];
52223
+ const storeEffect = getEffect(variable);
52224
+ if (storeEffect) {
52225
+ effects.push(storeEffect(variable, extrasSerializable2, wsClient, taskContext));
52226
+ } else {
52227
+ if (variable.persist_value || isEmbedded()) {
52228
+ effects.push(
52229
+ STORES.BrowserStore.effect(variable, extrasSerializable2, wsClient, taskContext)
52230
+ );
52231
+ }
52232
+ }
52233
+ return effects;
52234
+ },
52235
+ key: variable.uid
52236
+ })
52237
+ );
52238
+ }
52239
+ const family = atomFamilyRegistry.get(variable.uid);
52240
+ const extrasSerializable = new RequestExtrasSerializable(extras);
52241
+ const atomInstance = family(extrasSerializable);
52242
+ if (!atomFamilyMembersRegistry.has(family)) {
52243
+ atomFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
52244
+ }
52245
+ atomFamilyMembersRegistry.get(family).set(extrasSerializable.toJSON(), atomInstance);
52246
+ if (isNested) {
52247
+ const key = getRegistryKey(variable, "selector");
52248
+ if (!selectorFamilyRegistry.has(key)) {
52249
+ selectorFamilyRegistry.set(
52250
+ key,
52251
+ Recoil_index_11({
52252
+ get: (currentExtras) => ({ get: get2 }) => {
52253
+ const variableValue = get2(family(currentExtras));
52254
+ return resolveNested(
52255
+ variableValue,
52256
+ variable.nested.map((n2) => String(n2))
52257
+ );
52258
+ },
52259
+ key,
52260
+ set: (currentExtras) => ({ set: set2 }, newValue) => {
52261
+ set2(
52262
+ family(currentExtras),
52263
+ (v2) => setNested(
52264
+ v2,
52265
+ variable.nested.map((n2) => String(n2)),
52266
+ newValue
52267
+ )
52268
+ );
52269
+ }
52270
+ })
52271
+ );
52272
+ }
52273
+ const selectorFamilyInstance = selectorFamilyRegistry.get(key);
52274
+ return selectorFamilyInstance(extrasSerializable);
52275
+ }
52276
+ return atomInstance;
52277
+ }
52278
+ function err(message) {
52279
+ const error = new Error(message);
52280
+ if (error.stack === void 0) {
52281
+ try {
52282
+ throw error;
52283
+ } catch (_) {
52284
+ }
52285
+ }
52286
+ return error;
52287
+ }
52288
+ var err_1 = err;
52289
+ var Recoil_err = err_1;
52290
+ function raiseError(suffix, resultFailure) {
52291
+ if (resultFailure != null) {
52292
+ const path = resultFailure.path.toString();
52293
+ const message = resultFailure.message;
52294
+ throw Recoil_err(`[refine.js (path=${path}, message=${message})]: ${suffix}`);
52295
+ }
52296
+ throw Recoil_err(`[refine.js (null result)]: ${suffix}`);
52297
+ }
52298
+ function assertion(checker, errorMessage = "assertion error") {
52299
+ return (value) => {
52300
+ const result = checker(value);
52301
+ return result.type === "success" ? result.value : raiseError(errorMessage, result);
52302
+ };
52303
+ }
52304
+ function coercion(checker, onResult) {
52305
+ return (value) => {
52306
+ const result = checker(value);
52307
+ if (onResult != null) {
52308
+ onResult(result);
52309
+ }
52310
+ return result.type === "success" ? result.value : null;
52311
+ };
52312
+ }
52313
+ var Refine_API = {
52314
+ assertion,
52315
+ coercion
52316
+ };
52317
+ function _defineProperty(obj, key, value) {
52318
+ if (key in obj) {
52319
+ Object.defineProperty(obj, key, {
52320
+ value,
52321
+ enumerable: true,
52322
+ configurable: true,
52323
+ writable: true
52324
+ });
52325
+ } else {
52326
+ obj[key] = value;
52327
+ }
52328
+ return obj;
52329
+ }
52330
+ class Path {
52331
+ constructor(parent = null, field = "<root>") {
52332
+ _defineProperty(this, "parent", void 0);
52333
+ _defineProperty(this, "field", void 0);
52334
+ this.parent = parent;
52335
+ this.field = field;
52336
+ }
52337
+ extend(field) {
52338
+ return new Path(this, field);
52339
+ }
52340
+ toString() {
52341
+ const pieces = [];
52342
+ let current = this;
52343
+ while (current != null) {
52344
+ const {
52345
+ field,
52346
+ parent
52347
+ } = current;
52348
+ pieces.push(field);
52349
+ current = parent;
52350
+ }
52351
+ return pieces.reverse().join("");
52352
+ }
52353
+ }
52354
+ function success(value, warnings) {
52355
+ return {
52356
+ type: "success",
52357
+ value,
52358
+ warnings
52359
+ };
52360
+ }
52361
+ function failure(message, path) {
52362
+ return {
52363
+ type: "failure",
52364
+ message,
52365
+ path
52366
+ };
52367
+ }
52368
+ function compose(checker, next) {
52369
+ return (value, path = new Path()) => {
52370
+ const result = checker(value, path);
52371
+ return result.type === "failure" ? result : next(result, path);
52372
+ };
52373
+ }
52374
+ var Refine_Checkers = {
52375
+ Path,
52376
+ success,
52377
+ failure,
52378
+ compose
52379
+ };
52380
+ var Refine_Checkers_1 = Refine_Checkers.Path;
52381
+ var Refine_Checkers_2 = Refine_Checkers.success;
52382
+ var Refine_Checkers_3 = Refine_Checkers.failure;
52383
+ var Refine_Checkers_4 = Refine_Checkers.compose;
52384
+ var Refine_Checkers$1 = /* @__PURE__ */ Object.freeze({
52385
+ __proto__: null,
52386
+ Path: Refine_Checkers_1,
52387
+ success: Refine_Checkers_2,
52388
+ failure: Refine_Checkers_3,
52389
+ compose: Refine_Checkers_4
52390
+ });
52391
+ const {
52392
+ Path: Path$1,
52393
+ compose: compose$1,
52394
+ failure: failure$1,
52395
+ success: success$1
52396
+ } = Refine_Checkers$1;
52397
+ function isPlainObject$1(value) {
52398
+ if (Object.prototype.toString.call(value) !== "[object Object]") {
52399
+ return false;
52400
+ }
52401
+ const prototype = Object.getPrototypeOf(value);
52402
+ return prototype === null || prototype === Object.prototype;
52403
+ }
52404
+ function array(valueChecker) {
52405
+ return (value, path = new Path$1()) => {
52406
+ if (!Array.isArray(value)) {
52407
+ return failure$1("value is not an array", path);
52408
+ }
52409
+ const len = value.length;
52410
+ const out = new Array(len);
52411
+ const warnings = [];
52412
+ for (let i2 = 0; i2 < len; i2++) {
52413
+ const element = value[i2];
52414
+ const result = valueChecker(element, path.extend(`[${i2}]`));
52415
+ if (result.type === "failure") {
52416
+ return failure$1(result.message, result.path);
52417
+ }
52418
+ out[i2] = result.value;
52419
+ if (result.warnings.length !== 0) {
52420
+ warnings.push(...result.warnings);
52421
+ }
52422
+ }
52423
+ return success$1(out, warnings);
52424
+ };
52425
+ }
52426
+ function tuple(...checkers) {
52427
+ return (value, path = new Path$1()) => {
52428
+ if (!Array.isArray(value)) {
52429
+ return failure$1("value is not an array", path);
52430
+ }
52431
+ const out = new Array(checkers.length);
52432
+ const warnings = [];
52433
+ for (const [i2, checker] of checkers.entries()) {
52434
+ const result = checker(value[i2], path.extend(`[${i2}]`));
52435
+ if (result.type === "failure") {
52436
+ return failure$1(result.message, result.path);
52437
+ }
52438
+ out[i2] = result.value;
52439
+ if (result.warnings.length !== 0) {
52440
+ warnings.push(...result.warnings);
52441
+ }
52442
+ }
52443
+ return success$1(out, warnings);
52444
+ };
52445
+ }
52446
+ function dict(valueChecker) {
52447
+ return (value, path = new Path$1()) => {
52448
+ if (typeof value !== "object" || value === null || !isPlainObject$1(value)) {
52449
+ return failure$1("value is not an object", path);
52450
+ }
52451
+ const out = {};
52452
+ const warnings = [];
52453
+ for (const [key, element] of Object.entries(value)) {
52454
+ const result = valueChecker(element, path.extend(`.${key}`));
52455
+ if (result.type === "failure") {
52456
+ return failure$1(result.message, result.path);
52457
+ }
52458
+ out[key] = result.value;
52459
+ if (result.warnings.length !== 0) {
52460
+ warnings.push(...result.warnings);
52461
+ }
52462
+ }
52463
+ return success$1(out, warnings);
52464
+ };
52465
+ }
52466
+ class OptionalProperty {
52467
+ constructor(checker) {
52468
+ _defineProperty(this, "checker", void 0);
52469
+ this.checker = checker;
52470
+ }
52471
+ }
52472
+ function optional(checker) {
52473
+ return new OptionalProperty((value, path = new Path$1()) => {
52474
+ const result = checker(value, path);
52475
+ if (result.type === "failure") {
52476
+ return {
52477
+ ...result,
52478
+ message: "(optional property) " + result.message
52479
+ };
52480
+ } else {
52481
+ return result;
52482
+ }
52483
+ });
52484
+ }
52485
+ function object(checkers) {
52486
+ const checkerProperties = Object.keys(checkers);
51639
52487
  return (value, path = new Path$1()) => {
51640
52488
  if (typeof value !== "object" || value === null || !isPlainObject$1(value)) {
51641
52489
  return failure$1("value is not an object", path);
@@ -51893,500 +52741,218 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
51893
52741
  if (a2.type === "success") {
51894
52742
  return success$3(a2.value, a2.warnings);
51895
52743
  }
51896
- const b2 = bChecker(value, path);
51897
- if (b2.type === "success") {
51898
- return success$3(b2.value, b2.warnings);
51899
- }
51900
- return unionFailure("value did not match any types in or()", path, [a2, b2]);
51901
- };
51902
- }
51903
- function union(...checkers) {
51904
- return (value, path = new Path$3()) => {
51905
- const failures = [];
51906
- for (const checker of checkers) {
51907
- const result = checker(value, path);
51908
- if (result.type === "success") {
51909
- return success$3(result.value, result.warnings);
51910
- }
51911
- failures.push(result);
51912
- }
51913
- return unionFailure("value did not match any types in union", path, failures);
51914
- };
51915
- }
51916
- function match(...checkers) {
51917
- return union(...checkers);
51918
- }
51919
- function nullable(checker, options) {
51920
- const {
51921
- nullWithWarningWhenInvalid = false
51922
- } = options !== null && options !== void 0 ? options : {};
51923
- return (value, parentPath = new Path$3()) => {
51924
- if (value == null) {
51925
- return success$3(value, []);
51926
- }
51927
- const result = checker(value, parentPath);
51928
- if (result.type === "success") {
51929
- return success$3(result.value, result.warnings);
51930
- }
51931
- if (nullWithWarningWhenInvalid) {
51932
- return success$3(null, [result]);
51933
- }
51934
- const {
51935
- message,
51936
- path
51937
- } = result;
51938
- return failure$3(message, path);
51939
- };
51940
- }
51941
- function voidable(checker, options) {
51942
- const {
51943
- undefinedWithWarningWhenInvalid = false
51944
- } = options !== null && options !== void 0 ? options : {};
51945
- return (value, parentPath = new Path$3()) => {
51946
- if (value === void 0) {
51947
- return success$3(void 0, []);
51948
- }
51949
- const result = checker(value, parentPath);
51950
- if (result.type === "success") {
51951
- return success$3(result.value, result.warnings);
51952
- }
51953
- if (undefinedWithWarningWhenInvalid) {
51954
- return success$3(void 0, [result]);
51955
- }
51956
- const {
51957
- message,
51958
- path
51959
- } = result;
51960
- return failure$3(message, path);
51961
- };
51962
- }
51963
- function withDefault(checker, fallback) {
51964
- return (value, path = new Path$3()) => {
51965
- if (value == null) {
51966
- return success$3(fallback, []);
51967
- }
51968
- const result = checker(value, path);
51969
- return result.type === "failure" || result.value != null ? result : success$3(fallback, []);
51970
- };
51971
- }
51972
- function constraint(checker, predicate) {
51973
- return compose$3(checker, ({
51974
- value,
51975
- warnings
51976
- }, path) => {
51977
- const result = predicate(value);
51978
- const [passed, message] = typeof result === "boolean" ? [result, "value failed constraint check"] : result;
51979
- return passed ? success$3(value, warnings) : failure$3(message, path);
51980
- });
51981
- }
51982
- function lazy(getChecker) {
51983
- return (value, path = new Path$3()) => {
51984
- const checker = getChecker();
51985
- return checker(value, path);
51986
- };
51987
- }
51988
- function custom(checkValue, failureMessage = `failed to return non-null from custom checker.`) {
51989
- return (value, path = new Path$3()) => {
51990
- try {
51991
- const checked = checkValue(value);
51992
- return checked != null ? success$3(checked, []) : failure$3(failureMessage, path);
51993
- } catch (error) {
51994
- return failure$3(error.message, path);
51995
- }
51996
- };
51997
- }
51998
- var Refine_UtilityCheckers = {
51999
- or,
52000
- union,
52001
- match,
52002
- nullable,
52003
- voidable,
52004
- withDefault,
52005
- constraint,
52006
- asType,
52007
- lazy,
52008
- custom
52009
- };
52010
- const {
52011
- assertion: assertion$2,
52012
- coercion: coercion$1
52013
- } = Refine_API;
52014
- const {
52015
- Path: Path$4
52016
- } = Refine_Checkers$1;
52017
- const {
52018
- array: array$1,
52019
- dict: dict$1,
52020
- map: map$1,
52021
- object: object$1,
52022
- optional: optional$1,
52023
- set: set$1$1,
52024
- tuple: tuple$1,
52025
- writableArray: writableArray$1,
52026
- writableDict: writableDict$1,
52027
- writableObject: writableObject$1
52028
- } = Refine_ContainerCheckers$1;
52029
- const {
52030
- jsonParser: jsonParser$1,
52031
- jsonParserEnforced: jsonParserEnforced$1
52032
- } = Refine_JSON;
52033
- const {
52034
- bool: bool$1,
52035
- date: date$1,
52036
- jsonDate: jsonDate$1,
52037
- literal: literal$1,
52038
- mixed: mixed$1,
52039
- number: number$1,
52040
- string: string$1,
52041
- stringLiterals: stringLiterals$1
52042
- } = Refine_PrimitiveCheckers;
52043
- const {
52044
- asType: asType$1,
52045
- constraint: constraint$1,
52046
- custom: custom$1,
52047
- lazy: lazy$1,
52048
- match: match$1,
52049
- nullable: nullable$1,
52050
- or: or$1,
52051
- union: union$1,
52052
- voidable: voidable$1,
52053
- withDefault: withDefault$1
52054
- } = Refine_UtilityCheckers;
52055
- var Refine_index = {
52056
- assertion: assertion$2,
52057
- coercion: coercion$1,
52058
- jsonParser: jsonParser$1,
52059
- jsonParserEnforced: jsonParserEnforced$1,
52060
- Path: Path$4,
52061
- mixed: mixed$1,
52062
- literal: literal$1,
52063
- bool: bool$1,
52064
- number: number$1,
52065
- string: string$1,
52066
- stringLiterals: stringLiterals$1,
52067
- date: date$1,
52068
- jsonDate: jsonDate$1,
52069
- asType: asType$1,
52070
- or: or$1,
52071
- union: union$1,
52072
- match: match$1,
52073
- nullable: nullable$1,
52074
- voidable: voidable$1,
52075
- withDefault: withDefault$1,
52076
- constraint: constraint$1,
52077
- lazy: lazy$1,
52078
- custom: custom$1,
52079
- array: array$1,
52080
- tuple: tuple$1,
52081
- dict: dict$1,
52082
- object: object$1,
52083
- optional: optional$1,
52084
- set: set$1$1,
52085
- map: map$1,
52086
- writableArray: writableArray$1,
52087
- writableDict: writableDict$1,
52088
- writableObject: writableObject$1
52089
- };
52090
- var Refine_index_6 = Refine_index.mixed;
52091
- function getOrRegisterUrlVariable(variable) {
52092
- if (!atomRegistry.has(variable.uid)) {
52093
- atomRegistry.set(
52094
- variable.uid,
52095
- Recoil_index_8({
52096
- default: variable.default,
52097
- effects: [
52098
- RecoilSync_index_6({ history: "push", itemKey: variable.query, refine: Refine_index_6(), syncDefault: true })
52099
- ],
52100
- key: variable.uid
52101
- })
52102
- );
52103
- }
52104
- return atomRegistry.get(variable.uid);
52105
- }
52106
- function useUrlVariable(variable) {
52107
- return Recoil_index_22(getOrRegisterUrlVariable(variable));
52108
- }
52109
- const interAttemptTimeout = 500;
52110
- const maxDisconnectedTime = 1e4;
52111
- const interPingInterval = 5e3;
52112
- const maxAttempts = Math.round(maxDisconnectedTime / interAttemptTimeout);
52113
- function isInitMessage(message) {
52114
- return message.type === "init";
52115
- }
52116
- function isTaskNotification(message) {
52117
- return message.type === "message" && "status" in message.message && "task_id" in message.message;
52118
- }
52119
- function isServerTriggerMessage(message) {
52120
- return message.type === "message" && "data_id" in message.message;
52121
- }
52122
- function isServerErrorMessage(message) {
52123
- return message.type === "message" && "error" in message.message;
52124
- }
52125
- function isVariableRequestMessage(message) {
52126
- return message.type === "message" && "variable" in message.message;
52127
- }
52128
- function isActionMessage(message) {
52129
- return message.type === "message" && "action" in message.message;
52130
- }
52131
- function isBackendStoreMessage(message) {
52132
- return message.type === "message" && "store_uid" in message.message && "value" in message.message;
52133
- }
52134
- function isBackendStorePatchMessage(message) {
52135
- return message.type === "message" && "store_uid" in message.message && "patches" in message.message;
52136
- }
52137
- function isCustomMessage(message) {
52138
- return message.type === "custom";
52139
- }
52140
- const pingMessage = {
52141
- message: null,
52142
- type: "ping"
52143
- };
52144
- class WebSocketClient {
52145
- constructor(_socketUrl2, _token, _liveReload = false) {
52146
- __publicField(this, "channel");
52147
- __publicField(this, "messages$");
52148
- __publicField(this, "socket");
52149
- __publicField(this, "token");
52150
- __publicField(this, "liveReload");
52151
- __publicField(this, "closeHandler");
52152
- __publicField(this, "maxAttempts");
52153
- __privateAdd(this, _pingInterval, void 0);
52154
- __privateAdd(this, _socketUrl, void 0);
52155
- __privateAdd(this, _reconnectCount, void 0);
52156
- this.token = _token;
52157
- this.liveReload = _liveReload;
52158
- this.messages$ = new Subject();
52159
- this.closeHandler = this.onClose.bind(this);
52160
- this.maxAttempts = maxAttempts;
52161
- __privateSet(this, _socketUrl, _socketUrl2);
52162
- __privateSet(this, _reconnectCount, 0);
52163
- __privateSet(this, _pingInterval, null);
52164
- this.channel = Promise.resolve("");
52165
- this.socket = this.initialize();
52166
- }
52167
- initialize(isReconnect = false) {
52168
- const url = new URL(__privateGet(this, _socketUrl));
52169
- this.token = store.getValueSync(getTokenKey());
52170
- url.searchParams.set("token", this.token);
52171
- const socket = new WebSocket(url);
52172
- __privateSet(this, _pingInterval, setInterval(() => {
52173
- if (socket.readyState === WebSocket.OPEN) {
52174
- socket.send(JSON.stringify(pingMessage));
52175
- }
52176
- }, interPingInterval));
52177
- socket.addEventListener("error", () => {
52178
- if (__privateGet(this, _pingInterval)) {
52179
- clearInterval(__privateGet(this, _pingInterval));
52180
- }
52181
- });
52182
- socket.addEventListener("message", (ev) => {
52183
- const msg = JSON.parse(ev.data);
52184
- this.messages$.next(msg);
52185
- });
52186
- this.channel = new Promise((resolve) => {
52187
- const handler = (ev) => {
52188
- var _a;
52189
- const msg = JSON.parse(ev.data);
52190
- if (msg.type === "init") {
52191
- __privateSet(this, _reconnectCount, 0);
52192
- this.messages$.next(msg);
52193
- socket.removeEventListener("message", handler);
52194
- resolve((_a = msg.message) == null ? void 0 : _a.channel);
52195
- if (this.liveReload && isReconnect) {
52196
- window.location.reload();
52197
- }
52198
- }
52199
- };
52200
- socket.addEventListener("message", handler);
52201
- });
52202
- socket.addEventListener("close", this.closeHandler);
52203
- return socket;
52204
- }
52205
- onClose() {
52206
- if (__privateGet(this, _reconnectCount) >= this.maxAttempts) {
52207
- console.error("Could not reconnect the websocket to the server");
52208
- const handler = () => {
52209
- if (document.visibilityState === "visible") {
52210
- __privateSet(this, _reconnectCount, 0);
52211
- this.socket = this.initialize();
52212
- document.removeEventListener("visibilitychange", handler);
52213
- }
52214
- };
52215
- document.addEventListener("visibilitychange", handler);
52216
- return;
52217
- }
52218
- setTimeout(() => {
52219
- __privateWrapper(this, _reconnectCount)._++;
52220
- this.socket = this.initialize(true);
52221
- }, interAttemptTimeout);
52222
- }
52223
- close() {
52224
- if (__privateGet(this, _pingInterval)) {
52225
- clearInterval(__privateGet(this, _pingInterval));
52226
- }
52227
- this.socket.removeEventListener("close", this.closeHandler);
52228
- this.socket.close();
52229
- }
52230
- getChannel() {
52231
- return this.channel;
52232
- }
52233
- backendStoreMessages$() {
52234
- return this.messages$.pipe(
52235
- filter(isBackendStoreMessage),
52236
- map$2((msg) => msg.message)
52237
- );
52238
- }
52239
- backendStorePatchMessages$() {
52240
- return this.messages$.pipe(
52241
- filter(isBackendStorePatchMessage),
52242
- map$2((msg) => msg.message)
52243
- );
52244
- }
52245
- channel$() {
52246
- return this.messages$.pipe(
52247
- filter((msg) => isInitMessage(msg)),
52248
- map$2((msg) => msg.message.channel)
52249
- );
52250
- }
52251
- taskStatusUpdates$(...task_ids) {
52252
- return this.messages$.pipe(
52253
- filter(
52254
- (msg) => isTaskNotification(msg) && task_ids.includes(msg.message.task_id)
52255
- ),
52256
- map$2((msg) => msg.message.status)
52257
- );
52258
- }
52259
- progressUpdates$(...task_ids) {
52260
- return this.messages$.pipe(
52261
- filter(
52262
- (msg) => isTaskNotification(msg) && msg.message.status === "PROGRESS" && task_ids.includes(msg.message.task_id)
52263
- )
52264
- );
52265
- }
52266
- serverTriggers$(dataId) {
52267
- return this.messages$.pipe(
52268
- filter(isServerTriggerMessage),
52269
- filter((msg) => {
52270
- var _a;
52271
- return ((_a = msg.message) == null ? void 0 : _a.data_id) === dataId;
52272
- })
52273
- );
52274
- }
52275
- serverErrors$() {
52276
- return this.messages$.pipe(filter(isServerErrorMessage));
52277
- }
52278
- variableRequests$() {
52279
- return this.messages$.pipe(filter(isVariableRequestMessage));
52280
- }
52281
- actionMessages$(executionId) {
52282
- return this.messages$.pipe(
52283
- filter((msg) => isActionMessage(msg) && msg.message.uid === executionId),
52284
- map$2((msg) => msg.message.action)
52285
- );
52286
- }
52287
- customMessages$() {
52288
- return this.messages$.pipe(filter(isCustomMessage));
52289
- }
52290
- waitForTask(task_id) {
52291
- return this.messages$.pipe(
52292
- filter(
52293
- (msg) => {
52294
- var _a;
52295
- return isTaskNotification(msg) && ((_a = msg.message) == null ? void 0 : _a.task_id) === task_id && msg.message.status !== "PROGRESS";
52296
- }
52297
- ),
52298
- map$2((msg) => {
52299
- if (isTaskNotification(msg) && msg.message.status === "CANCELED") {
52300
- throw new Error("CANCELED");
52301
- }
52302
- return msg;
52303
- }),
52304
- take(1)
52305
- ).toPromise();
52306
- }
52307
- sendVariable(value, channel) {
52308
- this.sendMessage(value, channel);
52309
- }
52310
- sendMessage(value, channel, chunkCount) {
52311
- if (this.socket.readyState === WebSocket.OPEN) {
52312
- this.socket.send(
52313
- JSON.stringify({
52314
- channel,
52315
- chunk_count: chunkCount != null ? chunkCount : null,
52316
- message: value,
52317
- type: "message"
52318
- })
52319
- );
52320
- }
52321
- }
52322
- updateToken(newToken) {
52323
- this.token = newToken;
52324
- if (this.socket.readyState === WebSocket.OPEN) {
52325
- this.socket.send(
52326
- JSON.stringify({
52327
- message: newToken,
52328
- type: "token_update"
52329
- })
52330
- );
52331
- }
52332
- }
52333
- sendCustomMessage(kind, data, awaitResponse = false) {
52334
- if (this.socket.readyState === WebSocket.OPEN) {
52335
- if (awaitResponse) {
52336
- const rchan = nanoid();
52337
- return new Promise((resolve) => {
52338
- const subscription = this.customMessages$().pipe().subscribe({
52339
- next: (msg) => {
52340
- if (msg.message.__response_for === rchan) {
52341
- resolve(msg);
52342
- subscription.unsubscribe();
52343
- }
52344
- }
52345
- });
52346
- this.socket.send(
52347
- JSON.stringify({
52348
- message: {
52349
- data,
52350
- kind,
52351
- __rchan: rchan
52352
- },
52353
- type: "custom"
52354
- })
52355
- );
52356
- });
52744
+ const b2 = bChecker(value, path);
52745
+ if (b2.type === "success") {
52746
+ return success$3(b2.value, b2.warnings);
52747
+ }
52748
+ return unionFailure("value did not match any types in or()", path, [a2, b2]);
52749
+ };
52750
+ }
52751
+ function union(...checkers) {
52752
+ return (value, path = new Path$3()) => {
52753
+ const failures = [];
52754
+ for (const checker of checkers) {
52755
+ const result = checker(value, path);
52756
+ if (result.type === "success") {
52757
+ return success$3(result.value, result.warnings);
52357
52758
  }
52358
- this.socket.send(
52359
- JSON.stringify({
52360
- message: {
52361
- data,
52362
- kind
52363
- },
52364
- type: "custom"
52365
- })
52366
- );
52367
- return Promise.resolve(null);
52759
+ failures.push(result);
52368
52760
  }
52369
- return Promise.resolve(null);
52370
- }
52761
+ return unionFailure("value did not match any types in union", path, failures);
52762
+ };
52371
52763
  }
52372
- _pingInterval = new WeakMap();
52373
- _socketUrl = new WeakMap();
52374
- _reconnectCount = new WeakMap();
52375
- function setupWebsocket(sessionToken, liveReload) {
52376
- var _a;
52377
- let { host } = window.location;
52378
- if ((_a = window.dara) == null ? void 0 : _a.base_url) {
52379
- const baseUrl = new URL(window.dara.base_url, window.origin);
52380
- let { pathname } = baseUrl;
52381
- if (pathname.endsWith("/")) {
52382
- pathname = pathname.slice(0, -1);
52764
+ function match(...checkers) {
52765
+ return union(...checkers);
52766
+ }
52767
+ function nullable(checker, options) {
52768
+ const {
52769
+ nullWithWarningWhenInvalid = false
52770
+ } = options !== null && options !== void 0 ? options : {};
52771
+ return (value, parentPath = new Path$3()) => {
52772
+ if (value == null) {
52773
+ return success$3(value, []);
52383
52774
  }
52384
- host = baseUrl.host + pathname;
52775
+ const result = checker(value, parentPath);
52776
+ if (result.type === "success") {
52777
+ return success$3(result.value, result.warnings);
52778
+ }
52779
+ if (nullWithWarningWhenInvalid) {
52780
+ return success$3(null, [result]);
52781
+ }
52782
+ const {
52783
+ message,
52784
+ path
52785
+ } = result;
52786
+ return failure$3(message, path);
52787
+ };
52788
+ }
52789
+ function voidable(checker, options) {
52790
+ const {
52791
+ undefinedWithWarningWhenInvalid = false
52792
+ } = options !== null && options !== void 0 ? options : {};
52793
+ return (value, parentPath = new Path$3()) => {
52794
+ if (value === void 0) {
52795
+ return success$3(void 0, []);
52796
+ }
52797
+ const result = checker(value, parentPath);
52798
+ if (result.type === "success") {
52799
+ return success$3(result.value, result.warnings);
52800
+ }
52801
+ if (undefinedWithWarningWhenInvalid) {
52802
+ return success$3(void 0, [result]);
52803
+ }
52804
+ const {
52805
+ message,
52806
+ path
52807
+ } = result;
52808
+ return failure$3(message, path);
52809
+ };
52810
+ }
52811
+ function withDefault(checker, fallback) {
52812
+ return (value, path = new Path$3()) => {
52813
+ if (value == null) {
52814
+ return success$3(fallback, []);
52815
+ }
52816
+ const result = checker(value, path);
52817
+ return result.type === "failure" || result.value != null ? result : success$3(fallback, []);
52818
+ };
52819
+ }
52820
+ function constraint(checker, predicate) {
52821
+ return compose$3(checker, ({
52822
+ value,
52823
+ warnings
52824
+ }, path) => {
52825
+ const result = predicate(value);
52826
+ const [passed, message] = typeof result === "boolean" ? [result, "value failed constraint check"] : result;
52827
+ return passed ? success$3(value, warnings) : failure$3(message, path);
52828
+ });
52829
+ }
52830
+ function lazy(getChecker) {
52831
+ return (value, path = new Path$3()) => {
52832
+ const checker = getChecker();
52833
+ return checker(value, path);
52834
+ };
52835
+ }
52836
+ function custom(checkValue, failureMessage = `failed to return non-null from custom checker.`) {
52837
+ return (value, path = new Path$3()) => {
52838
+ try {
52839
+ const checked = checkValue(value);
52840
+ return checked != null ? success$3(checked, []) : failure$3(failureMessage, path);
52841
+ } catch (error) {
52842
+ return failure$3(error.message, path);
52843
+ }
52844
+ };
52845
+ }
52846
+ var Refine_UtilityCheckers = {
52847
+ or,
52848
+ union,
52849
+ match,
52850
+ nullable,
52851
+ voidable,
52852
+ withDefault,
52853
+ constraint,
52854
+ asType,
52855
+ lazy,
52856
+ custom
52857
+ };
52858
+ const {
52859
+ assertion: assertion$2,
52860
+ coercion: coercion$1
52861
+ } = Refine_API;
52862
+ const {
52863
+ Path: Path$4
52864
+ } = Refine_Checkers$1;
52865
+ const {
52866
+ array: array$1,
52867
+ dict: dict$1,
52868
+ map: map$1,
52869
+ object: object$1,
52870
+ optional: optional$1,
52871
+ set: set$1$1,
52872
+ tuple: tuple$1,
52873
+ writableArray: writableArray$1,
52874
+ writableDict: writableDict$1,
52875
+ writableObject: writableObject$1
52876
+ } = Refine_ContainerCheckers$1;
52877
+ const {
52878
+ jsonParser: jsonParser$1,
52879
+ jsonParserEnforced: jsonParserEnforced$1
52880
+ } = Refine_JSON;
52881
+ const {
52882
+ bool: bool$1,
52883
+ date: date$1,
52884
+ jsonDate: jsonDate$1,
52885
+ literal: literal$1,
52886
+ mixed: mixed$1,
52887
+ number: number$1,
52888
+ string: string$1,
52889
+ stringLiterals: stringLiterals$1
52890
+ } = Refine_PrimitiveCheckers;
52891
+ const {
52892
+ asType: asType$1,
52893
+ constraint: constraint$1,
52894
+ custom: custom$1,
52895
+ lazy: lazy$1,
52896
+ match: match$1,
52897
+ nullable: nullable$1,
52898
+ or: or$1,
52899
+ union: union$1,
52900
+ voidable: voidable$1,
52901
+ withDefault: withDefault$1
52902
+ } = Refine_UtilityCheckers;
52903
+ var Refine_index = {
52904
+ assertion: assertion$2,
52905
+ coercion: coercion$1,
52906
+ jsonParser: jsonParser$1,
52907
+ jsonParserEnforced: jsonParserEnforced$1,
52908
+ Path: Path$4,
52909
+ mixed: mixed$1,
52910
+ literal: literal$1,
52911
+ bool: bool$1,
52912
+ number: number$1,
52913
+ string: string$1,
52914
+ stringLiterals: stringLiterals$1,
52915
+ date: date$1,
52916
+ jsonDate: jsonDate$1,
52917
+ asType: asType$1,
52918
+ or: or$1,
52919
+ union: union$1,
52920
+ match: match$1,
52921
+ nullable: nullable$1,
52922
+ voidable: voidable$1,
52923
+ withDefault: withDefault$1,
52924
+ constraint: constraint$1,
52925
+ lazy: lazy$1,
52926
+ custom: custom$1,
52927
+ array: array$1,
52928
+ tuple: tuple$1,
52929
+ dict: dict$1,
52930
+ object: object$1,
52931
+ optional: optional$1,
52932
+ set: set$1$1,
52933
+ map: map$1,
52934
+ writableArray: writableArray$1,
52935
+ writableDict: writableDict$1,
52936
+ writableObject: writableObject$1
52937
+ };
52938
+ var Refine_index_6 = Refine_index.mixed;
52939
+ function getOrRegisterUrlVariable(variable) {
52940
+ if (!atomRegistry.has(variable.uid)) {
52941
+ atomRegistry.set(
52942
+ variable.uid,
52943
+ Recoil_index_8({
52944
+ default: variable.default,
52945
+ effects: [
52946
+ RecoilSync_index_6({ history: "push", itemKey: variable.query, refine: Refine_index_6(), syncDefault: true })
52947
+ ],
52948
+ key: variable.uid
52949
+ })
52950
+ );
52385
52951
  }
52386
- const socketUrl = `${window.location.protocol === "https:" ? "wss://" : "ws://"}${host}/api/core/ws`;
52387
- const url = new URL(socketUrl);
52388
- url.searchParams.set("token", sessionToken);
52389
- return new WebSocketClient(socketUrl, sessionToken, liveReload);
52952
+ return atomRegistry.get(variable.uid);
52953
+ }
52954
+ function useUrlVariable(variable) {
52955
+ return Recoil_index_22(getOrRegisterUrlVariable(variable));
52390
52956
  }
52391
52957
  function combineFilters(combinator, queries) {
52392
52958
  const validQueries = queries.filter(Boolean);
@@ -52544,17 +53110,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
52544
53110
  atomRegistry.set(variable.uid, Recoil_index_8({ default: true, key: variable.uid }));
52545
53111
  }
52546
53112
  }
52547
- function useInterval(callback, delay2) {
52548
- React.useEffect(
52549
- () => {
52550
- if (delay2) {
52551
- const id = setInterval(callback, delay2 * 1e3);
52552
- return () => clearInterval(id);
52553
- }
52554
- },
52555
- useDeepCompare([delay2, callback])
52556
- );
52557
- }
52558
53113
  function isTaskResponse$1(dvResponse) {
52559
53114
  return "task_id" in dvResponse;
52560
53115
  }
@@ -52632,9 +53187,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
52632
53187
  debouncedFetchCache[selectorKey].pipe(take(1)).subscribe(resolve, reject);
52633
53188
  });
52634
53189
  }
52635
- function resolveValue$1(value, getter) {
53190
+ function resolveValue(value, getter) {
52636
53191
  if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
52637
- const resolvedValues = value.values.map((v2) => resolveValue$1(v2, getter));
53192
+ const resolvedValues = value.values.map((v2) => resolveValue(v2, getter));
52638
53193
  return {
52639
53194
  ...value,
52640
53195
  values: resolvedValues
@@ -52656,12 +53211,15 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
52656
53211
  return isResolvedDerivedVariable(val) || isResolvedDerivedDataVariable(val) ? getDeps(val.values, val.deps).flat() : val;
52657
53212
  });
52658
53213
  }
53214
+ function useTriggerIndex(variable) {
53215
+ return Recoil_index_20(getOrRegisterTrigger(variable));
53216
+ }
52659
53217
  async function resolveDerivedValue(key, variables, deps, resolvedVariables, wsClient, get2, selfTrigger) {
52660
53218
  const triggers = registerChildTriggers(variables, wsClient, get2);
52661
53219
  if (selfTrigger) {
52662
53220
  triggers.unshift(selfTrigger);
52663
53221
  }
52664
- const values = resolvedVariables.map((v2) => resolveValue$1(v2, get2));
53222
+ const values = resolvedVariables.map((v2) => resolveValue(v2, get2));
52665
53223
  const depsValues = getDeps(values);
52666
53224
  const variableValueMap = variables.reduce((acc, v2, idx) => {
52667
53225
  if (!isVariable(v2)) {
@@ -53624,18 +54182,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
53624
54182
  escapePathComponent,
53625
54183
  unescapePathComponent
53626
54184
  });
53627
- function onTokenChange(cb) {
53628
- return store.subscribe(getTokenKey(), cb);
53629
- }
53630
- function getSessionToken() {
53631
- return store.getValueSync(getTokenKey());
53632
- }
53633
- function setSessionToken(token) {
53634
- store.setValue(getTokenKey(), token);
53635
- }
53636
- function useSessionToken() {
53637
- return React__namespace.useSyncExternalStore(onTokenChange, getSessionToken);
53638
- }
53639
54185
  const STORE_EXTRAS_MAP = /* @__PURE__ */ new Map();
53640
54186
  const STORE_VARIABLE_MAP = /* @__PURE__ */ new Map();
53641
54187
  const STORE_SEQUENCE_MAP = /* @__PURE__ */ new Map();
@@ -53775,303 +54321,117 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
53775
54321
  return () => {
53776
54322
  valueSub.unsubscribe();
53777
54323
  patchSub.unsubscribe();
53778
- };
53779
- },
53780
- [client, applyPatchesToAtoms]
53781
- );
53782
- return /* @__PURE__ */ React__namespace.createElement(RecoilSync_index_1, { listen: listenToStoreChanges, read: getStoreValue, storeKey: "BackendStore", write: syncStoreValues }, children);
53783
- }
53784
- function backendStoreEffect(variable, requestExtras) {
53785
- STORE_EXTRAS_MAP.set(variable.store.uid, requestExtras);
53786
- if (!STORE_VARIABLE_MAP.has(variable.store.uid)) {
53787
- STORE_VARIABLE_MAP.set(variable.store.uid, /* @__PURE__ */ new Set());
53788
- }
53789
- STORE_VARIABLE_MAP.get(variable.store.uid).add(variable.uid);
53790
- return RecoilSync_index_2({
53791
- itemKey: variable.store.uid,
53792
- refine: Refine_index_6(),
53793
- storeKey: "BackendStore",
53794
- write({ write: write2 }, newValue) {
53795
- if (variable.store.readonly) {
53796
- return;
53797
- }
53798
- if (newValue instanceof Recoil_index_1) {
53799
- return;
53800
- }
53801
- write2(variable.store.uid, newValue);
53802
- }
53803
- });
53804
- }
53805
- function getSessionKey(uid2) {
53806
- if (isEmbedded()) {
53807
- return `dara-session-${window.frameElement.dataset.daraPageId}-var-${uid2}`;
53808
- }
53809
- return `dara-session-${getSessionToken()}-var-${uid2}`;
53810
- }
53811
- function BrowserStoreSync({ children }) {
53812
- const getStoreValue = React__namespace.useCallback((itemKey) => {
53813
- var _a;
53814
- const key = getSessionKey(itemKey);
53815
- return JSON.parse((_a = localStorage.getItem(key)) != null ? _a : "null");
53816
- }, []);
53817
- const syncStoreValues = React__namespace.useCallback(({ diff }) => {
53818
- for (const [itemKey, value] of diff.entries()) {
53819
- const key = getSessionKey(itemKey);
53820
- localStorage.setItem(key, JSON.stringify(value));
53821
- }
53822
- }, []);
53823
- const listenToStoreChanges = React__namespace.useCallback(({ updateItem }) => {
53824
- const listener2 = (e2) => {
53825
- var _a;
53826
- if (e2.storageArea === localStorage) {
53827
- if (e2.key) {
53828
- const match2 = e2.key.match(/^dara-session-(.*)-var-(.*)$/);
53829
- if (match2) {
53830
- const [, sessionToken, uid2] = match2;
53831
- if (sessionToken === getSessionToken()) {
53832
- updateItem(uid2, JSON.parse((_a = e2.newValue) != null ? _a : "null"));
53833
- }
53834
- }
53835
- }
53836
- }
53837
- };
53838
- window.addEventListener("storage", listener2);
53839
- return () => {
53840
- window.removeEventListener("storage", listener2);
53841
- };
53842
- }, []);
53843
- return /* @__PURE__ */ React__namespace.createElement(RecoilSync_index_1, { listen: listenToStoreChanges, read: getStoreValue, storeKey: "BrowserStore", write: syncStoreValues }, children);
53844
- }
53845
- function localStorageEffect(variable, extrasSerializable, wsClient, taskContext) {
53846
- let firstRun = false;
53847
- return RecoilSync_index_2({
53848
- itemKey: variable.uid,
53849
- read: ({ read: read2 }) => {
53850
- const readValue = read2(variable.uid);
53851
- if (!firstRun) {
53852
- firstRun = true;
53853
- if (!readValue) {
53854
- const isDefaultDerived = isDerivedVariable(variable.default);
53855
- return isDefaultDerived ? getOrRegisterDerivedVariableValue(
53856
- variable.default,
53857
- wsClient,
53858
- taskContext,
53859
- extrasSerializable.extras
53860
- ) : variable.default;
53861
- }
53862
- }
53863
- return readValue;
53864
- },
53865
- refine: Refine_index_6(),
53866
- storeKey: "BrowserStore"
53867
- });
53868
- }
53869
- const STORES = {
53870
- BackendStore: {
53871
- effect: backendStoreEffect,
53872
- sync: BackendStoreSync
53873
- },
53874
- BrowserStore: {
53875
- effect: localStorageEffect,
53876
- sync: BrowserStoreSync
53877
- }
53878
- };
53879
- function getEffect(variable) {
53880
- var _a, _b, _c;
53881
- const storeName = (_a = variable.store) == null ? void 0 : _a.__typename;
53882
- if (!storeName) {
53883
- return null;
53884
- }
53885
- return (_c = (_b = STORES[storeName]) == null ? void 0 : _b.effect) != null ? _c : null;
53886
- }
53887
- function StoreProviders({ children }) {
53888
- return /* @__PURE__ */ React__namespace.createElement(BackendStoreSync, null, /* @__PURE__ */ React__namespace.createElement(BrowserStoreSync, null, children));
53889
- }
53890
- const _StateSynchronizer = class {
53891
- constructor() {
53892
- __privateAdd(this, _observers, /* @__PURE__ */ new Map());
53893
- }
53894
- static getInstance() {
53895
- if (!__privateGet(_StateSynchronizer, _instance)) {
53896
- __privateSet(_StateSynchronizer, _instance, new _StateSynchronizer());
53897
- }
53898
- return __privateGet(_StateSynchronizer, _instance);
53899
- }
53900
- register(key, defaultValue) {
53901
- if (!__privateGet(this, _observers).has(key)) {
53902
- __privateGet(this, _observers).set(key, new BehaviorSubject({ type: "initial", value: defaultValue }));
53903
- }
53904
- }
53905
- isRegistered(key) {
53906
- return __privateGet(this, _observers).has(key);
53907
- }
53908
- getCurrentState(key) {
53909
- if (!this.isRegistered(key)) {
53910
- return null;
53911
- }
53912
- return __privateGet(this, _observers).get(key).getValue();
53913
- }
53914
- subscribe(key, subscription) {
53915
- if (!this.isRegistered(key)) {
53916
- this.register(key, null);
53917
- }
53918
- const sub = __privateGet(this, _observers).get(key).subscribe(subscription);
53919
- return () => {
53920
- sub.unsubscribe();
53921
- if (__privateGet(this, _observers).get(key).observers.length === 0) {
53922
- __privateGet(this, _observers).delete(key);
53923
- }
53924
- };
53925
- }
53926
- notify(key, update) {
53927
- if (!this.isRegistered(key)) {
53928
- this.register(key, null);
53929
- }
53930
- __privateGet(this, _observers).get(key).next(update);
53931
- }
53932
- };
53933
- let StateSynchronizer = _StateSynchronizer;
53934
- _instance = new WeakMap();
53935
- _observers = new WeakMap();
53936
- __privateAdd(StateSynchronizer, _instance, void 0);
53937
- function getOrRegisterPlainVariable(variable, wsClient, taskContext, extras) {
53938
- const isNested = variable.nested && variable.nested.length > 0;
53939
- const isDefaultDerived = isDerivedVariable(variable.default);
53940
- if (!atomFamilyRegistry.has(variable.uid)) {
53941
- atomFamilyRegistry.set(
53942
- variable.uid,
53943
- Recoil_index_10({
53944
- default: isDefaultDerived ? (extrasSerializable2) => getOrRegisterDerivedVariableValue(
53945
- variable.default,
53946
- wsClient,
53947
- taskContext,
53948
- extrasSerializable2.extras
53949
- ) : variable.default,
53950
- effects: (extrasSerializable2) => {
53951
- const familySync = ({ onSet, setSelf, resetSelf, node }) => {
53952
- if (!StateSynchronizer.getInstance().isRegistered(variable.uid)) {
53953
- StateSynchronizer.getInstance().register(variable.uid, variable.default);
53954
- } else {
53955
- const currentState = StateSynchronizer.getInstance().getCurrentState(variable.uid);
53956
- if (!isDefaultDerived || (currentState == null ? void 0 : currentState.type) !== "initial") {
53957
- setSelf(currentState == null ? void 0 : currentState.value);
53958
- }
53959
- }
53960
- const unsub = StateSynchronizer.getInstance().subscribe(variable.uid, (update) => {
53961
- if (update.type === "initial") {
53962
- return;
53963
- }
53964
- if (update.nodeKey === node.key) {
53965
- return;
53966
- }
53967
- if (update.isReset) {
53968
- resetSelf();
53969
- } else {
53970
- setSelf(update.value);
53971
- }
53972
- });
53973
- onSet((newValue, oldValue, isReset) => {
53974
- StateSynchronizer.getInstance().notify(variable.uid, {
53975
- isReset,
53976
- nodeKey: node.key,
53977
- oldValue,
53978
- type: "update",
53979
- value: newValue
53980
- });
53981
- });
53982
- return unsub;
53983
- };
53984
- const effects = [familySync];
53985
- const storeEffect = getEffect(variable);
53986
- if (storeEffect) {
53987
- effects.push(storeEffect(variable, extrasSerializable2, wsClient, taskContext));
53988
- } else {
53989
- if (variable.persist_value || isEmbedded()) {
53990
- effects.push(
53991
- STORES.BrowserStore.effect(variable, extrasSerializable2, wsClient, taskContext)
53992
- );
53993
- }
53994
- }
53995
- return effects;
53996
- },
53997
- key: variable.uid
53998
- })
53999
- );
54000
- }
54001
- const family = atomFamilyRegistry.get(variable.uid);
54002
- const extrasSerializable = new RequestExtrasSerializable(extras);
54003
- const atomInstance = family(extrasSerializable);
54004
- if (!atomFamilyMembersRegistry.has(family)) {
54005
- atomFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
54324
+ };
54325
+ },
54326
+ [client, applyPatchesToAtoms]
54327
+ );
54328
+ return /* @__PURE__ */ React__namespace.createElement(RecoilSync_index_1, { listen: listenToStoreChanges, read: getStoreValue, storeKey: "BackendStore", write: syncStoreValues }, children);
54329
+ }
54330
+ function backendStoreEffect(variable, requestExtras) {
54331
+ STORE_EXTRAS_MAP.set(variable.store.uid, requestExtras);
54332
+ if (!STORE_VARIABLE_MAP.has(variable.store.uid)) {
54333
+ STORE_VARIABLE_MAP.set(variable.store.uid, /* @__PURE__ */ new Set());
54006
54334
  }
54007
- atomFamilyMembersRegistry.get(family).set(extrasSerializable.toJSON(), atomInstance);
54008
- if (isNested) {
54009
- const key = getRegistryKey(variable, "selector");
54010
- if (!selectorFamilyRegistry.has(key)) {
54011
- selectorFamilyRegistry.set(
54012
- key,
54013
- Recoil_index_11({
54014
- get: (currentExtras) => ({ get: get2 }) => {
54015
- const variableValue = get2(family(currentExtras));
54016
- return resolveNested(
54017
- variableValue,
54018
- variable.nested.map((n2) => String(n2))
54019
- );
54020
- },
54021
- key,
54022
- set: (currentExtras) => ({ set: set2 }, newValue) => {
54023
- set2(
54024
- family(currentExtras),
54025
- (v2) => setNested(
54026
- v2,
54027
- variable.nested.map((n2) => String(n2)),
54028
- newValue
54029
- )
54030
- );
54031
- }
54032
- })
54033
- );
54335
+ STORE_VARIABLE_MAP.get(variable.store.uid).add(variable.uid);
54336
+ return RecoilSync_index_2({
54337
+ itemKey: variable.store.uid,
54338
+ refine: Refine_index_6(),
54339
+ storeKey: "BackendStore",
54340
+ write({ write: write2 }, newValue) {
54341
+ if (variable.store.readonly) {
54342
+ return;
54343
+ }
54344
+ if (newValue instanceof Recoil_index_1) {
54345
+ return;
54346
+ }
54347
+ write2(variable.store.uid, newValue);
54034
54348
  }
54035
- const selectorFamilyInstance = selectorFamilyRegistry.get(key);
54036
- return selectorFamilyInstance(extrasSerializable);
54349
+ });
54350
+ }
54351
+ function getSessionKey(uid2) {
54352
+ if (isEmbedded()) {
54353
+ return `dara-session-${window.frameElement.dataset.daraPageId}-var-${uid2}`;
54037
54354
  }
54038
- return atomInstance;
54355
+ return `dara-session-${getSessionToken()}-var-${uid2}`;
54039
54356
  }
54040
- function useDeferLoadable(loadable) {
54041
- const { suspend } = useFallbackCtx();
54042
- const [availableState, setAvailableState] = React.useState(() => loadable.getValue());
54043
- const timerId = React.useRef(null);
54044
- const isFirstRender = React.useRef(true);
54045
- const [showFallback, setShowFallback] = React.useState(false);
54046
- React.useEffect(() => {
54047
- if (isFirstRender.current) {
54048
- isFirstRender.current = false;
54049
- return;
54050
- }
54051
- if (loadable.state === "loading" && typeof suspend === "number") {
54052
- timerId.current = setTimeout(() => {
54053
- setShowFallback(true);
54054
- }, suspend);
54357
+ function BrowserStoreSync({ children }) {
54358
+ const getStoreValue = React__namespace.useCallback((itemKey) => {
54359
+ var _a;
54360
+ const key = getSessionKey(itemKey);
54361
+ return JSON.parse((_a = localStorage.getItem(key)) != null ? _a : "null");
54362
+ }, []);
54363
+ const syncStoreValues = React__namespace.useCallback(({ diff }) => {
54364
+ for (const [itemKey, value] of diff.entries()) {
54365
+ const key = getSessionKey(itemKey);
54366
+ localStorage.setItem(key, JSON.stringify(value));
54055
54367
  }
54056
- return () => {
54057
- if (timerId.current) {
54058
- clearTimeout(timerId.current);
54368
+ }, []);
54369
+ const listenToStoreChanges = React__namespace.useCallback(({ updateItem }) => {
54370
+ const listener2 = (e2) => {
54371
+ var _a;
54372
+ if (e2.storageArea === localStorage) {
54373
+ if (e2.key) {
54374
+ const match2 = e2.key.match(/^dara-session-(.*)-var-(.*)$/);
54375
+ if (match2) {
54376
+ const [, sessionToken, uid2] = match2;
54377
+ if (sessionToken === getSessionToken()) {
54378
+ updateItem(uid2, JSON.parse((_a = e2.newValue) != null ? _a : "null"));
54379
+ }
54380
+ }
54381
+ }
54059
54382
  }
54060
54383
  };
54061
- }, [loadable.state, suspend]);
54062
- React.useEffect(() => {
54063
- if (loadable.state === "hasValue") {
54064
- if (timerId.current) {
54065
- clearTimeout(timerId.current);
54384
+ window.addEventListener("storage", listener2);
54385
+ return () => {
54386
+ window.removeEventListener("storage", listener2);
54387
+ };
54388
+ }, []);
54389
+ return /* @__PURE__ */ React__namespace.createElement(RecoilSync_index_1, { listen: listenToStoreChanges, read: getStoreValue, storeKey: "BrowserStore", write: syncStoreValues }, children);
54390
+ }
54391
+ function localStorageEffect(variable, extrasSerializable, wsClient, taskContext) {
54392
+ let firstRun = false;
54393
+ return RecoilSync_index_2({
54394
+ itemKey: variable.uid,
54395
+ read: ({ read: read2 }) => {
54396
+ const readValue = read2(variable.uid);
54397
+ if (!firstRun) {
54398
+ firstRun = true;
54399
+ if (!readValue) {
54400
+ const isDefaultDerived = isDerivedVariable(variable.default);
54401
+ return isDefaultDerived ? getOrRegisterDerivedVariableValue(
54402
+ variable.default,
54403
+ wsClient,
54404
+ taskContext,
54405
+ extrasSerializable.extras
54406
+ ) : variable.default;
54407
+ }
54066
54408
  }
54067
- setShowFallback(false);
54068
- setAvailableState(loadable.valueOrThrow());
54069
- }
54070
- }, [loadable]);
54071
- if (suspend === true || showFallback) {
54072
- return loadable.getValue();
54409
+ return readValue;
54410
+ },
54411
+ refine: Refine_index_6(),
54412
+ storeKey: "BrowserStore"
54413
+ });
54414
+ }
54415
+ const STORES = {
54416
+ BackendStore: {
54417
+ effect: backendStoreEffect,
54418
+ sync: BackendStoreSync
54419
+ },
54420
+ BrowserStore: {
54421
+ effect: localStorageEffect,
54422
+ sync: BrowserStoreSync
54073
54423
  }
54074
- return availableState;
54424
+ };
54425
+ function getEffect(variable) {
54426
+ var _a, _b, _c;
54427
+ const storeName = (_a = variable.store) == null ? void 0 : _a.__typename;
54428
+ if (!storeName) {
54429
+ return null;
54430
+ }
54431
+ return (_c = (_b = STORES[storeName]) == null ? void 0 : _b.effect) != null ? _c : null;
54432
+ }
54433
+ function StoreProviders({ children }) {
54434
+ return /* @__PURE__ */ React__namespace.createElement(BackendStoreSync, null, /* @__PURE__ */ React__namespace.createElement(BrowserStoreSync, null, children));
54075
54435
  }
54076
54436
  function warnUpdateOnDerivedState() {
54077
54437
  console.warn("You tried to call update on variable with derived state, this is a noop and will be ignored.");
@@ -54135,19 +54495,6 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
54135
54495
  const deferred = useDeferLoadable(loadable);
54136
54496
  return [deferred, setLoadable];
54137
54497
  }
54138
- function useActionRegistry() {
54139
- const { actionRegistry: actions } = React.useContext(registriesCtx);
54140
- const get2 = React.useCallback(
54141
- (impl) => {
54142
- if (actions && actions[impl.name]) {
54143
- return actions[impl.name];
54144
- }
54145
- throw new Error(`Attempted to load an action (${impl.name}) that is not in the registry`);
54146
- },
54147
- [actions]
54148
- );
54149
- return React.useMemo(() => ({ get: get2 }), [get2]);
54150
- }
54151
54498
  async function invokeAction(input, executionId, annotatedAction, actionCtx) {
54152
54499
  const resolvedKwargs = Object.keys(annotatedAction.dynamic_kwargs).reduce(
54153
54500
  (acc, k2) => {
@@ -54190,6 +54537,9 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
54190
54537
  }
54191
54538
  }
54192
54539
  const ACTION_HANDLER_BY_NAME = {};
54540
+ function clearActionHandlerCache_TEST() {
54541
+ Object.keys(ACTION_HANDLER_BY_NAME).forEach((k2) => delete ACTION_HANDLER_BY_NAME[k2]);
54542
+ }
54193
54543
  class UnhandledActionError extends Error {
54194
54544
  constructor(message, actionImpl) {
54195
54545
  super(message);
@@ -54334,350 +54684,42 @@ You must set sticky: 'left' | 'right' for the '${bugWithUnderColumnsSticky.Heade
54334
54684
  cbInterface.set(loadingVariable, true);
54335
54685
  }
54336
54686
  const fullActionContext = {
54337
- ...actionCtx.current,
54338
- input,
54339
- onUnhandledAction: (_a = optionsRef.current) == null ? void 0 : _a.onUnhandledAction,
54340
- gotoSnapshot: cbInterface.gotoSnapshot,
54341
- refresh: cbInterface.refresh,
54342
- reset: cbInterface.reset,
54343
- set: cbInterface.set,
54344
- snapshot: cbInterface.snapshot,
54345
- transact_UNSTABLE: cbInterface.transact_UNSTABLE
54346
- };
54347
- try {
54348
- await executeAction(input, actionToExecute, fullActionContext, getAction, importers);
54349
- } catch (error) {
54350
- console.error(error);
54351
- let message = "Try again or contact the application owner";
54352
- if (error instanceof UnhandledActionError) {
54353
- message = error.message;
54354
- }
54355
- actionCtx.current.notificationCtx.pushNotification({
54356
- key: "_actionError",
54357
- message,
54358
- status: Status.ERROR,
54359
- title: "Error executing action"
54360
- });
54361
- }
54362
- if (loadingVariable) {
54363
- cbInterface.set(loadingVariable, false);
54364
- }
54365
- }
54366
- },
54367
- [action, getAction, importers]
54368
- );
54369
- if (!action) {
54370
- return noop;
54371
- }
54372
- return callback;
54373
- }
54374
- function useComponentRegistry(maxRetries = 5) {
54375
- const { componentRegistry: components, refetchComponents } = React.useContext(registriesCtx);
54376
- const extras = useRequestExtras();
54377
- const get2 = React.useCallback(
54378
- async (instance) => {
54379
- let component = null;
54380
- let registry = { ...components };
54381
- let i2 = 0;
54382
- while (i2 < maxRetries) {
54383
- if (registry && registry[instance.name]) {
54384
- component = registry[instance.name];
54385
- break;
54386
- }
54387
- if (i2 === 0) {
54388
- const res = await request(
54389
- `/api/core/components?name=${instance.name}`,
54390
- { method: HTTP_METHOD.GET },
54391
- extras
54392
- );
54393
- await handleAuthErrors(res, true);
54394
- await validateResponse(res, "Failed to fetch the config for this app");
54395
- registry = await res.json();
54396
- } else {
54397
- await new Promise((resolve) => setTimeout(resolve, 500));
54398
- const { data } = await refetchComponents();
54399
- registry = data;
54400
- }
54401
- i2++;
54402
- }
54403
- if (!component) {
54404
- throw new Error(`Attempted to load a component (${instance.name}) that is not in the registry`);
54405
- }
54406
- return component;
54407
- },
54408
- [components]
54409
- );
54410
- return { get: get2 };
54411
- }
54412
- function useWindowTitle(pageTitle) {
54413
- const { data: config2 } = useConfig();
54414
- React.useEffect(() => {
54415
- if (!config2) {
54416
- return;
54417
- }
54418
- if (!pageTitle) {
54419
- document.title = config2.title;
54420
- return;
54421
- }
54422
- document.title = `${config2.title} - ${pageTitle}`;
54423
- }, [config2, config2 == null ? void 0 : config2.title, pageTitle]);
54424
- }
54425
- const all_min = "";
54426
- const BaseRawCssInject = styled__default.default.div`
54427
- ${(props) => props.$rawCss}
54428
- `;
54429
- function injectCss(component) {
54430
- if (typeof component === "string") {
54431
- if (component === "div") {
54432
- return BaseRawCssInject;
54433
- }
54434
- return BaseRawCssInject.withComponent(component);
54435
- }
54436
- return styled__default.default(component)`
54437
- ${(props) => props.$rawCss}
54438
- `;
54439
- }
54440
- const Icon = injectCss("i");
54441
- function getIcon(icon2) {
54442
- let iconClasses = icon2;
54443
- if (typeof icon2 === "string" && !icon2.includes("fa-")) {
54444
- const inferredIconName = icon2.replace(/([A-Z])/g, " $1").trim().toLowerCase().split(" ").join("-");
54445
- iconClasses = `fa-solid fa-${inferredIconName}`;
54446
- console.warn(
54447
- `Invalid fontawesome class string "${icon2}" provided to getIcon(). This behaviour is deprecated and will be removed in the next version, please use "dara_core.css.get_icon" method.
54448
- Inferred class string: "${iconClasses}."`
54449
- );
54450
- }
54451
- return (props) => {
54452
- var _a;
54453
- return /* @__PURE__ */ React__default.default.createElement(Icon, { ...props, className: `${String((_a = props.className) != null ? _a : "")} ${iconClasses}` });
54454
- };
54455
- }
54456
- function flexStyles(props, displayCtx2, useDisplayContext) {
54457
- let flexBasis = props.basis;
54458
- let flexShrink = props.shrink;
54459
- let flexGrow = props.grow;
54460
- if (useDisplayContext) {
54461
- if (props.width && displayCtx2.direction === "horizontal") {
54462
- flexBasis != null ? flexBasis : flexBasis = props.width;
54463
- flexShrink != null ? flexShrink : flexShrink = "0";
54464
- flexGrow != null ? flexGrow : flexGrow = "0";
54465
- }
54466
- if (props.height && displayCtx2.direction === "vertical") {
54467
- flexBasis != null ? flexBasis : flexBasis = props.height;
54468
- flexShrink != null ? flexShrink : flexShrink = "0";
54469
- flexGrow != null ? flexGrow : flexGrow = "0";
54470
- }
54471
- }
54472
- if (props.hug || props.hug !== false && displayCtx2.hug) {
54473
- flexBasis != null ? flexBasis : flexBasis = "content";
54474
- flexShrink != null ? flexShrink : flexShrink = "1";
54475
- flexGrow != null ? flexGrow : flexGrow = "0";
54476
- }
54477
- return { flexBasis, flexGrow, flexShrink };
54478
- }
54479
- function parseRawCss(rawCss) {
54480
- const isRawObject = typeof rawCss === "object" && rawCss !== null && rawCss !== void 0;
54481
- const componentCss = !isRawObject && typeof rawCss === "string" ? rawCss : "";
54482
- const styles2 = isRawObject ? rawCss : {};
54483
- return [styles2, componentCss];
54484
- }
54485
- function useComponentStyles(props, useDisplayContext = true) {
54486
- const [rawStyles, rawCss] = parseRawCss(props.raw_css);
54487
- const displayCtx$1 = React.useContext(displayCtx);
54488
- const flexProps = flexStyles(props, displayCtx$1, useDisplayContext);
54489
- const styles2 = React.useMemo(() => {
54490
- var _a;
54491
- const stylesObj = {
54492
- backgroundColor: props.background,
54493
- border: props.border,
54494
- borderRadius: props.border_radius,
54495
- color: props.color,
54496
- fontFamily: props.font,
54497
- fontSize: props.font_size,
54498
- fontStyle: props.italic ? "italic" : "normal",
54499
- fontWeight: props.bold ? "bold" : "normal",
54500
- gap: props.gap,
54501
- height: props.height,
54502
- margin: props.margin,
54503
- maxHeight: props.max_height,
54504
- maxWidth: props.max_width,
54505
- minHeight: props.min_height,
54506
- minWidth: props.min_width,
54507
- overflow: props.overflow,
54508
- padding: props.padding,
54509
- position: props.position,
54510
- textDecoration: props.underline ? "underline" : "none",
54511
- width: props.width,
54512
- ...flexProps,
54513
- ...rawStyles,
54514
- ...(_a = props.style) != null ? _a : {}
54515
- };
54516
- return Object.fromEntries(Object.entries(stylesObj).filter(([, v2]) => v2 !== null && v2 !== void 0));
54517
- }, [useDeepCompare(props)]);
54518
- return [styles2, rawCss];
54519
- }
54520
- function useUrlSync(options) {
54521
- const urlSerializer = React.useCallback((val) => {
54522
- if (val === void 0 || val === null) {
54523
- return "";
54524
- }
54525
- if (["string", "number", "boolean"].includes(typeof val)) {
54526
- return String(val);
54527
- }
54528
- return JSON.stringify(val);
54529
- }, []);
54530
- const urlDeserializer = React.useCallback((val) => {
54531
- if (val === "") {
54532
- return void 0;
54533
- }
54534
- try {
54535
- return JSON.parse(val);
54536
- } catch {
54537
- return val;
54538
- }
54539
- }, []);
54540
- const listenChangeURL = React.useCallback((handler) => {
54541
- const unregister = options.history.listen(() => {
54542
- handler();
54543
- });
54544
- return () => unregister();
54545
- }, []);
54546
- const memoryOptions = {
54547
- getURL: () => {
54548
- return window.location.origin + options.history.location.pathname + options.history.location.search;
54549
- },
54550
- pushURL: (url) => {
54551
- options.history.push(url.replace(window.location.origin, ""));
54552
- },
54553
- replaceURL: (url) => {
54554
- options.history.replace(url.replace(window.location.origin, ""));
54555
- }
54556
- };
54557
- return {
54558
- browserInterface: {
54559
- listenChangeURL,
54560
- ...options.memory_TEST ? memoryOptions : {}
54561
- },
54562
- deserialize: urlDeserializer,
54563
- location: { part: "queryParams" },
54564
- serialize: urlSerializer
54565
- };
54566
- }
54567
- const Wrapper$2 = styled__default.default.div`
54568
- display: flex;
54569
- align-items: center;
54570
- justify-content: center;
54571
-
54572
- width: 100%;
54573
- height: 100%;
54574
- `;
54575
- const FlashingDots = styled__default.default.div`
54576
- position: relative;
54577
-
54578
- width: 10px;
54579
- height: 10px;
54580
-
54581
- color: ${(props) => props.theme.colors.grey4};
54582
-
54583
- background-color: ${(props) => props.theme.colors.grey4};
54584
- border-radius: 5px;
54585
-
54586
- animation: dot-flashing 1s infinite linear alternate;
54587
- animation-delay: 0.5s;
54588
-
54589
- &::before,
54590
- &::after {
54591
- content: '';
54592
- position: absolute;
54593
- top: 0;
54594
- display: inline-block;
54595
- }
54596
-
54597
- &::before {
54598
- left: -15px;
54599
-
54600
- width: 10px;
54601
- height: 10px;
54602
-
54603
- color: ${(props) => props.theme.colors.grey4};
54604
-
54605
- background-color: ${(props) => props.theme.colors.grey4};
54606
- border-radius: 5px;
54607
-
54608
- animation: dot-flashing 1s infinite alternate;
54609
- animation-delay: 0s;
54610
- }
54611
-
54612
- &::after {
54613
- left: 15px;
54614
-
54615
- width: 10px;
54616
- height: 10px;
54617
-
54618
- color: ${(props) => props.theme.colors.grey4};
54619
-
54620
- background-color: ${(props) => props.theme.colors.grey4};
54621
- border-radius: 5px;
54622
-
54623
- animation: dot-flashing 1s infinite alternate;
54624
- animation-delay: 1s;
54625
- }
54626
-
54627
- @keyframes dot-flashing {
54628
- 0% {
54629
- background-color: ${(props) => props.theme.colors.grey4};
54630
- }
54631
-
54632
- 50%,
54633
- 100% {
54634
- background-color: ${(props) => props.theme.colors.grey3};
54635
- }
54636
- }
54637
- `;
54638
- function Dots(props) {
54639
- return /* @__PURE__ */ React__default.default.createElement(Wrapper$2, { className: props.className, style: props.style }, /* @__PURE__ */ React__default.default.createElement(FlashingDots, { "data-testid": "LOADING" }));
54640
- }
54641
- const StyledDots$1 = injectCss(Dots);
54642
- function DefaultFallback(props) {
54643
- const [style, css2] = useComponentStyles(props);
54644
- return /* @__PURE__ */ React__default.default.createElement(StyledDots$1, { $rawCss: css2, style });
54645
- }
54646
- const Center = styled__default.default.div`
54647
- overflow: hidden;
54648
- display: flex;
54649
- flex-direction: column;
54650
- align-items: center;
54651
- justify-content: center;
54652
-
54653
- width: 100%;
54654
- height: 100%;
54655
-
54656
- background: ${(props) => props.colored ? props.theme.colors.blue1 : ""};
54657
- `;
54658
- const CenteredDivWithGap = styled__default.default(Center)`
54659
- gap: 0.6rem;
54660
- margin: 10px;
54661
- text-align: center;
54662
- `;
54663
- const errorMessages = {
54664
- "403": {
54665
- description: "You are not authorised to access this application. Please contact the application owner to enable access.",
54666
- styling: "error",
54667
- title: "We were not able to authenticate you"
54668
- },
54669
- default: {
54670
- description: "Your login session may have expired. Try again.",
54671
- styling: "primary",
54672
- title: "We were not able to authenticate you"
54687
+ ...actionCtx.current,
54688
+ input,
54689
+ onUnhandledAction: (_a = optionsRef.current) == null ? void 0 : _a.onUnhandledAction,
54690
+ gotoSnapshot: cbInterface.gotoSnapshot,
54691
+ refresh: cbInterface.refresh,
54692
+ reset: cbInterface.reset,
54693
+ set: cbInterface.set,
54694
+ snapshot: cbInterface.snapshot,
54695
+ transact_UNSTABLE: cbInterface.transact_UNSTABLE
54696
+ };
54697
+ try {
54698
+ await executeAction(input, actionToExecute, fullActionContext, getAction, importers);
54699
+ } catch (error) {
54700
+ console.error(error);
54701
+ let message = "Try again or contact the application owner";
54702
+ if (error instanceof UnhandledActionError) {
54703
+ message = error.message;
54704
+ }
54705
+ actionCtx.current.notificationCtx.pushNotification({
54706
+ key: "_actionError",
54707
+ message,
54708
+ status: Status.ERROR,
54709
+ title: "Error executing action"
54710
+ });
54711
+ }
54712
+ if (loadingVariable) {
54713
+ cbInterface.set(loadingVariable, false);
54714
+ }
54715
+ }
54716
+ },
54717
+ [action, getAction, importers]
54718
+ );
54719
+ if (!action) {
54720
+ return noop;
54673
54721
  }
54674
- };
54675
- function ErrorPage() {
54676
- const { search } = useLocation();
54677
- const query = React.useMemo(() => new URLSearchParams(search), [search]);
54678
- const code = query.get("code");
54679
- const errorConfig = code && errorMessages[code] || errorMessages.default;
54680
- return /* @__PURE__ */ React__default.default.createElement(CenteredDivWithGap, null, /* @__PURE__ */ React__default.default.createElement("h1", null, errorConfig.title), /* @__PURE__ */ React__default.default.createElement("p", null, errorConfig.description), /* @__PURE__ */ React__default.default.createElement(Button$1, { href: "/login", styling: errorConfig.styling }, "Retry"));
54722
+ return callback;
54681
54723
  }
54682
54724
  function PrivateRoute({ children, on_load, name }) {
54683
54725
  const token = useSessionToken();
@@ -54704,486 +54746,42 @@ Inferred class string: "${iconClasses}."`
54704
54746
  function DynamicAuthComponent(props) {
54705
54747
  const importers = React.useContext(importersCtx);
54706
54748
  const [component, setComponent] = React.useState(() => /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
54707
- React.useEffect(() => {
54708
- const importer = importers[props.component.py_module];
54709
- if (!importer) {
54710
- throw new Error(`Missing importer for module ${props.component.py_module}`);
54711
- }
54712
- importer().then((moduleContent) => {
54713
- if (!moduleContent) {
54714
- throw new Error(`Failed to import module ${props.component.py_module}`);
54715
- }
54716
- const Component = moduleContent[props.component.js_name];
54717
- if (!Component) {
54718
- throw new Error(
54719
- `Failed to import component ${props.component.js_name} from module ${props.component.py_module}`
54720
- );
54721
- }
54722
- setComponent(/* @__PURE__ */ React__default.default.createElement(Component, null));
54723
- }).catch((err2) => {
54724
- throw new Error(`Failed to import module ${props.component.py_module}`, err2);
54725
- });
54726
- }, [props.component, importers]);
54727
- return component;
54728
- }
54729
- function AuthWrapper(props) {
54730
- const { data: authConfig, isLoading } = useAuthConfig();
54731
- const isMounted = React.useRef(false);
54732
- if (!isMounted.current) {
54733
- isMounted.current = true;
54734
- setSessionToken(getToken());
54735
- }
54736
- if (isLoading) {
54737
- return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
54738
- }
54739
- const { login, logout, ...extraRoutes } = authConfig.auth_components;
54740
- return /* @__PURE__ */ React__default.default.createElement(Switch$1, null, /* @__PURE__ */ React__default.default.createElement(Route, { path: "/login" }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component: login })), /* @__PURE__ */ React__default.default.createElement(Route, { path: "/logout" }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component: logout })), Object.entries(extraRoutes).map(([path, component]) => /* @__PURE__ */ React__default.default.createElement(Route, { key: path, path: `/${path}` }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component }))), /* @__PURE__ */ React__default.default.createElement(Route, { component: ErrorPage, path: "/error" }), /* @__PURE__ */ React__default.default.createElement(Route, { path: "/", render: () => /* @__PURE__ */ React__default.default.createElement(PrivateRoute, null, props.children) }));
54741
- }
54742
- const index = "";
54743
- const ErrorBoundaryContext = React.createContext(null);
54744
- const initialState = {
54745
- didCatch: false,
54746
- error: null
54747
- };
54748
- class ErrorBoundary extends React.Component {
54749
- constructor(props) {
54750
- super(props);
54751
- this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
54752
- this.state = initialState;
54753
- }
54754
- static getDerivedStateFromError(error) {
54755
- return {
54756
- didCatch: true,
54757
- error
54758
- };
54759
- }
54760
- resetErrorBoundary() {
54761
- const {
54762
- error
54763
- } = this.state;
54764
- if (error !== null) {
54765
- var _this$props$onReset, _this$props;
54766
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
54767
- args[_key] = arguments[_key];
54768
- }
54769
- (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
54770
- args,
54771
- reason: "imperative-api"
54772
- });
54773
- this.setState(initialState);
54774
- }
54775
- }
54776
- componentDidCatch(error, info) {
54777
- var _this$props$onError, _this$props2;
54778
- (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
54779
- }
54780
- componentDidUpdate(prevProps, prevState) {
54781
- const {
54782
- didCatch
54783
- } = this.state;
54784
- const {
54785
- resetKeys
54786
- } = this.props;
54787
- if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
54788
- var _this$props$onReset2, _this$props3;
54789
- (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
54790
- next: resetKeys,
54791
- prev: prevProps.resetKeys,
54792
- reason: "keys"
54793
- });
54794
- this.setState(initialState);
54795
- }
54796
- }
54797
- render() {
54798
- const {
54799
- children,
54800
- fallbackRender,
54801
- FallbackComponent,
54802
- fallback
54803
- } = this.props;
54804
- const {
54805
- didCatch,
54806
- error
54807
- } = this.state;
54808
- let childToRender = children;
54809
- if (didCatch) {
54810
- const props = {
54811
- error,
54812
- resetErrorBoundary: this.resetErrorBoundary
54813
- };
54814
- if (typeof fallbackRender === "function") {
54815
- childToRender = fallbackRender(props);
54816
- } else if (FallbackComponent) {
54817
- childToRender = React.createElement(FallbackComponent, props);
54818
- } else if (fallback !== void 0) {
54819
- childToRender = fallback;
54820
- } else {
54821
- throw error;
54822
- }
54823
- }
54824
- return React.createElement(ErrorBoundaryContext.Provider, {
54825
- value: {
54826
- didCatch,
54827
- error,
54828
- resetErrorBoundary: this.resetErrorBoundary
54829
- }
54830
- }, childToRender);
54831
- }
54832
- }
54833
- function hasArrayChanged() {
54834
- let a2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
54835
- let b2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
54836
- return a2.length !== b2.length || a2.some((item, index2) => !Object.is(item, b2[index2]));
54837
- }
54838
- var baseGetTag = _baseGetTag, getPrototype = _getPrototype, isObjectLike = isObjectLike_1;
54839
- var objectTag = "[object Object]";
54840
- var funcProto = Function.prototype, objectProto = Object.prototype;
54841
- var funcToString = funcProto.toString;
54842
- var hasOwnProperty = objectProto.hasOwnProperty;
54843
- var objectCtorString = funcToString.call(Object);
54844
- function isPlainObject(value) {
54845
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
54846
- return false;
54847
- }
54848
- var proto = getPrototype(value);
54849
- if (proto === null) {
54850
- return true;
54851
- }
54852
- var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
54853
- return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
54854
- }
54855
- var isPlainObject_1 = isPlainObject;
54856
- var baseSet = _baseSet;
54857
- function set(object2, path, value) {
54858
- return object2 == null ? object2 : baseSet(object2, path, value);
54859
- }
54860
- var set_1 = set;
54861
- function createMarkers(scope, loopInstanceUid) {
54862
- const markers = [];
54863
- if (scope.action) {
54864
- markers.push({ type: "action", path: scope.action });
54865
- }
54866
- if (scope.derivedVariable) {
54867
- markers.push({ type: "derived_var", path: scope.derivedVariable, loopInstanceUid });
54868
- }
54869
- if (scope.serverComponent) {
54870
- markers.push({ type: "server_component", path: scope.serverComponent, loopInstanceUid });
54871
- }
54872
- return markers;
54873
- }
54874
- function updateScope(scope, value, path) {
54875
- const newScope = { ...scope };
54876
- if (!scope.action && isAnnotatedAction(value)) {
54877
- newScope.action = path;
54878
- }
54879
- if (!scope.derivedVariable && isDerivedVariable(value)) {
54880
- newScope.derivedVariable = path;
54881
- }
54882
- if (!scope.serverComponent && isPyComponent(value)) {
54883
- newScope.serverComponent = path;
54884
- }
54885
- return newScope;
54886
- }
54887
- function getInjectionMarkers(renderer) {
54888
- const markers = [];
54889
- function walk(obj, pathSegments, scope = {}) {
54890
- for (const [key, value] of Object.entries(obj)) {
54891
- const currentPath = [...pathSegments, key];
54892
- const dotPath = currentPath.join(".");
54893
- if (isLoopVariable(value)) {
54894
- markers.push(
54895
- { path: dotPath, nested: value.nested, type: "loop_var" },
54896
- ...createMarkers(scope, value.uid)
54897
- );
54898
- continue;
54899
- }
54900
- if (isPlainObject_1(value) || Array.isArray(value)) {
54901
- const newScope = updateScope(scope, value, dotPath);
54902
- walk(value, [...pathSegments, key], newScope);
54903
- }
54904
- }
54905
- }
54906
- walk(renderer, []);
54907
- return markers;
54908
- }
54909
- function applyMarkers(renderer, markers, loopValue, itemKey) {
54910
- if (markers.length === 0) {
54911
- return renderer;
54912
- }
54913
- const clonedRenderer = cloneDeep_1(renderer);
54914
- for (const marker of markers) {
54915
- switch (marker.type) {
54916
- case "loop_var": {
54917
- set_1(clonedRenderer, marker.path, resolveNested(loopValue, marker.nested));
54918
- break;
54919
- }
54920
- case "action": {
54921
- set_1(clonedRenderer, `${marker.path}.loading.uid`, nanoid());
54922
- break;
54923
- }
54924
- case "derived_var": {
54925
- set_1(clonedRenderer, `${marker.path}.loop_instance_uid`, `${marker.loopInstanceUid}:${itemKey}`);
54926
- break;
54927
- }
54928
- case "server_component": {
54929
- set_1(clonedRenderer, `${marker.path}.loop_instance_uid`, `${marker.loopInstanceUid}:${itemKey}`);
54930
- break;
54931
- }
54932
- }
54933
- }
54934
- return clonedRenderer;
54935
- }
54936
- function hasMarkers(component) {
54937
- for (const [key, value] of Object.entries(component.props)) {
54938
- if (isLoopVariable(value)) {
54939
- return key;
54940
- }
54941
- }
54942
- return null;
54943
- }
54944
- const POLLING_INTERVAL = 100;
54945
- const FAKE_PROGRESS_INTERVAL = 100;
54946
- const ESTIMATE_RATIO = 0.85;
54947
- function estimateProgress(time, timeConstant = 10) {
54948
- return 1 - Math.exp(-1 * time / (FAKE_PROGRESS_INTERVAL * 10 * timeConstant));
54949
- }
54950
- function fakeProgressGenerator(progressStart, progressEnd, estimatedTime) {
54951
- const difference = progressEnd - progressStart;
54952
- const estimatedProgressUpdates = [];
54953
- let timeConstant = 10;
54954
- if (estimatedTime && estimatedTime !== 0) {
54955
- const estimatedDifference = ESTIMATE_RATIO * difference;
54956
- const estimatedProgressTime = ESTIMATE_RATIO * estimatedTime;
54957
- const numberOfUpdates = estimatedProgressTime / FAKE_PROGRESS_INTERVAL;
54958
- const estimatedProgressChunk = estimatedDifference / numberOfUpdates;
54959
- let t2 = 0;
54960
- let p2 = progressStart;
54961
- while (t2 < estimatedProgressTime) {
54962
- p2 += estimatedProgressChunk;
54963
- t2 += FAKE_PROGRESS_INTERVAL;
54964
- estimatedProgressUpdates.push(p2);
54965
- }
54966
- timeConstant = (1 - ESTIMATE_RATIO) * (estimatedTime / 1e3);
54967
- }
54968
- function* getNextUpdate() {
54969
- let startFrom = progressStart;
54970
- while (estimatedProgressUpdates.length > 0) {
54971
- const update = estimatedProgressUpdates.shift();
54972
- startFrom = update;
54973
- yield update;
54974
- }
54975
- let i2 = 0;
54976
- while (true) {
54977
- const estimated = estimateProgress(FAKE_PROGRESS_INTERVAL * i2, timeConstant);
54978
- yield estimated * (progressEnd - startFrom) + startFrom;
54979
- i2++;
54980
- }
54981
- }
54982
- return getNextUpdate();
54983
- }
54984
- const ProgressWrapper = styled__default.default.div`
54985
- display: flex;
54986
- flex-direction: column;
54987
- gap: 0.5rem;
54988
- padding: 1rem;
54989
- `;
54990
- const ProgressHeader = styled__default.default.h4`
54991
- font-size: 1.2rem;
54992
- `;
54993
- const ProgressMessage = styled__default.default.span`
54994
- font-size: ${(props) => props.theme.font.size};
54995
- `;
54996
- function findRunningTasks(tasksContext, variablesRef) {
54997
- var _a;
54998
- if (!(variablesRef && ((_a = variablesRef == null ? void 0 : variablesRef.current) == null ? void 0 : _a.size) > 0 && tasksContext.hasRunningTasks())) {
54999
- return [];
55000
- }
55001
- return tasksContext.getVariableTasks(...variablesRef.current.values());
55002
- }
55003
- function ProgressTracker(props) {
55004
- const taskContext = useTaskContext();
55005
- const { client: wsClient } = React.useContext(websocketCtx);
55006
- const [latestProgressUpdate, setLatestProgressUpdate] = React.useState(
55007
- null
55008
- );
55009
- const [progress, setProgress] = React.useState(null);
55010
- const fakeInterval = React.useRef(null);
55011
- const [subscribedTaskIds, setSubscribedTaskIds] = React.useState([]);
55012
- const [restartTrigger, setRestartTrigger] = React.useState(0);
55013
- React.useEffect(() => {
55014
- if (!wsClient) {
55015
- return;
55016
- }
55017
- let progressSubscription = null;
55018
- const timer2 = setInterval(() => {
55019
- const taskIds = findRunningTasks(taskContext, props.variablesRef);
55020
- if (taskIds.length > 0) {
55021
- setSubscribedTaskIds(taskIds);
55022
- progressSubscription = wsClient.progressUpdates$(...taskIds).subscribe((notif) => setLatestProgressUpdate(notif.message));
55023
- clearInterval(timer2);
55024
- }
55025
- }, POLLING_INTERVAL);
55026
- return () => {
55027
- clearInterval(timer2);
55028
- if (fakeInterval.current) {
55029
- clearInterval(fakeInterval.current);
55030
- }
55031
- progressSubscription == null ? void 0 : progressSubscription.unsubscribe();
55032
- };
55033
- }, [restartTrigger, wsClient]);
55034
- React.useEffect(() => {
55035
- if (!wsClient) {
55036
- return;
55037
- }
55038
- let subscription = null;
55039
- if (subscribedTaskIds.length > 0) {
55040
- subscription = wsClient.taskStatusUpdates$(...subscribedTaskIds).subscribe((newStatus) => {
55041
- if (newStatus === "CANCELED") {
55042
- if (fakeInterval.current) {
55043
- clearInterval(fakeInterval.current);
55044
- }
55045
- setLatestProgressUpdate(null);
55046
- setSubscribedTaskIds([]);
55047
- setProgress(null);
55048
- setRestartTrigger((v2) => v2 + 1);
55049
- }
55050
- });
55051
- }
55052
- return () => {
55053
- subscription == null ? void 0 : subscription.unsubscribe();
55054
- };
55055
- }, [subscribedTaskIds, wsClient]);
55056
- React.useEffect(() => {
55057
- var _a, _b;
55058
- if (!latestProgressUpdate) {
55059
- return;
55060
- }
55061
- if (fakeInterval.current) {
55062
- clearInterval(fakeInterval.current);
55063
- }
55064
- const shouldStartFakeProgress = latestProgressUpdate.message.startsWith("FAKE_PROGRESS__");
55065
- if (!shouldStartFakeProgress) {
55066
- setProgress({
55067
- message: latestProgressUpdate.message,
55068
- progress: latestProgressUpdate.progress
55069
- });
55070
- return;
55071
- }
55072
- const [, estimatedTime, message] = latestProgressUpdate.message.split("__");
55073
- setProgress({
55074
- message,
55075
- progress: (_a = progress == null ? void 0 : progress.progress) != null ? _a : 0
55076
- });
55077
- const progressGenerator = fakeProgressGenerator(
55078
- (_b = progress == null ? void 0 : progress.progress) != null ? _b : 0,
55079
- latestProgressUpdate.progress,
55080
- parseFloat(estimatedTime)
55081
- );
55082
- fakeInterval.current = setInterval(() => {
55083
- const nextValue = progressGenerator.next().value;
55084
- setProgress({
55085
- message,
55086
- progress: nextValue
55087
- });
55088
- }, FAKE_PROGRESS_INTERVAL);
55089
- }, [latestProgressUpdate]);
55090
- if (subscribedTaskIds.length === 0) {
55091
- return props.fallback;
55092
- }
55093
- return /* @__PURE__ */ React__default.default.createElement(ProgressWrapper, null, /* @__PURE__ */ React__default.default.createElement(ProgressHeader, null, "Task in progress"), progress && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(ProgressMessage, null, progress.message), /* @__PURE__ */ React__default.default.createElement(ProgressBar, { progress: parseFloat(progress.progress.toFixed(2)) })));
55094
- }
55095
- function isSelectorError(e2) {
55096
- return e2 !== void 0 && e2 !== null && typeof e2 === "object" && "selectorId" in e2 && "selectorExtras" in e2;
55097
- }
55098
- const StyledErrorDisplay = styled__default.default.div`
55099
- display: flex;
55100
- gap: 1rem;
55101
- align-items: center;
55102
- justify-content: space-between;
55103
-
55104
- height: min-content;
55105
- padding: 1rem;
55106
-
55107
- background-color: ${(props) => curriedTransparentize$1(0.9, props.theme.colors.error)};
55108
- border-radius: 0.25rem;
55109
- `;
55110
- const ErrorDisplayWrapper = injectCss(StyledErrorDisplay);
55111
- const IconWrapper = styled__default.default.div`
55112
- display: flex;
55113
- height: 100%;
55114
- `;
55115
- const ErrorIcon = styled__default.default.i`
55116
- line-height: 21px;
55117
- color: ${(props) => props.theme.colors.error};
55118
- `;
55119
- const ContentWrapper = styled__default.default.div`
55120
- display: flex;
55121
- flex-direction: column;
55122
- gap: 1rem;
55123
- align-items: flex-start;
55124
- `;
55125
- const ErrorContent = styled__default.default.div`
55126
- display: flex;
55127
- flex-direction: column;
55128
- gap: 0.5rem;
55129
- color: ${(props) => props.theme.colors.error};
55130
- `;
55131
- const ErrorTitle$1 = styled__default.default.h3`
55132
- display: flex;
55133
- gap: 0.375rem;
55134
-
55135
- font-size: 1rem;
55136
- font-weight: bold;
55137
- line-height: 1.375rem;
55138
- color: ${(props) => props.theme.colors.error};
55139
- `;
55140
- const ErrorText$1 = styled__default.default.span`
55141
- font-size: 1rem;
55142
- line-height: 1.375rem;
55143
- `;
55144
- const RetryButton = styled__default.default.button`
55145
- cursor: pointer;
55146
-
55147
- display: flex;
55148
- gap: 0.5rem;
55149
- align-items: center;
55150
- justify-content: center;
55151
-
55152
- width: 40px;
55153
- height: 40px;
55154
-
55155
- color: ${(props) => props.theme.colors.error};
55156
-
55157
- background-color: inherit;
55158
- border: none;
55159
- border: 1px solid;
55160
- border-color: ${(props) => props.theme.colors.error};
55161
- border-radius: 5px;
55162
-
55163
- transition-timing-function: ease;
55164
- transition-duration: 100ms;
55165
- transition-property: color, border-color;
55166
-
55167
- i {
55168
- line-height: 21px;
55169
- transition: transform 400ms ease-in-out;
55170
- }
55171
-
55172
- &:hover {
55173
- color: ${(props) => props.theme.colors.errorHover};
55174
- border-color: ${(props) => props.theme.colors.errorHover};
55175
-
55176
- i {
55177
- transform: rotate(180deg);
54749
+ React.useEffect(() => {
54750
+ const importer = importers[props.component.py_module];
54751
+ if (!importer) {
54752
+ throw new Error(`Missing importer for module ${props.component.py_module}`);
54753
+ }
54754
+ importer().then((moduleContent) => {
54755
+ if (!moduleContent) {
54756
+ throw new Error(`Failed to import module ${props.component.py_module}`);
55178
54757
  }
54758
+ const Component = moduleContent[props.component.js_name];
54759
+ if (!Component) {
54760
+ throw new Error(
54761
+ `Failed to import component ${props.component.js_name} from module ${props.component.py_module}`
54762
+ );
54763
+ }
54764
+ setComponent(/* @__PURE__ */ React__default.default.createElement(Component, null));
54765
+ }).catch((err2) => {
54766
+ throw new Error(`Failed to import module ${props.component.py_module}`, err2);
54767
+ });
54768
+ }, [props.component, importers]);
54769
+ return component;
54770
+ }
54771
+ function AuthWrapper(props) {
54772
+ const { data: authConfig, isLoading } = useAuthConfig();
54773
+ const isMounted = React.useRef(false);
54774
+ if (!isMounted.current) {
54775
+ isMounted.current = true;
54776
+ setSessionToken(getToken());
55179
54777
  }
55180
- `;
55181
- function ErrorDisplay$1(props) {
55182
- var _a, _b, _c, _d, _e2;
55183
- const [styles2, css2] = parseRawCss((_a = props.config) == null ? void 0 : _a.raw_css);
55184
- const defaultMessage = props.error instanceof UserError ? props.error.message : "Try again or contact the application owner.";
55185
- return /* @__PURE__ */ React__default.default.createElement(ErrorDisplayWrapper, { $rawCss: css2, style: styles2 }, /* @__PURE__ */ React__default.default.createElement(ContentWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorContent, null, /* @__PURE__ */ React__default.default.createElement(ErrorTitle$1, null, /* @__PURE__ */ React__default.default.createElement(IconWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorIcon, { "aria-hidden": true, className: "fa-solid fa-circle-xmark fa-lg" })), (_c = (_b = props == null ? void 0 : props.config) == null ? void 0 : _b.title) != null ? _c : "Error"), /* @__PURE__ */ React__default.default.createElement(ErrorText$1, null, (_e2 = (_d = props == null ? void 0 : props.config) == null ? void 0 : _d.description) != null ? _e2 : defaultMessage))), props.resetErrorBoundary && /* @__PURE__ */ React__default.default.createElement(RetryButton, { onClick: () => props.resetErrorBoundary(props.error), type: "button" }, /* @__PURE__ */ React__default.default.createElement("i", { "aria-hidden": true, className: "fa-solid fa-rotate fa-xl" })));
54778
+ if (isLoading) {
54779
+ return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
54780
+ }
54781
+ const { login, logout, ...extraRoutes } = authConfig.auth_components;
54782
+ return /* @__PURE__ */ React__default.default.createElement(Switch$1, null, /* @__PURE__ */ React__default.default.createElement(Route, { path: "/login" }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component: login })), /* @__PURE__ */ React__default.default.createElement(Route, { path: "/logout" }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component: logout })), Object.entries(extraRoutes).map(([path, component]) => /* @__PURE__ */ React__default.default.createElement(Route, { key: path, path: `/${path}` }, /* @__PURE__ */ React__default.default.createElement(DynamicAuthComponent, { component }))), /* @__PURE__ */ React__default.default.createElement(Route, { component: ErrorPage, path: "/error" }), /* @__PURE__ */ React__default.default.createElement(Route, { path: "/", render: () => /* @__PURE__ */ React__default.default.createElement(PrivateRoute, null, props.children) }));
55186
54783
  }
54784
+ const index = "";
55187
54785
  function useDataVariable(variable) {
55188
54786
  const extras = useRequestExtras();
55189
54787
  const { client: wsClient } = React.useContext(websocketCtx);
@@ -55300,21 +54898,6 @@ Inferred class string: "${iconClasses}."`
55300
54898
  [variable.uid, useDeepCompare(taskContext), client, search, extras]
55301
54899
  );
55302
54900
  }
55303
- function resolveValue(value, force) {
55304
- if (isResolvedDerivedVariable(value) || isResolvedDerivedDataVariable(value)) {
55305
- const { deps, ...rest } = value;
55306
- const resolvedValues = value.values.map((v2) => resolveValue(v2, force));
55307
- return {
55308
- ...rest,
55309
- force,
55310
- values: resolvedValues
55311
- };
55312
- }
55313
- if (typeof value === "function") {
55314
- return resolveValue(value(), force);
55315
- }
55316
- return value;
55317
- }
55318
54901
  function useRefreshSelector() {
55319
54902
  return Recoil_index_31(({ refresh }) => {
55320
54903
  return (key, extras) => {
@@ -55349,6 +54932,229 @@ Inferred class string: "${iconClasses}."`
55349
54932
  };
55350
54933
  }, []);
55351
54934
  }
54935
+ const Wrapper$1 = styled__default.default.div`
54936
+ display: flex;
54937
+ flex: 1 1 0%;
54938
+ flex-direction: column;
54939
+ justify-content: center;
54940
+
54941
+ min-height: 100%;
54942
+
54943
+ background: ${(props) => `radial-gradient(circle closest-corner at 50% 40%, ${curriedTransparentize$1(
54944
+ 0.9,
54945
+ props.theme.colors.background
54946
+ )} 0%, ${curriedTransparentize$1(
54947
+ 0.8,
54948
+ props.theme.colors.blue4
54949
+ )} 70%),radial-gradient(circle closest-corner at 20% 150%, ${curriedTransparentize$1(
54950
+ 0.8,
54951
+ props.theme.colors.error
54952
+ )} 0%, ${curriedTransparentize$1(0.2, props.theme.colors.blue4)} 230%)`};
54953
+ `;
54954
+ const Card = styled__default.default.div`
54955
+ padding: 1.5rem;
54956
+
54957
+ color: ${(props) => props.theme.colors.text};
54958
+
54959
+ background-color: ${(props) => props.theme.colors.blue1};
54960
+ border-radius: 1rem;
54961
+ box-shadow: ${(props) => props.theme.shadow.medium};
54962
+
54963
+ @media (width >= 640px) {
54964
+ width: 100%;
54965
+ max-width: 24rem;
54966
+ margin-right: auto;
54967
+ margin-left: auto;
54968
+ }
54969
+ `;
54970
+ const FormWrapper = styled__default.default.div`
54971
+ margin-top: 1.5rem;
54972
+ `;
54973
+ const Form = styled__default.default.form`
54974
+ > * + * {
54975
+ margin-top: 1.5rem;
54976
+ }
54977
+ `;
54978
+ const ErrorText$1 = styled__default.default.h3`
54979
+ margin: 0;
54980
+
54981
+ font-size: 0.875rem;
54982
+ font-weight: 500;
54983
+ line-height: 1.25rem;
54984
+ color: ${(props) => props.theme.colors.error};
54985
+ letter-spacing: 0.025em;
54986
+
54987
+ visibility: ${(props) => props.$hidden ? "hidden" : "visible"};
54988
+ `;
54989
+ const Label = styled__default.default.label`
54990
+ font-weight: 500;
54991
+ line-height: 1.5rem;
54992
+ `;
54993
+ const StyledInput = styled__default.default.input`
54994
+ display: flex;
54995
+ display: block;
54996
+ align-items: center;
54997
+
54998
+ width: 100%;
54999
+ height: 2.5rem;
55000
+ margin-top: 0.5rem;
55001
+ padding: 0 1rem;
55002
+
55003
+ font-size: 1rem;
55004
+ line-height: 1.5rem;
55005
+ color: ${(props) => props.theme.colors.text};
55006
+
55007
+ background-color: ${(props) => props.theme.colors.blue1};
55008
+ border: none;
55009
+ border-radius: 0.25rem;
55010
+ outline: none;
55011
+ box-shadow:
55012
+ inset 0 0 0 0 ${(props) => props.theme.colors.blue1},
55013
+ inset 0 0 0 1px ${(props) => props.$error ? props.theme.colors.error : props.theme.colors.grey2},
55014
+ 0 1px 2px 0 rgb(0 0 0 / 5%);
55015
+
55016
+ :active,
55017
+ :focus {
55018
+ box-shadow:
55019
+ inset 0 0 0 0 ${(props) => props.theme.colors.blue1},
55020
+ inset 0 0 0 2px ${(props) => props.$error ? props.theme.colors.error : props.theme.colors.primary},
55021
+ 0 1px 2px 0 rgb(0 0 0 / 5%);
55022
+ }
55023
+ `;
55024
+ const StyledButton = styled__default.default(Button$1)`
55025
+ width: 100%;
55026
+ font-weight: 600;
55027
+ line-height: 1.5rem;
55028
+ box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);
55029
+
55030
+ :active,
55031
+ :focus {
55032
+ outline-color: ${(props) => props.theme.colors.primary};
55033
+ outline-width: 2px;
55034
+ outline-offset: 2px;
55035
+ }
55036
+ `;
55037
+ function BasicAuthLogin() {
55038
+ var _a;
55039
+ const [isVerifyingToken, setIsVerifyingToken] = React.useState(true);
55040
+ const [isLoggingIn, setIsLoggingIn] = React.useState(false);
55041
+ const [username, setUsername] = React.useState("");
55042
+ const [password, setPassword] = React.useState("");
55043
+ const [isError2, setIsError] = React.useState(false);
55044
+ const history2 = useHistory();
55045
+ const location2 = useLocation();
55046
+ const queryParams = new URLSearchParams(location2.search);
55047
+ const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
55048
+ const login = async () => {
55049
+ setIsLoggingIn(true);
55050
+ setIsError(false);
55051
+ try {
55052
+ const sessionToken = await requestSessionToken({ password, username });
55053
+ if (sessionToken) {
55054
+ setSessionToken(sessionToken);
55055
+ history2.replace(decodeURIComponent(previousLocation));
55056
+ }
55057
+ } catch {
55058
+ setIsError(true);
55059
+ }
55060
+ setIsLoggingIn(false);
55061
+ };
55062
+ React.useEffect(() => {
55063
+ if (getSessionToken()) {
55064
+ verifySessionToken().then((verified) => {
55065
+ if (verified) {
55066
+ history2.replace(decodeURIComponent(previousLocation));
55067
+ } else {
55068
+ setIsVerifyingToken(false);
55069
+ }
55070
+ });
55071
+ } else {
55072
+ setIsVerifyingToken(false);
55073
+ }
55074
+ }, []);
55075
+ if (isVerifyingToken) {
55076
+ return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
55077
+ }
55078
+ return /* @__PURE__ */ React__default.default.createElement(Wrapper$1, null, /* @__PURE__ */ React__default.default.createElement(Card, null, /* @__PURE__ */ React__default.default.createElement(FormWrapper, null, /* @__PURE__ */ React__default.default.createElement(
55079
+ Form,
55080
+ {
55081
+ onSubmit: (e2) => {
55082
+ e2.preventDefault();
55083
+ login();
55084
+ }
55085
+ },
55086
+ /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(Label, { htmlFor: "username" }, "Username"), /* @__PURE__ */ React__default.default.createElement(
55087
+ StyledInput,
55088
+ {
55089
+ $error: isError2,
55090
+ id: "username",
55091
+ onChange: (e2) => setUsername(e2.target.value),
55092
+ required: true,
55093
+ type: "text",
55094
+ value: username
55095
+ }
55096
+ )),
55097
+ /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(Label, { htmlFor: "password" }, "Password"), /* @__PURE__ */ React__default.default.createElement(
55098
+ StyledInput,
55099
+ {
55100
+ $error: isError2,
55101
+ id: "password",
55102
+ onChange: (e2) => setPassword(e2.target.value),
55103
+ required: true,
55104
+ type: "password",
55105
+ value: password
55106
+ }
55107
+ )),
55108
+ /* @__PURE__ */ React__default.default.createElement(ErrorText$1, { $hidden: !isError2, style: { marginTop: "1rem" } }, "Incorrect Username or Password"),
55109
+ /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(
55110
+ StyledButton,
55111
+ {
55112
+ loading: isLoggingIn,
55113
+ style: { color: "white" },
55114
+ styling: "primary",
55115
+ type: "submit"
55116
+ },
55117
+ "Sign in"
55118
+ ))
55119
+ ))));
55120
+ }
55121
+ function BasicAuthLogout() {
55122
+ React.useEffect(() => {
55123
+ revokeSession().then(() => {
55124
+ setSessionToken(null);
55125
+ window.location.href = `${window.dara.base_url}/login`;
55126
+ });
55127
+ }, []);
55128
+ return null;
55129
+ }
55130
+ function DefaultAuthLogin() {
55131
+ var _a;
55132
+ const history2 = useHistory();
55133
+ const location2 = useLocation();
55134
+ const queryParams = new URLSearchParams(location2.search);
55135
+ const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
55136
+ async function getNewToken() {
55137
+ const sessionToken = await requestSessionToken({});
55138
+ if (sessionToken) {
55139
+ setSessionToken(sessionToken);
55140
+ history2.replace(decodeURIComponent(previousLocation));
55141
+ }
55142
+ }
55143
+ React.useEffect(() => {
55144
+ if (getSessionToken()) {
55145
+ verifySessionToken().then((verified) => {
55146
+ if (verified) {
55147
+ history2.replace(decodeURIComponent(previousLocation));
55148
+ } else {
55149
+ getNewToken();
55150
+ }
55151
+ });
55152
+ } else {
55153
+ getNewToken();
55154
+ }
55155
+ }, []);
55156
+ return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
55157
+ }
55352
55158
  function isTaskResponse(response) {
55353
55159
  return response && typeof response === "object" && "task_id" in response;
55354
55160
  }
@@ -55514,56 +55320,500 @@ Inferred class string: "${iconClasses}."`
55514
55320
  })
55515
55321
  );
55516
55322
  }
55517
- const family = selectorFamilyRegistry.get(key);
55518
- const serializableExtras = new RequestExtrasSerializable(currentExtras);
55519
- const selectorInstance = family(serializableExtras);
55520
- if (!selectorFamilyMembersRegistry.has(family)) {
55521
- selectorFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
55323
+ const family = selectorFamilyRegistry.get(key);
55324
+ const serializableExtras = new RequestExtrasSerializable(currentExtras);
55325
+ const selectorInstance = family(serializableExtras);
55326
+ if (!selectorFamilyMembersRegistry.has(family)) {
55327
+ selectorFamilyMembersRegistry.set(family, /* @__PURE__ */ new Map());
55328
+ }
55329
+ selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
55330
+ return selectorInstance;
55331
+ }
55332
+ function useServerComponent(name, uid2, dynamicKwargs, loop_instance_uid) {
55333
+ const extras = useRequestExtras();
55334
+ const { client: wsClient } = React.useContext(websocketCtx);
55335
+ const taskContext = useTaskContext();
55336
+ const variablesContext = React.useContext(variablesCtx);
55337
+ const bus = useEventBus();
55338
+ variablesContext == null ? void 0 : variablesContext.variables.current.add(getComponentRegistryKey(uid2));
55339
+ React.useEffect(() => {
55340
+ return () => {
55341
+ variablesContext == null ? void 0 : variablesContext.variables.current.delete(getComponentRegistryKey(uid2));
55342
+ };
55343
+ }, []);
55344
+ const componentSelector = getOrRegisterServerComponent({
55345
+ name,
55346
+ uid: uid2,
55347
+ dynamicKwargs,
55348
+ wsClient,
55349
+ taskContext,
55350
+ currentExtras: extras,
55351
+ loop_instance_uid
55352
+ });
55353
+ const componentLoadable = Recoil_index_21(componentSelector);
55354
+ React.useEffect(() => {
55355
+ if (componentLoadable.state === "hasValue") {
55356
+ bus.publish("SERVER_COMPONENT_LOADED", { name, uid: uid2, value: componentLoadable.contents });
55357
+ }
55358
+ }, [componentLoadable]);
55359
+ const deferred = useDeferLoadable(componentLoadable);
55360
+ return deferred;
55361
+ }
55362
+ function useRefreshServerComponent(uid2, loop_instance_uid) {
55363
+ return Recoil_index_31(
55364
+ ({ set: set2 }) => () => {
55365
+ const triggerAtom = getOrRegisterComponentTrigger(uid2, loop_instance_uid);
55366
+ set2(triggerAtom, (triggerIndexValue) => ({
55367
+ force: false,
55368
+ inc: triggerIndexValue.inc + 1
55369
+ }));
55370
+ },
55371
+ [uid2]
55372
+ );
55373
+ }
55374
+ const ErrorBoundaryContext = React.createContext(null);
55375
+ const initialState = {
55376
+ didCatch: false,
55377
+ error: null
55378
+ };
55379
+ class ErrorBoundary extends React.Component {
55380
+ constructor(props) {
55381
+ super(props);
55382
+ this.resetErrorBoundary = this.resetErrorBoundary.bind(this);
55383
+ this.state = initialState;
55384
+ }
55385
+ static getDerivedStateFromError(error) {
55386
+ return {
55387
+ didCatch: true,
55388
+ error
55389
+ };
55390
+ }
55391
+ resetErrorBoundary() {
55392
+ const {
55393
+ error
55394
+ } = this.state;
55395
+ if (error !== null) {
55396
+ var _this$props$onReset, _this$props;
55397
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
55398
+ args[_key] = arguments[_key];
55399
+ }
55400
+ (_this$props$onReset = (_this$props = this.props).onReset) === null || _this$props$onReset === void 0 ? void 0 : _this$props$onReset.call(_this$props, {
55401
+ args,
55402
+ reason: "imperative-api"
55403
+ });
55404
+ this.setState(initialState);
55405
+ }
55406
+ }
55407
+ componentDidCatch(error, info) {
55408
+ var _this$props$onError, _this$props2;
55409
+ (_this$props$onError = (_this$props2 = this.props).onError) === null || _this$props$onError === void 0 ? void 0 : _this$props$onError.call(_this$props2, error, info);
55410
+ }
55411
+ componentDidUpdate(prevProps, prevState) {
55412
+ const {
55413
+ didCatch
55414
+ } = this.state;
55415
+ const {
55416
+ resetKeys
55417
+ } = this.props;
55418
+ if (didCatch && prevState.error !== null && hasArrayChanged(prevProps.resetKeys, resetKeys)) {
55419
+ var _this$props$onReset2, _this$props3;
55420
+ (_this$props$onReset2 = (_this$props3 = this.props).onReset) === null || _this$props$onReset2 === void 0 ? void 0 : _this$props$onReset2.call(_this$props3, {
55421
+ next: resetKeys,
55422
+ prev: prevProps.resetKeys,
55423
+ reason: "keys"
55424
+ });
55425
+ this.setState(initialState);
55426
+ }
55427
+ }
55428
+ render() {
55429
+ const {
55430
+ children,
55431
+ fallbackRender,
55432
+ FallbackComponent,
55433
+ fallback
55434
+ } = this.props;
55435
+ const {
55436
+ didCatch,
55437
+ error
55438
+ } = this.state;
55439
+ let childToRender = children;
55440
+ if (didCatch) {
55441
+ const props = {
55442
+ error,
55443
+ resetErrorBoundary: this.resetErrorBoundary
55444
+ };
55445
+ if (typeof fallbackRender === "function") {
55446
+ childToRender = fallbackRender(props);
55447
+ } else if (FallbackComponent) {
55448
+ childToRender = React.createElement(FallbackComponent, props);
55449
+ } else if (fallback !== void 0) {
55450
+ childToRender = fallback;
55451
+ } else {
55452
+ throw error;
55453
+ }
55454
+ }
55455
+ return React.createElement(ErrorBoundaryContext.Provider, {
55456
+ value: {
55457
+ didCatch,
55458
+ error,
55459
+ resetErrorBoundary: this.resetErrorBoundary
55460
+ }
55461
+ }, childToRender);
55462
+ }
55463
+ }
55464
+ function hasArrayChanged() {
55465
+ let a2 = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [];
55466
+ let b2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : [];
55467
+ return a2.length !== b2.length || a2.some((item, index2) => !Object.is(item, b2[index2]));
55468
+ }
55469
+ var baseGetTag = _baseGetTag, getPrototype = _getPrototype, isObjectLike = isObjectLike_1;
55470
+ var objectTag = "[object Object]";
55471
+ var funcProto = Function.prototype, objectProto = Object.prototype;
55472
+ var funcToString = funcProto.toString;
55473
+ var hasOwnProperty = objectProto.hasOwnProperty;
55474
+ var objectCtorString = funcToString.call(Object);
55475
+ function isPlainObject(value) {
55476
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
55477
+ return false;
55478
+ }
55479
+ var proto = getPrototype(value);
55480
+ if (proto === null) {
55481
+ return true;
55482
+ }
55483
+ var Ctor = hasOwnProperty.call(proto, "constructor") && proto.constructor;
55484
+ return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
55485
+ }
55486
+ var isPlainObject_1 = isPlainObject;
55487
+ var baseSet = _baseSet;
55488
+ function set(object2, path, value) {
55489
+ return object2 == null ? object2 : baseSet(object2, path, value);
55490
+ }
55491
+ var set_1 = set;
55492
+ function createMarkers(scope, loopInstanceUid) {
55493
+ const markers = [];
55494
+ if (scope.action) {
55495
+ markers.push({ type: "action", path: scope.action });
55496
+ }
55497
+ if (scope.derivedVariable) {
55498
+ markers.push({ type: "derived_var", path: scope.derivedVariable, loopInstanceUid });
55499
+ }
55500
+ if (scope.serverComponent) {
55501
+ markers.push({ type: "server_component", path: scope.serverComponent, loopInstanceUid });
55502
+ }
55503
+ return markers;
55504
+ }
55505
+ function updateScope(scope, value, path) {
55506
+ const newScope = { ...scope };
55507
+ if (!scope.action && isAnnotatedAction(value)) {
55508
+ newScope.action = path;
55509
+ }
55510
+ if (!scope.derivedVariable && isDerivedVariable(value)) {
55511
+ newScope.derivedVariable = path;
55512
+ }
55513
+ if (!scope.serverComponent && isPyComponent(value)) {
55514
+ newScope.serverComponent = path;
55515
+ }
55516
+ return newScope;
55517
+ }
55518
+ function getInjectionMarkers(renderer) {
55519
+ const markers = [];
55520
+ function walk(obj, pathSegments, scope = {}) {
55521
+ for (const [key, value] of Object.entries(obj)) {
55522
+ const currentPath = [...pathSegments, key];
55523
+ const dotPath = currentPath.join(".");
55524
+ if (isLoopVariable(value)) {
55525
+ markers.push(
55526
+ { path: dotPath, nested: value.nested, type: "loop_var" },
55527
+ ...createMarkers(scope, value.uid)
55528
+ );
55529
+ continue;
55530
+ }
55531
+ if (isPlainObject_1(value) || Array.isArray(value)) {
55532
+ const newScope = updateScope(scope, value, dotPath);
55533
+ walk(value, [...pathSegments, key], newScope);
55534
+ }
55535
+ }
55536
+ }
55537
+ walk(renderer, []);
55538
+ return markers;
55539
+ }
55540
+ function applyMarkers(renderer, markers, loopValue, itemKey) {
55541
+ if (markers.length === 0) {
55542
+ return renderer;
55543
+ }
55544
+ const clonedRenderer = cloneDeep_1(renderer);
55545
+ for (const marker of markers) {
55546
+ switch (marker.type) {
55547
+ case "loop_var": {
55548
+ set_1(clonedRenderer, marker.path, resolveNested(loopValue, marker.nested));
55549
+ break;
55550
+ }
55551
+ case "action": {
55552
+ set_1(clonedRenderer, `${marker.path}.loading.uid`, nanoid());
55553
+ break;
55554
+ }
55555
+ case "derived_var": {
55556
+ set_1(clonedRenderer, `${marker.path}.loop_instance_uid`, `${marker.loopInstanceUid}:${itemKey}`);
55557
+ break;
55558
+ }
55559
+ case "server_component": {
55560
+ set_1(clonedRenderer, `${marker.path}.loop_instance_uid`, `${marker.loopInstanceUid}:${itemKey}`);
55561
+ break;
55562
+ }
55563
+ }
55564
+ }
55565
+ return clonedRenderer;
55566
+ }
55567
+ function hasMarkers(component) {
55568
+ for (const [key, value] of Object.entries(component.props)) {
55569
+ if (isLoopVariable(value)) {
55570
+ return key;
55571
+ }
55572
+ }
55573
+ return null;
55574
+ }
55575
+ const POLLING_INTERVAL = 100;
55576
+ const FAKE_PROGRESS_INTERVAL = 100;
55577
+ const ESTIMATE_RATIO = 0.85;
55578
+ function estimateProgress(time, timeConstant = 10) {
55579
+ return 1 - Math.exp(-1 * time / (FAKE_PROGRESS_INTERVAL * 10 * timeConstant));
55580
+ }
55581
+ function fakeProgressGenerator(progressStart, progressEnd, estimatedTime) {
55582
+ const difference = progressEnd - progressStart;
55583
+ const estimatedProgressUpdates = [];
55584
+ let timeConstant = 10;
55585
+ if (estimatedTime && estimatedTime !== 0) {
55586
+ const estimatedDifference = ESTIMATE_RATIO * difference;
55587
+ const estimatedProgressTime = ESTIMATE_RATIO * estimatedTime;
55588
+ const numberOfUpdates = estimatedProgressTime / FAKE_PROGRESS_INTERVAL;
55589
+ const estimatedProgressChunk = estimatedDifference / numberOfUpdates;
55590
+ let t2 = 0;
55591
+ let p2 = progressStart;
55592
+ while (t2 < estimatedProgressTime) {
55593
+ p2 += estimatedProgressChunk;
55594
+ t2 += FAKE_PROGRESS_INTERVAL;
55595
+ estimatedProgressUpdates.push(p2);
55596
+ }
55597
+ timeConstant = (1 - ESTIMATE_RATIO) * (estimatedTime / 1e3);
55522
55598
  }
55523
- selectorFamilyMembersRegistry.get(family).set(serializableExtras.toJSON(), selectorInstance);
55524
- return selectorInstance;
55599
+ function* getNextUpdate() {
55600
+ let startFrom = progressStart;
55601
+ while (estimatedProgressUpdates.length > 0) {
55602
+ const update = estimatedProgressUpdates.shift();
55603
+ startFrom = update;
55604
+ yield update;
55605
+ }
55606
+ let i2 = 0;
55607
+ while (true) {
55608
+ const estimated = estimateProgress(FAKE_PROGRESS_INTERVAL * i2, timeConstant);
55609
+ yield estimated * (progressEnd - startFrom) + startFrom;
55610
+ i2++;
55611
+ }
55612
+ }
55613
+ return getNextUpdate();
55525
55614
  }
55526
- function useServerComponent(name, uid2, dynamicKwargs, loop_instance_uid) {
55527
- const extras = useRequestExtras();
55528
- const { client: wsClient } = React.useContext(websocketCtx);
55615
+ const ProgressWrapper = styled__default.default.div`
55616
+ display: flex;
55617
+ flex-direction: column;
55618
+ gap: 0.5rem;
55619
+ padding: 1rem;
55620
+ `;
55621
+ const ProgressHeader = styled__default.default.h4`
55622
+ font-size: 1.2rem;
55623
+ `;
55624
+ const ProgressMessage = styled__default.default.span`
55625
+ font-size: ${(props) => props.theme.font.size};
55626
+ `;
55627
+ function findRunningTasks(tasksContext, variablesRef) {
55628
+ var _a;
55629
+ if (!(variablesRef && ((_a = variablesRef == null ? void 0 : variablesRef.current) == null ? void 0 : _a.size) > 0 && tasksContext.hasRunningTasks())) {
55630
+ return [];
55631
+ }
55632
+ return tasksContext.getVariableTasks(...variablesRef.current.values());
55633
+ }
55634
+ function ProgressTracker(props) {
55529
55635
  const taskContext = useTaskContext();
55530
- const variablesContext = React.useContext(variablesCtx);
55531
- const bus = useEventBus();
55532
- variablesContext == null ? void 0 : variablesContext.variables.current.add(getComponentRegistryKey(uid2));
55636
+ const { client: wsClient } = React.useContext(websocketCtx);
55637
+ const [latestProgressUpdate, setLatestProgressUpdate] = React.useState(
55638
+ null
55639
+ );
55640
+ const [progress, setProgress] = React.useState(null);
55641
+ const fakeInterval = React.useRef(null);
55642
+ const [subscribedTaskIds, setSubscribedTaskIds] = React.useState([]);
55643
+ const [restartTrigger, setRestartTrigger] = React.useState(0);
55533
55644
  React.useEffect(() => {
55645
+ if (!wsClient) {
55646
+ return;
55647
+ }
55648
+ let progressSubscription = null;
55649
+ const timer2 = setInterval(() => {
55650
+ const taskIds = findRunningTasks(taskContext, props.variablesRef);
55651
+ if (taskIds.length > 0) {
55652
+ setSubscribedTaskIds(taskIds);
55653
+ progressSubscription = wsClient.progressUpdates$(...taskIds).subscribe((notif) => setLatestProgressUpdate(notif.message));
55654
+ clearInterval(timer2);
55655
+ }
55656
+ }, POLLING_INTERVAL);
55534
55657
  return () => {
55535
- variablesContext == null ? void 0 : variablesContext.variables.current.delete(getComponentRegistryKey(uid2));
55658
+ clearInterval(timer2);
55659
+ if (fakeInterval.current) {
55660
+ clearInterval(fakeInterval.current);
55661
+ }
55662
+ progressSubscription == null ? void 0 : progressSubscription.unsubscribe();
55536
55663
  };
55537
- }, []);
55538
- const componentSelector = getOrRegisterServerComponent({
55539
- name,
55540
- uid: uid2,
55541
- dynamicKwargs,
55542
- wsClient,
55543
- taskContext,
55544
- currentExtras: extras,
55545
- loop_instance_uid
55546
- });
55547
- const componentLoadable = Recoil_index_21(componentSelector);
55664
+ }, [restartTrigger, wsClient]);
55548
55665
  React.useEffect(() => {
55549
- if (componentLoadable.state === "hasValue") {
55550
- bus.publish("SERVER_COMPONENT_LOADED", { name, uid: uid2, value: componentLoadable.contents });
55666
+ if (!wsClient) {
55667
+ return;
55551
55668
  }
55552
- }, [componentLoadable]);
55553
- const deferred = useDeferLoadable(componentLoadable);
55554
- return deferred;
55669
+ let subscription = null;
55670
+ if (subscribedTaskIds.length > 0) {
55671
+ subscription = wsClient.taskStatusUpdates$(...subscribedTaskIds).subscribe((newStatus) => {
55672
+ if (newStatus === "CANCELED") {
55673
+ if (fakeInterval.current) {
55674
+ clearInterval(fakeInterval.current);
55675
+ }
55676
+ setLatestProgressUpdate(null);
55677
+ setSubscribedTaskIds([]);
55678
+ setProgress(null);
55679
+ setRestartTrigger((v2) => v2 + 1);
55680
+ }
55681
+ });
55682
+ }
55683
+ return () => {
55684
+ subscription == null ? void 0 : subscription.unsubscribe();
55685
+ };
55686
+ }, [subscribedTaskIds, wsClient]);
55687
+ React.useEffect(() => {
55688
+ var _a, _b;
55689
+ if (!latestProgressUpdate) {
55690
+ return;
55691
+ }
55692
+ if (fakeInterval.current) {
55693
+ clearInterval(fakeInterval.current);
55694
+ }
55695
+ const shouldStartFakeProgress = latestProgressUpdate.message.startsWith("FAKE_PROGRESS__");
55696
+ if (!shouldStartFakeProgress) {
55697
+ setProgress({
55698
+ message: latestProgressUpdate.message,
55699
+ progress: latestProgressUpdate.progress
55700
+ });
55701
+ return;
55702
+ }
55703
+ const [, estimatedTime, message] = latestProgressUpdate.message.split("__");
55704
+ setProgress({
55705
+ message,
55706
+ progress: (_a = progress == null ? void 0 : progress.progress) != null ? _a : 0
55707
+ });
55708
+ const progressGenerator = fakeProgressGenerator(
55709
+ (_b = progress == null ? void 0 : progress.progress) != null ? _b : 0,
55710
+ latestProgressUpdate.progress,
55711
+ parseFloat(estimatedTime)
55712
+ );
55713
+ fakeInterval.current = setInterval(() => {
55714
+ const nextValue = progressGenerator.next().value;
55715
+ setProgress({
55716
+ message,
55717
+ progress: nextValue
55718
+ });
55719
+ }, FAKE_PROGRESS_INTERVAL);
55720
+ }, [latestProgressUpdate]);
55721
+ if (subscribedTaskIds.length === 0) {
55722
+ return props.fallback;
55723
+ }
55724
+ return /* @__PURE__ */ React__default.default.createElement(ProgressWrapper, null, /* @__PURE__ */ React__default.default.createElement(ProgressHeader, null, "Task in progress"), progress && /* @__PURE__ */ React__default.default.createElement(React__default.default.Fragment, null, /* @__PURE__ */ React__default.default.createElement(ProgressMessage, null, progress.message), /* @__PURE__ */ React__default.default.createElement(ProgressBar, { progress: parseFloat(progress.progress.toFixed(2)) })));
55555
55725
  }
55556
- function useRefreshServerComponent(uid2, loop_instance_uid) {
55557
- return Recoil_index_31(
55558
- ({ set: set2 }) => () => {
55559
- const triggerAtom = getOrRegisterComponentTrigger(uid2, loop_instance_uid);
55560
- set2(triggerAtom, (triggerIndexValue) => ({
55561
- force: false,
55562
- inc: triggerIndexValue.inc + 1
55563
- }));
55564
- },
55565
- [uid2]
55566
- );
55726
+ function isSelectorError(e2) {
55727
+ return e2 !== void 0 && e2 !== null && typeof e2 === "object" && "selectorId" in e2 && "selectorExtras" in e2;
55728
+ }
55729
+ const StyledErrorDisplay = styled__default.default.div`
55730
+ display: flex;
55731
+ gap: 1rem;
55732
+ align-items: center;
55733
+ justify-content: space-between;
55734
+
55735
+ height: min-content;
55736
+ padding: 1rem;
55737
+
55738
+ background-color: ${(props) => curriedTransparentize$1(0.9, props.theme.colors.error)};
55739
+ border-radius: 0.25rem;
55740
+ `;
55741
+ const ErrorDisplayWrapper = injectCss(StyledErrorDisplay);
55742
+ const IconWrapper = styled__default.default.div`
55743
+ display: flex;
55744
+ height: 100%;
55745
+ `;
55746
+ const ErrorIcon = styled__default.default.i`
55747
+ line-height: 21px;
55748
+ color: ${(props) => props.theme.colors.error};
55749
+ `;
55750
+ const ContentWrapper = styled__default.default.div`
55751
+ display: flex;
55752
+ flex-direction: column;
55753
+ gap: 1rem;
55754
+ align-items: flex-start;
55755
+ `;
55756
+ const ErrorContent = styled__default.default.div`
55757
+ display: flex;
55758
+ flex-direction: column;
55759
+ gap: 0.5rem;
55760
+ color: ${(props) => props.theme.colors.error};
55761
+ `;
55762
+ const ErrorTitle$1 = styled__default.default.h3`
55763
+ display: flex;
55764
+ gap: 0.375rem;
55765
+
55766
+ font-size: 1rem;
55767
+ font-weight: bold;
55768
+ line-height: 1.375rem;
55769
+ color: ${(props) => props.theme.colors.error};
55770
+ `;
55771
+ const ErrorText = styled__default.default.span`
55772
+ font-size: 1rem;
55773
+ line-height: 1.375rem;
55774
+ `;
55775
+ const RetryButton = styled__default.default.button`
55776
+ cursor: pointer;
55777
+
55778
+ display: flex;
55779
+ gap: 0.5rem;
55780
+ align-items: center;
55781
+ justify-content: center;
55782
+
55783
+ width: 40px;
55784
+ height: 40px;
55785
+
55786
+ color: ${(props) => props.theme.colors.error};
55787
+
55788
+ background-color: inherit;
55789
+ border: none;
55790
+ border: 1px solid;
55791
+ border-color: ${(props) => props.theme.colors.error};
55792
+ border-radius: 5px;
55793
+
55794
+ transition-timing-function: ease;
55795
+ transition-duration: 100ms;
55796
+ transition-property: color, border-color;
55797
+
55798
+ i {
55799
+ line-height: 21px;
55800
+ transition: transform 400ms ease-in-out;
55801
+ }
55802
+
55803
+ &:hover {
55804
+ color: ${(props) => props.theme.colors.errorHover};
55805
+ border-color: ${(props) => props.theme.colors.errorHover};
55806
+
55807
+ i {
55808
+ transform: rotate(180deg);
55809
+ }
55810
+ }
55811
+ `;
55812
+ function ErrorDisplay$1(props) {
55813
+ var _a, _b, _c, _d, _e2;
55814
+ const [styles2, css2] = parseRawCss((_a = props.config) == null ? void 0 : _a.raw_css);
55815
+ const defaultMessage = props.error instanceof UserError ? props.error.message : "Try again or contact the application owner.";
55816
+ return /* @__PURE__ */ React__default.default.createElement(ErrorDisplayWrapper, { $rawCss: css2, style: styles2 }, /* @__PURE__ */ React__default.default.createElement(ContentWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorContent, null, /* @__PURE__ */ React__default.default.createElement(ErrorTitle$1, null, /* @__PURE__ */ React__default.default.createElement(IconWrapper, null, /* @__PURE__ */ React__default.default.createElement(ErrorIcon, { "aria-hidden": true, className: "fa-solid fa-circle-xmark fa-lg" })), (_c = (_b = props == null ? void 0 : props.config) == null ? void 0 : _b.title) != null ? _c : "Error"), /* @__PURE__ */ React__default.default.createElement(ErrorText, null, (_e2 = (_d = props == null ? void 0 : props.config) == null ? void 0 : _d.description) != null ? _e2 : defaultMessage))), props.resetErrorBoundary && /* @__PURE__ */ React__default.default.createElement(RetryButton, { onClick: () => props.resetErrorBoundary(props.error), type: "button" }, /* @__PURE__ */ React__default.default.createElement("i", { "aria-hidden": true, className: "fa-solid fa-rotate fa-xl" })));
55567
55817
  }
55568
55818
  function cleanProps(props) {
55569
55819
  if ("children" in props && Array.isArray(props.children)) {
@@ -55605,8 +55855,15 @@ Inferred class string: "${iconClasses}."`
55605
55855
  }
55606
55856
  const MODULE_CACHE = /* @__PURE__ */ new Map();
55607
55857
  const COMPONENT_METADATA_CACHE = /* @__PURE__ */ new Map();
55858
+ function clearCaches_TEST() {
55859
+ MODULE_CACHE.clear();
55860
+ COMPONENT_METADATA_CACHE.clear();
55861
+ }
55608
55862
  function resolveComponentSync(component) {
55609
55863
  var _a;
55864
+ if (!component) {
55865
+ return null;
55866
+ }
55610
55867
  if ((component == null ? void 0 : component.name) === "RawString") {
55611
55868
  return component.props.content;
55612
55869
  }
@@ -55654,6 +55911,9 @@ Inferred class string: "${iconClasses}."`
55654
55911
  }
55655
55912
  }
55656
55913
  async function resolveComponentAsync(component, getComponent, importers) {
55914
+ if (!component) {
55915
+ return;
55916
+ }
55657
55917
  const entry = await getComponent(component);
55658
55918
  if (!isJsComponent(entry)) {
55659
55919
  COMPONENT_METADATA_CACHE.set(component.name, entry);
@@ -55709,6 +55969,9 @@ Inferred class string: "${iconClasses}."`
55709
55969
  const [isLoading, setIsLoading] = React.useState(() => component === null);
55710
55970
  const [loadingStarted, setLoadingStarted] = React.useState(false);
55711
55971
  React.useLayoutEffect(() => {
55972
+ if (!props.component) {
55973
+ return;
55974
+ }
55712
55975
  const markerProp = hasMarkers(props.component);
55713
55976
  if (markerProp) {
55714
55977
  throw new UserError(
@@ -55771,6 +56034,9 @@ Inferred class string: "${iconClasses}."`
55771
56034
  return getFallbackComponent((_b2 = (_a2 = props.component) == null ? void 0 : _a2.props) == null ? void 0 : _b2.fallback, (_d2 = (_c2 = props.component) == null ? void 0 : _c2.props) == null ? void 0 : _d2.track_progress, variables);
55772
56035
  }
55773
56036
  );
56037
+ if (!props.component) {
56038
+ return null;
56039
+ }
55774
56040
  if (isLoading) {
55775
56041
  return fallback;
55776
56042
  }
@@ -56396,7 +56662,7 @@ Inferred class string: "${iconClasses}."`
56396
56662
  /* @__PURE__ */ React__default.default.createElement(DynamicContext, { contextComponents: (_c = config2 == null ? void 0 : config2.context_components) != null ? _c : [] }, /* @__PURE__ */ React__default.default.createElement(StoreProviders, null, /* @__PURE__ */ React__default.default.createElement(RootWrapper, null, /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: template.layout }), /* @__PURE__ */ React__default.default.createElement(VariableStateProvider, { wsClient }), (config2 == null ? void 0 : config2.enable_devtools) && /* @__PURE__ */ React__default.default.createElement(DevTools, null))))
56397
56663
  )));
56398
56664
  }
56399
- const Wrapper$1 = styled__default.default.div`
56665
+ const Wrapper = styled__default.default.div`
56400
56666
  overflow: auto;
56401
56667
  display: flex;
56402
56668
  flex: 1 1 auto;
@@ -81849,229 +82115,6 @@ Inferred class string: "${iconClasses}."`
81849
82115
  title: actionImpl.title
81850
82116
  });
81851
82117
  };
81852
- const Wrapper = styled__default.default.div`
81853
- display: flex;
81854
- flex: 1 1 0%;
81855
- flex-direction: column;
81856
- justify-content: center;
81857
-
81858
- min-height: 100%;
81859
-
81860
- background: ${(props) => `radial-gradient(circle closest-corner at 50% 40%, ${curriedTransparentize$1(
81861
- 0.9,
81862
- props.theme.colors.background
81863
- )} 0%, ${curriedTransparentize$1(
81864
- 0.8,
81865
- props.theme.colors.blue4
81866
- )} 70%),radial-gradient(circle closest-corner at 20% 150%, ${curriedTransparentize$1(
81867
- 0.8,
81868
- props.theme.colors.error
81869
- )} 0%, ${curriedTransparentize$1(0.2, props.theme.colors.blue4)} 230%)`};
81870
- `;
81871
- const Card = styled__default.default.div`
81872
- padding: 1.5rem;
81873
-
81874
- color: ${(props) => props.theme.colors.text};
81875
-
81876
- background-color: ${(props) => props.theme.colors.blue1};
81877
- border-radius: 1rem;
81878
- box-shadow: ${(props) => props.theme.shadow.medium};
81879
-
81880
- @media (width >= 640px) {
81881
- width: 100%;
81882
- max-width: 24rem;
81883
- margin-right: auto;
81884
- margin-left: auto;
81885
- }
81886
- `;
81887
- const FormWrapper = styled__default.default.div`
81888
- margin-top: 1.5rem;
81889
- `;
81890
- const Form = styled__default.default.form`
81891
- > * + * {
81892
- margin-top: 1.5rem;
81893
- }
81894
- `;
81895
- const ErrorText = styled__default.default.h3`
81896
- margin: 0;
81897
-
81898
- font-size: 0.875rem;
81899
- font-weight: 500;
81900
- line-height: 1.25rem;
81901
- color: ${(props) => props.theme.colors.error};
81902
- letter-spacing: 0.025em;
81903
-
81904
- visibility: ${(props) => props.$hidden ? "hidden" : "visible"};
81905
- `;
81906
- const Label = styled__default.default.label`
81907
- font-weight: 500;
81908
- line-height: 1.5rem;
81909
- `;
81910
- const StyledInput = styled__default.default.input`
81911
- display: flex;
81912
- display: block;
81913
- align-items: center;
81914
-
81915
- width: 100%;
81916
- height: 2.5rem;
81917
- margin-top: 0.5rem;
81918
- padding: 0 1rem;
81919
-
81920
- font-size: 1rem;
81921
- line-height: 1.5rem;
81922
- color: ${(props) => props.theme.colors.text};
81923
-
81924
- background-color: ${(props) => props.theme.colors.blue1};
81925
- border: none;
81926
- border-radius: 0.25rem;
81927
- outline: none;
81928
- box-shadow:
81929
- inset 0 0 0 0 ${(props) => props.theme.colors.blue1},
81930
- inset 0 0 0 1px ${(props) => props.$error ? props.theme.colors.error : props.theme.colors.grey2},
81931
- 0 1px 2px 0 rgb(0 0 0 / 5%);
81932
-
81933
- :active,
81934
- :focus {
81935
- box-shadow:
81936
- inset 0 0 0 0 ${(props) => props.theme.colors.blue1},
81937
- inset 0 0 0 2px ${(props) => props.$error ? props.theme.colors.error : props.theme.colors.primary},
81938
- 0 1px 2px 0 rgb(0 0 0 / 5%);
81939
- }
81940
- `;
81941
- const StyledButton = styled__default.default(Button$1)`
81942
- width: 100%;
81943
- font-weight: 600;
81944
- line-height: 1.5rem;
81945
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 5%);
81946
-
81947
- :active,
81948
- :focus {
81949
- outline-color: ${(props) => props.theme.colors.primary};
81950
- outline-width: 2px;
81951
- outline-offset: 2px;
81952
- }
81953
- `;
81954
- function BasicAuthLogin() {
81955
- var _a;
81956
- const [isVerifyingToken, setIsVerifyingToken] = React.useState(true);
81957
- const [isLoggingIn, setIsLoggingIn] = React.useState(false);
81958
- const [username, setUsername] = React.useState("");
81959
- const [password, setPassword] = React.useState("");
81960
- const [isError2, setIsError] = React.useState(false);
81961
- const history2 = useHistory();
81962
- const location2 = useLocation();
81963
- const queryParams = new URLSearchParams(location2.search);
81964
- const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
81965
- const login = async () => {
81966
- setIsLoggingIn(true);
81967
- setIsError(false);
81968
- try {
81969
- const sessionToken = await requestSessionToken({ password, username });
81970
- if (sessionToken) {
81971
- setSessionToken(sessionToken);
81972
- history2.replace(decodeURIComponent(previousLocation));
81973
- }
81974
- } catch {
81975
- setIsError(true);
81976
- }
81977
- setIsLoggingIn(false);
81978
- };
81979
- React.useEffect(() => {
81980
- if (getSessionToken()) {
81981
- verifySessionToken().then((verified) => {
81982
- if (verified) {
81983
- history2.replace(decodeURIComponent(previousLocation));
81984
- } else {
81985
- setIsVerifyingToken(false);
81986
- }
81987
- });
81988
- } else {
81989
- setIsVerifyingToken(false);
81990
- }
81991
- }, []);
81992
- if (isVerifyingToken) {
81993
- return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
81994
- }
81995
- return /* @__PURE__ */ React__default.default.createElement(Wrapper, null, /* @__PURE__ */ React__default.default.createElement(Card, null, /* @__PURE__ */ React__default.default.createElement(FormWrapper, null, /* @__PURE__ */ React__default.default.createElement(
81996
- Form,
81997
- {
81998
- onSubmit: (e2) => {
81999
- e2.preventDefault();
82000
- login();
82001
- }
82002
- },
82003
- /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(Label, { htmlFor: "username" }, "Username"), /* @__PURE__ */ React__default.default.createElement(
82004
- StyledInput,
82005
- {
82006
- $error: isError2,
82007
- id: "username",
82008
- onChange: (e2) => setUsername(e2.target.value),
82009
- required: true,
82010
- type: "text",
82011
- value: username
82012
- }
82013
- )),
82014
- /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(Label, { htmlFor: "password" }, "Password"), /* @__PURE__ */ React__default.default.createElement(
82015
- StyledInput,
82016
- {
82017
- $error: isError2,
82018
- id: "password",
82019
- onChange: (e2) => setPassword(e2.target.value),
82020
- required: true,
82021
- type: "password",
82022
- value: password
82023
- }
82024
- )),
82025
- /* @__PURE__ */ React__default.default.createElement(ErrorText, { $hidden: !isError2, style: { marginTop: "1rem" } }, "Incorrect Username or Password"),
82026
- /* @__PURE__ */ React__default.default.createElement("div", null, /* @__PURE__ */ React__default.default.createElement(
82027
- StyledButton,
82028
- {
82029
- loading: isLoggingIn,
82030
- style: { color: "white" },
82031
- styling: "primary",
82032
- type: "submit"
82033
- },
82034
- "Sign in"
82035
- ))
82036
- ))));
82037
- }
82038
- function BasicAuthLogout() {
82039
- React.useEffect(() => {
82040
- revokeSession().then(() => {
82041
- setSessionToken(null);
82042
- window.location.href = `${window.dara.base_url}/login`;
82043
- });
82044
- }, []);
82045
- return null;
82046
- }
82047
- function DefaultAuthLogin() {
82048
- var _a;
82049
- const history2 = useHistory();
82050
- const location2 = useLocation();
82051
- const queryParams = new URLSearchParams(location2.search);
82052
- const previousLocation = (_a = queryParams.get("referrer")) != null ? _a : "/";
82053
- async function getNewToken() {
82054
- const sessionToken = await requestSessionToken({});
82055
- if (sessionToken) {
82056
- setSessionToken(sessionToken);
82057
- history2.replace(decodeURIComponent(previousLocation));
82058
- }
82059
- }
82060
- React.useEffect(() => {
82061
- if (getSessionToken()) {
82062
- verifySessionToken().then((verified) => {
82063
- if (verified) {
82064
- history2.replace(decodeURIComponent(previousLocation));
82065
- } else {
82066
- getNewToken();
82067
- }
82068
- });
82069
- } else {
82070
- getNewToken();
82071
- }
82072
- }, []);
82073
- return /* @__PURE__ */ React__default.default.createElement(Center, null, /* @__PURE__ */ React__default.default.createElement(DefaultFallback, null));
82074
- }
82075
82118
  const MenuItem = styled__default.default(NavLink)`
82076
82119
  cursor: pointer;
82077
82120
 
@@ -82223,7 +82266,7 @@ Inferred class string: "${iconClasses}."`
82223
82266
  const causalensLogoSrc = theme2.themeType === "dark" ? CausalensDark : CausalensLight;
82224
82267
  const daraLogo = /* @__PURE__ */ React__default.default.createElement("img", { alt: "Dara Logo", src: logoSrc });
82225
82268
  const causalensLogo = /* @__PURE__ */ React__default.default.createElement("img", { alt: "causaLens Logo", src: causalensLogoSrc });
82226
- return /* @__PURE__ */ React__default.default.createElement(Wrapper$1, { backgroundColor: theme2.colors.background }, props.side_bar_position === "right" && /* @__PURE__ */ React__default.default.createElement(Wrapper$1, null, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })), /* @__PURE__ */ React__default.default.createElement(styled.ThemeContext.Provider, { value: resolveTheme((_a = config2 == null ? void 0 : config2.theme) == null ? void 0 : _a.main, (_b = config2 == null ? void 0 : config2.theme) == null ? void 0 : _b.base) }, /* @__PURE__ */ React__default.default.createElement(SideBar, { style: { padding: props.side_bar_padding }, width: props.side_bar_width }, !props.hide_logo && props.logo_position !== "bottom" && logo, /* @__PURE__ */ React__default.default.createElement(Wrapper$1, { direction: "column" }, /* @__PURE__ */ React__default.default.createElement(directionCtx.Provider, { value: { direction: "column" } }, props.side_bar && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.side_bar }))), !props.hide_logo && props.logo_position === "bottom" && logo, /* @__PURE__ */ React__default.default.createElement(LogoutButton$1, { href: "/logout", styling: "error" }, /* @__PURE__ */ React__default.default.createElement(LogoutArrow$1, { style: { marginRight: "0.5rem" } }), "Logout"), /* @__PURE__ */ React__default.default.createElement(BuiltWithLink, { href: "https://github.com/causalens/dara", target: "_blank", rel: "noopener noreferrer" }, "Built with ", daraLogo), (config2 == null ? void 0 : config2.powered_by_causalens) && /* @__PURE__ */ React__default.default.createElement(
82269
+ return /* @__PURE__ */ React__default.default.createElement(Wrapper, { backgroundColor: theme2.colors.background }, props.side_bar_position === "right" && /* @__PURE__ */ React__default.default.createElement(Wrapper, null, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })), /* @__PURE__ */ React__default.default.createElement(styled.ThemeContext.Provider, { value: resolveTheme((_a = config2 == null ? void 0 : config2.theme) == null ? void 0 : _a.main, (_b = config2 == null ? void 0 : config2.theme) == null ? void 0 : _b.base) }, /* @__PURE__ */ React__default.default.createElement(SideBar, { style: { padding: props.side_bar_padding }, width: props.side_bar_width }, !props.hide_logo && props.logo_position !== "bottom" && logo, /* @__PURE__ */ React__default.default.createElement(Wrapper, { direction: "column" }, /* @__PURE__ */ React__default.default.createElement(directionCtx.Provider, { value: { direction: "column" } }, props.side_bar && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.side_bar }))), !props.hide_logo && props.logo_position === "bottom" && logo, /* @__PURE__ */ React__default.default.createElement(LogoutButton$1, { href: "/logout", styling: "error" }, /* @__PURE__ */ React__default.default.createElement(LogoutArrow$1, { style: { marginRight: "0.5rem" } }), "Logout"), /* @__PURE__ */ React__default.default.createElement(BuiltWithLink, { href: "https://github.com/causalens/dara", target: "_blank", rel: "noopener noreferrer" }, "Built with ", daraLogo), (config2 == null ? void 0 : config2.powered_by_causalens) && /* @__PURE__ */ React__default.default.createElement(
82227
82270
  BuiltWithLink,
82228
82271
  {
82229
82272
  href: "https://causalens.com/?utm_source=dara&utm_medium=direct&utm_campaign=dara_platform",
@@ -82233,7 +82276,7 @@ Inferred class string: "${iconClasses}."`
82233
82276
  /* @__PURE__ */ React__default.default.createElement("span", { style: { marginTop: "0.4375rem" } }, "Powered by"),
82234
82277
  " ",
82235
82278
  causalensLogo
82236
- ))), props.side_bar_position !== "right" && /* @__PURE__ */ React__default.default.createElement(Wrapper$1, { style: { padding: "2rem 3rem" } }, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })));
82279
+ ))), props.side_bar_position !== "right" && /* @__PURE__ */ React__default.default.createElement(Wrapper, { style: { padding: "2rem 3rem" } }, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })));
82237
82280
  }
82238
82281
  const shouldForwardProp = (prop) => !["width"].includes(prop);
82239
82282
  const TopBar = styled__default.default.div.withConfig({ shouldForwardProp })`
@@ -82294,7 +82337,7 @@ Inferred class string: "${iconClasses}."`
82294
82337
  color: ${(props) => props.theme.colors.blue1};
82295
82338
  }
82296
82339
  `;
82297
- const RouteButtons = styled__default.default(Wrapper$1)`
82340
+ const RouteButtons = styled__default.default(Wrapper)`
82298
82341
  gap: 0.5rem;
82299
82342
  align-items: center;
82300
82343
  `;
@@ -82317,7 +82360,7 @@ Inferred class string: "${iconClasses}."`
82317
82360
  const logo = props.logo_path && /* @__PURE__ */ React__default.default.createElement(LogoImage, { alt: "Logo", src: prependBaseUrl(props.logo_path), width: props.logo_width });
82318
82361
  const logoSrc = theme2.themeType === "dark" ? DaraDark : DaraLight;
82319
82362
  const daraLogo = /* @__PURE__ */ React__default.default.createElement("img", { alt: "Dara", src: logoSrc });
82320
- return /* @__PURE__ */ React__default.default.createElement(Wrapper$1, { backgroundColor: theme2.colors.background, direction: "column" }, /* @__PURE__ */ React__default.default.createElement(styled.ThemeContext.Provider, { value: resolveTheme((_a = config2 == null ? void 0 : config2.theme) == null ? void 0 : _a.main, (_b = config2 == null ? void 0 : config2.theme) == null ? void 0 : _b.base) }, /* @__PURE__ */ React__default.default.createElement(TopBar, { height: props.top_bar_height, style: { padding: props.top_bar_padding } }, /* @__PURE__ */ React__default.default.createElement(TopBarContent, null, !props.hide_logo && logo, props.top_bar && /* @__PURE__ */ React__default.default.createElement(RouteButtons, { direction: "row" }, /* @__PURE__ */ React__default.default.createElement(directionCtx.Provider, { value: { direction: "row" } }, props.top_bar && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.top_bar }))), /* @__PURE__ */ React__default.default.createElement(LogoutButton, { href: "/logout", styling: "error" }, /* @__PURE__ */ React__default.default.createElement(LogoutArrow, { style: { marginRight: "0.5rem" } }), "Logout")), /* @__PURE__ */ React__default.default.createElement(BuiltWithSpan, null, "Built with ", daraLogo))), /* @__PURE__ */ React__default.default.createElement(Wrapper$1, { style: { padding: "2rem 3rem" } }, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })));
82363
+ return /* @__PURE__ */ React__default.default.createElement(Wrapper, { backgroundColor: theme2.colors.background, direction: "column" }, /* @__PURE__ */ React__default.default.createElement(styled.ThemeContext.Provider, { value: resolveTheme((_a = config2 == null ? void 0 : config2.theme) == null ? void 0 : _a.main, (_b = config2 == null ? void 0 : config2.theme) == null ? void 0 : _b.base) }, /* @__PURE__ */ React__default.default.createElement(TopBar, { height: props.top_bar_height, style: { padding: props.top_bar_padding } }, /* @__PURE__ */ React__default.default.createElement(TopBarContent, null, !props.hide_logo && logo, props.top_bar && /* @__PURE__ */ React__default.default.createElement(RouteButtons, { direction: "row" }, /* @__PURE__ */ React__default.default.createElement(directionCtx.Provider, { value: { direction: "row" } }, props.top_bar && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.top_bar }))), /* @__PURE__ */ React__default.default.createElement(LogoutButton, { href: "/logout", styling: "error" }, /* @__PURE__ */ React__default.default.createElement(LogoutArrow, { style: { marginRight: "0.5rem" } }), "Logout")), /* @__PURE__ */ React__default.default.createElement(BuiltWithSpan, null, "Built with ", daraLogo))), /* @__PURE__ */ React__default.default.createElement(Wrapper, { style: { padding: "2rem 3rem" } }, props.content && /* @__PURE__ */ React__default.default.createElement(DynamicComponent$1, { component: props.content })));
82321
82364
  }
82322
82365
  const RowDots = styled__default.default(Dots)`
82323
82366
  height: 2.5rem;
@@ -82397,65 +82440,142 @@ Inferred class string: "${iconClasses}."`
82397
82440
  const { suspend } = useFallbackCtx();
82398
82441
  return /* @__PURE__ */ React__namespace.createElement(fallbackCtx.Provider, { value: { suspend: false } }, /* @__PURE__ */ React__namespace.createElement(ForImpl, { ...props, suspend }));
82399
82442
  }
82443
+ exports.AuthType = AuthType;
82444
+ exports.AuthWrapper = AuthWrapper;
82400
82445
  exports.BasicAuthLogin = BasicAuthLogin;
82401
82446
  exports.BasicAuthLogout = BasicAuthLogout;
82402
82447
  exports.Center = Center;
82448
+ exports.ComponentType = ComponentType;
82403
82449
  exports.ConditionOperator = ConditionOperator;
82404
82450
  exports.DARA_JWT_TOKEN = DARA_JWT_TOKEN;
82451
+ exports.DEFAULT_BUS = DEFAULT_BUS;
82405
82452
  exports.DefaultAuthLogin = DefaultAuthLogin;
82406
82453
  exports.DefaultFallback = DefaultFallback;
82454
+ exports.DirectionCtx = directionCtx;
82407
82455
  exports.DisplayCtx = displayCtx;
82408
82456
  exports.DownloadVariable = DownloadVariable;
82409
82457
  exports.DynamicComponent = DynamicComponent$1;
82410
82458
  exports.EventBus = EventBus;
82411
82459
  exports.EventCapturer = EventCapturer;
82460
+ exports.FallbackCtx = fallbackCtx;
82412
82461
  exports.For = For;
82462
+ exports.GlobalTaskProvider = GlobalTaskProvider;
82463
+ exports.ImportersCtx = importersCtx;
82413
82464
  exports.Menu = Menu;
82414
82465
  exports.NavigateTo = NavigateTo;
82415
82466
  exports.Notifications = index$1;
82416
82467
  exports.Notify = Notify;
82417
82468
  exports.PartialRequestExtrasProvider = PartialRequestExtrasProvider;
82469
+ exports.PrivateRoute = PrivateRoute;
82418
82470
  exports.ProgressTracker = ProgressTracker;
82419
82471
  exports.ReactRouter = reactRouterDom;
82472
+ exports.RegistriesCtx = registriesCtx;
82473
+ exports.RequestExtrasCtx = requestExtrasCtx;
82420
82474
  exports.RequestExtrasProvider = RequestExtrasProvider;
82421
82475
  exports.ResetVariables = ResetVariables;
82422
82476
  exports.RouterContent = RouterContent;
82423
82477
  exports.RowFallback = RowFallback;
82424
82478
  exports.SideBarFrame = SideBarFrame;
82479
+ exports.TemplateRoot = TemplateRoot;
82425
82480
  exports.TopBarFrame = TopBarFrame;
82426
82481
  exports.TriggerVariable = TriggerVariable;
82427
82482
  exports.UpdateVariable = UpdateVariable;
82483
+ exports.UserError = UserError;
82484
+ exports.VariableCtx = variablesCtx;
82485
+ exports.WebSocketClient = WebSocketClient;
82428
82486
  exports.WebSocketCtx = websocketCtx;
82487
+ exports.Wrapper = Wrapper;
82488
+ exports.atomFamilyMembersRegistry = atomFamilyMembersRegistry;
82489
+ exports.atomFamilyRegistry = atomFamilyRegistry;
82490
+ exports.atomRegistry = atomRegistry;
82491
+ exports.cancelTask = cancelTask;
82492
+ exports.cleanSessionCache = cleanSessionCache;
82493
+ exports.cleanValue = cleanValue;
82494
+ exports.clearActionHandlerCache_TEST = clearActionHandlerCache_TEST;
82495
+ exports.clearCaches_TEST = clearCaches_TEST;
82496
+ exports.clearRegistries_TEST = clearRegistries_TEST;
82429
82497
  exports.combineFilters = combineFilters;
82498
+ exports.dataRegistry = dataRegistry;
82430
82499
  exports.default = run;
82500
+ exports.depsRegistry = depsRegistry;
82501
+ exports.fetchDerivedVariable = fetchDerivedVariable;
82502
+ exports.fetchTaskResult = fetchTaskResult;
82503
+ exports.formatDerivedVariableRequest = formatDerivedVariableRequest;
82431
82504
  exports.getComponentRegistryKey = getComponentRegistryKey;
82505
+ exports.getDeps = getDeps;
82432
82506
  exports.getIcon = getIcon;
82507
+ exports.getOrRegisterDerivedVariable = getOrRegisterDerivedVariable;
82508
+ exports.getOrRegisterDerivedVariableValue = getOrRegisterDerivedVariableValue;
82433
82509
  exports.getRegistryKey = getRegistryKey;
82434
82510
  exports.getSessionToken = getSessionToken;
82435
82511
  exports.getToken = getToken;
82436
82512
  exports.getTokenKey = getTokenKey;
82513
+ exports.getVariableValue = getVariableValue;
82437
82514
  exports.handleAuthErrors = handleAuthErrors;
82438
82515
  exports.injectCss = injectCss;
82516
+ exports.isActionImpl = isActionImpl;
82517
+ exports.isAnnotatedAction = isAnnotatedAction;
82518
+ exports.isDataVariable = isDataVariable;
82519
+ exports.isDerivedDataVariable = isDerivedDataVariable;
82520
+ exports.isDerivedVariable = isDerivedVariable;
82521
+ exports.isInvalidComponent = isInvalidComponent;
82522
+ exports.isJsComponent = isJsComponent;
82523
+ exports.isLoopVariable = isLoopVariable;
82524
+ exports.isPyComponent = isPyComponent;
82525
+ exports.isRawString = isRawString;
82526
+ exports.isRegistered = isRegistered;
82527
+ exports.isResolvedDataVariable = isResolvedDataVariable;
82528
+ exports.isResolvedDerivedDataVariable = isResolvedDerivedDataVariable;
82529
+ exports.isResolvedDerivedVariable = isResolvedDerivedVariable;
82530
+ exports.isTaskResponse = isTaskResponse$1;
82531
+ exports.isUrlVariable = isUrlVariable;
82439
82532
  exports.isVariable = isVariable;
82440
82533
  exports.normalizeRequest = normalizeRequest;
82534
+ exports.onTokenChange = onTokenChange;
82535
+ exports.parseRawCss = parseRawCss;
82441
82536
  exports.prependBaseUrl = prependBaseUrl;
82442
82537
  exports.request = request;
82443
- exports.resolveValue = resolveValue;
82538
+ exports.requestSessionToken = requestSessionToken;
82539
+ exports.resolveDerivedValue = resolveDerivedValue;
82540
+ exports.resolveNested = resolveNested;
82541
+ exports.resolveReferrer = resolveReferrer;
82542
+ exports.resolveTheme = resolveTheme;
82444
82543
  exports.revokeSession = revokeSession;
82544
+ exports.selectorFamilyMembersRegistry = selectorFamilyMembersRegistry;
82545
+ exports.selectorFamilyRegistry = selectorFamilyRegistry;
82546
+ exports.selectorRegistry = selectorRegistry;
82547
+ exports.setNested = setNested;
82445
82548
  exports.setSessionToken = setSessionToken;
82549
+ exports.setupWebsocket = setupWebsocket;
82446
82550
  exports.useAction = useAction;
82447
82551
  exports.useActionIsLoading = useActionIsLoading;
82552
+ exports.useActions = useActions;
82448
82553
  exports.useAnyVariable = useAnyVariable;
82554
+ exports.useAuthConfig = useAuthConfig;
82555
+ exports.useComponentRegistry = useComponentRegistry;
82449
82556
  exports.useComponentStyles = useComponentStyles;
82557
+ exports.useComponents = useComponents;
82558
+ exports.useConfig = useConfig;
82450
82559
  exports.useDataVariable = useDataVariable;
82560
+ exports.useDeferLoadable = useDeferLoadable;
82561
+ exports.useDerivedVariable = useDerivedVariable;
82451
82562
  exports.useEventBus = useEventBus;
82563
+ exports.useInterval = useInterval;
82564
+ exports.usePrevious = usePrevious;
82452
82565
  exports.useRefreshSelector = useRefreshSelector;
82453
82566
  exports.useRefreshServerComponent = useRefreshServerComponent;
82454
82567
  exports.useRequestExtras = useRequestExtras;
82568
+ exports.useSession = useSession;
82455
82569
  exports.useSessionToken = useSessionToken;
82570
+ exports.useTaskContext = useTaskContext;
82571
+ exports.useTemplate = useTemplate;
82572
+ exports.useTriggerIndex = useTriggerIndex;
82573
+ exports.useUrlSync = useUrlSync;
82456
82574
  exports.useUser = useUser;
82457
82575
  exports.useVariable = useVariable;
82576
+ exports.useVariableState = useVariableState;
82458
82577
  exports.useVariableValue = useVariableValue;
82578
+ exports.useWindowTitle = useWindowTitle;
82459
82579
  exports.verifySessionToken = verifySessionToken;
82460
82580
  Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
82461
82581
  });