@workflow/web 5.3.2 → 5.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/build/client/assets/app-CmaRLUwS.css +1 -0
  2. package/build/client/assets/arrow-up-right-AHTyWXU2.js +9 -0
  3. package/build/client/assets/{entry.client-xzxVCL3o.js → entry.client-BqbaswKw.js} +13 -35
  4. package/build/client/assets/{highlighted-body-JLMTFACH-1yzOVKg0.js → highlighted-body-JLMTFACH-_kzpqYmW.js} +2 -2
  5. package/build/client/assets/{home--wf0CrF6.js → home-DjUPTrY5.js} +91 -161
  6. package/build/client/assets/{index-wl5l5E8H.js → index-BUQuaV5X.js} +78 -149
  7. package/build/client/assets/{manifest-7b81d8d4.js → manifest-9126df65.js} +1 -1
  8. package/build/client/assets/{mermaid-WFAXDIZX-CB__BxYb.js → mermaid-WFAXDIZX-CNo_0yWo.js} +1236 -1340
  9. package/build/client/assets/mermaid-WFAXDIZX-F88p7PFX.css +1 -0
  10. package/build/client/assets/{root-C1XwTNUK.js → root-Bh-E5He-.js} +7 -31
  11. package/build/client/assets/root-kJB77No4.css +1 -0
  12. package/build/client/assets/{rpc-client-SbyXJdFV.js → rpc-client-DL_nSX36.js} +3 -4
  13. package/build/client/assets/{run-detail-2CnpdXm1.js → run-detail-5dPVsaSm.js} +121 -203
  14. package/build/client/assets/{run-usage-DRV6lopZ.js → run-usage-BEswHGKU.js} +15 -24
  15. package/build/client/assets/{run-usage-C3aywyqa.js → run-usage-C_wyncgV.js} +5 -5
  16. package/build/client/assets/{skeleton-DMLgjvZZ.js → skeleton-DE14mNQw.js} +3 -21
  17. package/build/client/assets/{url-state-JAVaNZ_m.js → url-state-5GKQwo-f.js} +471 -702
  18. package/build/client/assets/{zstd-browser-decoder-Z5736ep5.js → zstd-browser-decoder-CbTMLAMd.js} +2 -2
  19. package/build/server/assets/{app-C4Vf0mu1.js → app-C-e60j14.js} +11450 -12386
  20. package/build/server/assets/{esm-CETb4fkq.js → esm-BzrGWk7J.js} +2 -2
  21. package/build/server/assets/{highlighted-body-JLMTFACH-CF_5tt3-.js → highlighted-body-JLMTFACH-B7y0X_Kn.js} +1 -1
  22. package/build/server/assets/{index-BrYeW--s.js → index-DRDsjR--.js} +398 -490
  23. package/build/server/assets/{mermaid-WFAXDIZX-BHZz_uL6.js → mermaid-WFAXDIZX-MsPxEM1Y.js} +1 -1
  24. package/build/server/assets/{token-B94O3LuJ.js → token-CKgyaeCJ.js} +5 -5
  25. package/build/server/assets/{token-k0na1G9v.js → token-DXh0TnqB.js} +6 -6
  26. package/build/server/assets/{token-util-DFlzY9Hw.js → token-util-CCc0uYVy.js} +2 -2
  27. package/build/server/assets/{token-util-DgTmPzWb.js → token-util-DOHYMq7D.js} +1 -1
  28. package/build/server/assets/{wrapper-BEqyNEir.js → wrapper-BzLz38Oh.js} +2 -2
  29. package/build/server/assets/{zstd-browser-decoder-LnaKiDUZ.js → zstd-browser-decoder-BSSEC3XP.js} +1 -1
  30. package/build/server/index.js +1 -1
  31. package/package.json +8 -8
  32. package/build/client/assets/app-BHCSMHev.css +0 -1
  33. package/build/client/assets/arrow-up-right-DyaB_ak4.js +0 -15
  34. package/build/client/assets/mermaid-WFAXDIZX-D8CjRQta.css +0 -1
  35. package/build/client/assets/root-C3ED6Dwc.css +0 -1
@@ -1,24 +1,15 @@
1
- var __defProp = Object.defineProperty;
2
1
  var __typeError = (msg) => {
3
2
  throw TypeError(msg);
4
3
  };
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
7
4
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
8
5
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
9
6
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
7
  var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
11
8
  var _keys, _a;
