forgeframe 0.0.6 → 0.0.10

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,9 +1,9 @@
1
- const m = {
1
+ const f = {
2
2
  /** Render component in an iframe */
3
3
  IFRAME: "iframe",
4
4
  /** Render component in a popup window */
5
5
  POPUP: "popup"
6
- }, p = {
6
+ }, g = {
7
7
  /** Emitted when rendering starts */
8
8
  RENDER: "render",
9
9
  /** Emitted when component is fully rendered and initialized */
@@ -26,14 +26,14 @@ const m = {
26
26
  RESIZE: "resize",
27
27
  /** Emitted when component receives focus */
28
28
  FOCUS: "focus"
29
- }, U = {
29
+ }, z = {
30
30
  /** Default JSON serialization */
31
31
  JSON: "json",
32
32
  /** Base64 encoding for binary or large data */
33
33
  BASE64: "base64",
34
- /** Dot notation for nested objects (e.g., "a.b.c=value") */
34
+ /** Explicit framed-path encoding for nested objects */
35
35
  DOTIFY: "dotify"
36
- }, F = {
36
+ }, W = {
37
37
  /** Request message expecting a response */
38
38
  REQUEST: "request",
39
39
  /** Response to a previous request */
@@ -63,14 +63,14 @@ const m = {
63
63
  CONSUMER_EXPORT: "forgeframe_consumer_export",
64
64
  /** Get sibling components request */
65
65
  GET_SIBLINGS: "forgeframe_get_siblings"
66
- }, H = "__forgeframe__", xe = (() => {
67
- if ("0.0.6".trim().length === 0)
66
+ }, j = "__forgeframe__", ae = (() => {
67
+ if ("0.0.10".trim().length === 0)
68
68
  throw new Error(
69
69
  "ForgeFrame VERSION injection is missing. Configure __FORGEFRAME_VERSION__ in build/test tooling."
70
70
  );
71
- return "0.0.6";
71
+ return "0.0.10";
72
72
  })();
73
- class Re {
73
+ class Ae {
74
74
  /**
75
75
  * Internal storage for event listeners mapped by event name.
76
76
  * @internal
@@ -93,8 +93,8 @@ class Re {
93
93
  *
94
94
  * @public
95
95
  */
96
- on(e, t) {
97
- return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => this.off(e, t);
96
+ on(e, n) {
97
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(n), () => this.off(e, n);
98
98
  }
99
99
  /**
100
100
  * Subscribes a handler to an event that will automatically unsubscribe after the first invocation.
@@ -117,9 +117,9 @@ class Re {
117
117
  *
118
118
  * @public
119
119
  */
120
- once(e, t) {
121
- const n = (r) => (this.off(e, n), t(r));
122
- return this.on(e, n);
120
+ once(e, n) {
121
+ const s = (r) => (this.off(e, s), n(r));
122
+ return this.on(e, s);
123
123
  }
124
124
  /**
125
125
  * Emits an event, invoking all registered handlers with the provided data.
@@ -140,12 +140,12 @@ class Re {
140
140
  *
141
141
  * @public
142
142
  */
143
- emit(e, t) {
144
- const n = this.listeners.get(e);
145
- if (n)
146
- for (const r of n)
143
+ emit(e, n) {
144
+ const s = this.listeners.get(e);
145
+ if (s)
146
+ for (const r of s)
147
147
  try {
148
- const i = r(t);
148
+ const i = r(n);
149
149
  i && typeof i == "object" && "catch" in i && typeof i.catch == "function" && i.catch((o) => {
150
150
  console.error(`Error in async event handler for "${e}":`, o);
151
151
  });
@@ -174,13 +174,13 @@ class Re {
174
174
  *
175
175
  * @public
176
176
  */
177
- off(e, t) {
178
- if (!t) {
177
+ off(e, n) {
178
+ if (!n) {
179
179
  this.listeners.delete(e);
180
180
  return;
181
181
  }
182
- const n = this.listeners.get(e);
183
- n && (n.delete(t), n.size === 0 && this.listeners.delete(e));
182
+ const s = this.listeners.get(e);
183
+ s && (s.delete(n), s.size === 0 && this.listeners.delete(e));
184
184
  }
185
185
  /**
186
186
  * Removes all event listeners from the emitter.
@@ -221,14 +221,14 @@ class Re {
221
221
  return this.listeners.get(e)?.size ?? 0;
222
222
  }
223
223
  }
224
- function Me() {
225
- const s = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
226
- return `${s}_${e}`;
224
+ function tt() {
225
+ const t = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
226
+ return `${t}_${e}`;
227
227
  }
228
- function N() {
228
+ function k() {
229
229
  return Math.random().toString(36).slice(2, 11);
230
230
  }
231
- class We {
231
+ class nt {
232
232
  /**
233
233
  * Array of registered cleanup tasks awaiting execution.
234
234
  * @internal
@@ -265,8 +265,8 @@ class We {
265
265
  */
266
266
  register(e) {
267
267
  if (this.cleaned) {
268
- Promise.resolve().then(() => e()).catch((t) => {
269
- console.error("Error in cleanup task:", t);
268
+ Promise.resolve().then(() => e()).catch((n) => {
269
+ console.error("Error in cleanup task:", n);
270
270
  });
271
271
  return;
272
272
  }
@@ -298,11 +298,11 @@ class We {
298
298
  this.cleaned = !0;
299
299
  const e = this.tasks.reverse();
300
300
  this.tasks = [];
301
- for (const t of e)
301
+ for (const n of e)
302
302
  try {
303
- await t();
304
- } catch (n) {
305
- console.error("Error in cleanup task:", n);
303
+ await n();
304
+ } catch (s) {
305
+ console.error("Error in cleanup task:", s);
306
306
  }
307
307
  }
308
308
  /**
@@ -345,125 +345,125 @@ class We {
345
345
  this.tasks = [], this.cleaned = !1;
346
346
  }
347
347
  }
348
- function Oe() {
349
- let s, e;
350
- return { promise: new Promise((n, r) => {
351
- s = n, e = r;
352
- }), resolve: s, reject: e };
348
+ function Le() {
349
+ let t, e;
350
+ return { promise: new Promise((s, r) => {
351
+ t = s, e = r;
352
+ }), resolve: t, reject: e };
353
353
  }
354
- function Be(s, e, t = "Operation timed out") {
355
- return new Promise((n, r) => {
354
+ function st(t, e, n = "Operation timed out") {
355
+ return new Promise((s, r) => {
356
356
  const i = setTimeout(() => {
357
- r(new Error(`${t} (${e}ms)`));
357
+ r(new Error(`${n} (${e}ms)`));
358
358
  }, e);
359
- s.then((o) => {
360
- clearTimeout(i), n(o);
359
+ t.then((o) => {
360
+ clearTimeout(i), s(o);
361
361
  }).catch((o) => {
362
362
  clearTimeout(i), r(o);
363
363
  });
364
364
  });
365
365
  }
366
- const O = /* @__PURE__ */ new Map(), je = 200;
367
- function Ve(s) {
368
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
366
+ const S = /* @__PURE__ */ new Map(), rt = 200;
367
+ function it(t) {
368
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
369
369
  }
370
- function Ke(s) {
371
- if (!s.includes("*"))
370
+ function ot(t) {
371
+ if (!t.includes("*"))
372
372
  return null;
373
- const e = O.get(s);
373
+ const e = S.get(t);
374
374
  if (e)
375
375
  return e;
376
- const t = s.split("*").map((r) => Ve(r)).join(".*"), n = new RegExp(`^${t}$`);
377
- if (O.size >= je) {
378
- const r = O.keys().next().value;
379
- r && O.delete(r);
376
+ const n = t.split("*").map((r) => it(r)).join(".*"), s = new RegExp(`^${n}$`);
377
+ if (S.size >= rt) {
378
+ const r = S.keys().next().value;
379
+ r && S.delete(r);
380
380
  }
381
- return O.set(s, n), n;
381
+ return S.set(t, s), s;
382
382
  }
383
- function qe(s, e) {
384
- return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
383
+ function at(t, e) {
384
+ return t.global || t.sticky ? new RegExp(t.source, t.flags.replace(/[gy]/g, "")).test(e) : t.test(e);
385
385
  }
386
- function K(s = window) {
386
+ function B(t = window) {
387
387
  try {
388
- return s.location.origin;
388
+ return t.location.origin;
389
389
  } catch {
390
390
  return "";
391
391
  }
392
392
  }
393
- function Je(s, e = window) {
393
+ function Me(t, e = window) {
394
394
  try {
395
- return s.location.origin === e.location.origin;
395
+ return t.location.origin === e.location.origin;
396
396
  } catch {
397
397
  return !1;
398
398
  }
399
399
  }
400
- function C(s, e) {
401
- if (typeof s == "string") {
402
- if (s === "*") return !0;
403
- const t = Ke(s);
404
- return t ? t.test(e) : s === e;
400
+ function U(t, e) {
401
+ if (typeof t == "string") {
402
+ if (t === "*") return !0;
403
+ const n = ot(t);
404
+ return n ? n.test(e) : t === e;
405
405
  }
406
- return s instanceof RegExp ? qe(s, e) : Array.isArray(s) ? s.some((t) => C(t, e)) : !1;
406
+ return t instanceof RegExp ? at(t, e) : Array.isArray(t) ? t.some((n) => U(n, e)) : !1;
407
407
  }
408
- function q(s) {
409
- if (!s) return !0;
408
+ function se(t) {
409
+ if (!t) return !0;
410
410
  try {
411
- return s.closed;
411
+ return t.closed;
412
412
  } catch {
413
413
  return !0;
414
414
  }
415
415
  }
416
- function Xe(s = window) {
416
+ function ct(t = window) {
417
417
  try {
418
- return s.opener;
418
+ return t.opener;
419
419
  } catch {
420
420
  return null;
421
421
  }
422
422
  }
423
- function Ye(s = window) {
423
+ function lt(t = window) {
424
424
  try {
425
- const e = s.parent;
426
- return e && e !== s ? e : null;
425
+ const e = t.parent;
426
+ return e && e !== t ? e : null;
427
427
  } catch {
428
428
  return null;
429
429
  }
430
430
  }
431
- function Ge(s = window) {
431
+ function ut(t = window) {
432
432
  try {
433
- return s.parent !== s;
433
+ return t.parent !== t;
434
434
  } catch {
435
435
  return !0;
436
436
  }
437
437
  }
438
- function Ze(s = window) {
438
+ function ht(t = window) {
439
439
  try {
440
- return s.opener !== null && s.opener !== void 0;
440
+ return t.opener !== null && t.opener !== void 0;
441
441
  } catch {
442
442
  return !1;
443
443
  }
444
444
  }
445
- const fe = 100, P = /* @__PURE__ */ new Map();
446
- function Qe() {
447
- const s = [];
448
- for (const [e, t] of P.entries())
449
- q(t) && s.push(e);
450
- for (const e of s)
451
- P.delete(e);
445
+ const De = 100, b = /* @__PURE__ */ new Map();
446
+ function dt() {
447
+ const t = [];
448
+ for (const [e, n] of b.entries())
449
+ se(n) && t.push(e);
450
+ for (const e of t)
451
+ b.delete(e);
452
452
  }
453
- function et(s, e) {
454
- if (P.size >= fe && Qe(), P.size >= fe) {
455
- const t = P.keys().next().value;
456
- t && P.delete(t);
453
+ function pt(t, e) {
454
+ if (b.size >= De && dt(), b.size >= De) {
455
+ const n = b.keys().next().value;
456
+ n && b.delete(n);
457
457
  }
458
- P.set(s, e);
458
+ b.set(t, e);
459
459
  }
460
- function tt(s) {
461
- P.delete(s);
460
+ function ft(t) {
461
+ b.delete(t);
462
462
  }
463
- function st(s, e) {
464
- return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
463
+ function mt(t, e) {
464
+ return t.global || t.sticky ? new RegExp(t.source, t.flags.replace(/[gy]/g, "")).test(e) : t.test(e);
465
465
  }
466
- class _ {
466
+ class P {
467
467
  /** @internal */
468
468
  _optional = !1;
469
469
  /** @internal */
@@ -526,11 +526,11 @@ class _ {
526
526
  * ```
527
527
  */
528
528
  default(e) {
529
- const t = this._clone();
530
- return t._default = e, t;
529
+ const n = this._clone();
530
+ return n._default = e, n;
531
531
  }
532
532
  }
533
- class G extends _ {
533
+ class ce extends P {
534
534
  /** @internal */
535
535
  _minLength;
536
536
  /** @internal */
@@ -547,26 +547,26 @@ class G extends _ {
547
547
  return {
548
548
  issues: [{ message: `Expected string, got ${typeof e}` }]
549
549
  };
550
- const t = this._trim ? e.trim() : e;
551
- return this._minLength !== void 0 && t.length < this._minLength ? {
550
+ const n = this._trim ? e.trim() : e;
551
+ return this._minLength !== void 0 && n.length < this._minLength ? {
552
552
  issues: [
553
553
  { message: `String must be at least ${this._minLength} characters` }
554
554
  ]
555
- } : this._maxLength !== void 0 && t.length > this._maxLength ? {
555
+ } : this._maxLength !== void 0 && n.length > this._maxLength ? {
556
556
  issues: [
557
557
  { message: `String must be at most ${this._maxLength} characters` }
558
558
  ]
559
- } : this._pattern && !st(this._pattern, t) ? {
559
+ } : this._pattern && !mt(this._pattern, n) ? {
560
560
  issues: [
561
561
  {
562
562
  message: this._patternMessage || `String must match pattern ${this._pattern}`
563
563
  }
564
564
  ]
565
- } : { value: t };
565
+ } : { value: n };
566
566
  }
567
567
  /** @internal */
568
568
  _clone() {
569
- const e = new G();
569
+ const e = new ce();
570
570
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._minLength = this._minLength, e._maxLength = this._maxLength, e._pattern = this._pattern, e._patternMessage = this._patternMessage, e._trim = this._trim, e;
571
571
  }
572
572
  /**
@@ -580,8 +580,8 @@ class G extends _ {
580
580
  * ```
581
581
  */
582
582
  min(e) {
583
- const t = this._clone();
584
- return t._minLength = e, t;
583
+ const n = this._clone();
584
+ return n._minLength = e, n;
585
585
  }
586
586
  /**
587
587
  * Requires maximum string length.
@@ -594,8 +594,8 @@ class G extends _ {
594
594
  * ```
595
595
  */
596
596
  max(e) {
597
- const t = this._clone();
598
- return t._maxLength = e, t;
597
+ const n = this._clone();
598
+ return n._maxLength = e, n;
599
599
  }
600
600
  /**
601
601
  * Requires exact string length.
@@ -608,8 +608,8 @@ class G extends _ {
608
608
  * ```
609
609
  */
610
610
  length(e) {
611
- const t = this._clone();
612
- return t._minLength = e, t._maxLength = e, t;
611
+ const n = this._clone();
612
+ return n._minLength = e, n._maxLength = e, n;
613
613
  }
614
614
  /**
615
615
  * Requires string to match a regex pattern.
@@ -622,9 +622,9 @@ class G extends _ {
622
622
  * slug: prop.string().pattern(/^[a-z0-9-]+$/, 'Invalid slug format')
623
623
  * ```
624
624
  */
625
- pattern(e, t) {
626
- const n = this._clone();
627
- return n._pattern = e, n._patternMessage = t, n;
625
+ pattern(e, n) {
626
+ const s = this._clone();
627
+ return s._pattern = e, s._patternMessage = n, s;
628
628
  }
629
629
  /**
630
630
  * Validates as email address.
@@ -691,7 +691,7 @@ class G extends _ {
691
691
  return e._minLength = 1, e;
692
692
  }
693
693
  }
694
- class Z extends _ {
694
+ class le extends P {
695
695
  /** @internal */
696
696
  _min;
697
697
  /** @internal */
@@ -706,7 +706,7 @@ class Z extends _ {
706
706
  }
707
707
  /** @internal */
708
708
  _clone() {
709
- const e = new Z();
709
+ const e = new le();
710
710
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._min = this._min, e._max = this._max, e._int = this._int, e;
711
711
  }
712
712
  /**
@@ -720,8 +720,8 @@ class Z extends _ {
720
720
  * ```
721
721
  */
722
722
  min(e) {
723
- const t = this._clone();
724
- return t._min = e, t;
723
+ const n = this._clone();
724
+ return n._min = e, n;
725
725
  }
726
726
  /**
727
727
  * Requires maximum value.
@@ -734,8 +734,8 @@ class Z extends _ {
734
734
  * ```
735
735
  */
736
736
  max(e) {
737
- const t = this._clone();
738
- return t._max = e, t;
737
+ const n = this._clone();
738
+ return n._max = e, n;
739
739
  }
740
740
  /**
741
741
  * Requires integer value.
@@ -786,7 +786,7 @@ class Z extends _ {
786
786
  return e._max = -Number.MIN_VALUE, e;
787
787
  }
788
788
  }
789
- class Q extends _ {
789
+ class ue extends P {
790
790
  /** @internal */
791
791
  _validate(e) {
792
792
  return typeof e != "boolean" ? {
@@ -795,11 +795,11 @@ class Q extends _ {
795
795
  }
796
796
  /** @internal */
797
797
  _clone() {
798
- const e = new Q();
798
+ const e = new ue();
799
799
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
800
800
  }
801
801
  }
802
- class ee extends _ {
802
+ class he extends P {
803
803
  /** @internal */
804
804
  _validate(e) {
805
805
  return typeof e != "function" ? {
@@ -808,11 +808,11 @@ class ee extends _ {
808
808
  }
809
809
  /** @internal */
810
810
  _clone() {
811
- const e = new ee();
811
+ const e = new he();
812
812
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
813
813
  }
814
814
  }
815
- class $ extends _ {
815
+ class V extends P {
816
816
  /** @internal */
817
817
  _itemSchema;
818
818
  /** @internal */
@@ -838,9 +838,9 @@ class $ extends _ {
838
838
  ]
839
839
  };
840
840
  if (this._itemSchema) {
841
- const t = [];
842
- for (let n = 0; n < e.length; n++) {
843
- const r = this._itemSchema["~standard"].validate(e[n]);
841
+ const n = [];
842
+ for (let s = 0; s < e.length; s++) {
843
+ const r = this._itemSchema["~standard"].validate(e[s]);
844
844
  if (r instanceof Promise)
845
845
  throw new Error(
846
846
  "Async schema validation is not supported. Use synchronous schemas."
@@ -849,18 +849,18 @@ class $ extends _ {
849
849
  return {
850
850
  issues: r.issues.map((i) => ({
851
851
  ...i,
852
- path: [n, ...i.path || []]
852
+ path: [s, ...i.path || []]
853
853
  }))
854
854
  };
855
- t.push(r.value);
855
+ n.push(r.value);
856
856
  }
857
- return { value: t };
857
+ return { value: n };
858
858
  }
859
859
  return { value: e };
860
860
  }
861
861
  /** @internal */
862
862
  _clone() {
863
- const e = new $();
863
+ const e = new V();
864
864
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._itemSchema = this._itemSchema, e._minLength = this._minLength, e._maxLength = this._maxLength, e;
865
865
  }
866
866
  /**
@@ -876,8 +876,8 @@ class $ extends _ {
876
876
  * ```
877
877
  */
878
878
  of(e) {
879
- const t = new $();
880
- return t._optional = this._optional, t._nullable = this._nullable, t._itemSchema = e, t._minLength = this._minLength, t._maxLength = this._maxLength, t;
879
+ const n = new V();
880
+ return n._optional = this._optional, n._nullable = this._nullable, n._itemSchema = e, n._minLength = this._minLength, n._maxLength = this._maxLength, n;
881
881
  }
882
882
  /**
883
883
  * Requires minimum array length.
@@ -890,8 +890,8 @@ class $ extends _ {
890
890
  * ```
891
891
  */
892
892
  min(e) {
893
- const t = this._clone();
894
- return t._minLength = e, t;
893
+ const n = this._clone();
894
+ return n._minLength = e, n;
895
895
  }
896
896
  /**
897
897
  * Requires maximum array length.
@@ -904,8 +904,8 @@ class $ extends _ {
904
904
  * ```
905
905
  */
906
906
  max(e) {
907
- const t = this._clone();
908
- return t._maxLength = e, t;
907
+ const n = this._clone();
908
+ return n._maxLength = e, n;
909
909
  }
910
910
  /**
911
911
  * Requires non-empty array.
@@ -919,7 +919,7 @@ class $ extends _ {
919
919
  return this.min(1);
920
920
  }
921
921
  }
922
- class L extends _ {
922
+ class Y extends P {
923
923
  /** @internal */
924
924
  _shape;
925
925
  /** @internal */
@@ -934,18 +934,18 @@ class L extends _ {
934
934
  }
935
935
  ]
936
936
  };
937
- const t = e, n = {};
937
+ const n = e, s = {};
938
938
  if (this._shape) {
939
939
  if (this._strict) {
940
940
  const r = new Set(Object.keys(this._shape));
941
- for (const i of Object.keys(t))
941
+ for (const i of Object.keys(n))
942
942
  if (!r.has(i))
943
943
  return {
944
944
  issues: [{ message: `Unknown key: ${i}`, path: [i] }]
945
945
  };
946
946
  }
947
947
  for (const [r, i] of Object.entries(this._shape)) {
948
- const o = i["~standard"].validate(t[r]);
948
+ const o = i["~standard"].validate(n[r]);
949
949
  if (o instanceof Promise)
950
950
  throw new Error(
951
951
  "Async schema validation is not supported. Use synchronous schemas."
@@ -957,18 +957,18 @@ class L extends _ {
957
957
  path: [r, ...a.path || []]
958
958
  }))
959
959
  };
960
- n[r] = o.value;
960
+ s[r] = o.value;
961
961
  }
962
962
  if (!this._strict)
963
- for (const r of Object.keys(t))
964
- r in this._shape || (n[r] = t[r]);
965
- return { value: n };
963
+ for (const r of Object.keys(n))
964
+ r in this._shape || (s[r] = n[r]);
965
+ return { value: s };
966
966
  }
967
967
  return { value: e };
968
968
  }
969
969
  /** @internal */
970
970
  _clone() {
971
- const e = new L();
971
+ const e = new Y();
972
972
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._shape = this._shape, e._strict = this._strict, e;
973
973
  }
974
974
  /**
@@ -986,8 +986,8 @@ class L extends _ {
986
986
  * ```
987
987
  */
988
988
  shape(e) {
989
- const t = new L();
990
- return t._optional = this._optional, t._nullable = this._nullable, t._shape = e, t._strict = this._strict, t;
989
+ const n = new Y();
990
+ return n._optional = this._optional, n._nullable = this._nullable, n._shape = e, n._strict = this._strict, n;
991
991
  }
992
992
  /**
993
993
  * Rejects objects with unknown keys.
@@ -1002,7 +1002,7 @@ class L extends _ {
1002
1002
  return e._strict = !0, e;
1003
1003
  }
1004
1004
  }
1005
- class te extends _ {
1005
+ class de extends P {
1006
1006
  /** @internal */
1007
1007
  _value;
1008
1008
  constructor(e) {
@@ -1016,11 +1016,11 @@ class te extends _ {
1016
1016
  }
1017
1017
  /** @internal */
1018
1018
  _clone() {
1019
- const e = new te(this._value);
1019
+ const e = new de(this._value);
1020
1020
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1021
1021
  }
1022
1022
  }
1023
- class se extends _ {
1023
+ class pe extends P {
1024
1024
  /** @internal */
1025
1025
  _values;
1026
1026
  /** @internal */
@@ -1033,18 +1033,18 @@ class se extends _ {
1033
1033
  return this._valueSet.has(e) ? { value: e } : {
1034
1034
  issues: [
1035
1035
  {
1036
- message: `Expected one of [${this._values.map((t) => JSON.stringify(t)).join(", ")}], got ${JSON.stringify(e)}`
1036
+ message: `Expected one of [${this._values.map((n) => JSON.stringify(n)).join(", ")}], got ${JSON.stringify(e)}`
1037
1037
  }
1038
1038
  ]
1039
1039
  };
1040
1040
  }
1041
1041
  /** @internal */
1042
1042
  _clone() {
1043
- const e = new se(this._values);
1043
+ const e = new pe(this._values);
1044
1044
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1045
1045
  }
1046
1046
  }
1047
- class ne extends _ {
1047
+ class fe extends P {
1048
1048
  constructor() {
1049
1049
  super(), this._nullable = !0;
1050
1050
  }
@@ -1054,11 +1054,11 @@ class ne extends _ {
1054
1054
  }
1055
1055
  /** @internal */
1056
1056
  _clone() {
1057
- const e = new ne();
1057
+ const e = new fe();
1058
1058
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1059
1059
  }
1060
1060
  }
1061
- const d = {
1061
+ const p = {
1062
1062
  /**
1063
1063
  * Creates a string schema.
1064
1064
  *
@@ -1071,7 +1071,7 @@ const d = {
1071
1071
  * prop.string().pattern(/^[a-z]+$/)
1072
1072
  * ```
1073
1073
  */
1074
- string: () => new G(),
1074
+ string: () => new ce(),
1075
1075
  /**
1076
1076
  * Creates a number schema.
1077
1077
  *
@@ -1083,7 +1083,7 @@ const d = {
1083
1083
  * prop.number().positive()
1084
1084
  * ```
1085
1085
  */
1086
- number: () => new Z(),
1086
+ number: () => new le(),
1087
1087
  /**
1088
1088
  * Creates a boolean schema.
1089
1089
  *
@@ -1093,7 +1093,7 @@ const d = {
1093
1093
  * prop.boolean().default(false)
1094
1094
  * ```
1095
1095
  */
1096
- boolean: () => new Q(),
1096
+ boolean: () => new ue(),
1097
1097
  /**
1098
1098
  * Creates a function schema.
1099
1099
  *
@@ -1106,7 +1106,7 @@ const d = {
1106
1106
  * prop.function<(data: { id: string }) => Promise<void>>()
1107
1107
  * ```
1108
1108
  */
1109
- function: () => new ee(),
1109
+ function: () => new he(),
1110
1110
  /**
1111
1111
  * Creates an array schema.
1112
1112
  *
@@ -1119,7 +1119,7 @@ const d = {
1119
1119
  * prop.array().of(prop.number()).min(1).max(10)
1120
1120
  * ```
1121
1121
  */
1122
- array: () => new $(),
1122
+ array: () => new V(),
1123
1123
  /**
1124
1124
  * Creates an object schema.
1125
1125
  *
@@ -1135,7 +1135,7 @@ const d = {
1135
1135
  * prop.object().shape({ key: prop.string() }).strict()
1136
1136
  * ```
1137
1137
  */
1138
- object: () => new L(),
1138
+ object: () => new Y(),
1139
1139
  /**
1140
1140
  * Creates a literal schema for exact value matching.
1141
1141
  *
@@ -1148,7 +1148,7 @@ const d = {
1148
1148
  * prop.literal(true)
1149
1149
  * ```
1150
1150
  */
1151
- literal: (s) => new te(s),
1151
+ literal: (t) => new de(t),
1152
1152
  /**
1153
1153
  * Creates an enum schema for a set of allowed values.
1154
1154
  *
@@ -1160,7 +1160,7 @@ const d = {
1160
1160
  * prop.enum([1, 2, 3])
1161
1161
  * ```
1162
1162
  */
1163
- enum: (s) => new se(s),
1163
+ enum: (t) => new pe(t),
1164
1164
  /**
1165
1165
  * Creates a schema that accepts any value.
1166
1166
  *
@@ -1172,199 +1172,199 @@ const d = {
1172
1172
  * prop.any()
1173
1173
  * ```
1174
1174
  */
1175
- any: () => new ne()
1176
- }, b = {
1175
+ any: () => new fe()
1176
+ }, R = {
1177
1177
  uid: {
1178
- schema: d.string().optional(),
1178
+ schema: p.string().optional(),
1179
1179
  sendToHost: !0
1180
1180
  },
1181
1181
  tag: {
1182
- schema: d.string().optional(),
1182
+ schema: p.string().optional(),
1183
1183
  sendToHost: !0
1184
1184
  },
1185
1185
  dimensions: {
1186
- schema: d.object().default(() => ({ width: "100%", height: "100%" })),
1186
+ schema: p.object().default(() => ({ width: "100%", height: "100%" })),
1187
1187
  sendToHost: !1
1188
1188
  },
1189
1189
  timeout: {
1190
- schema: d.number().default(1e4),
1190
+ schema: p.number().default(1e4),
1191
1191
  sendToHost: !1
1192
1192
  },
1193
1193
  cspNonce: {
1194
- schema: d.string().optional(),
1194
+ schema: p.string().optional(),
1195
1195
  sendToHost: !0
1196
1196
  },
1197
1197
  // Lifecycle callbacks - not sent to host (consumer-only)
1198
1198
  onDisplay: {
1199
- schema: d.function().optional(),
1199
+ schema: p.function().optional(),
1200
1200
  sendToHost: !1
1201
1201
  },
1202
1202
  onRendered: {
1203
- schema: d.function().optional(),
1203
+ schema: p.function().optional(),
1204
1204
  sendToHost: !1
1205
1205
  },
1206
1206
  onRender: {
1207
- schema: d.function().optional(),
1207
+ schema: p.function().optional(),
1208
1208
  sendToHost: !1
1209
1209
  },
1210
1210
  onPrerendered: {
1211
- schema: d.function().optional(),
1211
+ schema: p.function().optional(),
1212
1212
  sendToHost: !1
1213
1213
  },
1214
1214
  onPrerender: {
1215
- schema: d.function().optional(),
1215
+ schema: p.function().optional(),
1216
1216
  sendToHost: !1
1217
1217
  },
1218
1218
  onClose: {
1219
- schema: d.function().optional(),
1219
+ schema: p.function().optional(),
1220
1220
  sendToHost: !1
1221
1221
  },
1222
1222
  onDestroy: {
1223
- schema: d.function().optional(),
1223
+ schema: p.function().optional(),
1224
1224
  sendToHost: !1
1225
1225
  },
1226
1226
  onResize: {
1227
- schema: d.function().optional(),
1227
+ schema: p.function().optional(),
1228
1228
  sendToHost: !1
1229
1229
  },
1230
1230
  onFocus: {
1231
- schema: d.function().optional(),
1231
+ schema: p.function().optional(),
1232
1232
  sendToHost: !1
1233
1233
  },
1234
1234
  onError: {
1235
- schema: d.function().optional(),
1235
+ schema: p.function().optional(),
1236
1236
  sendToHost: !1
1237
1237
  },
1238
1238
  onProps: {
1239
- schema: d.function().optional(),
1239
+ schema: p.function().optional(),
1240
1240
  sendToHost: !1
1241
1241
  }
1242
1242
  };
1243
- function z(s) {
1244
- return typeof s == "object" && s !== null && "~standard" in s && typeof s["~standard"] == "object" && s["~standard"] !== null && s["~standard"].version === 1 && typeof s["~standard"].vendor == "string" && typeof s["~standard"].validate == "function";
1243
+ function D(t) {
1244
+ return typeof t == "object" && t !== null && "~standard" in t && typeof t["~standard"] == "object" && t["~standard"] !== null && t["~standard"].version === 1 && typeof t["~standard"].vendor == "string" && typeof t["~standard"].validate == "function";
1245
1245
  }
1246
- function nt(s, e, t) {
1247
- const n = s["~standard"].validate(e);
1248
- if (n instanceof Promise)
1246
+ function gt(t, e, n) {
1247
+ const s = t["~standard"].validate(e);
1248
+ if (s instanceof Promise)
1249
1249
  throw new Error(
1250
- `Prop "${t}" uses an async schema. ForgeFrame only supports synchronous schema validation. Please use a synchronous schema or remove async operations (like database lookups) from your schema definition.`
1250
+ `Prop "${n}" uses an async schema. ForgeFrame only supports synchronous schema validation. Please use a synchronous schema or remove async operations (like database lookups) from your schema definition.`
1251
1251
  );
1252
- if (n.issues) {
1253
- const r = n.issues.map((i) => `${rt(i.path, t)}: ${i.message}`);
1252
+ if (s.issues) {
1253
+ const r = s.issues.map((i) => `${yt(i.path, n)}: ${i.message}`);
1254
1254
  throw new Error(`Validation failed: ${r.join("; ")}`);
1255
1255
  }
1256
- return n.value;
1256
+ return s.value;
1257
1257
  }
1258
- function rt(s, e) {
1259
- if (!s || s.length === 0)
1258
+ function yt(t, e) {
1259
+ if (!t || t.length === 0)
1260
1260
  return e;
1261
- const t = s.map((n) => {
1262
- if (typeof n == "object" && n !== null) {
1263
- if ("key" in n && n.key !== void 0)
1264
- return String(n.key);
1265
- if ("index" in n && typeof n.index == "number")
1266
- return String(n.index);
1261
+ const n = t.map((s) => {
1262
+ if (typeof s == "object" && s !== null) {
1263
+ if ("key" in s && s.key !== void 0)
1264
+ return String(s.key);
1265
+ if ("index" in s && typeof s.index == "number")
1266
+ return String(s.index);
1267
1267
  }
1268
- return String(n);
1268
+ return String(s);
1269
1269
  });
1270
- return `${e}.${t.join(".")}`;
1270
+ return `${e}.${n.join(".")}`;
1271
1271
  }
1272
- function I(s) {
1273
- const e = z(s);
1274
- return { isDirectSchema: e, definition: e ? { schema: s } : s };
1272
+ function H(t) {
1273
+ const e = D(t);
1274
+ return { isDirectSchema: e, definition: e ? { schema: t } : t };
1275
1275
  }
1276
- function me(s, e, t) {
1277
- const n = {
1278
- ...b,
1276
+ function Ie(t, e, n) {
1277
+ const s = {
1278
+ ...R,
1279
1279
  ...e
1280
1280
  }, r = {};
1281
- for (const [i, o] of Object.entries(n)) {
1282
- const { definition: a } = I(o);
1281
+ for (const [i, o] of Object.entries(s)) {
1282
+ const { definition: a } = H(o);
1283
1283
  let c;
1284
- const l = a.alias, h = i in s, f = l && l in s;
1285
- if (h)
1286
- c = s[i];
1287
- else if (f)
1288
- c = s[l];
1284
+ const l = a.alias, d = i in t, m = l && l in t;
1285
+ if (d)
1286
+ c = t[i];
1287
+ else if (m)
1288
+ c = t[l];
1289
1289
  else if (a.value)
1290
- c = a.value(t);
1290
+ c = a.value(n);
1291
1291
  else if (a.default !== void 0)
1292
- c = typeof a.default == "function" ? a.default(t) : a.default;
1293
- else if (a.schema && z(a.schema)) {
1294
- const g = a.schema["~standard"].validate(void 0);
1295
- !(g instanceof Promise) && !g.issues && (c = g.value);
1292
+ c = typeof a.default == "function" ? a.default(n) : a.default;
1293
+ else if (a.schema && D(a.schema)) {
1294
+ const h = a.schema["~standard"].validate(void 0);
1295
+ !(h instanceof Promise) && !h.issues && (c = h.value);
1296
1296
  }
1297
1297
  c !== void 0 && a.decorate && (c = a.decorate({ value: c, props: r })), r[i] = c;
1298
1298
  }
1299
1299
  return r;
1300
1300
  }
1301
- function ve(s, e) {
1302
- const t = {
1303
- ...b,
1301
+ function T(t, e) {
1302
+ const n = {
1303
+ ...R,
1304
1304
  ...e
1305
1305
  };
1306
- for (const [n, r] of Object.entries(t)) {
1307
- const { isDirectSchema: i, definition: o } = I(r);
1308
- let a = s[n];
1306
+ for (const [s, r] of Object.entries(n)) {
1307
+ const { isDirectSchema: i, definition: o } = H(r);
1308
+ let a = t[s];
1309
1309
  if (o.required && a === void 0)
1310
- throw new Error(`Prop "${n}" is required but was not provided`);
1311
- if (o.schema && z(o.schema))
1312
- (a !== void 0 || i) && (a = nt(o.schema, a, n), s[n] = a);
1310
+ throw new Error(`Prop "${s}" is required but was not provided`);
1311
+ if (o.schema && D(o.schema))
1312
+ (a !== void 0 || i) && (a = gt(o.schema, a, s), t[s] = a);
1313
1313
  else if (a === void 0)
1314
1314
  continue;
1315
- o.validate && o.validate({ value: a, props: s });
1315
+ o.validate && o.validate({ value: a, props: t });
1316
1316
  }
1317
1317
  }
1318
- function ge(s, e, t, n) {
1318
+ function Se(t, e, n, s) {
1319
1319
  const r = {
1320
- ...b,
1320
+ ...R,
1321
1321
  ...e
1322
1322
  }, i = {};
1323
1323
  for (const [o, a] of Object.entries(r)) {
1324
- const { definition: c } = I(a), l = s[o];
1325
- if (c.sendToHost === !1 || c.sameDomain && !n) continue;
1324
+ const { definition: c } = H(a), l = t[o];
1325
+ if (c.sendToHost === !1 || c.sameDomain && !s) continue;
1326
1326
  if (c.trustedDomains) {
1327
- const f = c.trustedDomains;
1328
- if (!C(f, t)) continue;
1327
+ const m = c.trustedDomains;
1328
+ if (!U(m, n)) continue;
1329
1329
  }
1330
- let h = l;
1331
- c.hostDecorate && l !== void 0 && (h = c.hostDecorate({ value: l, props: s })), i[o] = h;
1330
+ let d = l;
1331
+ c.hostDecorate && l !== void 0 && (d = c.hostDecorate({ value: l, props: t })), i[o] = d;
1332
1332
  }
1333
1333
  return i;
1334
1334
  }
1335
- function it(s, e) {
1336
- const t = new URLSearchParams(), n = {
1337
- ...b,
1335
+ function wt(t, e) {
1336
+ const n = new URLSearchParams(), s = {
1337
+ ...R,
1338
1338
  ...e
1339
1339
  };
1340
- for (const [r, i] of Object.entries(n)) {
1341
- const { definition: o } = I(i), a = s[r];
1340
+ for (const [r, i] of Object.entries(s)) {
1341
+ const { definition: o } = H(i), a = t[r];
1342
1342
  if (a === void 0 || typeof a == "function" || !o.queryParam) continue;
1343
1343
  const c = typeof o.queryParam == "string" ? o.queryParam : r;
1344
1344
  let l;
1345
- typeof o.queryParam == "function" ? l = o.queryParam({ value: a }) : typeof a == "object" ? l = JSON.stringify(a) : l = String(a), t.set(c, l);
1345
+ typeof o.queryParam == "function" ? l = o.queryParam({ value: a }) : typeof a == "object" ? l = JSON.stringify(a) : l = String(a), n.set(c, l);
1346
1346
  }
1347
- return t;
1347
+ return n;
1348
1348
  }
1349
- function ot(s, e) {
1350
- const t = new URLSearchParams(), n = {
1351
- ...b,
1349
+ function _t(t, e) {
1350
+ const n = new URLSearchParams(), s = {
1351
+ ...R,
1352
1352
  ...e
1353
1353
  };
1354
- for (const [r, i] of Object.entries(n)) {
1355
- const { definition: o } = I(i), a = s[r];
1354
+ for (const [r, i] of Object.entries(s)) {
1355
+ const { definition: o } = H(i), a = t[r];
1356
1356
  if (a === void 0 || typeof a == "function" || !o.bodyParam) continue;
1357
1357
  const c = typeof o.bodyParam == "string" ? o.bodyParam : r;
1358
1358
  let l;
1359
- typeof o.bodyParam == "function" ? l = o.bodyParam({ value: a }) : typeof a == "object" ? l = JSON.stringify(a) : l = String(a), t.set(c, l);
1359
+ typeof o.bodyParam == "function" ? l = o.bodyParam({ value: a }) : typeof a == "object" ? l = JSON.stringify(a) : l = String(a), n.set(c, l);
1360
1360
  }
1361
- return t;
1361
+ return n;
1362
1362
  }
1363
- const ye = 500, at = /* @__PURE__ */ new Set(["__proto__"]);
1364
- function Se(s) {
1365
- return !at.has(s);
1363
+ const ve = 500, Pt = /* @__PURE__ */ new Set(["__proto__"]);
1364
+ function ze(t) {
1365
+ return !Pt.has(t);
1366
1366
  }
1367
- class re {
1367
+ class me {
1368
1368
  /**
1369
1369
  * Creates a new FunctionBridge instance.
1370
1370
  *
@@ -1390,16 +1390,16 @@ class re {
1390
1390
  * @param name - Optional name for debugging
1391
1391
  * @returns A function reference that can be sent across domains
1392
1392
  */
1393
- serialize(e, t) {
1394
- if (this.localFunctions.size >= ye) {
1393
+ serialize(e, n) {
1394
+ if (this.localFunctions.size >= ve) {
1395
1395
  const r = this.localFunctions.keys().next().value;
1396
1396
  r && this.localFunctions.delete(r);
1397
1397
  }
1398
- const n = N();
1399
- return this.localFunctions.set(n, e), this.currentBatchIds.add(n), {
1398
+ const s = k();
1399
+ return this.localFunctions.set(s, e), this.currentBatchIds.add(s), {
1400
1400
  __type__: "function",
1401
- __id__: n,
1402
- __name__: t || e.name || "anonymous"
1401
+ __id__: s,
1402
+ __name__: n || e.name || "anonymous"
1403
1403
  };
1404
1404
  }
1405
1405
  /**
@@ -1414,14 +1414,14 @@ class re {
1414
1414
  * @param targetDomain - The origin of the target window
1415
1415
  * @returns A callable wrapper function
1416
1416
  */
1417
- deserialize(e, t, n) {
1417
+ deserialize(e, n, s) {
1418
1418
  const r = `${e.__id__}`, i = this.remoteFunctions.get(r);
1419
1419
  if (i) return i;
1420
- if (this.remoteFunctions.size >= ye) {
1420
+ if (this.remoteFunctions.size >= ve) {
1421
1421
  const a = this.remoteFunctions.keys().next().value;
1422
1422
  a && this.remoteFunctions.delete(a);
1423
1423
  }
1424
- const o = async (...a) => this.messenger.send(t, n, u.CALL, {
1424
+ const o = async (...a) => this.messenger.send(n, s, u.CALL, {
1425
1425
  id: e.__id__,
1426
1426
  args: a
1427
1427
  });
@@ -1446,11 +1446,11 @@ class re {
1446
1446
  setupCallHandler() {
1447
1447
  this.messenger.on(
1448
1448
  u.CALL,
1449
- async ({ id: e, args: t }) => {
1450
- const n = this.localFunctions.get(e);
1451
- if (!n)
1449
+ async ({ id: e, args: n }) => {
1450
+ const s = this.localFunctions.get(e);
1451
+ if (!s)
1452
1452
  throw new Error(`Function with id "${e}" not found`);
1453
- return n(...t);
1453
+ return s(...n);
1454
1454
  }
1455
1455
  );
1456
1456
  }
@@ -1493,8 +1493,8 @@ class re {
1493
1493
  this.currentBatchIds.clear();
1494
1494
  return;
1495
1495
  }
1496
- for (const t of this.localFunctions.keys())
1497
- this.currentBatchIds.has(t) || this.localFunctions.delete(t);
1496
+ for (const n of this.localFunctions.keys())
1497
+ this.currentBatchIds.has(n) || this.localFunctions.delete(n);
1498
1498
  this.currentBatchIds.clear();
1499
1499
  }
1500
1500
  /**
@@ -1528,180 +1528,222 @@ class re {
1528
1528
  this.localFunctions.clear(), this.remoteFunctions.clear(), this.currentBatchIds.clear();
1529
1529
  }
1530
1530
  }
1531
- function J(s, e, t = /* @__PURE__ */ new WeakSet()) {
1532
- if (typeof s == "function")
1533
- return e.serialize(s);
1534
- if (Array.isArray(s)) {
1535
- if (t.has(s))
1531
+ function re(t, e, n = /* @__PURE__ */ new WeakSet()) {
1532
+ if (typeof t == "function")
1533
+ return e.serialize(t);
1534
+ if (Array.isArray(t)) {
1535
+ if (n.has(t))
1536
1536
  throw new Error("Circular reference detected in props - arrays cannot contain circular references");
1537
- t.add(s);
1537
+ n.add(t);
1538
1538
  try {
1539
- return s.map((n) => J(n, e, t));
1539
+ return t.map((s) => re(s, e, n));
1540
1540
  } finally {
1541
- t.delete(s);
1541
+ n.delete(t);
1542
1542
  }
1543
1543
  }
1544
- if (typeof s == "object" && s !== null) {
1545
- if (t.has(s))
1544
+ if (typeof t == "object" && t !== null) {
1545
+ if (n.has(t))
1546
1546
  throw new Error("Circular reference detected in props - objects cannot contain circular references");
1547
- t.add(s);
1547
+ n.add(t);
1548
1548
  try {
1549
- const n = {};
1550
- for (const [r, i] of Object.entries(s))
1551
- Se(r) && (n[r] = J(i, e, t));
1552
- return n;
1549
+ const s = {};
1550
+ for (const [r, i] of Object.entries(t))
1551
+ ze(r) && (s[r] = re(i, e, n));
1552
+ return s;
1553
1553
  } finally {
1554
- t.delete(s);
1554
+ n.delete(t);
1555
1555
  }
1556
1556
  }
1557
- return s;
1557
+ return t;
1558
1558
  }
1559
- function X(s, e, t, n, r = /* @__PURE__ */ new WeakSet()) {
1560
- if (re.isFunctionRef(s))
1561
- return e.deserialize(s, t, n);
1562
- if (Array.isArray(s)) {
1563
- if (r.has(s))
1559
+ function ie(t, e, n, s, r = /* @__PURE__ */ new WeakSet()) {
1560
+ if (me.isFunctionRef(t))
1561
+ return e.deserialize(t, n, s);
1562
+ if (Array.isArray(t)) {
1563
+ if (r.has(t))
1564
1564
  throw new Error("Circular reference detected in serialized props");
1565
- r.add(s);
1565
+ r.add(t);
1566
1566
  try {
1567
- return s.map(
1568
- (i) => X(i, e, t, n, r)
1567
+ return t.map(
1568
+ (i) => ie(i, e, n, s, r)
1569
1569
  );
1570
1570
  } finally {
1571
- r.delete(s);
1571
+ r.delete(t);
1572
1572
  }
1573
1573
  }
1574
- if (typeof s == "object" && s !== null) {
1575
- if (r.has(s))
1574
+ if (typeof t == "object" && t !== null) {
1575
+ if (r.has(t))
1576
1576
  throw new Error("Circular reference detected in serialized props");
1577
- r.add(s);
1577
+ r.add(t);
1578
1578
  try {
1579
1579
  const i = {};
1580
- for (const [o, a] of Object.entries(s))
1581
- Se(o) && (i[o] = X(a, e, t, n, r));
1580
+ for (const [o, a] of Object.entries(t))
1581
+ ze(o) && (i[o] = ie(a, e, n, s, r));
1582
1582
  return i;
1583
1583
  } finally {
1584
- r.delete(s);
1584
+ r.delete(t);
1585
1585
  }
1586
1586
  }
1587
- return s;
1587
+ return t;
1588
1588
  }
1589
- const ct = /* @__PURE__ */ new Set(["__proto__"]);
1590
- function Ce(s) {
1591
- return !ct.has(s);
1589
+ const Et = /* @__PURE__ */ new Set(["__proto__"]), ke = "__forgeframe.dotify_path__:", J = "__forgeframe.dotify_empty_object_path__:", We = "__forgeframe.dotify_empty_object__";
1590
+ function je(t) {
1591
+ return !Et.has(t);
1592
1592
  }
1593
- function Ie(s, e = "") {
1594
- const t = [];
1595
- for (const [n, r] of Object.entries(s)) {
1596
- const i = e ? `${e}.${n}` : n;
1597
- if (r !== null && typeof r == "object" && !Array.isArray(r))
1598
- t.push(Ie(r, i));
1599
- else {
1600
- const o = encodeURIComponent(JSON.stringify(r));
1601
- t.push(`${i}=${o}`);
1602
- }
1593
+ function Te(t) {
1594
+ if (t === null || typeof t != "object" || Array.isArray(t))
1595
+ return !1;
1596
+ const e = Object.getPrototypeOf(t);
1597
+ return e === Object.prototype || e === null;
1598
+ }
1599
+ function Be(t, e = ke) {
1600
+ return `${e}${encodeURIComponent(JSON.stringify(t))}`;
1601
+ }
1602
+ function bt(t) {
1603
+ return encodeURIComponent(JSON.stringify(t));
1604
+ }
1605
+ function Ot(t, e) {
1606
+ return `${Be(t)}=${bt(e)}`;
1607
+ }
1608
+ function Ct(t) {
1609
+ return `${Be(t, J)}=1`;
1610
+ }
1611
+ function Rt(t, e, n) {
1612
+ Object.defineProperty(t, e, {
1613
+ configurable: !0,
1614
+ enumerable: !0,
1615
+ writable: !0,
1616
+ value: n
1617
+ });
1618
+ }
1619
+ function Ve(t, e = []) {
1620
+ const n = Object.entries(t);
1621
+ if (n.length === 0 && Te(t))
1622
+ return e.length === 0 ? We : Ct(e);
1623
+ const s = [];
1624
+ for (const [r, i] of n) {
1625
+ if (i === void 0) continue;
1626
+ const o = [...e, r];
1627
+ Te(i) ? s.push(Ve(i, o)) : s.push(Ot(o, i));
1603
1628
  }
1604
- return t.filter(Boolean).join("&");
1629
+ return s.filter(Boolean).join("&");
1605
1630
  }
1606
- function lt(s) {
1631
+ function xt(t) {
1607
1632
  const e = {};
1608
- if (!s) return e;
1609
- const t = s.split("&");
1610
- for (const n of t) {
1611
- const [r, i] = n.split("=");
1612
- if (!r || i === void 0) continue;
1613
- let o;
1614
- try {
1615
- o = JSON.parse(decodeURIComponent(i));
1616
- } catch {
1617
- o = decodeURIComponent(i);
1618
- }
1619
- const a = r.split(".");
1620
- if (a.some((h) => !Ce(h))) continue;
1621
- let c = e;
1622
- for (let h = 0; h < a.length - 1; h++) {
1623
- const f = a[h], g = c[f];
1624
- (!Object.prototype.hasOwnProperty.call(c, f) || typeof g != "object" || g === null || Array.isArray(g)) && (c[f] = {}), c = c[f];
1633
+ if (!t || t === We) return e;
1634
+ const n = t.split("&");
1635
+ for (const s of n) {
1636
+ const r = s.indexOf("=");
1637
+ if (r === -1) continue;
1638
+ const i = s.slice(0, r), o = s.slice(r + 1);
1639
+ if (!i || o === void 0) continue;
1640
+ const a = i.startsWith(J);
1641
+ let c;
1642
+ if (a) {
1643
+ if (o !== "1")
1644
+ throw new Error("Invalid empty-object DOTIFY entry");
1645
+ c = {};
1646
+ } else
1647
+ try {
1648
+ c = JSON.parse(decodeURIComponent(o));
1649
+ } catch {
1650
+ c = decodeURIComponent(o);
1651
+ }
1652
+ const l = Dt(i);
1653
+ if (l.some((h) => !je(h))) continue;
1654
+ let d = e;
1655
+ for (let h = 0; h < l.length - 1; h++) {
1656
+ const E = l[h], O = d[E];
1657
+ (!Object.prototype.hasOwnProperty.call(d, E) || typeof O != "object" || O === null || Array.isArray(O)) && (d[E] = {}), d = d[E];
1625
1658
  }
1626
- const l = a[a.length - 1];
1627
- c[l] = o;
1659
+ const m = l[l.length - 1];
1660
+ Rt(d, m, c);
1628
1661
  }
1629
1662
  return e;
1630
1663
  }
1631
- function ut(s) {
1632
- return typeof s == "object" && s !== null && s.__type__ === "dotify" && typeof s.__value__ == "string";
1664
+ function Dt(t) {
1665
+ const e = t.startsWith(J) ? J : ke;
1666
+ if (!t.startsWith(e))
1667
+ throw new Error("Invalid DOTIFY path framing");
1668
+ const n = decodeURIComponent(t.slice(e.length)), s = JSON.parse(n);
1669
+ if (Array.isArray(s) && s.length > 0 && s.every((r) => typeof r == "string"))
1670
+ return s;
1671
+ throw new Error("Invalid DOTIFY path framing");
1633
1672
  }
1634
- function ht(s, e, t) {
1635
- const n = {
1636
- ...b,
1673
+ function It(t) {
1674
+ return typeof t == "object" && t !== null && t.__type__ === "dotify" && typeof t.__value__ == "string";
1675
+ }
1676
+ function St(t, e, n) {
1677
+ const s = {
1678
+ ...R,
1637
1679
  ...e
1638
1680
  }, r = {};
1639
- for (const [i, o] of Object.entries(s)) {
1681
+ for (const [i, o] of Object.entries(t)) {
1640
1682
  if (o === void 0) continue;
1641
- const a = n[i];
1642
- r[i] = dt(o, a, t);
1683
+ const a = s[i];
1684
+ r[i] = vt(o, a, n);
1643
1685
  }
1644
1686
  return r;
1645
1687
  }
1646
- function dt(s, e, t) {
1647
- if (typeof s == "function")
1648
- return t.serialize(s);
1649
- const n = e?.serialization ?? U.JSON;
1650
- if (n === U.BASE64 && typeof s == "object") {
1651
- const r = JSON.stringify(s);
1688
+ function vt(t, e, n) {
1689
+ if (typeof t == "function")
1690
+ return n.serialize(t);
1691
+ const s = e?.serialization ?? z.JSON;
1692
+ if (s === z.BASE64 && typeof t == "object") {
1693
+ const r = JSON.stringify(t);
1652
1694
  return {
1653
1695
  __type__: "base64",
1654
1696
  __value__: btoa(encodeURIComponent(r))
1655
1697
  };
1656
1698
  }
1657
- return n === U.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
1699
+ return s === z.DOTIFY && typeof t == "object" && t !== null && !Array.isArray(t) ? {
1658
1700
  __type__: "dotify",
1659
- __value__: Ie(s)
1660
- } : J(s, t);
1701
+ __value__: Ve(t)
1702
+ } : re(t, n);
1661
1703
  }
1662
- function we(s, e, t, n, r, i) {
1704
+ function Ue(t, e, n, s, r, i) {
1663
1705
  const o = {
1664
- ...b,
1706
+ ...R,
1665
1707
  ...e
1666
1708
  }, a = {};
1667
- for (const [c, l] of Object.entries(s)) {
1668
- if (!Ce(c)) continue;
1669
- const h = o[c];
1670
- a[c] = pt(
1709
+ for (const [c, l] of Object.entries(t)) {
1710
+ if (!je(c)) continue;
1711
+ const d = o[c];
1712
+ a[c] = Tt(
1671
1713
  l,
1672
- h,
1673
- t,
1714
+ d,
1674
1715
  n,
1716
+ s,
1675
1717
  r,
1676
1718
  i
1677
1719
  );
1678
1720
  }
1679
1721
  return a;
1680
1722
  }
1681
- function pt(s, e, t, n, r, i) {
1682
- if (ft(s))
1723
+ function Tt(t, e, n, s, r, i) {
1724
+ if (Ut(t))
1683
1725
  try {
1684
- const o = decodeURIComponent(atob(s.__value__));
1726
+ const o = decodeURIComponent(atob(t.__value__));
1685
1727
  return JSON.parse(o);
1686
1728
  } catch {
1687
- return s;
1729
+ return t;
1688
1730
  }
1689
- if (ut(s))
1731
+ if (It(t))
1690
1732
  try {
1691
- return lt(s.__value__);
1733
+ return xt(t.__value__);
1692
1734
  } catch {
1693
- return s;
1735
+ return t;
1694
1736
  }
1695
- return X(s, n, r, i);
1737
+ return ie(t, s, r, i);
1696
1738
  }
1697
- function ft(s) {
1698
- return typeof s == "object" && s !== null && s.__type__ === "base64" && typeof s.__value__ == "string";
1739
+ function Ut(t) {
1740
+ return typeof t == "object" && t !== null && t.__type__ === "base64" && typeof t.__value__ == "string";
1699
1741
  }
1700
- class mt {
1701
- constructor(e, t, n) {
1702
- this.options = e, this.createPropContext = n, this.inputProps = { ...t };
1742
+ class Nt {
1743
+ constructor(e, n, s) {
1744
+ this.options = e, this.createPropContext = s, this.inputProps = { ...n };
1703
1745
  const r = this.inputProps, i = this.createPropContext(r);
1704
- this.props = me(r, this.options.props, i);
1746
+ this.props = Ie(r, this.options.props, i);
1705
1747
  }
1706
1748
  /** Current normalized prop snapshot. */
1707
1749
  props;
@@ -1713,84 +1755,126 @@ class mt {
1713
1755
  * Builds and validates the next props snapshot.
1714
1756
  */
1715
1757
  buildNextProps(e) {
1716
- const t = { ...this.inputProps, ...e }, n = { ...this.props, ...e }, r = this.createPropContext(n), i = me(n, this.options.props, r);
1717
- return ve(i, this.options.props), this.options.validate?.({ props: i }), { nextInputProps: t, nextProps: i };
1758
+ const n = { ...this.inputProps, ...e }, s = { ...this.props, ...e }, r = this.createPropContext(s), i = Ie(s, this.options.props, r);
1759
+ return T(i, this.options.props), this.options.validate?.({ props: i }), { nextInputProps: n, nextProps: i };
1718
1760
  }
1719
1761
  /**
1720
1762
  * Applies a props update and synchronizes it to the host when connected.
1721
1763
  */
1722
- updateProps(e, t) {
1764
+ updateProps(e, n) {
1723
1765
  return this.queuePropsUpdate(async () => {
1724
- const { nextInputProps: n, nextProps: r } = this.buildNextProps(e), i = t.resolveUrl(r), o = t.resolveUrlOrigin(i);
1725
- t.assertStableRenderedOrigin(o), this.inputProps = n, this.props = r, t.isRendered() || t.syncTrustedDomainForUrl(i), t.shouldSendPropsToHost() && await t.sendPropsUpdateToHost(r), t.emitPropsUpdated(r);
1726
- }, t.shouldSendPropsToHost);
1766
+ const { nextInputProps: s, nextProps: r } = this.buildNextProps(e), i = n.resolveUrl(r), o = n.resolveUrlOrigin(i);
1767
+ n.assertStableRenderedOrigin(o), this.inputProps = s, this.props = r, n.isRendered() || n.syncTrustedDomainForUrl(i), n.shouldSendPropsToHost() && await n.sendPropsUpdateToHost(r), n.emitPropsUpdated(r);
1768
+ }, n.shouldSendPropsToHost);
1769
+ }
1770
+ /**
1771
+ * Queues a host synchronization for the current props snapshot.
1772
+ *
1773
+ * @remarks
1774
+ * This shares the same serialization queue as updateProps so function bridge
1775
+ * batches cannot overlap with user-initiated prop updates.
1776
+ */
1777
+ syncCurrentPropsToHost(e) {
1778
+ return this.queuePropsUpdate(async () => {
1779
+ e.shouldSendPropsToHost() && await e.sendPropsUpdateToHost(this.props);
1780
+ }, e.shouldSendPropsToHost);
1727
1781
  }
1728
1782
  /**
1729
1783
  * Queues prop updates when a previous host sync is in flight.
1730
1784
  */
1731
- queuePropsUpdate(e, t) {
1785
+ queuePropsUpdate(e, n) {
1732
1786
  if (!this.pendingPropsUpdate) {
1733
1787
  const r = e();
1734
- return t() && this.trackPendingUpdate(r), r;
1788
+ return n() && this.trackPendingUpdate(r), r;
1735
1789
  }
1736
- const n = this.pendingPropsUpdate.then(e, e);
1737
- return this.trackPendingUpdate(n), n;
1790
+ const s = this.pendingPropsUpdate.then(e, e);
1791
+ return this.trackPendingUpdate(s), s;
1738
1792
  }
1739
1793
  /**
1740
1794
  * Tracks a promise as the active queued update and clears it when settled.
1741
1795
  */
1742
1796
  trackPendingUpdate(e) {
1743
- const t = e.then(
1797
+ const n = e.then(
1744
1798
  () => {
1745
1799
  },
1746
1800
  () => {
1747
1801
  }
1748
1802
  );
1749
- this.pendingPropsUpdate = t, t.finally(() => {
1750
- this.pendingPropsUpdate === t && (this.pendingPropsUpdate = null);
1803
+ this.pendingPropsUpdate = n, n.finally(() => {
1804
+ this.pendingPropsUpdate === n && (this.pendingPropsUpdate = null);
1751
1805
  });
1752
1806
  }
1753
1807
  }
1754
- function x(s, e = "100%") {
1755
- return s === void 0 ? e : typeof s == "number" ? `${s}px` : s;
1808
+ function x(t, e = "100%") {
1809
+ return t === void 0 ? e : typeof t == "number" ? `${t}px` : t;
1756
1810
  }
1757
- function A(s, e) {
1758
- if (s === void 0) return e;
1759
- if (typeof s == "number") return s;
1760
- const t = parseInt(s, 10);
1761
- return isNaN(t) ? e : t;
1811
+ function q(t, e) {
1812
+ if (t === void 0) return e;
1813
+ if (typeof t == "number") return t;
1814
+ const n = parseInt(t, 10);
1815
+ return isNaN(n) ? e : n;
1762
1816
  }
1763
- function gt(s) {
1817
+ function Ft(t) {
1818
+ const { name: e, dimensions: n, attributes: s = {}, style: r = {} } = t, i = document.createElement("iframe");
1819
+ return i.name = e, i.setAttribute("frameborder", "0"), i.setAttribute("allowtransparency", "true"), i.setAttribute("scrolling", "auto"), Ye(i, n), zt(i, s), Mt(i, r), kt(i, s), i;
1820
+ }
1821
+ function Ht(t) {
1764
1822
  try {
1765
- s.src = "about:blank", s.parentNode?.removeChild(s);
1823
+ t.src = "about:blank", t.parentNode?.removeChild(t);
1766
1824
  } catch {
1767
1825
  }
1768
1826
  }
1769
- function yt(s, e) {
1770
- Pt(s, e);
1827
+ function $t(t, e) {
1828
+ Ye(t, e);
1771
1829
  }
1772
- function wt(s) {
1773
- s.style.display = "", s.style.visibility = "visible";
1830
+ function At(t) {
1831
+ t.style.display = "", t.style.visibility = "visible";
1774
1832
  }
1775
- function _e(s) {
1776
- s.style.display = "none", s.style.visibility = "hidden";
1833
+ function Ne(t) {
1834
+ t.style.display = "none", t.style.visibility = "hidden";
1777
1835
  }
1778
- function _t(s) {
1836
+ function Lt(t) {
1779
1837
  try {
1780
- s.focus(), s.contentWindow?.focus();
1838
+ t.focus(), t.contentWindow?.focus();
1781
1839
  } catch {
1782
1840
  }
1783
1841
  }
1784
- function Pt(s, e) {
1785
- e.width !== void 0 && (s.style.width = x(e.width)), e.height !== void 0 && (s.style.height = x(e.height));
1842
+ function Ye(t, e) {
1843
+ e.width !== void 0 && (t.style.width = x(e.width)), e.height !== void 0 && (t.style.height = x(e.height));
1844
+ }
1845
+ function Mt(t, e) {
1846
+ for (const [n, s] of Object.entries(e)) {
1847
+ if (s === void 0) continue;
1848
+ const r = typeof s == "number" ? `${s}px` : s;
1849
+ t.style.setProperty(
1850
+ n.replace(/([A-Z])/g, "-$1").toLowerCase(),
1851
+ r
1852
+ );
1853
+ }
1854
+ }
1855
+ function zt(t, e) {
1856
+ for (const [n, s] of Object.entries(e))
1857
+ if (s !== void 0) {
1858
+ if (typeof s == "boolean") {
1859
+ s && t.setAttribute(n, "");
1860
+ continue;
1861
+ }
1862
+ t.setAttribute(n, s);
1863
+ }
1786
1864
  }
1787
- class De extends Error {
1865
+ function kt(t, e) {
1866
+ e.sandbox === void 0 && t.setAttribute(
1867
+ "sandbox",
1868
+ "allow-scripts allow-same-origin allow-forms allow-popups"
1869
+ );
1870
+ }
1871
+ class Je extends Error {
1788
1872
  constructor(e = "Popup blocked by browser") {
1789
1873
  super(e), this.name = "PopupOpenError";
1790
1874
  }
1791
1875
  }
1792
- function Et(s) {
1793
- const { url: e, name: t, dimensions: n } = s, r = A(n.width, 500), i = A(n.height, 500), o = Math.floor(window.screenX + (window.outerWidth - r) / 2), a = Math.floor(window.screenY + (window.outerHeight - i) / 2), c = [
1876
+ function Wt(t) {
1877
+ const { url: e, name: n, dimensions: s } = t, r = q(s.width, 500), i = q(s.height, 500), o = Math.floor(window.screenX + (window.outerWidth - r) / 2), a = Math.floor(window.screenY + (window.outerHeight - i) / 2), c = [
1794
1878
  `width=${r}`,
1795
1879
  `height=${i}`,
1796
1880
  `left=${o}`,
@@ -1802,51 +1886,51 @@ function Et(s) {
1802
1886
  "status=no",
1803
1887
  "resizable=yes",
1804
1888
  "scrollbars=yes"
1805
- ].join(","), l = window.open(e, t, c);
1806
- if (!l || Rt(l))
1807
- throw new De();
1889
+ ].join(","), l = window.open(e, n, c);
1890
+ if (!l || Vt(l))
1891
+ throw new Je();
1808
1892
  return l;
1809
1893
  }
1810
- function bt(s) {
1894
+ function jt(t) {
1811
1895
  try {
1812
- s.closed || s.close();
1896
+ t.closed || t.close();
1813
1897
  } catch {
1814
1898
  }
1815
1899
  }
1816
- function xt(s) {
1900
+ function Bt(t) {
1817
1901
  try {
1818
- s.closed || s.focus();
1902
+ t.closed || t.focus();
1819
1903
  } catch {
1820
1904
  }
1821
1905
  }
1822
- function Rt(s) {
1823
- if (!s) return !0;
1906
+ function Vt(t) {
1907
+ if (!t) return !0;
1824
1908
  try {
1825
- return !!(s.closed || s.innerHeight === 0 || s.innerWidth === 0);
1909
+ return !!(t.closed || t.innerHeight === 0 || t.innerWidth === 0);
1826
1910
  } catch {
1827
1911
  return !0;
1828
1912
  }
1829
1913
  }
1830
- function Ot(s, e, t = {}) {
1914
+ function Yt(t, e, n = {}) {
1831
1915
  const {
1832
- initialInterval: n = 100,
1916
+ initialInterval: s = 100,
1833
1917
  // Start fast to catch quick closes
1834
1918
  maxInterval: r = 2e3,
1835
1919
  // Cap at 2 seconds
1836
1920
  multiplier: i = 1.5
1837
1921
  // Exponential backoff multiplier
1838
- } = t;
1839
- let o = n, a, c = !1;
1922
+ } = n;
1923
+ let o = s, a, c = !1;
1840
1924
  const l = () => {
1841
1925
  try {
1842
1926
  e();
1843
- } catch (f) {
1844
- console.error("Error in popup close callback:", f);
1927
+ } catch (m) {
1928
+ console.error("Error in popup close callback:", m);
1845
1929
  }
1846
- }, h = () => {
1930
+ }, d = () => {
1847
1931
  if (!c) {
1848
1932
  try {
1849
- if (s.closed) {
1933
+ if (t.closed) {
1850
1934
  l();
1851
1935
  return;
1852
1936
  }
@@ -1854,59 +1938,59 @@ function Ot(s, e, t = {}) {
1854
1938
  l();
1855
1939
  return;
1856
1940
  }
1857
- o = Math.min(o * i, r), a = setTimeout(h, o);
1941
+ o = Math.min(o * i, r), a = setTimeout(d, o);
1858
1942
  }
1859
1943
  };
1860
- return a = setTimeout(h, o), () => {
1944
+ return a = setTimeout(d, o), () => {
1861
1945
  c = !0, clearTimeout(a);
1862
1946
  };
1863
1947
  }
1864
- function vt(s, e) {
1948
+ function Jt(t, e) {
1865
1949
  try {
1866
- const t = A(e.width, s.outerWidth), n = A(
1950
+ const n = q(e.width, t.outerWidth), s = q(
1867
1951
  e.height,
1868
- s.outerHeight
1952
+ t.outerHeight
1869
1953
  );
1870
- s.resizeTo(t, n);
1954
+ t.resizeTo(n, s);
1871
1955
  } catch {
1872
1956
  }
1873
1957
  }
1874
- const Pe = "forgeframe-spinner-style";
1875
- function St(s, e) {
1876
- const t = s.getElementById(Pe);
1877
- if (t) {
1878
- const r = t.getAttribute("nonce");
1958
+ const Fe = "forgeframe-spinner-style";
1959
+ function qt(t, e) {
1960
+ const n = t.getElementById(Fe);
1961
+ if (n) {
1962
+ const r = n.getAttribute("nonce");
1879
1963
  if (!e || r === e)
1880
1964
  return;
1881
- t.remove();
1965
+ n.remove();
1882
1966
  }
1883
- const n = s.createElement("style");
1884
- n.id = Pe, e && n.setAttribute("nonce", e), n.textContent = `
1967
+ const s = t.createElement("style");
1968
+ s.id = Fe, e && s.setAttribute("nonce", e), s.textContent = `
1885
1969
  @keyframes forgeframe-spin {
1886
1970
  to { transform: rotate(360deg); }
1887
1971
  }
1888
- `, (s.head ?? s.documentElement).appendChild(n);
1972
+ `, (t.head ?? t.documentElement).appendChild(s);
1889
1973
  }
1890
- function Ct(s) {
1891
- const { doc: e, dimensions: t, uid: n, tag: r } = s, i = e.createElement("div");
1892
- return i.id = `forgeframe-container-${n}`, i.setAttribute("data-forgeframe-tag", r), Object.assign(i.style, {
1974
+ function Kt(t) {
1975
+ const { doc: e, dimensions: n, uid: s, tag: r } = t, i = e.createElement("div");
1976
+ return i.id = `forgeframe-container-${s}`, i.setAttribute("data-forgeframe-tag", r), Object.assign(i.style, {
1893
1977
  display: "inline-block",
1894
1978
  position: "relative",
1895
- width: x(t.width),
1896
- height: x(t.height),
1979
+ width: x(n.width),
1980
+ height: x(n.height),
1897
1981
  overflow: "hidden"
1898
1982
  }), i;
1899
1983
  }
1900
- function It(s) {
1901
- const { doc: e, dimensions: t, cspNonce: n } = s;
1902
- St(e, n);
1984
+ function Xt(t) {
1985
+ const { doc: e, dimensions: n, cspNonce: s } = t;
1986
+ qt(e, s);
1903
1987
  const r = e.createElement("div");
1904
1988
  Object.assign(r.style, {
1905
1989
  display: "flex",
1906
1990
  alignItems: "center",
1907
1991
  justifyContent: "center",
1908
- width: x(t.width),
1909
- height: x(t.height),
1992
+ width: x(n.width),
1993
+ height: x(n.height),
1910
1994
  backgroundColor: "#f5f5f5",
1911
1995
  position: "absolute",
1912
1996
  top: "0",
@@ -1923,22 +2007,22 @@ function It(s) {
1923
2007
  animation: "forgeframe-spin 1s linear infinite"
1924
2008
  }), r.appendChild(i), r;
1925
2009
  }
1926
- function Dt(s, e = 200) {
1927
- return new Promise((t) => {
1928
- s.style.opacity = "0", s.style.transition = `opacity ${e}ms ease-in`, s.offsetHeight, s.style.opacity = "1", setTimeout(t, e);
2010
+ function Gt(t, e = 200) {
2011
+ return new Promise((n) => {
2012
+ t.style.opacity = "0", t.style.transition = `opacity ${e}ms ease-in`, t.offsetHeight, t.style.opacity = "1", setTimeout(n, e);
1929
2013
  });
1930
2014
  }
1931
- function Tt(s, e = 200) {
1932
- return new Promise((t) => {
1933
- s.style.transition = `opacity ${e}ms ease-out`, s.style.opacity = "0", setTimeout(t, e);
2015
+ function Zt(t, e = 200) {
2016
+ return new Promise((n) => {
2017
+ t.style.transition = `opacity ${e}ms ease-out`, t.style.opacity = "0", setTimeout(n, e);
1934
2018
  });
1935
2019
  }
1936
- async function Ut(s, e, t) {
1937
- e && (await Tt(e, 150), e.remove()), t.style.display = "", t.style.visibility = "visible", t.style.opacity = "0", await Dt(t, 150);
2020
+ async function Qt(t, e, n) {
2021
+ e && (await Zt(e, 150), e.remove()), n.style.display = "", n.style.visibility = "visible", n.style.opacity = "0", await Gt(n, 150);
1938
2022
  }
1939
- class Nt {
1940
- constructor(e, t, n, r, i) {
1941
- this.options = e, this.uid = t, this.getProps = n, this.resolveDimensions = r, this.callbacks = i, this.context = this.options.defaultContext;
2023
+ class en {
2024
+ constructor(e, n, s, r, i) {
2025
+ this.options = e, this.uid = n, this.getProps = s, this.resolveDimensions = r, this.callbacks = i, this.context = this.options.defaultContext;
1942
2026
  }
1943
2027
  /** Active rendering context. */
1944
2028
  context;
@@ -1948,6 +2032,8 @@ class Nt {
1948
2032
  container = null;
1949
2033
  /** Prerender element currently displayed while host initializes. */
1950
2034
  prerenderElement = null;
2035
+ /** Wrapper element created and owned by the renderer. */
2036
+ ownedContainer = null;
1951
2037
  /**
1952
2038
  * Resolves a container selector or element to an HTMLElement.
1953
2039
  */
@@ -1955,92 +2041,92 @@ class Nt {
1955
2041
  if (!e)
1956
2042
  throw new Error("Container is required for rendering");
1957
2043
  if (typeof e == "string") {
1958
- const t = document.querySelector(e);
1959
- if (!t)
2044
+ const n = document.querySelector(e);
2045
+ if (!n)
1960
2046
  throw new Error(`Container "${e}" not found`);
1961
- return t;
2047
+ return n;
1962
2048
  }
1963
2049
  return e;
1964
2050
  }
1965
2051
  /**
1966
2052
  * Creates and displays prerender/loading content.
1967
2053
  */
1968
- async prerender(e, t) {
2054
+ async prerender(e, n) {
1969
2055
  if (!this.container) return;
1970
- const n = this.getProps(), r = this.options.prerenderTemplate ?? It, i = this.options.containerTemplate ?? Ct, o = this.resolveDimensions(), a = n.cspNonce;
1971
- if (this.context === m.IFRAME) {
1972
- const f = t();
1973
- this.iframe = e(f), _e(this.iframe);
2056
+ const s = this.container;
2057
+ this.ownedContainer = null;
2058
+ const r = this.getProps(), i = this.options.prerenderTemplate ?? Xt, o = this.options.containerTemplate ?? Kt, a = this.resolveDimensions(), c = r.cspNonce;
2059
+ if (this.context === f.IFRAME) {
2060
+ const h = n();
2061
+ this.iframe = e(h), Ne(this.iframe);
1974
2062
  }
1975
- const c = {
2063
+ const l = {
1976
2064
  uid: this.uid,
1977
2065
  tag: this.options.tag,
1978
2066
  context: this.context,
1979
- dimensions: o,
1980
- props: n,
2067
+ dimensions: a,
2068
+ props: r,
1981
2069
  doc: document,
1982
- container: this.container,
2070
+ container: s,
1983
2071
  frame: this.iframe,
1984
2072
  prerenderFrame: null,
1985
2073
  close: () => this.callbacks.close(),
1986
2074
  focus: () => this.callbacks.focus(),
1987
- cspNonce: a
2075
+ cspNonce: c
1988
2076
  };
1989
- this.prerenderElement = r(c);
1990
- const l = {
2077
+ this.prerenderElement = i(l);
2078
+ const d = {
1991
2079
  uid: this.uid,
1992
2080
  tag: this.options.tag,
1993
2081
  context: this.context,
1994
- dimensions: o,
1995
- props: n,
2082
+ dimensions: a,
2083
+ props: r,
1996
2084
  doc: document,
1997
- container: this.container,
2085
+ container: s,
1998
2086
  frame: this.iframe,
1999
2087
  prerenderFrame: this.prerenderElement,
2000
2088
  close: () => this.callbacks.close(),
2001
2089
  focus: () => this.callbacks.focus(),
2002
- cspNonce: a
2003
- }, h = i(l);
2004
- h && (this.container.appendChild(h), this.container = h), this.prerenderElement && !this.prerenderElement.parentNode && this.container.appendChild(this.prerenderElement), this.iframe && !this.iframe.parentNode && this.container.appendChild(this.iframe);
2090
+ cspNonce: c
2091
+ }, m = o(d);
2092
+ if (m) {
2093
+ if (m !== s) {
2094
+ const h = !m.parentNode;
2095
+ s.appendChild(m), h && (this.ownedContainer = m);
2096
+ }
2097
+ this.container = m;
2098
+ }
2099
+ this.prerenderElement && !this.prerenderElement.parentNode && this.container.appendChild(this.prerenderElement), this.iframe && !this.iframe.parentNode && this.container.appendChild(this.iframe);
2005
2100
  }
2006
2101
  /**
2007
2102
  * Creates an iframe element without setting src (for prerender phase).
2008
2103
  */
2009
2104
  createIframeElement(e) {
2010
- const t = document.createElement("iframe"), n = this.resolveDimensions(), r = this.getProps(), i = typeof this.options.attributes == "function" ? this.options.attributes(r) : this.options.attributes ?? {}, o = typeof this.options.style == "function" ? this.options.style(r) : this.options.style ?? {};
2011
- t.name = e, t.setAttribute("frameborder", "0"), t.setAttribute("allowtransparency", "true"), t.setAttribute("scrolling", "auto"), n.width !== void 0 && (t.style.width = typeof n.width == "number" ? `${n.width}px` : n.width), n.height !== void 0 && (t.style.height = typeof n.height == "number" ? `${n.height}px` : n.height);
2012
- for (const [a, c] of Object.entries(i))
2013
- c !== void 0 && (typeof c == "boolean" ? c && t.setAttribute(a, "") : t.setAttribute(a, c));
2014
- for (const [a, c] of Object.entries(o)) {
2015
- if (c === void 0) continue;
2016
- const l = typeof c == "number" ? `${c}px` : c;
2017
- t.style.setProperty(
2018
- a.replace(/([A-Z])/g, "-$1").toLowerCase(),
2019
- String(l)
2020
- );
2021
- }
2022
- return i.sandbox || t.setAttribute(
2023
- "sandbox",
2024
- "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"
2025
- ), t;
2105
+ const n = this.resolveDimensions(), s = this.getProps(), r = typeof this.options.attributes == "function" ? this.options.attributes(s) : this.options.attributes ?? {}, i = typeof this.options.style == "function" ? this.options.style(s) : this.options.style ?? {};
2106
+ return Ft({
2107
+ name: e,
2108
+ dimensions: n,
2109
+ attributes: r,
2110
+ style: i
2111
+ });
2026
2112
  }
2027
2113
  /**
2028
2114
  * Opens host content in iframe or popup context.
2029
2115
  */
2030
2116
  open(e) {
2031
- const t = e.buildUrl(e.baseUrl), n = e.buildBodyParams(), r = n.toString().length > 0;
2032
- if (this.context === m.IFRAME) {
2117
+ const n = e.buildUrl(e.baseUrl), s = e.buildBodyParams(), r = s.toString().length > 0;
2118
+ if (this.context === f.IFRAME) {
2033
2119
  if (!this.iframe)
2034
2120
  throw new Error("Iframe not created during prerender");
2035
- return r ? e.submitBodyForm(this.iframe.name, t, n) : this.iframe.src = t, this.iframe.contentWindow;
2121
+ return r ? e.submitBodyForm(this.iframe.name, n, s) : this.iframe.src = n, this.iframe.contentWindow;
2036
2122
  }
2037
- const i = e.buildWindowName(), o = Et({
2038
- url: r ? "about:blank" : t,
2123
+ const i = e.buildWindowName(), o = Wt({
2124
+ url: r ? "about:blank" : n,
2039
2125
  name: i,
2040
2126
  dimensions: this.resolveDimensions()
2041
2127
  });
2042
- r && e.submitBodyForm(i, t, n);
2043
- const a = Ot(o, () => {
2128
+ r && e.submitBodyForm(i, n, s);
2129
+ const a = Yt(o, () => {
2044
2130
  e.onPopupClose();
2045
2131
  });
2046
2132
  return e.registerCleanup(a), o;
@@ -2049,18 +2135,18 @@ class Nt {
2049
2135
  * Swaps prerender content with the live iframe after host initialization.
2050
2136
  */
2051
2137
  async swapPrerenderContentIfNeeded() {
2052
- this.context === m.IFRAME && this.iframe && this.container && (await Ut(this.container, this.prerenderElement, this.iframe), this.prerenderElement = null);
2138
+ this.context === f.IFRAME && this.iframe && this.container && (await Qt(this.container, this.prerenderElement, this.iframe), this.prerenderElement = null);
2053
2139
  }
2054
2140
  /**
2055
2141
  * Submits a hidden form to navigate a target window via POST.
2056
2142
  */
2057
- submitBodyForm(e, t, n) {
2143
+ submitBodyForm(e, n, s) {
2058
2144
  const r = this.container?.ownerDocument ?? document, i = r.body ?? r.documentElement;
2059
2145
  if (!i)
2060
2146
  throw new Error("Document root is unavailable for bodyParam form submission");
2061
2147
  const o = r.createElement("form");
2062
- o.method = "POST", o.action = t, o.target = e, o.style.display = "none";
2063
- for (const [a, c] of n.entries()) {
2148
+ o.method = "POST", o.action = n, o.target = e, o.style.display = "none";
2149
+ for (const [a, c] of s.entries()) {
2064
2150
  const l = r.createElement("input");
2065
2151
  l.type = "hidden", l.name = a, l.value = c, o.appendChild(l);
2066
2152
  }
@@ -2075,81 +2161,95 @@ class Nt {
2075
2161
  * Focuses iframe/popup context.
2076
2162
  */
2077
2163
  focus(e) {
2078
- this.context === m.IFRAME && this.iframe ? _t(this.iframe) : this.context === m.POPUP && e && xt(e);
2164
+ this.context === f.IFRAME && this.iframe ? Lt(this.iframe) : this.context === f.POPUP && e && Bt(e);
2079
2165
  }
2080
2166
  /**
2081
2167
  * Resizes iframe/popup context.
2082
2168
  */
2083
- resize(e, t) {
2084
- this.context === m.IFRAME && this.iframe ? yt(this.iframe, e) : this.context === m.POPUP && t && vt(t, e);
2169
+ resize(e, n) {
2170
+ this.context === f.IFRAME && this.iframe ? $t(this.iframe, e) : this.context === f.POPUP && n && Jt(n, e);
2085
2171
  }
2086
2172
  /**
2087
2173
  * Shows iframe context.
2088
2174
  */
2089
2175
  show() {
2090
- this.context === m.IFRAME && this.iframe && wt(this.iframe);
2176
+ this.context === f.IFRAME && this.iframe && At(this.iframe);
2091
2177
  }
2092
2178
  /**
2093
2179
  * Hides iframe context.
2094
2180
  */
2095
2181
  hide() {
2096
- this.context === m.IFRAME && this.iframe && _e(this.iframe);
2182
+ this.context === f.IFRAME && this.iframe && Ne(this.iframe);
2097
2183
  }
2098
2184
  /**
2099
2185
  * Destroys rendered iframe/popup DOM artifacts.
2100
2186
  */
2101
2187
  destroy(e) {
2102
- this.iframe && (gt(this.iframe), this.iframe = null), this.context === m.POPUP && e && bt(e), this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null);
2188
+ this.iframe && (Ht(this.iframe), this.iframe = null), this.context === f.POPUP && e && jt(e), this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null), this.ownedContainer && (this.ownedContainer.remove(), this.ownedContainer = null), this.container = null;
2103
2189
  }
2104
2190
  }
2105
- const Y = "forgeframe:";
2106
- function j(s) {
2107
- return Y + JSON.stringify(s);
2191
+ const oe = "forgeframe:";
2192
+ function ee(t) {
2193
+ return oe + JSON.stringify(t);
2108
2194
  }
2109
- function Ft(s) {
2110
- if (typeof s != "string" || !s.startsWith(Y)) return null;
2195
+ function tn(t) {
2196
+ if (typeof t != "string" || !t.startsWith(oe)) return null;
2111
2197
  try {
2112
- const e = s.slice(Y.length), t = JSON.parse(e);
2113
- return !t.id || !t.type || !t.name || !t.source ? null : t;
2198
+ const e = t.slice(oe.length), n = JSON.parse(e);
2199
+ return !n.id || !n.type || !n.name || !n.source ? null : n;
2114
2200
  } catch {
2115
2201
  return null;
2116
2202
  }
2117
2203
  }
2118
- function Ee(s, e, t, n) {
2204
+ function He(t, e, n, s) {
2119
2205
  return {
2120
- id: s,
2121
- type: F.REQUEST,
2206
+ id: t,
2207
+ type: W.REQUEST,
2122
2208
  name: e,
2123
- data: t,
2124
- source: n
2209
+ data: n,
2210
+ source: s
2125
2211
  };
2126
2212
  }
2127
- function Ht(s, e, t, n) {
2213
+ function nn(t, e, n, s) {
2128
2214
  return {
2129
- id: s,
2130
- type: F.RESPONSE,
2215
+ id: t,
2216
+ type: W.RESPONSE,
2131
2217
  name: "response",
2132
2218
  data: e,
2133
- source: t,
2134
- error: n ? {
2135
- message: n.message,
2136
- stack: n.stack
2219
+ source: n,
2220
+ error: s ? {
2221
+ message: s.message,
2222
+ stack: s.stack
2137
2223
  } : void 0
2138
2224
  };
2139
2225
  }
2140
- function $t(s) {
2141
- return s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2226
+ function sn(t) {
2227
+ return t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2142
2228
  }
2143
- function Lt(s) {
2144
- if (!s.includes("*"))
2229
+ function rn(t) {
2230
+ if (!t.includes("*"))
2145
2231
  return null;
2146
- const e = s.split("*").map((t) => $t(t)).join(".*");
2232
+ const e = t.split("*").map((n) => sn(n)).join(".*");
2147
2233
  return new RegExp(`^${e}$`);
2148
2234
  }
2149
- function At(s, e) {
2150
- return s.global || s.sticky ? new RegExp(s.source, s.flags.replace(/[gy]/g, "")).test(e) : s.test(e);
2235
+ function on(t, e) {
2236
+ return t.global || t.sticky ? new RegExp(t.source, t.flags.replace(/[gy]/g, "")).test(e) : t.test(e);
2237
+ }
2238
+ function an(t, e, n) {
2239
+ return e !== t.targetWin ? !1 : t.expectedOrigin === "*" ? !0 : n === t.expectedOrigin;
2240
+ }
2241
+ function cn(t, e) {
2242
+ if (t === "*")
2243
+ return "*";
2244
+ if (t === "/")
2245
+ return e;
2246
+ try {
2247
+ return new URL(t, e).origin;
2248
+ } catch {
2249
+ return t;
2250
+ }
2151
2251
  }
2152
- class Te {
2252
+ class qe {
2153
2253
  /**
2154
2254
  * Creates a new Messenger instance.
2155
2255
  *
@@ -2158,8 +2258,8 @@ class Te {
2158
2258
  * @param domain - The origin domain of this messenger
2159
2259
  * @param trustedDomains - Optional domains to trust for incoming messages
2160
2260
  */
2161
- constructor(e, t = window, n = window.location.origin, r) {
2162
- this.uid = e, this.win = t, this.domain = n, this.allowedOrigins.add(n), r && this.addTrustedDomain(r), this.setupListener();
2261
+ constructor(e, n = window, s = window.location.origin, r) {
2262
+ this.uid = e, this.win = n, this.domain = s, this.allowedOrigins.add(s), r && this.addTrustedDomain(r), this.setupListener();
2163
2263
  }
2164
2264
  /** @internal */
2165
2265
  pending = /* @__PURE__ */ new Map();
@@ -2184,13 +2284,13 @@ class Te {
2184
2284
  */
2185
2285
  addTrustedDomain(e) {
2186
2286
  if (Array.isArray(e))
2187
- for (const t of e)
2188
- this.addTrustedDomain(t);
2287
+ for (const n of e)
2288
+ this.addTrustedDomain(n);
2189
2289
  else if (e instanceof RegExp)
2190
2290
  this.allowedOriginPatterns.push(e);
2191
2291
  else {
2192
- const t = Lt(e);
2193
- t ? this.wildcardPatternRegistry.has(e) || (this.wildcardPatternRegistry.set(e, t), this.allowedOriginPatterns.push(t)) : this.allowedOrigins.add(e);
2292
+ const n = rn(e);
2293
+ n ? this.wildcardPatternRegistry.has(e) || (this.wildcardPatternRegistry.set(e, n), this.allowedOriginPatterns.push(n)) : this.allowedOrigins.add(e);
2194
2294
  }
2195
2295
  }
2196
2296
  /**
@@ -2200,14 +2300,14 @@ class Te {
2200
2300
  */
2201
2301
  removeTrustedDomain(e) {
2202
2302
  if (Array.isArray(e))
2203
- for (const t of e)
2204
- this.removeTrustedDomain(t);
2303
+ for (const n of e)
2304
+ this.removeTrustedDomain(n);
2205
2305
  else if (e instanceof RegExp)
2206
- this.allowedOriginPatterns = this.allowedOriginPatterns.filter((t) => t !== e);
2306
+ this.allowedOriginPatterns = this.allowedOriginPatterns.filter((n) => n !== e);
2207
2307
  else {
2208
- const t = this.wildcardPatternRegistry.get(e);
2209
- t && (this.allowedOriginPatterns = this.allowedOriginPatterns.filter(
2210
- (n) => n !== t
2308
+ const n = this.wildcardPatternRegistry.get(e);
2309
+ n && (this.allowedOriginPatterns = this.allowedOriginPatterns.filter(
2310
+ (s) => s !== n
2211
2311
  ), this.wildcardPatternRegistry.delete(e)), this.allowedOrigins.delete(e);
2212
2312
  }
2213
2313
  }
@@ -2221,8 +2321,8 @@ class Te {
2221
2321
  isOriginTrusted(e) {
2222
2322
  if (this.allowedOrigins.has(e))
2223
2323
  return !0;
2224
- for (const t of this.allowedOriginPatterns)
2225
- if (At(t, e))
2324
+ for (const n of this.allowedOriginPatterns)
2325
+ if (on(n, e))
2226
2326
  return !0;
2227
2327
  return !1;
2228
2328
  }
@@ -2230,12 +2330,12 @@ class Te {
2230
2330
  * Resolves source identity from the browser event context.
2231
2331
  * @internal
2232
2332
  */
2233
- resolveVerifiedSource(e, t, n) {
2333
+ resolveVerifiedSource(e, n, s) {
2234
2334
  const r = e, i = this.sourceUidRegistry.get(r);
2235
2335
  if (i)
2236
- return { uid: i, domain: t };
2237
- const o = n && typeof n.uid == "string" && n.uid.length > 0 ? n.uid : N();
2238
- return this.sourceUidRegistry.set(r, o), { uid: o, domain: t };
2336
+ return { uid: i, domain: n };
2337
+ const o = s && typeof s.uid == "string" && s.uid.length > 0 ? s.uid : k();
2338
+ return this.sourceUidRegistry.set(r, o), { uid: o, domain: n };
2239
2339
  }
2240
2340
  /**
2241
2341
  * Sends a message and waits for a response.
@@ -2250,23 +2350,25 @@ class Te {
2250
2350
  * @returns Promise resolving to the response data
2251
2351
  * @throws Error if messenger is destroyed or timeout occurs
2252
2352
  */
2253
- async send(e, t, n, r, i = 1e4) {
2353
+ async send(e, n, s, r, i = 1e4) {
2254
2354
  if (this.destroyed)
2255
2355
  throw new Error("Messenger has been destroyed");
2256
- const o = N(), a = Ee(o, n, r, {
2356
+ const o = k(), a = He(o, s, r, {
2257
2357
  uid: this.uid,
2258
2358
  domain: this.domain
2259
- }), c = Oe(), l = setTimeout(() => {
2260
- this.pending.delete(o), c.reject(new Error(`Message "${n}" timed out after ${i}ms`));
2359
+ }), c = Le(), l = setTimeout(() => {
2360
+ this.pending.delete(o), c.reject(new Error(`Message "${s}" timed out after ${i}ms`));
2261
2361
  }, i);
2262
2362
  this.pending.set(o, {
2263
2363
  deferred: c,
2264
- timeout: l
2364
+ timeout: l,
2365
+ targetWin: e,
2366
+ expectedOrigin: cn(n, this.domain)
2265
2367
  });
2266
2368
  try {
2267
- e.postMessage(j(a), t);
2268
- } catch (h) {
2269
- throw this.pending.delete(o), clearTimeout(l), h;
2369
+ e.postMessage(ee(a), n);
2370
+ } catch (d) {
2371
+ throw this.pending.delete(o), clearTimeout(l), d;
2270
2372
  }
2271
2373
  return c.promise;
2272
2374
  }
@@ -2280,14 +2382,14 @@ class Te {
2280
2382
  * @param data - Optional data payload
2281
2383
  * @throws Error if messenger is destroyed
2282
2384
  */
2283
- post(e, t, n, r) {
2385
+ post(e, n, s, r) {
2284
2386
  if (this.destroyed)
2285
2387
  throw new Error("Messenger has been destroyed");
2286
- const i = N(), o = Ee(i, n, r, {
2388
+ const i = k(), o = He(i, s, r, {
2287
2389
  uid: this.uid,
2288
2390
  domain: this.domain
2289
2391
  });
2290
- e.postMessage(j(o), t);
2392
+ e.postMessage(ee(o), n);
2291
2393
  }
2292
2394
  /**
2293
2395
  * Registers a handler for incoming messages of a specific type.
@@ -2298,8 +2400,8 @@ class Te {
2298
2400
  * @param handler - The handler function
2299
2401
  * @returns Function to unregister the handler
2300
2402
  */
2301
- on(e, t) {
2302
- return this.handlers.set(e, t), () => this.handlers.delete(e);
2403
+ on(e, n) {
2404
+ return this.handlers.set(e, n), () => this.handlers.delete(e);
2303
2405
  }
2304
2406
  /**
2305
2407
  * Sets up the postMessage event listener.
@@ -2309,50 +2411,53 @@ class Te {
2309
2411
  this.listener = (e) => {
2310
2412
  if (e.source === this.win || !this.isOriginTrusted(e.origin))
2311
2413
  return;
2312
- const t = Ft(e.data);
2313
- if (!t) return;
2314
- const n = e.source;
2315
- !n || typeof n.postMessage != "function" || this.handleMessage(t, n, e.origin);
2414
+ const n = tn(e.data);
2415
+ if (!n) return;
2416
+ const s = e.source;
2417
+ !s || typeof s.postMessage != "function" || this.handleMessage(n, s, e.origin);
2316
2418
  }, this.win.addEventListener("message", this.listener);
2317
2419
  }
2318
2420
  /**
2319
2421
  * Processes a received message.
2320
2422
  * @internal
2321
2423
  */
2322
- async handleMessage(e, t, n) {
2323
- if (e.type === F.RESPONSE) {
2424
+ async handleMessage(e, n, s) {
2425
+ if (e.type === W.RESPONSE) {
2324
2426
  const r = this.pending.get(e.id);
2325
- if (r)
2427
+ if (r) {
2428
+ if (!an(r, n, s))
2429
+ return;
2326
2430
  if (this.pending.delete(e.id), clearTimeout(r.timeout), e.error) {
2327
2431
  const i = new Error(e.error.message);
2328
2432
  i.stack = e.error.stack, r.deferred.reject(i);
2329
2433
  } else
2330
2434
  r.deferred.resolve(e.data);
2435
+ }
2331
2436
  return;
2332
2437
  }
2333
- if (e.type === F.REQUEST) {
2438
+ if (e.type === W.REQUEST) {
2334
2439
  const r = this.handlers.get(e.name);
2335
2440
  if (!r)
2336
2441
  return;
2337
2442
  let i, o;
2338
2443
  try {
2339
2444
  const c = this.resolveVerifiedSource(
2340
- t,
2341
2445
  n,
2446
+ s,
2342
2447
  e.source
2343
2448
  );
2344
2449
  i = await r(e.data, c);
2345
2450
  } catch (c) {
2346
2451
  o = c instanceof Error ? c : new Error(String(c));
2347
2452
  }
2348
- const a = Ht(
2453
+ const a = nn(
2349
2454
  e.id,
2350
2455
  i,
2351
2456
  { uid: this.uid, domain: this.domain },
2352
2457
  o
2353
2458
  );
2354
2459
  try {
2355
- t.postMessage(j(a), n);
2460
+ n.postMessage(ee(a), s);
2356
2461
  } catch {
2357
2462
  }
2358
2463
  }
@@ -2381,67 +2486,105 @@ class Te {
2381
2486
  return this.destroyed;
2382
2487
  }
2383
2488
  }
2384
- const be = 32 * 1024;
2385
- function zt(s) {
2386
- const e = kt(s);
2387
- return `${H}${e}`;
2489
+ const ln = [
2490
+ "init",
2491
+ "close",
2492
+ "resize",
2493
+ "show",
2494
+ "hide",
2495
+ "onError",
2496
+ "updateProps",
2497
+ "export"
2498
+ ], $e = 32 * 1024;
2499
+ function un(t) {
2500
+ const e = gn(t);
2501
+ return `${j}${e}`;
2388
2502
  }
2389
- function Ue(s) {
2390
- if (!s || !s.startsWith(H))
2503
+ function Ke(t) {
2504
+ if (!t || !t.startsWith(j))
2391
2505
  return null;
2392
- const e = s.slice(H.length);
2393
- return Mt(e);
2506
+ const e = t.slice(j.length);
2507
+ return yn(e);
2508
+ }
2509
+ function C(t) {
2510
+ return typeof t == "object" && t !== null;
2511
+ }
2512
+ function hn(t) {
2513
+ return C(t);
2514
+ }
2515
+ function dn(t) {
2516
+ return C(t) && ln.every(
2517
+ (e) => typeof t[e] == "string" && t[e].length > 0
2518
+ );
2519
+ }
2520
+ function pn(t) {
2521
+ if (!C(t) || typeof t.tag != "string" || t.tag.length === 0 || typeof t.url != "string" || t.url.length === 0 || t.props !== void 0 && !C(t.props) || t.defaultContext !== void 0 && t.defaultContext !== f.IFRAME && t.defaultContext !== f.POPUP)
2522
+ return !1;
2523
+ if (t.dimensions !== void 0) {
2524
+ if (!C(t.dimensions))
2525
+ return !1;
2526
+ const { width: e, height: n } = t.dimensions;
2527
+ if (e !== void 0 && typeof e != "string" && typeof e != "number" || n !== void 0 && typeof n != "string" && typeof n != "number")
2528
+ return !1;
2529
+ }
2530
+ return !0;
2394
2531
  }
2395
- function ie(s = window) {
2532
+ function fn(t) {
2533
+ return C(t) ? Object.values(t).every((e) => pn(e)) : !1;
2534
+ }
2535
+ function mn(t) {
2536
+ return !(!C(t) || typeof t.uid != "string" || t.uid.length === 0 || typeof t.tag != "string" || t.tag.length === 0 || typeof t.version != "string" || t.version.length === 0 || t.version !== ae || t.context !== f.IFRAME && t.context !== f.POPUP || typeof t.consumerDomain != "string" || t.consumerDomain.length === 0 || !hn(t.props) || !dn(t.exports) || t.children !== void 0 && !fn(t.children));
2537
+ }
2538
+ function ge(t = window) {
2396
2539
  try {
2397
- return s.name.startsWith(H);
2540
+ return t.name.startsWith(j);
2398
2541
  } catch {
2399
2542
  return !1;
2400
2543
  }
2401
2544
  }
2402
- function V(s, e = window) {
2403
- return Ue(e.name)?.tag === s;
2545
+ function te(t, e = window) {
2546
+ return Ke(e.name)?.tag === t;
2404
2547
  }
2405
- function kt(s) {
2548
+ function gn(t) {
2406
2549
  try {
2407
- const e = JSON.stringify(s), t = btoa(encodeURIComponent(e)), n = new Blob([t]).size;
2408
- if (n > be)
2550
+ const e = JSON.stringify(t), n = btoa(encodeURIComponent(e)), s = new Blob([n]).size;
2551
+ if (s > $e)
2409
2552
  throw new Error(
2410
- `Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${be / 1024}KB). Consider reducing the amount of data passed via props.`
2553
+ `Payload size (${Math.round(s / 1024)}KB) exceeds maximum allowed size (${$e / 1024}KB). Consider reducing the amount of data passed via props.`
2411
2554
  );
2412
- return t;
2555
+ return n;
2413
2556
  } catch (e) {
2414
2557
  throw e instanceof Error && e.message.includes("Payload size") ? e : new Error(`Failed to encode payload: ${e}`);
2415
2558
  }
2416
2559
  }
2417
- function Mt(s) {
2560
+ function yn(t) {
2418
2561
  try {
2419
- const e = decodeURIComponent(atob(s));
2420
- return JSON.parse(e);
2562
+ const e = decodeURIComponent(atob(t)), n = JSON.parse(e);
2563
+ return mn(n) ? n : null;
2421
2564
  } catch {
2422
2565
  return null;
2423
2566
  }
2424
2567
  }
2425
- function Wt(s) {
2568
+ function wn(t) {
2426
2569
  return {
2427
- uid: s.uid,
2428
- tag: s.tag,
2429
- version: xe,
2430
- context: s.context,
2431
- consumerDomain: s.consumerDomain,
2432
- props: s.props,
2433
- exports: s.exports,
2434
- children: s.children
2570
+ uid: t.uid,
2571
+ tag: t.tag,
2572
+ version: ae,
2573
+ context: t.context,
2574
+ consumerDomain: t.consumerDomain,
2575
+ props: t.props,
2576
+ exports: t.exports,
2577
+ children: t.children
2435
2578
  };
2436
2579
  }
2437
- function Bt(s = window) {
2438
- return Ue(s.name);
2580
+ function _n(t = window) {
2581
+ return Ke(t.name);
2439
2582
  }
2440
- class jt {
2441
- constructor(e, t, n, r) {
2442
- this.uid = e, this.options = t, this.resolveUrl = n, this.resolveUrlOrigin = r;
2583
+ class Pn {
2584
+ constructor(e, n, s, r) {
2585
+ this.uid = e, this.options = n, this.resolveUrl = s, this.resolveUrlOrigin = r;
2443
2586
  const i = this.buildTrustedDomains();
2444
- this.messenger = new Te(this.uid, window, K(), i), this.bridge = new re(this.messenger);
2587
+ this.messenger = new qe(this.uid, window, B(), i), this.bridge = new me(this.messenger);
2445
2588
  }
2446
2589
  /** Messenger for host communication. */
2447
2590
  messenger;
@@ -2461,25 +2604,25 @@ class jt {
2461
2604
  * Builds trusted domains used to initialize messenger security checks.
2462
2605
  */
2463
2606
  buildTrustedDomains() {
2464
- const e = [], t = this.resolveUrlOrigin(this.resolveUrl());
2465
- if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain && (typeof this.options.domain == "string" ? e.push(this.options.domain) : Array.isArray(this.options.domain) ? e.push(...this.options.domain) : this.options.domain instanceof RegExp && e.push(this.options.domain)), e.length !== 0)
2607
+ const e = [], n = this.resolveUrlOrigin(this.resolveUrl());
2608
+ if (n && (e.push(n), this.dynamicUrlTrustedOrigin = n), this.options.domain && (typeof this.options.domain == "string" ? e.push(this.options.domain) : Array.isArray(this.options.domain) ? e.push(...this.options.domain) : this.options.domain instanceof RegExp && e.push(this.options.domain)), e.length !== 0)
2466
2609
  return e.length === 1 ? e[0] : e;
2467
2610
  }
2468
2611
  /**
2469
2612
  * Returns true when the domain option explicitly includes this origin.
2470
2613
  */
2471
2614
  isExplicitDomainTrust(e) {
2472
- return this.options.domain ? C(this.options.domain, e) : !1;
2615
+ return this.options.domain ? U(this.options.domain, e) : !1;
2473
2616
  }
2474
2617
  /**
2475
2618
  * Ensures the messenger trusts the origin for a resolved host URL.
2476
2619
  */
2477
2620
  syncTrustedDomainForUrl(e) {
2478
- const t = this.resolveUrlOrigin(e);
2479
- if (!t)
2621
+ const n = this.resolveUrlOrigin(e);
2622
+ if (!n)
2480
2623
  return;
2481
- const n = this.dynamicUrlTrustedOrigin;
2482
- n && n !== t && !this.isExplicitDomainTrust(n) && this.messenger.removeTrustedDomain(n), this.messenger.addTrustedDomain(t), this.dynamicUrlTrustedOrigin = t;
2624
+ const s = this.dynamicUrlTrustedOrigin;
2625
+ s && s !== n && !this.isExplicitDomainTrust(s) && this.messenger.removeTrustedDomain(s), this.messenger.addTrustedDomain(n), this.dynamicUrlTrustedOrigin = n;
2483
2626
  }
2484
2627
  /**
2485
2628
  * Returns the current host domain target used for messaging.
@@ -2491,16 +2634,16 @@ class jt {
2491
2634
  * Returns true when the host window is connected and not closed.
2492
2635
  */
2493
2636
  isHostConnected() {
2494
- return !!(this.hostWindow && !q(this.hostWindow));
2637
+ return !!(this.hostWindow && !se(this.hostWindow));
2495
2638
  }
2496
2639
  /**
2497
2640
  * Serializes host props while keeping function bridge references in sync.
2498
2641
  */
2499
- serializePropsForHost(e, t, n) {
2642
+ serializePropsForHost(e, n, s) {
2500
2643
  this.bridge.startBatch();
2501
- const r = n?.finishBatch ?? !0;
2644
+ const r = s?.finishBatch ?? !0;
2502
2645
  try {
2503
- const i = ht(e, t, this.bridge);
2646
+ const i = St(e, n, this.bridge);
2504
2647
  return r && this.bridge.finishBatch(), i;
2505
2648
  } catch (i) {
2506
2649
  throw this.bridge.finishBatch(!0), i;
@@ -2509,23 +2652,23 @@ class jt {
2509
2652
  /**
2510
2653
  * Sends the current props snapshot to the host window when available.
2511
2654
  */
2512
- async sendPropsUpdateToHost(e, t) {
2513
- if (!this.hostWindow || q(this.hostWindow))
2655
+ async sendPropsUpdateToHost(e, n) {
2656
+ if (!this.hostWindow || se(this.hostWindow))
2514
2657
  return;
2515
- const n = this.getHostDomain(), r = ge(
2658
+ const s = this.getHostDomain(), r = Se(
2516
2659
  e,
2517
- t,
2518
2660
  n,
2519
- Je(this.hostWindow)
2661
+ s,
2662
+ Me(this.hostWindow)
2520
2663
  ), i = this.serializePropsForHost(
2521
2664
  r,
2522
- t,
2665
+ n,
2523
2666
  { finishBatch: !1 }
2524
2667
  );
2525
2668
  try {
2526
2669
  await this.messenger.send(
2527
2670
  this.hostWindow,
2528
- n,
2671
+ s,
2529
2672
  u.PROPS,
2530
2673
  i
2531
2674
  ), this.bridge.finishBatch();
@@ -2537,41 +2680,41 @@ class jt {
2537
2680
  * Builds the window.name payload for host initialization.
2538
2681
  */
2539
2682
  buildWindowName(e) {
2540
- const t = e.hostDomain ?? this.getHostDomain(), n = ge(
2683
+ const n = e.hostDomain ?? this.getHostDomain(), s = Se(
2541
2684
  e.props,
2542
2685
  e.propDefinitions,
2543
- t,
2686
+ n,
2544
2687
  !1
2545
2688
  ), r = this.serializePropsForHost(
2546
- n,
2689
+ s,
2547
2690
  e.propDefinitions
2548
- ), i = Wt({
2691
+ ), i = wn({
2549
2692
  uid: this.uid,
2550
2693
  tag: e.tag,
2551
2694
  context: e.context,
2552
- consumerDomain: K(),
2695
+ consumerDomain: B(),
2553
2696
  props: r,
2554
2697
  exports: e.exports,
2555
2698
  children: e.children
2556
2699
  });
2557
- return zt(i);
2700
+ return un(i);
2558
2701
  }
2559
2702
  /**
2560
2703
  * Waits for the host to send the initialization handshake.
2561
2704
  */
2562
- async waitForHost(e, t, n) {
2705
+ async waitForHost(e, n, s) {
2563
2706
  if (this.hostInitialized)
2564
2707
  return;
2565
- const r = Oe();
2708
+ const r = Le();
2566
2709
  this.initPromise = r;
2567
2710
  try {
2568
- await Be(
2711
+ await st(
2569
2712
  r.promise,
2570
2713
  e,
2571
- `Host component "${t}" (uid: ${this.uid}) did not initialize within ${e}ms. Check that the host page loads correctly and calls the initialization code.`
2714
+ `Host component "${n}" (uid: ${this.uid}) did not initialize within ${e}ms. Check that the host page loads correctly and calls the initialization code.`
2572
2715
  );
2573
2716
  } catch (i) {
2574
- throw n(i), i;
2717
+ throw s(i), i;
2575
2718
  } finally {
2576
2719
  this.initPromise === r && (this.initPromise = null);
2577
2720
  }
@@ -2580,13 +2723,17 @@ class jt {
2580
2723
  * Sets up host message handlers.
2581
2724
  */
2582
2725
  setupMessageHandlers(e) {
2583
- this.messenger.on(u.INIT, () => (this.hostInitialized = !0, this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await e.onClose(), { success: !0 })), this.messenger.on(u.RESIZE, async (t) => (await e.onResize(t), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await e.onFocus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await e.onShow(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await e.onHide(), { success: !0 })), this.messenger.on(
2726
+ this.messenger.on(u.INIT, () => (this.hostInitialized = !0, this.initPromise && this.initPromise.resolve(), e.onInit && queueMicrotask(() => {
2727
+ Promise.resolve(e.onInit?.()).catch((n) => {
2728
+ e.onError(n);
2729
+ });
2730
+ }), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await e.onClose(), { success: !0 })), this.messenger.on(u.RESIZE, async (n) => (await e.onResize(n), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await e.onFocus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await e.onShow(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await e.onHide(), { success: !0 })), this.messenger.on(
2584
2731
  u.ERROR,
2585
- async (t) => {
2586
- const n = new Error(t.message);
2587
- return n.stack = t.stack, e.onError(n), { success: !0 };
2732
+ async (n) => {
2733
+ const s = new Error(n.message);
2734
+ return s.stack = n.stack, e.onError(s), { success: !0 };
2588
2735
  }
2589
- ), this.messenger.on(u.EXPORT, async (t) => (e.onExport(t), { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (t) => (e.onConsumerExport(t), { success: !0 })), this.messenger.on(u.GET_SIBLINGS, async (t) => e.onGetSiblings(t));
2736
+ ), this.messenger.on(u.EXPORT, async (n) => (e.onExport(n), { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (n) => (e.onConsumerExport(n), { success: !0 })), this.messenger.on(u.GET_SIBLINGS, async (n) => e.onGetSiblings(n));
2590
2737
  }
2591
2738
  /**
2592
2739
  * Destroys transport resources.
@@ -2595,7 +2742,7 @@ class jt {
2595
2742
  this.messenger.destroy(), this.bridge.destroy();
2596
2743
  }
2597
2744
  }
2598
- class oe {
2745
+ class ye {
2599
2746
  /** Event emitter for lifecycle events. */
2600
2747
  event;
2601
2748
  /** Arbitrary state storage for the component instance. */
@@ -2628,6 +2775,8 @@ class oe {
2628
2775
  /** @internal */
2629
2776
  destroyed = !1;
2630
2777
  /** @internal */
2778
+ closing = !1;
2779
+ /** @internal */
2631
2780
  get props() {
2632
2781
  return this.propsPipeline ? this.propsPipeline.props : {};
2633
2782
  }
@@ -2733,8 +2882,8 @@ class oe {
2733
2882
  * @param options - Component configuration options
2734
2883
  * @param props - Initial props to pass to the component
2735
2884
  */
2736
- constructor(e, t = {}) {
2737
- this._uid = Me(), this.options = this.normalizeOptions(e), this.event = new Re(), this.cleanup = new We(), this.renderer = new Nt(
2885
+ constructor(e, n = {}) {
2886
+ this._uid = tt(), this.options = this.normalizeOptions(e), this.event = new Ae(), this.cleanup = new nt(), this.renderer = new en(
2738
2887
  this.options,
2739
2888
  this.uid,
2740
2889
  () => this.props,
@@ -2743,15 +2892,15 @@ class oe {
2743
2892
  close: () => this.close(),
2744
2893
  focus: () => this.focus()
2745
2894
  }
2746
- ), this.propsPipeline = new mt(
2895
+ ), this.propsPipeline = new Nt(
2747
2896
  this.options,
2748
- { ...t },
2749
- (n) => this.createPropContext(n)
2750
- ), this.transport = new jt(
2897
+ { ...n },
2898
+ (s) => this.createPropContext(s)
2899
+ ), this.transport = new Pn(
2751
2900
  this.uid,
2752
2901
  this.options,
2753
2902
  () => this.resolveUrl(),
2754
- (n) => this.resolveUrlOrigin(n)
2903
+ (s) => this.resolveUrlOrigin(s)
2755
2904
  ), this.setupMessageHandlers(), this.setupCleanup();
2756
2905
  }
2757
2906
  /**
@@ -2772,19 +2921,19 @@ class oe {
2772
2921
  * await instance.render(document.getElementById('target'), 'popup');
2773
2922
  * ```
2774
2923
  */
2775
- async render(e, t) {
2924
+ async render(e, n) {
2776
2925
  if (this.destroyed)
2777
2926
  throw new Error("Component has been destroyed");
2778
2927
  if (this.rendered)
2779
2928
  throw new Error("Component has already been rendered");
2780
- this.context = t ?? this.options.defaultContext, this.checkEligibility(), ve(this.props, this.options.props), this.options.validate?.({ props: this.props }), this.container = this.resolveContainer(e), this.event.emit(p.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(p.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(p.RENDER), this.callPropCallback("onRender");
2929
+ this.context = n ?? this.options.defaultContext, this.checkEligibility(), T(this.props, this.options.props), this.options.validate?.({ props: this.props }), this.container = this.resolveContainer(e), this.event.emit(g.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(g.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(g.RENDER), this.callPropCallback("onRender");
2781
2930
  try {
2782
- await this.open(), await this.waitForHost(), this.context === m.IFRAME && this.iframe && await this.renderer.swapPrerenderContentIfNeeded();
2783
- } catch (n) {
2931
+ await this.open(), await this.waitForHost(), this.context === f.IFRAME && this.iframe && await this.renderer.swapPrerenderContentIfNeeded();
2932
+ } catch (s) {
2784
2933
  throw await this.destroy().catch(() => {
2785
- }), n;
2934
+ }), s;
2786
2935
  }
2787
- this.rendered = !0, this.event.emit(p.RENDERED), this.callPropCallback("onRendered"), this.event.emit(p.DISPLAY), this.callPropCallback("onDisplay");
2936
+ this.rendered = !0, this.event.emit(g.RENDERED), this.callPropCallback("onRendered"), this.event.emit(g.DISPLAY), this.callPropCallback("onDisplay");
2788
2937
  }
2789
2938
  /**
2790
2939
  * Renders the component into a container in a different window.
@@ -2797,10 +2946,10 @@ class oe {
2797
2946
  * @param container - CSS selector or HTMLElement to render into
2798
2947
  * @param context - Override the default rendering context
2799
2948
  */
2800
- async renderTo(e, t, n) {
2949
+ async renderTo(e, n, s) {
2801
2950
  if (e !== window)
2802
2951
  throw new Error("Cross-window renderTo is not supported; pass the current window");
2803
- return this.render(t, n);
2952
+ return this.render(n, s);
2804
2953
  }
2805
2954
  /**
2806
2955
  * Closes and destroys the component.
@@ -2809,7 +2958,14 @@ class oe {
2809
2958
  * Emits the 'close' event before destruction. Safe to call multiple times.
2810
2959
  */
2811
2960
  async close() {
2812
- this.destroyed || (this.event.emit(p.CLOSE), await this.destroy());
2961
+ if (!(this.destroyed || this.closing)) {
2962
+ this.closing = !0;
2963
+ try {
2964
+ this.event.emit(g.CLOSE), this.callPropCallback("onClose"), await this.destroy();
2965
+ } finally {
2966
+ this.closing = !1;
2967
+ }
2968
+ }
2813
2969
  }
2814
2970
  /**
2815
2971
  * Focuses the component window.
@@ -2818,7 +2974,7 @@ class oe {
2818
2974
  * For iframes, focuses the iframe element. For popups, brings the window to front.
2819
2975
  */
2820
2976
  async focus() {
2821
- this.renderer.focus(this.hostWindow), this.event.emit(p.FOCUS), this.callPropCallback("onFocus");
2977
+ this.renderer.focus(this.hostWindow), this.event.emit(g.FOCUS), this.callPropCallback("onFocus");
2822
2978
  }
2823
2979
  /**
2824
2980
  * Resizes the component to the specified dimensions.
@@ -2826,7 +2982,7 @@ class oe {
2826
2982
  * @param dimensions - New width and height for the component
2827
2983
  */
2828
2984
  async resize(e) {
2829
- this.renderer.resize(e, this.hostWindow), this.event.emit(p.RESIZE, e), this.callPropCallback("onResize", e);
2985
+ this.renderer.resize(e, this.hostWindow), this.event.emit(g.RESIZE, e), this.callPropCallback("onResize", e);
2830
2986
  }
2831
2987
  /**
2832
2988
  * Shows the component if hidden.
@@ -2862,17 +3018,17 @@ class oe {
2862
3018
  * @internal
2863
3019
  */
2864
3020
  async applyPropsUpdate(e) {
2865
- const t = {
2866
- resolveUrl: (n) => this.resolveUrl(n),
2867
- resolveUrlOrigin: (n) => this.resolveUrlOrigin(n),
2868
- assertStableRenderedOrigin: (n) => this.assertStableRenderedOrigin(n),
3021
+ const n = {
3022
+ resolveUrl: (s) => this.resolveUrl(s),
3023
+ resolveUrlOrigin: (s) => this.resolveUrlOrigin(s),
3024
+ assertStableRenderedOrigin: (s) => this.assertStableRenderedOrigin(s),
2869
3025
  isRendered: () => this.rendered,
2870
- syncTrustedDomainForUrl: (n) => this.syncTrustedDomainForUrl(n),
3026
+ syncTrustedDomainForUrl: (s) => this.syncTrustedDomainForUrl(s),
2871
3027
  shouldSendPropsToHost: () => this.transport.isHostConnected(),
2872
- sendPropsUpdateToHost: (n) => this.sendPropsUpdateToHost(n),
3028
+ sendPropsUpdateToHost: (s) => this.sendPropsUpdateToHost(s),
2873
3029
  emitPropsUpdated: () => this.emitPropsUpdated()
2874
3030
  };
2875
- await this.propsPipeline.updateProps(e, t);
3031
+ await this.propsPipeline.updateProps(e, n);
2876
3032
  }
2877
3033
  /**
2878
3034
  * Prevents origin changes after render for security and routing consistency.
@@ -2896,7 +3052,7 @@ class oe {
2896
3052
  * @internal
2897
3053
  */
2898
3054
  emitPropsUpdated() {
2899
- this.event.emit(p.PROPS, this.props), this.callPropCallback("onProps", this.props);
3055
+ this.event.emit(g.PROPS, this.props), this.callPropCallback("onProps", this.props);
2900
3056
  }
2901
3057
  /**
2902
3058
  * Creates a clone of this instance with the same props.
@@ -2904,7 +3060,7 @@ class oe {
2904
3060
  * @returns A new unrendered component instance with identical configuration
2905
3061
  */
2906
3062
  clone() {
2907
- const e = new oe(this.options, this.props);
3063
+ const e = new ye(this.options, this.props);
2908
3064
  return e.inputProps = { ...this.inputProps }, e;
2909
3065
  }
2910
3066
  /**
@@ -2923,7 +3079,7 @@ class oe {
2923
3079
  return {
2924
3080
  ...e,
2925
3081
  props: e.props ?? {},
2926
- defaultContext: e.defaultContext ?? m.IFRAME,
3082
+ defaultContext: e.defaultContext ?? f.IFRAME,
2927
3083
  dimensions: e.dimensions ?? { width: "100%", height: "100%" },
2928
3084
  timeout: e.timeout ?? 1e4,
2929
3085
  children: e.children
@@ -2966,8 +3122,8 @@ class oe {
2966
3122
  * @internal
2967
3123
  */
2968
3124
  syncTrustedDomainForUrl(e) {
2969
- const t = this.resolveUrlOrigin(e);
2970
- t && this.isExplicitDomainTrust(t), this.transport.syncTrustedDomainForUrl(e);
3125
+ const n = this.resolveUrlOrigin(e);
3126
+ n && this.isExplicitDomainTrust(n), this.transport.syncTrustedDomainForUrl(e);
2971
3127
  }
2972
3128
  /**
2973
3129
  * Creates the prop context passed to prop callbacks and validators.
@@ -2979,7 +3135,7 @@ class oe {
2979
3135
  state: this.state,
2980
3136
  close: () => this.close(),
2981
3137
  focus: () => this.focus(),
2982
- onError: (t) => this.handleError(t),
3138
+ onError: (n) => this.handleError(n),
2983
3139
  container: this.container,
2984
3140
  uid: this.uid,
2985
3141
  tag: this.options.tag
@@ -3028,41 +3184,41 @@ class oe {
3028
3184
  const e = this.resolveUrl();
3029
3185
  this.syncTrustedDomainForUrl(e), this.openedHostDomain = this.resolveUrlOrigin(e), this.hostWindow = this.renderer.open({
3030
3186
  baseUrl: e,
3031
- buildUrl: (t) => this.buildUrl(t),
3187
+ buildUrl: (n) => this.buildUrl(n),
3032
3188
  buildBodyParams: () => this.buildBodyParams(),
3033
3189
  buildWindowName: () => this.buildWindowName(),
3034
- submitBodyForm: (t, n, r) => this.submitBodyForm(t, n, r),
3190
+ submitBodyForm: (n, s, r) => this.submitBodyForm(n, s, r),
3035
3191
  onPopupClose: () => {
3036
3192
  this.close();
3037
3193
  },
3038
- registerCleanup: (t) => {
3039
- this.cleanup.register(t);
3194
+ registerCleanup: (n) => {
3195
+ this.cleanup.register(n);
3040
3196
  }
3041
- }), this.hostWindow && et(this.uid, this.hostWindow);
3197
+ }), this.hostWindow && pt(this.uid, this.hostWindow);
3042
3198
  }
3043
3199
  /**
3044
3200
  * Builds the URL for the host window including query parameters.
3045
3201
  * @internal
3046
3202
  */
3047
3203
  buildUrl(e = this.resolveUrl()) {
3048
- const n = it(this.props, this.options.props).toString();
3049
- if (!n) return e;
3204
+ const s = wt(this.props, this.options.props).toString();
3205
+ if (!s) return e;
3050
3206
  const r = e.includes("?") ? "&" : "?";
3051
- return `${e}${r}${n}`;
3207
+ return `${e}${r}${s}`;
3052
3208
  }
3053
3209
  /**
3054
3210
  * Builds POST body parameters from props marked with bodyParam.
3055
3211
  * @internal
3056
3212
  */
3057
3213
  buildBodyParams() {
3058
- return ot(this.props, this.options.props);
3214
+ return _t(this.props, this.options.props);
3059
3215
  }
3060
3216
  /**
3061
3217
  * Submits a hidden form to navigate a target window via POST.
3062
3218
  * @internal
3063
3219
  */
3064
- submitBodyForm(e, t, n) {
3065
- this.renderer.submitBodyForm(e, t, n);
3220
+ submitBodyForm(e, n, s) {
3221
+ this.renderer.submitBodyForm(e, n, s);
3066
3222
  }
3067
3223
  /**
3068
3224
  * Builds the window.name payload for the host window.
@@ -3085,16 +3241,16 @@ class oe {
3085
3241
  */
3086
3242
  buildNestedHostRefs() {
3087
3243
  if (!this.options.children) return;
3088
- const e = this.options.children({ props: this.props }), t = {};
3089
- for (const [n, r] of Object.entries(e)) {
3090
- const i = ns(r);
3244
+ const e = this.options.children({ props: this.props }), n = {};
3245
+ for (const [s, r] of Object.entries(e)) {
3246
+ const i = Nn(r);
3091
3247
  if (!i)
3092
- throw new Error(`Nested component "${n}" is missing component metadata`);
3248
+ throw new Error(`Nested component "${s}" is missing component metadata`);
3093
3249
  if (typeof i.url != "string")
3094
3250
  throw new Error(
3095
- `Nested component "${n}" must use a static string URL. Function URLs are not supported in children.`
3251
+ `Nested component "${s}" must use a static string URL. Function URLs are not supported in children.`
3096
3252
  );
3097
- t[n] = {
3253
+ n[s] = {
3098
3254
  tag: i.tag,
3099
3255
  url: i.url,
3100
3256
  props: i.props,
@@ -3102,7 +3258,7 @@ class oe {
3102
3258
  defaultContext: i.defaultContext
3103
3259
  };
3104
3260
  }
3105
- return Object.keys(t).length > 0 ? t : void 0;
3261
+ return Object.keys(n).length > 0 ? n : void 0;
3106
3262
  }
3107
3263
  /**
3108
3264
  * Creates the exports object sent to the host.
@@ -3144,6 +3300,7 @@ class oe {
3144
3300
  */
3145
3301
  setupMessageHandlers() {
3146
3302
  this.transport.setupMessageHandlers({
3303
+ onInit: () => this.syncSameDomainPropsAfterInit(),
3147
3304
  onClose: async () => this.close(),
3148
3305
  onResize: async (e) => this.resize(e),
3149
3306
  onFocus: async () => this.focus(),
@@ -3159,28 +3316,50 @@ class oe {
3159
3316
  onGetSiblings: (e) => this.getSiblingInstances(e)
3160
3317
  });
3161
3318
  }
3319
+ /**
3320
+ * Synchronizes sameDomain props after the host proves its loaded origin via INIT.
3321
+ * @internal
3322
+ */
3323
+ async syncSameDomainPropsAfterInit() {
3324
+ if (!(!this.hostWindow || !this.transport.isHostConnected()) && Me(this.hostWindow) && this.hasSameDomainPropDefinition())
3325
+ try {
3326
+ await this.propsPipeline.syncCurrentPropsToHost({
3327
+ shouldSendPropsToHost: () => this.transport.isHostConnected(),
3328
+ sendPropsUpdateToHost: (e) => this.sendPropsUpdateToHost(e)
3329
+ });
3330
+ } catch (e) {
3331
+ this.handleError(e);
3332
+ }
3333
+ }
3334
+ /**
3335
+ * Returns true when any prop definition is restricted to same-origin hosts.
3336
+ * @internal
3337
+ */
3338
+ hasSameDomainPropDefinition() {
3339
+ return Object.values(this.options.props).some((e) => !e || D(e) ? !1 : e.sameDomain === !0);
3340
+ }
3162
3341
  /**
3163
3342
  * Gets sibling component instances for a request.
3164
3343
  * @internal
3165
3344
  */
3166
3345
  getSiblingInstances(e) {
3167
- const t = [];
3346
+ const n = [];
3168
3347
  if (e.options?.anyConsumer) {
3169
- for (const n of ss())
3170
- n.instance.uid !== e.uid && t.push({
3171
- uid: n.instance.uid,
3172
- tag: n.tag,
3173
- exports: n.instance.exports
3348
+ for (const s of Un())
3349
+ s.instance.uid !== e.uid && n.push({
3350
+ uid: s.instance.uid,
3351
+ tag: s.tag,
3352
+ exports: s.instance.exports
3174
3353
  });
3175
- return t;
3354
+ return n;
3176
3355
  }
3177
- for (const n of ts(e.tag))
3178
- n.uid !== e.uid && t.push({
3179
- uid: n.uid,
3356
+ for (const s of Tn(e.tag))
3357
+ s.uid !== e.uid && n.push({
3358
+ uid: s.uid,
3180
3359
  tag: e.tag,
3181
- exports: n.exports
3360
+ exports: s.exports
3182
3361
  });
3183
- return t;
3362
+ return n;
3184
3363
  }
3185
3364
  /**
3186
3365
  * Registers cleanup handlers for the instance.
@@ -3188,7 +3367,7 @@ class oe {
3188
3367
  */
3189
3368
  setupCleanup() {
3190
3369
  this.cleanup.register(() => {
3191
- this.messenger.destroy(), this.bridge.destroy(), tt(this.uid);
3370
+ this.messenger.destroy(), this.bridge.destroy(), ft(this.uid);
3192
3371
  });
3193
3372
  }
3194
3373
  /**
@@ -3196,17 +3375,17 @@ class oe {
3196
3375
  * @internal
3197
3376
  */
3198
3377
  handleError(e) {
3199
- this.event.emit(p.ERROR, e), this.callPropCallback("onError", e);
3378
+ this.event.emit(g.ERROR, e), this.callPropCallback("onError", e);
3200
3379
  }
3201
3380
  /**
3202
3381
  * Calls a prop callback if it exists.
3203
3382
  * @internal
3204
3383
  */
3205
- callPropCallback(e, ...t) {
3206
- const n = this.props[e];
3207
- if (typeof n == "function")
3384
+ callPropCallback(e, ...n) {
3385
+ const s = this.props[e];
3386
+ if (typeof s == "function")
3208
3387
  try {
3209
- const r = n(...t);
3388
+ const r = s(...n);
3210
3389
  r && typeof r == "object" && "catch" in r && typeof r.catch == "function" && r.catch((i) => {
3211
3390
  console.error(`Error in async ${e} callback:`, i);
3212
3391
  });
@@ -3223,31 +3402,31 @@ class oe {
3223
3402
  new Error(
3224
3403
  `Component "${this.options.tag}" was destroyed before initialization completed`
3225
3404
  )
3226
- ), this.initPromise = null), this.hostInitialized = !1, this.renderer.destroy(this.hostWindow), this.hostWindow = null, this.openedHostDomain = null, this.dynamicUrlTrustedOrigin = null, this.pendingPropsUpdate = null, await this.cleanup.cleanup(), this.event.emit(p.DESTROY), this.callPropCallback("onDestroy"), this.event.removeAllListeners());
3405
+ ), this.initPromise = null), this.hostInitialized = !1, this.renderer.destroy(this.hostWindow), this.hostWindow = null, this.openedHostDomain = null, this.dynamicUrlTrustedOrigin = null, this.pendingPropsUpdate = null, await this.cleanup.cleanup(), this.event.emit(g.DESTROY), this.callPropCallback("onDestroy"), this.event.removeAllListeners());
3227
3406
  }
3228
3407
  }
3229
- const v = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Map();
3230
- function Vt(s, e) {
3231
- const t = e;
3232
- v.get(t.uid) && Ne(t.uid);
3233
- let r = S.get(s);
3234
- r || (r = /* @__PURE__ */ new Map(), S.set(s, r)), r.set(t.uid, t), v.set(t.uid, { tag: s, instance: t });
3408
+ const N = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
3409
+ function En(t, e) {
3410
+ const n = e;
3411
+ N.get(n.uid) && Xe(n.uid);
3412
+ let r = F.get(t);
3413
+ r || (r = /* @__PURE__ */ new Map(), F.set(t, r)), r.set(n.uid, n), N.set(n.uid, { tag: t, instance: n });
3235
3414
  }
3236
- function Ne(s) {
3237
- const e = v.get(s);
3415
+ function Xe(t) {
3416
+ const e = N.get(t);
3238
3417
  if (!e)
3239
3418
  return;
3240
- v.delete(s);
3241
- const t = S.get(e.tag);
3242
- t && (t.delete(s), t.size === 0 && S.delete(e.tag));
3419
+ N.delete(t);
3420
+ const n = F.get(e.tag);
3421
+ n && (n.delete(t), n.size === 0 && F.delete(e.tag));
3243
3422
  }
3244
- function Kt(s) {
3245
- return Array.from(S.get(s)?.values() ?? []);
3423
+ function bn(t) {
3424
+ return Array.from(F.get(t)?.values() ?? []);
3246
3425
  }
3247
- function qt() {
3248
- return Array.from(v.values());
3426
+ function On() {
3427
+ return Array.from(N.values());
3249
3428
  }
3250
- const Fe = "Could not resolve consumer window", Jt = /* @__PURE__ */ new Set([
3429
+ const Ge = "Could not resolve consumer window", ne = "Could not verify consumer origin", Cn = /* @__PURE__ */ new Set([
3251
3430
  "uid",
3252
3431
  "tag",
3253
3432
  "close",
@@ -3264,7 +3443,13 @@ const Fe = "Could not resolve consumer window", Jt = /* @__PURE__ */ new Set([
3264
3443
  "getPeerInstances",
3265
3444
  "children"
3266
3445
  ]);
3267
- class Xt {
3446
+ function v(t) {
3447
+ const e = {};
3448
+ for (const [n, s] of Object.entries(t))
3449
+ Cn.has(n) || (e[n] = s);
3450
+ return e;
3451
+ }
3452
+ class Rn {
3268
3453
  /**
3269
3454
  * Creates a new HostComponent instance.
3270
3455
  *
@@ -3273,13 +3458,13 @@ class Xt {
3273
3458
  * @param allowedConsumerDomains - Optional allowlist of consumer domains
3274
3459
  * @param deferInit - Whether to defer INIT until a later explicit flush
3275
3460
  */
3276
- constructor(e, t = {}, n, r = !1) {
3277
- this.propDefinitions = t, this.allowedConsumerDomains = n, this.deferInit = r, this.uid = e.uid, this.tag = e.tag, this.consumerDomain = e.consumerDomain, this.validateConsumerDomain(), this.event = new Re(), this.messenger = new Te(this.uid, window, K(), this.consumerDomain);
3278
- let i = null;
3461
+ constructor(e, n = {}, s, r = !1) {
3462
+ this.propDefinitions = n, this.allowedConsumerDomains = s, this.deferInit = r, this.uid = e.uid, this.tag = e.tag, this.event = new Ae();
3463
+ let i = null, o = null;
3279
3464
  try {
3280
- this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), i = new re(this.messenger), this.bridge = i, this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
3281
- } catch (o) {
3282
- throw i?.destroy(), this.messenger.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear(), o;
3465
+ this.consumerWindow = this.resolveConsumerWindow(), this.consumerDomain = this.resolveConsumerDomain(e.consumerDomain), o = new qe(this.uid, window, B(), this.consumerDomain), this.messenger = o, this.setupMessageHandlers(), i = new me(this.messenger), this.bridge = i, this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
3466
+ } catch (a) {
3467
+ throw i?.destroy(), o?.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear(), a;
3283
3468
  }
3284
3469
  }
3285
3470
  /** The hostProps object containing props and control methods passed from the consumer. */
@@ -3295,6 +3480,8 @@ class Xt {
3295
3480
  /** @internal */
3296
3481
  consumerDomain;
3297
3482
  /** @internal */
3483
+ consumerDomainVerified = !1;
3484
+ /** @internal */
3298
3485
  messenger;
3299
3486
  /** @internal */
3300
3487
  bridge;
@@ -3339,8 +3526,8 @@ class Xt {
3339
3526
  configurable: !0,
3340
3527
  enumerable: !0,
3341
3528
  get: () => (this.deferInit && !this.initSent && !this.destroyed && this.scheduleDeferredInitFlush(), this.hostProps),
3342
- set: (t) => {
3343
- t && (this.hostProps = t);
3529
+ set: (n) => {
3530
+ n && (this.hostProps = n);
3344
3531
  }
3345
3532
  });
3346
3533
  } catch {
@@ -3352,11 +3539,93 @@ class Xt {
3352
3539
  * @internal
3353
3540
  */
3354
3541
  validateConsumerDomain() {
3355
- if (this.allowedConsumerDomains && !C(this.allowedConsumerDomains, this.consumerDomain))
3542
+ if (this.allowedConsumerDomains) {
3543
+ if (!this.consumerDomain)
3544
+ throw new Error(
3545
+ `${ne} for component "${this.tag}"`
3546
+ );
3547
+ if (!U(this.allowedConsumerDomains, this.consumerDomain))
3548
+ throw new Error(
3549
+ `Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
3550
+ );
3551
+ }
3552
+ }
3553
+ /**
3554
+ * Reads a browser-verifiable consumer origin when available.
3555
+ * @internal
3556
+ */
3557
+ getVerifiedConsumerOrigin() {
3558
+ return this.getReferrerOrigin() ?? this.getAccessibleConsumerOrigin();
3559
+ }
3560
+ /**
3561
+ * Updates the tracked consumer origin and keeps trusted messaging origins in sync.
3562
+ * @internal
3563
+ */
3564
+ setConsumerDomain(e, n) {
3565
+ const s = this.consumerDomain;
3566
+ this.consumerDomain = e, this.consumerDomainVerified = n, !(!this.messenger || !s || s === e) && (this.messenger.removeTrustedDomain(s), this.messenger.addTrustedDomain(e));
3567
+ }
3568
+ /**
3569
+ * Applies host configuration that may arrive after deferred pre-initialization.
3570
+ * @internal
3571
+ */
3572
+ applyHostConfiguration(e, n) {
3573
+ n !== void 0 && (this.allowedConsumerDomains = n), e !== void 0 && (this.propDefinitions = e, T(this.consumerProps, this.getBootstrapValidationDefinitions()), Object.assign(this.hostProps, v(this.consumerProps)), this.hostProps.consumer.props = this.consumerProps);
3574
+ }
3575
+ /**
3576
+ * Resolves the consumer origin from browser-provided context and falls back to the
3577
+ * claimed bootstrap origin only when no explicit allowlist is configured.
3578
+ * @internal
3579
+ */
3580
+ resolveConsumerDomain(e) {
3581
+ const n = this.getVerifiedConsumerOrigin();
3582
+ if (n)
3583
+ return this.consumerDomainVerified = !0, this.consumerDomain = n, this.validateConsumerDomain(), n;
3584
+ if (this.consumerDomainVerified = !1, this.allowedConsumerDomains)
3585
+ throw new Error(
3586
+ `${ne} for component "${this.tag}"`
3587
+ );
3588
+ return e;
3589
+ }
3590
+ /**
3591
+ * Rechecks allowlist constraints against a browser-verified consumer origin.
3592
+ * @internal
3593
+ */
3594
+ assertAllowedConsumerDomain(e) {
3595
+ const n = this.getVerifiedConsumerOrigin();
3596
+ if (n && this.setConsumerDomain(n, !0), !this.consumerDomainVerified)
3597
+ throw new Error(
3598
+ `${ne} for component "${this.tag}"`
3599
+ );
3600
+ if (!U(e, this.consumerDomain))
3356
3601
  throw new Error(
3357
3602
  `Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
3358
3603
  );
3359
3604
  }
3605
+ /**
3606
+ * Reads the consumer origin from the browser-provided referrer when available.
3607
+ * @internal
3608
+ */
3609
+ getReferrerOrigin() {
3610
+ if (!document.referrer)
3611
+ return null;
3612
+ try {
3613
+ return new URL(document.referrer, window.location.href).origin;
3614
+ } catch {
3615
+ return null;
3616
+ }
3617
+ }
3618
+ /**
3619
+ * Reads the consumer origin directly when same-origin access is available.
3620
+ * @internal
3621
+ */
3622
+ getAccessibleConsumerOrigin() {
3623
+ try {
3624
+ return this.consumerWindow.location.origin;
3625
+ } catch {
3626
+ return null;
3627
+ }
3628
+ }
3360
3629
  /**
3361
3630
  * Returns the hostProps object.
3362
3631
  *
@@ -3370,22 +3639,22 @@ class Xt {
3370
3639
  * @internal
3371
3640
  */
3372
3641
  resolveConsumerWindow() {
3373
- if (Ge()) {
3374
- const e = Ye();
3642
+ if (ut()) {
3643
+ const e = lt();
3375
3644
  if (e) return e;
3376
3645
  }
3377
- if (Ze()) {
3378
- const e = Xe();
3646
+ if (ht()) {
3647
+ const e = ct();
3379
3648
  if (e) return e;
3380
3649
  }
3381
- throw new Error(Fe);
3650
+ throw new Error(Ge);
3382
3651
  }
3383
3652
  /**
3384
3653
  * Builds the hostProps object with deserialized props and control methods.
3385
3654
  * @internal
3386
3655
  */
3387
3656
  buildHostProps(e) {
3388
- const t = we(
3657
+ const n = Ue(
3389
3658
  e.props,
3390
3659
  this.propDefinitions,
3391
3660
  this.messenger,
@@ -3393,28 +3662,47 @@ class Xt {
3393
3662
  this.consumerWindow,
3394
3663
  this.consumerDomain
3395
3664
  );
3396
- return this.consumerProps = t, {
3397
- ...t,
3665
+ return T(n, this.getBootstrapValidationDefinitions()), this.consumerProps = n, {
3666
+ ...v(n),
3398
3667
  uid: this.uid,
3399
3668
  tag: this.tag,
3400
3669
  close: () => this.close(),
3401
3670
  focus: () => this.focus(),
3402
- resize: (n) => this.resize(n),
3671
+ resize: (r) => this.resize(r),
3403
3672
  show: () => this.show(),
3404
3673
  hide: () => this.hide(),
3405
- onProps: (n) => this.onProps(n),
3406
- onError: (n) => this.onError(n),
3674
+ onProps: (r) => this.onProps(r),
3675
+ onError: (r) => this.onError(r),
3407
3676
  getConsumer: () => this.consumerWindow,
3408
3677
  getConsumerDomain: () => this.consumerDomain,
3409
- export: (n) => this.exportData(n),
3678
+ export: (r) => this.exportData(r),
3410
3679
  consumer: {
3411
3680
  props: this.consumerProps,
3412
- export: (n) => this.consumerExport(n)
3681
+ export: (r) => this.consumerExport(r)
3413
3682
  },
3414
- getPeerInstances: (n) => this.getPeerInstances(n),
3683
+ getPeerInstances: (r) => this.getPeerInstances(r),
3415
3684
  children: this.buildNestedComponents(e.children)
3416
3685
  };
3417
3686
  }
3687
+ /**
3688
+ * Relaxes required sameDomain props during bootstrap for verified same-origin hosts.
3689
+ * Those props are synchronized after INIT through the live messaging channel.
3690
+ * @internal
3691
+ */
3692
+ getBootstrapValidationDefinitions() {
3693
+ if (!this.consumerDomainVerified || this.consumerDomain !== B())
3694
+ return this.propDefinitions;
3695
+ let e = !1;
3696
+ const n = {
3697
+ ...this.propDefinitions
3698
+ };
3699
+ for (const [s, r] of Object.entries(this.propDefinitions))
3700
+ !r || D(r) || !r.sameDomain || (e = !0, n[s] = {
3701
+ ...r,
3702
+ required: !1
3703
+ });
3704
+ return e ? n : this.propDefinitions;
3705
+ }
3418
3706
  /**
3419
3707
  * Sends initialization message to the consumer.
3420
3708
  * @internal
@@ -3428,11 +3716,11 @@ class Xt {
3428
3716
  { uid: this.uid, tag: this.tag }
3429
3717
  );
3430
3718
  } catch (e) {
3431
- const t = e instanceof Error ? e : new Error(String(e));
3432
- this.initError = t, this.event.emit(p.ERROR, {
3719
+ const n = e instanceof Error ? e : new Error(String(e));
3720
+ this.initError = n, this.event.emit(g.ERROR, {
3433
3721
  type: "init_failed",
3434
- message: `Failed to initialize host component: ${t.message}`,
3435
- error: t
3722
+ message: `Failed to initialize host component: ${n.message}`,
3723
+ error: n
3436
3724
  }), console.error("Failed to send init message:", e);
3437
3725
  }
3438
3726
  }
@@ -3570,10 +3858,10 @@ class Xt {
3570
3858
  */
3571
3859
  buildNestedComponents(e) {
3572
3860
  if (!e) return;
3573
- const t = {};
3574
- for (const [n, r] of Object.entries(e))
3861
+ const n = {};
3862
+ for (const [s, r] of Object.entries(e))
3575
3863
  try {
3576
- t[n] = $e({
3864
+ n[s] = Qe({
3577
3865
  tag: r.tag,
3578
3866
  url: r.url,
3579
3867
  props: r.props,
@@ -3581,9 +3869,9 @@ class Xt {
3581
3869
  defaultContext: r.defaultContext
3582
3870
  });
3583
3871
  } catch (i) {
3584
- console.warn(`Failed to create nested component "${n}":`, i);
3872
+ console.warn(`Failed to create nested component "${s}":`, i);
3585
3873
  }
3586
- return Object.keys(t).length > 0 ? t : void 0;
3874
+ return Object.keys(n).length > 0 ? n : void 0;
3587
3875
  }
3588
3876
  /**
3589
3877
  * Sets up message handlers for consumer communication.
@@ -3592,7 +3880,7 @@ class Xt {
3592
3880
  setupMessageHandlers() {
3593
3881
  this.messenger.on(u.PROPS, (e) => {
3594
3882
  try {
3595
- const t = this.consumerProps, n = we(
3883
+ const n = this.consumerProps, s = Ue(
3596
3884
  e,
3597
3885
  this.propDefinitions,
3598
3886
  this.messenger,
@@ -3600,17 +3888,17 @@ class Xt {
3600
3888
  this.consumerWindow,
3601
3889
  this.consumerDomain
3602
3890
  );
3603
- this.removeStaleHostProps(t, n), this.consumerProps = n, Object.assign(this.hostProps, n), this.hostProps.consumer.props = this.consumerProps;
3891
+ T(s, this.propDefinitions), this.removeStaleHostProps(n, s), this.consumerProps = s, Object.assign(this.hostProps, v(s)), this.hostProps.consumer.props = this.consumerProps;
3604
3892
  for (const r of this.propsHandlers)
3605
3893
  try {
3606
- r(n);
3894
+ r(s);
3607
3895
  } catch (i) {
3608
3896
  console.error("Error in props handler:", i);
3609
3897
  }
3610
- return this.event.emit(p.PROPS, n), { success: !0 };
3611
- } catch (t) {
3612
- const n = t instanceof Error ? t : new Error(String(t));
3613
- throw console.error("Error deserializing props:", n), this.event.emit(p.ERROR, n), n;
3898
+ return this.event.emit(g.PROPS, s), { success: !0 };
3899
+ } catch (n) {
3900
+ const s = n instanceof Error ? n : new Error(String(n));
3901
+ throw console.error("Error deserializing props:", s), this.event.emit(g.ERROR, s), s;
3614
3902
  }
3615
3903
  });
3616
3904
  }
@@ -3618,9 +3906,10 @@ class Xt {
3618
3906
  * Removes stale prop keys that are no longer present in the latest consumer payload.
3619
3907
  * @internal
3620
3908
  */
3621
- removeStaleHostProps(e, t) {
3622
- for (const n of Object.keys(e))
3623
- n in t || Jt.has(n) || delete this.hostProps[n];
3909
+ removeStaleHostProps(e, n) {
3910
+ const s = v(e), r = v(n);
3911
+ for (const i of Object.keys(s))
3912
+ i in r || delete this.hostProps[i];
3624
3913
  }
3625
3914
  /**
3626
3915
  * Destroys the host component and cleans up resources.
@@ -3630,178 +3919,194 @@ class Xt {
3630
3919
  }
3631
3920
  }
3632
3921
  let w = null;
3633
- function ae(s, e, t = {}) {
3922
+ function we(t, e, n = {}) {
3634
3923
  if (w) {
3635
- if (e) {
3636
- const r = w.getProps().getConsumerDomain();
3637
- if (!C(e, r))
3638
- throw Qt(), new Error(
3639
- `Consumer domain "${r}" is not allowed for this host component`
3640
- );
3924
+ try {
3925
+ w.applyHostConfiguration(
3926
+ t,
3927
+ e
3928
+ ), e && w.assertAllowedConsumerDomain(e);
3929
+ } catch (r) {
3930
+ throw Sn(), r;
3641
3931
  }
3642
- return t.deferInit || w.flushInit(), w;
3932
+ return n.deferInit || w.flushInit(), w;
3643
3933
  }
3644
- if (!ie())
3934
+ if (!ge())
3645
3935
  return null;
3646
- const n = Bt();
3647
- if (!n)
3936
+ const s = _n();
3937
+ if (!s)
3648
3938
  return console.error("Failed to parse ForgeFrame payload from window.name"), null;
3649
3939
  try {
3650
- w = new Xt(
3651
- n,
3940
+ w = new Rn(
3652
3941
  s,
3942
+ t,
3653
3943
  e,
3654
- t.deferInit ?? !1
3944
+ n.deferInit ?? !1
3655
3945
  );
3656
3946
  } catch (r) {
3657
- if (r instanceof Error && r.message === Fe)
3947
+ if (r instanceof Error && r.message === Ge)
3658
3948
  return null;
3659
3949
  throw r;
3660
3950
  }
3661
3951
  return w;
3662
3952
  }
3663
- function Yt() {
3664
- return ie();
3953
+ function xn() {
3954
+ return ge();
3665
3955
  }
3666
- function Gt() {
3667
- return ie();
3956
+ function Dn() {
3957
+ return ge();
3668
3958
  }
3669
- function Zt() {
3959
+ function In() {
3670
3960
  return window.hostProps;
3671
3961
  }
3672
- function Qt() {
3962
+ function Sn() {
3673
3963
  w && (w.destroy(), w = null), delete window.hostProps;
3674
3964
  }
3675
- const k = /* @__PURE__ */ new Map(), He = /* @__PURE__ */ Symbol("forgeframe.component.options");
3676
- function es(s) {
3677
- if (!s.tag)
3965
+ const K = /* @__PURE__ */ new Map(), Ze = /* @__PURE__ */ Symbol("forgeframe.component.options");
3966
+ function vn(t) {
3967
+ if (!t.tag)
3678
3968
  throw new Error("Component tag is required");
3679
- if (!/^[a-z][a-z0-9-]*$/.test(s.tag))
3969
+ if (!/^[a-z][a-z0-9-]*$/.test(t.tag))
3680
3970
  throw new Error(
3681
- `Invalid component tag "${s.tag}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`
3971
+ `Invalid component tag "${t.tag}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`
3682
3972
  );
3683
- if (!s.url)
3973
+ if (!t.url)
3684
3974
  throw new Error("Component url is required");
3685
- if (typeof s.url == "string")
3975
+ if (typeof t.url == "string")
3686
3976
  try {
3687
- new URL(s.url, window.location.origin);
3977
+ new URL(t.url, window.location.origin);
3688
3978
  } catch {
3689
3979
  throw new Error(
3690
- `Invalid component URL "${s.url}". Must be a valid absolute or relative URL.`
3980
+ `Invalid component URL "${t.url}". Must be a valid absolute or relative URL.`
3691
3981
  );
3692
3982
  }
3693
- if (k.has(s.tag))
3694
- throw new Error(`Component "${s.tag}" is already registered`);
3983
+ if (K.has(t.tag))
3984
+ throw new Error(`Component "${t.tag}" is already registered`);
3695
3985
  }
3696
- function $e(s) {
3697
- es(s);
3986
+ function Qe(t) {
3987
+ vn(t);
3698
3988
  const e = [];
3699
- let t;
3700
- if (V(s.tag)) {
3701
- const r = ae(s.props, s.allowedConsumerDomains);
3702
- r && (t = r.hostProps);
3703
- }
3704
- const n = function(r = {}) {
3705
- const i = new oe(s, r);
3706
- return e.push(i), Vt(s.tag, i), i.event.once("destroy", () => {
3989
+ let n;
3990
+ if (te(t.tag)) {
3991
+ const r = we(t.props, t.allowedConsumerDomains);
3992
+ r && (n = r.hostProps);
3993
+ }
3994
+ const s = function(r = {}) {
3995
+ const i = new ye(t, r);
3996
+ return e.push(i), En(t.tag, i), i.event.once("destroy", () => {
3707
3997
  const o = e.indexOf(i);
3708
- o !== -1 && e.splice(o, 1), Ne(i.uid);
3998
+ o !== -1 && e.splice(o, 1), Xe(i.uid);
3709
3999
  }), i;
3710
4000
  };
3711
- return n.instances = e, n.isHost = () => V(s.tag), n.isEmbedded = () => V(s.tag), n.hostProps = t, n[He] = s, n.canRenderTo = async (r) => r === window, k.set(s.tag, n), n;
4001
+ return s.instances = e, s.isHost = () => te(t.tag), s.isEmbedded = () => te(t.tag), s.hostProps = n, s[Ze] = t, s.canRenderTo = async (r) => r === window, K.set(t.tag, s), s;
3712
4002
  }
3713
- function ts(s) {
3714
- return Kt(s);
4003
+ function Tn(t) {
4004
+ return bn(t);
3715
4005
  }
3716
- function ss() {
3717
- return qt();
4006
+ function Un() {
4007
+ return On();
3718
4008
  }
3719
- function ns(s) {
3720
- return s[He];
4009
+ function Nn(t) {
4010
+ return t[Ze];
3721
4011
  }
3722
- async function rs(s) {
3723
- await s.close();
4012
+ async function Fn(t) {
4013
+ await t.close();
3724
4014
  }
3725
- async function Le(s) {
3726
- const e = k.get(s);
4015
+ async function et(t) {
4016
+ const e = K.get(t);
3727
4017
  if (!e) return;
3728
- const t = [...e.instances];
3729
- await Promise.all(t.map((n) => n.close()));
4018
+ const n = [...e.instances];
4019
+ await Promise.all(n.map((s) => s.close()));
3730
4020
  }
3731
- async function is() {
3732
- const s = Array.from(k.keys());
3733
- await Promise.all(s.map((e) => Le(e)));
4021
+ async function Hn() {
4022
+ const t = Array.from(K.keys());
4023
+ await Promise.all(t.map((e) => et(e)));
3734
4024
  }
3735
- function os(s, e) {
3736
- const t = Object.keys(s), n = Object.keys(e);
3737
- if (t.length !== n.length)
4025
+ function $n(t, e) {
4026
+ const n = Object.keys(t), s = Object.keys(e);
4027
+ if (n.length !== s.length)
3738
4028
  return !1;
3739
- for (const r of t)
3740
- if (!Object.prototype.hasOwnProperty.call(e, r) || !Object.is(s[r], e[r]))
4029
+ for (const r of n)
4030
+ if (!Object.prototype.hasOwnProperty.call(e, r) || !Object.is(t[r], e[r]))
3741
4031
  return !1;
3742
4032
  return !0;
3743
4033
  }
3744
- function as(s, e) {
3745
- const { React: t } = e, { createElement: n, useRef: r, useEffect: i, useState: o, forwardRef: a } = t, c = a(
3746
- function(f, g) {
4034
+ function An(t, e) {
4035
+ const { React: n } = e, { createElement: s, useRef: r, useEffect: i, useState: o, forwardRef: a } = n, c = a(
4036
+ function(m, h) {
3747
4037
  const {
3748
- onRendered: ce,
3749
- onError: M,
3750
- onClose: le,
3751
- context: Ae,
3752
- className: ue,
3753
- style: he,
3754
- ...de
3755
- } = f, D = r(null), W = r(null), B = r(null), T = r(M), [pe, ze] = o(null);
4038
+ onRendered: E,
4039
+ onError: O,
4040
+ onClose: X,
4041
+ context: _e,
4042
+ className: Pe,
4043
+ style: Ee,
4044
+ ...G
4045
+ } = m, Z = r(null), I = r(null), $ = r(null), be = r(E), A = r(O), Oe = r(X), [Ce, Re] = o(null);
3756
4046
  return i(() => {
3757
- T.current = M;
3758
- }, [M]), i(() => {
3759
- const R = D.current;
3760
- if (!R) return;
3761
- const y = s(de);
3762
- return W.current = y, ce && y.event.once("rendered", ce), le && y.event.once("close", le), y.event.on("error", (E) => {
3763
- T.current?.(E);
3764
- }), y.render(R, Ae).catch((E) => {
3765
- ze(E), T.current?.(E);
4047
+ be.current = E, A.current = O, Oe.current = X;
4048
+ }, [E, O, X]), i(() => {
4049
+ const _ = Z.current;
4050
+ if (!_) return;
4051
+ Re(null);
4052
+ const y = t(G);
4053
+ I.current = y, $.current = G;
4054
+ const L = y.event.once("rendered", () => {
4055
+ be.current?.();
4056
+ }), xe = y.event.once("close", () => {
4057
+ Oe.current?.();
4058
+ }), Q = y.event.on("error", (M) => {
4059
+ A.current?.(M);
4060
+ });
4061
+ return y.render(_, _e).catch((M) => {
4062
+ I.current === y && (Re(M), A.current?.(M));
3766
4063
  }), () => {
3767
4064
  y.close().catch(() => {
3768
- }), W.current = null, B.current = null;
4065
+ }), L(), xe(), Q(), I.current = null, $.current = null;
3769
4066
  };
3770
- }, []), i(() => {
3771
- const R = W.current;
3772
- if (!R) return;
3773
- const y = de, E = B.current;
3774
- E && os(E, y) || (B.current = y, R.updateProps(y).catch((ke) => {
3775
- T.current?.(ke);
4067
+ }, [_e]), i(() => {
4068
+ const _ = I.current;
4069
+ if (!_) return;
4070
+ const y = G, L = $.current;
4071
+ L && $n(L, y) || ($.current = y, _.updateProps(y).catch((Q) => {
4072
+ I.current === _ && A.current?.(Q);
3776
4073
  }));
3777
4074
  }), i(() => {
3778
- g && typeof g == "object" && D.current && (g.current = D.current);
3779
- }, [g]), pe ? n(
4075
+ const _ = Z.current;
4076
+ if (typeof h == "function")
4077
+ return h(_), () => {
4078
+ h(null);
4079
+ };
4080
+ if (h && typeof h == "object")
4081
+ return h.current = _, () => {
4082
+ h.current = null;
4083
+ };
4084
+ }, [h]), Ce ? s(
3780
4085
  "div",
3781
4086
  {
3782
- className: ue,
3783
- style: { color: "red", padding: "16px", ...he }
4087
+ className: Pe,
4088
+ style: { color: "red", padding: "16px", ...Ee }
3784
4089
  },
3785
- `Error: ${pe.message}`
3786
- ) : n("div", {
3787
- ref: D,
3788
- className: ue,
4090
+ `Error: ${Ce.message}`
4091
+ ) : s("div", {
4092
+ ref: Z,
4093
+ className: Pe,
3789
4094
  style: {
3790
4095
  display: "inline-block",
3791
- ...he
4096
+ ...Ee
3792
4097
  }
3793
4098
  });
3794
4099
  }
3795
- ), l = `ForgeFrame(${s.name || "Component"})`;
4100
+ ), l = `ForgeFrame(${t.name || "Component"})`;
3796
4101
  return c.displayName = l, c;
3797
4102
  }
3798
- function ls(s) {
3799
- return function(t) {
3800
- return as(t, { React: s });
4103
+ function Ln(t) {
4104
+ return function(n) {
4105
+ return An(n, { React: t });
3801
4106
  };
3802
4107
  }
3803
- ae(void 0, void 0, { deferInit: !0 });
3804
- const us = {
4108
+ we(void 0, void 0, { deferInit: !0 });
4109
+ const Mn = {
3805
4110
  /**
3806
4111
  * Create a new component definition.
3807
4112
  *
@@ -3826,23 +4131,23 @@ const us = {
3826
4131
  * await instance.render('#container');
3827
4132
  * ```
3828
4133
  */
3829
- create: $e,
4134
+ create: Qe,
3830
4135
  /**
3831
4136
  * Destroy a single component instance.
3832
4137
  *
3833
4138
  * @param instance - The component instance to destroy
3834
4139
  */
3835
- destroy: rs,
4140
+ destroy: Fn,
3836
4141
  /**
3837
4142
  * Destroy all instances of a specific component by tag.
3838
4143
  *
3839
4144
  * @param tag - The component tag name
3840
4145
  */
3841
- destroyByTag: Le,
4146
+ destroyByTag: et,
3842
4147
  /**
3843
4148
  * Destroy all ForgeFrame component instances.
3844
4149
  */
3845
- destroyAll: is,
4150
+ destroyAll: Hn,
3846
4151
  /**
3847
4152
  * Check if the current window is a host component context.
3848
4153
  *
@@ -3852,7 +4157,7 @@ const us = {
3852
4157
  *
3853
4158
  * @returns True if running inside a ForgeFrame iframe/popup
3854
4159
  */
3855
- isHost: Yt,
4160
+ isHost: xn,
3856
4161
  /**
3857
4162
  * Check if the current window is embedded by ForgeFrame.
3858
4163
  *
@@ -3861,7 +4166,7 @@ const us = {
3861
4166
  *
3862
4167
  * @returns True if running inside a ForgeFrame iframe/popup
3863
4168
  */
3864
- isEmbedded: Gt,
4169
+ isEmbedded: Dn,
3865
4170
  /**
3866
4171
  * Get hostProps from the current host window.
3867
4172
  *
@@ -3870,7 +4175,7 @@ const us = {
3870
4175
  *
3871
4176
  * @returns The hostProps object if in host context, undefined otherwise
3872
4177
  */
3873
- getHostProps: Zt,
4178
+ getHostProps: In,
3874
4179
  /**
3875
4180
  * Flush host initialization in embedded contexts.
3876
4181
  *
@@ -3881,30 +4186,30 @@ const us = {
3881
4186
  *
3882
4187
  * @returns The host component instance if running embedded, otherwise null
3883
4188
  */
3884
- initHost: ae,
4189
+ initHost: we,
3885
4190
  /**
3886
4191
  * Serialization strategy constants.
3887
4192
  * @see {@link PROP_SERIALIZATION}
3888
4193
  */
3889
- PROP_SERIALIZATION: U,
4194
+ PROP_SERIALIZATION: z,
3890
4195
  /**
3891
4196
  * Rendering context constants (IFRAME, POPUP).
3892
4197
  * @see {@link CONTEXT}
3893
4198
  */
3894
- CONTEXT: m,
4199
+ CONTEXT: f,
3895
4200
  /**
3896
4201
  * Lifecycle event name constants.
3897
4202
  * @see {@link EVENT}
3898
4203
  */
3899
- EVENT: p,
4204
+ EVENT: g,
3900
4205
  /**
3901
4206
  * Error thrown when popup window fails to open.
3902
4207
  */
3903
- PopupOpenError: De,
4208
+ PopupOpenError: Je,
3904
4209
  /**
3905
4210
  * Current library version.
3906
4211
  */
3907
- VERSION: xe,
4212
+ VERSION: ae,
3908
4213
  /**
3909
4214
  * Check if a value is a Standard Schema (Zod, Valibot, ArkType, etc.)
3910
4215
  *
@@ -3921,7 +4226,7 @@ const us = {
3921
4226
  * }
3922
4227
  * ```
3923
4228
  */
3924
- isStandardSchema: z,
4229
+ isStandardSchema: D,
3925
4230
  /**
3926
4231
  * Prop schema builders for defining component props.
3927
4232
  *
@@ -3944,36 +4249,36 @@ const us = {
3944
4249
  * });
3945
4250
  * ```
3946
4251
  */
3947
- prop: d
4252
+ prop: p
3948
4253
  };
3949
4254
  export {
3950
- ne as AnySchema,
3951
- $ as ArraySchema,
3952
- Q as BooleanSchema,
3953
- m as CONTEXT,
3954
- p as EVENT,
3955
- se as EnumSchema,
3956
- us as ForgeFrame,
3957
- ee as FunctionSchema,
3958
- te as LiteralSchema,
3959
- Z as NumberSchema,
3960
- L as ObjectSchema,
3961
- U as PROP_SERIALIZATION,
3962
- De as PopupOpenError,
3963
- _ as PropSchema,
3964
- G as StringSchema,
3965
- xe as VERSION,
3966
- $e as create,
3967
- as as createReactComponent,
3968
- us as default,
3969
- rs as destroy,
3970
- is as destroyAll,
3971
- Le as destroyByTag,
3972
- Zt as getHostProps,
3973
- ae as initHost,
3974
- Gt as isEmbedded,
3975
- Yt as isHost,
3976
- z as isStandardSchema,
3977
- d as prop,
3978
- ls as withReactComponent
4255
+ fe as AnySchema,
4256
+ V as ArraySchema,
4257
+ ue as BooleanSchema,
4258
+ f as CONTEXT,
4259
+ g as EVENT,
4260
+ pe as EnumSchema,
4261
+ Mn as ForgeFrame,
4262
+ he as FunctionSchema,
4263
+ de as LiteralSchema,
4264
+ le as NumberSchema,
4265
+ Y as ObjectSchema,
4266
+ z as PROP_SERIALIZATION,
4267
+ Je as PopupOpenError,
4268
+ P as PropSchema,
4269
+ ce as StringSchema,
4270
+ ae as VERSION,
4271
+ Qe as create,
4272
+ An as createReactComponent,
4273
+ Mn as default,
4274
+ Fn as destroy,
4275
+ Hn as destroyAll,
4276
+ et as destroyByTag,
4277
+ In as getHostProps,
4278
+ we as initHost,
4279
+ Dn as isEmbedded,
4280
+ xn as isHost,
4281
+ D as isStandardSchema,
4282
+ p as prop,
4283
+ Ln as withReactComponent
3979
4284
  };