forgeframe 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -33,12 +33,12 @@ const p = {
33
33
  BASE64: "base64",
34
34
  /** Dot notation for nested objects (e.g., "a.b.c=value") */
35
35
  DOTIFY: "dotify"
36
- }, D = {
36
+ }, T = {
37
37
  /** Request message expecting a response */
38
38
  REQUEST: "request",
39
39
  /** Response to a previous request */
40
40
  RESPONSE: "response"
41
- }, u = {
41
+ }, h = {
42
42
  /** Host initialization complete */
43
43
  INIT: "forgeframe_init",
44
44
  /** Props update from consumer to host */
@@ -63,8 +63,8 @@ const p = {
63
63
  CONSUMER_EXPORT: "forgeframe_consumer_export",
64
64
  /** Get sibling components request */
65
65
  GET_SIBLINGS: "forgeframe_get_siblings"
66
- }, N = "__forgeframe__", pe = "0.0.1";
67
- class me {
66
+ }, N = "__forgeframe__", ye = "0.0.1";
67
+ class we {
68
68
  /**
69
69
  * Internal storage for event listeners mapped by event name.
70
70
  * @internal
@@ -87,8 +87,8 @@ class me {
87
87
  *
88
88
  * @public
89
89
  */
90
- on(e, s) {
91
- return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(s), () => this.off(e, s);
90
+ on(e, t) {
91
+ return this.listeners.has(e) || this.listeners.set(e, /* @__PURE__ */ new Set()), this.listeners.get(e).add(t), () => this.off(e, t);
92
92
  }
93
93
  /**
94
94
  * Subscribes a handler to an event that will automatically unsubscribe after the first invocation.
@@ -111,8 +111,8 @@ class me {
111
111
  *
112
112
  * @public
113
113
  */
114
- once(e, s) {
115
- const n = (i) => (this.off(e, n), s(i));
114
+ once(e, t) {
115
+ const n = (i) => (this.off(e, n), t(i));
116
116
  return this.on(e, n);
117
117
  }
118
118
  /**
@@ -134,12 +134,12 @@ class me {
134
134
  *
135
135
  * @public
136
136
  */
137
- emit(e, s) {
137
+ emit(e, t) {
138
138
  const n = this.listeners.get(e);
139
139
  if (n)
140
140
  for (const i of n)
141
141
  try {
142
- const r = i(s);
142
+ const r = i(t);
143
143
  r && typeof r == "object" && "catch" in r && typeof r.catch == "function" && r.catch((o) => {
144
144
  console.error(`Error in async event handler for "${e}":`, o);
145
145
  });
@@ -168,13 +168,13 @@ class me {
168
168
  *
169
169
  * @public
170
170
  */
171
- off(e, s) {
172
- if (!s) {
171
+ off(e, t) {
172
+ if (!t) {
173
173
  this.listeners.delete(e);
174
174
  return;
175
175
  }
176
176
  const n = this.listeners.get(e);
177
- n && (n.delete(s), n.size === 0 && this.listeners.delete(e));
177
+ n && (n.delete(t), n.size === 0 && this.listeners.delete(e));
178
178
  }
179
179
  /**
180
180
  * Removes all event listeners from the emitter.
@@ -215,14 +215,14 @@ class me {
215
215
  return this.listeners.get(e)?.size ?? 0;
216
216
  }
217
217
  }
218
- function Ie() {
219
- const t = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
220
- return `${t}_${e}`;
218
+ function Ne() {
219
+ const s = Date.now().toString(36), e = Math.random().toString(36).slice(2, 11);
220
+ return `${s}_${e}`;
221
221
  }
222
- function W() {
222
+ function z() {
223
223
  return Math.random().toString(36).slice(2, 11);
224
224
  }
225
- class De {
225
+ class Fe {
226
226
  /**
227
227
  * Array of registered cleanup tasks awaiting execution.
228
228
  * @internal
@@ -260,8 +260,8 @@ class De {
260
260
  if (this.cleaned) {
261
261
  try {
262
262
  e();
263
- } catch (s) {
264
- console.error("Error in cleanup task:", s);
263
+ } catch (t) {
264
+ console.error("Error in cleanup task:", t);
265
265
  }
266
266
  return;
267
267
  }
@@ -293,9 +293,9 @@ class De {
293
293
  this.cleaned = !0;
294
294
  const e = this.tasks.reverse();
295
295
  this.tasks = [];
296
- for (const s of e)
296
+ for (const t of e)
297
297
  try {
298
- await s();
298
+ await t();
299
299
  } catch (n) {
300
300
  console.error("Error in cleanup task:", n);
301
301
  }
@@ -340,60 +340,60 @@ class De {
340
340
  this.tasks = [], this.cleaned = !1;
341
341
  }
342
342
  }
343
- function ge() {
344
- let t, e;
343
+ function _e() {
344
+ let s, e;
345
345
  return { promise: new Promise((n, i) => {
346
- t = n, e = i;
347
- }), resolve: t, reject: e };
346
+ s = n, e = i;
347
+ }), resolve: s, reject: e };
348
348
  }
349
- function Ne(t, e, s = "Operation timed out") {
349
+ function $e(s, e, t = "Operation timed out") {
350
350
  return new Promise((n, i) => {
351
351
  const r = setTimeout(() => {
352
- i(new Error(`${s} (${e}ms)`));
352
+ i(new Error(`${t} (${e}ms)`));
353
353
  }, e);
354
- t.then((o) => {
354
+ s.then((o) => {
355
355
  clearTimeout(r), n(o);
356
356
  }).catch((o) => {
357
357
  clearTimeout(r), i(o);
358
358
  });
359
359
  });
360
360
  }
361
- const z = "forgeframe:";
362
- function A(t) {
363
- return z + JSON.stringify(t);
361
+ const j = "forgeframe:";
362
+ function M(s) {
363
+ return j + JSON.stringify(s);
364
364
  }
365
- function Te(t) {
366
- if (typeof t != "string" || !t.startsWith(z)) return null;
365
+ function ke(s) {
366
+ if (typeof s != "string" || !s.startsWith(j)) return null;
367
367
  try {
368
- const e = t.slice(z.length), s = JSON.parse(e);
369
- return !s.id || !s.type || !s.name || !s.source ? null : s;
368
+ const e = s.slice(j.length), t = JSON.parse(e);
369
+ return !t.id || !t.type || !t.name || !t.source ? null : t;
370
370
  } catch {
371
371
  return null;
372
372
  }
373
373
  }
374
- function re(t, e, s, n) {
374
+ function ce(s, e, t, n) {
375
375
  return {
376
- id: t,
377
- type: D.REQUEST,
376
+ id: s,
377
+ type: T.REQUEST,
378
378
  name: e,
379
- data: s,
379
+ data: t,
380
380
  source: n
381
381
  };
382
382
  }
383
- function ke(t, e, s, n) {
383
+ function Le(s, e, t, n) {
384
384
  return {
385
- id: t,
386
- type: D.RESPONSE,
385
+ id: s,
386
+ type: T.RESPONSE,
387
387
  name: "response",
388
388
  data: e,
389
- source: s,
389
+ source: t,
390
390
  error: n ? {
391
391
  message: n.message,
392
392
  stack: n.stack
393
393
  } : void 0
394
394
  };
395
395
  }
396
- class ye {
396
+ class Ee {
397
397
  /**
398
398
  * Creates a new Messenger instance.
399
399
  *
@@ -402,8 +402,8 @@ class ye {
402
402
  * @param domain - The origin domain of this messenger
403
403
  * @param trustedDomains - Optional domains to trust for incoming messages
404
404
  */
405
- constructor(e, s = window, n = window.location.origin, i) {
406
- this.uid = e, this.win = s, this.domain = n, this.allowedOrigins.add(n), i && this.addTrustedDomain(i), this.setupListener();
405
+ constructor(e, t = window, n = window.location.origin, i) {
406
+ this.uid = e, this.win = t, this.domain = n, this.allowedOrigins.add(n), i && this.addTrustedDomain(i), this.setupListener();
407
407
  }
408
408
  /** @internal */
409
409
  pending = /* @__PURE__ */ new Map();
@@ -424,10 +424,21 @@ class ye {
424
424
  */
425
425
  addTrustedDomain(e) {
426
426
  if (Array.isArray(e))
427
- for (const s of e)
428
- this.allowedOrigins.add(s);
427
+ for (const t of e)
428
+ this.allowedOrigins.add(t);
429
429
  else e instanceof RegExp ? this.allowedOriginPatterns.push(e) : this.allowedOrigins.add(e);
430
430
  }
431
+ /**
432
+ * Removes a trusted domain from this messenger.
433
+ *
434
+ * @param domain - Domain pattern to remove (string, RegExp, or array)
435
+ */
436
+ removeTrustedDomain(e) {
437
+ if (Array.isArray(e))
438
+ for (const t of e)
439
+ this.allowedOrigins.delete(t);
440
+ else e instanceof RegExp ? this.allowedOriginPatterns = this.allowedOriginPatterns.filter((t) => t !== e) : this.allowedOrigins.delete(e);
441
+ }
431
442
  /**
432
443
  * Checks if an origin is trusted.
433
444
  *
@@ -438,8 +449,8 @@ class ye {
438
449
  isOriginTrusted(e) {
439
450
  if (this.allowedOrigins.has(e))
440
451
  return !0;
441
- for (const s of this.allowedOriginPatterns)
442
- if (s.test(e))
452
+ for (const t of this.allowedOriginPatterns)
453
+ if (t.test(e))
443
454
  return !0;
444
455
  return !1;
445
456
  }
@@ -456,13 +467,13 @@ class ye {
456
467
  * @returns Promise resolving to the response data
457
468
  * @throws Error if messenger is destroyed or timeout occurs
458
469
  */
459
- async send(e, s, n, i, r = 1e4) {
470
+ async send(e, t, n, i, r = 1e4) {
460
471
  if (this.destroyed)
461
472
  throw new Error("Messenger has been destroyed");
462
- const o = W(), a = re(o, n, i, {
473
+ const o = z(), a = ce(o, n, i, {
463
474
  uid: this.uid,
464
475
  domain: this.domain
465
- }), c = ge(), l = setTimeout(() => {
476
+ }), c = _e(), l = setTimeout(() => {
466
477
  this.pending.delete(o), c.reject(new Error(`Message "${n}" timed out after ${r}ms`));
467
478
  }, r);
468
479
  this.pending.set(o, {
@@ -470,9 +481,9 @@ class ye {
470
481
  timeout: l
471
482
  });
472
483
  try {
473
- e.postMessage(A(a), s);
474
- } catch (h) {
475
- throw this.pending.delete(o), clearTimeout(l), h;
484
+ e.postMessage(M(a), t);
485
+ } catch (u) {
486
+ throw this.pending.delete(o), clearTimeout(l), u;
476
487
  }
477
488
  return c.promise;
478
489
  }
@@ -486,14 +497,14 @@ class ye {
486
497
  * @param data - Optional data payload
487
498
  * @throws Error if messenger is destroyed
488
499
  */
489
- post(e, s, n, i) {
500
+ post(e, t, n, i) {
490
501
  if (this.destroyed)
491
502
  throw new Error("Messenger has been destroyed");
492
- const r = W(), o = re(r, n, i, {
503
+ const r = z(), o = ce(r, n, i, {
493
504
  uid: this.uid,
494
505
  domain: this.domain
495
506
  });
496
- e.postMessage(A(o), s);
507
+ e.postMessage(M(o), t);
497
508
  }
498
509
  /**
499
510
  * Registers a handler for incoming messages of a specific type.
@@ -504,8 +515,8 @@ class ye {
504
515
  * @param handler - The handler function
505
516
  * @returns Function to unregister the handler
506
517
  */
507
- on(e, s) {
508
- return this.handlers.set(e, s), () => this.handlers.delete(e);
518
+ on(e, t) {
519
+ return this.handlers.set(e, t), () => this.handlers.delete(e);
509
520
  }
510
521
  /**
511
522
  * Sets up the postMessage event listener.
@@ -515,16 +526,16 @@ class ye {
515
526
  this.listener = (e) => {
516
527
  if (e.source === this.win || !this.isOriginTrusted(e.origin))
517
528
  return;
518
- const s = Te(e.data);
519
- s && this.handleMessage(s, e.source, e.origin);
529
+ const t = ke(e.data);
530
+ t && this.handleMessage(t, e.source, e.origin);
520
531
  }, this.win.addEventListener("message", this.listener);
521
532
  }
522
533
  /**
523
534
  * Processes a received message.
524
535
  * @internal
525
536
  */
526
- async handleMessage(e, s, n) {
527
- if (e.type === D.RESPONSE) {
537
+ async handleMessage(e, t, n) {
538
+ if (e.type === T.RESPONSE) {
528
539
  const i = this.pending.get(e.id);
529
540
  if (i)
530
541
  if (this.pending.delete(e.id), clearTimeout(i.timeout), e.error) {
@@ -534,7 +545,7 @@ class ye {
534
545
  i.deferred.resolve(e.data);
535
546
  return;
536
547
  }
537
- if (e.type === D.REQUEST) {
548
+ if (e.type === T.REQUEST) {
538
549
  const i = this.handlers.get(e.name);
539
550
  if (!i)
540
551
  return;
@@ -544,14 +555,14 @@ class ye {
544
555
  } catch (c) {
545
556
  o = c instanceof Error ? c : new Error(String(c));
546
557
  }
547
- const a = ke(
558
+ const a = Le(
548
559
  e.id,
549
560
  r,
550
561
  { uid: this.uid, domain: this.domain },
551
562
  o
552
563
  );
553
564
  try {
554
- s.postMessage(A(a), n);
565
+ t.postMessage(M(a), n);
555
566
  } catch {
556
567
  }
557
568
  }
@@ -580,8 +591,8 @@ class ye {
580
591
  return this.destroyed;
581
592
  }
582
593
  }
583
- const oe = 500;
584
- class B {
594
+ const le = 500;
595
+ class J {
585
596
  /**
586
597
  * Creates a new FunctionBridge instance.
587
598
  *
@@ -607,16 +618,16 @@ class B {
607
618
  * @param name - Optional name for debugging
608
619
  * @returns A function reference that can be sent across domains
609
620
  */
610
- serialize(e, s) {
611
- if (this.localFunctions.size >= oe) {
621
+ serialize(e, t) {
622
+ if (this.localFunctions.size >= le) {
612
623
  const i = this.localFunctions.keys().next().value;
613
624
  i && this.localFunctions.delete(i);
614
625
  }
615
- const n = W();
626
+ const n = z();
616
627
  return this.localFunctions.set(n, e), this.currentBatchIds.add(n), {
617
628
  __type__: "function",
618
629
  __id__: n,
619
- __name__: s || e.name || "anonymous"
630
+ __name__: t || e.name || "anonymous"
620
631
  };
621
632
  }
622
633
  /**
@@ -631,14 +642,14 @@ class B {
631
642
  * @param targetDomain - The origin of the target window
632
643
  * @returns A callable wrapper function
633
644
  */
634
- deserialize(e, s, n) {
645
+ deserialize(e, t, n) {
635
646
  const i = `${e.__id__}`, r = this.remoteFunctions.get(i);
636
647
  if (r) return r;
637
- if (this.remoteFunctions.size >= oe) {
648
+ if (this.remoteFunctions.size >= le) {
638
649
  const a = this.remoteFunctions.keys().next().value;
639
650
  a && this.remoteFunctions.delete(a);
640
651
  }
641
- const o = async (...a) => this.messenger.send(s, n, u.CALL, {
652
+ const o = async (...a) => this.messenger.send(t, n, h.CALL, {
642
653
  id: e.__id__,
643
654
  args: a
644
655
  });
@@ -662,12 +673,12 @@ class B {
662
673
  */
663
674
  setupCallHandler() {
664
675
  this.messenger.on(
665
- u.CALL,
666
- async ({ id: e, args: s }) => {
676
+ h.CALL,
677
+ async ({ id: e, args: t }) => {
667
678
  const n = this.localFunctions.get(e);
668
679
  if (!n)
669
680
  throw new Error(`Function with id "${e}" not found`);
670
- return n(...s);
681
+ return n(...t);
671
682
  }
672
683
  );
673
684
  }
@@ -710,8 +721,8 @@ class B {
710
721
  this.currentBatchIds.clear();
711
722
  return;
712
723
  }
713
- for (const s of this.localFunctions.keys())
714
- this.currentBatchIds.has(s) || this.localFunctions.delete(s);
724
+ for (const t of this.localFunctions.keys())
725
+ this.currentBatchIds.has(t) || this.localFunctions.delete(t);
715
726
  this.currentBatchIds.clear();
716
727
  }
717
728
  /**
@@ -745,175 +756,175 @@ class B {
745
756
  this.localFunctions.clear(), this.remoteFunctions.clear(), this.currentBatchIds.clear();
746
757
  }
747
758
  }
748
- function M(t, e, s = /* @__PURE__ */ new WeakSet()) {
749
- if (typeof t == "function")
750
- return e.serialize(t);
751
- if (Array.isArray(t)) {
752
- if (s.has(t))
759
+ function B(s, e, t = /* @__PURE__ */ new WeakSet()) {
760
+ if (typeof s == "function")
761
+ return e.serialize(s);
762
+ if (Array.isArray(s)) {
763
+ if (t.has(s))
753
764
  throw new Error("Circular reference detected in props - arrays cannot contain circular references");
754
- return s.add(t), t.map((n) => M(n, e, s));
765
+ return t.add(s), s.map((n) => B(n, e, t));
755
766
  }
756
- if (typeof t == "object" && t !== null) {
757
- if (s.has(t))
767
+ if (typeof s == "object" && s !== null) {
768
+ if (t.has(s))
758
769
  throw new Error("Circular reference detected in props - objects cannot contain circular references");
759
- s.add(t);
770
+ t.add(s);
760
771
  const n = {};
761
- for (const [i, r] of Object.entries(t))
762
- n[i] = M(r, e, s);
772
+ for (const [i, r] of Object.entries(s))
773
+ n[i] = B(r, e, t);
763
774
  return n;
764
775
  }
765
- return t;
776
+ return s;
766
777
  }
767
- function U(t, e, s, n, i = /* @__PURE__ */ new WeakSet()) {
768
- if (B.isFunctionRef(t))
769
- return e.deserialize(t, s, n);
770
- if (Array.isArray(t)) {
771
- if (i.has(t))
778
+ function q(s, e, t, n, i = /* @__PURE__ */ new WeakSet()) {
779
+ if (J.isFunctionRef(s))
780
+ return e.deserialize(s, t, n);
781
+ if (Array.isArray(s)) {
782
+ if (i.has(s))
772
783
  throw new Error("Circular reference detected in serialized props");
773
- return i.add(t), t.map(
774
- (r) => U(r, e, s, n, i)
784
+ return i.add(s), s.map(
785
+ (r) => q(r, e, t, n, i)
775
786
  );
776
787
  }
777
- if (typeof t == "object" && t !== null) {
778
- if (i.has(t))
788
+ if (typeof s == "object" && s !== null) {
789
+ if (i.has(s))
779
790
  throw new Error("Circular reference detected in serialized props");
780
- i.add(t);
791
+ i.add(s);
781
792
  const r = {};
782
- for (const [o, a] of Object.entries(t))
783
- r[o] = U(a, e, s, n, i);
793
+ for (const [o, a] of Object.entries(s))
794
+ r[o] = q(a, e, t, n, i);
784
795
  return r;
785
796
  }
786
- return t;
797
+ return s;
787
798
  }
788
- function j(t = window) {
799
+ function V(s = window) {
789
800
  try {
790
- return t.location.origin;
801
+ return s.location.origin;
791
802
  } catch {
792
803
  return "";
793
804
  }
794
805
  }
795
- function _e(t, e = window) {
806
+ function be(s, e = window) {
796
807
  try {
797
- return t.location.origin === e.location.origin;
808
+ return s.location.origin === e.location.origin;
798
809
  } catch {
799
810
  return !1;
800
811
  }
801
812
  }
802
- function we(t, e) {
803
- return typeof t == "string" ? t === "*" ? !0 : t === e : t instanceof RegExp ? t.test(e) : Array.isArray(t) ? t.some((s) => we(s, e)) : !1;
813
+ function L(s, e) {
814
+ return typeof s == "string" ? s === "*" ? !0 : s === e : s instanceof RegExp ? s.test(e) : Array.isArray(s) ? s.some((t) => L(t, e)) : !1;
804
815
  }
805
- function Ee(t) {
806
- if (!t) return !0;
816
+ function Pe(s) {
817
+ if (!s) return !0;
807
818
  try {
808
- return t.closed;
819
+ return s.closed;
809
820
  } catch {
810
821
  return !0;
811
822
  }
812
823
  }
813
- function $e(t = window) {
824
+ function He(s = window) {
814
825
  try {
815
- return t.opener;
826
+ return s.opener;
816
827
  } catch {
817
828
  return null;
818
829
  }
819
830
  }
820
- function Fe(t = window) {
831
+ function Ae(s = window) {
821
832
  try {
822
- const e = t.parent;
823
- return e && e !== t ? e : null;
833
+ const e = s.parent;
834
+ return e && e !== s ? e : null;
824
835
  } catch {
825
836
  return null;
826
837
  }
827
838
  }
828
- function Le(t = window) {
839
+ function Ue(s = window) {
829
840
  try {
830
- return t.parent !== t;
841
+ return s.parent !== s;
831
842
  } catch {
832
843
  return !0;
833
844
  }
834
845
  }
835
- function Ae(t = window) {
846
+ function Me(s = window) {
836
847
  try {
837
- return t.opener !== null && t.opener !== void 0;
848
+ return s.opener !== null && s.opener !== void 0;
838
849
  } catch {
839
850
  return !1;
840
851
  }
841
852
  }
842
- const ae = 32 * 1024;
843
- function He(t) {
844
- const e = We(t);
853
+ const he = 32 * 1024;
854
+ function We(s) {
855
+ const e = ze(s);
845
856
  return `${N}${e}`;
846
857
  }
847
- function be(t) {
848
- if (!t || !t.startsWith(N))
858
+ function Oe(s) {
859
+ if (!s || !s.startsWith(N))
849
860
  return null;
850
- const e = t.slice(N.length);
851
- return ze(e);
861
+ const e = s.slice(N.length);
862
+ return je(e);
852
863
  }
853
- function J(t = window) {
864
+ function X(s = window) {
854
865
  try {
855
- return t.name.startsWith(N);
866
+ return s.name.startsWith(N);
856
867
  } catch {
857
868
  return !1;
858
869
  }
859
870
  }
860
- function H(t, e = window) {
861
- return be(e.name)?.tag === t;
871
+ function W(s, e = window) {
872
+ return Oe(e.name)?.tag === s;
862
873
  }
863
- function We(t) {
874
+ function ze(s) {
864
875
  try {
865
- const e = JSON.stringify(t), s = btoa(encodeURIComponent(e)), n = new Blob([s]).size;
866
- if (n > ae)
876
+ const e = JSON.stringify(s), t = btoa(encodeURIComponent(e)), n = new Blob([t]).size;
877
+ if (n > he)
867
878
  throw new Error(
868
- `Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${ae / 1024}KB). Consider reducing the amount of data passed via props.`
879
+ `Payload size (${Math.round(n / 1024)}KB) exceeds maximum allowed size (${he / 1024}KB). Consider reducing the amount of data passed via props.`
869
880
  );
870
- return s;
881
+ return t;
871
882
  } catch (e) {
872
883
  throw e instanceof Error && e.message.includes("Payload size") ? e : new Error(`Failed to encode payload: ${e}`);
873
884
  }
874
885
  }
875
- function ze(t) {
886
+ function je(s) {
876
887
  try {
877
- const e = decodeURIComponent(atob(t));
888
+ const e = decodeURIComponent(atob(s));
878
889
  return JSON.parse(e);
879
890
  } catch {
880
891
  return null;
881
892
  }
882
893
  }
883
- function Me(t) {
894
+ function Be(s) {
884
895
  return {
885
- uid: t.uid,
886
- tag: t.tag,
887
- version: pe,
888
- context: t.context,
889
- consumerDomain: t.consumerDomain,
890
- props: t.props,
891
- exports: t.exports,
892
- children: t.children
896
+ uid: s.uid,
897
+ tag: s.tag,
898
+ version: ye,
899
+ context: s.context,
900
+ consumerDomain: s.consumerDomain,
901
+ props: s.props,
902
+ exports: s.exports,
903
+ children: s.children
893
904
  };
894
905
  }
895
- function Ue(t = window) {
896
- return be(t.name);
906
+ function qe(s = window) {
907
+ return Oe(s.name);
897
908
  }
898
- const ce = 100, w = /* @__PURE__ */ new Map();
899
- function je() {
900
- const t = [];
901
- for (const [e, s] of w.entries())
902
- Ee(s) && t.push(e);
903
- for (const e of t)
904
- w.delete(e);
909
+ const ue = 100, E = /* @__PURE__ */ new Map();
910
+ function Ve() {
911
+ const s = [];
912
+ for (const [e, t] of E.entries())
913
+ Pe(t) && s.push(e);
914
+ for (const e of s)
915
+ E.delete(e);
905
916
  }
906
- function Be(t, e) {
907
- if (w.size >= ce && je(), w.size >= ce) {
908
- const s = w.keys().next().value;
909
- s && w.delete(s);
917
+ function Je(s, e) {
918
+ if (E.size >= ue && Ve(), E.size >= ue) {
919
+ const t = E.keys().next().value;
920
+ t && E.delete(t);
910
921
  }
911
- w.set(t, e);
922
+ E.set(s, e);
912
923
  }
913
- function Je(t) {
914
- w.delete(t);
924
+ function Xe(s) {
925
+ E.delete(s);
915
926
  }
916
- class m {
927
+ class y {
917
928
  /** @internal */
918
929
  _optional = !1;
919
930
  /** @internal */
@@ -976,11 +987,11 @@ class m {
976
987
  * ```
977
988
  */
978
989
  default(e) {
979
- const s = this._clone();
980
- return s._default = e, s;
990
+ const t = this._clone();
991
+ return t._default = e, t;
981
992
  }
982
993
  }
983
- class V extends m {
994
+ class K extends y {
984
995
  /** @internal */
985
996
  _minLength;
986
997
  /** @internal */
@@ -997,26 +1008,26 @@ class V extends m {
997
1008
  return {
998
1009
  issues: [{ message: `Expected string, got ${typeof e}` }]
999
1010
  };
1000
- const s = this._trim ? e.trim() : e;
1001
- return this._minLength !== void 0 && s.length < this._minLength ? {
1011
+ const t = this._trim ? e.trim() : e;
1012
+ return this._minLength !== void 0 && t.length < this._minLength ? {
1002
1013
  issues: [
1003
1014
  { message: `String must be at least ${this._minLength} characters` }
1004
1015
  ]
1005
- } : this._maxLength !== void 0 && s.length > this._maxLength ? {
1016
+ } : this._maxLength !== void 0 && t.length > this._maxLength ? {
1006
1017
  issues: [
1007
1018
  { message: `String must be at most ${this._maxLength} characters` }
1008
1019
  ]
1009
- } : this._pattern && !this._pattern.test(s) ? {
1020
+ } : this._pattern && !this._pattern.test(t) ? {
1010
1021
  issues: [
1011
1022
  {
1012
1023
  message: this._patternMessage || `String must match pattern ${this._pattern}`
1013
1024
  }
1014
1025
  ]
1015
- } : { value: s };
1026
+ } : { value: t };
1016
1027
  }
1017
1028
  /** @internal */
1018
1029
  _clone() {
1019
- const e = new V();
1030
+ const e = new K();
1020
1031
  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;
1021
1032
  }
1022
1033
  /**
@@ -1030,8 +1041,8 @@ class V extends m {
1030
1041
  * ```
1031
1042
  */
1032
1043
  min(e) {
1033
- const s = this._clone();
1034
- return s._minLength = e, s;
1044
+ const t = this._clone();
1045
+ return t._minLength = e, t;
1035
1046
  }
1036
1047
  /**
1037
1048
  * Requires maximum string length.
@@ -1044,8 +1055,8 @@ class V extends m {
1044
1055
  * ```
1045
1056
  */
1046
1057
  max(e) {
1047
- const s = this._clone();
1048
- return s._maxLength = e, s;
1058
+ const t = this._clone();
1059
+ return t._maxLength = e, t;
1049
1060
  }
1050
1061
  /**
1051
1062
  * Requires exact string length.
@@ -1058,8 +1069,8 @@ class V extends m {
1058
1069
  * ```
1059
1070
  */
1060
1071
  length(e) {
1061
- const s = this._clone();
1062
- return s._minLength = e, s._maxLength = e, s;
1072
+ const t = this._clone();
1073
+ return t._minLength = e, t._maxLength = e, t;
1063
1074
  }
1064
1075
  /**
1065
1076
  * Requires string to match a regex pattern.
@@ -1072,9 +1083,9 @@ class V extends m {
1072
1083
  * slug: prop.string().pattern(/^[a-z0-9-]+$/, 'Invalid slug format')
1073
1084
  * ```
1074
1085
  */
1075
- pattern(e, s) {
1086
+ pattern(e, t) {
1076
1087
  const n = this._clone();
1077
- return n._pattern = e, n._patternMessage = s, n;
1088
+ return n._pattern = e, n._patternMessage = t, n;
1078
1089
  }
1079
1090
  /**
1080
1091
  * Validates as email address.
@@ -1141,7 +1152,7 @@ class V extends m {
1141
1152
  return e._minLength = 1, e;
1142
1153
  }
1143
1154
  }
1144
- class q extends m {
1155
+ class Y extends y {
1145
1156
  /** @internal */
1146
1157
  _min;
1147
1158
  /** @internal */
@@ -1156,7 +1167,7 @@ class q extends m {
1156
1167
  }
1157
1168
  /** @internal */
1158
1169
  _clone() {
1159
- const e = new q();
1170
+ const e = new Y();
1160
1171
  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;
1161
1172
  }
1162
1173
  /**
@@ -1170,8 +1181,8 @@ class q extends m {
1170
1181
  * ```
1171
1182
  */
1172
1183
  min(e) {
1173
- const s = this._clone();
1174
- return s._min = e, s;
1184
+ const t = this._clone();
1185
+ return t._min = e, t;
1175
1186
  }
1176
1187
  /**
1177
1188
  * Requires maximum value.
@@ -1184,8 +1195,8 @@ class q extends m {
1184
1195
  * ```
1185
1196
  */
1186
1197
  max(e) {
1187
- const s = this._clone();
1188
- return s._max = e, s;
1198
+ const t = this._clone();
1199
+ return t._max = e, t;
1189
1200
  }
1190
1201
  /**
1191
1202
  * Requires integer value.
@@ -1236,7 +1247,7 @@ class q extends m {
1236
1247
  return e._max = -Number.MIN_VALUE, e;
1237
1248
  }
1238
1249
  }
1239
- class X extends m {
1250
+ class Z extends y {
1240
1251
  /** @internal */
1241
1252
  _validate(e) {
1242
1253
  return typeof e != "boolean" ? {
@@ -1245,11 +1256,11 @@ class X extends m {
1245
1256
  }
1246
1257
  /** @internal */
1247
1258
  _clone() {
1248
- const e = new X();
1259
+ const e = new Z();
1249
1260
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1250
1261
  }
1251
1262
  }
1252
- class Y extends m {
1263
+ class G extends y {
1253
1264
  /** @internal */
1254
1265
  _validate(e) {
1255
1266
  return typeof e != "function" ? {
@@ -1258,11 +1269,11 @@ class Y extends m {
1258
1269
  }
1259
1270
  /** @internal */
1260
1271
  _clone() {
1261
- const e = new Y();
1272
+ const e = new G();
1262
1273
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1263
1274
  }
1264
1275
  }
1265
- class T extends m {
1276
+ class F extends y {
1266
1277
  /** @internal */
1267
1278
  _itemSchema;
1268
1279
  /** @internal */
@@ -1288,7 +1299,7 @@ class T extends m {
1288
1299
  ]
1289
1300
  };
1290
1301
  if (this._itemSchema) {
1291
- const s = [];
1302
+ const t = [];
1292
1303
  for (let n = 0; n < e.length; n++) {
1293
1304
  const i = this._itemSchema["~standard"].validate(e[n]);
1294
1305
  if (i instanceof Promise)
@@ -1302,15 +1313,15 @@ class T extends m {
1302
1313
  path: [n, ...r.path || []]
1303
1314
  }))
1304
1315
  };
1305
- s.push(i.value);
1316
+ t.push(i.value);
1306
1317
  }
1307
- return { value: s };
1318
+ return { value: t };
1308
1319
  }
1309
1320
  return { value: e };
1310
1321
  }
1311
1322
  /** @internal */
1312
1323
  _clone() {
1313
- const e = new T();
1324
+ const e = new F();
1314
1325
  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;
1315
1326
  }
1316
1327
  /**
@@ -1326,8 +1337,8 @@ class T extends m {
1326
1337
  * ```
1327
1338
  */
1328
1339
  of(e) {
1329
- const s = new T();
1330
- return s._optional = this._optional, s._nullable = this._nullable, s._itemSchema = e, s._minLength = this._minLength, s._maxLength = this._maxLength, s;
1340
+ const t = new F();
1341
+ return t._optional = this._optional, t._nullable = this._nullable, t._itemSchema = e, t._minLength = this._minLength, t._maxLength = this._maxLength, t;
1331
1342
  }
1332
1343
  /**
1333
1344
  * Requires minimum array length.
@@ -1340,8 +1351,8 @@ class T extends m {
1340
1351
  * ```
1341
1352
  */
1342
1353
  min(e) {
1343
- const s = this._clone();
1344
- return s._minLength = e, s;
1354
+ const t = this._clone();
1355
+ return t._minLength = e, t;
1345
1356
  }
1346
1357
  /**
1347
1358
  * Requires maximum array length.
@@ -1354,8 +1365,8 @@ class T extends m {
1354
1365
  * ```
1355
1366
  */
1356
1367
  max(e) {
1357
- const s = this._clone();
1358
- return s._maxLength = e, s;
1368
+ const t = this._clone();
1369
+ return t._maxLength = e, t;
1359
1370
  }
1360
1371
  /**
1361
1372
  * Requires non-empty array.
@@ -1369,7 +1380,7 @@ class T extends m {
1369
1380
  return this.min(1);
1370
1381
  }
1371
1382
  }
1372
- class k extends m {
1383
+ class $ extends y {
1373
1384
  /** @internal */
1374
1385
  _shape;
1375
1386
  /** @internal */
@@ -1384,18 +1395,18 @@ class k extends m {
1384
1395
  }
1385
1396
  ]
1386
1397
  };
1387
- const s = e, n = {};
1398
+ const t = e, n = {};
1388
1399
  if (this._shape) {
1389
1400
  if (this._strict) {
1390
1401
  const i = new Set(Object.keys(this._shape));
1391
- for (const r of Object.keys(s))
1402
+ for (const r of Object.keys(t))
1392
1403
  if (!i.has(r))
1393
1404
  return {
1394
1405
  issues: [{ message: `Unknown key: ${r}`, path: [r] }]
1395
1406
  };
1396
1407
  }
1397
1408
  for (const [i, r] of Object.entries(this._shape)) {
1398
- const o = r["~standard"].validate(s[i]);
1409
+ const o = r["~standard"].validate(t[i]);
1399
1410
  if (o instanceof Promise)
1400
1411
  throw new Error(
1401
1412
  "Async schema validation is not supported. Use synchronous schemas."
@@ -1410,15 +1421,15 @@ class k extends m {
1410
1421
  n[i] = o.value;
1411
1422
  }
1412
1423
  if (!this._strict)
1413
- for (const i of Object.keys(s))
1414
- i in this._shape || (n[i] = s[i]);
1424
+ for (const i of Object.keys(t))
1425
+ i in this._shape || (n[i] = t[i]);
1415
1426
  return { value: n };
1416
1427
  }
1417
1428
  return { value: e };
1418
1429
  }
1419
1430
  /** @internal */
1420
1431
  _clone() {
1421
- const e = new k();
1432
+ const e = new $();
1422
1433
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e._shape = this._shape, e._strict = this._strict, e;
1423
1434
  }
1424
1435
  /**
@@ -1436,8 +1447,8 @@ class k extends m {
1436
1447
  * ```
1437
1448
  */
1438
1449
  shape(e) {
1439
- const s = new k();
1440
- return s._optional = this._optional, s._nullable = this._nullable, s._shape = e, s._strict = this._strict, s;
1450
+ const t = new $();
1451
+ return t._optional = this._optional, t._nullable = this._nullable, t._shape = e, t._strict = this._strict, t;
1441
1452
  }
1442
1453
  /**
1443
1454
  * Rejects objects with unknown keys.
@@ -1452,7 +1463,7 @@ class k extends m {
1452
1463
  return e._strict = !0, e;
1453
1464
  }
1454
1465
  }
1455
- class Z extends m {
1466
+ class Q extends y {
1456
1467
  /** @internal */
1457
1468
  _value;
1458
1469
  constructor(e) {
@@ -1466,11 +1477,11 @@ class Z extends m {
1466
1477
  }
1467
1478
  /** @internal */
1468
1479
  _clone() {
1469
- const e = new Z(this._value);
1480
+ const e = new Q(this._value);
1470
1481
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1471
1482
  }
1472
1483
  }
1473
- class G extends m {
1484
+ class ee extends y {
1474
1485
  /** @internal */
1475
1486
  _values;
1476
1487
  constructor(e) {
@@ -1481,18 +1492,18 @@ class G extends m {
1481
1492
  return this._values.includes(e) ? { value: e } : {
1482
1493
  issues: [
1483
1494
  {
1484
- message: `Expected one of [${this._values.map((s) => JSON.stringify(s)).join(", ")}], got ${JSON.stringify(e)}`
1495
+ message: `Expected one of [${this._values.map((t) => JSON.stringify(t)).join(", ")}], got ${JSON.stringify(e)}`
1485
1496
  }
1486
1497
  ]
1487
1498
  };
1488
1499
  }
1489
1500
  /** @internal */
1490
1501
  _clone() {
1491
- const e = new G(this._values);
1502
+ const e = new ee(this._values);
1492
1503
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1493
1504
  }
1494
1505
  }
1495
- class K extends m {
1506
+ class te extends y {
1496
1507
  constructor() {
1497
1508
  super(), this._nullable = !0;
1498
1509
  }
@@ -1502,7 +1513,7 @@ class K extends m {
1502
1513
  }
1503
1514
  /** @internal */
1504
1515
  _clone() {
1505
- const e = new K();
1516
+ const e = new te();
1506
1517
  return e._optional = this._optional, e._nullable = this._nullable, e._default = this._default, e;
1507
1518
  }
1508
1519
  }
@@ -1519,7 +1530,7 @@ const d = {
1519
1530
  * prop.string().pattern(/^[a-z]+$/)
1520
1531
  * ```
1521
1532
  */
1522
- string: () => new V(),
1533
+ string: () => new K(),
1523
1534
  /**
1524
1535
  * Creates a number schema.
1525
1536
  *
@@ -1531,7 +1542,7 @@ const d = {
1531
1542
  * prop.number().positive()
1532
1543
  * ```
1533
1544
  */
1534
- number: () => new q(),
1545
+ number: () => new Y(),
1535
1546
  /**
1536
1547
  * Creates a boolean schema.
1537
1548
  *
@@ -1541,7 +1552,7 @@ const d = {
1541
1552
  * prop.boolean().default(false)
1542
1553
  * ```
1543
1554
  */
1544
- boolean: () => new X(),
1555
+ boolean: () => new Z(),
1545
1556
  /**
1546
1557
  * Creates a function schema.
1547
1558
  *
@@ -1554,7 +1565,7 @@ const d = {
1554
1565
  * prop.function<(data: { id: string }) => Promise<void>>()
1555
1566
  * ```
1556
1567
  */
1557
- function: () => new Y(),
1568
+ function: () => new G(),
1558
1569
  /**
1559
1570
  * Creates an array schema.
1560
1571
  *
@@ -1567,7 +1578,7 @@ const d = {
1567
1578
  * prop.array().of(prop.number()).min(1).max(10)
1568
1579
  * ```
1569
1580
  */
1570
- array: () => new T(),
1581
+ array: () => new F(),
1571
1582
  /**
1572
1583
  * Creates an object schema.
1573
1584
  *
@@ -1583,7 +1594,7 @@ const d = {
1583
1594
  * prop.object().shape({ key: prop.string() }).strict()
1584
1595
  * ```
1585
1596
  */
1586
- object: () => new k(),
1597
+ object: () => new $(),
1587
1598
  /**
1588
1599
  * Creates a literal schema for exact value matching.
1589
1600
  *
@@ -1596,7 +1607,7 @@ const d = {
1596
1607
  * prop.literal(true)
1597
1608
  * ```
1598
1609
  */
1599
- literal: (t) => new Z(t),
1610
+ literal: (s) => new Q(s),
1600
1611
  /**
1601
1612
  * Creates an enum schema for a set of allowed values.
1602
1613
  *
@@ -1608,7 +1619,7 @@ const d = {
1608
1619
  * prop.enum([1, 2, 3])
1609
1620
  * ```
1610
1621
  */
1611
- enum: (t) => new G(t),
1622
+ enum: (s) => new ee(s),
1612
1623
  /**
1613
1624
  * Creates a schema that accepts any value.
1614
1625
  *
@@ -1620,7 +1631,7 @@ const d = {
1620
1631
  * prop.any()
1621
1632
  * ```
1622
1633
  */
1623
- any: () => new K()
1634
+ any: () => new te()
1624
1635
  }, R = {
1625
1636
  uid: {
1626
1637
  schema: d.string().optional(),
@@ -1688,118 +1699,118 @@ const d = {
1688
1699
  sendToHost: !1
1689
1700
  }
1690
1701
  };
1691
- function E(t) {
1692
- return typeof t == "object" && t !== null && "~standard" in t && typeof t["~standard"] == "object" && t["~standard"] !== null && t["~standard"].version === 1 && typeof t["~standard"].validate == "function";
1702
+ function b(s) {
1703
+ return typeof s == "object" && s !== null && "~standard" in s && typeof s["~standard"] == "object" && s["~standard"] !== null && s["~standard"].version === 1 && typeof s["~standard"].validate == "function";
1693
1704
  }
1694
- function Ve(t, e, s) {
1695
- const n = t["~standard"].validate(e);
1705
+ function Ke(s, e, t) {
1706
+ const n = s["~standard"].validate(e);
1696
1707
  if (n instanceof Promise)
1697
1708
  throw new Error(
1698
- `Prop "${s}" 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.`
1709
+ `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.`
1699
1710
  );
1700
1711
  if (n.issues) {
1701
- const i = n.issues.map((r) => `${qe(r.path, s)}: ${r.message}`);
1712
+ const i = n.issues.map((r) => `${Ye(r.path, t)}: ${r.message}`);
1702
1713
  throw new Error(`Validation failed: ${i.join("; ")}`);
1703
1714
  }
1704
1715
  return n.value;
1705
1716
  }
1706
- function qe(t, e) {
1707
- if (!t || t.length === 0)
1717
+ function Ye(s, e) {
1718
+ if (!s || s.length === 0)
1708
1719
  return e;
1709
- const s = t.map((n) => typeof n == "object" && n !== null && "key" in n ? String(n.key) : String(n));
1710
- return `${e}.${s.join(".")}`;
1720
+ const t = s.map((n) => typeof n == "object" && n !== null && "key" in n ? String(n.key) : String(n));
1721
+ return `${e}.${t.join(".")}`;
1711
1722
  }
1712
- function le(t, e, s) {
1723
+ function de(s, e, t) {
1713
1724
  const n = {
1714
1725
  ...R,
1715
1726
  ...e
1716
1727
  }, i = {};
1717
1728
  for (const [r, o] of Object.entries(n)) {
1718
- const c = E(o) ? { schema: o } : o;
1729
+ const c = b(o) ? { schema: o } : o;
1719
1730
  let l;
1720
- const h = c.alias, g = r in t, y = h && h in t;
1721
- if (g)
1722
- l = t[r];
1723
- else if (y)
1724
- l = t[h];
1731
+ const u = c.alias, w = r in s, _ = u && u in s;
1732
+ if (w)
1733
+ l = s[r];
1734
+ else if (_)
1735
+ l = s[u];
1725
1736
  else if (c.value)
1726
- l = c.value(s);
1737
+ l = c.value(t);
1727
1738
  else if (c.default !== void 0)
1728
- l = typeof c.default == "function" ? c.default(s) : c.default;
1729
- else if (c.schema && E(c.schema)) {
1730
- const b = c.schema["~standard"].validate(void 0);
1731
- !(b instanceof Promise) && !b.issues && (l = b.value);
1739
+ l = typeof c.default == "function" ? c.default(t) : c.default;
1740
+ else if (c.schema && b(c.schema)) {
1741
+ const P = c.schema["~standard"].validate(void 0);
1742
+ !(P instanceof Promise) && !P.issues && (l = P.value);
1732
1743
  }
1733
1744
  l !== void 0 && c.decorate && (l = c.decorate({ value: l, props: i })), i[r] = l;
1734
1745
  }
1735
1746
  return i;
1736
1747
  }
1737
- function Xe(t, e) {
1738
- const s = {
1748
+ function Ze(s, e) {
1749
+ const t = {
1739
1750
  ...R,
1740
1751
  ...e
1741
1752
  };
1742
- for (const [n, i] of Object.entries(s)) {
1743
- const r = E(i), o = r ? { schema: i } : i;
1744
- let a = t[n];
1753
+ for (const [n, i] of Object.entries(t)) {
1754
+ const r = b(i), o = r ? { schema: i } : i;
1755
+ let a = s[n];
1745
1756
  if (o.required && a === void 0)
1746
1757
  throw new Error(`Prop "${n}" is required but was not provided`);
1747
- if (o.schema && E(o.schema))
1748
- (a !== void 0 || r) && (a = Ve(o.schema, a, n), t[n] = a);
1758
+ if (o.schema && b(o.schema))
1759
+ (a !== void 0 || r) && (a = Ke(o.schema, a, n), s[n] = a);
1749
1760
  else if (a === void 0)
1750
1761
  continue;
1751
- o.validate && o.validate({ value: a, props: t });
1762
+ o.validate && o.validate({ value: a, props: s });
1752
1763
  }
1753
1764
  }
1754
- function ue(t, e, s, n) {
1765
+ function fe(s, e, t, n) {
1755
1766
  const i = {
1756
1767
  ...R,
1757
1768
  ...e
1758
1769
  }, r = {};
1759
1770
  for (const [o, a] of Object.entries(i)) {
1760
- const l = E(a) ? { schema: a } : a, h = t[o];
1771
+ const l = b(a) ? { schema: a } : a, u = s[o];
1761
1772
  if (l.sendToHost === !1 || l.sameDomain && !n) continue;
1762
1773
  if (l.trustedDomains) {
1763
- const y = l.trustedDomains;
1764
- if (!we(y, s)) continue;
1774
+ const _ = l.trustedDomains;
1775
+ if (!L(_, t)) continue;
1765
1776
  }
1766
- let g = h;
1767
- l.hostDecorate && h !== void 0 && (g = l.hostDecorate({ value: h, props: t })), r[o] = g;
1777
+ let w = u;
1778
+ l.hostDecorate && u !== void 0 && (w = l.hostDecorate({ value: u, props: s })), r[o] = w;
1768
1779
  }
1769
1780
  return r;
1770
1781
  }
1771
- function Ye(t, e) {
1772
- const s = new URLSearchParams(), n = {
1782
+ function Ge(s, e) {
1783
+ const t = new URLSearchParams(), n = {
1773
1784
  ...R,
1774
1785
  ...e
1775
1786
  };
1776
1787
  for (const [i, r] of Object.entries(n)) {
1777
- const a = E(r) ? { schema: r } : r, c = t[i];
1788
+ const a = b(r) ? { schema: r } : r, c = s[i];
1778
1789
  if (c === void 0 || typeof c == "function" || !a.queryParam) continue;
1779
1790
  const l = typeof a.queryParam == "string" ? a.queryParam : i;
1780
- let h;
1781
- typeof a.queryParam == "function" ? h = a.queryParam({ value: c }) : typeof c == "object" ? h = JSON.stringify(c) : h = String(c), s.set(l, h);
1791
+ let u;
1792
+ typeof a.queryParam == "function" ? u = a.queryParam({ value: c }) : typeof c == "object" ? u = JSON.stringify(c) : u = String(c), t.set(l, u);
1782
1793
  }
1783
- return s;
1794
+ return t;
1784
1795
  }
1785
- function Pe(t, e = "") {
1786
- const s = [];
1787
- for (const [n, i] of Object.entries(t)) {
1796
+ function Re(s, e = "") {
1797
+ const t = [];
1798
+ for (const [n, i] of Object.entries(s)) {
1788
1799
  const r = e ? `${e}.${n}` : n;
1789
1800
  if (i !== null && typeof i == "object" && !Array.isArray(i))
1790
- s.push(Pe(i, r));
1801
+ t.push(Re(i, r));
1791
1802
  else {
1792
1803
  const o = encodeURIComponent(JSON.stringify(i));
1793
- s.push(`${r}=${o}`);
1804
+ t.push(`${r}=${o}`);
1794
1805
  }
1795
1806
  }
1796
- return s.filter(Boolean).join("&");
1807
+ return t.filter(Boolean).join("&");
1797
1808
  }
1798
- function Ze(t) {
1809
+ function Qe(s) {
1799
1810
  const e = {};
1800
- if (!t) return e;
1801
- const s = t.split("&");
1802
- for (const n of s) {
1811
+ if (!s) return e;
1812
+ const t = s.split("&");
1813
+ for (const n of t) {
1803
1814
  const [i, r] = n.split("=");
1804
1815
  if (!i || r === void 0) continue;
1805
1816
  let o;
@@ -1811,55 +1822,55 @@ function Ze(t) {
1811
1822
  const a = i.split(".");
1812
1823
  let c = e;
1813
1824
  for (let l = 0; l < a.length - 1; l++) {
1814
- const h = a[l];
1815
- (!(h in c) || typeof c[h] != "object") && (c[h] = {}), c = c[h];
1825
+ const u = a[l];
1826
+ (!(u in c) || typeof c[u] != "object") && (c[u] = {}), c = c[u];
1816
1827
  }
1817
1828
  c[a[a.length - 1]] = o;
1818
1829
  }
1819
1830
  return e;
1820
1831
  }
1821
- function Ge(t) {
1822
- return typeof t == "object" && t !== null && t.__type__ === "dotify" && typeof t.__value__ == "string";
1832
+ function et(s) {
1833
+ return typeof s == "object" && s !== null && s.__type__ === "dotify" && typeof s.__value__ == "string";
1823
1834
  }
1824
- function he(t, e, s) {
1835
+ function pe(s, e, t) {
1825
1836
  const n = {
1826
1837
  ...R,
1827
1838
  ...e
1828
1839
  }, i = {};
1829
- for (const [r, o] of Object.entries(t)) {
1840
+ for (const [r, o] of Object.entries(s)) {
1830
1841
  if (o === void 0) continue;
1831
1842
  const a = n[r];
1832
- i[r] = Ke(o, a, s);
1843
+ i[r] = tt(o, a, t);
1833
1844
  }
1834
1845
  return i;
1835
1846
  }
1836
- function Ke(t, e, s) {
1837
- if (typeof t == "function")
1838
- return s.serialize(t);
1847
+ function tt(s, e, t) {
1848
+ if (typeof s == "function")
1849
+ return t.serialize(s);
1839
1850
  const n = e?.serialization ?? I.JSON;
1840
- if (n === I.BASE64 && typeof t == "object") {
1841
- const i = JSON.stringify(t);
1851
+ if (n === I.BASE64 && typeof s == "object") {
1852
+ const i = JSON.stringify(s);
1842
1853
  return {
1843
1854
  __type__: "base64",
1844
1855
  __value__: btoa(encodeURIComponent(i))
1845
1856
  };
1846
1857
  }
1847
- return n === I.DOTIFY && typeof t == "object" && t !== null && !Array.isArray(t) ? {
1858
+ return n === I.DOTIFY && typeof s == "object" && s !== null && !Array.isArray(s) ? {
1848
1859
  __type__: "dotify",
1849
- __value__: Pe(t)
1850
- } : M(t, s);
1860
+ __value__: Re(s)
1861
+ } : B(s, t);
1851
1862
  }
1852
- function de(t, e, s, n, i, r) {
1863
+ function me(s, e, t, n, i, r) {
1853
1864
  const o = {
1854
1865
  ...R,
1855
1866
  ...e
1856
1867
  }, a = {};
1857
- for (const [c, l] of Object.entries(t)) {
1858
- const h = o[c];
1859
- a[c] = Qe(
1868
+ for (const [c, l] of Object.entries(s)) {
1869
+ const u = o[c];
1870
+ a[c] = st(
1860
1871
  l,
1861
- h,
1862
- s,
1872
+ u,
1873
+ t,
1863
1874
  n,
1864
1875
  i,
1865
1876
  r
@@ -1867,65 +1878,65 @@ function de(t, e, s, n, i, r) {
1867
1878
  }
1868
1879
  return a;
1869
1880
  }
1870
- function Qe(t, e, s, n, i, r) {
1871
- if (et(t))
1881
+ function st(s, e, t, n, i, r) {
1882
+ if (nt(s))
1872
1883
  try {
1873
- const o = decodeURIComponent(atob(t.__value__));
1884
+ const o = decodeURIComponent(atob(s.__value__));
1874
1885
  return JSON.parse(o);
1875
1886
  } catch {
1876
- return t;
1887
+ return s;
1877
1888
  }
1878
- if (Ge(t))
1889
+ if (et(s))
1879
1890
  try {
1880
- return Ze(t.__value__);
1891
+ return Qe(s.__value__);
1881
1892
  } catch {
1882
- return t;
1893
+ return s;
1883
1894
  }
1884
- return U(t, n, i, r);
1895
+ return q(s, n, i, r);
1885
1896
  }
1886
- function et(t) {
1887
- return typeof t == "object" && t !== null && t.__type__ === "base64" && typeof t.__value__ == "string";
1897
+ function nt(s) {
1898
+ return typeof s == "object" && s !== null && s.__type__ === "base64" && typeof s.__value__ == "string";
1888
1899
  }
1889
- function P(t, e = "100%") {
1890
- return t === void 0 ? e : typeof t == "number" ? `${t}px` : t;
1900
+ function O(s, e = "100%") {
1901
+ return s === void 0 ? e : typeof s == "number" ? `${s}px` : s;
1891
1902
  }
1892
- function $(t, e) {
1893
- if (t === void 0) return e;
1894
- if (typeof t == "number") return t;
1895
- const s = parseInt(t, 10);
1896
- return isNaN(s) ? e : s;
1903
+ function k(s, e) {
1904
+ if (s === void 0) return e;
1905
+ if (typeof s == "number") return s;
1906
+ const t = parseInt(s, 10);
1907
+ return isNaN(t) ? e : t;
1897
1908
  }
1898
- function tt(t) {
1909
+ function it(s) {
1899
1910
  try {
1900
- t.src = "about:blank", t.parentNode?.removeChild(t);
1911
+ s.src = "about:blank", s.parentNode?.removeChild(s);
1901
1912
  } catch {
1902
1913
  }
1903
1914
  }
1904
- function st(t, e) {
1905
- rt(t, e);
1915
+ function rt(s, e) {
1916
+ ct(s, e);
1906
1917
  }
1907
- function nt(t) {
1908
- t.style.display = "", t.style.visibility = "visible";
1918
+ function ot(s) {
1919
+ s.style.display = "", s.style.visibility = "visible";
1909
1920
  }
1910
- function fe(t) {
1911
- t.style.display = "none", t.style.visibility = "hidden";
1921
+ function ge(s) {
1922
+ s.style.display = "none", s.style.visibility = "hidden";
1912
1923
  }
1913
- function it(t) {
1924
+ function at(s) {
1914
1925
  try {
1915
- t.focus(), t.contentWindow?.focus();
1926
+ s.focus(), s.contentWindow?.focus();
1916
1927
  } catch {
1917
1928
  }
1918
1929
  }
1919
- function rt(t, e) {
1920
- e.width !== void 0 && (t.style.width = P(e.width)), e.height !== void 0 && (t.style.height = P(e.height));
1930
+ function ct(s, e) {
1931
+ e.width !== void 0 && (s.style.width = O(e.width)), e.height !== void 0 && (s.style.height = O(e.height));
1921
1932
  }
1922
- class Re extends Error {
1933
+ class xe extends Error {
1923
1934
  constructor(e = "Popup blocked by browser") {
1924
1935
  super(e), this.name = "PopupOpenError";
1925
1936
  }
1926
1937
  }
1927
- function ot(t) {
1928
- const { url: e, name: s, dimensions: n } = t, i = $(n.width, 500), r = $(n.height, 500), o = Math.floor(window.screenX + (window.outerWidth - i) / 2), a = Math.floor(window.screenY + (window.outerHeight - r) / 2), c = [
1938
+ function lt(s) {
1939
+ const { url: e, name: t, dimensions: n } = s, i = k(n.width, 500), r = k(n.height, 500), o = Math.floor(window.screenX + (window.outerWidth - i) / 2), a = Math.floor(window.screenY + (window.outerHeight - r) / 2), c = [
1929
1940
  `width=${i}`,
1930
1941
  `height=${r}`,
1931
1942
  `left=${o}`,
@@ -1937,32 +1948,32 @@ function ot(t) {
1937
1948
  "status=no",
1938
1949
  "resizable=yes",
1939
1950
  "scrollbars=yes"
1940
- ].join(","), l = window.open(e, s, c);
1941
- if (!l || lt(l))
1942
- throw new Re();
1951
+ ].join(","), l = window.open(e, t, c);
1952
+ if (!l || dt(l))
1953
+ throw new xe();
1943
1954
  return l;
1944
1955
  }
1945
- function at(t) {
1956
+ function ht(s) {
1946
1957
  try {
1947
- t.closed || t.close();
1958
+ s.closed || s.close();
1948
1959
  } catch {
1949
1960
  }
1950
1961
  }
1951
- function ct(t) {
1962
+ function ut(s) {
1952
1963
  try {
1953
- t.closed || t.focus();
1964
+ s.closed || s.focus();
1954
1965
  } catch {
1955
1966
  }
1956
1967
  }
1957
- function lt(t) {
1958
- if (!t) return !0;
1968
+ function dt(s) {
1969
+ if (!s) return !0;
1959
1970
  try {
1960
- return !!(t.closed || t.innerHeight === 0 || t.innerWidth === 0);
1971
+ return !!(s.closed || s.innerHeight === 0 || s.innerWidth === 0);
1961
1972
  } catch {
1962
1973
  return !0;
1963
1974
  }
1964
1975
  }
1965
- function ut(t, e, s = {}) {
1976
+ function ft(s, e, t = {}) {
1966
1977
  const {
1967
1978
  initialInterval: n = 100,
1968
1979
  // Start fast to catch quick closes
@@ -1970,18 +1981,18 @@ function ut(t, e, s = {}) {
1970
1981
  // Cap at 2 seconds
1971
1982
  multiplier: r = 1.5
1972
1983
  // Exponential backoff multiplier
1973
- } = s;
1984
+ } = t;
1974
1985
  let o = n, a, c = !1;
1975
1986
  const l = () => {
1976
1987
  try {
1977
1988
  e();
1978
- } catch (g) {
1979
- console.error("Error in popup close callback:", g);
1989
+ } catch (w) {
1990
+ console.error("Error in popup close callback:", w);
1980
1991
  }
1981
- }, h = () => {
1992
+ }, u = () => {
1982
1993
  if (!c) {
1983
1994
  try {
1984
- if (t.closed) {
1995
+ if (s.closed) {
1985
1996
  l();
1986
1997
  return;
1987
1998
  }
@@ -1989,41 +2000,41 @@ function ut(t, e, s = {}) {
1989
2000
  l();
1990
2001
  return;
1991
2002
  }
1992
- o = Math.min(o * r, i), a = setTimeout(h, o);
2003
+ o = Math.min(o * r, i), a = setTimeout(u, o);
1993
2004
  }
1994
2005
  };
1995
- return a = setTimeout(h, o), () => {
2006
+ return a = setTimeout(u, o), () => {
1996
2007
  c = !0, clearTimeout(a);
1997
2008
  };
1998
2009
  }
1999
- function ht(t, e) {
2010
+ function pt(s, e) {
2000
2011
  try {
2001
- const s = $(e.width, t.outerWidth), n = $(
2012
+ const t = k(e.width, s.outerWidth), n = k(
2002
2013
  e.height,
2003
- t.outerHeight
2014
+ s.outerHeight
2004
2015
  );
2005
- t.resizeTo(s, n);
2016
+ s.resizeTo(t, n);
2006
2017
  } catch {
2007
2018
  }
2008
2019
  }
2009
- function dt(t) {
2010
- const { doc: e, dimensions: s, uid: n, tag: i } = t, r = e.createElement("div");
2020
+ function mt(s) {
2021
+ const { doc: e, dimensions: t, uid: n, tag: i } = s, r = e.createElement("div");
2011
2022
  return r.id = `forgeframe-container-${n}`, r.setAttribute("data-forgeframe-tag", i), Object.assign(r.style, {
2012
2023
  display: "inline-block",
2013
2024
  position: "relative",
2014
- width: P(s.width),
2015
- height: P(s.height),
2025
+ width: O(t.width),
2026
+ height: O(t.height),
2016
2027
  overflow: "hidden"
2017
2028
  }), r;
2018
2029
  }
2019
- function ft(t) {
2020
- const { doc: e, dimensions: s, cspNonce: n } = t, i = e.createElement("div");
2030
+ function gt(s) {
2031
+ const { doc: e, dimensions: t, cspNonce: n } = s, i = e.createElement("div");
2021
2032
  Object.assign(i.style, {
2022
2033
  display: "flex",
2023
2034
  alignItems: "center",
2024
2035
  justifyContent: "center",
2025
- width: P(s.width),
2026
- height: P(s.height),
2036
+ width: O(t.width),
2037
+ height: O(t.height),
2027
2038
  backgroundColor: "#f5f5f5",
2028
2039
  position: "absolute",
2029
2040
  top: "0",
@@ -2046,20 +2057,20 @@ function ft(t) {
2046
2057
  }
2047
2058
  `, i.appendChild(o), i.appendChild(r), i;
2048
2059
  }
2049
- function pt(t, e = 200) {
2050
- return new Promise((s) => {
2051
- t.style.opacity = "0", t.style.transition = `opacity ${e}ms ease-in`, t.offsetHeight, t.style.opacity = "1", setTimeout(s, e);
2060
+ function yt(s, e = 200) {
2061
+ return new Promise((t) => {
2062
+ s.style.opacity = "0", s.style.transition = `opacity ${e}ms ease-in`, s.offsetHeight, s.style.opacity = "1", setTimeout(t, e);
2052
2063
  });
2053
2064
  }
2054
- function mt(t, e = 200) {
2055
- return new Promise((s) => {
2056
- t.style.transition = `opacity ${e}ms ease-out`, t.style.opacity = "0", setTimeout(s, e);
2065
+ function wt(s, e = 200) {
2066
+ return new Promise((t) => {
2067
+ s.style.transition = `opacity ${e}ms ease-out`, s.style.opacity = "0", setTimeout(t, e);
2057
2068
  });
2058
2069
  }
2059
- async function gt(t, e, s) {
2060
- e && (await mt(e, 150), e.remove()), s.style.display = "", s.style.visibility = "visible", s.style.opacity = "0", await pt(s, 150);
2070
+ async function _t(s, e, t) {
2071
+ e && (await wt(e, 150), e.remove()), t.style.display = "", t.style.visibility = "visible", t.style.opacity = "0", await yt(t, 150);
2061
2072
  }
2062
- class Q {
2073
+ class se {
2063
2074
  /** Event emitter for lifecycle events. */
2064
2075
  event;
2065
2076
  /** Arbitrary state storage for the component instance. */
@@ -2092,6 +2103,10 @@ class Q {
2092
2103
  /** @internal */
2093
2104
  hostWindow = null;
2094
2105
  /** @internal */
2106
+ openedHostDomain = null;
2107
+ /** @internal */
2108
+ dynamicUrlTrustedOrigin = null;
2109
+ /** @internal */
2095
2110
  iframe = null;
2096
2111
  /** @internal */
2097
2112
  container = null;
@@ -2109,25 +2124,20 @@ class Q {
2109
2124
  * @param options - Component configuration options
2110
2125
  * @param props - Initial props to pass to the component
2111
2126
  */
2112
- constructor(e, s = {}) {
2113
- this._uid = Ie(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new me(), this.cleanup = new De();
2114
- const n = this.buildTrustedDomains();
2115
- this.messenger = new ye(this.uid, window, j(), n), this.bridge = new B(this.messenger);
2116
- const i = this.createPropContext();
2117
- this.props = le(s, this.options.props, i), this.setupMessageHandlers(), this.setupCleanup();
2127
+ constructor(e, t = {}) {
2128
+ this._uid = Ne(), this.options = this.normalizeOptions(e), this.context = this.options.defaultContext, this.event = new we(), this.cleanup = new Fe();
2129
+ const n = this.createPropContext();
2130
+ this.props = de(t, this.options.props, n);
2131
+ const i = this.buildTrustedDomains();
2132
+ this.messenger = new Ee(this.uid, window, V(), i), this.bridge = new J(this.messenger), this.setupMessageHandlers(), this.setupCleanup();
2118
2133
  }
2119
2134
  /**
2120
2135
  * Builds the list of trusted domains for messenger communication.
2121
2136
  * @internal
2122
2137
  */
2123
2138
  buildTrustedDomains() {
2124
- const e = [], s = typeof this.options.url == "function" ? this.options.url(this.props) : this.options.url;
2125
- try {
2126
- const n = new URL(s);
2127
- e.push(n.origin);
2128
- } catch {
2129
- }
2130
- if (this.options.domain) {
2139
+ const e = [], t = this.resolveUrlOrigin(this.resolveUrl());
2140
+ if (t && (e.push(t), this.dynamicUrlTrustedOrigin = t), this.options.domain) {
2131
2141
  if (typeof this.options.domain == "string")
2132
2142
  e.push(this.options.domain);
2133
2143
  else if (Array.isArray(this.options.domain))
@@ -2155,12 +2165,12 @@ class Q {
2155
2165
  * await instance.render(document.getElementById('target'), 'popup');
2156
2166
  * ```
2157
2167
  */
2158
- async render(e, s) {
2168
+ async render(e, t) {
2159
2169
  if (this.destroyed)
2160
2170
  throw new Error("Component has been destroyed");
2161
2171
  if (this.rendered)
2162
2172
  throw new Error("Component has already been rendered");
2163
- this.context = s ?? this.options.defaultContext, this.checkEligibility(), Xe(this.props, this.options.props), this.container = this.resolveContainer(e), this.event.emit(f.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(f.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(f.RENDER), this.callPropCallback("onRender"), await this.open(), await this.waitForHost(), this.context === p.IFRAME && this.iframe && this.prerenderElement && (await gt(
2173
+ this.context = t ?? this.options.defaultContext, this.checkEligibility(), Ze(this.props, this.options.props), this.options.validate?.({ props: this.props }), this.container = this.resolveContainer(e), this.event.emit(f.PRERENDER), this.callPropCallback("onPrerender"), await this.prerender(), this.event.emit(f.PRERENDERED), this.callPropCallback("onPrerendered"), this.event.emit(f.RENDER), this.callPropCallback("onRender"), await this.open(), await this.waitForHost(), this.context === p.IFRAME && this.iframe && this.prerenderElement && (await _t(
2164
2174
  this.container,
2165
2175
  this.prerenderElement,
2166
2176
  this.iframe
@@ -2177,8 +2187,8 @@ class Q {
2177
2187
  * @param container - CSS selector or HTMLElement to render into
2178
2188
  * @param context - Override the default rendering context
2179
2189
  */
2180
- async renderTo(e, s, n) {
2181
- return this.render(s, n);
2190
+ async renderTo(e, t, n) {
2191
+ return this.render(t, n);
2182
2192
  }
2183
2193
  /**
2184
2194
  * Closes and destroys the component.
@@ -2196,7 +2206,7 @@ class Q {
2196
2206
  * For iframes, focuses the iframe element. For popups, brings the window to front.
2197
2207
  */
2198
2208
  async focus() {
2199
- this.context === p.IFRAME && this.iframe ? it(this.iframe) : this.context === p.POPUP && this.hostWindow && ct(this.hostWindow), this.event.emit(f.FOCUS), this.callPropCallback("onFocus");
2209
+ this.context === p.IFRAME && this.iframe ? at(this.iframe) : this.context === p.POPUP && this.hostWindow && ut(this.hostWindow), this.event.emit(f.FOCUS), this.callPropCallback("onFocus");
2200
2210
  }
2201
2211
  /**
2202
2212
  * Resizes the component to the specified dimensions.
@@ -2204,7 +2214,7 @@ class Q {
2204
2214
  * @param dimensions - New width and height for the component
2205
2215
  */
2206
2216
  async resize(e) {
2207
- this.context === p.IFRAME && this.iframe ? st(this.iframe, e) : this.context === p.POPUP && this.hostWindow && ht(this.hostWindow, e), this.event.emit(f.RESIZE, e), this.callPropCallback("onResize", e);
2217
+ this.context === p.IFRAME && this.iframe ? rt(this.iframe, e) : this.context === p.POPUP && this.hostWindow && pt(this.hostWindow, e), this.event.emit(f.RESIZE, e), this.callPropCallback("onResize", e);
2208
2218
  }
2209
2219
  /**
2210
2220
  * Shows the component if hidden.
@@ -2213,7 +2223,7 @@ class Q {
2213
2223
  * Only applicable to iframe context.
2214
2224
  */
2215
2225
  async show() {
2216
- this.context === p.IFRAME && this.iframe && nt(this.iframe);
2226
+ this.context === p.IFRAME && this.iframe && ot(this.iframe);
2217
2227
  }
2218
2228
  /**
2219
2229
  * Hides the component.
@@ -2222,7 +2232,7 @@ class Q {
2222
2232
  * Only applicable to iframe context.
2223
2233
  */
2224
2234
  async hide() {
2225
- this.context === p.IFRAME && this.iframe && fe(this.iframe);
2235
+ this.context === p.IFRAME && this.iframe && ge(this.iframe);
2226
2236
  }
2227
2237
  /**
2228
2238
  * Updates the component props and sends them to the host.
@@ -2233,27 +2243,33 @@ class Q {
2233
2243
  * @param newProps - Partial props object to merge with existing props
2234
2244
  */
2235
2245
  async updateProps(e) {
2236
- const s = this.createPropContext();
2237
- if (this.props = le(
2246
+ const t = this.createPropContext(), n = de(
2238
2247
  { ...this.props, ...e },
2239
2248
  this.options.props,
2240
- s
2241
- ), this.hostWindow && !Ee(this.hostWindow)) {
2242
- const n = this.getHostDomain(), i = ue(
2243
- this.props,
2244
- this.options.props,
2249
+ t
2250
+ );
2251
+ this.options.validate?.({ props: n });
2252
+ const i = this.resolveUrl(n), r = this.resolveUrlOrigin(i);
2253
+ if (this.rendered && this.openedHostDomain && r && r !== this.openedHostDomain)
2254
+ throw new Error(
2255
+ `Cannot change component URL origin after render (from "${this.openedHostDomain}" to "${r}")`
2256
+ );
2257
+ if (this.props = n, this.rendered || this.syncTrustedDomainForUrl(i), this.hostWindow && !Pe(this.hostWindow)) {
2258
+ const o = this.openedHostDomain ?? this.getHostDomain(), a = fe(
2245
2259
  n,
2246
- _e(this.hostWindow)
2247
- ), r = he(
2248
- i,
2260
+ this.options.props,
2261
+ o,
2262
+ be(this.hostWindow)
2263
+ ), c = pe(
2264
+ a,
2249
2265
  this.options.props,
2250
2266
  this.bridge
2251
2267
  );
2252
2268
  await this.messenger.send(
2253
2269
  this.hostWindow,
2254
- n,
2255
- u.PROPS,
2256
- r
2270
+ o,
2271
+ h.PROPS,
2272
+ c
2257
2273
  );
2258
2274
  }
2259
2275
  this.event.emit(f.PROPS, this.props), this.callPropCallback("onProps", this.props);
@@ -2264,7 +2280,7 @@ class Q {
2264
2280
  * @returns A new unrendered component instance with identical configuration
2265
2281
  */
2266
2282
  clone() {
2267
- return new Q(this.options, this.props);
2283
+ return new se(this.options, this.props);
2268
2284
  }
2269
2285
  /**
2270
2286
  * Checks if the component is eligible to render based on the eligible option.
@@ -2283,11 +2299,54 @@ class Q {
2283
2299
  ...e,
2284
2300
  props: e.props ?? {},
2285
2301
  defaultContext: e.defaultContext ?? p.IFRAME,
2286
- dimensions: typeof e.dimensions == "function" ? e.dimensions(this.props) : e.dimensions ?? { width: "100%", height: "100%" },
2302
+ dimensions: e.dimensions ?? { width: "100%", height: "100%" },
2287
2303
  timeout: e.timeout ?? 1e4,
2288
2304
  children: e.children
2289
2305
  };
2290
2306
  }
2307
+ /**
2308
+ * Resolves the host URL from static or function options.
2309
+ * @internal
2310
+ */
2311
+ resolveUrl(e = this.props) {
2312
+ return typeof this.options.url == "function" ? this.options.url(e) : this.options.url;
2313
+ }
2314
+ /**
2315
+ * Resolves dimensions from static or function options.
2316
+ * @internal
2317
+ */
2318
+ resolveDimensions() {
2319
+ return typeof this.options.dimensions == "function" ? this.options.dimensions(this.props) : this.options.dimensions;
2320
+ }
2321
+ /**
2322
+ * Resolves a URL to an origin, supporting relative URLs.
2323
+ * @internal
2324
+ */
2325
+ resolveUrlOrigin(e) {
2326
+ try {
2327
+ return new URL(e, window.location.origin).origin;
2328
+ } catch {
2329
+ return null;
2330
+ }
2331
+ }
2332
+ /**
2333
+ * Returns true when the domain option explicitly includes this origin.
2334
+ * @internal
2335
+ */
2336
+ isExplicitDomainTrust(e) {
2337
+ return !this.options.domain || this.options.domain instanceof RegExp ? !1 : typeof this.options.domain == "string" ? this.options.domain === e : this.options.domain.includes(e);
2338
+ }
2339
+ /**
2340
+ * Ensures the messenger trusts the origin for a resolved host URL.
2341
+ * @internal
2342
+ */
2343
+ syncTrustedDomainForUrl(e) {
2344
+ const t = this.resolveUrlOrigin(e);
2345
+ if (!t)
2346
+ return;
2347
+ const n = this.dynamicUrlTrustedOrigin;
2348
+ n && n !== t && !this.isExplicitDomainTrust(n) && this.messenger.removeTrustedDomain(n), this.messenger.addTrustedDomain(t), this.dynamicUrlTrustedOrigin = t;
2349
+ }
2291
2350
  /**
2292
2351
  * Creates the prop context passed to prop callbacks and validators.
2293
2352
  * @internal
@@ -2312,10 +2371,10 @@ class Q {
2312
2371
  if (!e)
2313
2372
  throw new Error("Container is required for rendering");
2314
2373
  if (typeof e == "string") {
2315
- const s = document.querySelector(e);
2316
- if (!s)
2374
+ const t = document.querySelector(e);
2375
+ if (!t)
2317
2376
  throw new Error(`Container "${e}" not found`);
2318
- return s;
2377
+ return t;
2319
2378
  }
2320
2379
  return e;
2321
2380
  }
@@ -2335,10 +2394,10 @@ class Q {
2335
2394
  */
2336
2395
  async prerender() {
2337
2396
  if (!this.container) return;
2338
- const e = this.options.prerenderTemplate ?? ft, s = this.options.containerTemplate ?? dt, n = this.options.dimensions, i = this.props.cspNonce;
2397
+ const e = this.options.prerenderTemplate ?? gt, t = this.options.containerTemplate ?? mt, n = this.resolveDimensions(), i = this.props.cspNonce;
2339
2398
  if (this.context === p.IFRAME) {
2340
2399
  const c = this.buildWindowName();
2341
- this.iframe = this.createIframeElement(c), fe(this.iframe);
2400
+ this.iframe = this.createIframeElement(c), ge(this.iframe);
2342
2401
  }
2343
2402
  const r = {
2344
2403
  uid: this.uid,
@@ -2368,7 +2427,7 @@ class Q {
2368
2427
  close: () => this.close(),
2369
2428
  focus: () => this.focus(),
2370
2429
  cspNonce: i
2371
- }, a = s(o);
2430
+ }, a = t(o);
2372
2431
  a && (this.container.appendChild(a), this.container = a), this.prerenderElement && !this.prerenderElement.parentNode && this.container.appendChild(this.prerenderElement), this.iframe && !this.iframe.parentNode && this.container.appendChild(this.iframe);
2373
2432
  }
2374
2433
  /**
@@ -2377,53 +2436,55 @@ class Q {
2377
2436
  * @internal
2378
2437
  */
2379
2438
  createIframeElement(e) {
2380
- const s = document.createElement("iframe"), n = this.options.dimensions, i = typeof this.options.attributes == "function" ? this.options.attributes(this.props) : this.options.attributes ?? {}, r = typeof this.options.style == "function" ? this.options.style(this.props) : this.options.style ?? {};
2381
- s.name = e, s.setAttribute("frameborder", "0"), s.setAttribute("allowtransparency", "true"), s.setAttribute("scrolling", "auto"), n.width !== void 0 && (s.style.width = typeof n.width == "number" ? `${n.width}px` : n.width), n.height !== void 0 && (s.style.height = typeof n.height == "number" ? `${n.height}px` : n.height);
2439
+ const t = document.createElement("iframe"), n = this.resolveDimensions(), i = typeof this.options.attributes == "function" ? this.options.attributes(this.props) : this.options.attributes ?? {}, r = typeof this.options.style == "function" ? this.options.style(this.props) : this.options.style ?? {};
2440
+ 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);
2382
2441
  for (const [o, a] of Object.entries(i))
2383
- a !== void 0 && (typeof a == "boolean" ? a && s.setAttribute(o, "") : s.setAttribute(o, a));
2442
+ a !== void 0 && (typeof a == "boolean" ? a && t.setAttribute(o, "") : t.setAttribute(o, a));
2384
2443
  for (const [o, a] of Object.entries(r)) {
2385
2444
  if (a === void 0) continue;
2386
2445
  const c = typeof a == "number" ? `${a}px` : a;
2387
- s.style.setProperty(
2446
+ t.style.setProperty(
2388
2447
  o.replace(/([A-Z])/g, "-$1").toLowerCase(),
2389
2448
  String(c)
2390
2449
  );
2391
2450
  }
2392
- return i.sandbox || s.setAttribute(
2451
+ return i.sandbox || t.setAttribute(
2393
2452
  "sandbox",
2394
2453
  "allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"
2395
- ), s;
2454
+ ), t;
2396
2455
  }
2397
2456
  /**
2398
2457
  * Opens the host window (iframe or popup).
2399
2458
  * @internal
2400
2459
  */
2401
2460
  async open() {
2402
- const e = this.buildUrl();
2461
+ const e = this.resolveUrl();
2462
+ this.syncTrustedDomainForUrl(e), this.openedHostDomain = this.resolveUrlOrigin(e);
2463
+ const t = this.buildUrl(e);
2403
2464
  if (this.context === p.IFRAME) {
2404
2465
  if (!this.iframe)
2405
2466
  throw new Error("Iframe not created during prerender");
2406
- this.iframe.src = e, this.hostWindow = this.iframe.contentWindow;
2467
+ this.iframe.src = t, this.hostWindow = this.iframe.contentWindow;
2407
2468
  } else {
2408
- const s = this.buildWindowName();
2409
- this.hostWindow = ot({
2410
- url: e,
2411
- name: s,
2412
- dimensions: this.options.dimensions
2469
+ const n = this.buildWindowName();
2470
+ this.hostWindow = lt({
2471
+ url: t,
2472
+ name: n,
2473
+ dimensions: this.resolveDimensions()
2413
2474
  });
2414
- const n = ut(this.hostWindow, () => {
2475
+ const i = ft(this.hostWindow, () => {
2415
2476
  this.destroy();
2416
2477
  });
2417
- this.cleanup.register(n);
2478
+ this.cleanup.register(i);
2418
2479
  }
2419
- this.hostWindow && Be(this.uid, this.hostWindow);
2480
+ this.hostWindow && Je(this.uid, this.hostWindow);
2420
2481
  }
2421
2482
  /**
2422
2483
  * Builds the URL for the host window including query parameters.
2423
2484
  * @internal
2424
2485
  */
2425
- buildUrl() {
2426
- const e = typeof this.options.url == "function" ? this.options.url(this.props) : this.options.url, n = Ye(this.props, this.options.props).toString();
2486
+ buildUrl(e = this.resolveUrl()) {
2487
+ const n = Ge(this.props, this.options.props).toString();
2427
2488
  if (!n) return e;
2428
2489
  const i = e.includes("?") ? "&" : "?";
2429
2490
  return `${e}${i}${n}`;
@@ -2433,26 +2494,26 @@ class Q {
2433
2494
  * @internal
2434
2495
  */
2435
2496
  buildWindowName() {
2436
- const e = this.getHostDomain(), s = ue(
2497
+ const e = this.getHostDomain(), t = fe(
2437
2498
  this.props,
2438
2499
  this.options.props,
2439
2500
  e,
2440
2501
  !1
2441
2502
  // Assume cross-domain for initial payload
2442
- ), n = he(
2443
- s,
2503
+ ), n = pe(
2504
+ t,
2444
2505
  this.options.props,
2445
2506
  this.bridge
2446
- ), i = this.buildNestedHostRefs(), r = Me({
2507
+ ), i = this.buildNestedHostRefs(), r = Be({
2447
2508
  uid: this.uid,
2448
2509
  tag: this.options.tag,
2449
2510
  context: this.context,
2450
- consumerDomain: j(),
2511
+ consumerDomain: V(),
2451
2512
  props: n,
2452
2513
  exports: this.createConsumerExports(),
2453
2514
  children: i
2454
2515
  });
2455
- return He(r);
2516
+ return We(r);
2456
2517
  }
2457
2518
  /**
2458
2519
  * Builds component references for nested host components.
@@ -2460,15 +2521,24 @@ class Q {
2460
2521
  */
2461
2522
  buildNestedHostRefs() {
2462
2523
  if (!this.options.children) return;
2463
- const e = this.options.children({ props: this.props }), s = {};
2524
+ const e = this.options.children({ props: this.props }), t = {};
2464
2525
  for (const [n, i] of Object.entries(e)) {
2465
- const r = i;
2466
- s[n] = {
2467
- tag: r.tag ?? n,
2468
- url: typeof r.url == "function" ? r.url.toString() : r.url ?? ""
2526
+ const r = St(i);
2527
+ if (!r)
2528
+ throw new Error(`Nested component "${n}" is missing component metadata`);
2529
+ if (typeof r.url != "string")
2530
+ throw new Error(
2531
+ `Nested component "${n}" must use a static string URL. Function URLs are not supported in children.`
2532
+ );
2533
+ t[n] = {
2534
+ tag: r.tag,
2535
+ url: r.url,
2536
+ props: r.props,
2537
+ dimensions: typeof r.dimensions == "function" ? void 0 : r.dimensions,
2538
+ defaultContext: r.defaultContext
2469
2539
  };
2470
2540
  }
2471
- return Object.keys(s).length > 0 ? s : void 0;
2541
+ return Object.keys(t).length > 0 ? t : void 0;
2472
2542
  }
2473
2543
  /**
2474
2544
  * Creates the exports object sent to the host.
@@ -2476,14 +2546,14 @@ class Q {
2476
2546
  */
2477
2547
  createConsumerExports() {
2478
2548
  return {
2479
- init: u.INIT,
2480
- close: u.CLOSE,
2481
- resize: u.RESIZE,
2482
- show: u.SHOW,
2483
- hide: u.HIDE,
2484
- onError: u.ERROR,
2485
- updateProps: u.PROPS,
2486
- export: u.EXPORT
2549
+ init: h.INIT,
2550
+ close: h.CLOSE,
2551
+ resize: h.RESIZE,
2552
+ show: h.SHOW,
2553
+ hide: h.HIDE,
2554
+ onError: h.ERROR,
2555
+ updateProps: h.PROPS,
2556
+ export: h.EXPORT
2487
2557
  };
2488
2558
  }
2489
2559
  /**
@@ -2491,21 +2561,16 @@ class Q {
2491
2561
  * @internal
2492
2562
  */
2493
2563
  getHostDomain() {
2494
- const e = typeof this.options.url == "function" ? this.options.url(this.props) : this.options.url;
2495
- try {
2496
- return new URL(e, window.location.origin).origin;
2497
- } catch {
2498
- return "*";
2499
- }
2564
+ return this.openedHostDomain ? this.openedHostDomain : this.resolveUrlOrigin(this.resolveUrl()) ?? "*";
2500
2565
  }
2501
2566
  /**
2502
2567
  * Waits for the host to send the init message.
2503
2568
  * @internal
2504
2569
  */
2505
2570
  async waitForHost() {
2506
- this.initPromise = ge();
2571
+ this.initPromise = _e();
2507
2572
  try {
2508
- await Ne(
2573
+ await $e(
2509
2574
  this.initPromise.promise,
2510
2575
  this.options.timeout,
2511
2576
  `Host component "${this.options.tag}" (uid: ${this._uid}) did not initialize within ${this.options.timeout}ms. Check that the host page loads correctly and calls the initialization code.`
@@ -2519,24 +2584,24 @@ class Q {
2519
2584
  * @internal
2520
2585
  */
2521
2586
  setupMessageHandlers() {
2522
- this.messenger.on(u.INIT, () => (this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(u.CLOSE, async () => (await this.close(), { success: !0 })), this.messenger.on(u.RESIZE, async (e) => (await this.resize(e), { success: !0 })), this.messenger.on(u.FOCUS, async () => (await this.focus(), { success: !0 })), this.messenger.on(u.SHOW, async () => (await this.show(), { success: !0 })), this.messenger.on(u.HIDE, async () => (await this.hide(), { success: !0 })), this.messenger.on(
2523
- u.ERROR,
2587
+ this.messenger.on(h.INIT, () => (this.initPromise && this.initPromise.resolve(), { success: !0 })), this.messenger.on(h.CLOSE, async () => (await this.close(), { success: !0 })), this.messenger.on(h.RESIZE, async (e) => (await this.resize(e), { success: !0 })), this.messenger.on(h.FOCUS, async () => (await this.focus(), { success: !0 })), this.messenger.on(h.SHOW, async () => (await this.show(), { success: !0 })), this.messenger.on(h.HIDE, async () => (await this.hide(), { success: !0 })), this.messenger.on(
2588
+ h.ERROR,
2524
2589
  async (e) => {
2525
- const s = new Error(e.message);
2526
- return s.stack = e.stack, this.handleError(s), { success: !0 };
2590
+ const t = new Error(e.message);
2591
+ return t.stack = e.stack, this.handleError(t), { success: !0 };
2527
2592
  }
2528
- ), this.messenger.on(u.EXPORT, async (e) => (this.exports = e, { success: !0 })), this.messenger.on(u.CONSUMER_EXPORT, async (e) => (this.consumerExports = e, { success: !0 })), this.messenger.on(
2529
- u.GET_SIBLINGS,
2593
+ ), this.messenger.on(h.EXPORT, async (e) => (this.exports = e, { success: !0 })), this.messenger.on(h.CONSUMER_EXPORT, async (e) => (this.consumerExports = e, { success: !0 })), this.messenger.on(
2594
+ h.GET_SIBLINGS,
2530
2595
  async (e) => {
2531
- const s = [], n = Pt(e.tag);
2596
+ const t = [], n = vt(e.tag);
2532
2597
  if (n)
2533
2598
  for (const i of n.instances)
2534
- i.uid !== e.uid && s.push({
2599
+ i.uid !== e.uid && t.push({
2535
2600
  uid: i.uid,
2536
2601
  tag: e.tag,
2537
2602
  exports: i.exports
2538
2603
  });
2539
- return s;
2604
+ return t;
2540
2605
  }
2541
2606
  );
2542
2607
  }
@@ -2546,7 +2611,7 @@ class Q {
2546
2611
  */
2547
2612
  setupCleanup() {
2548
2613
  this.cleanup.register(() => {
2549
- this.messenger.destroy(), this.bridge.destroy(), this.event.removeAllListeners(), Je(this.uid);
2614
+ this.messenger.destroy(), this.bridge.destroy(), Xe(this.uid);
2550
2615
  });
2551
2616
  }
2552
2617
  /**
@@ -2560,11 +2625,11 @@ class Q {
2560
2625
  * Calls a prop callback if it exists.
2561
2626
  * @internal
2562
2627
  */
2563
- callPropCallback(e, ...s) {
2628
+ callPropCallback(e, ...t) {
2564
2629
  const n = this.props[e];
2565
2630
  if (typeof n == "function")
2566
2631
  try {
2567
- const i = n(...s);
2632
+ const i = n(...t);
2568
2633
  i && typeof i == "object" && "catch" in i && typeof i.catch == "function" && i.catch((r) => {
2569
2634
  console.error(`Error in async ${e} callback:`, r);
2570
2635
  });
@@ -2579,18 +2644,20 @@ class Q {
2579
2644
  async destroy() {
2580
2645
  this.destroyed || (this.destroyed = !0, this.initPromise && (this.initPromise.reject(
2581
2646
  new Error(`Component "${this.options.tag}" was destroyed before initialization completed`)
2582
- ), this.initPromise = null), this.iframe && (tt(this.iframe), this.iframe = null), this.context === p.POPUP && this.hostWindow && at(this.hostWindow), this.hostWindow = null, this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null), await this.cleanup.cleanup(), this.event.emit(f.DESTROY), this.callPropCallback("onDestroy"));
2647
+ ), this.initPromise = null), this.iframe && (it(this.iframe), this.iframe = null), this.context === p.POPUP && this.hostWindow && ht(this.hostWindow), this.hostWindow = null, this.openedHostDomain = null, this.dynamicUrlTrustedOrigin = null, this.prerenderElement && (this.prerenderElement.remove(), this.prerenderElement = null), await this.cleanup.cleanup(), this.event.emit(f.DESTROY), this.callPropCallback("onDestroy"), this.event.removeAllListeners());
2583
2648
  }
2584
2649
  }
2585
- class yt {
2650
+ class Et {
2586
2651
  /**
2587
2652
  * Creates a new HostComponent instance.
2588
2653
  *
2589
2654
  * @param payload - The payload parsed from window.name
2590
2655
  * @param propDefinitions - Optional prop definitions for deserialization
2656
+ * @param allowedConsumerDomains - Optional allowlist of consumer domains
2657
+ * @param deferInit - Whether to defer INIT until a later explicit flush
2591
2658
  */
2592
- constructor(e, s = {}) {
2593
- this.propDefinitions = s, this.uid = e.uid, this.tag = e.tag, this.consumerDomain = e.consumerDomain, this.event = new me(), this.messenger = new ye(this.uid, window, j(), this.consumerDomain), this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), this.bridge = new B(this.messenger), this.hostProps = this.buildHostProps(e), window.hostProps = this.hostProps, this.sendInit();
2659
+ constructor(e, t = {}, n, i = !1) {
2660
+ this.propDefinitions = t, this.allowedConsumerDomains = n, this.deferInit = i, this.uid = e.uid, this.tag = e.tag, this.consumerDomain = e.consumerDomain, this.validateConsumerDomain(), this.event = new we(), this.messenger = new Ee(this.uid, window, V(), this.consumerDomain), this.setupMessageHandlers(), this.consumerWindow = this.resolveConsumerWindow(), this.bridge = new J(this.messenger), this.hostProps = this.buildHostProps(e), this.exposeHostProps(), this.deferInit || this.flushInit();
2594
2661
  }
2595
2662
  /** The hostProps object containing props and control methods passed from the consumer. */
2596
2663
  hostProps;
@@ -2614,6 +2681,59 @@ class yt {
2614
2681
  consumerProps;
2615
2682
  /** @internal */
2616
2683
  initError = null;
2684
+ /** @internal */
2685
+ destroyed = !1;
2686
+ /** @internal */
2687
+ initSent = !1;
2688
+ /** @internal */
2689
+ deferredInitFlushScheduled = !1;
2690
+ /**
2691
+ * Ensures the INIT handshake is sent at most once.
2692
+ * @internal
2693
+ */
2694
+ flushInit() {
2695
+ this.destroyed || this.initSent || (this.initSent = !0, this.sendInit());
2696
+ }
2697
+ /**
2698
+ * Schedules deferred INIT flush on the next microtask.
2699
+ * This preserves legacy hostProps-only usage while giving same-tick
2700
+ * host configuration a chance to run allowlist checks first.
2701
+ * @internal
2702
+ */
2703
+ scheduleDeferredInitFlush() {
2704
+ this.deferredInitFlushScheduled || this.destroyed || this.initSent || (this.deferredInitFlushScheduled = !0, queueMicrotask(() => {
2705
+ this.deferredInitFlushScheduled = !1, this.flushInit();
2706
+ }));
2707
+ }
2708
+ /**
2709
+ * Exposes hostProps on window and lazily flushes deferred init on first access.
2710
+ * @internal
2711
+ */
2712
+ exposeHostProps() {
2713
+ const e = window;
2714
+ try {
2715
+ Object.defineProperty(e, "hostProps", {
2716
+ configurable: !0,
2717
+ enumerable: !0,
2718
+ get: () => (this.deferInit && !this.initSent && !this.destroyed && this.scheduleDeferredInitFlush(), this.hostProps),
2719
+ set: (t) => {
2720
+ t && (this.hostProps = t);
2721
+ }
2722
+ });
2723
+ } catch {
2724
+ e.hostProps = this.hostProps;
2725
+ }
2726
+ }
2727
+ /**
2728
+ * Validates that the consumer domain is allowed.
2729
+ * @internal
2730
+ */
2731
+ validateConsumerDomain() {
2732
+ if (this.allowedConsumerDomains && !L(this.allowedConsumerDomains, this.consumerDomain))
2733
+ throw new Error(
2734
+ `Consumer domain "${this.consumerDomain}" is not allowed for component "${this.tag}"`
2735
+ );
2736
+ }
2617
2737
  /**
2618
2738
  * Returns the hostProps object.
2619
2739
  *
@@ -2627,12 +2747,12 @@ class yt {
2627
2747
  * @internal
2628
2748
  */
2629
2749
  resolveConsumerWindow() {
2630
- if (Le()) {
2631
- const e = Fe();
2750
+ if (Ue()) {
2751
+ const e = Ae();
2632
2752
  if (e) return e;
2633
2753
  }
2634
- if (Ae()) {
2635
- const e = $e();
2754
+ if (Me()) {
2755
+ const e = He();
2636
2756
  if (e) return e;
2637
2757
  }
2638
2758
  throw new Error("Could not resolve consumer window");
@@ -2642,7 +2762,7 @@ class yt {
2642
2762
  * @internal
2643
2763
  */
2644
2764
  buildHostProps(e) {
2645
- const s = de(
2765
+ const t = me(
2646
2766
  e.props,
2647
2767
  this.propDefinitions,
2648
2768
  this.messenger,
@@ -2650,8 +2770,8 @@ class yt {
2650
2770
  this.consumerWindow,
2651
2771
  this.consumerDomain
2652
2772
  );
2653
- return this.consumerProps = s, {
2654
- ...s,
2773
+ return this.consumerProps = t, {
2774
+ ...t,
2655
2775
  uid: this.uid,
2656
2776
  tag: this.tag,
2657
2777
  close: () => this.close(),
@@ -2681,15 +2801,15 @@ class yt {
2681
2801
  await this.messenger.send(
2682
2802
  this.consumerWindow,
2683
2803
  this.consumerDomain,
2684
- u.INIT,
2804
+ h.INIT,
2685
2805
  { uid: this.uid, tag: this.tag }
2686
2806
  );
2687
2807
  } catch (e) {
2688
- const s = e instanceof Error ? e : new Error(String(e));
2689
- this.initError = s, this.event.emit(f.ERROR, {
2808
+ const t = e instanceof Error ? e : new Error(String(e));
2809
+ this.initError = t, this.event.emit(f.ERROR, {
2690
2810
  type: "init_failed",
2691
- message: `Failed to initialize host component: ${s.message}`,
2692
- error: s
2811
+ message: `Failed to initialize host component: ${t.message}`,
2812
+ error: t
2693
2813
  }), console.error("Failed to send init message:", e);
2694
2814
  }
2695
2815
  }
@@ -2709,7 +2829,7 @@ class yt {
2709
2829
  await this.messenger.send(
2710
2830
  this.consumerWindow,
2711
2831
  this.consumerDomain,
2712
- u.CLOSE,
2832
+ h.CLOSE,
2713
2833
  {}
2714
2834
  );
2715
2835
  }
@@ -2721,7 +2841,7 @@ class yt {
2721
2841
  window.focus(), await this.messenger.send(
2722
2842
  this.consumerWindow,
2723
2843
  this.consumerDomain,
2724
- u.FOCUS,
2844
+ h.FOCUS,
2725
2845
  {}
2726
2846
  );
2727
2847
  }
@@ -2733,7 +2853,7 @@ class yt {
2733
2853
  await this.messenger.send(
2734
2854
  this.consumerWindow,
2735
2855
  this.consumerDomain,
2736
- u.RESIZE,
2856
+ h.RESIZE,
2737
2857
  e
2738
2858
  );
2739
2859
  }
@@ -2745,7 +2865,7 @@ class yt {
2745
2865
  await this.messenger.send(
2746
2866
  this.consumerWindow,
2747
2867
  this.consumerDomain,
2748
- u.SHOW,
2868
+ h.SHOW,
2749
2869
  {}
2750
2870
  );
2751
2871
  }
@@ -2757,7 +2877,7 @@ class yt {
2757
2877
  await this.messenger.send(
2758
2878
  this.consumerWindow,
2759
2879
  this.consumerDomain,
2760
- u.HIDE,
2880
+ h.HIDE,
2761
2881
  {}
2762
2882
  );
2763
2883
  }
@@ -2778,7 +2898,7 @@ class yt {
2778
2898
  await this.messenger.send(
2779
2899
  this.consumerWindow,
2780
2900
  this.consumerDomain,
2781
- u.ERROR,
2901
+ h.ERROR,
2782
2902
  {
2783
2903
  message: e.message,
2784
2904
  stack: e.stack
@@ -2793,7 +2913,7 @@ class yt {
2793
2913
  await this.messenger.send(
2794
2914
  this.consumerWindow,
2795
2915
  this.consumerDomain,
2796
- u.EXPORT,
2916
+ h.EXPORT,
2797
2917
  e
2798
2918
  );
2799
2919
  }
@@ -2805,7 +2925,7 @@ class yt {
2805
2925
  await this.messenger.send(
2806
2926
  this.consumerWindow,
2807
2927
  this.consumerDomain,
2808
- u.CONSUMER_EXPORT,
2928
+ h.CONSUMER_EXPORT,
2809
2929
  e
2810
2930
  );
2811
2931
  }
@@ -2817,7 +2937,7 @@ class yt {
2817
2937
  return await this.messenger.send(
2818
2938
  this.consumerWindow,
2819
2939
  this.consumerDomain,
2820
- u.GET_SIBLINGS,
2940
+ h.GET_SIBLINGS,
2821
2941
  { uid: this.uid, tag: this.tag, options: e }
2822
2942
  ) ?? [];
2823
2943
  }
@@ -2827,10 +2947,10 @@ class yt {
2827
2947
  */
2828
2948
  buildNestedComponents(e) {
2829
2949
  if (!e) return;
2830
- const s = {};
2950
+ const t = {};
2831
2951
  for (const [n, i] of Object.entries(e))
2832
2952
  try {
2833
- s[n] = Se({
2953
+ t[n] = Se({
2834
2954
  tag: i.tag,
2835
2955
  url: i.url,
2836
2956
  props: i.props,
@@ -2840,16 +2960,16 @@ class yt {
2840
2960
  } catch (r) {
2841
2961
  console.warn(`Failed to create nested component "${n}":`, r);
2842
2962
  }
2843
- return Object.keys(s).length > 0 ? s : void 0;
2963
+ return Object.keys(t).length > 0 ? t : void 0;
2844
2964
  }
2845
2965
  /**
2846
2966
  * Sets up message handlers for consumer communication.
2847
2967
  * @internal
2848
2968
  */
2849
2969
  setupMessageHandlers() {
2850
- this.messenger.on(u.PROPS, (e) => {
2970
+ this.messenger.on(h.PROPS, (e) => {
2851
2971
  try {
2852
- const s = de(
2972
+ const t = me(
2853
2973
  e,
2854
2974
  this.propDefinitions,
2855
2975
  this.messenger,
@@ -2857,16 +2977,16 @@ class yt {
2857
2977
  this.consumerWindow,
2858
2978
  this.consumerDomain
2859
2979
  );
2860
- Object.assign(this.hostProps, s);
2980
+ Object.assign(this.hostProps, t);
2861
2981
  for (const n of this.propsHandlers)
2862
2982
  try {
2863
- n(s);
2983
+ n(t);
2864
2984
  } catch (i) {
2865
2985
  console.error("Error in props handler:", i);
2866
2986
  }
2867
- return this.event.emit(f.PROPS, s), { success: !0 };
2868
- } catch (s) {
2869
- const n = s instanceof Error ? s : new Error(String(s));
2987
+ return this.event.emit(f.PROPS, t), { success: !0 };
2988
+ } catch (t) {
2989
+ const n = t instanceof Error ? t : new Error(String(t));
2870
2990
  throw console.error("Error deserializing props:", n), this.event.emit(f.ERROR, n), n;
2871
2991
  }
2872
2992
  });
@@ -2875,145 +2995,172 @@ class yt {
2875
2995
  * Destroys the host component and cleans up resources.
2876
2996
  */
2877
2997
  destroy() {
2878
- this.messenger.destroy(), this.bridge.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear();
2998
+ this.destroyed || (this.destroyed = !0, this.deferredInitFlushScheduled = !1, this.messenger.destroy(), this.bridge.destroy(), this.event.removeAllListeners(), this.propsHandlers.clear());
2879
2999
  }
2880
3000
  }
2881
- let v = null;
2882
- function xe(t) {
2883
- if (v)
2884
- return v;
2885
- if (!J())
3001
+ let g = null;
3002
+ function ne(s, e, t = {}) {
3003
+ if (g) {
3004
+ if (e) {
3005
+ const i = g.getProps().getConsumerDomain();
3006
+ if (!L(e, i))
3007
+ throw Rt(), new Error(
3008
+ `Consumer domain "${i}" is not allowed for this host component`
3009
+ );
3010
+ }
3011
+ return t.deferInit || g.flushInit(), g;
3012
+ }
3013
+ if (!X())
2886
3014
  return null;
2887
- const e = Ue();
2888
- return e ? (v = new yt(
3015
+ const n = qe();
3016
+ return n ? (g = new Et(
3017
+ n,
3018
+ s,
2889
3019
  e,
2890
- t
2891
- ), v) : (console.error("Failed to parse ForgeFrame payload from window.name"), null);
3020
+ t.deferInit ?? !1
3021
+ ), g) : (console.error("Failed to parse ForgeFrame payload from window.name"), null);
2892
3022
  }
2893
- function _t() {
2894
- return J();
3023
+ function bt() {
3024
+ return X();
2895
3025
  }
2896
- function wt() {
2897
- return J();
3026
+ function Pt() {
3027
+ return X();
2898
3028
  }
2899
- function Et() {
3029
+ function Ot() {
2900
3030
  return window.hostProps;
2901
3031
  }
2902
- const S = /* @__PURE__ */ new Map();
2903
- function bt(t) {
2904
- if (!t.tag)
3032
+ function Rt() {
3033
+ g && (g.destroy(), g = null), delete window.hostProps;
3034
+ }
3035
+ const C = /* @__PURE__ */ new Map(), ve = /* @__PURE__ */ Symbol("forgeframe.component.options");
3036
+ function xt(s) {
3037
+ if (!s.tag)
2905
3038
  throw new Error("Component tag is required");
2906
- if (!/^[a-z][a-z0-9-]*$/.test(t.tag))
3039
+ if (!/^[a-z][a-z0-9-]*$/.test(s.tag))
2907
3040
  throw new Error(
2908
- `Invalid component tag "${t.tag}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`
3041
+ `Invalid component tag "${s.tag}". Must start with lowercase letter and contain only lowercase letters, numbers, and hyphens.`
2909
3042
  );
2910
- if (!t.url)
3043
+ if (!s.url)
2911
3044
  throw new Error("Component url is required");
2912
- if (typeof t.url == "string")
3045
+ if (typeof s.url == "string")
2913
3046
  try {
2914
- new URL(t.url, window.location.origin);
3047
+ new URL(s.url, window.location.origin);
2915
3048
  } catch {
2916
3049
  throw new Error(
2917
- `Invalid component URL "${t.url}". Must be a valid absolute or relative URL.`
3050
+ `Invalid component URL "${s.url}". Must be a valid absolute or relative URL.`
2918
3051
  );
2919
3052
  }
2920
- if (S.has(t.tag))
2921
- throw new Error(`Component "${t.tag}" is already registered`);
3053
+ if (C.has(s.tag))
3054
+ throw new Error(`Component "${s.tag}" is already registered`);
2922
3055
  }
2923
- function Se(t) {
2924
- bt(t);
3056
+ function Se(s) {
3057
+ xt(s);
2925
3058
  const e = [];
2926
- let s;
2927
- if (H(t.tag)) {
2928
- const i = xe(t.props);
2929
- i && (s = i.hostProps);
3059
+ let t;
3060
+ if (W(s.tag)) {
3061
+ const i = ne(s.props, s.allowedConsumerDomains);
3062
+ i && (t = i.hostProps);
2930
3063
  }
2931
3064
  const n = function(i = {}) {
2932
- const r = new Q(t, i);
3065
+ const r = new se(s, i);
2933
3066
  return e.push(r), r.event.once("destroy", () => {
2934
3067
  const o = e.indexOf(r);
2935
3068
  o !== -1 && e.splice(o, 1);
2936
3069
  }), r;
2937
3070
  };
2938
- return n.instances = e, n.isHost = () => H(t.tag), n.isEmbedded = () => H(t.tag), n.hostProps = s, n.canRenderTo = async (i) => {
3071
+ return n.instances = e, n.isHost = () => W(s.tag), n.isEmbedded = () => W(s.tag), n.hostProps = t, n[ve] = s, n.canRenderTo = async (i) => {
2939
3072
  try {
2940
- return !!(_e(i) || t.domain);
3073
+ return !!(be(i) || s.domain);
2941
3074
  } catch {
2942
3075
  return !1;
2943
3076
  }
2944
- }, S.set(t.tag, n), n;
3077
+ }, C.set(s.tag, n), n;
2945
3078
  }
2946
- function Pt(t) {
2947
- return S.get(t);
3079
+ function vt(s) {
3080
+ return C.get(s);
2948
3081
  }
2949
- async function Rt(t) {
2950
- await t.close();
3082
+ function St(s) {
3083
+ return s[ve];
2951
3084
  }
2952
- async function Oe(t) {
2953
- const e = S.get(t);
3085
+ async function Ct(s) {
3086
+ await s.close();
3087
+ }
3088
+ async function Ce(s) {
3089
+ const e = C.get(s);
2954
3090
  if (!e) return;
2955
- const s = [...e.instances];
2956
- await Promise.all(s.map((n) => n.close()));
3091
+ const t = [...e.instances];
3092
+ await Promise.all(t.map((n) => n.close()));
3093
+ }
3094
+ async function Dt() {
3095
+ const s = Array.from(C.keys());
3096
+ await Promise.all(s.map((e) => Ce(e)));
2957
3097
  }
2958
- async function xt() {
2959
- const t = Array.from(S.keys());
2960
- await Promise.all(t.map((e) => Oe(e)));
3098
+ function It(s, e) {
3099
+ const t = Object.keys(s), n = Object.keys(e);
3100
+ if (t.length !== n.length)
3101
+ return !1;
3102
+ for (const i of t)
3103
+ if (!Object.prototype.hasOwnProperty.call(e, i) || !Object.is(s[i], e[i]))
3104
+ return !1;
3105
+ return !0;
2961
3106
  }
2962
- function St(t, e) {
2963
- const { React: s } = e, { createElement: n, useRef: i, useEffect: r, useState: o, forwardRef: a } = s, c = a(
2964
- function(g, y) {
3107
+ function Tt(s, e) {
3108
+ const { React: t } = e, { createElement: n, useRef: i, useEffect: r, useState: o, forwardRef: a } = t, c = a(
3109
+ function(w, _) {
2965
3110
  const {
2966
- onRendered: b,
2967
- onError: O,
2968
- onClose: ee,
2969
- context: Ce,
2970
- className: te,
2971
- style: se,
2972
- ...F
2973
- } = g, C = i(null), L = i(null), [ne, ve] = o(null);
3111
+ onRendered: P,
3112
+ onError: x,
3113
+ onClose: ie,
3114
+ context: De,
3115
+ className: re,
3116
+ style: oe,
3117
+ ...H
3118
+ } = w, D = i(null), A = i(null), U = i(null), [ae, Ie] = o(null);
2974
3119
  return r(() => {
2975
- const x = C.current;
2976
- if (!x) return;
2977
- const _ = t(F);
2978
- return L.current = _, b && _.event.once("rendered", b), ee && _.event.once("close", ee), O && _.event.on("error", O), _.render(x, Ce).catch((ie) => {
2979
- ve(ie), O?.(ie);
3120
+ const v = D.current;
3121
+ if (!v) return;
3122
+ const m = s(H);
3123
+ return A.current = m, P && m.event.once("rendered", P), ie && m.event.once("close", ie), x && m.event.on("error", x), m.render(v, De).catch((S) => {
3124
+ Ie(S), x?.(S);
2980
3125
  }), () => {
2981
- _.close().catch(() => {
2982
- }), L.current = null;
3126
+ m.close().catch(() => {
3127
+ }), A.current = null, U.current = null;
2983
3128
  };
2984
3129
  }, []), r(() => {
2985
- const x = L.current;
2986
- x && x.updateProps(F).catch((_) => {
2987
- O?.(_);
2988
- });
2989
- }, [JSON.stringify(F)]), r(() => {
2990
- y && typeof y == "object" && C.current && (y.current = C.current);
2991
- }, [y]), ne ? n(
3130
+ const v = A.current;
3131
+ if (!v) return;
3132
+ const m = H, S = U.current;
3133
+ S && It(S, m) || (U.current = m, v.updateProps(m).catch((Te) => {
3134
+ x?.(Te);
3135
+ }));
3136
+ }, [H, x]), r(() => {
3137
+ _ && typeof _ == "object" && D.current && (_.current = D.current);
3138
+ }, [_]), ae ? n(
2992
3139
  "div",
2993
3140
  {
2994
- className: te,
2995
- style: { color: "red", padding: "16px", ...se }
3141
+ className: re,
3142
+ style: { color: "red", padding: "16px", ...oe }
2996
3143
  },
2997
- `Error: ${ne.message}`
3144
+ `Error: ${ae.message}`
2998
3145
  ) : n("div", {
2999
- ref: C,
3000
- className: te,
3146
+ ref: D,
3147
+ className: re,
3001
3148
  style: {
3002
3149
  display: "inline-block",
3003
- ...se
3150
+ ...oe
3004
3151
  }
3005
3152
  });
3006
3153
  }
3007
- ), l = `ForgeFrame(${t.name || "Component"})`;
3154
+ ), l = `ForgeFrame(${s.name || "Component"})`;
3008
3155
  return c.displayName = l, c;
3009
3156
  }
3010
- function Ot(t) {
3011
- return function(s) {
3012
- return St(s, { React: t });
3157
+ function Ft(s) {
3158
+ return function(t) {
3159
+ return Tt(t, { React: s });
3013
3160
  };
3014
3161
  }
3015
- xe();
3016
- const Ct = {
3162
+ ne(void 0, void 0, { deferInit: !0 });
3163
+ const $t = {
3017
3164
  /**
3018
3165
  * Create a new component definition.
3019
3166
  *
@@ -3044,17 +3191,17 @@ const Ct = {
3044
3191
  *
3045
3192
  * @param instance - The component instance to destroy
3046
3193
  */
3047
- destroy: Rt,
3194
+ destroy: Ct,
3048
3195
  /**
3049
3196
  * Destroy all instances of a specific component by tag.
3050
3197
  *
3051
3198
  * @param tag - The component tag name
3052
3199
  */
3053
- destroyByTag: Oe,
3200
+ destroyByTag: Ce,
3054
3201
  /**
3055
3202
  * Destroy all ForgeFrame component instances.
3056
3203
  */
3057
- destroyAll: xt,
3204
+ destroyAll: Dt,
3058
3205
  /**
3059
3206
  * Check if the current window is a host component context.
3060
3207
  *
@@ -3064,7 +3211,7 @@ const Ct = {
3064
3211
  *
3065
3212
  * @returns True if running inside a ForgeFrame iframe/popup
3066
3213
  */
3067
- isHost: _t,
3214
+ isHost: bt,
3068
3215
  /**
3069
3216
  * Check if the current window is embedded by ForgeFrame.
3070
3217
  *
@@ -3073,7 +3220,7 @@ const Ct = {
3073
3220
  *
3074
3221
  * @returns True if running inside a ForgeFrame iframe/popup
3075
3222
  */
3076
- isEmbedded: wt,
3223
+ isEmbedded: Pt,
3077
3224
  /**
3078
3225
  * Get hostProps from the current host window.
3079
3226
  *
@@ -3082,7 +3229,18 @@ const Ct = {
3082
3229
  *
3083
3230
  * @returns The hostProps object if in host context, undefined otherwise
3084
3231
  */
3085
- getHostProps: Et,
3232
+ getHostProps: Ot,
3233
+ /**
3234
+ * Flush host initialization in embedded contexts.
3235
+ *
3236
+ * @remarks
3237
+ * Only required in host pages that access `window.hostProps` directly
3238
+ * without defining a component via `ForgeFrame.create(...)`.
3239
+ * When `create()` is used on the host side, init is flushed automatically.
3240
+ *
3241
+ * @returns The host component instance if running embedded, otherwise null
3242
+ */
3243
+ initHost: ne,
3086
3244
  /**
3087
3245
  * Serialization strategy constants.
3088
3246
  * @see {@link PROP_SERIALIZATION}
@@ -3101,11 +3259,11 @@ const Ct = {
3101
3259
  /**
3102
3260
  * Error thrown when popup window fails to open.
3103
3261
  */
3104
- PopupOpenError: Re,
3262
+ PopupOpenError: xe,
3105
3263
  /**
3106
3264
  * Current library version.
3107
3265
  */
3108
- VERSION: pe,
3266
+ VERSION: ye,
3109
3267
  /**
3110
3268
  * Check if a value is a Standard Schema (Zod, Valibot, ArkType, etc.)
3111
3269
  *
@@ -3122,7 +3280,7 @@ const Ct = {
3122
3280
  * }
3123
3281
  * ```
3124
3282
  */
3125
- isStandardSchema: E,
3283
+ isStandardSchema: b,
3126
3284
  /**
3127
3285
  * Prop schema builders for defining component props.
3128
3286
  *
@@ -3148,32 +3306,33 @@ const Ct = {
3148
3306
  prop: d
3149
3307
  };
3150
3308
  export {
3151
- K as AnySchema,
3152
- T as ArraySchema,
3153
- X as BooleanSchema,
3309
+ te as AnySchema,
3310
+ F as ArraySchema,
3311
+ Z as BooleanSchema,
3154
3312
  p as CONTEXT,
3155
3313
  f as EVENT,
3156
- G as EnumSchema,
3157
- Ct as ForgeFrame,
3158
- Y as FunctionSchema,
3159
- Z as LiteralSchema,
3160
- q as NumberSchema,
3161
- k as ObjectSchema,
3314
+ ee as EnumSchema,
3315
+ $t as ForgeFrame,
3316
+ G as FunctionSchema,
3317
+ Q as LiteralSchema,
3318
+ Y as NumberSchema,
3319
+ $ as ObjectSchema,
3162
3320
  I as PROP_SERIALIZATION,
3163
- Re as PopupOpenError,
3164
- m as PropSchema,
3165
- V as StringSchema,
3166
- pe as VERSION,
3321
+ xe as PopupOpenError,
3322
+ y as PropSchema,
3323
+ K as StringSchema,
3324
+ ye as VERSION,
3167
3325
  Se as create,
3168
- St as createReactComponent,
3169
- Ct as default,
3170
- Rt as destroy,
3171
- xt as destroyAll,
3172
- Oe as destroyByTag,
3173
- Et as getHostProps,
3174
- wt as isEmbedded,
3175
- _t as isHost,
3176
- E as isStandardSchema,
3326
+ Tt as createReactComponent,
3327
+ $t as default,
3328
+ Ct as destroy,
3329
+ Dt as destroyAll,
3330
+ Ce as destroyByTag,
3331
+ Ot as getHostProps,
3332
+ ne as initHost,
3333
+ Pt as isEmbedded,
3334
+ bt as isHost,
3335
+ b as isStandardSchema,
3177
3336
  d as prop,
3178
- Ot as withReactComponent
3337
+ Ft as withReactComponent
3179
3338
  };