@superblocksteam/library 2.0.59-next.2 → 2.0.59-next.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.
@@ -1,7 +1,7 @@
1
1
  import { t as getTracer } from "./utils-AzBGeVXo.js";
2
- import { getQueryParams, pathStringToArray, toMobXPatch } from "@superblocksteam/library-shared";
2
+ import { NO_SELECT_ATTRIBUTE, SELECTOR_ID_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, URL_PARAMS, getQueryParams, pathStringToArray, toMobXPatch } from "@superblocksteam/library-shared";
3
3
  import * as React$1 from "react";
4
- import React, { createContext, isValidElement, useCallback, useContext, useSyncExternalStore } from "react";
4
+ import React, { Component, createContext, isValidElement, useCallback, useContext, useEffect, useMemo, useRef, useSyncExternalStore } from "react";
5
5
  import { action, entries, isComputedProp, isObservableArray, isObservableMap, isObservableObject, makeAutoObservable, makeObservable, observable, observe, reaction, toJS, values } from "mobx";
6
6
  import { matchRoutes } from "react-router";
7
7
  import { pick, throttle } from "lodash";
@@ -9,11 +9,13 @@ import { ApiResponseType, OrchestratorViewMode, SUPERBLOCKS_AUTHORIZATION_HEADER
9
9
  import { NotificationPosition } from "@superblocksteam/library-shared/types";
10
10
  import isString from "lodash/isString";
11
11
  import { toast } from "sonner";
12
- import styled from "styled-components";
12
+ import styled, { keyframes } from "styled-components";
13
13
  import { jsx, jsxs } from "react/jsx-runtime";
14
14
  import { ROOT_CONTEXT, context, propagation, trace } from "@opentelemetry/api";
15
15
  import diff from "microdiff";
16
16
  import { InputType, PropsCategory } from "@superblocksteam/library-shared/props";
17
+ import { Observer } from "mobx-react-lite";
18
+ import polyfill from "@oddbird/css-anchor-positioning/fn";
17
19
 
18
20
  //#region src/lib/internal-details/is-edit-mode.ts
19
21
  const getIsEditMode = () => {
@@ -398,11 +400,13 @@ var SuperblocksEditorBridge = class SuperblocksEditorBridge {
398
400
  editStore.ai.addTargetedSelector(selectorId);
399
401
  return;
400
402
  }
403
+ const label = editStore.runtimeTrackingStore.getComponent(selectorId)?.displayName;
401
404
  this.sendImmediate({
402
405
  type: "ai-updates",
403
406
  payload: {
404
407
  type: "add-component-to-context",
405
- component: sourceId
408
+ component: sourceId,
409
+ label
406
410
  }
407
411
  });
408
412
  }
@@ -950,9 +954,11 @@ function useSuperblocksUser() {
950
954
  return useSyncExternalStore((onStoreChange) => {
951
955
  return reaction(() => context$2.user, onStoreChange);
952
956
  }, () => {
953
- return context$2.user;
957
+ if (!context$2.user) return;
958
+ return toJS(context$2.user);
954
959
  }, () => {
955
- return context$2.user;
960
+ if (!context$2.user) return;
961
+ return toJS(context$2.user);
956
962
  });
957
963
  }
958
964
  function useSuperblocksGroups() {
@@ -960,9 +966,11 @@ function useSuperblocksGroups() {
960
966
  return useSyncExternalStore((onStoreChange) => {
961
967
  return reaction(() => context$2.groups, onStoreChange);
962
968
  }, () => {
963
- return context$2.groups;
969
+ if (!context$2.groups) return;
970
+ return toJS(context$2.groups);
964
971
  }, () => {
965
- return context$2.groups;
972
+ if (!context$2.groups) return;
973
+ return toJS(context$2.groups);
966
974
  });
967
975
  }
968
976
  function useSuperblocksProfiles() {
@@ -971,15 +979,22 @@ function useSuperblocksProfiles() {
971
979
  profiles: useSyncExternalStore((onStoreChange) => {
972
980
  return reaction(() => context$2.profiles, onStoreChange);
973
981
  }, () => {
974
- return context$2.profiles;
982
+ if (!context$2.profiles) return;
983
+ return toJS(context$2.profiles);
975
984
  }, () => {
976
- return context$2.profiles;
985
+ if (!context$2.profiles) return;
986
+ return toJS(context$2.profiles);
977
987
  }),
978
988
  setProfile: useCallback((profileName) => {
979
989
  context$2.setProfile(profileName);
980
990
  }, [context$2])
981
991
  };
982
992
  }
993
+ function getAppMode() {
994
+ const appMode = new URL(window.location.href).searchParams.get(URL_PARAMS.appMode);
995
+ if (!appMode) console.warn("No app mode found in URL");
996
+ return appMode;
997
+ }
983
998
 
984
999
  //#endregion
985
1000
  //#region src/lib/internal-details/lib/resolve-id-singleton.ts
@@ -1026,6 +1041,69 @@ function rejectById(id, payload) {
1026
1041
  }
1027
1042
  }
1028
1043
 
1044
+ //#endregion
1045
+ //#region src/lib/internal-details/lib/features/api-hmr-tracker.ts
1046
+ var ApiHmrTracker = class ApiHmrTracker {
1047
+ static CLEAR_REF_DELAY = 18e4;
1048
+ reloadCount = 0;
1049
+ propagatedReloadCount = 0;
1050
+ seenHashes = /* @__PURE__ */ new Set();
1051
+ lastResultByHash = {};
1052
+ clearRefAfterDelay(value) {
1053
+ clearTimeout(value.clearTimer);
1054
+ value.clearTimer = setTimeout(() => {
1055
+ value.clearTimer = void 0;
1056
+ delete value.hardRef;
1057
+ }, ApiHmrTracker.CLEAR_REF_DELAY);
1058
+ }
1059
+ getAndRefreshResult(callHash) {
1060
+ const lastResult = this.lastResultByHash[callHash];
1061
+ if (!lastResult) return null;
1062
+ const result = lastResult.hardRef ?? lastResult.weakRef.deref();
1063
+ if (result) {
1064
+ this.clearRefAfterDelay(lastResult);
1065
+ return result;
1066
+ }
1067
+ return null;
1068
+ }
1069
+ shouldSkipRun(callHash) {
1070
+ if (!this.seenHashes.has(callHash)) {
1071
+ this.seenHashes.add(callHash);
1072
+ return false;
1073
+ }
1074
+ if (!this.getAndRefreshResult(callHash)) return false;
1075
+ return this.propagatedReloadCount !== this.reloadCount;
1076
+ }
1077
+ getCachedResult(callHash) {
1078
+ return this.getAndRefreshResult(callHash);
1079
+ }
1080
+ setResult(callHash, result) {
1081
+ this.lastResultByHash[callHash] = {
1082
+ weakRef: new WeakRef(result),
1083
+ hardRef: result
1084
+ };
1085
+ this.clearRefAfterDelay(this.lastResultByHash[callHash]);
1086
+ }
1087
+ incReloadCount() {
1088
+ this.reloadCount++;
1089
+ }
1090
+ mountLikeTimer = null;
1091
+ reportJSXActivity() {
1092
+ const reloadCount = this.reloadCount;
1093
+ if (this.mountLikeTimer) clearTimeout(this.mountLikeTimer);
1094
+ this.mountLikeTimer = setTimeout(() => {
1095
+ requestIdleCallback(() => {
1096
+ this.propagatedReloadCount = Math.max(this.propagatedReloadCount, reloadCount);
1097
+ });
1098
+ }, 0);
1099
+ }
1100
+ };
1101
+ const tracker = new ApiHmrTracker();
1102
+ if (import.meta.hot) import.meta.hot.on("vite:beforeUpdate", () => {
1103
+ tracker.incReloadCount();
1104
+ });
1105
+ var api_hmr_tracker_default = tracker;
1106
+
1029
1107
  //#endregion
1030
1108
  //#region src/lib/tracing/context-utils.ts
1031
1109
  function getContextFromTraceHeaders(traceHeaders) {
@@ -1400,7 +1478,7 @@ var ApiManager = class {
1400
1478
  error: void 0
1401
1479
  };
1402
1480
  }
1403
- const result = await this.executeApiInternal({
1481
+ const result = await this.executeApi({
1404
1482
  apiId: context$2.apiId,
1405
1483
  apiName: context$2.apiName,
1406
1484
  path: context$2.path,
@@ -1414,12 +1492,24 @@ var ApiManager = class {
1414
1492
  error: result.error
1415
1493
  };
1416
1494
  }
1417
- @action async runApiByPath({ path, inputs, callId, callback, isTestRun }) {
1495
+ @action async runApiByPath({ path, inputs, callId, callback, isTestRun, injectedCallerId }) {
1496
+ console.log("[api-store.runApiByPath] Called with:", {
1497
+ path,
1498
+ inputs,
1499
+ callId,
1500
+ isTestRun,
1501
+ hasCallback: !!callback
1502
+ });
1418
1503
  await this.awaitInitApiIfNeeded();
1419
1504
  const apiName = path.match(/^\/apis\/([^/]+)\/api\.yaml$/)?.[1];
1420
- if (!apiName) throw new Error(`Invalid path: ${path}`);
1505
+ if (!apiName) {
1506
+ console.error("[api-store.runApiByPath] Invalid path:", path);
1507
+ throw new Error(`Invalid path: ${path}`);
1508
+ }
1509
+ console.log("[api-store.runApiByPath] Extracted apiName:", apiName);
1421
1510
  editorBridge.setApiStarted(apiName);
1422
- const result = await this.executeApiInternal({
1511
+ console.log("[api-store.runApiByPath] Executing API internally...");
1512
+ const result = await this.executeApi({
1423
1513
  apiId: apiName,
1424
1514
  apiName,
1425
1515
  path,
@@ -1427,14 +1517,38 @@ var ApiManager = class {
1427
1517
  options: inputs ?? {},
1428
1518
  callId,
1429
1519
  isTestRun,
1430
- callback
1520
+ callback,
1521
+ injectedCallerId
1431
1522
  });
1523
+ console.log("[api-store.runApiByPath] Execution complete, calling setApiResponse for:", apiName);
1432
1524
  editorBridge.setApiResponse(apiName, result.parsedResult);
1433
1525
  return {
1434
1526
  data: result.data,
1435
1527
  error: result.error
1436
1528
  };
1437
1529
  }
1530
+ getHMRCallHash(params) {
1531
+ return `${params.injectedCallerId ?? ""}-${params.apiId}`;
1532
+ }
1533
+ getCachedHMRExecution(params) {
1534
+ if (params.callId) return null;
1535
+ const hmrCallHash = this.getHMRCallHash(params);
1536
+ if (api_hmr_tracker_default.shouldSkipRun(hmrCallHash)) {
1537
+ const result = api_hmr_tracker_default.getCachedResult(hmrCallHash);
1538
+ if (result) return result;
1539
+ }
1540
+ return null;
1541
+ }
1542
+ async executeApi(params) {
1543
+ if (isEditMode()) {
1544
+ const cachedResult = this.getCachedHMRExecution(params);
1545
+ if (cachedResult) return cachedResult;
1546
+ const result = await this.executeApiInternal(params);
1547
+ api_hmr_tracker_default.setResult(this.getHMRCallHash(params), result);
1548
+ return result;
1549
+ }
1550
+ return this.executeApiInternal(params);
1551
+ }
1438
1552
  async executeApiInternal({ apiId, apiName, path, inputs, options, callId: providedCallId, callback, isTestRun }) {
1439
1553
  const executionStartTime = Date.now();
1440
1554
  const callId = providedCallId ?? `${apiId}-${executionStartTime}-${Math.random().toString(36).substr(2, 9)}`;
@@ -3054,6 +3168,180 @@ function FixWithClarkButton({ identifier, error, onClick }) {
3054
3168
  });
3055
3169
  }
3056
3170
 
3171
+ //#endregion
3172
+ //#region src/lib/internal-details/css-constants.ts
3173
+ const CSS_CLASSES = {
3174
+ SUSPENSE_FALLBACK: "sb-suspense-fallback",
3175
+ ANCHOR_NAME: "sb-anchor-name"
3176
+ };
3177
+
3178
+ //#endregion
3179
+ //#region src/lib/internal-details/lib/suspense/suspense-fallback.tsx
3180
+ const shimmerAnimation = keyframes`
3181
+ 0% {
3182
+ background-position: -200px 0;
3183
+ }
3184
+ 100% {
3185
+ background-position: calc(200px + 100%) 0;
3186
+ }
3187
+ `;
3188
+ const ShimmerDiv = styled.div`
3189
+ min-height: 12px;
3190
+ min-width: 12px;
3191
+ background-color: ${(props) => props.$backgroundColor};
3192
+ border-radius: ${(props) => props.$borderRadius};
3193
+ position: relative;
3194
+ overflow: hidden;
3195
+ background: linear-gradient(
3196
+ 90deg,
3197
+ ${(props) => props.$backgroundColor} 25%,
3198
+ ${(props) => props.$shimmerHighlight} 50%,
3199
+ ${(props) => props.$backgroundColor} 75%
3200
+ );
3201
+ background-size: max(100%, 200px) 100%;
3202
+ animation: ${shimmerAnimation} 5s infinite linear;
3203
+ `;
3204
+ /**
3205
+ * Default fallback component displayed while components are suspended.
3206
+ */
3207
+ function SuspenseFallback({ style, className, noBorderRadius }) {
3208
+ const backgroundColor = "#f8f9fa";
3209
+ const shimmerHighlight = "#ffffff";
3210
+ const borderRadius = noBorderRadius ? "0px" : "4px";
3211
+ const classes = useMemo(() => [CSS_CLASSES.ANCHOR_NAME, className].filter(Boolean).join(" "), [className]);
3212
+ return /* @__PURE__ */ jsx(ShimmerDiv, {
3213
+ $backgroundColor: backgroundColor,
3214
+ $shimmerHighlight: shimmerHighlight,
3215
+ $borderRadius: borderRadius,
3216
+ style: style?.(),
3217
+ className: classes,
3218
+ "data-test": "suspense-fallback"
3219
+ });
3220
+ }
3221
+
3222
+ //#endregion
3223
+ //#region src/lib/user-facing/component-base/error-boundary.tsx
3224
+ const ErrorBoundaryContainer = styled.div`
3225
+ background: white;
3226
+ padding: 10px;
3227
+ display: flex;
3228
+ flex-direction: column;
3229
+ gap: 8px;
3230
+ border: 1px solid ${colors.GREY_100};
3231
+ border-left: 3px solid ${colors.RED_500};
3232
+ border-radius: 4px;
3233
+ width: 100%;
3234
+ color: ${colors.GREY_700};
3235
+ `;
3236
+ const ErrorDetailsContainer = styled.div`
3237
+ display: flex;
3238
+ flex-direction: column;
3239
+ gap: 8px;
3240
+ `;
3241
+ const ErrorActionsContainer = styled.div`
3242
+ display: flex;
3243
+ justify-content: flex-end;
3244
+ align-items: center;
3245
+ gap: 8px;
3246
+ `;
3247
+ var ErrorBoundary = class extends Component {
3248
+ state = {
3249
+ id: generateId(),
3250
+ hasError: false
3251
+ };
3252
+ disposeAutoReset;
3253
+ static getDerivedStateFromError(e) {
3254
+ const error = e instanceof Error ? e : new Error(typeof e === "object" && e !== null ? JSON.stringify(e) : String(e));
3255
+ return {
3256
+ id: generateId(),
3257
+ hasError: true,
3258
+ error
3259
+ };
3260
+ }
3261
+ componentDidCatch(error, errorInfo) {
3262
+ console.error("Uncaught error:", error, errorInfo);
3263
+ if (isEditMode()) root_store_default.editStore?.ai.handleRuntimeError({
3264
+ id: this.state.id,
3265
+ error: String(error),
3266
+ errorInfo,
3267
+ identifier: this.props.identifier
3268
+ });
3269
+ }
3270
+ reset = () => {
3271
+ if (isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
3272
+ this.setState({
3273
+ hasError: false,
3274
+ error: void 0
3275
+ });
3276
+ };
3277
+ componentWillUnmount() {
3278
+ if (this.state.hasError && isEditMode()) root_store_default.editStore?.ai.clearRuntimeError(this.state.id);
3279
+ this.disposeAutoReset?.();
3280
+ }
3281
+ handleFixWithClarkInitiated = () => {
3282
+ const ai = root_store_default.editStore?.ai;
3283
+ if (!ai) return;
3284
+ this.disposeAutoReset?.();
3285
+ this.disposeAutoReset = void 0;
3286
+ let sawStart = ai.getIsEditing();
3287
+ this.disposeAutoReset = reaction(() => ai.getIsEditing(), (isEditing) => {
3288
+ if (!sawStart && isEditing) sawStart = true;
3289
+ if (sawStart && !isEditing) {
3290
+ this.reset();
3291
+ this.disposeAutoReset?.();
3292
+ this.disposeAutoReset = void 0;
3293
+ }
3294
+ }, {
3295
+ fireImmediately: true,
3296
+ name: "error-boundary-ai-auto-reset"
3297
+ });
3298
+ };
3299
+ handleFixWithAi() {
3300
+ const { identifier } = this.props;
3301
+ if (identifier) editorBridge.addComponentToAiContext(identifier.sourceId, identifier.selectorId);
3302
+ let prompt = `Fix this error: `;
3303
+ if (this.state.error?.stack) {
3304
+ const lines = this.state.error.stack.split("\n");
3305
+ const nodeModulesIndex = lines.findIndex((line) => line.includes("node_modules"));
3306
+ const relevantLines = nodeModulesIndex > -1 ? lines.slice(0, nodeModulesIndex) : lines;
3307
+ prompt += relevantLines.slice(0, 5).join("\n");
3308
+ } else prompt += this.state.error?.toString();
3309
+ editorBridge.aiGenerate(prompt);
3310
+ }
3311
+ render() {
3312
+ if (this.state.hasError) return /* @__PURE__ */ jsx(Observer, { children: () => {
3313
+ if (root_store_default.editStore?.ai.getIsEditing() ?? false) return /* @__PURE__ */ jsx(SuspenseFallback, {});
3314
+ return /* @__PURE__ */ jsxs(ErrorBoundaryContainer, { children: [/* @__PURE__ */ jsxs(ErrorDetailsContainer, { children: [/* @__PURE__ */ jsx("h3", { children: this.props.header || "Something went wrong." }), /* @__PURE__ */ jsxs("details", {
3315
+ style: { fontSize: "0.8em" },
3316
+ children: [/* @__PURE__ */ jsx("summary", {
3317
+ style: { paddingLeft: "0.25rem" },
3318
+ children: "Error details"
3319
+ }), /* @__PURE__ */ jsx("div", {
3320
+ style: {
3321
+ marginTop: "0.5rem",
3322
+ maxWidth: "100%",
3323
+ overflowX: "auto",
3324
+ scrollbarWidth: "thin"
3325
+ },
3326
+ children: /* @__PURE__ */ jsx("pre", {
3327
+ style: { color: "gray" },
3328
+ children: /* @__PURE__ */ jsx("code", { children: this.state.error?.stack ? this.state.error.stack : this.state.error?.toString() })
3329
+ })
3330
+ })]
3331
+ })] }), /* @__PURE__ */ jsxs(ErrorActionsContainer, { children: [isEditMode() && /* @__PURE__ */ jsx(FixWithClarkButton, {
3332
+ onClick: this.handleFixWithClarkInitiated,
3333
+ error: this.state.error,
3334
+ identifier: this.props.identifier
3335
+ }), /* @__PURE__ */ jsx(SecondaryButton, {
3336
+ onClick: this.reset,
3337
+ children: "Try again"
3338
+ })] })] });
3339
+ } });
3340
+ return this.props.children;
3341
+ }
3342
+ };
3343
+ var error_boundary_default = ErrorBoundary;
3344
+
3057
3345
  //#endregion
3058
3346
  //#region src/lib/utils/widget-wrapper-naming.ts
3059
3347
  const getWidgetAnchorName = (selectorId) => {
@@ -3064,5 +3352,110 @@ const getWidgetRectAnchorName = (selectorId) => {
3064
3352
  };
3065
3353
 
3066
3354
  //#endregion
3067
- export { useSuperblocksUser as A, generateId as C, useSuperblocksContext as D, SuperblocksContextProvider as E, iframeMessageHandler as F, isEmbeddedBySuperblocksFirstParty as I, isEditMode as L, colors as M, editorBridge as N, useSuperblocksGroups as O, getEditStore as P, startEditorSync as S, resolveById as T, createManagedPropsList as _, ActionsContainer as a, Section as b, ErrorDetails as c, ErrorStack as d, ErrorSummary as f, root_store_default as g, StyledClarkIcon as h, ai_stars_default as i, sendNotification as j, useSuperblocksProfiles as k, ErrorIconContainer as l, SecondaryButton as m, getWidgetRectAnchorName as n, ErrorContainer as o, ErrorTitle as p, FixWithClarkButton as r, ErrorContent as s, getWidgetAnchorName as t, ErrorMessage as u, Prop as v, rejectById as w, createPropertiesPanelDefinition as x, PropsCategory as y };
3068
- //# sourceMappingURL=widget-wrapper-naming-DxFT8zmk.js.map
3355
+ //#region src/edit-mode/edit-wrapper.tsx
3356
+ if (typeof window !== "undefined" && typeof document.documentElement !== "undefined" && !("anchorName" in document.documentElement.style)) polyfill();
3357
+ const createAnchorNameStyle = (props) => {
3358
+ return { "--anchor-name": getWidgetAnchorName(props.selectorId) };
3359
+ };
3360
+
3361
+ //#endregion
3362
+ //#region src/edit-mode/instance-tracker.ts
3363
+ /**
3364
+ * Tracks and recycles instance numbers for each sourceId to generate stable, unique selector IDs.
3365
+ * When components unmount, their instance numbers are released and can be reused.
3366
+ */
3367
+ var InstanceTracker = class {
3368
+ sourceIdToUsedInstances = /* @__PURE__ */ new Map();
3369
+ getNextAvailableInstance(sourceId) {
3370
+ const usedInstances = this.sourceIdToUsedInstances.get(sourceId) ?? /* @__PURE__ */ new Set();
3371
+ let instance = 0;
3372
+ while (usedInstances.has(instance)) instance++;
3373
+ usedInstances.add(instance);
3374
+ this.sourceIdToUsedInstances.set(sourceId, usedInstances);
3375
+ return instance;
3376
+ }
3377
+ releaseInstance(sourceId, instance) {
3378
+ const usedInstances = this.sourceIdToUsedInstances.get(sourceId);
3379
+ if (usedInstances) {
3380
+ usedInstances.delete(instance);
3381
+ if (usedInstances.size === 0) this.sourceIdToUsedInstances.delete(sourceId);
3382
+ }
3383
+ }
3384
+ };
3385
+ const instanceTracker = new InstanceTracker();
3386
+
3387
+ //#endregion
3388
+ //#region src/edit-mode/jsx-wrapper.tsx
3389
+ const JSXContext = React.createContext({
3390
+ selectorId: "S-<unknown>",
3391
+ sourceId: "SB-<unknown>"
3392
+ });
3393
+ const makeWrappedComponent = (type) => {
3394
+ const isTag = typeof type === "string";
3395
+ const isRegisteredSbComponent = root_store_default.componentRegistry.hasComponent(type);
3396
+ const Component$1 = React.forwardRef((props, ref) => {
3397
+ const { selectorId: parentSelectorId } = useJSXContext();
3398
+ const sourceId = props[SOURCE_ID_ATTRIBUTE];
3399
+ const noSelect = props[NO_SELECT_ATTRIBUTE];
3400
+ const instanceNumberRef = useRef();
3401
+ const selectorId = useRef("S-<unknown>");
3402
+ if (selectorId.current === "S-<unknown>") {
3403
+ instanceNumberRef.current = instanceTracker.getNextAvailableInstance(sourceId);
3404
+ selectorId.current = `S-x-${sourceId}-${instanceNumberRef.current}`;
3405
+ }
3406
+ useEffect(() => {
3407
+ root_store_default.editStore?.runtimeTrackingStore.registerComponent(selectorId.current, {
3408
+ sourceId,
3409
+ type,
3410
+ parentSelectorId,
3411
+ isSbComponent: isRegisteredSbComponent,
3412
+ isHtmlElement: isTag,
3413
+ noSelect
3414
+ });
3415
+ return () => {
3416
+ root_store_default.editStore?.runtimeTrackingStore.unregisterComponent(selectorId.current);
3417
+ if (instanceNumberRef.current !== void 0) instanceTracker.releaseInstance(sourceId, instanceNumberRef.current);
3418
+ };
3419
+ }, []);
3420
+ useEffect(() => {
3421
+ root_store_default.editStore?.runtimeTrackingStore.updatePropsForComponent(selectorId.current, props);
3422
+ }, [props]);
3423
+ const jsxContext = useMemo(() => ({
3424
+ selectorId: selectorId.current,
3425
+ sourceId
3426
+ }), [sourceId]);
3427
+ const selectorProps = { [SELECTOR_ID_ATTRIBUTE]: selectorId.current };
3428
+ if (parentSelectorId) selectorProps["data-sb-parent-selector-id"] = parentSelectorId;
3429
+ const style = useMemo(() => {
3430
+ return {
3431
+ ...props.style,
3432
+ ...createAnchorNameStyle({ selectorId: selectorId.current })
3433
+ };
3434
+ }, [props.style]);
3435
+ const element = React.createElement(type, {
3436
+ ref,
3437
+ ...props,
3438
+ ...selectorProps,
3439
+ className: ["sb-anchor-name", props.className].filter(Boolean).join(" "),
3440
+ style
3441
+ });
3442
+ if (!root_store_default.editStore?.isInitialized) return element;
3443
+ return /* @__PURE__ */ jsx(JSXContext.Provider, {
3444
+ value: jsxContext,
3445
+ children: /* @__PURE__ */ jsx(error_boundary_default, { children: element })
3446
+ });
3447
+ });
3448
+ try {
3449
+ Component$1.displayName = typeof type === "string" ? type : type.displayName || type.name || "Component";
3450
+ } catch (e) {
3451
+ console.error("Error setting displayName", e);
3452
+ }
3453
+ return Component$1;
3454
+ };
3455
+ const useJSXContext = () => {
3456
+ return React.useContext(JSXContext);
3457
+ };
3458
+
3459
+ //#endregion
3460
+ export { SuperblocksContextProvider as A, iframeMessageHandler as B, startEditorSync as C, api_hmr_tracker_default as D, getContextFromTraceHeaders as E, useSuperblocksUser as F, isEditMode as H, sendNotification as I, colors as L, useSuperblocksContext as M, useSuperblocksGroups as N, rejectById as O, useSuperblocksProfiles as P, editorBridge as R, createPropertiesPanelDefinition as S, createIframeSpan as T, isEmbeddedBySuperblocksFirstParty as V, root_store_default as _, FixWithClarkButton as a, PropsCategory as b, ErrorContent as c, ErrorMessage as d, ErrorStack as f, StyledClarkIcon as g, SecondaryButton as h, getWidgetRectAnchorName as i, getAppMode as j, resolveById as k, ErrorDetails as l, ErrorTitle as m, useJSXContext as n, ActionsContainer as o, ErrorSummary as p, getWidgetAnchorName as r, ErrorContainer as s, makeWrappedComponent as t, ErrorIconContainer as u, createManagedPropsList as v, generateId as w, Section as x, Prop as y, getEditStore as z };
3461
+ //# sourceMappingURL=jsx-wrapper-Ddb528TO.js.map