12
- import { c as createLucideIcon, L as ChevronDown, a as cn, a3 as isRunCreationEvent, b1 as startHookId, a0 as isHookLifecycleEventType, O as cva, p as useComposedRefs, y as createContextScope, K as createSlot, q as useLayoutEffect2, v as useId, P as Primitive, A as composeEventHandlers, s as useControllableState, J as useCallbackRef$1, x as createPopperScope, w as Popper, z as PopperAnchor, E as Presence, D as Portal, b2 as dispatchDiscreteCustomEvent, b3 as useFocusScopeBranch, b4 as useFocusScopeBranchRegistry, b5 as FocusScopeBranchProvider, F as FocusScope, G as DismissableLayer, H as PopperContent, C as ChevronRight, n as Check, b6 as VERCEL_403_ERROR_MESSAGE, T as Tooltip, d as TooltipTrigger, a4 as CopyButton, e as TooltipContent, b7 as formatDuration, B as Button, t as toast, b8 as useDismissableLayerSurface } from "./mermaid-WFAXDIZX-CB__BxYb.js";
13
- import { r as reactExports, j as jsxRuntimeExports, H as React2, a as requireReact, R as ReactExports, I as getDefaultExportFromCjs, g as reactDomExports, C as useSearchParams, B as useNavigate } from "./index-wl5l5E8H.js";
14
- import { b as CircleAlert, C as Circle, R as RotateCw } from "./skeleton-DMLgjvZZ.js";
15
- import { m as fetchRuns, n as bulkCancelRuns$1, o as reenqueueRun$1, w as wakeUpRun$1, p as resumeHook$1, q as fetchHookToken$1, s as cancelRun$1, t as recreateRun$1 } from "./rpc-client-SbyXJdFV.js";
16
- /**
17
- * @license lucide-react v0.575.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */
9
+ import { c as createLucideIcon, L as ChevronDown, a as cn, a3 as isRunCreationEvent, b1 as startHookId, a0 as isHookLifecycleEventType, O as cva, p as useComposedRefs, y as createContextScope, K as createSlot, q as useLayoutEffect2, v as useId, P as Primitive, A as composeEventHandlers, s as useControllableState, J as useCallbackRef$1, x as createPopperScope, w as Popper, z as PopperAnchor, E as Presence, D as Portal, b2 as dispatchDiscreteCustomEvent, b3 as useFocusScopeBranch, b4 as useFocusScopeBranchRegistry, b5 as FocusScopeBranchProvider, F as FocusScope, G as DismissableLayer, H as PopperContent, C as ChevronRight, n as Check, b6 as VERCEL_403_ERROR_MESSAGE, T as Tooltip, d as TooltipTrigger, a4 as CopyButton, e as TooltipContent, b7 as formatDuration, B as Button, t as toast, b8 as useDismissableLayerSurface } from "./mermaid-WFAXDIZX-CNo_0yWo.js";
10
+ import { r as reactExports, j as jsxRuntimeExports, H as React2, a as requireReact, R as ReactExports, I as getDefaultExportFromCjs, g as reactDomExports, C as useSearchParams, B as useNavigate } from "./index-BUQuaV5X.js";
11
+ import { b as CircleAlert, C as Circle, R as RotateCw } from "./skeleton-DE14mNQw.js";
12
+ import { m as fetchRuns, n as bulkCancelRuns$1, o as reenqueueRun$1, w as wakeUpRun$1, p as resumeHook$1, q as fetchHookToken$1, s as cancelRun$1, t as recreateRun$1 } from "./rpc-client-DL_nSX36.js";
22
13
  const __iconNode$d = [
23
14
  ["path", { d: "M6.87 6.87a8 8 0 1 0 11.26 11.26", key: "3on8tj" }],
24
15
  ["path", { d: "M19.9 14.25a8 8 0 0 0-9.15-9.15", key: "15ghsc" }],
@@ -28,12 +19,6 @@ const __iconNode$d = [
28
19
  ["path", { d: "M4 4 2 6", key: "1ycko6" }]
29
20
  ];
30
21
  const AlarmClockOff = createLucideIcon("alarm-clock-off", __iconNode$d);
31
- /**
32
- * @license lucide-react v0.575.0 - ISC
33
- *
34
- * This source code is licensed under the ISC license.
35
- * See the LICENSE file in the root directory of this source tree.
36
- */
37
22
  const __iconNode$c = [
38
23
  ["path", { d: "M12 8V4H8", key: "hb8ula" }],
39
24
  ["rect", { width: "16", height: "12", x: "4", y: "8", rx: "2", key: "enze0r" }],
@@ -43,20 +28,8 @@ const __iconNode$c = [
43
28
  ["path", { d: "M9 13v2", key: "rq6x2g" }]
44
29
  ];
45
30
  const Bot = createLucideIcon("bot", __iconNode$c);
46
- /**
47
- * @license lucide-react v0.575.0 - ISC
48
- *
49
- * This source code is licensed under the ISC license.
50
- * See the LICENSE file in the root directory of this source tree.
51
- */
52
31
  const __iconNode$b = [["path", { d: "m18 15-6-6-6 6", key: "153udz" }]];
53
32
  const ChevronUp = createLucideIcon("chevron-up", __iconNode$b);
54
- /**
55
- * @license lucide-react v0.575.0 - ISC
56
- *
57
- * This source code is licensed under the ISC license.
58
- * See the LICENSE file in the root directory of this source tree.
59
- */
60
33
  const __iconNode$a = [
61
34
  [
62
35
  "path",
@@ -68,46 +41,22 @@ const __iconNode$a = [
68
41
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }]
69
42
  ];
70
43
  const CirclePlay = createLucideIcon("circle-play", __iconNode$a);
71
- /**
72
- * @license lucide-react v0.575.0 - ISC
73
- *
74
- * This source code is licensed under the ISC license.
75
- * See the LICENSE file in the root directory of this source tree.
76
- */
77
44
  const __iconNode$9 = [
78
45
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
79
46
  ["rect", { x: "9", y: "9", width: "6", height: "6", rx: "1", key: "1ssd4o" }]
80
47
  ];
81
48
  const CircleStop = createLucideIcon("circle-stop", __iconNode$9);
82
- /**
83
- * @license lucide-react v0.575.0 - ISC
84
- *
85
- * This source code is licensed under the ISC license.
86
- * See the LICENSE file in the root directory of this source tree.
87
- */
88
49
  const __iconNode$8 = [
89
50
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
90
51
  ["path", { d: "m15 9-6 6", key: "1uzhvr" }],
91
52
  ["path", { d: "m9 9 6 6", key: "z0biqf" }]
92
53
  ];
93
54
  const CircleX = createLucideIcon("circle-x", __iconNode$8);
94
- /**
95
- * @license lucide-react v0.575.0 - ISC
96
- *
97
- * This source code is licensed under the ISC license.
98
- * See the LICENSE file in the root directory of this source tree.
99
- */
100
55
  const __iconNode$7 = [
101
56
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
102
57
  ["path", { d: "M12 6v6l4 2", key: "mmk7yg" }]
103
58
  ];
104
59
  const Clock = createLucideIcon("clock", __iconNode$7);
105
- /**
106
- * @license lucide-react v0.575.0 - ISC
107
- *
108
- * This source code is licensed under the ISC license.
109
- * See the LICENSE file in the root directory of this source tree.
110
- */
111
60
  const __iconNode$6 = [
112
61
  [
113
62
  "path",
@@ -118,36 +67,18 @@ const __iconNode$6 = [
118
67
  ]
119
68
  ];
120
69
  const Diamond = createLucideIcon("diamond", __iconNode$6);
121
- /**
122
- * @license lucide-react v0.575.0 - ISC
123
- *
124
- * This source code is licensed under the ISC license.
125
- * See the LICENSE file in the root directory of this source tree.
126
- */
127
70
  const __iconNode$5 = [
128
71
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
129
72
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
130
73
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
131
74
  ];
132
75
  const Ellipsis = createLucideIcon("ellipsis", __iconNode$5);
133
- /**
134
- * @license lucide-react v0.575.0 - ISC
135
- *
136
- * This source code is licensed under the ISC license.
137
- * See the LICENSE file in the root directory of this source tree.
138
- */
139
76
  const __iconNode$4 = [
140
77
  ["path", { d: "M9 17H7A5 5 0 0 1 7 7h2", key: "8i5ue5" }],
141
78
  ["path", { d: "M15 7h2a5 5 0 1 1 0 10h-2", key: "1b9ql8" }],
142
79
  ["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
143
80
  ];
144
81
  const Link2 = createLucideIcon("link-2", __iconNode$4);
145
- /**
146
- * @license lucide-react v0.575.0 - ISC
147
- *
148
- * This source code is licensed under the ISC license.
149
- * See the LICENSE file in the root directory of this source tree.
150
- */
151
82
  const __iconNode$3 = [
152
83
  [
153
84
  "path",
@@ -159,12 +90,6 @@ const __iconNode$3 = [
159
90
  ["path", { d: "m21.854 2.147-10.94 10.939", key: "12cjpa" }]
160
91
  ];
161
92
  const Send = createLucideIcon("send", __iconNode$3);
162
- /**
163
- * @license lucide-react v0.575.0 - ISC
164
- *
165
- * This source code is licensed under the ISC license.
166
- * See the LICENSE file in the root directory of this source tree.
167
- */
168
93
  const __iconNode$2 = [
169
94
  [
170
95
  "path",
@@ -175,23 +100,11 @@ const __iconNode$2 = [
175
100
  ]
176
101
  ];
177
102
  const Wrench = createLucideIcon("wrench", __iconNode$2);
178
- /**
179
- * @license lucide-react v0.575.0 - ISC
180
- *
181
- * This source code is licensed under the ISC license.
182
- * See the LICENSE file in the root directory of this source tree.
183
- */
184
103
  const __iconNode$1 = [
185
104
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
186
105
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
187
106
  ];
188
107
  const X = createLucideIcon("x", __iconNode$1);
189
- /**
190
- * @license lucide-react v0.575.0 - ISC
191
- *
192
- * This source code is licensed under the ISC license.
193
- * See the LICENSE file in the root directory of this source tree.
194
- */
195
108
  const __iconNode = [
196
109
  [
197
110
  "path",
@@ -221,8 +134,7 @@ class ErrorBoundary extends reactExports.Component {
221
134
  this.setState({ hasError: false, error: null });
222
135
  }
223
136
  componentDidCatch(error, errorInfo) {
224
- var _a2, _b;
225
- (_b = (_a2 = this.props).onCatch) == null ? void 0 : _b.call(_a2, error, () => this.retry());
137
+ this.props.onCatch?.(error, () => this.retry());
226
138
  }
227
139
  render() {
228
140
  if (this.state.hasError) {
@@ -230,16 +142,16 @@ class ErrorBoundary extends reactExports.Component {
230
142
  return this.props.fallback;
231
143
  }
232
144
  const err = this.state.error instanceof Error ? this.state.error : null;
233
- const errorDetails = (err == null ? void 0 : err.stack) ? `${err.message}
145
+ const errorDetails = err?.stack ? `${err.message}
234
146
 
235
- ${err.stack}` : (err == null ? void 0 : err.message) ?? "Unknown error";
147
+ ${err.stack}` : err?.message ?? "Unknown error";
236
148
  return jsxRuntimeExports.jsx(ErrorCard, { title: this.props.title || "An error occurred", details: errorDetails });
237
149
  }
238
150
  return this.props.children;
239
151
  }
240
152
  }
241
153
  function eventTimestamp(event) {
242
- const value = (event == null ? void 0 : event.occurredAt) ?? (event == null ? void 0 : event.createdAt);
154
+ const value = event?.occurredAt ?? event?.createdAt;
243
155
  if (!value)
244
156
  return void 0;
245
157
  const date2 = value instanceof Date ? value : new Date(value);
@@ -252,27 +164,25 @@ function tokenOf(startHook) {
252
164
  return typeof token === "string" && token.length > 0 ? token : void 0;
253
165
  }
254
166
  function findStartHookCreation(events, run) {
255
- var _a2, _b;
256
167
  const creationEvent = events.find(isRunCreationEvent);
257
- const runId = (run == null ? void 0 : run.runId) ?? (creationEvent == null ? void 0 : creationEvent.runId) ?? ((_a2 = events[0]) == null ? void 0 : _a2.runId);
258
- if (!(runId == null ? void 0 : runId.startsWith("wrun_")) || runId.length <= "wrun_".length) {
168
+ const runId = run?.runId ?? creationEvent?.runId ?? events[0]?.runId;
169
+ if (!runId?.startsWith("wrun_") || runId.length <= "wrun_".length) {
259
170
  return void 0;
260
171
  }
261
172
  const hookId = startHookId(runId);
262
- const token = tokenOf(creationEvent && "eventData" in creationEvent ? (_b = creationEvent.eventData) == null ? void 0 : _b.startHook : void 0) ?? tokenOf(run == null ? void 0 : run.startHook);
173
+ const token = tokenOf(creationEvent && "eventData" in creationEvent ? creationEvent.eventData?.startHook : void 0) ?? tokenOf(run?.startHook);
263
174
  const hookEvents = events.filter((event) => event.correlationId === hookId && isHookLifecycleEventType(event.eventType));
264
175
  if (token === void 0 && hookEvents.length === 0)
265
176
  return void 0;
266
177
  if (hookEvents.some((event) => event.eventType === "hook_created")) {
267
178
  return void 0;
268
179
  }
269
- const createdAt = eventTimestamp(creationEvent) ?? ((run == null ? void 0 : run.createdAt) ? new Date(run.createdAt) : void 0) ?? eventTimestamp(hookEvents[0]);
180
+ const createdAt = eventTimestamp(creationEvent) ?? (run?.createdAt ? new Date(run.createdAt) : void 0) ?? eventTimestamp(hookEvents[0]);
270
181
  if (!createdAt)
271
182
  return void 0;
272
183
  return { hookId, runId, token, createdAt };
273
184
  }
274
185
  function ResolveHookModal({ isOpen, onClose, onSubmit, isSubmitting = false }) {
275
- var _a2;
276
186
  const [jsonInput, setJsonInput] = reactExports.useState("");
277
187
  const [parseError, setParseError] = reactExports.useState(null);
278
188
  const textareaRef = reactExports.useRef(null);
@@ -315,7 +225,7 @@ function ResolveHookModal({ isOpen, onClose, onSubmit, isSubmitting = false }) {
315
225
  e.preventDefault();
316
226
  void submitPayload();
317
227
  }, [submitPayload]);
318
- const isMacPlatform = typeof navigator !== "undefined" && (((_a2 = navigator.userAgentData) == null ? void 0 : _a2.platform) ?? navigator.userAgent).toLowerCase().includes("mac");
228
+ const isMacPlatform = typeof navigator !== "undefined" && (navigator.userAgentData?.platform ?? navigator.userAgent).toLowerCase().includes("mac");
319
229
  const handleKeyDown = reactExports.useCallback((e) => {
320
230
  if ((e.metaKey || e.ctrlKey) && e.key === "Enter" && !isSubmitting) {
321
231
  e.preventDefault();
@@ -336,7 +246,7 @@ const millisecondsInMinute = 6e4;
336
246
  const minutesInYear = 525600;
337
247
  const minutesInMonth = 43200;
338
248
  const minutesInDay = 1440;
339
- const constructFromSymbol = Symbol.for("constructDateFrom");
249
+ const constructFromSymbol = /* @__PURE__ */ Symbol.for("constructDateFrom");
340
250
  function constructFrom(date2, value) {
341
251
  if (typeof date2 === "function") return date2(value);
342
252
  if (date2 && typeof date2 === "object" && constructFromSymbol in date2)
@@ -351,22 +261,21 @@ let defaultOptions$1 = {};
351
261
  function getDefaultOptions() {
352
262
  return defaultOptions$1;
353
263
  }
354
- function startOfWeek(date2, options) {
355
- var _a2, _b, _c, _d;
264
+ function startOfWeek(date2, options2) {
356
265
  const defaultOptions2 = getDefaultOptions();
357
- const weekStartsOn = (options == null ? void 0 : options.weekStartsOn) ?? ((_b = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b.weekStartsOn) ?? defaultOptions2.weekStartsOn ?? ((_d = (_c = defaultOptions2.locale) == null ? void 0 : _c.options) == null ? void 0 : _d.weekStartsOn) ?? 0;
358
- const _date = toDate(date2, options == null ? void 0 : options.in);
266
+ const weekStartsOn = options2?.weekStartsOn ?? options2?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
267
+ const _date = toDate(date2, options2?.in);
359
268
  const day = _date.getDay();
360
269
  const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
361
270
  _date.setDate(_date.getDate() - diff);
362
271
  _date.setHours(0, 0, 0, 0);
363
272
  return _date;
364
273
  }
365
- function startOfISOWeek(date2, options) {
366
- return startOfWeek(date2, { ...options, weekStartsOn: 1 });
274
+ function startOfISOWeek(date2, options2) {
275
+ return startOfWeek(date2, { ...options2, weekStartsOn: 1 });
367
276
  }
368
- function getISOWeekYear(date2, options) {
369
- const _date = toDate(date2, options == null ? void 0 : options.in);
277
+ function getISOWeekYear(date2, options2) {
278
+ const _date = toDate(date2, options2?.in);
370
279
  const year = _date.getFullYear();
371
280
  const fourthOfJanuaryOfNextYear = constructFrom(_date, 0);
372
281
  fourthOfJanuaryOfNextYear.setFullYear(year + 1, 0, 4);
@@ -407,14 +316,14 @@ function normalizeDates(context, ...dates) {
407
316
  );
408
317
  return dates.map(normalize2);
409
318
  }
410
- function startOfDay(date2, options) {
411
- const _date = toDate(date2, options == null ? void 0 : options.in);
319
+ function startOfDay(date2, options2) {
320
+ const _date = toDate(date2, options2?.in);
412
321
  _date.setHours(0, 0, 0, 0);
413
322
  return _date;
414
323
  }
415
- function differenceInCalendarDays(laterDate, earlierDate, options) {
324
+ function differenceInCalendarDays(laterDate, earlierDate, options2) {
416
325
  const [laterDate_, earlierDate_] = normalizeDates(
417
- options == null ? void 0 : options.in,
326
+ options2?.in,
418
327
  laterDate,
419
328
  earlierDate
420
329
  );
@@ -424,8 +333,8 @@ function differenceInCalendarDays(laterDate, earlierDate, options) {
424
333
  const earlierTimestamp = +earlierStartOfDay - getTimezoneOffsetInMilliseconds(earlierStartOfDay);
425
334
  return Math.round((laterTimestamp - earlierTimestamp) / millisecondsInDay);
426
335
  }
427
- function startOfISOWeekYear(date2, options) {
428
- const year = getISOWeekYear(date2, options);
336
+ function startOfISOWeekYear(date2, options2) {
337
+ const year = getISOWeekYear(date2, options2);
429
338
  const fourthOfJanuary = constructFrom(date2, 0);
430
339
  fourthOfJanuary.setFullYear(year, 0, 4);
431
340
  fourthOfJanuary.setHours(0, 0, 0, 0);
@@ -453,8 +362,8 @@ function getRoundingMethod(method) {
453
362
  return result === 0 ? 0 : result;
454
363
  };
455
364
  }
456
- function startOfYear(date2, options) {
457
- const date_ = toDate(date2, options == null ? void 0 : options.in);
365
+ function startOfYear(date2, options2) {
366
+ const date_ = toDate(date2, options2?.in);
458
367
  date_.setFullYear(date_.getFullYear(), 0, 1);
459
368
  date_.setHours(0, 0, 0, 0);
460
369
  return date_;
@@ -522,7 +431,7 @@ const formatDistanceLocale = {
522
431
  other: "almost {{count}} years"
523
432
  }
524
433
  };
525
- const formatDistance = (token, count2, options) => {
434
+ const formatDistance = (token, count2, options2) => {
526
435
  let result;
527
436
  const tokenValue = formatDistanceLocale[token];
528
437
  if (typeof tokenValue === "string") {
@@ -532,8 +441,8 @@ const formatDistance = (token, count2, options) => {
532
441
  } else {
533
442
  result = tokenValue.other.replace("{{count}}", count2.toString());
534
443
  }
535
- if (options == null ? void 0 : options.addSuffix) {
536
- if (options.comparison && options.comparison > 0) {
444
+ if (options2?.addSuffix) {
445
+ if (options2.comparison && options2.comparison > 0) {
537
446
  return "in " + result;
538
447
  } else {
539
448
  return result + " ago";
@@ -542,8 +451,8 @@ const formatDistance = (token, count2, options) => {
542
451
  return result;
543
452
  };
544
453
  function buildFormatLongFn(args) {
545
- return (options = {}) => {
546
- const width = options.width ? String(options.width) : args.defaultWidth;
454
+ return (options2 = {}) => {
455
+ const width = options2.width ? String(options2.width) : args.defaultWidth;
547
456
  const format2 = args.formats[width] || args.formats[args.defaultWidth];
548
457
  return format2;
549
458
  };
@@ -590,16 +499,16 @@ const formatRelativeLocale = {
590
499
  };
591
500
  const formatRelative$1 = (token, _date, _baseDate, _options) => formatRelativeLocale[token];
592
501
  function buildLocalizeFn(args) {
593
- return (value, options) => {
594
- const context = (options == null ? void 0 : options.context) ? String(options.context) : "standalone";
502
+ return (value, options2) => {
503
+ const context = options2?.context ? String(options2.context) : "standalone";
595
504
  let valuesArray;
596
505
  if (context === "formatting" && args.formattingValues) {
597
506
  const defaultWidth2 = args.defaultFormattingWidth || args.defaultWidth;
598
- const width = (options == null ? void 0 : options.width) ? String(options.width) : defaultWidth2;
507
+ const width = options2?.width ? String(options2.width) : defaultWidth2;
599
508
  valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth2];
600
509
  } else {
601
510
  const defaultWidth2 = args.defaultWidth;
602
- const width = (options == null ? void 0 : options.width) ? String(options.width) : args.defaultWidth;
511
+ const width = options2?.width ? String(options2.width) : args.defaultWidth;
603
512
  valuesArray = args.values[width] || args.values[defaultWidth2];
604
513
  }
605
514
  const index2 = args.argumentCallback ? args.argumentCallback(value) : value;
@@ -767,8 +676,8 @@ const localize = {
767
676
  })
768
677
  };
769
678
  function buildMatchFn(args) {
770
- return (string, options = {}) => {
771
- const width = options.width;
679
+ return (string, options2 = {}) => {
680
+ const width = options2.width;
772
681
  const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
773
682
  const matchResult = string.match(matchPattern);
774
683
  if (!matchResult) {
@@ -782,9 +691,9 @@ function buildMatchFn(args) {
782
691
  );
783
692
  let value;
784
693
  value = args.valueCallback ? args.valueCallback(key) : key;
785
- value = options.valueCallback ? (
694
+ value = options2.valueCallback ? (
786
695
  // [TODO] -- I challenge you to fix the type
787
- options.valueCallback(value)
696
+ options2.valueCallback(value)
788
697
  ) : value;
789
698
  const rest = string.slice(matchedString.length);
790
699
  return { value, rest };
@@ -807,14 +716,14 @@ function findIndex(array2, predicate) {
807
716
  return void 0;
808
717
  }
809
718
  function buildMatchPatternFn(args) {
810
- return (string, options = {}) => {
719
+ return (string, options2 = {}) => {
811
720
  const matchResult = string.match(args.matchPattern);
812
721
  if (!matchResult) return null;
813
722
  const matchedString = matchResult[0];
814
723
  const parseResult = string.match(args.parsePattern);
815
724
  if (!parseResult) return null;
816
725
  let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
817
- value = options.valueCallback ? options.valueCallback(value) : value;
726
+ value = options2.valueCallback ? options2.valueCallback(value) : value;
818
727
  const rest = string.slice(matchedString.length);
819
728
  return { value, rest };
820
729
  };
@@ -948,31 +857,30 @@ const enUS = {
948
857
  firstWeekContainsDate: 1
949
858
  }
950
859
  };
951
- function getDayOfYear(date2, options) {
952
- const _date = toDate(date2, options == null ? void 0 : options.in);
860
+ function getDayOfYear(date2, options2) {
861
+ const _date = toDate(date2, options2?.in);
953
862
  const diff = differenceInCalendarDays(_date, startOfYear(_date));
954
863
  const dayOfYear = diff + 1;
955
864
  return dayOfYear;
956
865
  }
957
- function getISOWeek(date2, options) {
958
- const _date = toDate(date2, options == null ? void 0 : options.in);
866
+ function getISOWeek(date2, options2) {
867
+ const _date = toDate(date2, options2?.in);
959
868
  const diff = +startOfISOWeek(_date) - +startOfISOWeekYear(_date);
960
869
  return Math.round(diff / millisecondsInWeek) + 1;
961
870
  }
962
- function getWeekYear(date2, options) {
963
- var _a2, _b, _c, _d;
964
- const _date = toDate(date2, options == null ? void 0 : options.in);
871
+ function getWeekYear(date2, options2) {
872
+ const _date = toDate(date2, options2?.in);
965
873
  const year = _date.getFullYear();
966
874
  const defaultOptions2 = getDefaultOptions();
967
- const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d = (_c = defaultOptions2.locale) == null ? void 0 : _c.options) == null ? void 0 : _d.firstWeekContainsDate) ?? 1;
968
- const firstWeekOfNextYear = constructFrom((options == null ? void 0 : options.in) || date2, 0);
875
+ const firstWeekContainsDate = options2?.firstWeekContainsDate ?? options2?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
876
+ const firstWeekOfNextYear = constructFrom(options2?.in || date2, 0);
969
877
  firstWeekOfNextYear.setFullYear(year + 1, 0, firstWeekContainsDate);
970
878
  firstWeekOfNextYear.setHours(0, 0, 0, 0);
971
- const startOfNextYear = startOfWeek(firstWeekOfNextYear, options);
972
- const firstWeekOfThisYear = constructFrom((options == null ? void 0 : options.in) || date2, 0);
879
+ const startOfNextYear = startOfWeek(firstWeekOfNextYear, options2);
880
+ const firstWeekOfThisYear = constructFrom(options2?.in || date2, 0);
973
881
  firstWeekOfThisYear.setFullYear(year, 0, firstWeekContainsDate);
974
882
  firstWeekOfThisYear.setHours(0, 0, 0, 0);
975
- const startOfThisYear = startOfWeek(firstWeekOfThisYear, options);
883
+ const startOfThisYear = startOfWeek(firstWeekOfThisYear, options2);
976
884
  if (+_date >= +startOfNextYear) {
977
885
  return year + 1;
978
886
  } else if (+_date >= +startOfThisYear) {
@@ -981,20 +889,19 @@ function getWeekYear(date2, options) {
981
889
  return year - 1;
982
890
  }
983
891
  }
984
- function startOfWeekYear(date2, options) {
985
- var _a2, _b, _c, _d;
892
+ function startOfWeekYear(date2, options2) {
986
893
  const defaultOptions2 = getDefaultOptions();
987
- const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d = (_c = defaultOptions2.locale) == null ? void 0 : _c.options) == null ? void 0 : _d.firstWeekContainsDate) ?? 1;
988
- const year = getWeekYear(date2, options);
989
- const firstWeek = constructFrom((options == null ? void 0 : options.in) || date2, 0);
894
+ const firstWeekContainsDate = options2?.firstWeekContainsDate ?? options2?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
895
+ const year = getWeekYear(date2, options2);
896
+ const firstWeek = constructFrom(options2?.in || date2, 0);
990
897
  firstWeek.setFullYear(year, 0, firstWeekContainsDate);
991
898
  firstWeek.setHours(0, 0, 0, 0);
992
- const _date = startOfWeek(firstWeek, options);
899
+ const _date = startOfWeek(firstWeek, options2);
993
900
  return _date;
994
901
  }
995
- function getWeek(date2, options) {
996
- const _date = toDate(date2, options == null ? void 0 : options.in);
997
- const diff = +startOfWeek(_date, options) - +startOfWeekYear(_date, options);
902
+ function getWeek(date2, options2) {
903
+ const _date = toDate(date2, options2?.in);
904
+ const diff = +startOfWeek(_date, options2) - +startOfWeekYear(_date, options2);
998
905
  return Math.round(diff / millisecondsInWeek) + 1;
999
906
  }
1000
907
  function addLeadingZeros(number, targetLength) {
@@ -1097,8 +1004,8 @@ const formatters = {
1097
1004
  return lightFormatters.y(date2, token);
1098
1005
  },
1099
1006
  // Local week-numbering year
1100
- Y: function(date2, token, localize2, options) {
1101
- const signedWeekYear = getWeekYear(date2, options);
1007
+ Y: function(date2, token, localize2, options2) {
1008
+ const signedWeekYear = getWeekYear(date2, options2);
1102
1009
  const weekYear = signedWeekYear > 0 ? signedWeekYear : 1 - signedWeekYear;
1103
1010
  if (token === "YY") {
1104
1011
  const twoDigitYear = weekYear % 100;
@@ -1255,8 +1162,8 @@ const formatters = {
1255
1162
  }
1256
1163
  },
1257
1164
  // Local week of year
1258
- w: function(date2, token, localize2, options) {
1259
- const week = getWeek(date2, options);
1165
+ w: function(date2, token, localize2, options2) {
1166
+ const week = getWeek(date2, options2);
1260
1167
  if (token === "wo") {
1261
1168
  return localize2.ordinalNumber(week, { unit: "week" });
1262
1169
  }
@@ -1319,9 +1226,9 @@ const formatters = {
1319
1226
  }
1320
1227
  },
1321
1228
  // Local day of week
1322
- e: function(date2, token, localize2, options) {
1229
+ e: function(date2, token, localize2, options2) {
1323
1230
  const dayOfWeek = date2.getDay();
1324
- const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1231
+ const localDayOfWeek = (dayOfWeek - options2.weekStartsOn + 8) % 7 || 7;
1325
1232
  switch (token) {
1326
1233
  // Numerical value (Nth day of week with current locale or weekStartsOn)
1327
1234
  case "e":
@@ -1359,9 +1266,9 @@ const formatters = {
1359
1266
  }
1360
1267
  },
1361
1268
  // Stand-alone local day of week
1362
- c: function(date2, token, localize2, options) {
1269
+ c: function(date2, token, localize2, options2) {
1363
1270
  const dayOfWeek = date2.getDay();
1364
- const localDayOfWeek = (dayOfWeek - options.weekStartsOn + 8) % 7 || 7;
1271
+ const localDayOfWeek = (dayOfWeek - options2.weekStartsOn + 8) % 7 || 7;
1365
1272
  switch (token) {
1366
1273
  // Numerical value (same as in `e`)
1367
1274
  case "c":
@@ -1780,13 +1687,12 @@ const longFormattingTokensRegExp = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g;
1780
1687
  const escapedStringRegExp = /^'([^]*?)'?$/;
1781
1688
  const doubleQuoteRegExp = /''/g;
1782
1689
  const unescapedLatinCharacterRegExp = /[a-zA-Z]/;
1783
- function format(date2, formatStr, options) {
1784
- var _a2, _b, _c, _d, _e, _f, _g, _h;
1690
+ function format(date2, formatStr, options2) {
1785
1691
  const defaultOptions2 = getDefaultOptions();
1786
- const locale = (options == null ? void 0 : options.locale) ?? defaultOptions2.locale ?? enUS;
1787
- const firstWeekContainsDate = (options == null ? void 0 : options.firstWeekContainsDate) ?? ((_b = (_a2 = options == null ? void 0 : options.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b.firstWeekContainsDate) ?? defaultOptions2.firstWeekContainsDate ?? ((_d = (_c = defaultOptions2.locale) == null ? void 0 : _c.options) == null ? void 0 : _d.firstWeekContainsDate) ?? 1;
1788
- const weekStartsOn = (options == null ? void 0 : options.weekStartsOn) ?? ((_f = (_e = options == null ? void 0 : options.locale) == null ? void 0 : _e.options) == null ? void 0 : _f.weekStartsOn) ?? defaultOptions2.weekStartsOn ?? ((_h = (_g = defaultOptions2.locale) == null ? void 0 : _g.options) == null ? void 0 : _h.weekStartsOn) ?? 0;
1789
- const originalDate = toDate(date2, options == null ? void 0 : options.in);
1692
+ const locale = options2?.locale ?? defaultOptions2.locale ?? enUS;
1693
+ const firstWeekContainsDate = options2?.firstWeekContainsDate ?? options2?.locale?.options?.firstWeekContainsDate ?? defaultOptions2.firstWeekContainsDate ?? defaultOptions2.locale?.options?.firstWeekContainsDate ?? 1;
1694
+ const weekStartsOn = options2?.weekStartsOn ?? options2?.locale?.options?.weekStartsOn ?? defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
1695
+ const originalDate = toDate(date2, options2?.in);
1790
1696
  if (!isValid(originalDate)) {
1791
1697
  throw new RangeError("Invalid time value");
1792
1698
  }
@@ -1826,7 +1732,7 @@ function format(date2, formatStr, options) {
1826
1732
  return parts.map((part) => {
1827
1733
  if (!part.isToken) return part.value;
1828
1734
  const token = part.value;
1829
- if (!(options == null ? void 0 : options.useAdditionalWeekYearTokens) && isProtectedWeekYearToken(token) || !(options == null ? void 0 : options.useAdditionalDayOfYearTokens) && isProtectedDayOfYearToken(token)) {
1735
+ if (!options2?.useAdditionalWeekYearTokens && isProtectedWeekYearToken(token) || !options2?.useAdditionalDayOfYearTokens && isProtectedDayOfYearToken(token)) {
1830
1736
  warnOrThrowProtectedError(token, formatStr, String(date2));
1831
1737
  }
1832
1738
  const formatter = formatters[token[0]];
@@ -1840,27 +1746,27 @@ function cleanEscapedString(input) {
1840
1746
  }
1841
1747
  return matched[1].replace(doubleQuoteRegExp, "'");
1842
1748
  }
1843
- function formatDistanceStrict(laterDate, earlierDate, options) {
1749
+ function formatDistanceStrict(laterDate, earlierDate, options2) {
1844
1750
  const defaultOptions2 = getDefaultOptions();
1845
- const locale = (options == null ? void 0 : options.locale) ?? defaultOptions2.locale ?? enUS;
1751
+ const locale = options2?.locale ?? defaultOptions2.locale ?? enUS;
1846
1752
  const comparison = compareAsc(laterDate, earlierDate);
1847
1753
  if (isNaN(comparison)) {
1848
1754
  throw new RangeError("Invalid time value");
1849
1755
  }
1850
- const localizeOptions = Object.assign({}, options, {
1851
- addSuffix: options == null ? void 0 : options.addSuffix,
1756
+ const localizeOptions = Object.assign({}, options2, {
1757
+ addSuffix: options2?.addSuffix,
1852
1758
  comparison
1853
1759
  });
1854
1760
  const [laterDate_, earlierDate_] = normalizeDates(
1855
- options == null ? void 0 : options.in,
1761
+ options2?.in,
1856
1762
  ...comparison > 0 ? [earlierDate, laterDate] : [laterDate, earlierDate]
1857
1763
  );
1858
- const roundingMethod = getRoundingMethod((options == null ? void 0 : options.roundingMethod) ?? "round");
1764
+ const roundingMethod = getRoundingMethod(options2?.roundingMethod ?? "round");
1859
1765
  const milliseconds = earlierDate_.getTime() - laterDate_.getTime();
1860
1766
  const minutes = milliseconds / millisecondsInMinute;
1861
1767
  const timezoneOffset = getTimezoneOffsetInMilliseconds(earlierDate_) - getTimezoneOffsetInMilliseconds(laterDate_);
1862
1768
  const dstNormalizedMinutes = (milliseconds - timezoneOffset) / millisecondsInMinute;
1863
- const defaultUnit = options == null ? void 0 : options.unit;
1769
+ const defaultUnit = options2?.unit;
1864
1770
  let unit;
1865
1771
  if (!defaultUnit) {
1866
1772
  if (minutes < 1) {
@@ -1899,15 +1805,14 @@ function formatDistanceStrict(laterDate, earlierDate, options) {
1899
1805
  return locale.formatDistance("xYears", years, localizeOptions);
1900
1806
  }
1901
1807
  }
1902
- function formatDistanceToNowStrict(date2, options) {
1903
- return formatDistanceStrict(date2, constructNow(date2), options);
1808
+ function formatDistanceToNowStrict(date2, options2) {
1809
+ return formatDistanceStrict(date2, constructNow(date2), options2);
1904
1810
  }
1905
- function formatRelative(date2, baseDate, options) {
1906
- var _a2, _b;
1907
- const [date_, baseDate_] = normalizeDates(options == null ? void 0 : options.in, date2, baseDate);
1811
+ function formatRelative(date2, baseDate, options2) {
1812
+ const [date_, baseDate_] = normalizeDates(options2?.in, date2, baseDate);
1908
1813
  const defaultOptions2 = getDefaultOptions();
1909
1814
  const locale = defaultOptions2.locale ?? enUS;
1910
- const weekStartsOn = defaultOptions2.weekStartsOn ?? ((_b = (_a2 = defaultOptions2.locale) == null ? void 0 : _a2.options) == null ? void 0 : _b.weekStartsOn) ?? 0;
1815
+ const weekStartsOn = defaultOptions2.weekStartsOn ?? defaultOptions2.locale?.options?.weekStartsOn ?? 0;
1911
1816
  const diff = differenceInCalendarDays(date_, baseDate_);
1912
1817
  if (isNaN(diff)) {
1913
1818
  throw new RangeError("Invalid time value");
@@ -2570,7 +2475,7 @@ function createCollection2(name) {
2570
2475
  reactExports.useEffect(() => {
2571
2476
  const element = ref.current;
2572
2477
  const registered = registeredRef.current;
2573
- if (((registered == null ? void 0 : registered.element) ?? null) === element && (!element || (registered == null ? void 0 : registered.itemData) === memoizedItemData)) {
2478
+ if ((registered?.element ?? null) === element && (!element || registered?.itemData === memoizedItemData)) {
2574
2479
  return;
2575
2480
  }
2576
2481
  registeredRef.current = element ? { element, itemData: memoizedItemData } : null;
@@ -2715,8 +2620,8 @@ function useFocusGuards() {
2715
2620
  count++;
2716
2621
  return () => {
2717
2622
  if (count === 1) {
2718
- guards == null ? void 0 : guards.start.remove();
2719
- guards == null ? void 0 : guards.end.remove();
2623
+ guards?.start.remove();
2624
+ guards?.end.remove();
2720
2625
  guards = null;
2721
2626
  }
2722
2627
  count = Math.max(0, count - 1);
@@ -3292,12 +3197,12 @@ function innerCreateMedium(defaults, middleware2) {
3292
3197
  };
3293
3198
  return medium;
3294
3199
  }
3295
- function createSidecarMedium(options) {
3296
- if (options === void 0) {
3297
- options = {};
3200
+ function createSidecarMedium(options2) {
3201
+ if (options2 === void 0) {
3202
+ options2 = {};
3298
3203
  }
3299
3204
  var medium = innerCreateMedium(null);
3300
- medium.options = __assign({ async: true, ssr: false }, options);
3205
+ medium.options = __assign({ async: true, ssr: false }, options2);
3301
3206
  return medium;
3302
3207
  }
3303
3208
  var SideCar$1 = function(_a2) {
@@ -3978,14 +3883,13 @@ var MenuContentImpl = /* @__PURE__ */ reactExports.forwardRef(
3978
3883
  shards
3979
3884
  } : void 0;
3980
3885
  const handleTypeaheadSearch = /* @__PURE__ */ __name$3((key) => {
3981
- var _a2, _b;
3982
3886
  const search = searchRef.current + key;
3983
3887
  const items = getItems().filter((item) => !item.disabled);
3984
3888
  const currentItem = document.activeElement;
3985
- const currentMatch = (_a2 = items.find((item) => item.ref.current === currentItem)) == null ? void 0 : _a2.textValue;
3889
+ const currentMatch = items.find((item) => item.ref.current === currentItem)?.textValue;
3986
3890
  const values = items.map((item) => item.textValue);
3987
3891
  const nextMatch = getNextMatch(values, search, currentMatch);
3988
- const newItem = (_b = items.find((item) => item.textValue === nextMatch)) == null ? void 0 : _b.ref.current;
3892
+ const newItem = items.find((item) => item.textValue === nextMatch)?.ref.current;
3989
3893
  function updateSearch(value) {
3990
3894
  searchRef.current = value;
3991
3895
  window.clearTimeout(timerRef.current);
@@ -4002,9 +3906,8 @@ var MenuContentImpl = /* @__PURE__ */ reactExports.forwardRef(
4002
3906
  }, []);
4003
3907
  useFocusGuards();
4004
3908
  const isPointerMovingToSubmenu = reactExports.useCallback((event) => {
4005
- var _a2, _b;
4006
- const isMovingTowards = pointerDirRef.current === ((_a2 = pointerGraceIntentRef.current) == null ? void 0 : _a2.side);
4007
- return isMovingTowards && isPointerInGraceArea(event, (_b = pointerGraceIntentRef.current) == null ? void 0 : _b.area);
3909
+ const isMovingTowards = pointerDirRef.current === pointerGraceIntentRef.current?.side;
3910
+ return isMovingTowards && isPointerInGraceArea(event, pointerGraceIntentRef.current?.area);
4008
3911
  }, []);
4009
3912
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
4010
3913
  MenuContentProvider,
@@ -4019,9 +3922,8 @@ var MenuContentImpl = /* @__PURE__ */ reactExports.forwardRef(
4019
3922
  ),
4020
3923
  onItemLeave: reactExports.useCallback(
4021
3924
  (event) => {
4022
- var _a2;
4023
3925
  if (isPointerMovingToSubmenu(event)) return;
4024
- (_a2 = contentRef.current) == null ? void 0 : _a2.focus();
3926
+ contentRef.current?.focus();
4025
3927
  setCurrentItemId(null);
4026
3928
  },
4027
3929
  [isPointerMovingToSubmenu]
@@ -4043,9 +3945,8 @@ var MenuContentImpl = /* @__PURE__ */ reactExports.forwardRef(
4043
3945
  trapped: trapFocus,
4044
3946
  branches: branchNodes,
4045
3947
  onMountAutoFocus: composeEventHandlers(onOpenAutoFocus, (event) => {
4046
- var _a2;
4047
3948
  event.preventDefault();
4048
- (_a2 = contentRef.current) == null ? void 0 : _a2.focus({ preventScroll: true });
3949
+ contentRef.current?.focus({ preventScroll: true });
4049
3950
  }),
4050
3951
  onUnmountAutoFocus: onCloseAutoFocus,
4051
3952
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -4153,7 +4054,7 @@ var MenuItem = /* @__PURE__ */ reactExports.forwardRef(
4153
4054
  const menuItem = ref.current;
4154
4055
  if (!disabled && menuItem) {
4155
4056
  const itemSelectEvent = new CustomEvent(ITEM_SELECT, { bubbles: true, cancelable: true });
4156
- menuItem.addEventListener(ITEM_SELECT, (event) => onSelect == null ? void 0 : onSelect(event), { once: true });
4057
+ menuItem.addEventListener(ITEM_SELECT, (event) => onSelect?.(event), { once: true });
4157
4058
  dispatchDiscreteCustomEvent(menuItem, itemSelectEvent);
4158
4059
  if (itemSelectEvent.defaultPrevented) {
4159
4060
  isPointerDownRef.current = false;
@@ -4170,13 +4071,11 @@ var MenuItem = /* @__PURE__ */ reactExports.forwardRef(
4170
4071
  disabled,
4171
4072
  onClick: composeEventHandlers(props.onClick, handleSelect),
4172
4073
  onPointerDown: (event) => {
4173
- var _a2;
4174
- (_a2 = props.onPointerDown) == null ? void 0 : _a2.call(props, event);
4074
+ props.onPointerDown?.(event);
4175
4075
  isPointerDownRef.current = true;
4176
4076
  },
4177
4077
  onPointerUp: composeEventHandlers(props.onPointerUp, (event) => {
4178
- var _a2;
4179
- if (!isPointerDownRef.current) (_a2 = event.currentTarget) == null ? void 0 : _a2.click();
4078
+ if (!isPointerDownRef.current) event.currentTarget?.click();
4180
4079
  }),
4181
4080
  onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
4182
4081
  if (disabled || event.target !== event.currentTarget) {
@@ -4265,7 +4164,7 @@ var MenuCheckboxItem = /* @__PURE__ */ reactExports.forwardRef(
4265
4164
  "data-state": getCheckedState(checked),
4266
4165
  onSelect: composeEventHandlers(
4267
4166
  checkboxItemProps.onSelect,
4268
- () => onCheckedChange == null ? void 0 : onCheckedChange(isIndeterminate(checked) ? true : !checked),
4167
+ () => onCheckedChange?.(isIndeterminate(checked) ? true : !checked),
4269
4168
  { checkForDefaultPrevented: false }
4270
4169
  )
4271
4170
  }
@@ -4294,10 +4193,7 @@ var MenuRadioItem = /* @__PURE__ */ reactExports.forwardRef(
4294
4193
  "data-state": getCheckedState(checked),
4295
4194
  onSelect: composeEventHandlers(
4296
4195
  radioItemProps.onSelect,
4297
- () => {
4298
- var _a2;
4299
- return (_a2 = context.onValueChange) == null ? void 0 : _a2.call(context, value);
4300
- },
4196
+ () => context.onValueChange?.(value),
4301
4197
  { checkForDefaultPrevented: false }
4302
4198
  )
4303
4199
  }
@@ -4380,8 +4276,7 @@ var MenuSubTrigger = /* @__PURE__ */ reactExports.forwardRef(
4380
4276
  ...props,
4381
4277
  ref: composedRefs,
4382
4278
  onClick: (event) => {
4383
- var _a2;
4384
- (_a2 = props.onClick) == null ? void 0 : _a2.call(props, event);
4279
+ props.onClick?.(event);
4385
4280
  if (props.disabled || event.defaultPrevented) return;
4386
4281
  event.currentTarget.focus();
4387
4282
  if (!context.open) context.onOpenChange(true);
@@ -4403,11 +4298,10 @@ var MenuSubTrigger = /* @__PURE__ */ reactExports.forwardRef(
4403
4298
  onPointerLeave: composeEventHandlers(
4404
4299
  props.onPointerLeave,
4405
4300
  whenMouse((event) => {
4406
- var _a2, _b;
4407
4301
  clearOpenTimer();
4408
- const contentRect = (_a2 = context.content) == null ? void 0 : _a2.getBoundingClientRect();
4302
+ const contentRect = context.content?.getBoundingClientRect();
4409
4303
  if (contentRect) {
4410
- const side = (_b = context.content) == null ? void 0 : _b.dataset.side;
4304
+ const side = context.content?.dataset.side;
4411
4305
  const rightSide = side === "right";
4412
4306
  const bleed = rightSide ? -5 : 5;
4413
4307
  const contentNearEdge = contentRect[rightSide ? "left" : "right"];
@@ -4437,7 +4331,6 @@ var MenuSubTrigger = /* @__PURE__ */ reactExports.forwardRef(
4437
4331
  })
4438
4332
  ),
4439
4333
  onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
4440
- var _a2;
4441
4334
  if (props.disabled || event.target !== event.currentTarget) {
4442
4335
  return;
4443
4336
  }
@@ -4447,7 +4340,7 @@ var MenuSubTrigger = /* @__PURE__ */ reactExports.forwardRef(
4447
4340
  }
4448
4341
  if (SUB_OPEN_KEYS[rootContext.dir].includes(event.key)) {
4449
4342
  context.onOpenChange(true);
4450
- (_a2 = context.content) == null ? void 0 : _a2.focus();
4343
+ context.content?.focus();
4451
4344
  event.preventDefault();
4452
4345
  }
4453
4346
  })
@@ -4478,8 +4371,7 @@ var MenuSubContent = /* @__PURE__ */ reactExports.forwardRef(
4478
4371
  disableOutsideScroll: false,
4479
4372
  trapFocus: false,
4480
4373
  onOpenAutoFocus: (event) => {
4481
- var _a2;
4482
- if (rootContext.isUsingKeyboardRef.current) (_a2 = ref.current) == null ? void 0 : _a2.focus();
4374
+ if (rootContext.isUsingKeyboardRef.current) ref.current?.focus();
4483
4375
  event.preventDefault();
4484
4376
  },
4485
4377
  onCloseAutoFocus: (event) => event.preventDefault(),
@@ -4491,12 +4383,11 @@ var MenuSubContent = /* @__PURE__ */ reactExports.forwardRef(
4491
4383
  event.preventDefault();
4492
4384
  }),
4493
4385
  onKeyDown: composeEventHandlers(props.onKeyDown, (event) => {
4494
- var _a2;
4495
4386
  const isKeyDownInside = event.currentTarget.contains(event.target);
4496
4387
  const isCloseKey = SUB_CLOSE_KEYS[rootContext.dir].includes(event.key);
4497
4388
  if (isKeyDownInside && isCloseKey) {
4498
4389
  context.onOpenChange(false);
4499
- (_a2 = subContext.trigger) == null ? void 0 : _a2.focus();
4390
+ subContext.trigger?.focus();
4500
4391
  event.preventDefault();
4501
4392
  }
4502
4393
  })
@@ -4669,8 +4560,7 @@ var DropdownMenuContent$1 = /* @__PURE__ */ reactExports.forwardRef(
4669
4560
  ...contentProps,
4670
4561
  ref: forwardedRef,
4671
4562
  onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
4672
- var _a2;
4673
- if (!hasInteractedOutsideRef.current) (_a2 = context.triggerRef.current) == null ? void 0 : _a2.focus();
4563
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
4674
4564
  hasInteractedOutsideRef.current = false;
4675
4565
  event.preventDefault();
4676
4566
  }),
@@ -4873,15 +4763,6 @@ const DropdownMenuSeparator = reactExports.forwardRef(({ className, ...props },
4873
4763
  DropdownMenuSeparator.displayName = DropdownMenuSeparator$1.displayName;
4874
4764
  var shim = { exports: {} };
4875
4765
  var useSyncExternalStoreShim_production = {};
4876
- /**
4877
- * @license React
4878
- * use-sync-external-store-shim.production.js
4879
- *
4880
- * Copyright (c) Meta Platforms, Inc. and affiliates.
4881
- *
4882
- * This source code is licensed under the MIT license found in the
4883
- * LICENSE file in the root directory of this source tree.
4884
- */
4885
4766
  var hasRequiredUseSyncExternalStoreShim_production;
4886
4767
  function requireUseSyncExternalStoreShim_production() {
4887
4768
  if (hasRequiredUseSyncExternalStoreShim_production) return useSyncExternalStoreShim_production;
@@ -5132,19 +5013,19 @@ let __timestamp = 0;
5132
5013
  const getTimestamp = () => ++__timestamp;
5133
5014
  async function internalMutate(...args) {
5134
5015
  const [cache2, _key, _data, _opts] = args;
5135
- const options = mergeObjects$1({
5016
+ const options2 = mergeObjects$1({
5136
5017
  populateCache: true,
5137
5018
  throwOnError: true
5138
5019
  }, typeof _opts === "boolean" ? {
5139
5020
  revalidate: _opts
5140
5021
  } : _opts || {});
5141
- let populateCache = options.populateCache;
5142
- const rollbackOnErrorOption = options.rollbackOnError;
5143
- let optimisticData = options.optimisticData;
5022
+ let populateCache = options2.populateCache;
5023
+ const rollbackOnErrorOption = options2.rollbackOnError;
5024
+ let optimisticData = options2.optimisticData;
5144
5025
  const rollbackOnError = (error) => {
5145
5026
  return typeof rollbackOnErrorOption === "function" ? rollbackOnErrorOption(error) : rollbackOnErrorOption !== false;
5146
5027
  };
5147
- const throwOnError = options.throwOnError;
5028
+ const throwOnError = options2.throwOnError;
5148
5029
  if (isFunction(_key)) {
5149
5030
  const keyFilter = _key;
5150
5031
  const matchedKeys = [];
@@ -5167,7 +5048,7 @@ async function internalMutate(...args) {
5167
5048
  const [EVENT_REVALIDATORS, MUTATION, FETCH, PRELOAD] = SWRGlobalState.get(cache2);
5168
5049
  const startRevalidate = () => {
5169
5050
  const revalidators = EVENT_REVALIDATORS[key];
5170
- const revalidate = isFunction(options.revalidate) ? options.revalidate(get2().data, _k) : options.revalidate !== false;
5051
+ const revalidate = isFunction(options2.revalidate) ? options2.revalidate(get2().data, _k) : options2.revalidate !== false;
5171
5052
  if (revalidate) {
5172
5053
  delete FETCH[key];
5173
5054
  delete PRELOAD[key];
@@ -5260,9 +5141,9 @@ const revalidateAllKeys = (revalidators, type) => {
5260
5141
  if (revalidators[key][0]) revalidators[key][0](type);
5261
5142
  }
5262
5143
  };
5263
- const initCache = (provider, options) => {
5144
+ const initCache = (provider, options2) => {
5264
5145
  if (!SWRGlobalState.has(provider)) {
5265
- const opts = mergeObjects$1(defaultConfigOptions, options);
5146
+ const opts = mergeObjects$1(defaultConfigOptions, options2);
5266
5147
  const EVENT_REVALIDATORS = /* @__PURE__ */ Object.create(null);
5267
5148
  const mutate2 = internalMutate.bind(UNDEFINED, provider);
5268
5149
  let unmount = noop$1;
@@ -6151,26 +6032,26 @@ const infinite = (useSWRNext) => (getKey, fn, config) => {
6151
6032
  const mutate2 = reactExports.useCallback(
6152
6033
  // eslint-disable-next-line func-names
6153
6034
  function(data, opts) {
6154
- const options = typeof opts === "boolean" ? {
6035
+ const options2 = typeof opts === "boolean" ? {
6155
6036
  revalidate: opts
6156
6037
  } : opts || {};
6157
- const shouldRevalidate = options.revalidate !== false;
6038
+ const shouldRevalidate = options2.revalidate !== false;
6158
6039
  if (!infiniteKey) return EMPTY_PROMISE;
6159
6040
  if (shouldRevalidate) {
6160
6041
  if (!isUndefined(data)) {
6161
6042
  set2({
6162
6043
  _i: false,
6163
- _r: options.revalidate
6044
+ _r: options2.revalidate
6164
6045
  });
6165
6046
  } else {
6166
6047
  set2({
6167
6048
  _i: true,
6168
- _r: options.revalidate
6049
+ _r: options2.revalidate
6169
6050
  });
6170
6051
  }
6171
6052
  }
6172
6053
  return arguments.length ? swr.mutate(data, {
6173
- ...options,
6054
+ ...options2,
6174
6055
  revalidate: shouldRevalidate
6175
6056
  }) : swr.mutate();
6176
6057
  },
@@ -6243,16 +6124,16 @@ const OBSERVABILITY_UPGRADE_REQUIRED_CODE = "observability-upgrade-required";
6243
6124
  const OBSERVABILITY_UPGRADE_REQUIRED_MESSAGE = "This workflow observability data is outside your current plan window. Upgrade Observability Plus to view up to 30 days of workflow data.";
6244
6125
  const OBSERVABILITY_UPGRADE_REQUIRED_TITLE = "Upgrade Observability Plus";
6245
6126
  class WorkflowWebAPIError extends Error {
6246
- constructor(message2, options) {
6247
- super(message2, { cause: options == null ? void 0 : options.cause });
6248
- __publicField(this, "request");
6249
- __publicField(this, "layer");
6127
+ request;
6128
+ layer;
6129
+ constructor(message2, options2) {
6130
+ super(message2, { cause: options2?.cause });
6250
6131
  this.name = "WorkflowWebAPIError";
6251
- this.request = options == null ? void 0 : options.request;
6252
- this.layer = options == null ? void 0 : options.layer;
6253
- if ((options == null ? void 0 : options.cause) instanceof Error) {
6132
+ this.request = options2?.request;
6133
+ this.layer = options2?.layer;
6134
+ if (options2?.cause instanceof Error) {
6254
6135
  this.stack = `${this.stack}
6255
- Caused by: ${options.cause.stack}`;
6136
+ Caused by: ${options2.cause.stack}`;
6256
6137
  }
6257
6138
  }
6258
6139
  }
@@ -6264,8 +6145,7 @@ function createWorkflowAPIError(serverError) {
6264
6145
  });
6265
6146
  }
6266
6147
  function isObservabilityUpgradeRequired(error) {
6267
- var _a2, _b;
6268
- return error instanceof WorkflowWebAPIError && ((_a2 = error.request) == null ? void 0 : _a2.status) === 402 && ((_b = error.request) == null ? void 0 : _b.code) === OBSERVABILITY_UPGRADE_REQUIRED_CODE;
6148
+ return error instanceof WorkflowWebAPIError && error.request?.status === 402 && error.request?.code === OBSERVABILITY_UPGRADE_REQUIRED_CODE;
6269
6149
  }
6270
6150
  function getErrorTitle(error, fallback) {
6271
6151
  if (isObservabilityUpgradeRequired(error)) {
@@ -6274,13 +6154,12 @@ function getErrorTitle(error, fallback) {
6274
6154
  return fallback;
6275
6155
  }
6276
6156
  const getErrorMessage = (error) => {
6277
- var _a2;
6278
6157
  if (isObservabilityUpgradeRequired(error)) {
6279
6158
  return OBSERVABILITY_UPGRADE_REQUIRED_MESSAGE;
6280
6159
  }
6281
6160
  if ("layer" in error && error.layer) {
6282
6161
  if (error instanceof WorkflowWebAPIError) {
6283
- if (((_a2 = error.request) == null ? void 0 : _a2.status) === 403) {
6162
+ if (error.request?.status === 403) {
6284
6163
  return VERCEL_403_ERROR_MESSAGE;
6285
6164
  }
6286
6165
  }
@@ -6319,13 +6198,12 @@ async function unwrapOrThrow(promise) {
6319
6198
  if (error) throw error;
6320
6199
  return result;
6321
6200
  }
6322
- function useInfiniteList(cacheKey, fetchFn, getItemKey, options = {}) {
6323
- var _a2;
6324
- const { keepPreviousData = true, revalidateCached = false } = options;
6201
+ function useInfiniteList(cacheKey, fetchFn, getItemKey, options2 = {}) {
6202
+ const { keepPreviousData = true, revalidateCached = false } = options2;
6325
6203
  const getKey = reactExports.useCallback(
6326
6204
  (_index, prev) => {
6327
6205
  if (prev && (!prev.hasMore || !prev.cursor)) return null;
6328
- return [cacheKey, (prev == null ? void 0 : prev.cursor) ?? null];
6206
+ return [cacheKey, prev?.cursor ?? null];
6329
6207
  },
6330
6208
  [cacheKey]
6331
6209
  );
@@ -6361,8 +6239,8 @@ function useInfiniteList(cacheKey, fetchFn, getItemKey, options = {}) {
6361
6239
  }
6362
6240
  return result;
6363
6241
  }, [pages, getItemKey]);
6364
- const lastPage = pages == null ? void 0 : pages[pages.length - 1];
6365
- const hasMore = Boolean((lastPage == null ? void 0 : lastPage.hasMore) && (lastPage == null ? void 0 : lastPage.cursor));
6242
+ const lastPage = pages?.[pages.length - 1];
6243
+ const hasMore = Boolean(lastPage?.hasMore && lastPage?.cursor);
6366
6244
  const isLoadingMore = size > 0 && Boolean(pages) && pages.length < size;
6367
6245
  const loadMore = reactExports.useCallback(() => {
6368
6246
  if (isValidating || !hasMore) return;
@@ -6384,7 +6262,7 @@ function useInfiniteList(cacheKey, fetchFn, getItemKey, options = {}) {
6384
6262
  hasMore,
6385
6263
  loadMore,
6386
6264
  reload,
6387
- pageInfo: (_a2 = pages == null ? void 0 : pages[0]) == null ? void 0 : _a2.pageInfo
6265
+ pageInfo: pages?.[0]?.pageInfo
6388
6266
  };
6389
6267
  }
6390
6268
  function useWorkflowRunsInfinite(env, params) {
@@ -6434,8 +6312,8 @@ async function recreateRun(env, runId) {
6434
6312
  async function reenqueueRun(env, runId) {
6435
6313
  await unwrapOrThrow(reenqueueRun$1(env, runId));
6436
6314
  }
6437
- async function wakeUpRun(env, runId, options) {
6438
- return unwrapOrThrow(wakeUpRun$1(env, runId, options));
6315
+ async function wakeUpRun(env, runId, options2) {
6316
+ return unwrapOrThrow(wakeUpRun$1(env, runId, options2));
6439
6317
  }
6440
6318
  async function resumeHook(env, token, payload) {
6441
6319
  return unwrapOrThrow(resumeHook$1(env, token, payload));
@@ -6536,7 +6414,6 @@ function StatusBadge({
6536
6414
  className,
6537
6415
  durationMs
6538
6416
  }) {
6539
- var _a2;
6540
6417
  const content = /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: cn("flex flex-row gap-2", className), children: [
6541
6418
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-1.5", children: [
6542
6419
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -6556,11 +6433,11 @@ function StatusBadge({
6556
6433
  ")"
6557
6434
  ] })
6558
6435
  ] });
6559
- const errorCode = status === "failed" ? getErrorCode(context == null ? void 0 : context.error) : void 0;
6436
+ const errorCode = status === "failed" ? getErrorCode(context?.error) : void 0;
6560
6437
  if (errorCode) {
6561
6438
  return /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorCodeBadge, { content, errorCode });
6562
6439
  }
6563
- const cancelReason = (_a2 = context == null ? void 0 : context.cancelReason) == null ? void 0 : _a2.trim();
6440
+ const cancelReason = context?.cancelReason?.trim();
6564
6441
  if (status === "cancelled" && cancelReason) {
6565
6442
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 200, children: [
6566
6443
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -6611,7 +6488,6 @@ function useRunActions({
6611
6488
  const eventAnalysis = reactExports.useMemo(() => analyzeEvents(events), [events]);
6612
6489
  const hasPendingSleeps = eventAnalysis.hasPendingSleeps;
6613
6490
  const handleReplay = reactExports.useCallback(async () => {
6614
- var _a2, _b;
6615
6491
  if (rerunning || replayDisabledReason) return null;
6616
6492
  try {
6617
6493
  setRerunning(true);
@@ -6619,8 +6495,8 @@ function useRunActions({
6619
6495
  toast.success("New run started", {
6620
6496
  description: `Run ID: ${newRunId}`
6621
6497
  });
6622
- (_a2 = callbacks == null ? void 0 : callbacks.onSuccess) == null ? void 0 : _a2.call(callbacks);
6623
- (_b = callbacks == null ? void 0 : callbacks.onNavigateToRun) == null ? void 0 : _b.call(callbacks, newRunId);
6498
+ callbacks?.onSuccess?.();
6499
+ callbacks?.onNavigateToRun?.(newRunId);
6624
6500
  return newRunId;
6625
6501
  } catch (err) {
6626
6502
  toast.error("Failed to re-run", {
@@ -6632,7 +6508,6 @@ function useRunActions({
6632
6508
  }
6633
6509
  }, [env, runId, rerunning, replayDisabledReason, callbacks]);
6634
6510
  const handleReenqueue = reactExports.useCallback(async () => {
6635
- var _a2;
6636
6511
  if (reenqueuing) return;
6637
6512
  try {
6638
6513
  setReenqueuing(true);
@@ -6640,7 +6515,7 @@ function useRunActions({
6640
6515
  toast.success("Run re-enqueued", {
6641
6516
  description: "The workflow orchestration layer has been re-enqueued."
6642
6517
  });
6643
- (_a2 = callbacks == null ? void 0 : callbacks.onSuccess) == null ? void 0 : _a2.call(callbacks);
6518
+ callbacks?.onSuccess?.();
6644
6519
  } catch (err) {
6645
6520
  toast.error("Failed to re-enqueue", {
6646
6521
  description: err instanceof Error ? err.message : "Unknown error"
@@ -6650,7 +6525,6 @@ function useRunActions({
6650
6525
  }
6651
6526
  }, [env, runId, reenqueuing, callbacks]);
6652
6527
  const handleWakeUp = reactExports.useCallback(async () => {
6653
- var _a2;
6654
6528
  if (wakingUp) return;
6655
6529
  try {
6656
6530
  setWakingUp(true);
@@ -6664,7 +6538,7 @@ function useRunActions({
6664
6538
  description: "There were no active sleep calls to cancel."
6665
6539
  });
6666
6540
  }
6667
- (_a2 = callbacks == null ? void 0 : callbacks.onSuccess) == null ? void 0 : _a2.call(callbacks);
6541
+ callbacks?.onSuccess?.();
6668
6542
  } catch (err) {
6669
6543
  toast.error("Failed to cancel sleeps", {
6670
6544
  description: err instanceof Error ? err.message : "Unknown error"
@@ -6674,7 +6548,6 @@ function useRunActions({
6674
6548
  }
6675
6549
  }, [env, runId, wakingUp, callbacks]);
6676
6550
  const handleCancel = reactExports.useCallback(async () => {
6677
- var _a2;
6678
6551
  if (cancelling) return;
6679
6552
  const isRunActive = runStatus === "pending" || runStatus === "running";
6680
6553
  if (!isRunActive) {
@@ -6687,7 +6560,7 @@ function useRunActions({
6687
6560
  setCancelling(true);
6688
6561
  await cancelRun(env, runId);
6689
6562
  toast.success("Run cancelled");
6690
- (_a2 = callbacks == null ? void 0 : callbacks.onSuccess) == null ? void 0 : _a2.call(callbacks);
6563
+ callbacks?.onSuccess?.();
6691
6564
  } catch (err) {
6692
6565
  toast.error("Failed to cancel", {
6693
6566
  description: err instanceof Error ? err.message : "Unknown error"
@@ -7823,24 +7696,24 @@ function onRemove(typename) {
7823
7696
  else delete this.__on;
7824
7697
  };
7825
7698
  }
7826
- function onAdd(typename, value, options) {
7699
+ function onAdd(typename, value, options2) {
7827
7700
  return function() {
7828
7701
  var on = this.__on, o, listener = contextListener(value);
7829
7702
  if (on) for (var j = 0, m = on.length; j < m; ++j) {
7830
7703
  if ((o = on[j]).type === typename.type && o.name === typename.name) {
7831
7704
  this.removeEventListener(o.type, o.listener, o.options);
7832
- this.addEventListener(o.type, o.listener = listener, o.options = options);
7705
+ this.addEventListener(o.type, o.listener = listener, o.options = options2);
7833
7706
  o.value = value;
7834
7707
  return;
7835
7708
  }
7836
7709
  }
7837
- this.addEventListener(typename.type, listener, options);
7838
- o = { type: typename.type, name: typename.name, value, listener, options };
7710
+ this.addEventListener(typename.type, listener, options2);
7711
+ o = { type: typename.type, name: typename.name, value, listener, options: options2 };
7839
7712
  if (!on) this.__on = [o];
7840
7713
  else on.push(o);
7841
7714
  };
7842
7715
  }
7843
- function selection_on(typename, value, options) {
7716
+ function selection_on(typename, value, options2) {
7844
7717
  var typenames = parseTypenames(typename + ""), i, n = typenames.length, t;
7845
7718
  if (arguments.length < 2) {
7846
7719
  var on = this.node().__on;
@@ -7854,7 +7727,7 @@ function selection_on(typename, value, options) {
7854
7727
  return;
7855
7728
  }
7856
7729
  on = value ? onAdd : onRemove;
7857
- for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options));
7730
+ for (i = 0; i < n; ++i) this.each(on(typenames[i], value, options2));
7858
7731
  return this;
7859
7732
  }
7860
7733
  function dispatchEvent(node, type, params) {
@@ -10044,12 +9917,12 @@ const getConnectedEdges = (nodes, edges) => {
10044
9917
  });
10045
9918
  return edges.filter((edge) => nodeIds.has(edge.source) || nodeIds.has(edge.target));
10046
9919
  };
10047
- function getFitViewNodes(nodeLookup, options) {
9920
+ function getFitViewNodes(nodeLookup, options2) {
10048
9921
  const fitViewNodes = /* @__PURE__ */ new Map();
10049
- const optionNodeIds = (options == null ? void 0 : options.nodes) ? new Set(options.nodes.map((node) => node.id)) : null;
9922
+ const optionNodeIds = options2?.nodes ? new Set(options2.nodes.map((node) => node.id)) : null;
10050
9923
  nodeLookup.forEach((n) => {
10051
9924
  let isVisible2;
10052
- if (options == null ? void 0 : options.includeHiddenNodes) {
9925
+ if (options2?.includeHiddenNodes) {
10053
9926
  const { width, height } = getNodeDimensions(n);
10054
9927
  isVisible2 = width > 0 && height > 0;
10055
9928
  } else {
@@ -10061,17 +9934,17 @@ function getFitViewNodes(nodeLookup, options) {
10061
9934
  });
10062
9935
  return fitViewNodes;
10063
9936
  }
10064
- async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom }, options) {
9937
+ async function fitViewport({ nodes, width, height, panZoom, minZoom, maxZoom }, options2) {
10065
9938
  if (nodes.size === 0) {
10066
9939
  return true;
10067
9940
  }
10068
- const nodesToFit = getFitViewNodes(nodes, options);
9941
+ const nodesToFit = getFitViewNodes(nodes, options2);
10069
9942
  const bounds = getInternalNodesBounds(nodesToFit);
10070
- const viewport = getViewportForBounds(bounds, width, height, (options == null ? void 0 : options.minZoom) ?? minZoom, (options == null ? void 0 : options.maxZoom) ?? maxZoom, (options == null ? void 0 : options.padding) ?? 0.1);
9943
+ const viewport = getViewportForBounds(bounds, width, height, options2?.minZoom ?? minZoom, options2?.maxZoom ?? maxZoom, options2?.padding ?? 0.1);
10071
9944
  await panZoom.setViewport(viewport, {
10072
- duration: options == null ? void 0 : options.duration,
10073
- ease: options == null ? void 0 : options.ease,
10074
- interpolate: options == null ? void 0 : options.interpolate
9945
+ duration: options2?.duration,
9946
+ ease: options2?.ease,
9947
+ interpolate: options2?.interpolate
10075
9948
  });
10076
9949
  return true;
10077
9950
  }
@@ -10083,7 +9956,7 @@ function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin =
10083
9956
  let extent = node.extent || nodeExtent;
10084
9957
  if (node.extent === "parent" && !node.expandParent) {
10085
9958
  if (!parentNode) {
10086
- onError == null ? void 0 : onError("005", errorMessages["error005"]());
9959
+ onError?.("005", errorMessages["error005"]());
10087
9960
  } else {
10088
9961
  const { width: parentWidth, height: parentHeight } = getNodeDimensions(parentNode);
10089
9962
  if (parentWidth && parentHeight) {
@@ -10101,7 +9974,7 @@ function calculateNodePosition({ nodeId, nextPosition, nodeLookup, nodeOrigin =
10101
9974
  }
10102
9975
  const positionAbsolute = isCoordinateExtent(extent) ? clampPosition(nextPosition, extent, node.measured) : nextPosition;
10103
9976
  if (node.measured.width === void 0 || node.measured.height === void 0) {
10104
- onError == null ? void 0 : onError("015", errorMessages["error015"]());
9977
+ onError?.("015", errorMessages["error015"]());
10105
9978
  }
10106
9979
  return {
10107
9980
  position: {
@@ -10151,8 +10024,8 @@ async function getElementsToRemove({ nodesToRemove = [], edgesToRemove = [], nod
10151
10024
  }
10152
10025
  const clamp = (val, min = 0, max = 1) => Math.min(Math.max(val, min), max);
10153
10026
  const clampPosition = (position = { x: 0, y: 0 }, extent, dimensions) => ({
10154
- x: clamp(position.x, extent[0][0], extent[1][0] - ((dimensions == null ? void 0 : dimensions.width) ?? 0)),
10155
- y: clamp(position.y, extent[0][1], extent[1][1] - ((dimensions == null ? void 0 : dimensions.height) ?? 0))
10027
+ x: clamp(position.x, extent[0][0], extent[1][0] - (dimensions?.width ?? 0)),
10028
+ y: clamp(position.y, extent[0][1], extent[1][1] - (dimensions?.height ?? 0))
10156
10029
  });
10157
10030
  function clampPositionToParent(childPosition, childDimensions, parent) {
10158
10031
  const { width: parentWidth, height: parentHeight } = getNodeDimensions(parent);
@@ -10194,23 +10067,21 @@ const boxToRect = ({ x, y, x2, y2 }) => ({
10194
10067
  height: y2 - y
10195
10068
  });
10196
10069
  const nodeToRect = (node, nodeOrigin = [0, 0]) => {
10197
- var _a2, _b;
10198
10070
  const { x, y } = isInternalNodeBase(node) ? node.internals.positionAbsolute : getNodePositionWithOrigin(node, nodeOrigin);
10199
10071
  return {
10200
10072
  x,
10201
10073
  y,
10202
- width: ((_a2 = node.measured) == null ? void 0 : _a2.width) ?? node.width ?? node.initialWidth ?? 0,
10203
- height: ((_b = node.measured) == null ? void 0 : _b.height) ?? node.height ?? node.initialHeight ?? 0
10074
+ width: node.measured?.width ?? node.width ?? node.initialWidth ?? 0,
10075
+ height: node.measured?.height ?? node.height ?? node.initialHeight ?? 0
10204
10076
  };
10205
10077
  };
10206
10078
  const nodeToBox = (node, nodeOrigin = [0, 0]) => {
10207
- var _a2, _b;
10208
10079
  const { x, y } = isInternalNodeBase(node) ? node.internals.positionAbsolute : getNodePositionWithOrigin(node, nodeOrigin);
10209
10080
  return {
10210
10081
  x,
10211
10082
  y,
10212
- x2: x + (((_a2 = node.measured) == null ? void 0 : _a2.width) ?? node.width ?? node.initialWidth ?? 0),
10213
- y2: y + (((_b = node.measured) == null ? void 0 : _b.height) ?? node.height ?? node.initialHeight ?? 0)
10083
+ x2: x + (node.measured?.width ?? node.width ?? node.initialWidth ?? 0),
10084
+ y2: y + (node.measured?.height ?? node.height ?? node.initialHeight ?? 0)
10214
10085
  };
10215
10086
  };
10216
10087
  const getBoundsOfRects = (rect1, rect2) => boxToRect(getBoundsOfBoxes(rectToBox(rect1), rectToBox(rect2)));
@@ -10319,23 +10190,18 @@ const getViewportForBounds = (bounds, width, height, minZoom, maxZoom, padding)
10319
10190
  zoom: clampedZoom
10320
10191
  };
10321
10192
  };
10322
- const isMacOs = () => {
10323
- var _a2;
10324
- return typeof navigator !== "undefined" && ((_a2 = navigator == null ? void 0 : navigator.userAgent) == null ? void 0 : _a2.indexOf("Mac")) >= 0;
10325
- };
10193
+ const isMacOs = () => typeof navigator !== "undefined" && navigator?.userAgent?.indexOf("Mac") >= 0;
10326
10194
  function isCoordinateExtent(extent) {
10327
10195
  return extent !== void 0 && extent !== null && extent !== "parent";
10328
10196
  }
10329
10197
  function getNodeDimensions(node) {
10330
- var _a2, _b;
10331
10198
  return {
10332
- width: ((_a2 = node.measured) == null ? void 0 : _a2.width) ?? node.width ?? node.initialWidth ?? 0,
10333
- height: ((_b = node.measured) == null ? void 0 : _b.height) ?? node.height ?? node.initialHeight ?? 0
10199
+ width: node.measured?.width ?? node.width ?? node.initialWidth ?? 0,
10200
+ height: node.measured?.height ?? node.height ?? node.initialHeight ?? 0
10334
10201
  };
10335
10202
  }
10336
10203
  function nodeHasDimensions(node) {
10337
- var _a2, _b;
10338
- return (((_a2 = node.measured) == null ? void 0 : _a2.width) ?? node.width ?? node.initialWidth) !== void 0 && (((_b = node.measured) == null ? void 0 : _b.height) ?? node.height ?? node.initialHeight) !== void 0;
10204
+ return (node.measured?.width ?? node.width ?? node.initialWidth) !== void 0 && (node.measured?.height ?? node.height ?? node.initialHeight) !== void 0;
10339
10205
  }
10340
10206
  function evaluateAbsolutePosition(position, dimensions = { width: 0, height: 0 }, parentId, nodeLookup, nodeOrigin) {
10341
10207
  const positionAbsolute = { ...position };
@@ -10375,7 +10241,7 @@ function getConnectionStatus(isValid2) {
10375
10241
  }
10376
10242
  function getPointerPosition(event, { snapGrid = [0, 0], snapToGrid = false, transform: transform2, containerBounds }) {
10377
10243
  const { x, y } = getEventPosition(event);
10378
- const pointerPos = pointToRendererPoint({ x: x - ((containerBounds == null ? void 0 : containerBounds.left) ?? 0), y: y - ((containerBounds == null ? void 0 : containerBounds.top) ?? 0) }, transform2);
10244
+ const pointerPos = pointToRendererPoint({ x: x - (containerBounds?.left ?? 0), y: y - (containerBounds?.top ?? 0) }, transform2);
10379
10245
  const { x: xSnapped, y: ySnapped } = snapToGrid ? snapPosition(pointerPos, snapGrid) : pointerPos;
10380
10246
  return {
10381
10247
  xSnapped,
@@ -10387,28 +10253,23 @@ const getDimensions = (node) => ({
10387
10253
  width: node.offsetWidth,
10388
10254
  height: node.offsetHeight
10389
10255
  });
10390
- const getHostForElement = (element) => {
10391
- var _a2;
10392
- return ((_a2 = element == null ? void 0 : element.getRootNode) == null ? void 0 : _a2.call(element)) || (window == null ? void 0 : window.document);
10393
- };
10256
+ const getHostForElement = (element) => element?.getRootNode?.() || window?.document;
10394
10257
  const inputTags = ["INPUT", "SELECT", "TEXTAREA"];
10395
10258
  function isInputDOMNode(event) {
10396
- var _a2, _b;
10397
- const target = ((_b = (_a2 = event.composedPath) == null ? void 0 : _a2.call(event)) == null ? void 0 : _b[0]) || event.target;
10398
- if ((target == null ? void 0 : target.nodeType) !== 1)
10259
+ const target = event.composedPath?.()?.[0] || event.target;
10260
+ if (target?.nodeType !== 1)
10399
10261
  return false;
10400
10262
  const isInput = inputTags.includes(target.nodeName) || target.hasAttribute("contenteditable");
10401
10263
  return isInput || !!target.closest(".nokey");
10402
10264
  }
10403
10265
  const isMouseEvent = (event) => "clientX" in event;
10404
10266
  const getEventPosition = (event, bounds) => {
10405
- var _a2, _b;
10406
10267
  const isMouse = isMouseEvent(event);
10407
- const evtX = isMouse ? event.clientX : (_a2 = event.touches) == null ? void 0 : _a2[0].clientX;
10408
- const evtY = isMouse ? event.clientY : (_b = event.touches) == null ? void 0 : _b[0].clientY;
10268
+ const evtX = isMouse ? event.clientX : event.touches?.[0].clientX;
10269
+ const evtY = isMouse ? event.clientY : event.touches?.[0].clientY;
10409
10270
  return {
10410
- x: evtX - ((bounds == null ? void 0 : bounds.left) ?? 0),
10411
- y: evtY - ((bounds == null ? void 0 : bounds.top) ?? 0)
10271
+ x: evtX - (bounds?.left ?? 0),
10272
+ y: evtY - (bounds?.top ?? 0)
10412
10273
  };
10413
10274
  };
10414
10275
  const getHandleBounds = (type, nodeElement, nodeBounds, zoom2, nodeId) => {
@@ -10524,13 +10385,12 @@ const getEdgeId = ({ source, sourceHandle, target, targetHandle }) => `xy-edge__
10524
10385
  const connectionExists = (edge, edges) => {
10525
10386
  return edges.some((el) => el.source === edge.source && el.target === edge.target && (el.sourceHandle === edge.sourceHandle || !el.sourceHandle && !edge.sourceHandle) && (el.targetHandle === edge.targetHandle || !el.targetHandle && !edge.targetHandle));
10526
10387
  };
10527
- const addEdge$1 = (edgeParams, edges, options = {}) => {
10528
- var _a2;
10388
+ const addEdge$1 = (edgeParams, edges, options2 = {}) => {
10529
10389
  if (!edgeParams.source || !edgeParams.target) {
10530
- (_a2 = options.onError) == null ? void 0 : _a2.call(options, "006", errorMessages["error006"]());
10390
+ options2.onError?.("006", errorMessages["error006"]());
10531
10391
  return edges;
10532
10392
  }
10533
- const edgeIdGenerator = options.getEdgeId || getEdgeId;
10393
+ const edgeIdGenerator = options2.getEdgeId || getEdgeId;
10534
10394
  let edge;
10535
10395
  if (isEdgeBase(edgeParams)) {
10536
10396
  edge = { ...edgeParams };
@@ -10703,33 +10563,31 @@ function getSmoothStepPath({ sourceX, sourceY, sourcePosition = Position.Bottom,
10703
10563
  return [path, labelX, labelY, offsetX, offsetY];
10704
10564
  }
10705
10565
  function isNodeInitialized(node) {
10706
- var _a2;
10707
- return node && !!(node.internals.handleBounds || ((_a2 = node.handles) == null ? void 0 : _a2.length)) && !!(node.measured.width || node.width || node.initialWidth);
10566
+ return node && !!(node.internals.handleBounds || node.handles?.length) && !!(node.measured.width || node.width || node.initialWidth);
10708
10567
  }
10709
10568
  function getEdgePosition(params) {
10710
- var _a2;
10711
10569
  const { sourceNode, targetNode } = params;
10712
10570
  if (!isNodeInitialized(sourceNode) || !isNodeInitialized(targetNode)) {
10713
10571
  return null;
10714
10572
  }
10715
10573
  const sourceHandleBounds = sourceNode.internals.handleBounds || toHandleBounds(sourceNode.handles);
10716
10574
  const targetHandleBounds = targetNode.internals.handleBounds || toHandleBounds(targetNode.handles);
10717
- const sourceHandle = getHandle$1((sourceHandleBounds == null ? void 0 : sourceHandleBounds.source) ?? [], params.sourceHandle);
10575
+ const sourceHandle = getHandle$1(sourceHandleBounds?.source ?? [], params.sourceHandle);
10718
10576
  const targetHandle = getHandle$1(
10719
10577
  // when connection type is loose we can define all handles as sources and connect source -> source
10720
- params.connectionMode === ConnectionMode.Strict ? (targetHandleBounds == null ? void 0 : targetHandleBounds.target) ?? [] : ((targetHandleBounds == null ? void 0 : targetHandleBounds.target) ?? []).concat((targetHandleBounds == null ? void 0 : targetHandleBounds.source) ?? []),
10578
+ params.connectionMode === ConnectionMode.Strict ? targetHandleBounds?.target ?? [] : (targetHandleBounds?.target ?? []).concat(targetHandleBounds?.source ?? []),
10721
10579
  params.targetHandle
10722
10580
  );
10723
10581
  if (!sourceHandle || !targetHandle) {
10724
- (_a2 = params.onError) == null ? void 0 : _a2.call(params, "008", errorMessages["error008"](!sourceHandle ? "source" : "target", {
10582
+ params.onError?.("008", errorMessages["error008"](!sourceHandle ? "source" : "target", {
10725
10583
  id: params.id,
10726
10584
  sourceHandle: params.sourceHandle,
10727
10585
  targetHandle: params.targetHandle
10728
10586
  }));
10729
10587
  return null;
10730
10588
  }
10731
- const sourcePosition = (sourceHandle == null ? void 0 : sourceHandle.position) || Position.Bottom;
10732
- const targetPosition = (targetHandle == null ? void 0 : targetHandle.position) || Position.Top;
10589
+ const sourcePosition = sourceHandle?.position || Position.Bottom;
10590
+ const targetPosition = targetHandle?.position || Position.Top;
10733
10591
  const source = getHandlePosition(sourceNode, sourceHandle, sourcePosition);
10734
10592
  const target = getHandlePosition(targetNode, targetHandle, targetPosition);
10735
10593
  return {
@@ -10762,13 +10620,13 @@ function toHandleBounds(handles) {
10762
10620
  };
10763
10621
  }
10764
10622
  function getHandlePosition(node, handle, fallbackPosition = Position.Left, center = false) {
10765
- const x = ((handle == null ? void 0 : handle.x) ?? 0) + node.internals.positionAbsolute.x;
10766
- const y = ((handle == null ? void 0 : handle.y) ?? 0) + node.internals.positionAbsolute.y;
10623
+ const x = (handle?.x ?? 0) + node.internals.positionAbsolute.x;
10624
+ const y = (handle?.y ?? 0) + node.internals.positionAbsolute.y;
10767
10625
  const { width, height } = handle ?? getNodeDimensions(node);
10768
10626
  if (center) {
10769
10627
  return { x: x + width / 2, y: y + height / 2 };
10770
10628
  }
10771
- const position = (handle == null ? void 0 : handle.position) ?? fallbackPosition;
10629
+ const position = handle?.position ?? fallbackPosition;
10772
10630
  switch (position) {
10773
10631
  case Position.Top:
10774
10632
  return { x: x + width / 2, y };
@@ -10833,8 +10691,8 @@ function mergeObjects(base, incoming) {
10833
10691
  }
10834
10692
  return result;
10835
10693
  }
10836
- function updateAbsolutePositions(nodeLookup, parentLookup, options) {
10837
- const _options = mergeObjects(defaultOptions, options);
10694
+ function updateAbsolutePositions(nodeLookup, parentLookup, options2) {
10695
+ const _options = mergeObjects(defaultOptions, options2);
10838
10696
  for (const node of nodeLookup.values()) {
10839
10697
  if (node.parentId) {
10840
10698
  updateChildNode(node, nodeLookup, parentLookup, _options);
@@ -10848,7 +10706,7 @@ function updateAbsolutePositions(nodeLookup, parentLookup, options) {
10848
10706
  }
10849
10707
  function parseHandles(userNode, internalNode) {
10850
10708
  if (!userNode.handles) {
10851
- return !userNode.measured ? void 0 : internalNode == null ? void 0 : internalNode.internals.handleBounds;
10709
+ return !userNode.measured ? void 0 : internalNode?.internals.handleBounds;
10852
10710
  }
10853
10711
  const source = [];
10854
10712
  const target = [];
@@ -10877,19 +10735,18 @@ function parseHandles(userNode, internalNode) {
10877
10735
  function isManualZIndexMode(zIndexMode) {
10878
10736
  return zIndexMode === "manual";
10879
10737
  }
10880
- function adoptUserNodes(nodes, nodeLookup, parentLookup, options = {}) {
10881
- var _a2, _b;
10882
- const _options = mergeObjects(adoptUserNodesDefaultOptions, options);
10738
+ function adoptUserNodes(nodes, nodeLookup, parentLookup, options2 = {}) {
10739
+ const _options = mergeObjects(adoptUserNodesDefaultOptions, options2);
10883
10740
  const rootParentIndex = { i: 0 };
10884
10741
  const tmpLookup = new Map(nodeLookup);
10885
- const selectedNodeZ = (_options == null ? void 0 : _options.elevateNodesOnSelect) && !isManualZIndexMode(_options.zIndexMode) ? SELECTED_NODE_Z : 0;
10742
+ const selectedNodeZ = _options?.elevateNodesOnSelect && !isManualZIndexMode(_options.zIndexMode) ? SELECTED_NODE_Z : 0;
10886
10743
  let nodesInitialized = nodes.length > 0;
10887
10744
  let hasSelectedNodes = false;
10888
10745
  nodeLookup.clear();
10889
10746
  parentLookup.clear();
10890
10747
  for (const userNode of nodes) {
10891
10748
  let internalNode = tmpLookup.get(userNode.id);
10892
- if (_options.checkEquality && userNode === (internalNode == null ? void 0 : internalNode.internals.userNode)) {
10749
+ if (_options.checkEquality && userNode === internalNode?.internals.userNode) {
10893
10750
  nodeLookup.set(userNode.id, internalNode);
10894
10751
  } else {
10895
10752
  const positionWithOrigin = getNodePositionWithOrigin(userNode, _options.nodeOrigin);
@@ -10899,8 +10756,8 @@ function adoptUserNodes(nodes, nodeLookup, parentLookup, options = {}) {
10899
10756
  ..._options.defaults,
10900
10757
  ...userNode,
10901
10758
  measured: {
10902
- width: (_a2 = userNode.measured) == null ? void 0 : _a2.width,
10903
- height: (_b = userNode.measured) == null ? void 0 : _b.height
10759
+ width: userNode.measured?.width,
10760
+ height: userNode.measured?.height
10904
10761
  },
10905
10762
  internals: {
10906
10763
  positionAbsolute: clampedPosition,
@@ -10916,9 +10773,9 @@ function adoptUserNodes(nodes, nodeLookup, parentLookup, options = {}) {
10916
10773
  nodesInitialized = false;
10917
10774
  }
10918
10775
  if (userNode.parentId) {
10919
- updateChildNode(internalNode, nodeLookup, parentLookup, options, rootParentIndex);
10776
+ updateChildNode(internalNode, nodeLookup, parentLookup, options2, rootParentIndex);
10920
10777
  }
10921
- hasSelectedNodes || (hasSelectedNodes = userNode.selected ?? false);
10778
+ hasSelectedNodes ||= userNode.selected ?? false;
10922
10779
  }
10923
10780
  return { nodesInitialized, hasSelectedNodes };
10924
10781
  }
@@ -10933,8 +10790,8 @@ function updateParentLookup(node, parentLookup) {
10933
10790
  parentLookup.set(node.parentId, /* @__PURE__ */ new Map([[node.id, node]]));
10934
10791
  }
10935
10792
  }
10936
- function updateChildNode(node, nodeLookup, parentLookup, options, rootParentIndex) {
10937
- const { elevateNodesOnSelect, nodeOrigin, nodeExtent, zIndexMode } = mergeObjects(defaultOptions, options);
10793
+ function updateChildNode(node, nodeLookup, parentLookup, options2, rootParentIndex) {
10794
+ const { elevateNodesOnSelect, nodeOrigin, nodeExtent, zIndexMode } = mergeObjects(defaultOptions, options2);
10938
10795
  const parentId = node.parentId;
10939
10796
  const parentNode = nodeLookup.get(parentId);
10940
10797
  if (!parentNode) {
@@ -10989,7 +10846,6 @@ function calculateChildXYZ(childNode, parentNode, nodeOrigin, nodeExtent, select
10989
10846
  };
10990
10847
  }
10991
10848
  function handleExpandParent(children2, nodeLookup, parentLookup, nodeOrigin = [0, 0]) {
10992
- var _a2;
10993
10849
  const changes = [];
10994
10850
  const parentExpansions = /* @__PURE__ */ new Map();
10995
10851
  for (const child of children2) {
@@ -10997,13 +10853,12 @@ function handleExpandParent(children2, nodeLookup, parentLookup, nodeOrigin = [0
10997
10853
  if (!parent) {
10998
10854
  continue;
10999
10855
  }
11000
- const parentRect = ((_a2 = parentExpansions.get(child.parentId)) == null ? void 0 : _a2.expandedRect) ?? nodeToRect(parent);
10856
+ const parentRect = parentExpansions.get(child.parentId)?.expandedRect ?? nodeToRect(parent);
11001
10857
  const expandedRect = getBoundsOfRects(parentRect, child.rect);
11002
10858
  parentExpansions.set(child.parentId, { expandedRect, parent });
11003
10859
  }
11004
10860
  if (parentExpansions.size > 0) {
11005
10861
  parentExpansions.forEach(({ expandedRect, parent }, parentId) => {
11006
- var _a3;
11007
10862
  const positionAbsolute = parent.internals.positionAbsolute;
11008
10863
  const dimensions = getNodeDimensions(parent);
11009
10864
  const origin = parent.origin ?? nodeOrigin;
@@ -11022,7 +10877,7 @@ function handleExpandParent(children2, nodeLookup, parentLookup, nodeOrigin = [0
11022
10877
  y: parent.position.y - yChange + heightChange
11023
10878
  }
11024
10879
  });
11025
- (_a3 = parentLookup.get(parentId)) == null ? void 0 : _a3.forEach((childNode) => {
10880
+ parentLookup.get(parentId)?.forEach((childNode) => {
11026
10881
  if (!children2.some((child) => child.id === childNode.id)) {
11027
10882
  changes.push({
11028
10883
  id: childNode.id,
@@ -11051,7 +10906,7 @@ function handleExpandParent(children2, nodeLookup, parentLookup, nodeOrigin = [0
11051
10906
  return changes;
11052
10907
  }
11053
10908
  function updateNodeInternals(updates, nodeLookup, parentLookup, domNode, nodeOrigin, nodeExtent, zIndexMode) {
11054
- const viewportNode = domNode == null ? void 0 : domNode.querySelector(".xyflow__viewport");
10909
+ const viewportNode = domNode?.querySelector(".xyflow__viewport");
11055
10910
  let updatedInternals = false;
11056
10911
  if (!viewportNode) {
11057
10912
  return { changes: [], updatedInternals };
@@ -11185,14 +11040,13 @@ function isParentSelected(node, nodeLookup) {
11185
11040
  return isParentSelected(parentNode, nodeLookup);
11186
11041
  }
11187
11042
  function hasSelector(target, selector2, domNode) {
11188
- var _a2;
11189
11043
  let current = target;
11190
11044
  do {
11191
- if ((_a2 = current == null ? void 0 : current.matches) == null ? void 0 : _a2.call(current, selector2))
11045
+ if (current?.matches?.(selector2))
11192
11046
  return true;
11193
11047
  if (current === domNode)
11194
11048
  return false;
11195
- current = current == null ? void 0 : current.parentElement;
11049
+ current = current?.parentElement;
11196
11050
  } while (current);
11197
11051
  return false;
11198
11052
  }
@@ -11228,10 +11082,9 @@ function getDragItems(nodeLookup, nodesDraggable, mousePos, nodeId, onlyDragNode
11228
11082
  return dragItems;
11229
11083
  }
11230
11084
  function getEventHandlerParams({ nodeId, dragItems, nodeLookup, dragging = true }) {
11231
- var _a2, _b, _c;
11232
11085
  const nodesFromDragItems = [];
11233
11086
  for (const [id2, dragItem] of dragItems) {
11234
- const node2 = (_a2 = nodeLookup.get(id2)) == null ? void 0 : _a2.internals.userNode;
11087
+ const node2 = nodeLookup.get(id2)?.internals.userNode;
11235
11088
  if (node2) {
11236
11089
  nodesFromDragItems.push({
11237
11090
  ...node2,
@@ -11243,11 +11096,11 @@ function getEventHandlerParams({ nodeId, dragItems, nodeLookup, dragging = true
11243
11096
  if (!nodeId) {
11244
11097
  return [nodesFromDragItems[0], nodesFromDragItems];
11245
11098
  }
11246
- const node = (_b = nodeLookup.get(nodeId)) == null ? void 0 : _b.internals.userNode;
11099
+ const node = nodeLookup.get(nodeId)?.internals.userNode;
11247
11100
  return [
11248
11101
  !node ? nodesFromDragItems[0] : {
11249
11102
  ...node,
11250
- position: ((_c = dragItems.get(nodeId)) == null ? void 0 : _c.position) || node.position,
11103
+ position: dragItems.get(nodeId)?.position || node.position,
11251
11104
  dragging
11252
11105
  },
11253
11106
  nodesFromDragItems
@@ -11340,10 +11193,10 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
11340
11193
  dragItems,
11341
11194
  nodeLookup
11342
11195
  });
11343
- onDrag == null ? void 0 : onDrag(dragEvent, dragItems, currentNode, currentNodes);
11344
- onNodeDrag == null ? void 0 : onNodeDrag(dragEvent, currentNode, currentNodes);
11196
+ onDrag?.(dragEvent, dragItems, currentNode, currentNodes);
11197
+ onNodeDrag?.(dragEvent, currentNode, currentNodes);
11345
11198
  if (!nodeId) {
11346
- onSelectionDrag == null ? void 0 : onSelectionDrag(dragEvent, currentNodes);
11199
+ onSelectionDrag?.(dragEvent, currentNodes);
11347
11200
  }
11348
11201
  }
11349
11202
  }
@@ -11368,17 +11221,16 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
11368
11221
  autoPanId = requestAnimationFrame(autoPan);
11369
11222
  }
11370
11223
  function startDrag(event) {
11371
- var _a2, _b;
11372
11224
  const { nodeLookup, multiSelectionActive, nodesDraggable, transform: transform2, snapGrid, snapToGrid, selectNodesOnDrag, onNodeDragStart, onSelectionDragStart, unselectNodesAndEdges } = getStoreItems();
11373
11225
  dragStarted = true;
11374
- const isUnselectedNodeDrag = !!nodeId && !multiSelectionActive && !((_a2 = nodeLookup.get(nodeId)) == null ? void 0 : _a2.selected);
11226
+ const isUnselectedNodeDrag = !!nodeId && !multiSelectionActive && !nodeLookup.get(nodeId)?.selected;
11375
11227
  if ((!selectNodesOnDrag || !isSelectable) && !multiSelectionActive && nodeId) {
11376
- if (!((_b = nodeLookup.get(nodeId)) == null ? void 0 : _b.selected)) {
11228
+ if (!nodeLookup.get(nodeId)?.selected) {
11377
11229
  unselectNodesAndEdges();
11378
11230
  }
11379
11231
  }
11380
11232
  if (isSelectable && selectNodesOnDrag && nodeId) {
11381
- onNodeMouseDown == null ? void 0 : onNodeMouseDown(nodeId);
11233
+ onNodeMouseDown?.(nodeId);
11382
11234
  }
11383
11235
  const pointerPos = getPointerPosition(event.sourceEvent, { transform: transform2, snapGrid, snapToGrid, containerBounds });
11384
11236
  lastPos = pointerPos;
@@ -11389,16 +11241,16 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
11389
11241
  dragItems,
11390
11242
  nodeLookup
11391
11243
  });
11392
- onDragStart == null ? void 0 : onDragStart(event.sourceEvent, dragItems, currentNode, currentNodes);
11393
- onNodeDragStart == null ? void 0 : onNodeDragStart(event.sourceEvent, currentNode, currentNodes);
11244
+ onDragStart?.(event.sourceEvent, dragItems, currentNode, currentNodes);
11245
+ onNodeDragStart?.(event.sourceEvent, currentNode, currentNodes);
11394
11246
  if (!nodeId) {
11395
- onSelectionDragStart == null ? void 0 : onSelectionDragStart(event.sourceEvent, currentNodes);
11247
+ onSelectionDragStart?.(event.sourceEvent, currentNodes);
11396
11248
  }
11397
11249
  }
11398
11250
  }
11399
11251
  const d3DragInstance = drag().clickDistance(nodeClickDistance).on("start", (event) => {
11400
11252
  const { domNode: domNode2, nodeDragThreshold, transform: transform2, snapGrid, snapToGrid } = getStoreItems();
11401
- containerBounds = (domNode2 == null ? void 0 : domNode2.getBoundingClientRect()) || null;
11253
+ containerBounds = domNode2?.getBoundingClientRect() || null;
11402
11254
  abortDrag = false;
11403
11255
  nodePositionsChanged = false;
11404
11256
  dragEvent = event.sourceEvent;
@@ -11459,10 +11311,10 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
11459
11311
  nodeLookup,
11460
11312
  dragging: false
11461
11313
  });
11462
- onDragStop == null ? void 0 : onDragStop(event.sourceEvent, dragItems, currentNode, currentNodes);
11463
- onNodeDragStop == null ? void 0 : onNodeDragStop(event.sourceEvent, currentNode, currentNodes);
11314
+ onDragStop?.(event.sourceEvent, dragItems, currentNode, currentNodes);
11315
+ onNodeDragStop?.(event.sourceEvent, currentNode, currentNodes);
11464
11316
  if (!nodeId) {
11465
- onSelectionDragStop == null ? void 0 : onSelectionDragStop(event.sourceEvent, currentNodes);
11317
+ onSelectionDragStop?.(event.sourceEvent, currentNodes);
11466
11318
  }
11467
11319
  }
11468
11320
  }
@@ -11474,7 +11326,7 @@ function XYDrag({ onNodeMouseDown, getStoreItems, onDragStart, onDrag, onDragSto
11474
11326
  d3Selection.call(d3DragInstance);
11475
11327
  }
11476
11328
  function destroy() {
11477
- d3Selection == null ? void 0 : d3Selection.on(".drag", null);
11329
+ d3Selection?.on(".drag", null);
11478
11330
  }
11479
11331
  return {
11480
11332
  update,
@@ -11498,12 +11350,11 @@ function getNodesWithinDistance(position, nodeLookup, distance2) {
11498
11350
  }
11499
11351
  const ADDITIONAL_DISTANCE = 250;
11500
11352
  function getClosestHandle(position, connectionRadius, nodeLookup, fromHandle) {
11501
- var _a2, _b;
11502
11353
  let closestHandles = [];
11503
11354
  let minDistance = Infinity;
11504
11355
  const closeNodes = getNodesWithinDistance(position, nodeLookup, connectionRadius + ADDITIONAL_DISTANCE);
11505
11356
  for (const node of closeNodes) {
11506
- const allHandles = [...((_a2 = node.internals.handleBounds) == null ? void 0 : _a2.source) ?? [], ...((_b = node.internals.handleBounds) == null ? void 0 : _b.target) ?? []];
11357
+ const allHandles = [...node.internals.handleBounds?.source ?? [], ...node.internals.handleBounds?.target ?? []];
11507
11358
  for (const handle of allHandles) {
11508
11359
  if (fromHandle.nodeId === handle.nodeId && fromHandle.type === handle.type && fromHandle.id === handle.id) {
11509
11360
  continue;
@@ -11531,21 +11382,20 @@ function getClosestHandle(position, connectionRadius, nodeLookup, fromHandle) {
11531
11382
  return closestHandles[0];
11532
11383
  }
11533
11384
  function getHandle(nodeId, handleType, handleId, nodeLookup, connectionMode, withAbsolutePosition = false) {
11534
- var _a2, _b, _c;
11535
11385
  const node = nodeLookup.get(nodeId);
11536
11386
  if (!node) {
11537
11387
  return null;
11538
11388
  }
11539
- const handles = connectionMode === "strict" ? (_a2 = node.internals.handleBounds) == null ? void 0 : _a2[handleType] : [...((_b = node.internals.handleBounds) == null ? void 0 : _b.source) ?? [], ...((_c = node.internals.handleBounds) == null ? void 0 : _c.target) ?? []];
11540
- const handle = (handleId ? handles == null ? void 0 : handles.find((h) => h.id === handleId) : handles == null ? void 0 : handles[0]) ?? null;
11389
+ const handles = connectionMode === "strict" ? node.internals.handleBounds?.[handleType] : [...node.internals.handleBounds?.source ?? [], ...node.internals.handleBounds?.target ?? []];
11390
+ const handle = (handleId ? handles?.find((h) => h.id === handleId) : handles?.[0]) ?? null;
11541
11391
  return handle && withAbsolutePosition ? { ...handle, ...getHandlePosition(node, handle, handle.position, true) } : handle;
11542
11392
  }
11543
11393
  function getHandleType(edgeUpdaterType, handleDomNode) {
11544
11394
  if (edgeUpdaterType) {
11545
11395
  return edgeUpdaterType;
11546
- } else if (handleDomNode == null ? void 0 : handleDomNode.classList.contains("target")) {
11396
+ } else if (handleDomNode?.classList.contains("target")) {
11547
11397
  return "target";
11548
- } else if (handleDomNode == null ? void 0 : handleDomNode.classList.contains("source")) {
11398
+ } else if (handleDomNode?.classList.contains("source")) {
11549
11399
  return "source";
11550
11400
  }
11551
11401
  return null;
@@ -11566,7 +11416,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
11566
11416
  let closestHandle;
11567
11417
  const { x, y } = getEventPosition(event);
11568
11418
  const handleType = getHandleType(edgeUpdaterType, handleDomNode);
11569
- const containerBounds = domNode == null ? void 0 : domNode.getBoundingClientRect();
11419
+ const containerBounds = domNode?.getBoundingClientRect();
11570
11420
  let connectionStarted = false;
11571
11421
  if (!containerBounds || !handleType) {
11572
11422
  return;
@@ -11612,7 +11462,7 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
11612
11462
  function startConnection() {
11613
11463
  connectionStarted = true;
11614
11464
  updateConnection(previousConnection);
11615
- onConnectStart == null ? void 0 : onConnectStart(event, { nodeId, handleId, handleType });
11465
+ onConnectStart?.(event, { nodeId, handleId, handleType });
11616
11466
  }
11617
11467
  if (dragThreshold === 0) {
11618
11468
  startConnection();
@@ -11675,16 +11525,16 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
11675
11525
  }
11676
11526
  if (connectionStarted) {
11677
11527
  if ((closestHandle || resultHandleDomNode) && connection && isValid2) {
11678
- onConnect == null ? void 0 : onConnect(connection);
11528
+ onConnect?.(connection);
11679
11529
  }
11680
11530
  const { inProgress, ...connectionState } = previousConnection;
11681
11531
  const finalConnectionState = {
11682
11532
  ...connectionState,
11683
11533
  toPosition: previousConnection.toHandle ? previousConnection.toPosition : null
11684
11534
  };
11685
- onConnectEnd == null ? void 0 : onConnectEnd(event2, finalConnectionState);
11535
+ onConnectEnd?.(event2, finalConnectionState);
11686
11536
  if (edgeUpdaterType) {
11687
- onReconnectEnd == null ? void 0 : onReconnectEnd(event2, finalConnectionState);
11537
+ onReconnectEnd?.(event2, finalConnectionState);
11688
11538
  }
11689
11539
  }
11690
11540
  cancelConnection();
@@ -11705,10 +11555,10 @@ function onPointerDown(event, { connectionMode, connectionRadius, handleId, node
11705
11555
  }
11706
11556
  function isValidHandle(event, { handle, connectionMode, fromNodeId, fromHandleId, fromType, doc, lib, flowId, isValidConnection = alwaysValid, nodeLookup }) {
11707
11557
  const isTarget = fromType === "target";
11708
- const handleDomNode = handle ? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle == null ? void 0 : handle.nodeId}-${handle == null ? void 0 : handle.id}-${handle == null ? void 0 : handle.type}"]`) : null;
11558
+ const handleDomNode = handle ? doc.querySelector(`.${lib}-flow__handle[data-id="${flowId}-${handle?.nodeId}-${handle?.id}-${handle?.type}"]`) : null;
11709
11559
  const { x, y } = getEventPosition(event);
11710
11560
  const handleBelow = doc.elementFromPoint(x, y);
11711
- const handleToCheck = (handleBelow == null ? void 0 : handleBelow.classList.contains(`${lib}-flow__handle`)) ? handleBelow : handleDomNode;
11561
+ const handleToCheck = handleBelow?.classList.contains(`${lib}-flow__handle`) ? handleBelow : handleDomNode;
11712
11562
  const result = {
11713
11563
  handleDomNode: handleToCheck,
11714
11564
  isValid: false,
@@ -11859,12 +11709,12 @@ function createPanOnScrollHandler({ zoomPanValues, noWheelClassName, d3Selection
11859
11709
  clearTimeout(zoomPanValues.panScrollTimeout);
11860
11710
  if (!zoomPanValues.isPanScrolling) {
11861
11711
  zoomPanValues.isPanScrolling = true;
11862
- onPanZoomStart == null ? void 0 : onPanZoomStart(event, nextViewport);
11712
+ onPanZoomStart?.(event, nextViewport);
11863
11713
  } else {
11864
- onPanZoom == null ? void 0 : onPanZoom(event, nextViewport);
11714
+ onPanZoom?.(event, nextViewport);
11865
11715
  }
11866
11716
  zoomPanValues.panScrollTimeout = setTimeout(() => {
11867
- onPanZoomEnd == null ? void 0 : onPanZoomEnd(event, nextViewport);
11717
+ onPanZoomEnd?.(event, nextViewport);
11868
11718
  zoomPanValues.isPanScrolling = false;
11869
11719
  }, 150);
11870
11720
  };
@@ -11886,38 +11736,35 @@ function createZoomOnScrollHandler({ noWheelClassName, preventScrolling, d3ZoomH
11886
11736
  }
11887
11737
  function createPanZoomStartHandler({ zoomPanValues, onDraggingChange, onPanZoomStart }) {
11888
11738
  return (event) => {
11889
- var _a2, _b, _c;
11890
- if ((_a2 = event.sourceEvent) == null ? void 0 : _a2.internal) {
11739
+ if (event.sourceEvent?.internal) {
11891
11740
  return;
11892
11741
  }
11893
11742
  const viewport = transformToViewport(event.transform);
11894
- zoomPanValues.mouseButton = ((_b = event.sourceEvent) == null ? void 0 : _b.button) || 0;
11743
+ zoomPanValues.mouseButton = event.sourceEvent?.button || 0;
11895
11744
  zoomPanValues.isZoomingOrPanning = true;
11896
11745
  zoomPanValues.prevViewport = viewport;
11897
- if (((_c = event.sourceEvent) == null ? void 0 : _c.type) === "mousedown") {
11746
+ if (event.sourceEvent?.type === "mousedown") {
11898
11747
  onDraggingChange(true);
11899
11748
  }
11900
11749
  if (onPanZoomStart) {
11901
- onPanZoomStart == null ? void 0 : onPanZoomStart(event.sourceEvent, viewport);
11750
+ onPanZoomStart?.(event.sourceEvent, viewport);
11902
11751
  }
11903
11752
  };
11904
11753
  }
11905
11754
  function createPanZoomHandler({ zoomPanValues, panOnDrag, onPaneContextMenu, onTransformChange, onPanZoom }) {
11906
11755
  return (event) => {
11907
- var _a2, _b;
11908
11756
  zoomPanValues.usedRightMouseButton = !!(onPaneContextMenu && isRightClickPan(panOnDrag, zoomPanValues.mouseButton ?? 0));
11909
- if (!((_a2 = event.sourceEvent) == null ? void 0 : _a2.sync)) {
11757
+ if (!event.sourceEvent?.sync) {
11910
11758
  onTransformChange([event.transform.x, event.transform.y, event.transform.k]);
11911
11759
  }
11912
- if (onPanZoom && !((_b = event.sourceEvent) == null ? void 0 : _b.internal)) {
11913
- onPanZoom == null ? void 0 : onPanZoom(event.sourceEvent, transformToViewport(event.transform));
11760
+ if (onPanZoom && !event.sourceEvent?.internal) {
11761
+ onPanZoom?.(event.sourceEvent, transformToViewport(event.transform));
11914
11762
  }
11915
11763
  };
11916
11764
  }
11917
11765
  function createPanZoomEndHandler({ zoomPanValues, panOnDrag, panOnScroll, onDraggingChange, onPanZoomEnd, onPaneContextMenu }) {
11918
11766
  return (event) => {
11919
- var _a2;
11920
- if ((_a2 = event.sourceEvent) == null ? void 0 : _a2.internal) {
11767
+ if (event.sourceEvent?.internal) {
11921
11768
  return;
11922
11769
  }
11923
11770
  zoomPanValues.isZoomingOrPanning = false;
@@ -11932,7 +11779,7 @@ function createPanZoomEndHandler({ zoomPanValues, panOnDrag, panOnScroll, onDrag
11932
11779
  clearTimeout(zoomPanValues.timerId);
11933
11780
  zoomPanValues.timerId = setTimeout(
11934
11781
  () => {
11935
- onPanZoomEnd == null ? void 0 : onPanZoomEnd(event.sourceEvent, viewport);
11782
+ onPanZoomEnd?.(event.sourceEvent, viewport);
11936
11783
  },
11937
11784
  // we need a setTimeout for panOnScroll to suppress multiple end events fired during scroll
11938
11785
  panOnScroll ? 150 : 0
@@ -11942,7 +11789,6 @@ function createPanZoomEndHandler({ zoomPanValues, panOnDrag, panOnScroll, onDrag
11942
11789
  }
11943
11790
  function createFilter({ panActivationKeyPressed, zoomActivationKeyPressed, zoomOnScroll, zoomOnPinch, panOnDrag, panOnScroll, zoomOnDoubleClick, userSelectionActive, noWheelClassName, noPanClassName, lib, connectionInProgress }) {
11944
11791
  return (event) => {
11945
- var _a2;
11946
11792
  const zoomScroll = zoomActivationKeyPressed || zoomOnScroll;
11947
11793
  const pinchZoom = zoomOnPinch && event.ctrlKey;
11948
11794
  const isWheelEvent = event.type === "wheel";
@@ -11967,7 +11813,7 @@ function createFilter({ panActivationKeyPressed, zoomActivationKeyPressed, zoomO
11967
11813
  if (!zoomOnPinch && event.ctrlKey && isWheelEvent) {
11968
11814
  return false;
11969
11815
  }
11970
- if (!zoomOnPinch && event.type === "touchstart" && ((_a2 = event.touches) == null ? void 0 : _a2.length) > 1) {
11816
+ if (!zoomOnPinch && event.type === "touchstart" && event.touches?.length > 1) {
11971
11817
  event.preventDefault();
11972
11818
  return false;
11973
11819
  }
@@ -12001,14 +11847,14 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
12001
11847
  ];
12002
11848
  const extentResizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver((entries) => {
12003
11849
  const entry = entries[0];
12004
- if (entry == null ? void 0 : entry.contentRect) {
11850
+ if (entry?.contentRect) {
12005
11851
  cachedExtent = [
12006
11852
  [0, 0],
12007
11853
  [entry.contentRect.width, entry.contentRect.height]
12008
11854
  ];
12009
11855
  }
12010
11856
  }) : null;
12011
- extentResizeObserver == null ? void 0 : extentResizeObserver.observe(domNode);
11857
+ extentResizeObserver?.observe(domNode);
12012
11858
  const d3ZoomInstance = zoom().extent(() => cachedExtent).scaleExtent([minZoom, maxZoom]).translateExtent(translateExtent);
12013
11859
  const d3Selection = select(domNode).call(d3ZoomInstance);
12014
11860
  setViewportConstrained({
@@ -12022,10 +11868,10 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
12022
11868
  const d3ZoomHandler = d3Selection.on("wheel.zoom");
12023
11869
  const d3DblClickZoomHandler = d3Selection.on("dblclick.zoom");
12024
11870
  d3ZoomInstance.wheelDelta(wheelDelta);
12025
- async function setTransform(transform2, options) {
11871
+ async function setTransform(transform2, options2) {
12026
11872
  if (d3Selection) {
12027
11873
  return new Promise((resolve) => {
12028
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.interpolate((options == null ? void 0 : options.interpolate) === "linear" ? interpolate$1 : interpolateZoom).transform(getD3Transition(d3Selection, options == null ? void 0 : options.duration, options == null ? void 0 : options.ease, () => resolve(true)), transform2);
11874
+ d3ZoomInstance?.interpolate(options2?.interpolate === "linear" ? interpolate$1 : interpolateZoom).transform(getD3Transition(d3Selection, options2?.duration, options2?.ease, () => resolve(true)), transform2);
12029
11875
  });
12030
11876
  }
12031
11877
  return false;
@@ -12099,19 +11945,19 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
12099
11945
  }
12100
11946
  function destroy() {
12101
11947
  d3ZoomInstance.on("zoom", null);
12102
- extentResizeObserver == null ? void 0 : extentResizeObserver.disconnect();
11948
+ extentResizeObserver?.disconnect();
12103
11949
  }
12104
11950
  async function setViewportConstrained(viewport2, extent, translateExtent2) {
12105
11951
  const nextTransform = viewportToTransform(viewport2);
12106
- const contrainedTransform = d3ZoomInstance == null ? void 0 : d3ZoomInstance.constrain()(nextTransform, extent, translateExtent2);
11952
+ const contrainedTransform = d3ZoomInstance?.constrain()(nextTransform, extent, translateExtent2);
12107
11953
  if (contrainedTransform) {
12108
11954
  await setTransform(contrainedTransform);
12109
11955
  }
12110
11956
  return contrainedTransform;
12111
11957
  }
12112
- async function setViewport(viewport2, options) {
11958
+ async function setViewport(viewport2, options2) {
12113
11959
  const nextTransform = viewportToTransform(viewport2);
12114
- await setTransform(nextTransform, options);
11960
+ await setTransform(nextTransform, options2);
12115
11961
  return nextTransform;
12116
11962
  }
12117
11963
  function syncViewport(viewport2) {
@@ -12119,7 +11965,7 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
12119
11965
  const nextTransform = viewportToTransform(viewport2);
12120
11966
  const currentTransform = d3Selection.property("__zoom");
12121
11967
  if (currentTransform.k !== viewport2.zoom || currentTransform.x !== viewport2.x || currentTransform.y !== viewport2.y) {
12122
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.transform(d3Selection, nextTransform, null, { sync: true });
11968
+ d3ZoomInstance?.transform(d3Selection, nextTransform, null, { sync: true });
12123
11969
  }
12124
11970
  }
12125
11971
  }
@@ -12127,31 +11973,31 @@ function XYPanZoom({ domNode, minZoom, maxZoom, translateExtent, viewport, onPan
12127
11973
  const transform$1 = d3Selection ? transform(d3Selection.node()) : { x: 0, y: 0, k: 1 };
12128
11974
  return { x: transform$1.x, y: transform$1.y, zoom: transform$1.k };
12129
11975
  }
12130
- async function scaleTo(zoom2, options) {
11976
+ async function scaleTo(zoom2, options2) {
12131
11977
  if (d3Selection) {
12132
11978
  return new Promise((resolve) => {
12133
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.interpolate((options == null ? void 0 : options.interpolate) === "linear" ? interpolate$1 : interpolateZoom).scaleTo(getD3Transition(d3Selection, options == null ? void 0 : options.duration, options == null ? void 0 : options.ease, () => resolve(true)), zoom2);
11979
+ d3ZoomInstance?.interpolate(options2?.interpolate === "linear" ? interpolate$1 : interpolateZoom).scaleTo(getD3Transition(d3Selection, options2?.duration, options2?.ease, () => resolve(true)), zoom2);
12134
11980
  });
12135
11981
  }
12136
11982
  return false;
12137
11983
  }
12138
- async function scaleBy(factor, options) {
11984
+ async function scaleBy(factor, options2) {
12139
11985
  if (d3Selection) {
12140
11986
  return new Promise((resolve) => {
12141
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.interpolate((options == null ? void 0 : options.interpolate) === "linear" ? interpolate$1 : interpolateZoom).scaleBy(getD3Transition(d3Selection, options == null ? void 0 : options.duration, options == null ? void 0 : options.ease, () => resolve(true)), factor);
11987
+ d3ZoomInstance?.interpolate(options2?.interpolate === "linear" ? interpolate$1 : interpolateZoom).scaleBy(getD3Transition(d3Selection, options2?.duration, options2?.ease, () => resolve(true)), factor);
12142
11988
  });
12143
11989
  }
12144
11990
  return false;
12145
11991
  }
12146
11992
  function setScaleExtent(scaleExtent) {
12147
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.scaleExtent(scaleExtent);
11993
+ d3ZoomInstance?.scaleExtent(scaleExtent);
12148
11994
  }
12149
11995
  function setTranslateExtent(translateExtent2) {
12150
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.translateExtent(translateExtent2);
11996
+ d3ZoomInstance?.translateExtent(translateExtent2);
12151
11997
  }
12152
11998
  function setClickDistance(distance2) {
12153
11999
  const validDistance = !isNumeric(distance2) || distance2 < 0 ? 0 : distance2;
12154
- d3ZoomInstance == null ? void 0 : d3ZoomInstance.clickDistance(validDistance);
12000
+ d3ZoomInstance?.clickDistance(validDistance);
12155
12001
  }
12156
12002
  return {
12157
12003
  update,
@@ -12382,7 +12228,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
12382
12228
  if (!node) {
12383
12229
  return;
12384
12230
  }
12385
- containerBounds = (paneDomNode == null ? void 0 : paneDomNode.getBoundingClientRect()) ?? null;
12231
+ containerBounds = paneDomNode?.getBoundingClientRect() ?? null;
12386
12232
  const { xSnapped, ySnapped } = getPointerPosition(event.sourceEvent, {
12387
12233
  transform: transform2,
12388
12234
  snapGrid,
@@ -12434,7 +12280,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
12434
12280
  }
12435
12281
  }
12436
12282
  }
12437
- onResizeStart == null ? void 0 : onResizeStart(event, { ...prevValues });
12283
+ onResizeStart?.(event, { ...prevValues });
12438
12284
  }).on("drag", (event) => {
12439
12285
  const { transform: transform2, snapGrid, snapToGrid, nodeOrigin: storeNodeOrigin } = getStoreItems();
12440
12286
  const pointerPosition = getPointerPosition(event.sourceEvent, {
@@ -12511,7 +12357,7 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
12511
12357
  affectsY: params.controlDirection.affectsY
12512
12358
  });
12513
12359
  const nextValues = { ...prevValues, direction };
12514
- const callResize = shouldResize == null ? void 0 : shouldResize(event, nextValues);
12360
+ const callResize = shouldResize?.(event, nextValues);
12515
12361
  if (callResize === false) {
12516
12362
  prevValues = lastValid.prevValues;
12517
12363
  startValues.x = lastValid.startX;
@@ -12521,11 +12367,11 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
12521
12367
  });
12522
12368
  return;
12523
12369
  }
12524
- onResize == null ? void 0 : onResize(event, nextValues);
12370
+ onResize?.(event, nextValues);
12525
12371
  onChange(change, childChanges);
12526
12372
  }).on("end", (event) => {
12527
- onResizeEnd == null ? void 0 : onResizeEnd(event, { ...prevValues });
12528
- onEnd == null ? void 0 : onEnd({ ...prevValues });
12373
+ onResizeEnd?.(event, { ...prevValues });
12374
+ onEnd?.({ ...prevValues });
12529
12375
  });
12530
12376
  selection2.call(dragHandler);
12531
12377
  }
@@ -12539,15 +12385,6 @@ function XYResizer({ domNode, nodeId, getStoreItems, onChange, onEnd }) {
12539
12385
  }
12540
12386
  var withSelector = { exports: {} };
12541
12387
  var withSelector_production = {};
12542
- /**
12543
- * @license React
12544
- * use-sync-external-store-shim/with-selector.production.js
12545
- *
12546
- * Copyright (c) Meta Platforms, Inc. and affiliates.
12547
- *
12548
- * This source code is licensed under the MIT license found in the
12549
- * LICENSE file in the root directory of this source tree.
12550
- */
12551
12388
  var hasRequiredWithSelector_production;
12552
12389
  function requireWithSelector_production() {
12553
12390
  if (hasRequiredWithSelector_production) return withSelector_production;
@@ -12767,7 +12604,7 @@ function Attribution({ proOptions, position = "bottom-right" }) {
12767
12604
  return;
12768
12605
  }
12769
12606
  }, []);
12770
- if (proOptions == null ? void 0 : proOptions.hideAttribution) {
12607
+ if (proOptions?.hideAttribution) {
12771
12608
  return null;
12772
12609
  }
12773
12610
  return jsxRuntimeExports.jsx(Panel, { position, className: "react-flow__attribution", "data-message": `Please only hide this attribution when you are subscribed to React Flow Pro: ${link}`, children: jsxRuntimeExports.jsx("a", { href: link, target: "_blank", rel: "noopener noreferrer", "aria-label": "React Flow attribution", children: "React Flow" }) });
@@ -12796,7 +12633,7 @@ function SelectionListenerInner({ onSelectionChange }) {
12796
12633
  const { selectedNodes, selectedEdges } = useStore(selector$l, areEqual$1);
12797
12634
  reactExports.useEffect(() => {
12798
12635
  const params = { nodes: selectedNodes, edges: selectedEdges };
12799
- onSelectionChange == null ? void 0 : onSelectionChange(params);
12636
+ onSelectionChange?.(params);
12800
12637
  store.getState().onSelectionChangeHandlers.forEach((fn) => fn(params));
12801
12638
  }, [selectedNodes, selectedEdges, onSelectionChange]);
12802
12639
  return null;
@@ -12951,7 +12788,6 @@ function getMediaQuery() {
12951
12788
  return window.matchMedia("(prefers-color-scheme: dark)");
12952
12789
  }
12953
12790
  function useColorModeClass(colorMode) {
12954
- var _a2;
12955
12791
  const [colorModeClass, setColorModeClass] = reactExports.useState(colorMode === "system" ? null : colorMode);
12956
12792
  reactExports.useEffect(() => {
12957
12793
  if (colorMode !== "system") {
@@ -12959,17 +12795,17 @@ function useColorModeClass(colorMode) {
12959
12795
  return;
12960
12796
  }
12961
12797
  const mediaQuery = getMediaQuery();
12962
- const updateColorModeClass = () => setColorModeClass((mediaQuery == null ? void 0 : mediaQuery.matches) ? "dark" : "light");
12798
+ const updateColorModeClass = () => setColorModeClass(mediaQuery?.matches ? "dark" : "light");
12963
12799
  updateColorModeClass();
12964
- mediaQuery == null ? void 0 : mediaQuery.addEventListener("change", updateColorModeClass);
12800
+ mediaQuery?.addEventListener("change", updateColorModeClass);
12965
12801
  return () => {
12966
- mediaQuery == null ? void 0 : mediaQuery.removeEventListener("change", updateColorModeClass);
12802
+ mediaQuery?.removeEventListener("change", updateColorModeClass);
12967
12803
  };
12968
12804
  }, [colorMode]);
12969
- return colorModeClass !== null ? colorModeClass : ((_a2 = getMediaQuery()) == null ? void 0 : _a2.matches) ? "dark" : "light";
12805
+ return colorModeClass !== null ? colorModeClass : getMediaQuery()?.matches ? "dark" : "light";
12970
12806
  }
12971
12807
  const defaultDoc = typeof document !== "undefined" ? document : null;
12972
- function useKeyPress(keyCode = null, options = { target: defaultDoc, actInsideInputWithModifier: true }) {
12808
+ function useKeyPress(keyCode = null, options2 = { target: defaultDoc, actInsideInputWithModifier: true }) {
12973
12809
  const [keyPressed, setKeyPressed] = reactExports.useState(false);
12974
12810
  const modifierPressed = reactExports.useRef(false);
12975
12811
  const pressedKeys = reactExports.useRef(/* @__PURE__ */ new Set([]));
@@ -12983,11 +12819,10 @@ function useKeyPress(keyCode = null, options = { target: defaultDoc, actInsideIn
12983
12819
  return [[], []];
12984
12820
  }, [keyCode]);
12985
12821
  reactExports.useEffect(() => {
12986
- const target = (options == null ? void 0 : options.target) ?? defaultDoc;
12987
- const actInsideInputWithModifier = (options == null ? void 0 : options.actInsideInputWithModifier) ?? true;
12822
+ const target = options2?.target ?? defaultDoc;
12823
+ const actInsideInputWithModifier = options2?.actInsideInputWithModifier ?? true;
12988
12824
  if (keyCode !== null) {
12989
12825
  const downHandler = (event) => {
12990
- var _a2, _b;
12991
12826
  modifierPressed.current = event.ctrlKey || event.metaKey || event.shiftKey || event.altKey;
12992
12827
  const preventAction = (!modifierPressed.current || modifierPressed.current && !actInsideInputWithModifier) && isInputDOMNode(event);
12993
12828
  if (preventAction) {
@@ -12996,9 +12831,9 @@ function useKeyPress(keyCode = null, options = { target: defaultDoc, actInsideIn
12996
12831
  const keyOrCode = useKeyOrCode(event.code, keysToWatch);
12997
12832
  pressedKeys.current.add(event[keyOrCode]);
12998
12833
  if (isMatchingKey(keyCodes, pressedKeys.current, false)) {
12999
- const target2 = ((_b = (_a2 = event.composedPath) == null ? void 0 : _a2.call(event)) == null ? void 0 : _b[0]) || event.target;
13000
- const isInteractiveElement = (target2 == null ? void 0 : target2.nodeName) === "BUTTON" || (target2 == null ? void 0 : target2.nodeName) === "A";
13001
- if (options.preventDefault !== false && (modifierPressed.current || !isInteractiveElement)) {
12834
+ const target2 = event.composedPath?.()?.[0] || event.target;
12835
+ const isInteractiveElement = target2?.nodeName === "BUTTON" || target2?.nodeName === "A";
12836
+ if (options2.preventDefault !== false && (modifierPressed.current || !isInteractiveElement)) {
13002
12837
  event.preventDefault();
13003
12838
  }
13004
12839
  setKeyPressed(true);
@@ -13021,13 +12856,13 @@ function useKeyPress(keyCode = null, options = { target: defaultDoc, actInsideIn
13021
12856
  pressedKeys.current.clear();
13022
12857
  setKeyPressed(false);
13023
12858
  };
13024
- target == null ? void 0 : target.addEventListener("keydown", downHandler);
13025
- target == null ? void 0 : target.addEventListener("keyup", upHandler);
12859
+ target?.addEventListener("keydown", downHandler);
12860
+ target?.addEventListener("keyup", upHandler);
13026
12861
  window.addEventListener("blur", resetHandler);
13027
12862
  window.addEventListener("contextmenu", resetHandler);
13028
12863
  return () => {
13029
- target == null ? void 0 : target.removeEventListener("keydown", downHandler);
13030
- target == null ? void 0 : target.removeEventListener("keyup", upHandler);
12864
+ target?.removeEventListener("keydown", downHandler);
12865
+ target?.removeEventListener("keyup", upHandler);
13031
12866
  window.removeEventListener("blur", resetHandler);
13032
12867
  window.removeEventListener("contextmenu", resetHandler);
13033
12868
  };
@@ -13045,20 +12880,20 @@ const useViewportHelper = () => {
13045
12880
  const store = useStoreApi();
13046
12881
  return reactExports.useMemo(() => {
13047
12882
  return {
13048
- zoomIn: async (options) => {
12883
+ zoomIn: async (options2) => {
13049
12884
  const { panZoom } = store.getState();
13050
- return panZoom ? panZoom.scaleBy(1.2, options) : false;
12885
+ return panZoom ? panZoom.scaleBy(1.2, options2) : false;
13051
12886
  },
13052
- zoomOut: async (options) => {
12887
+ zoomOut: async (options2) => {
13053
12888
  const { panZoom } = store.getState();
13054
- return panZoom ? panZoom.scaleBy(1 / 1.2, options) : false;
12889
+ return panZoom ? panZoom.scaleBy(1 / 1.2, options2) : false;
13055
12890
  },
13056
- zoomTo: async (zoomLevel, options) => {
12891
+ zoomTo: async (zoomLevel, options2) => {
13057
12892
  const { panZoom } = store.getState();
13058
- return panZoom ? panZoom.scaleTo(zoomLevel, options) : false;
12893
+ return panZoom ? panZoom.scaleTo(zoomLevel, options2) : false;
13059
12894
  },
13060
12895
  getZoom: () => store.getState().transform[2],
13061
- setViewport: async (viewport, options) => {
12896
+ setViewport: async (viewport, options2) => {
13062
12897
  const { transform: [tX, tY, tZoom], panZoom } = store.getState();
13063
12898
  if (!panZoom) {
13064
12899
  return false;
@@ -13067,30 +12902,30 @@ const useViewportHelper = () => {
13067
12902
  x: viewport.x ?? tX,
13068
12903
  y: viewport.y ?? tY,
13069
12904
  zoom: viewport.zoom ?? tZoom
13070
- }, options);
12905
+ }, options2);
13071
12906
  return true;
13072
12907
  },
13073
12908
  getViewport: () => {
13074
12909
  const [x, y, zoom2] = store.getState().transform;
13075
12910
  return { x, y, zoom: zoom2 };
13076
12911
  },
13077
- setCenter: async (x, y, options) => {
13078
- return store.getState().setCenter(x, y, options);
12912
+ setCenter: async (x, y, options2) => {
12913
+ return store.getState().setCenter(x, y, options2);
13079
12914
  },
13080
- fitBounds: async (bounds, options) => {
12915
+ fitBounds: async (bounds, options2) => {
13081
12916
  const { width, height, minZoom, maxZoom, panZoom } = store.getState();
13082
- const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, (options == null ? void 0 : options.padding) ?? 0.1);
12917
+ const viewport = getViewportForBounds(bounds, width, height, minZoom, maxZoom, options2?.padding ?? 0.1);
13083
12918
  if (!panZoom) {
13084
12919
  return false;
13085
12920
  }
13086
12921
  await panZoom.setViewport(viewport, {
13087
- duration: options == null ? void 0 : options.duration,
13088
- ease: options == null ? void 0 : options.ease,
13089
- interpolate: options == null ? void 0 : options.interpolate
12922
+ duration: options2?.duration,
12923
+ ease: options2?.ease,
12924
+ interpolate: options2?.interpolate
13090
12925
  });
13091
12926
  return true;
13092
12927
  },
13093
- screenToFlowPosition: (clientPosition, options = {}) => {
12928
+ screenToFlowPosition: (clientPosition, options2 = {}) => {
13094
12929
  const { transform: transform2, snapGrid, snapToGrid, domNode } = store.getState();
13095
12930
  if (!domNode) {
13096
12931
  return clientPosition;
@@ -13100,8 +12935,8 @@ const useViewportHelper = () => {
13100
12935
  x: clientPosition.x - domX,
13101
12936
  y: clientPosition.y - domY
13102
12937
  };
13103
- const _snapGrid = options.snapGrid ?? snapGrid;
13104
- const _snapToGrid = options.snapToGrid ?? snapToGrid;
12938
+ const _snapGrid = options2.snapGrid ?? snapGrid;
12939
+ const _snapToGrid = options2.snapToGrid ?? snapToGrid;
13105
12940
  return pointToRendererPoint(correctedPosition, transform2, _snapToGrid, _snapGrid);
13106
12941
  },
13107
12942
  flowToScreenPosition: (flowPosition) => {
@@ -13228,12 +13063,11 @@ function getSelectionChanges(items, selectedIds = /* @__PURE__ */ new Set()) {
13228
13063
  return changes;
13229
13064
  }
13230
13065
  function getElementsDiffChanges({ items = [], lookup }) {
13231
- var _a2;
13232
13066
  const changes = [];
13233
13067
  const itemsLookup = new Map(items.map((item) => [item.id, item]));
13234
13068
  for (const [index2, item] of items.entries()) {
13235
13069
  const lookupItem = lookup.get(item.id);
13236
- const storeItem = ((_a2 = lookupItem == null ? void 0 : lookupItem.internals) == null ? void 0 : _a2.userNode) ?? lookupItem;
13070
+ const storeItem = lookupItem?.internals?.userNode ?? lookupItem;
13237
13071
  if (storeItem !== void 0 && storeItem !== item) {
13238
13072
  changes.push({ id: item.id, item, type: "replace" });
13239
13073
  }
@@ -13256,10 +13090,10 @@ function elementToRemoveChange(item) {
13256
13090
  };
13257
13091
  }
13258
13092
  const defaultOnError = createDevWarn();
13259
- function addEdge(edgeParams, edges, options = {}) {
13093
+ function addEdge(edgeParams, edges, options2 = {}) {
13260
13094
  return addEdge$1(edgeParams, edges, {
13261
- ...options,
13262
- onError: options.onError ?? defaultOnError
13095
+ ...options2,
13096
+ onError: options2.onError ?? defaultOnError
13263
13097
  });
13264
13098
  }
13265
13099
  const isNode = (element) => isNodeBase(element);
@@ -13313,7 +13147,7 @@ function BatchProvider({ children: children2 }) {
13313
13147
  setNodes(next);
13314
13148
  }
13315
13149
  if (changes.length > 0) {
13316
- onNodesChange == null ? void 0 : onNodesChange(changes);
13150
+ onNodesChange?.(changes);
13317
13151
  } else if (fitViewQueued) {
13318
13152
  window.requestAnimationFrame(() => {
13319
13153
  const { fitViewQueued: fitViewQueued2, nodes: nodes2, setNodes: setNodes2 } = store.getState();
@@ -13365,42 +13199,38 @@ function useReactFlow() {
13365
13199
  batchContext.edgeQueue.push(payload);
13366
13200
  };
13367
13201
  const getNodeRect = (node) => {
13368
- var _a2, _b;
13369
13202
  const { nodeLookup, nodeOrigin } = store.getState();
13370
13203
  const nodeToUse = isNode(node) ? node : nodeLookup.get(node.id);
13371
13204
  const position = nodeToUse.parentId ? evaluateAbsolutePosition(nodeToUse.position, nodeToUse.measured, nodeToUse.parentId, nodeLookup, nodeOrigin) : nodeToUse.position;
13372
13205
  const nodeWithPosition = {
13373
13206
  ...nodeToUse,
13374
13207
  position,
13375
- width: ((_a2 = nodeToUse.measured) == null ? void 0 : _a2.width) ?? nodeToUse.width,
13376
- height: ((_b = nodeToUse.measured) == null ? void 0 : _b.height) ?? nodeToUse.height
13208
+ width: nodeToUse.measured?.width ?? nodeToUse.width,
13209
+ height: nodeToUse.measured?.height ?? nodeToUse.height
13377
13210
  };
13378
13211
  return nodeToRect(nodeWithPosition, nodeToUse.parentId ? void 0 : nodeOrigin);
13379
13212
  };
13380
- const updateNode = (id2, nodeUpdate, options = { replace: false }) => {
13213
+ const updateNode = (id2, nodeUpdate, options2 = { replace: false }) => {
13381
13214
  setNodes((prevNodes) => prevNodes.map((node) => {
13382
13215
  if (node.id === id2) {
13383
13216
  const nextNode = typeof nodeUpdate === "function" ? nodeUpdate(node) : nodeUpdate;
13384
- return options.replace && isNode(nextNode) ? nextNode : { ...node, ...nextNode };
13217
+ return options2.replace && isNode(nextNode) ? nextNode : { ...node, ...nextNode };
13385
13218
  }
13386
13219
  return node;
13387
13220
  }));
13388
13221
  };
13389
- const updateEdge = (id2, edgeUpdate, options = { replace: false }) => {
13222
+ const updateEdge = (id2, edgeUpdate, options2 = { replace: false }) => {
13390
13223
  setEdges((prevEdges) => prevEdges.map((edge) => {
13391
13224
  if (edge.id === id2) {
13392
13225
  const nextEdge = typeof edgeUpdate === "function" ? edgeUpdate(edge) : edgeUpdate;
13393
- return options.replace && isEdge(nextEdge) ? nextEdge : { ...edge, ...nextEdge };
13226
+ return options2.replace && isEdge(nextEdge) ? nextEdge : { ...edge, ...nextEdge };
13394
13227
  }
13395
13228
  return edge;
13396
13229
  }));
13397
13230
  };
13398
13231
  return {
13399
13232
  getNodes: () => store.getState().nodes.map((n) => ({ ...n })),
13400
- getNode: (id2) => {
13401
- var _a2;
13402
- return (_a2 = getInternalNode(id2)) == null ? void 0 : _a2.internals.userNode;
13403
- },
13233
+ getNode: (id2) => getInternalNode(id2)?.internals.userNode,
13404
13234
  getInternalNode,
13405
13235
  getEdges: () => {
13406
13236
  const { edges = [] } = store.getState();
@@ -13443,16 +13273,16 @@ function useReactFlow() {
13443
13273
  const hasMatchingNodes = matchingNodes.length > 0;
13444
13274
  if (hasMatchingEdges) {
13445
13275
  const edgeChanges = matchingEdges.map(elementToRemoveChange);
13446
- onEdgesDelete == null ? void 0 : onEdgesDelete(matchingEdges);
13276
+ onEdgesDelete?.(matchingEdges);
13447
13277
  triggerEdgeChanges(edgeChanges);
13448
13278
  }
13449
13279
  if (hasMatchingNodes) {
13450
13280
  const nodeChanges = matchingNodes.map(elementToRemoveChange);
13451
- onNodesDelete == null ? void 0 : onNodesDelete(matchingNodes);
13281
+ onNodesDelete?.(matchingNodes);
13452
13282
  triggerNodeChanges(nodeChanges);
13453
13283
  }
13454
13284
  if (hasMatchingNodes || hasMatchingEdges) {
13455
- onDelete == null ? void 0 : onDelete({ nodes: matchingNodes, edges: matchingEdges });
13285
+ onDelete?.({ nodes: matchingNodes, edges: matchingEdges });
13456
13286
  }
13457
13287
  return { deletedNodes: matchingNodes, deletedEdges: matchingEdges };
13458
13288
  },
@@ -13491,34 +13321,28 @@ function useReactFlow() {
13491
13321
  return partiallyVisible || overlappingArea >= area.width * area.height || overlappingArea >= nodeRect.width * nodeRect.height;
13492
13322
  },
13493
13323
  updateNode,
13494
- updateNodeData: (id2, dataUpdate, options = { replace: false }) => {
13324
+ updateNodeData: (id2, dataUpdate, options2 = { replace: false }) => {
13495
13325
  updateNode(id2, (node) => {
13496
13326
  const nextData = typeof dataUpdate === "function" ? dataUpdate(node) : dataUpdate;
13497
- return options.replace ? { ...node, data: nextData } : { ...node, data: { ...node.data, ...nextData } };
13498
- }, options);
13327
+ return options2.replace ? { ...node, data: nextData } : { ...node, data: { ...node.data, ...nextData } };
13328
+ }, options2);
13499
13329
  },
13500
13330
  updateEdge,
13501
- updateEdgeData: (id2, dataUpdate, options = { replace: false }) => {
13331
+ updateEdgeData: (id2, dataUpdate, options2 = { replace: false }) => {
13502
13332
  updateEdge(id2, (edge) => {
13503
13333
  const nextData = typeof dataUpdate === "function" ? dataUpdate(edge) : dataUpdate;
13504
- return options.replace ? { ...edge, data: nextData } : { ...edge, data: { ...edge.data, ...nextData } };
13505
- }, options);
13334
+ return options2.replace ? { ...edge, data: nextData } : { ...edge, data: { ...edge.data, ...nextData } };
13335
+ }, options2);
13506
13336
  },
13507
13337
  getNodesBounds: (nodes) => {
13508
13338
  const { nodeLookup, nodeOrigin } = store.getState();
13509
13339
  return getNodesBounds(nodes, { nodeLookup, nodeOrigin });
13510
13340
  },
13511
- getHandleConnections: ({ type, id: id2, nodeId }) => {
13512
- var _a2;
13513
- return Array.from(((_a2 = store.getState().connectionLookup.get(`${nodeId}-${type}${id2 ? `-${id2}` : ""}`)) == null ? void 0 : _a2.values()) ?? []);
13514
- },
13515
- getNodeConnections: ({ type, handleId, nodeId }) => {
13516
- var _a2;
13517
- return Array.from(((_a2 = store.getState().connectionLookup.get(`${nodeId}${type ? handleId ? `-${type}-${handleId}` : `-${type}` : ""}`)) == null ? void 0 : _a2.values()) ?? []);
13518
- },
13519
- fitView: async (options) => {
13341
+ getHandleConnections: ({ type, id: id2, nodeId }) => Array.from(store.getState().connectionLookup.get(`${nodeId}-${type}${id2 ? `-${id2}` : ""}`)?.values() ?? []),
13342
+ getNodeConnections: ({ type, handleId, nodeId }) => Array.from(store.getState().connectionLookup.get(`${nodeId}${type ? handleId ? `-${type}-${handleId}` : `-${type}` : ""}`)?.values() ?? []),
13343
+ fitView: async (options2) => {
13520
13344
  const fitViewResolver = store.getState().fitViewResolver ?? withResolvers();
13521
- store.setState({ fitViewQueued: true, fitViewOptions: options, fitViewResolver });
13345
+ store.setState({ fitViewQueued: true, fitViewOptions: options2, fitViewResolver });
13522
13346
  batchContext.nodeQueue.push((nodes) => [...nodes]);
13523
13347
  return fitViewResolver.promise;
13524
13348
  }
@@ -13554,13 +13378,12 @@ function useResizeHandler(domNode) {
13554
13378
  const store = useStoreApi();
13555
13379
  reactExports.useEffect(() => {
13556
13380
  const updateDimensions = () => {
13557
- var _a2, _b, _c, _d;
13558
- if (!domNode.current || !(((_b = (_a2 = domNode.current).checkVisibility) == null ? void 0 : _b.call(_a2)) ?? true)) {
13381
+ if (!domNode.current || !(domNode.current.checkVisibility?.() ?? true)) {
13559
13382
  return false;
13560
13383
  }
13561
13384
  const size = getDimensions(domNode.current);
13562
13385
  if (size.height === 0 || size.width === 0) {
13563
- (_d = (_c = store.getState()).onError) == null ? void 0 : _d.call(_c, "004", errorMessages["error004"]());
13386
+ store.getState().onError?.("004", errorMessages["error004"]());
13564
13387
  }
13565
13388
  store.setState({ width: size.width || 500, height: size.height || 500 });
13566
13389
  };
@@ -13596,7 +13419,7 @@ function ZoomPane({ onPaneContextMenu, zoomOnScroll = true, zoomOnPinch = true,
13596
13419
  const panZoom = reactExports.useRef();
13597
13420
  useResizeHandler(zoomPane);
13598
13421
  const onTransformChange = reactExports.useCallback((transform2) => {
13599
- onViewportChange == null ? void 0 : onViewportChange({ x: transform2[0], y: transform2[1], zoom: transform2[2] });
13422
+ onViewportChange?.({ x: transform2[0], y: transform2[1], zoom: transform2[2] });
13600
13423
  if (!isControlledViewport) {
13601
13424
  store.setState({ transform: transform2 });
13602
13425
  }
@@ -13612,18 +13435,18 @@ function ZoomPane({ onPaneContextMenu, zoomOnScroll = true, zoomOnPinch = true,
13612
13435
  onDraggingChange: (paneDragging) => store.setState((prevState) => prevState.paneDragging === paneDragging ? prevState : { paneDragging }),
13613
13436
  onPanZoomStart: (event, vp) => {
13614
13437
  const { onViewportChangeStart, onMoveStart } = store.getState();
13615
- onMoveStart == null ? void 0 : onMoveStart(event, vp);
13616
- onViewportChangeStart == null ? void 0 : onViewportChangeStart(vp);
13438
+ onMoveStart?.(event, vp);
13439
+ onViewportChangeStart?.(vp);
13617
13440
  },
13618
13441
  onPanZoom: (event, vp) => {
13619
13442
  const { onViewportChange: onViewportChange2, onMove } = store.getState();
13620
- onMove == null ? void 0 : onMove(event, vp);
13621
- onViewportChange2 == null ? void 0 : onViewportChange2(vp);
13443
+ onMove?.(event, vp);
13444
+ onViewportChange2?.(vp);
13622
13445
  },
13623
13446
  onPanZoomEnd: (event, vp) => {
13624
13447
  const { onViewportChangeEnd, onMoveEnd } = store.getState();
13625
- onMoveEnd == null ? void 0 : onMoveEnd(event, vp);
13626
- onViewportChangeEnd == null ? void 0 : onViewportChangeEnd(vp);
13448
+ onMoveEnd?.(event, vp);
13449
+ onViewportChangeEnd?.(vp);
13627
13450
  }
13628
13451
  });
13629
13452
  const { x, y, zoom: zoom2 } = panZoom.current.getViewport();
@@ -13633,14 +13456,12 @@ function ZoomPane({ onPaneContextMenu, zoomOnScroll = true, zoomOnPinch = true,
13633
13456
  domNode: zoomPane.current.closest(".react-flow")
13634
13457
  });
13635
13458
  return () => {
13636
- var _a2;
13637
- (_a2 = panZoom.current) == null ? void 0 : _a2.destroy();
13459
+ panZoom.current?.destroy();
13638
13460
  };
13639
13461
  }
13640
13462
  }, []);
13641
13463
  reactExports.useEffect(() => {
13642
- var _a2;
13643
- (_a2 = panZoom.current) == null ? void 0 : _a2.update({
13464
+ panZoom.current?.update({
13644
13465
  onPaneContextMenu,
13645
13466
  zoomOnScroll,
13646
13467
  zoomOnPinch,
@@ -13705,7 +13526,7 @@ const wrapHandler = (handler, containerRef) => {
13705
13526
  if (event.target !== containerRef.current) {
13706
13527
  return;
13707
13528
  }
13708
- handler == null ? void 0 : handler(event);
13529
+ handler?.(event);
13709
13530
  };
13710
13531
  };
13711
13532
  const selector$g = (s) => ({
@@ -13739,19 +13560,19 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13739
13560
  const connectionClone = structuredClone(connection);
13740
13561
  delete connectionClone.inProgress;
13741
13562
  connectionClone.toPosition = connectionClone.toHandle ? connectionClone.toHandle.position : null;
13742
- onClickConnectEnd == null ? void 0 : onClickConnectEnd(event.nativeEvent, connectionClone);
13563
+ onClickConnectEnd?.(event.nativeEvent, connectionClone);
13743
13564
  store.setState({ connectionClickStartHandle: null });
13744
13565
  }
13745
- onPaneClick == null ? void 0 : onPaneClick(event);
13566
+ onPaneClick?.(event);
13746
13567
  resetSelectedElements();
13747
13568
  store.setState({ nodesSelectionActive: false });
13748
13569
  };
13749
13570
  const onContextMenu = (event) => {
13750
- if (Array.isArray(panOnDrag) && (panOnDrag == null ? void 0 : panOnDrag.includes(2))) {
13571
+ if (Array.isArray(panOnDrag) && panOnDrag?.includes(2)) {
13751
13572
  event.preventDefault();
13752
13573
  return;
13753
13574
  }
13754
- onPaneContextMenu == null ? void 0 : onPaneContextMenu(event);
13575
+ onPaneContextMenu?.(event);
13755
13576
  };
13756
13577
  const onWheel = onPaneScroll ? (event) => onPaneScroll(event) : void 0;
13757
13578
  const onClickCapture = (event) => {
@@ -13761,12 +13582,11 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13761
13582
  }
13762
13583
  };
13763
13584
  const onPointerDownCapture = (event) => {
13764
- var _a2, _b;
13765
13585
  if (event.pointerType === "touch" && panOnDrag !== false && !selectionKeyPressed) {
13766
13586
  return;
13767
13587
  }
13768
13588
  const { domNode, transform: transform2 } = store.getState();
13769
- containerBounds.current = domNode == null ? void 0 : domNode.getBoundingClientRect();
13589
+ containerBounds.current = domNode?.getBoundingClientRect();
13770
13590
  if (!containerBounds.current)
13771
13591
  return;
13772
13592
  const eventTargetIsContainer = event.target === container.current;
@@ -13775,7 +13595,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13775
13595
  if (isNoKeyEvent || !isSelecting || !isSelectionActive || event.button !== 0 || !event.isPrimary) {
13776
13596
  return;
13777
13597
  }
13778
- (_b = (_a2 = event.target) == null ? void 0 : _a2.setPointerCapture) == null ? void 0 : _b.call(_a2, event.pointerId);
13598
+ event.target?.setPointerCapture?.(event.pointerId);
13779
13599
  selectionInProgress.current = false;
13780
13600
  const { x, y } = getEventPosition(event.nativeEvent, containerBounds.current);
13781
13601
  const userSelectionStartPosition = pointToRendererPoint({ x, y }, transform2);
@@ -13814,7 +13634,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13814
13634
  const prevSelectedEdgeIds = selectedEdgeIds.current;
13815
13635
  selectedNodeIds.current = new Set(getNodesInside(nodeLookup, nextUserSelectRect, transform2, selectionMode === SelectionMode.Partial, true).map((node) => node.id));
13816
13636
  selectedEdgeIds.current = /* @__PURE__ */ new Set();
13817
- const edgesSelectable = (defaultEdgeOptions == null ? void 0 : defaultEdgeOptions.selectable) ?? true;
13637
+ const edgesSelectable = defaultEdgeOptions?.selectable ?? true;
13818
13638
  for (const nodeId of selectedNodeIds.current) {
13819
13639
  const connections = connectionLookup.get(nodeId);
13820
13640
  if (!connections)
@@ -13878,7 +13698,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13878
13698
  return;
13879
13699
  }
13880
13700
  resetSelectedElements();
13881
- onSelectionStart == null ? void 0 : onSelectionStart(event);
13701
+ onSelectionStart?.(event);
13882
13702
  }
13883
13703
  selectionInProgress.current = true;
13884
13704
  if (!autoPanStarted.current) {
@@ -13888,7 +13708,6 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13888
13708
  commitUserSelectionRect(mouseX, mouseY);
13889
13709
  };
13890
13710
  const onPointerUp = (event) => {
13891
- var _a2, _b;
13892
13711
  if (!isSelectionEnabled) {
13893
13712
  if (event.target === container.current && store.getState().connection.inProgress) {
13894
13713
  connectionEndedOnPane.current = true;
@@ -13898,16 +13717,16 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13898
13717
  if (event.button !== 0) {
13899
13718
  return;
13900
13719
  }
13901
- (_b = (_a2 = event.target) == null ? void 0 : _a2.releasePointerCapture) == null ? void 0 : _b.call(_a2, event.pointerId);
13720
+ event.target?.releasePointerCapture?.(event.pointerId);
13902
13721
  if (!userSelectionActive && event.target === container.current && store.getState().userSelectionRect) {
13903
- onClick == null ? void 0 : onClick(event);
13722
+ onClick?.(event);
13904
13723
  }
13905
13724
  store.setState({
13906
13725
  userSelectionActive: false,
13907
13726
  userSelectionRect: null
13908
13727
  });
13909
13728
  if (selectionInProgress.current) {
13910
- onSelectionEnd == null ? void 0 : onSelectionEnd(event);
13729
+ onSelectionEnd?.(event);
13911
13730
  store.setState({
13912
13731
  nodesSelectionActive: selectedNodeIds.current.size > 0
13913
13732
  });
@@ -13915,8 +13734,7 @@ function Pane({ isSelecting, selectionKeyPressed, selectionMode = SelectionMode.
13915
13734
  cleanupAutoPan();
13916
13735
  };
13917
13736
  const onPointerCancel = (event) => {
13918
- var _a2, _b;
13919
- (_b = (_a2 = event.target) == null ? void 0 : _a2.releasePointerCapture) == null ? void 0 : _b.call(_a2, event.pointerId);
13737
+ event.target?.releasePointerCapture?.(event.pointerId);
13920
13738
  cleanupAutoPan();
13921
13739
  };
13922
13740
  const draggable = panOnDrag === true || Array.isArray(panOnDrag) && panOnDrag.includes(0);
@@ -13926,7 +13744,7 @@ function handleNodeClick({ id: id2, store, unselect = false, nodeRef }) {
13926
13744
  const { addSelectedNodes, unselectNodesAndEdges, multiSelectionActive, nodeLookup, onError } = store.getState();
13927
13745
  const node = nodeLookup.get(id2);
13928
13746
  if (!node) {
13929
- onError == null ? void 0 : onError("012", errorMessages["error012"](id2));
13747
+ onError?.("012", errorMessages["error012"](id2));
13930
13748
  return;
13931
13749
  }
13932
13750
  store.setState({ nodesSelectionActive: false });
@@ -13934,10 +13752,7 @@ function handleNodeClick({ id: id2, store, unselect = false, nodeRef }) {
13934
13752
  addSelectedNodes([id2]);
13935
13753
  } else if (unselect || node.selected && multiSelectionActive) {
13936
13754
  unselectNodesAndEdges({ nodes: [node], edges: [] });
13937
- requestAnimationFrame(() => {
13938
- var _a2;
13939
- return (_a2 = nodeRef == null ? void 0 : nodeRef.current) == null ? void 0 : _a2.blur();
13940
- });
13755
+ requestAnimationFrame(() => nodeRef?.current?.blur());
13941
13756
  }
13942
13757
  }
13943
13758
  function useDrag({ nodeRef, disabled = false, noDragClassName, handleSelector, nodeId, isSelectable, nodeClickDistance }) {
@@ -13965,8 +13780,7 @@ function useDrag({ nodeRef, disabled = false, noDragClassName, handleSelector, n
13965
13780
  }
13966
13781
  });
13967
13782
  return () => {
13968
- var _a2;
13969
- (_a2 = xyDrag.current) == null ? void 0 : _a2.destroy();
13783
+ xyDrag.current?.destroy();
13970
13784
  xyDrag.current = void 0;
13971
13785
  };
13972
13786
  }, [disabled, store, nodeRef]);
@@ -14062,19 +13876,18 @@ const connectingSelector = (nodeId, handleId, type) => (state) => {
14062
13876
  if (!fromHandle && !clickHandle) {
14063
13877
  return idleConnectingState;
14064
13878
  }
14065
- const connectingTo = (toHandle == null ? void 0 : toHandle.nodeId) === nodeId && (toHandle == null ? void 0 : toHandle.id) === handleId && (toHandle == null ? void 0 : toHandle.type) === type;
13879
+ const connectingTo = toHandle?.nodeId === nodeId && toHandle?.id === handleId && toHandle?.type === type;
14066
13880
  return {
14067
- connectingFrom: (fromHandle == null ? void 0 : fromHandle.nodeId) === nodeId && (fromHandle == null ? void 0 : fromHandle.id) === handleId && (fromHandle == null ? void 0 : fromHandle.type) === type,
13881
+ connectingFrom: fromHandle?.nodeId === nodeId && fromHandle?.id === handleId && fromHandle?.type === type,
14068
13882
  connectingTo,
14069
- clickConnecting: (clickHandle == null ? void 0 : clickHandle.nodeId) === nodeId && (clickHandle == null ? void 0 : clickHandle.id) === handleId && (clickHandle == null ? void 0 : clickHandle.type) === type,
14070
- isPossibleEndHandle: connectionMode === ConnectionMode.Strict ? (fromHandle == null ? void 0 : fromHandle.type) !== type : nodeId !== (fromHandle == null ? void 0 : fromHandle.nodeId) || handleId !== (fromHandle == null ? void 0 : fromHandle.id),
13883
+ clickConnecting: clickHandle?.nodeId === nodeId && clickHandle?.id === handleId && clickHandle?.type === type,
13884
+ isPossibleEndHandle: connectionMode === ConnectionMode.Strict ? fromHandle?.type !== type : nodeId !== fromHandle?.nodeId || handleId !== fromHandle?.id,
14071
13885
  connectionInProcess: !!fromHandle,
14072
13886
  clickConnectionInProcess: !!clickHandle,
14073
13887
  valid: connectingTo && isValid2
14074
13888
  };
14075
13889
  };
14076
13890
  function HandleComponent({ type = "source", position = Position.Top, isValidConnection, isConnectable = true, isConnectableStart = true, isConnectableEnd = true, id: id2, onConnect, children: children2, className, onMouseDown, onTouchStart, ...rest }, ref) {
14077
- var _a2, _b;
14078
13891
  const handleId = id2 || null;
14079
13892
  const isTarget = type === "target";
14080
13893
  const store = useStoreApi();
@@ -14082,7 +13895,7 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14082
13895
  const { connectOnClick, noPanClassName, rfId } = useHandleConfig();
14083
13896
  const { connectingFrom, connectingTo, clickConnecting, isPossibleEndHandle, connectionInProcess, clickConnectionInProcess, valid } = useStore(connectingSelector(nodeId, handleId, type), shallow$1);
14084
13897
  if (!nodeId) {
14085
- (_b = (_a2 = store.getState()).onError) == null ? void 0 : _b.call(_a2, "010", errorMessages["error010"]());
13898
+ store.getState().onError?.("010", errorMessages["error010"]());
14086
13899
  }
14087
13900
  const onConnectExtended = (params) => {
14088
13901
  const { defaultEdgeOptions, onConnect: onConnectAction, hasDefaultEdges } = store.getState();
@@ -14094,8 +13907,8 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14094
13907
  const { edges, setEdges, onError } = store.getState();
14095
13908
  setEdges(addEdge(edgeParams, edges, { onError }));
14096
13909
  }
14097
- onConnectAction == null ? void 0 : onConnectAction(edgeParams);
14098
- onConnect == null ? void 0 : onConnect(edgeParams);
13910
+ onConnectAction?.(edgeParams);
13911
+ onConnect?.(edgeParams);
14099
13912
  };
14100
13913
  const onPointerDown2 = (event) => {
14101
13914
  if (!nodeId) {
@@ -14119,16 +13932,10 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14119
13932
  panBy: currentStore.panBy,
14120
13933
  cancelConnection: currentStore.cancelConnection,
14121
13934
  onConnectStart: currentStore.onConnectStart,
14122
- onConnectEnd: (...args) => {
14123
- var _a3, _b2;
14124
- return (_b2 = (_a3 = store.getState()).onConnectEnd) == null ? void 0 : _b2.call(_a3, ...args);
14125
- },
13935
+ onConnectEnd: (...args) => store.getState().onConnectEnd?.(...args),
14126
13936
  updateConnection: currentStore.updateConnection,
14127
13937
  onConnect: onConnectExtended,
14128
- isValidConnection: isValidConnection || ((...args) => {
14129
- var _a3, _b2;
14130
- return ((_b2 = (_a3 = store.getState()).isValidConnection) == null ? void 0 : _b2.call(_a3, ...args)) ?? true;
14131
- }),
13938
+ isValidConnection: isValidConnection || ((...args) => store.getState().isValidConnection?.(...args) ?? true),
14132
13939
  getTransform: () => store.getState().transform,
14133
13940
  getFromHandle: () => store.getState().connection.fromHandle,
14134
13941
  autoPanSpeed: currentStore.autoPanSpeed,
@@ -14136,9 +13943,9 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14136
13943
  });
14137
13944
  }
14138
13945
  if (isMouseTriggered) {
14139
- onMouseDown == null ? void 0 : onMouseDown(event);
13946
+ onMouseDown?.(event);
14140
13947
  } else {
14141
- onTouchStart == null ? void 0 : onTouchStart(event);
13948
+ onTouchStart?.(event);
14142
13949
  }
14143
13950
  };
14144
13951
  const onClick = (event) => {
@@ -14147,7 +13954,7 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14147
13954
  return;
14148
13955
  }
14149
13956
  if (!connectionClickStartHandle) {
14150
- onClickConnectStart == null ? void 0 : onClickConnectStart(event.nativeEvent, { nodeId, handleId, handleType: type });
13957
+ onClickConnectStart?.(event.nativeEvent, { nodeId, handleId, handleType: type });
14151
13958
  store.setState({ connectionClickStartHandle: { nodeId, type, id: handleId } });
14152
13959
  return;
14153
13960
  }
@@ -14175,7 +13982,7 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14175
13982
  const connectionClone = structuredClone(connectionState);
14176
13983
  delete connectionClone.inProgress;
14177
13984
  connectionClone.toPosition = connectionClone.toHandle ? connectionClone.toHandle.position : null;
14178
- onClickConnectEnd == null ? void 0 : onClickConnectEnd(event, connectionClone);
13985
+ onClickConnectEnd?.(event, connectionClone);
14179
13986
  store.setState({ connectionClickStartHandle: null });
14180
13987
  };
14181
13988
  return jsxRuntimeExports.jsx("div", { "data-handleid": handleId, "data-nodeid": nodeId, "data-handlepos": position, "data-id": `${rfId}-${nodeId}-${handleId}-${type}`, className: cc([
@@ -14204,16 +14011,16 @@ function HandleComponent({ type = "source", position = Position.Top, isValidConn
14204
14011
  }
14205
14012
  const Handle = reactExports.memo(fixedForwardRef(HandleComponent));
14206
14013
  function InputNode({ data, isConnectable, sourcePosition = Position.Bottom }) {
14207
- return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [data == null ? void 0 : data.label, jsxRuntimeExports.jsx(Handle, { type: "source", position: sourcePosition, isConnectable })] });
14014
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [data?.label, jsxRuntimeExports.jsx(Handle, { type: "source", position: sourcePosition, isConnectable })] });
14208
14015
  }
14209
14016
  function DefaultNode({ data, isConnectable, targetPosition = Position.Top, sourcePosition = Position.Bottom }) {
14210
- return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Handle, { type: "target", position: targetPosition, isConnectable }), data == null ? void 0 : data.label, jsxRuntimeExports.jsx(Handle, { type: "source", position: sourcePosition, isConnectable })] });
14017
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Handle, { type: "target", position: targetPosition, isConnectable }), data?.label, jsxRuntimeExports.jsx(Handle, { type: "source", position: sourcePosition, isConnectable })] });
14211
14018
  }
14212
14019
  function GroupNode() {
14213
14020
  return null;
14214
14021
  }
14215
14022
  function OutputNode({ data, isConnectable, targetPosition = Position.Top }) {
14216
- return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Handle, { type: "target", position: targetPosition, isConnectable }), data == null ? void 0 : data.label] });
14023
+ return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(Handle, { type: "target", position: targetPosition, isConnectable }), data?.label] });
14217
14024
  }
14218
14025
  const arrowKeyDiffs = {
14219
14026
  ArrowUp: { x: 0, y: -1 },
@@ -14228,16 +14035,15 @@ const builtinNodeTypes = {
14228
14035
  group: GroupNode
14229
14036
  };
14230
14037
  function getNodeInlineStyleDimensions(node) {
14231
- var _a2, _b, _c, _d;
14232
14038
  if (node.internals.handleBounds === void 0) {
14233
14039
  return {
14234
- width: node.width ?? node.initialWidth ?? ((_a2 = node.style) == null ? void 0 : _a2.width),
14235
- height: node.height ?? node.initialHeight ?? ((_b = node.style) == null ? void 0 : _b.height)
14040
+ width: node.width ?? node.initialWidth ?? node.style?.width,
14041
+ height: node.height ?? node.initialHeight ?? node.style?.height
14236
14042
  };
14237
14043
  }
14238
14044
  return {
14239
- width: node.width ?? ((_c = node.style) == null ? void 0 : _c.width),
14240
- height: node.height ?? ((_d = node.style) == null ? void 0 : _d.height)
14045
+ width: node.width ?? node.style?.width,
14046
+ height: node.height ?? node.style?.height
14241
14047
  };
14242
14048
  }
14243
14049
  const selector$e = (s) => {
@@ -14257,9 +14063,8 @@ function NodesSelection({ onSelectionContextMenu, noPanClassName, disableKeyboar
14257
14063
  const moveSelectedNodes = useMoveSelectedNodes();
14258
14064
  const nodeRef = reactExports.useRef(null);
14259
14065
  reactExports.useEffect(() => {
14260
- var _a2;
14261
14066
  if (!disableKeyboardA11y) {
14262
- (_a2 = nodeRef.current) == null ? void 0 : _a2.focus({
14067
+ nodeRef.current?.focus({
14263
14068
  preventScroll: true
14264
14069
  });
14265
14070
  }
@@ -14338,7 +14143,7 @@ function useResizeObserver() {
14338
14143
  });
14339
14144
  reactExports.useEffect(() => {
14340
14145
  return () => {
14341
- resizeObserver == null ? void 0 : resizeObserver.disconnect();
14146
+ resizeObserver?.disconnect();
14342
14147
  };
14343
14148
  }, [resizeObserver]);
14344
14149
  return resizeObserver;
@@ -14354,16 +14159,16 @@ function useNodeObserver({ node, nodeType, hasDimensions, resizeObserver }) {
14354
14159
  reactExports.useEffect(() => {
14355
14160
  if (nodeRef.current && !node.hidden && (!isInitialized || observedNode.current !== nodeRef.current)) {
14356
14161
  if (observedNode.current) {
14357
- resizeObserver == null ? void 0 : resizeObserver.unobserve(observedNode.current);
14162
+ resizeObserver?.unobserve(observedNode.current);
14358
14163
  }
14359
- resizeObserver == null ? void 0 : resizeObserver.observe(nodeRef.current);
14164
+ resizeObserver?.observe(nodeRef.current);
14360
14165
  observedNode.current = nodeRef.current;
14361
14166
  }
14362
14167
  }, [isInitialized, node.hidden]);
14363
14168
  reactExports.useEffect(() => {
14364
14169
  return () => {
14365
14170
  if (observedNode.current) {
14366
- resizeObserver == null ? void 0 : resizeObserver.unobserve(observedNode.current);
14171
+ resizeObserver?.unobserve(observedNode.current);
14367
14172
  observedNode.current = null;
14368
14173
  }
14369
14174
  };
@@ -14394,11 +14199,11 @@ function NodeWrapper({ id: id2, onClick, onMouseEnter, onMouseMove, onMouseLeave
14394
14199
  };
14395
14200
  }, shallow$1);
14396
14201
  let nodeType = node.type || "default";
14397
- let NodeComponent = (nodeTypes2 == null ? void 0 : nodeTypes2[nodeType]) || builtinNodeTypes[nodeType];
14202
+ let NodeComponent = nodeTypes2?.[nodeType] || builtinNodeTypes[nodeType];
14398
14203
  if (NodeComponent === void 0) {
14399
- onError == null ? void 0 : onError("003", errorMessages["error003"](nodeType));
14204
+ onError?.("003", errorMessages["error003"](nodeType));
14400
14205
  nodeType = "default";
14401
- NodeComponent = (nodeTypes2 == null ? void 0 : nodeTypes2["default"]) || builtinNodeTypes.default;
14206
+ NodeComponent = nodeTypes2?.["default"] || builtinNodeTypes.default;
14402
14207
  }
14403
14208
  const isDraggable = !!(node.draggable || nodesDraggable && typeof node.draggable === "undefined");
14404
14209
  const isSelectable = !!(node.selectable || elementsSelectable && typeof node.selectable === "undefined");
@@ -14470,8 +14275,7 @@ function NodeWrapper({ id: id2, onClick, onMouseEnter, onMouseMove, onMouseLeave
14470
14275
  }
14471
14276
  };
14472
14277
  const onFocus = () => {
14473
- var _a2;
14474
- if (disableKeyboardA11y || !((_a2 = nodeRef.current) == null ? void 0 : _a2.matches(":focus-visible"))) {
14278
+ if (disableKeyboardA11y || !nodeRef.current?.matches(":focus-visible")) {
14475
14279
  return;
14476
14280
  }
14477
14281
  const { transform: transform2, width, height, autoPanOnNodeFocus, setCenter } = store.getState();
@@ -14599,10 +14403,9 @@ const MarkerSymbols = {
14599
14403
  function useMarkerSymbol(type) {
14600
14404
  const store = useStoreApi();
14601
14405
  const symbol = reactExports.useMemo(() => {
14602
- var _a2, _b;
14603
14406
  const symbolExists = Object.prototype.hasOwnProperty.call(MarkerSymbols, type);
14604
14407
  if (!symbolExists) {
14605
- (_b = (_a2 = store.getState()).onError) == null ? void 0 : _b.call(_a2, "009", errorMessages["error009"](type));
14408
+ store.getState().onError?.("009", errorMessages["error009"](type));
14606
14409
  return null;
14607
14410
  }
14608
14411
  return MarkerSymbols[type];
@@ -14623,8 +14426,8 @@ const MarkerDefinitions = ({ defaultColor, rfId }) => {
14623
14426
  const markers2 = createMarkerIds(edges, {
14624
14427
  id: rfId,
14625
14428
  defaultColor,
14626
- defaultMarkerStart: defaultEdgeOptions == null ? void 0 : defaultEdgeOptions.markerStart,
14627
- defaultMarkerEnd: defaultEdgeOptions == null ? void 0 : defaultEdgeOptions.markerEnd
14429
+ defaultMarkerStart: defaultEdgeOptions?.markerStart,
14430
+ defaultMarkerEnd: defaultEdgeOptions?.markerEnd
14628
14431
  });
14629
14432
  return markers2;
14630
14433
  }, [edges, defaultEdgeOptions, rfId, defaultColor]);
@@ -14726,9 +14529,9 @@ function createSmoothStepEdge(params) {
14726
14529
  targetX,
14727
14530
  targetY,
14728
14531
  targetPosition,
14729
- borderRadius: pathOptions == null ? void 0 : pathOptions.borderRadius,
14730
- offset: pathOptions == null ? void 0 : pathOptions.offset,
14731
- stepPosition: pathOptions == null ? void 0 : pathOptions.stepPosition
14532
+ borderRadius: pathOptions?.borderRadius,
14533
+ offset: pathOptions?.offset,
14534
+ stepPosition: pathOptions?.stepPosition
14732
14535
  });
14733
14536
  const _id = params.isInternal ? void 0 : id2;
14734
14537
  return jsxRuntimeExports.jsx(BaseEdge, { id: _id, path, labelX, labelY, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, style: style2, markerEnd, markerStart, interactionWidth });
@@ -14740,12 +14543,8 @@ SmoothStepEdge.displayName = "SmoothStepEdge";
14740
14543
  SmoothStepEdgeInternal.displayName = "SmoothStepEdgeInternal";
14741
14544
  function createStepEdge(params) {
14742
14545
  return reactExports.memo(({ id: id2, ...props }) => {
14743
- var _a2;
14744
14546
  const _id = params.isInternal ? void 0 : id2;
14745
- return jsxRuntimeExports.jsx(SmoothStepEdge, { ...props, id: _id, pathOptions: reactExports.useMemo(() => {
14746
- var _a3;
14747
- return { borderRadius: 0, offset: (_a3 = props.pathOptions) == null ? void 0 : _a3.offset };
14748
- }, [(_a2 = props.pathOptions) == null ? void 0 : _a2.offset]) });
14547
+ return jsxRuntimeExports.jsx(SmoothStepEdge, { ...props, id: _id, pathOptions: reactExports.useMemo(() => ({ borderRadius: 0, offset: props.pathOptions?.offset }), [props.pathOptions?.offset]) });
14749
14548
  });
14750
14549
  }
14751
14550
  const StepEdge = createStepEdge({ isInternal: false });
@@ -14772,7 +14571,7 @@ function createBezierEdge(params) {
14772
14571
  targetX,
14773
14572
  targetY,
14774
14573
  targetPosition,
14775
- curvature: pathOptions == null ? void 0 : pathOptions.curvature
14574
+ curvature: pathOptions?.curvature
14776
14575
  });
14777
14576
  const _id = params.isInternal ? void 0 : id2;
14778
14577
  return jsxRuntimeExports.jsx(BaseEdge, { id: _id, path, labelX, labelY, label, labelStyle, labelShowBg, labelBgStyle, labelBgPadding, labelBgBorderRadius, style: style2, markerEnd, markerStart, interactionWidth });
@@ -14826,13 +14625,13 @@ function EdgeUpdateAnchors({ isReconnectable, reconnectRadius, edge, sourceX, so
14826
14625
  const isTarget = oppositeHandle.type === "target";
14827
14626
  const _onReconnectEnd = (evt, connectionState) => {
14828
14627
  setReconnecting(false);
14829
- onReconnectEnd == null ? void 0 : onReconnectEnd(evt, edge, oppositeHandle.type, connectionState);
14628
+ onReconnectEnd?.(evt, edge, oppositeHandle.type, connectionState);
14830
14629
  };
14831
- const onConnectEdge = (connection) => onReconnect == null ? void 0 : onReconnect(edge, connection);
14630
+ const onConnectEdge = (connection) => onReconnect?.(edge, connection);
14832
14631
  const _onConnectStart = (_event, params) => {
14833
14632
  setReconnecting(true);
14834
- onReconnectStart == null ? void 0 : onReconnectStart(event, edge, oppositeHandle.type);
14835
- onConnectStart == null ? void 0 : onConnectStart(_event, params);
14633
+ onReconnectStart?.(event, edge, oppositeHandle.type);
14634
+ onConnectStart?.(_event, params);
14836
14635
  };
14837
14636
  XYHandle.onPointerDown(event.nativeEvent, {
14838
14637
  autoPanOnConnect,
@@ -14848,16 +14647,10 @@ function EdgeUpdateAnchors({ isReconnectable, reconnectRadius, edge, sourceX, so
14848
14647
  flowId,
14849
14648
  cancelConnection,
14850
14649
  panBy: panBy2,
14851
- isValidConnection: (...args) => {
14852
- var _a2, _b;
14853
- return ((_b = (_a2 = store.getState()).isValidConnection) == null ? void 0 : _b.call(_a2, ...args)) ?? true;
14854
- },
14650
+ isValidConnection: (...args) => store.getState().isValidConnection?.(...args) ?? true,
14855
14651
  onConnect: onConnectEdge,
14856
14652
  onConnectStart: _onConnectStart,
14857
- onConnectEnd: (...args) => {
14858
- var _a2, _b;
14859
- return (_b = (_a2 = store.getState()).onConnectEnd) == null ? void 0 : _b.call(_a2, ...args);
14860
- },
14653
+ onConnectEnd: (...args) => store.getState().onConnectEnd?.(...args),
14861
14654
  onReconnectEnd: _onReconnectEnd,
14862
14655
  updateConnection,
14863
14656
  getTransform: () => store.getState().transform,
@@ -14877,11 +14670,11 @@ function EdgeWrapper({ id: id2, edgesFocusable, edgesReconnectable, elementsSele
14877
14670
  const defaultEdgeOptions = useStore((s) => s.defaultEdgeOptions);
14878
14671
  edge = defaultEdgeOptions ? { ...defaultEdgeOptions, ...edge } : edge;
14879
14672
  let edgeType = edge.type || "default";
14880
- let EdgeComponent = (edgeTypes2 == null ? void 0 : edgeTypes2[edgeType]) || builtinEdgeTypes[edgeType];
14673
+ let EdgeComponent = edgeTypes2?.[edgeType] || builtinEdgeTypes[edgeType];
14881
14674
  if (EdgeComponent === void 0) {
14882
- onError == null ? void 0 : onError("011", errorMessages["error011"](edgeType));
14675
+ onError?.("011", errorMessages["error011"](edgeType));
14883
14676
  edgeType = "default";
14884
- EdgeComponent = (edgeTypes2 == null ? void 0 : edgeTypes2["default"]) || builtinEdgeTypes.default;
14677
+ EdgeComponent = edgeTypes2?.["default"] || builtinEdgeTypes.default;
14885
14678
  }
14886
14679
  const isFocusable = !!(edge.focusable || edgesFocusable && typeof edge.focusable === "undefined");
14887
14680
  const isReconnectable = typeof onReconnect !== "undefined" && (edge.reconnectable || edgesReconnectable && typeof edge.reconnectable === "undefined");
@@ -14924,13 +14717,12 @@ function EdgeWrapper({ id: id2, edgesFocusable, edgesReconnectable, elementsSele
14924
14717
  return null;
14925
14718
  }
14926
14719
  const onEdgeClick = (event) => {
14927
- var _a2;
14928
14720
  const { addSelectedEdges, unselectNodesAndEdges, multiSelectionActive } = store.getState();
14929
14721
  if (isSelectable) {
14930
14722
  store.setState({ nodesSelectionActive: false });
14931
14723
  if (edge.selected && multiSelectionActive) {
14932
14724
  unselectNodesAndEdges({ nodes: [], edges: [edge] });
14933
- (_a2 = edgeRef.current) == null ? void 0 : _a2.blur();
14725
+ edgeRef.current?.blur();
14934
14726
  } else {
14935
14727
  addSelectedEdges([id2]);
14936
14728
  }
@@ -14955,12 +14747,11 @@ function EdgeWrapper({ id: id2, edgesFocusable, edgesReconnectable, elementsSele
14955
14747
  onMouseLeave(event, { ...edge });
14956
14748
  } : void 0;
14957
14749
  const onKeyDown = (event) => {
14958
- var _a2;
14959
14750
  if (!disableKeyboardA11y && elementSelectionKeys.includes(event.key) && isSelectable) {
14960
14751
  const { unselectNodesAndEdges, addSelectedEdges } = store.getState();
14961
14752
  const unselect = event.key === "Escape";
14962
14753
  if (unselect) {
14963
- (_a2 = edgeRef.current) == null ? void 0 : _a2.blur();
14754
+ edgeRef.current?.blur();
14964
14755
  unselectNodesAndEdges({ edges: [edge] });
14965
14756
  } else {
14966
14757
  addSelectedEdges([id2]);
@@ -15030,16 +14821,13 @@ function useOnInitHandler(onInit) {
15030
14821
  }
15031
14822
  }, [onInit, rfInstance.viewportInitialized]);
15032
14823
  }
15033
- const selector$8 = (state) => {
15034
- var _a2;
15035
- return (_a2 = state.panZoom) == null ? void 0 : _a2.syncViewport;
15036
- };
14824
+ const selector$8 = (state) => state.panZoom?.syncViewport;
15037
14825
  function useViewportSync(viewport) {
15038
14826
  const syncViewport = useStore(selector$8);
15039
14827
  const store = useStoreApi();
15040
14828
  reactExports.useEffect(() => {
15041
14829
  if (viewport) {
15042
- syncViewport == null ? void 0 : syncViewport(viewport);
14830
+ syncViewport?.(viewport);
15043
14831
  store.setState({ transform: [viewport.x, viewport.y, viewport.zoom] });
15044
14832
  }
15045
14833
  }, [viewport, syncViewport]);
@@ -15153,7 +14941,7 @@ const getInitialState = ({ nodes, edges, defaultNodes, defaultEdges, width, heig
15153
14941
  const bounds = getInternalNodesBounds(nodeLookup, {
15154
14942
  filter: (node) => !!((node.width || node.initialWidth) && (node.height || node.initialHeight))
15155
14943
  });
15156
- const { x, y, zoom: zoom2 } = getViewportForBounds(bounds, width, height, minZoom, maxZoom, (fitViewOptions == null ? void 0 : fitViewOptions.padding) ?? 0.1);
14944
+ const { x, y, zoom: zoom2 } = getViewportForBounds(bounds, width, height, minZoom, maxZoom, fitViewOptions?.padding ?? 0.1);
15157
14945
  transform2 = [x, y, zoom2];
15158
14946
  }
15159
14947
  return {
@@ -15258,7 +15046,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15258
15046
  minZoom: minZoom2,
15259
15047
  maxZoom: maxZoom2
15260
15048
  }, fitViewOptions2);
15261
- fitViewResolver == null ? void 0 : fitViewResolver.resolve(true);
15049
+ fitViewResolver?.resolve(true);
15262
15050
  set2({ fitViewResolver: null });
15263
15051
  }
15264
15052
  return {
@@ -15335,11 +15123,11 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15335
15123
  } else {
15336
15124
  set2({});
15337
15125
  }
15338
- if ((changes == null ? void 0 : changes.length) > 0) {
15126
+ if (changes?.length > 0) {
15339
15127
  if (debug) {
15340
15128
  console.log("React Flow: trigger node changes", changes);
15341
15129
  }
15342
- triggerNodeChanges == null ? void 0 : triggerNodeChanges(changes);
15130
+ triggerNodeChanges?.(changes);
15343
15131
  }
15344
15132
  },
15345
15133
  updateNodePositions: (nodeDragItems, dragging = false) => {
@@ -15348,7 +15136,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15348
15136
  const { nodeLookup, triggerNodeChanges, connection, updateConnection, onNodesChangeMiddlewareMap } = get2();
15349
15137
  for (const [id2, dragItem] of nodeDragItems) {
15350
15138
  const node = nodeLookup.get(id2);
15351
- const expandParent = !!((node == null ? void 0 : node.expandParent) && (node == null ? void 0 : node.parentId) && (dragItem == null ? void 0 : dragItem.position));
15139
+ const expandParent = !!(node?.expandParent && node?.parentId && dragItem?.position);
15352
15140
  const change = {
15353
15141
  id: id2,
15354
15142
  type: "position",
@@ -15387,7 +15175,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15387
15175
  },
15388
15176
  triggerNodeChanges: (changes) => {
15389
15177
  const { onNodesChange, setNodes, nodes: nodes2, hasDefaultNodes, debug } = get2();
15390
- if (changes == null ? void 0 : changes.length) {
15178
+ if (changes?.length) {
15391
15179
  if (hasDefaultNodes) {
15392
15180
  const updatedNodes = applyNodeChanges(changes, nodes2);
15393
15181
  setNodes(updatedNodes);
@@ -15395,12 +15183,12 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15395
15183
  if (debug) {
15396
15184
  console.log("React Flow: trigger node changes", changes);
15397
15185
  }
15398
- onNodesChange == null ? void 0 : onNodesChange(changes);
15186
+ onNodesChange?.(changes);
15399
15187
  }
15400
15188
  },
15401
15189
  triggerEdgeChanges: (changes) => {
15402
15190
  const { onEdgesChange, setEdges, edges: edges2, hasDefaultEdges, debug } = get2();
15403
- if (changes == null ? void 0 : changes.length) {
15191
+ if (changes?.length) {
15404
15192
  if (hasDefaultEdges) {
15405
15193
  const updatedEdges = applyEdgeChanges(changes, edges2);
15406
15194
  setEdges(updatedEdges);
@@ -15408,7 +15196,7 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15408
15196
  if (debug) {
15409
15197
  console.log("React Flow: trigger edge changes", changes);
15410
15198
  }
15411
- onEdgesChange == null ? void 0 : onEdgesChange(changes);
15199
+ onEdgesChange?.(changes);
15412
15200
  }
15413
15201
  },
15414
15202
  addSelectedNodes: (selectedNodeIds) => {
@@ -15454,17 +15242,16 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15454
15242
  },
15455
15243
  setMinZoom: (minZoom2) => {
15456
15244
  const { panZoom, maxZoom: maxZoom2 } = get2();
15457
- panZoom == null ? void 0 : panZoom.setScaleExtent([minZoom2, maxZoom2]);
15245
+ panZoom?.setScaleExtent([minZoom2, maxZoom2]);
15458
15246
  set2({ minZoom: minZoom2 });
15459
15247
  },
15460
15248
  setMaxZoom: (maxZoom2) => {
15461
15249
  const { panZoom, minZoom: minZoom2 } = get2();
15462
- panZoom == null ? void 0 : panZoom.setScaleExtent([minZoom2, maxZoom2]);
15250
+ panZoom?.setScaleExtent([minZoom2, maxZoom2]);
15463
15251
  set2({ maxZoom: maxZoom2 });
15464
15252
  },
15465
15253
  setTranslateExtent: (translateExtent) => {
15466
- var _a2;
15467
- (_a2 = get2().panZoom) == null ? void 0 : _a2.setTranslateExtent(translateExtent);
15254
+ get2().panZoom?.setTranslateExtent(translateExtent);
15468
15255
  set2({ translateExtent });
15469
15256
  },
15470
15257
  resetSelectedElements: () => {
@@ -15495,17 +15282,17 @@ const createStore = ({ nodes, edges, defaultNodes, defaultEdges, width, height,
15495
15282
  const { transform: transform2, width: width2, height: height2, panZoom, translateExtent } = get2();
15496
15283
  return panBy({ delta, panZoom, transform: transform2, translateExtent, width: width2, height: height2 });
15497
15284
  },
15498
- setCenter: async (x, y, options) => {
15285
+ setCenter: async (x, y, options2) => {
15499
15286
  const { width: width2, height: height2, maxZoom: maxZoom2, panZoom } = get2();
15500
15287
  if (!panZoom) {
15501
15288
  return false;
15502
15289
  }
15503
- const nextZoom = typeof (options == null ? void 0 : options.zoom) !== "undefined" ? options.zoom : maxZoom2;
15290
+ const nextZoom = typeof options2?.zoom !== "undefined" ? options2.zoom : maxZoom2;
15504
15291
  await panZoom.setViewport({
15505
15292
  x: width2 / 2 - x * nextZoom,
15506
15293
  y: height2 / 2 - y * nextZoom,
15507
15294
  zoom: nextZoom
15508
- }, { duration: options == null ? void 0 : options.duration, ease: options == null ? void 0 : options.ease, interpolate: options == null ? void 0 : options.interpolate });
15295
+ }, { duration: options2?.duration, ease: options2?.ease, interpolate: options2?.interpolate });
15509
15296
  return true;
15510
15297
  },
15511
15298
  cancelConnection: () => {
@@ -15556,15 +15343,12 @@ function ReactFlow({ nodes, edges, defaultNodes, defaultEdges, className, nodeTy
15556
15343
  const colorModeClassName = useColorModeClass(colorMode);
15557
15344
  const wrapperOnScroll = reactExports.useCallback((e) => {
15558
15345
  e.currentTarget.scrollTo({ top: 0, left: 0, behavior: "instant" });
15559
- onScroll == null ? void 0 : onScroll(e);
15346
+ onScroll?.(e);
15560
15347
  }, [onScroll]);
15561
15348
  return jsxRuntimeExports.jsx("div", { "data-testid": "rf__wrapper", ...rest, onScroll: wrapperOnScroll, style: { ...style2, ...wrapperStyle }, ref, className: cc(["react-flow", className, colorModeClassName]), id: id2, role: "application", children: jsxRuntimeExports.jsxs(Wrapper, { nodes, edges, width, height, fitView, fitViewOptions, minZoom, maxZoom, nodeOrigin, nodeExtent, zIndexMode, children: [jsxRuntimeExports.jsx(StoreUpdater, { nodes, edges, defaultNodes, defaultEdges, onConnect, onConnectStart, onConnectEnd, onClickConnectStart, onClickConnectEnd, nodesDraggable, autoPanOnNodeFocus, nodesConnectable, nodesFocusable, edgesFocusable, edgesReconnectable, elementsSelectable, elevateNodesOnSelect, elevateEdgesOnSelect, minZoom, maxZoom, nodeExtent, onNodesChange, onEdgesChange, snapToGrid, snapGrid, connectionMode, translateExtent, connectOnClick, defaultEdgeOptions, fitView, fitViewOptions, onNodesDelete, onEdgesDelete, onDelete, onNodeDragStart, onNodeDrag, onNodeDragStop, onSelectionDrag, onSelectionDragStart, onSelectionDragStop, onMove, onMoveStart, onMoveEnd, noPanClassName, nodeOrigin, rfId, autoPanOnConnect, autoPanOnNodeDrag, autoPanSpeed, onError, connectionRadius, isValidConnection, selectNodesOnDrag, nodeDragThreshold, connectionDragThreshold, onBeforeDelete, debug, ariaLabelConfig, zIndexMode }), jsxRuntimeExports.jsx(GraphView, { onInit, onNodeClick, onEdgeClick, onNodeMouseEnter, onNodeMouseMove, onNodeMouseLeave, onNodeContextMenu, onNodeDoubleClick, nodeTypes: nodeTypes2, edgeTypes: edgeTypes2, connectionLineType, connectionLineStyle, connectionLineComponent, connectionLineContainerStyle, selectionKeyCode, selectionOnDrag, selectionMode, deleteKeyCode, multiSelectionKeyCode, panActivationKeyCode, zoomActivationKeyCode, onlyRenderVisibleElements, defaultViewport: defaultViewport$1, translateExtent, minZoom, maxZoom, preventScrolling, zoomOnScroll, zoomOnPinch, zoomOnDoubleClick, panOnScroll, panOnScrollSpeed, panOnScrollMode, panOnDrag, autoPanOnSelection, onPaneClick, onPaneMouseEnter, onPaneMouseMove, onPaneMouseLeave, onPaneScroll, onPaneContextMenu, paneClickDistance, nodeClickDistance, onSelectionContextMenu, onSelectionStart, onSelectionEnd, onReconnect, onReconnectStart, onReconnectEnd, onEdgeContextMenu, onEdgeDoubleClick, onEdgeMouseEnter, onEdgeMouseMove, onEdgeMouseLeave, reconnectRadius, defaultMarkerColor, noDragClassName, noWheelClassName, noPanClassName, rfId, disableKeyboardA11y, nodeExtent, viewport, onViewportChange, nodesDraggable }), jsxRuntimeExports.jsx(SelectionListener, { onSelectionChange }), children2, jsxRuntimeExports.jsx(Attribution, { proOptions, position: attributionPosition }), jsxRuntimeExports.jsx(A11yDescriptions, { rfId, disableKeyboardA11y })] }) });
15562
15349
  }
15563
15350
  var index = fixedForwardRef(ReactFlow);
15564
- const selector$6 = (s) => {
15565
- var _a2;
15566
- return (_a2 = s.domNode) == null ? void 0 : _a2.querySelector(".react-flow__edgelabel-renderer");
15567
- };
15351
+ const selector$6 = (s) => s.domNode?.querySelector(".react-flow__edgelabel-renderer");
15568
15352
  function EdgeLabelRenderer({ children: children2 }) {
15569
15353
  const edgeLabelRenderer = useStore(selector$6);
15570
15354
  if (!edgeLabelRenderer) {
@@ -15669,15 +15453,15 @@ function ControlsComponent({ style: style2, showZoom = true, showFitView = true,
15669
15453
  const { zoomIn, zoomOut, fitView } = useReactFlow();
15670
15454
  const onZoomInHandler = () => {
15671
15455
  zoomIn();
15672
- onZoomIn == null ? void 0 : onZoomIn();
15456
+ onZoomIn?.();
15673
15457
  };
15674
15458
  const onZoomOutHandler = () => {
15675
15459
  zoomOut();
15676
- onZoomOut == null ? void 0 : onZoomOut();
15460
+ onZoomOut?.();
15677
15461
  };
15678
15462
  const onFitViewHandler = () => {
15679
15463
  fitView(fitViewOptions);
15680
- onFitView == null ? void 0 : onFitView();
15464
+ onFitView?.();
15681
15465
  };
15682
15466
  const onToggleInteractivity = () => {
15683
15467
  store.setState({
@@ -15685,7 +15469,7 @@ function ControlsComponent({ style: style2, showZoom = true, showFitView = true,
15685
15469
  nodesConnectable: !isInteractive,
15686
15470
  elementsSelectable: !isInteractive
15687
15471
  });
15688
- onInteractiveChange == null ? void 0 : onInteractiveChange(!isInteractive);
15472
+ onInteractiveChange?.(!isInteractive);
15689
15473
  };
15690
15474
  const orientationClass = orientation === "horizontal" ? "horizontal" : "vertical";
15691
15475
  return jsxRuntimeExports.jsxs(Panel, { className: cc(["react-flow__controls", orientationClass, className]), position, style: style2, "data-testid": "rf__controls", "aria-label": ariaLabel ?? ariaLabelConfig["controls.ariaLabel"], children: [showZoom && jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx(ControlButton, { onClick: onZoomInHandler, className: "react-flow__controls-zoomin", title: ariaLabelConfig["controls.zoomIn.ariaLabel"], "aria-label": ariaLabelConfig["controls.zoomIn.ariaLabel"], disabled: maxZoomReached, children: jsxRuntimeExports.jsx(PlusIcon, {}) }), jsxRuntimeExports.jsx(ControlButton, { onClick: onZoomOutHandler, className: "react-flow__controls-zoomout", title: ariaLabelConfig["controls.zoomOut.ariaLabel"], "aria-label": ariaLabelConfig["controls.zoomOut.ariaLabel"], disabled: minZoomReached, children: jsxRuntimeExports.jsx(MinusIcon, {}) })] }), showFitView && jsxRuntimeExports.jsx(ControlButton, { className: "react-flow__controls-fitview", onClick: onFitViewHandler, title: ariaLabelConfig["controls.fitView.ariaLabel"], "aria-label": ariaLabelConfig["controls.fitView.ariaLabel"], children: jsxRuntimeExports.jsx(FitViewIcon, {}) }), showInteractive && jsxRuntimeExports.jsx(ControlButton, { className: "react-flow__controls-interactive", onClick: onToggleInteractivity, title: ariaLabelConfig["controls.interactive.ariaLabel"], "aria-label": ariaLabelConfig["controls.interactive.ariaLabel"], children: isInteractive ? jsxRuntimeExports.jsx(UnlockIcon, {}) : jsxRuntimeExports.jsx(LockIcon, {}) }), children2] });
@@ -15818,8 +15602,8 @@ function MiniMapComponent({
15818
15602
  const store = useStoreApi();
15819
15603
  const svg = reactExports.useRef(null);
15820
15604
  const { boundingRect, panZoom, viewBB, rfId, translateExtent, flowWidth, flowHeight, ariaLabelConfig } = useStore(selector$1, areEqual);
15821
- const elementWidth = (style2 == null ? void 0 : style2.width) ?? defaultWidth;
15822
- const elementHeight = (style2 == null ? void 0 : style2.height) ?? defaultHeight;
15605
+ const elementWidth = style2?.width ?? defaultWidth;
15606
+ const elementHeight = style2?.height ?? defaultHeight;
15823
15607
  const scaledWidth = boundingRect.width / elementWidth;
15824
15608
  const scaledHeight = boundingRect.height / elementHeight;
15825
15609
  const viewScale = Math.max(scaledWidth, scaledHeight);
@@ -15844,14 +15628,12 @@ function MiniMapComponent({
15844
15628
  getViewScale: () => viewScaleRef.current
15845
15629
  });
15846
15630
  return () => {
15847
- var _a2;
15848
- (_a2 = minimapInstance.current) == null ? void 0 : _a2.destroy();
15631
+ minimapInstance.current?.destroy();
15849
15632
  };
15850
15633
  }
15851
15634
  }, [panZoom]);
15852
15635
  reactExports.useEffect(() => {
15853
- var _a2;
15854
- (_a2 = minimapInstance.current) == null ? void 0 : _a2.update({
15636
+ minimapInstance.current?.update({
15855
15637
  translateExtent,
15856
15638
  width: flowWidth,
15857
15639
  height: flowHeight,
@@ -15862,13 +15644,12 @@ function MiniMapComponent({
15862
15644
  });
15863
15645
  }, [pannable, zoomable, inversePan, zoomStep, translateExtent, flowWidth, flowHeight]);
15864
15646
  const onSvgClick = onClick ? (event) => {
15865
- var _a2;
15866
- const [x2, y2] = ((_a2 = minimapInstance.current) == null ? void 0 : _a2.pointer(event)) || [0, 0];
15647
+ const [x2, y2] = minimapInstance.current?.pointer(event) || [0, 0];
15867
15648
  onClick(event, { x: x2, y: y2 });
15868
15649
  } : void 0;
15869
15650
  const nodeClickHandler = reactExports.useCallback((event, nodeId) => {
15870
15651
  const node = store.getState().nodeLookup.get(nodeId).internals.userNode;
15871
- onNodeClick == null ? void 0 : onNodeClick(event, node);
15652
+ onNodeClick?.(event, node);
15872
15653
  }, [onNodeClick]);
15873
15654
  const onSvgNodeClick = onNodeClick ? nodeClickHandler : void 0;
15874
15655
  const _ariaLabel = ariaLabel ?? ariaLabelConfig["minimap.ariaLabel"];
@@ -16006,8 +15787,7 @@ function ResizeControl({ nodeId, position, variant = ResizeControlVariant.Handle
16006
15787
  shouldResize
16007
15788
  });
16008
15789
  return () => {
16009
- var _a2;
16010
- (_a2 = resizer.current) == null ? void 0 : _a2.destroy();
15790
+ resizer.current?.destroy();
16011
15791
  };
16012
15792
  }, [
16013
15793
  controlPosition,
@@ -16038,21 +15818,20 @@ const LAYOUT = {
16038
15818
  PARALLEL_GROUP_PADDING: 25
16039
15819
  };
16040
15820
  function LoopNodeComponent({ data, selected: selected2 }) {
16041
- var _a2, _b, _c, _d;
16042
15821
  const nodeData = data;
16043
15822
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
16044
15823
  "div",
16045
15824
  {
16046
15825
  className: `relative ${nodeData.className || ""}`,
16047
15826
  style: {
16048
- borderWidth: ((_a2 = nodeData.nodeStyle) == null ? void 0 : _a2.borderWidth) ?? 1,
15827
+ borderWidth: nodeData.nodeStyle?.borderWidth ?? 1,
16049
15828
  borderRadius: 8,
16050
15829
  padding: 12,
16051
15830
  width: 220,
16052
15831
  borderStyle: "solid",
16053
- backgroundColor: (_b = nodeData.nodeStyle) == null ? void 0 : _b.backgroundColor,
16054
- borderColor: ((_c = nodeData.nodeStyle) == null ? void 0 : _c.borderColor) ?? "#9ca3af",
16055
- opacity: (_d = nodeData.nodeStyle) == null ? void 0 : _d.opacity,
15832
+ backgroundColor: nodeData.nodeStyle?.backgroundColor,
15833
+ borderColor: nodeData.nodeStyle?.borderColor ?? "#9ca3af",
15834
+ opacity: nodeData.nodeStyle?.opacity,
16056
15835
  boxShadow: selected2 ? "0 0 0 2px rgba(168, 85, 247, 0.5)" : void 0
16057
15836
  },
16058
15837
  children: [
@@ -16127,7 +15906,6 @@ function ParallelGroupComponent({ data }) {
16127
15906
  );
16128
15907
  }
16129
15908
  function DiamondNodeComponent({ data, selected: selected2 }) {
16130
- var _a2, _b, _c;
16131
15909
  const nodeData = data;
16132
15910
  const size = 160;
16133
15911
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -16149,9 +15927,9 @@ function DiamondNodeComponent({ data, selected: selected2 }) {
16149
15927
  borderWidth: 2,
16150
15928
  borderStyle: "solid",
16151
15929
  borderRadius: 4,
16152
- backgroundColor: (_a2 = nodeData.nodeStyle) == null ? void 0 : _a2.backgroundColor,
16153
- borderColor: ((_b = nodeData.nodeStyle) == null ? void 0 : _b.borderColor) ?? "#ef4444",
16154
- opacity: (_c = nodeData.nodeStyle) == null ? void 0 : _c.opacity,
15930
+ backgroundColor: nodeData.nodeStyle?.backgroundColor,
15931
+ borderColor: nodeData.nodeStyle?.borderColor ?? "#ef4444",
15932
+ opacity: nodeData.nodeStyle?.opacity,
16155
15933
  boxShadow: selected2 ? "0 0 0 2px rgba(239, 68, 68, 0.5)" : void 0
16156
15934
  }
16157
15935
  }
@@ -16342,7 +16120,6 @@ function getNodeIcon(nodeKind, label) {
16342
16120
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Zap, { className: "h-3.5 w-3.5 text-green-900" });
16343
16121
  }
16344
16122
  function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16345
- var _a2, _b, _c, _d, _e;
16346
16123
  const nodes = workflow.nodes.map((node) => ({ ...node }));
16347
16124
  const groupNodes = [];
16348
16125
  const additionalEdges = [];
@@ -16350,7 +16127,7 @@ function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16350
16127
  const loopNodes = /* @__PURE__ */ new Map();
16351
16128
  const conditionalGroups = /* @__PURE__ */ new Map();
16352
16129
  for (const node of nodes) {
16353
- if ((_a2 = node.metadata) == null ? void 0 : _a2.parallelGroupId) {
16130
+ if (node.metadata?.parallelGroupId) {
16354
16131
  const group = parallelGroups.get(node.metadata.parallelGroupId) || {
16355
16132
  nodes: [],
16356
16133
  method: node.metadata.parallelMethod
@@ -16358,12 +16135,12 @@ function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16358
16135
  group.nodes.push(node);
16359
16136
  parallelGroups.set(node.metadata.parallelGroupId, group);
16360
16137
  }
16361
- if ((_b = node.metadata) == null ? void 0 : _b.loopId) {
16138
+ if (node.metadata?.loopId) {
16362
16139
  const group = loopNodes.get(node.metadata.loopId) || [];
16363
16140
  group.push(node);
16364
16141
  loopNodes.set(node.metadata.loopId, group);
16365
16142
  }
16366
- if ((_c = node.metadata) == null ? void 0 : _c.conditionalId) {
16143
+ if (node.metadata?.conditionalId) {
16367
16144
  const groups = conditionalGroups.get(node.metadata.conditionalId) || {
16368
16145
  thenBranch: [],
16369
16146
  elseBranch: []
@@ -16420,8 +16197,8 @@ function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16420
16197
  const elseNodes = branches.elseBranch;
16421
16198
  if (thenNodes.length > 0 && elseNodes.length > 0) {
16422
16199
  const baseY = Math.min(
16423
- ((_d = thenNodes[0]) == null ? void 0 : _d.position.y) || 0,
16424
- ((_e = elseNodes[0]) == null ? void 0 : _e.position.y) || 0
16200
+ thenNodes[0]?.position.y || 0,
16201
+ elseNodes[0]?.position.y || 0
16425
16202
  );
16426
16203
  thenNodes.forEach((node, idx) => {
16427
16204
  node.position = {
@@ -16439,10 +16216,7 @@ function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16439
16216
  }
16440
16217
  for (const [, loopNodeList] of loopNodes) {
16441
16218
  if (loopNodeList.length > 0) {
16442
- const isAwaitLoop = loopNodeList.some((n) => {
16443
- var _a3;
16444
- return (_a3 = n.metadata) == null ? void 0 : _a3.loopIsAwait;
16445
- });
16219
+ const isAwaitLoop = loopNodeList.some((n) => n.metadata?.loopIsAwait);
16446
16220
  for (const loopNode of loopNodeList) {
16447
16221
  additionalEdges.push({
16448
16222
  id: `self_loop_${loopNode.id}`,
@@ -16459,10 +16233,9 @@ function calculateEnhancedLayout(workflow, layoutConfig = LAYOUT) {
16459
16233
  return { nodes, groupNodes, additionalEdges };
16460
16234
  }
16461
16235
  function consolidateEdges(edges, nodes) {
16462
- var _a2;
16463
16236
  const nodeToGroup = /* @__PURE__ */ new Map();
16464
16237
  for (const node of nodes) {
16465
- if ((_a2 = node.metadata) == null ? void 0 : _a2.parallelGroupId) {
16238
+ if (node.metadata?.parallelGroupId) {
16466
16239
  nodeToGroup.set(node.id, node.metadata.parallelGroupId);
16467
16240
  }
16468
16241
  }
@@ -16504,7 +16277,6 @@ function consolidateEdges(edges, nodes) {
16504
16277
  return consolidatedEdges;
16505
16278
  }
16506
16279
  function convertToReactFlowNodes(workflow) {
16507
- var _a2;
16508
16280
  const { nodes, groupNodes } = calculateEnhancedLayout(workflow);
16509
16281
  const nodeToParent = /* @__PURE__ */ new Map();
16510
16282
  const groupPositions = /* @__PURE__ */ new Map();
@@ -16514,7 +16286,7 @@ function convertToReactFlowNodes(workflow) {
16514
16286
  }
16515
16287
  }
16516
16288
  for (const node of nodes) {
16517
- const parallelGroupId = ((_a2 = node.metadata) == null ? void 0 : _a2.parallelGroupId) ? `group_${node.metadata.parallelGroupId}` : null;
16289
+ const parallelGroupId = node.metadata?.parallelGroupId ? `group_${node.metadata.parallelGroupId}` : null;
16518
16290
  if (parallelGroupId && groupPositions.has(parallelGroupId)) {
16519
16291
  nodeToParent.set(node.id, parallelGroupId);
16520
16292
  }
@@ -16539,8 +16311,8 @@ function convertToReactFlowNodes(workflow) {
16539
16311
  nodes.forEach((node) => {
16540
16312
  const styles = getNodeStyle(node.data.nodeKind);
16541
16313
  const metadata = node.metadata;
16542
- const isLoopNode = !!(metadata == null ? void 0 : metadata.loopId);
16543
- const isAwaitLoop = !!(metadata == null ? void 0 : metadata.loopIsAwait);
16314
+ const isLoopNode = !!metadata?.loopId;
16315
+ const isAwaitLoop = !!metadata?.loopIsAwait;
16544
16316
  const isConditionalNode = node.data.nodeKind === "conditional";
16545
16317
  let nodeType = isConditionalNode ? "diamondNode" : isLoopNode ? "loopNode" : "default";
16546
16318
  if (node.type === "workflowStart") {
@@ -16813,8 +16585,8 @@ function WorkflowGraphViewer({ workflow }) {
16813
16585
  }
16814
16586
  ) });
16815
16587
  }
16816
- var __defProp2 = Object.defineProperty;
16817
- var __name = (target, value) => __defProp2(target, "name", { value, configurable: true });
16588
+ var __defProp = Object.defineProperty;
16589
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
16818
16590
  var DIALOG_NAME = "Dialog";
16819
16591
  var [createDialogContext, createDialogScope] = createContextScope(DIALOG_NAME);
16820
16592
  var [DialogProvider, useDialogContext] = createDialogContext(DIALOG_NAME);
@@ -16963,9 +16735,8 @@ var DialogContentModal = /* @__PURE__ */ reactExports.forwardRef(
16963
16735
  trapFocus: context.open,
16964
16736
  disableOutsidePointerEvents: context.open,
16965
16737
  onCloseAutoFocus: composeEventHandlers(props.onCloseAutoFocus, (event) => {
16966
- var _a2;
16967
16738
  event.preventDefault();
16968
- (_a2 = context.triggerRef.current) == null ? void 0 : _a2.focus();
16739
+ context.triggerRef.current?.focus();
16969
16740
  }),
16970
16741
  onPointerDownOutside: composeEventHandlers(props.onPointerDownOutside, (event) => {
16971
16742
  const originalEvent = event.detail.originalEvent;
@@ -16995,18 +16766,16 @@ var DialogContentNonModal = /* @__PURE__ */ reactExports.forwardRef(
16995
16766
  trapFocus: false,
16996
16767
  disableOutsidePointerEvents: false,
16997
16768
  onCloseAutoFocus: (event) => {
16998
- var _a2, _b;
16999
- (_a2 = props.onCloseAutoFocus) == null ? void 0 : _a2.call(props, event);
16769
+ props.onCloseAutoFocus?.(event);
17000
16770
  if (!event.defaultPrevented) {
17001
- if (!hasInteractedOutsideRef.current) (_b = context.triggerRef.current) == null ? void 0 : _b.focus();
16771
+ if (!hasInteractedOutsideRef.current) context.triggerRef.current?.focus();
17002
16772
  event.preventDefault();
17003
16773
  }
17004
16774
  hasInteractedOutsideRef.current = false;
17005
16775
  hasPointerDownOutsideRef.current = false;
17006
16776
  },
17007
16777
  onInteractOutside: (event) => {
17008
- var _a2, _b;
17009
- (_a2 = props.onInteractOutside) == null ? void 0 : _a2.call(props, event);
16778
+ props.onInteractOutside?.(event);
17010
16779
  if (!event.defaultPrevented) {
17011
16780
  hasInteractedOutsideRef.current = true;
17012
16781
  if (event.detail.originalEvent.type === "pointerdown") {
@@ -17014,7 +16783,7 @@ var DialogContentNonModal = /* @__PURE__ */ reactExports.forwardRef(
17014
16783
  }
17015
16784
  }
17016
16785
  const target = event.target;
17017
- const targetIsTrigger = (_b = context.triggerRef.current) == null ? void 0 : _b.contains(target);
16786
+ const targetIsTrigger = context.triggerRef.current?.contains(target);
17018
16787
  if (targetIsTrigger) event.preventDefault();
17019
16788
  if (event.detail.originalEvent.type === "focusin" && hasPointerDownOutsideRef.current) {
17020
16789
  event.preventDefault();
@@ -17128,7 +16897,7 @@ function useOptimisticSearchParams() {
17128
16897
  const [optimisticParams, setOptimisticParams] = reactExports.useOptimistic(searchParams);
17129
16898
  const [, startTransition] = reactExports.useTransition();
17130
16899
  const updateSearchParams = reactExports.useCallback(
17131
- (updates, options) => {
16900
+ (updates, options2) => {
17132
16901
  const next = new URLSearchParams(optimisticParams);
17133
16902
  for (const [key, value] of Object.entries(updates)) {
17134
16903
  if (value === null) {
@@ -17142,7 +16911,7 @@ function useOptimisticSearchParams() {
17142
16911
  setOptimisticParams(next);
17143
16912
  await navigate(
17144
16913
  { search: search ? `?${search}` : "" },
17145
- { preventScrollReset: true, ...options }
16914
+ { preventScrollReset: true, ...options2 }
17146
16915
  );
17147
16916
  });
17148
16917
  },