@soyio/soyio-widget 0.0.44 → 0.0.46

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.
package/dist/index.js CHANGED
@@ -10,37 +10,15 @@ var dt = (y, x, A) => {
10
10
  x instanceof WeakSet ? x.add(y) : x.set(y, A);
11
11
  };
12
12
  var ft = (y, x, A) => (Bt(y, x, "access private method"), A);
13
- const Gt = "https://app.soyio.id/widget", Jt = "https://sandbox.soyio.id/widget", qt = ["IDENTITY_AUTHENTICATED", "IDENTITY_REGISTERED"], Zt = "WIDGET_CLOSED";
14
- function Vt(y, x, A, S) {
15
- const g = S || (A ? Jt : Gt), v = Object.entries(x).filter(([, E]) => E).map(([E, M]) => `${E}=${encodeURIComponent(M)}`).join("&");
16
- return `${g}/${y}?platform=web&${v}`;
17
- }
18
- let X = null;
19
- function Rn() {
20
- if (X && !X.closed)
21
- X.focus();
22
- else
23
- throw new Error("Popup window does not exist or is closed.");
24
- }
25
- function $t(y, x, A, S) {
26
- const g = Vt(y, x, A, S), v = 510, E = 720, M = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width, V = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height, Q = M / 2 - v / 2, J = V / 2 - E / 2;
27
- document.body.style.filter = "blur(5px)", document.body.addEventListener("click", Rn), X = window.open(g, "Soyio", `scrollbars=yes, width=${v}, height=${E}, top=${J}, left=${Q}`), Rn();
28
- }
29
- function ht() {
30
- document.body.style.filter = "", document.body.removeEventListener("click", Rn);
31
- }
32
- function Yt() {
33
- X && (X.close(), X = null), ht();
34
- }
35
- var kt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
36
- function Kt(y) {
13
+ var Gt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
14
+ function Jt(y) {
37
15
  return y && y.__esModule && Object.prototype.hasOwnProperty.call(y, "default") ? y.default : y;
38
16
  }
39
- var lt = { exports: {} }, vt = { exports: {} };
17
+ var ht = { exports: {} }, lt = { exports: {} };
40
18
  (function(y, x) {
41
19
  (function(A, S) {
42
20
  y.exports = S();
43
- })(typeof self < "u" ? self : kt, function() {
21
+ })(typeof self < "u" ? self : Gt, function() {
44
22
  return function(A) {
45
23
  var S = {};
46
24
  function g(v) {
@@ -145,21 +123,21 @@ var lt = { exports: {} }, vt = { exports: {} };
145
123
  } catch {
146
124
  }
147
125
  }
148
- function zn(n) {
126
+ function fn(n) {
149
127
  if (n === void 0 && (n = window), n && !J(n))
150
128
  try {
151
129
  return n.opener;
152
130
  } catch {
153
131
  }
154
132
  }
155
- function fn(n) {
133
+ function hn(n) {
156
134
  try {
157
135
  return !0;
158
136
  } catch {
159
137
  }
160
138
  return !1;
161
139
  }
162
- function hn(n) {
140
+ function ln(n) {
163
141
  n === void 0 && (n = window);
164
142
  var r = n.location;
165
143
  if (!r)
@@ -171,7 +149,7 @@ var lt = { exports: {} }, vt = { exports: {} };
171
149
  return "file://";
172
150
  if (t === "about:") {
173
151
  var e = J(n);
174
- return e && fn() ? hn(e) : "about://";
152
+ return e && hn() ? ln(e) : "about://";
175
153
  }
176
154
  var o = r.host;
177
155
  if (!o)
@@ -180,7 +158,7 @@ var lt = { exports: {} }, vt = { exports: {} };
180
158
  }
181
159
  function T(n) {
182
160
  n === void 0 && (n = window);
183
- var r = hn(n);
161
+ var r = ln(n);
184
162
  return r && n.mockDomain && n.mockDomain.indexOf("mock:") === 0 ? n.mockDomain : r;
185
163
  }
186
164
  function $(n) {
@@ -197,19 +175,19 @@ var lt = { exports: {} }, vt = { exports: {} };
197
175
  } catch {
198
176
  }
199
177
  try {
200
- if (Q(r) && fn())
178
+ if (Q(r) && hn())
201
179
  return !0;
202
180
  } catch {
203
181
  }
204
182
  try {
205
183
  if (function(e) {
206
184
  return e === void 0 && (e = window), V(e) === "mock:";
207
- }(r) && fn())
185
+ }(r) && hn())
208
186
  return !0;
209
187
  } catch {
210
188
  }
211
189
  try {
212
- if (hn(r) === hn(window))
190
+ if (ln(r) === ln(window))
213
191
  return !0;
214
192
  } catch {
215
193
  }
@@ -217,13 +195,13 @@ var lt = { exports: {} }, vt = { exports: {} };
217
195
  }(n))
218
196
  return !1;
219
197
  try {
220
- if (n === window || Q(n) && fn() || T(window) === T(n))
198
+ if (n === window || Q(n) && hn() || T(window) === T(n))
221
199
  return !0;
222
200
  } catch {
223
201
  }
224
202
  return !1;
225
203
  }
226
- function ln(n) {
204
+ function vn(n) {
227
205
  if (!$(n))
228
206
  throw new Error("Expected window to be same domain");
229
207
  return n;
@@ -341,7 +319,7 @@ var lt = { exports: {} }, vt = { exports: {} };
341
319
  return !1;
342
320
  }
343
321
  function Cn(n) {
344
- return n === void 0 && (n = window), zn(n = n || window) || J(n) || void 0;
322
+ return n === void 0 && (n = window), fn(n = n || window) || J(n) || void 0;
345
323
  }
346
324
  function _(n, r) {
347
325
  if (typeof n == "string") {
@@ -354,7 +332,7 @@ var lt = { exports: {} }, vt = { exports: {} };
354
332
  return _(t, r);
355
333
  }));
356
334
  }
357
- function vn(n) {
335
+ function wn(n) {
358
336
  try {
359
337
  if (n === window)
360
338
  return !0;
@@ -412,7 +390,7 @@ var lt = { exports: {} }, vt = { exports: {} };
412
390
  }
413
391
  function Mn(n) {
414
392
  if ($(n))
415
- return ln(n).frameElement;
393
+ return vn(n).frameElement;
416
394
  for (var r = 0, t = document.querySelectorAll("iframe"); r < t.length; r++) {
417
395
  var e = t[r];
418
396
  if (e && e.contentWindow && e.contentWindow === n)
@@ -455,25 +433,25 @@ var lt = { exports: {} }, vt = { exports: {} };
455
433
  }
456
434
  return !1;
457
435
  }
458
- var Ln = [], nn = [], En = 0, tn;
436
+ var Ln = [], nn = [], Wn = 0, tn;
459
437
  function Fn() {
460
- if (!En && tn) {
438
+ if (!Wn && tn) {
461
439
  var n = tn;
462
440
  tn = null, n.resolve();
463
441
  }
464
442
  }
465
- function Wn() {
466
- En += 1;
443
+ function xn() {
444
+ Wn += 1;
467
445
  }
468
446
  function rn() {
469
- En -= 1, Fn();
447
+ Wn -= 1, Fn();
470
448
  }
471
449
  var b = function() {
472
450
  function n(t) {
473
451
  var e = this;
474
452
  if (this.resolved = void 0, this.rejected = void 0, this.errorHandled = void 0, this.value = void 0, this.error = void 0, this.handlers = void 0, this.dispatching = void 0, this.stack = void 0, this.resolved = !1, this.rejected = !1, this.errorHandled = !1, this.handlers = [], t) {
475
453
  var o, i, a = !1, s = !1, c = !1;
476
- Wn();
454
+ xn();
477
455
  try {
478
456
  t(function(u) {
479
457
  c ? e.resolve(u) : (a = !0, o = u);
@@ -520,7 +498,7 @@ var lt = { exports: {} }, vt = { exports: {} };
520
498
  }, r.dispatch = function() {
521
499
  var t = this.resolved, e = this.rejected, o = this.handlers;
522
500
  if (!this.dispatching && (t || e)) {
523
- this.dispatching = !0, Wn();
501
+ this.dispatching = !0, xn();
524
502
  for (var i = function(l, p) {
525
503
  return l.then(function(w) {
526
504
  p.resolve(w);
@@ -657,7 +635,7 @@ var lt = { exports: {} }, vt = { exports: {} };
657
635
  if (t && typeof t != "function" && !t.call)
658
636
  throw new Error("Promise.try expected a function");
659
637
  var i;
660
- Wn();
638
+ xn();
661
639
  try {
662
640
  i = t.apply(e, o || []);
663
641
  } catch (a) {
@@ -677,7 +655,7 @@ var lt = { exports: {} }, vt = { exports: {} };
677
655
  }(n);
678
656
  }, n;
679
657
  }();
680
- function wn(n, r) {
658
+ function mn(n, r) {
681
659
  for (var t = 0; t < n.length; t++)
682
660
  try {
683
661
  if (n[t] === r)
@@ -686,7 +664,7 @@ var lt = { exports: {} }, vt = { exports: {} };
686
664
  }
687
665
  return -1;
688
666
  }
689
- var xn = function() {
667
+ var Sn = function() {
690
668
  function n() {
691
669
  if (this.name = void 0, this.weakmap = void 0, this.keys = void 0, this.values = void 0, this.name = "__weakmap_" + (1e9 * Math.random() >>> 0) + "__", function() {
692
670
  if (typeof WeakMap > "u" || Object.freeze === void 0)
@@ -708,7 +686,7 @@ var lt = { exports: {} }, vt = { exports: {} };
708
686
  return r._cleanupClosedWindows = function() {
709
687
  for (var t = this.weakmap, e = this.keys, o = 0; o < e.length; o++) {
710
688
  var i = e[o];
711
- if (vn(i) && U(i)) {
689
+ if (wn(i) && U(i)) {
712
690
  if (t)
713
691
  try {
714
692
  t.delete(i);
@@ -718,7 +696,7 @@ var lt = { exports: {} }, vt = { exports: {} };
718
696
  }
719
697
  }
720
698
  }, r.isSafeToReadWrite = function(t) {
721
- return !vn(t);
699
+ return !wn(t);
722
700
  }, r.set = function(t, e) {
723
701
  if (!t)
724
702
  throw new Error("WeakMap expected key");
@@ -740,7 +718,7 @@ var lt = { exports: {} }, vt = { exports: {} };
740
718
  } catch {
741
719
  }
742
720
  this._cleanupClosedWindows();
743
- var s = this.keys, c = this.values, u = wn(s, t);
721
+ var s = this.keys, c = this.values, u = mn(s, t);
744
722
  u === -1 ? (s.push(t), c.push(e)) : c[u] = e;
745
723
  }, r.get = function(t) {
746
724
  if (!t)
@@ -760,7 +738,7 @@ var lt = { exports: {} }, vt = { exports: {} };
760
738
  } catch {
761
739
  }
762
740
  this._cleanupClosedWindows();
763
- var i = wn(this.keys, t);
741
+ var i = mn(this.keys, t);
764
742
  if (i !== -1)
765
743
  return this.values[i];
766
744
  }, r.delete = function(t) {
@@ -780,7 +758,7 @@ var lt = { exports: {} }, vt = { exports: {} };
780
758
  } catch {
781
759
  }
782
760
  this._cleanupClosedWindows();
783
- var i = this.keys, a = wn(i, t);
761
+ var i = this.keys, a = mn(i, t);
784
762
  a !== -1 && (i.splice(a, 1), this.values.splice(a, 1));
785
763
  }, r.has = function(t) {
786
764
  if (!t)
@@ -799,7 +777,7 @@ var lt = { exports: {} }, vt = { exports: {} };
799
777
  return !(!o || o[0] !== t);
800
778
  } catch {
801
779
  }
802
- return this._cleanupClosedWindows(), wn(this.keys, t) !== -1;
780
+ return this._cleanupClosedWindows(), mn(this.keys, t) !== -1;
803
781
  }, r.getOrSet = function(t, e) {
804
782
  if (this.has(t))
805
783
  return this.get(t);
@@ -831,15 +809,15 @@ var lt = { exports: {} }, vt = { exports: {} };
831
809
  throw new Error("Can not find window.btoa or Buffer");
832
810
  }((/* @__PURE__ */ new Date()).toISOString().slice(11, 19).replace("T", ".")).replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
833
811
  }
834
- var mn;
812
+ var pn;
835
813
  function Bn(n) {
836
814
  try {
837
815
  return JSON.stringify([].slice.call(n), function(r, t) {
838
816
  return typeof t == "function" ? "memoize[" + function(e) {
839
- if (mn = mn || new xn(), e == null || typeof e != "object" && typeof e != "function")
817
+ if (pn = pn || new Sn(), e == null || typeof e != "object" && typeof e != "function")
840
818
  throw new Error("Invalid object");
841
- var o = mn.get(e);
842
- return o || (o = typeof e + ":" + G(), mn.set(e, o)), o;
819
+ var o = pn.get(e);
820
+ return o || (o = typeof e + ":" + G(), pn.set(e, o)), o;
843
821
  }(t) + "]" : typeof window < "u" && t instanceof window.Element || t !== null && typeof t == "object" && t.nodeType === 1 && typeof t.style == "object" && typeof t.ownerDocument == "object" ? {} : t;
844
822
  });
845
823
  } catch {
@@ -859,7 +837,7 @@ var lt = { exports: {} }, vt = { exports: {} };
859
837
  h[d] = arguments[d];
860
838
  s < Gn && (i = null, a = null, s = en, en += 1);
861
839
  var f;
862
- f = e ? (a = a || new xn()).getOrSet(this, yt) : i = i || {};
840
+ f = e ? (a = a || new Sn()).getOrSet(this, yt) : i = i || {};
863
841
  var l;
864
842
  try {
865
843
  l = Bn(h);
@@ -934,7 +912,7 @@ var lt = { exports: {} }, vt = { exports: {} };
934
912
  n.hasOwnProperty(t) && r.push(n[t]);
935
913
  return r;
936
914
  });
937
- function Sn(n) {
915
+ function bn(n) {
938
916
  return {}.toString.call(n) === "[object RegExp]";
939
917
  }
940
918
  function un(n, r, t) {
@@ -965,8 +943,8 @@ var lt = { exports: {} }, vt = { exports: {} };
965
943
  }, 10);
966
944
  });
967
945
  });
968
- var pn = typeof document < "u" ? document.currentScript : null, Wt = on(function() {
969
- if (pn || (pn = function() {
946
+ var gn = typeof document < "u" ? document.currentScript : null, Wt = on(function() {
947
+ if (gn || (gn = function() {
970
948
  try {
971
949
  var n = function() {
972
950
  try {
@@ -985,7 +963,7 @@ var lt = { exports: {} }, vt = { exports: {} };
985
963
  } catch {
986
964
  }
987
965
  }()))
988
- return pn;
966
+ return gn;
989
967
  throw new Error("Can not determine current script");
990
968
  }), xt = G();
991
969
  on(function() {
@@ -1052,13 +1030,13 @@ var lt = { exports: {} }, vt = { exports: {} };
1052
1030
  }
1053
1031
  var St = function() {
1054
1032
  };
1055
- function gn() {
1033
+ function yn() {
1056
1034
  var n = cn();
1057
1035
  return n.WINDOW_WILDCARD = n.WINDOW_WILDCARD || new St(), n.WINDOW_WILDCARD;
1058
1036
  }
1059
1037
  function C(n, r) {
1060
1038
  return n === void 0 && (n = "store"), r === void 0 && (r = $n), z("windowStore").getOrSet(n, function() {
1061
- var t = new xn(), e = function(o) {
1039
+ var t = new Sn(), e = function(o) {
1062
1040
  return t.getOrSet(o, r);
1063
1041
  };
1064
1042
  return {
@@ -1094,7 +1072,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1094
1072
  });
1095
1073
  return e.set(n, i), i;
1096
1074
  }
1097
- function bn(n, r) {
1075
+ function Pn(n, r) {
1098
1076
  return (0, r.send)(n, "postrobot_hello", {
1099
1077
  instanceID: Yn()
1100
1078
  }, {
@@ -1114,7 +1092,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1114
1092
  function Kn(n, r) {
1115
1093
  var t = r.send;
1116
1094
  return C("windowInstanceIDPromises").getOrSet(n, function() {
1117
- return bn(n, {
1095
+ return Pn(n, {
1118
1096
  send: t
1119
1097
  }).then(function(e) {
1120
1098
  return e.instanceID;
@@ -1124,7 +1102,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1124
1102
  function Xn(n) {
1125
1103
  C("knownWindows").set(n, !0);
1126
1104
  }
1127
- function Pn(n) {
1105
+ function In(n) {
1128
1106
  return typeof n == "object" && n !== null && typeof n.__type__ == "string";
1129
1107
  }
1130
1108
  function Qn(n) {
@@ -1198,7 +1176,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1198
1176
  return clearInterval(r), n(window.document.body);
1199
1177
  }, 10);
1200
1178
  });
1201
- function In() {
1179
+ function On() {
1202
1180
  for (var n = z("idToProxyWindow"), r = 0, t = n.keys(); r < t.length; r++) {
1203
1181
  var e = t[r];
1204
1182
  n.get(e).shouldClean() && n.del(e);
@@ -1207,17 +1185,17 @@ var lt = { exports: {} }, vt = { exports: {} };
1207
1185
  function _n(n, r) {
1208
1186
  var t = r.send, e = r.id, o = e === void 0 ? G() : e, i = n.then(function(c) {
1209
1187
  if ($(c))
1210
- return ln(c).name;
1188
+ return vn(c).name;
1211
1189
  }), a = n.then(function(c) {
1212
1190
  if (U(c))
1213
1191
  throw new Error("Window is closed, can not determine type");
1214
- return zn(c) ? "popup" : "iframe";
1192
+ return fn(c) ? "popup" : "iframe";
1215
1193
  });
1216
1194
  i.catch(k), a.catch(k);
1217
1195
  var s = function() {
1218
1196
  return n.then(function(c) {
1219
1197
  if (!U(c))
1220
- return $(c) ? ln(c).name : i;
1198
+ return $(c) ? vn(c).name : i;
1221
1199
  });
1222
1200
  };
1223
1201
  return {
@@ -1261,8 +1239,8 @@ var lt = { exports: {} }, vt = { exports: {} };
1261
1239
  var P = m.url, R = m.target, O = m.body, I = m.method, j = I === void 0 ? "post" : I, W = document.createElement("form");
1262
1240
  if (W.setAttribute("target", R), W.setAttribute("method", j), W.setAttribute("action", P), W.style.display = "none", O)
1263
1241
  for (var D = 0, B = Object.keys(O); D < B.length; D++) {
1264
- var N, sn = B[D], Nn = document.createElement("input");
1265
- Nn.setAttribute("name", sn), Nn.setAttribute("value", (N = O[sn]) == null ? void 0 : N.toString()), W.appendChild(Nn);
1242
+ var N, sn = B[D], Rn = document.createElement("input");
1243
+ Rn.setAttribute("name", sn), Rn.setAttribute("value", (N = O[sn]) == null ? void 0 : N.toString()), W.appendChild(Rn);
1266
1244
  }
1267
1245
  qn().appendChild(W), W.submit(), qn().removeChild(W);
1268
1246
  })({
@@ -1290,7 +1268,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1290
1268
  var h = $(u), d = Mn(u);
1291
1269
  if (!h)
1292
1270
  throw new Error("Can not set name for cross-domain window: " + c);
1293
- ln(u).name = c, d && d.setAttribute("name", c), i = b.resolve(c);
1271
+ vn(u).name = c, d && d.setAttribute("name", c), i = b.resolve(c);
1294
1272
  });
1295
1273
  }
1296
1274
  };
@@ -1380,20 +1358,20 @@ var lt = { exports: {} }, vt = { exports: {} };
1380
1358
  return n.isProxyWindow(t) ? t.unwrap() : t;
1381
1359
  }, n.serialize = function(t, e) {
1382
1360
  var o = e.send;
1383
- return In(), n.toProxyWindow(t, {
1361
+ return On(), n.toProxyWindow(t, {
1384
1362
  send: o
1385
1363
  }).serialize();
1386
1364
  }, n.deserialize = function(t, e) {
1387
1365
  var o = e.send;
1388
- return In(), z("idToProxyWindow").get(t.id) || new n({
1366
+ return On(), z("idToProxyWindow").get(t.id) || new n({
1389
1367
  serializedWindow: t,
1390
1368
  send: o
1391
1369
  });
1392
1370
  }, n.isProxyWindow = function(t) {
1393
- return !!(t && !vn(t) && t.isProxyWindow);
1371
+ return !!(t && !wn(t) && t.isProxyWindow);
1394
1372
  }, n.toProxyWindow = function(t, e) {
1395
1373
  var o = e.send;
1396
- if (In(), n.isProxyWindow(t))
1374
+ if (On(), n.isProxyWindow(t))
1397
1375
  return t;
1398
1376
  var i = t;
1399
1377
  return C("winToProxyWindow").get(i) || new n({
@@ -1402,7 +1380,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1402
1380
  });
1403
1381
  }, n;
1404
1382
  }();
1405
- function On(n, r, t, e, o) {
1383
+ function Dn(n, r, t, e, o) {
1406
1384
  var i = C("methodStore"), a = z("proxyWindowMethods");
1407
1385
  H.isProxyWindow(e) ? a.set(n, {
1408
1386
  val: r,
@@ -1438,7 +1416,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1438
1416
  var P = m.source, R = m.domain, O = m.val;
1439
1417
  return b.try(function() {
1440
1418
  if (!_(R, f))
1441
- throw new Error("Method '" + l.name + "' domain " + JSON.stringify(Sn(m.domain) ? m.domain.source : m.domain) + " does not match origin " + f + " in " + T(window));
1419
+ throw new Error("Method '" + l.name + "' domain " + JSON.stringify(bn(m.domain) ? m.domain.source : m.domain) + " does not match origin " + f + " in " + T(window));
1442
1420
  if (H.isProxyWindow(P))
1443
1421
  return P.matchWindow(d, {
1444
1422
  send: s
@@ -1477,9 +1455,9 @@ var lt = { exports: {} }, vt = { exports: {} };
1477
1455
  var i, a, s, c = t.__id__ || G();
1478
1456
  n = H.unwrap(n);
1479
1457
  var u = t.__name__ || t.name || e;
1480
- return typeof u == "string" && typeof u.indexOf == "function" && u.indexOf("anonymous::") === 0 && (u = u.replace("anonymous::", e + "::")), H.isProxyWindow(n) ? (On(c, t, u, n, r), n.awaitWindow().then(function(h) {
1481
- On(c, t, u, h, r);
1482
- })) : On(c, t, u, n, r), K("cross_domain_function", {
1458
+ return typeof u == "string" && typeof u.indexOf == "function" && u.indexOf("anonymous::") === 0 && (u = u.replace("anonymous::", e + "::")), H.isProxyWindow(n) ? (Dn(c, t, u, n, r), n.awaitWindow().then(function(h) {
1459
+ Dn(c, t, u, h, r);
1460
+ })) : Dn(c, t, u, n, r), K("cross_domain_function", {
1483
1461
  id: c,
1484
1462
  name: u
1485
1463
  });
@@ -1490,7 +1468,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1490
1468
  c === void 0 && (c = Pt);
1491
1469
  var u = JSON.stringify(s, function(h) {
1492
1470
  var d = this[h];
1493
- if (Pn(this))
1471
+ if (In(this))
1494
1472
  return d;
1495
1473
  var f = Qn(d);
1496
1474
  if (!f)
@@ -1519,7 +1497,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1519
1497
  send: a
1520
1498
  });
1521
1499
  }, o.object = function(s) {
1522
- return vn(s) || H.isProxyWindow(s) ? K("cross_domain_window", H.serialize(s, {
1500
+ return wn(s) || H.isProxyWindow(s) ? K("cross_domain_window", H.serialize(s, {
1523
1501
  send: a
1524
1502
  })) : s;
1525
1503
  }, o));
@@ -1529,10 +1507,10 @@ var lt = { exports: {} }, vt = { exports: {} };
1529
1507
  return function(a, s) {
1530
1508
  if (s === void 0 && (s = Ot), a !== "undefined")
1531
1509
  return JSON.parse(a, function(c, u) {
1532
- if (Pn(this))
1510
+ if (In(this))
1533
1511
  return u;
1534
1512
  var h, d;
1535
- if (Pn(u) ? (h = u.__type__, d = u.__val__) : (h = Qn(u), d = u), !h)
1513
+ if (In(u) ? (h = u.__type__, d = u.__val__) : (h = Qn(u), d = u), !h)
1536
1514
  return d;
1537
1515
  var f = s[h] || It[h];
1538
1516
  return f ? f(d, c) : d;
@@ -1592,11 +1570,11 @@ var lt = { exports: {} }, vt = { exports: {} };
1592
1570
  });
1593
1571
  }, o));
1594
1572
  }
1595
- var Dn = {};
1596
- Dn.postrobot_post_message = function(n, r, t) {
1573
+ var An = {};
1574
+ An.postrobot_post_message = function(n, r, t) {
1597
1575
  t.indexOf("file:") === 0 && (t = "*"), n.postMessage(r, t);
1598
1576
  };
1599
- function An(n, r, t, e) {
1577
+ function Nn(n, r, t, e) {
1600
1578
  var o = e.on, i = e.send;
1601
1579
  return b.try(function() {
1602
1580
  var a = C().getOrSet(n, function() {
@@ -1610,10 +1588,10 @@ var lt = { exports: {} }, vt = { exports: {} };
1610
1588
  send: i
1611
1589
  }), c;
1612
1590
  delete a.buffer;
1613
- for (var u = Object.keys(Dn), h = [], d = 0; d < u.length; d++) {
1591
+ for (var u = Object.keys(An), h = [], d = 0; d < u.length; d++) {
1614
1592
  var f = u[d];
1615
1593
  try {
1616
- Dn[f](n, s, r);
1594
+ An[f](n, s, r);
1617
1595
  } catch (l) {
1618
1596
  h.push(l);
1619
1597
  }
@@ -1644,7 +1622,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1644
1622
  var r = n.name, t = n.win, e = n.domain, o = C("requestListeners");
1645
1623
  if (t === "*" && (t = null), e === "*" && (e = null), !r)
1646
1624
  throw new Error("Name required to get request listener");
1647
- for (var i = 0, a = [t, gn()]; i < a.length; i++) {
1625
+ for (var i = 0, a = [t, yn()]; i < a.length; i++) {
1648
1626
  var s = a[i];
1649
1627
  if (s) {
1650
1628
  var c = o.get(s);
@@ -1678,7 +1656,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1678
1656
  return b.flush().then(function() {
1679
1657
  if (!t.fireAndForget && !U(n))
1680
1658
  try {
1681
- return An(n, r, {
1659
+ return Nn(n, r, {
1682
1660
  id: G(),
1683
1661
  origin: T(window),
1684
1662
  type: "postrobot_message_response",
@@ -1701,7 +1679,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1701
1679
  return b.all([b.flush().then(function() {
1702
1680
  if (!t.fireAndForget && !U(n))
1703
1681
  try {
1704
- return An(n, r, {
1682
+ return Nn(n, r, {
1705
1683
  id: G(),
1706
1684
  origin: T(window),
1707
1685
  type: "postrobot_message_ack",
@@ -1873,16 +1851,16 @@ var lt = { exports: {} }, vt = { exports: {} };
1873
1851
  win: f,
1874
1852
  domain: u
1875
1853
  });
1876
- f && f !== "*" || (f = gn());
1854
+ f && f !== "*" || (f = yn());
1877
1855
  var I = (u = u || "*").toString();
1878
1856
  if (O)
1879
- throw f && u ? new Error("Request listener already exists for " + s + " on domain " + u.toString() + " for " + (f === gn() ? "wildcard" : "specified") + " window") : f ? new Error("Request listener already exists for " + s + " for " + (f === gn() ? "wildcard" : "specified") + " window") : u ? new Error("Request listener already exists for " + s + " on domain " + u.toString()) : new Error("Request listener already exists for " + s);
1857
+ throw f && u ? new Error("Request listener already exists for " + s + " on domain " + u.toString() + " for " + (f === yn() ? "wildcard" : "specified") + " window") : f ? new Error("Request listener already exists for " + s + " for " + (f === yn() ? "wildcard" : "specified") + " window") : u ? new Error("Request listener already exists for " + s + " on domain " + u.toString()) : new Error("Request listener already exists for " + s);
1880
1858
  var j = h.getOrSet(f, function() {
1881
1859
  return {};
1882
1860
  }), W = un(j, s, function() {
1883
1861
  return {};
1884
1862
  }), D, B;
1885
- return Sn(u) ? (D = un(W, "__domain_regex__", function() {
1863
+ return bn(u) ? (D = un(W, "__domain_regex__", function() {
1886
1864
  return [];
1887
1865
  })).push(B = {
1888
1866
  regex: u,
@@ -1927,7 +1905,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1927
1905
  if (function(h, d, f) {
1928
1906
  if (!h)
1929
1907
  throw new Error("Expected name");
1930
- if (f && typeof f != "string" && !Array.isArray(f) && !Sn(f))
1908
+ if (f && typeof f != "string" && !Array.isArray(f) && !bn(f))
1931
1909
  throw new TypeError("Can not send " + h + ". Expected domain " + JSON.stringify(f) + " to be a string, array, or regex");
1932
1910
  if (U(d))
1933
1911
  throw new Error("Can not send " + h + ". Target window is closed");
@@ -1993,7 +1971,7 @@ var lt = { exports: {} }, vt = { exports: {} };
1993
1971
  var w = p.send;
1994
1972
  return b.try(function() {
1995
1973
  return typeof f == "string" ? f : b.try(function() {
1996
- return l || bn(d, {
1974
+ return l || Pn(d, {
1997
1975
  send: w
1998
1976
  }).then(function(m) {
1999
1977
  return m.domain;
@@ -2051,7 +2029,7 @@ var lt = { exports: {} }, vt = { exports: {} };
2051
2029
  j.cancel(), m.splice(m.indexOf(l, 1));
2052
2030
  }).catch(k);
2053
2031
  }
2054
- return An(u, d, {
2032
+ return Nn(u, d, {
2055
2033
  id: G(),
2056
2034
  origin: T(window),
2057
2035
  type: "postrobot_message_request",
@@ -2152,7 +2130,7 @@ var lt = { exports: {} }, vt = { exports: {} };
2152
2130
  instanceID: Yn()
2153
2131
  };
2154
2132
  }), c = Cn();
2155
- return c && bn(c, {
2133
+ return c && Pn(c, {
2156
2134
  send: a
2157
2135
  }).catch(function(u) {
2158
2136
  }), s;
@@ -2181,41 +2159,62 @@ var lt = { exports: {} }, vt = { exports: {} };
2181
2159
  st();
2182
2160
  }]);
2183
2161
  });
2184
- })(vt);
2185
- var Xt = vt.exports;
2186
- (function(y) {
2187
- y.exports = Xt, y.exports.default = y.exports;
2188
2162
  })(lt);
2189
- var Qt = lt.exports;
2190
- const _t = /* @__PURE__ */ Kt(Qt), nr = "WIDGET_EVENT";
2163
+ var qt = lt.exports;
2164
+ (function(y) {
2165
+ y.exports = qt, y.exports.default = y.exports;
2166
+ })(ht);
2167
+ var Zt = ht.exports;
2168
+ const Vt = /* @__PURE__ */ Jt(Zt), $t = "WIDGET_EVENT", Yt = "https://app.soyio.id/widget", kt = "https://sandbox.soyio.id/widget", Kt = ["IDENTITY_AUTHENTICATED", "IDENTITY_REGISTERED"], Xt = "WIDGET_CLOSED";
2169
+ function Qt(y, x, A, S) {
2170
+ const g = S || (A ? kt : Yt), v = Object.entries(x).filter(([, E]) => E).map(([E, M]) => `${E}=${encodeURIComponent(M)}`).join("&");
2171
+ return `${g}/${y}?platform=web&${v}`;
2172
+ }
2173
+ let X = null;
2174
+ function zn() {
2175
+ if (X && !X.closed)
2176
+ X.focus();
2177
+ else
2178
+ throw new Error("Popup window does not exist or is closed.");
2179
+ }
2180
+ function _t(y, x, A, S) {
2181
+ const g = Qt(y, x, A, S), v = 510, E = 720, M = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width, V = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height, Q = M / 2 - v / 2, J = V / 2 - E / 2;
2182
+ document.body.style.filter = "blur(5px)", document.body.addEventListener("click", (fn) => {
2183
+ zn(), fn.preventDefault();
2184
+ }), X = window.open(g, "Soyio", `scrollbars=yes, width=${v}, height=${E}, top=${J}, left=${Q}`), zn();
2185
+ }
2186
+ function vt() {
2187
+ document.body.style.filter = "", document.body.removeEventListener("click", zn);
2188
+ }
2189
+ function nr() {
2190
+ X && (X.close(), X = null), vt();
2191
+ }
2191
2192
  function tr(y) {
2192
2193
  const { onEvent: x } = y;
2193
- _t.on(nr, (A) => {
2194
- x(A.data), qt.includes(A.data.eventName) ? Yt() : A.data.eventName === Zt && ht();
2194
+ Vt.on($t, (A) => {
2195
+ x(A.data), Kt.includes(A.data.eventName) ? nr() : A.data.eventName === Xt && vt();
2195
2196
  });
2196
2197
  }
2197
2198
  function rr(y) {
2198
2199
  tr(y);
2199
2200
  }
2200
- var yn, wt;
2201
+ var En, wt;
2201
2202
  class or {
2202
- // eslint-disable-next-line max-params
2203
2203
  constructor(x) {
2204
- dt(this, yn);
2204
+ dt(this, En);
2205
2205
  dn(this, "flow");
2206
2206
  dn(this, "configProps");
2207
2207
  dn(this, "onEvent");
2208
2208
  dn(this, "isSandbox");
2209
- this.flow = x.flow, this.configProps = x.configProps, this.onEvent = x.onEvent, this.isSandbox = x.isSandbox ?? !1, this.validateProps(), $t(
2209
+ this.flow = x.flow, this.configProps = x.configProps, this.onEvent = x.onEvent, this.isSandbox = x.isSandbox ?? !1, this.validateProps(), _t(
2210
2210
  this.flow,
2211
2211
  this.configProps,
2212
2212
  this.isSandbox,
2213
2213
  x.developmentUrl
2214
2214
  ), rr({
2215
- onEvent: ft(this, yn, wt).bind(this)
2215
+ onEvent: ft(this, En, wt).bind(this)
2216
2216
  });
2217
2217
  }
2218
- // eslint-disable-next-line complexity
2219
2218
  validateProps() {
2220
2219
  if (this.flow === "authenticate") {
2221
2220
  if (!this.configProps.identityId)
@@ -2230,7 +2229,7 @@ class or {
2230
2229
  }
2231
2230
  }
2232
2231
  }
2233
- yn = new WeakSet(), wt = function(x) {
2232
+ En = new WeakSet(), wt = function(x) {
2234
2233
  this.onEvent(x);
2235
2234
  };
2236
2235
  export {
@@ -1,17 +1,17 @@
1
- (function(N,O){typeof exports=="object"&&typeof module<"u"?module.exports=O():typeof define=="function"&&define.amd?define(O):(N=typeof globalThis<"u"?globalThis:N||self,N["soyio-widget"]=O())})(this,function(){"use strict";var te=Object.defineProperty;var ee=(N,O,L)=>O in N?te(N,O,{enumerable:!0,configurable:!0,writable:!0,value:L}):N[O]=L;var ln=(N,O,L)=>(ee(N,typeof O!="symbol"?O+"":O,L),L),re=(N,O,L)=>{if(!O.has(N))throw TypeError("Cannot "+L)};var mt=(N,O,L)=>{if(O.has(N))throw TypeError("Cannot add the same private member more than once");O instanceof WeakSet?O.add(N):O.set(N,L)};var pt=(N,O,L)=>(re(N,O,"access private method"),L);var vn,gt;const N="https://app.soyio.id/widget",O="https://sandbox.soyio.id/widget",L=["IDENTITY_AUTHENTICATED","IDENTITY_REGISTERED"],yt="WIDGET_CLOSED";function Et(D,T,G,W){const g=W||(G?O:N),v=Object.entries(T).filter(([,y])=>y).map(([y,F])=>`${y}=${encodeURIComponent(F)}`).join("&");return`${g}/${D}?platform=web&${v}`}let k=null;function Sn(){if(k&&!k.closed)k.focus();else throw new Error("Popup window does not exist or is closed.")}function Wt(D,T,G,W){const g=Et(D,T,G,W),v=510,y=720,F=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,K=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height,tn=F/2-v/2,V=K/2-y/2;document.body.style.filter="blur(5px)",document.body.addEventListener("click",Sn),k=window.open(g,"Soyio",`scrollbars=yes, width=${v}, height=${y}, top=${V}, left=${tn}`),Sn()}function Cn(){document.body.style.filter="",document.body.removeEventListener("click",Sn)}function xt(){k&&(k.close(),k=null),Cn()}var St=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function bt(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}var Mn={exports:{}},Ln={exports:{}};(function(D,T){(function(G,W){D.exports=W()})(typeof self<"u"?self:St,function(){return function(G){var W={};function g(v){if(W[v])return W[v].exports;var y=W[v]={i:v,l:!1,exports:{}};return G[v].call(y.exports,y,y.exports,g),y.l=!0,y.exports}return g.m=G,g.c=W,g.d=function(v,y,F){g.o(v,y)||Object.defineProperty(v,y,{enumerable:!0,get:F})},g.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},g.t=function(v,y){if(1&y&&(v=g(v)),8&y||4&y&&typeof v=="object"&&v&&v.__esModule)return v;var F=Object.create(null);if(g.r(F),Object.defineProperty(F,"default",{enumerable:!0,value:v}),2&y&&typeof v!="string")for(var K in v)g.d(F,K,(function(tn){return v[tn]}).bind(null,K));return F},g.n=function(v){var y=v&&v.__esModule?function(){return v.default}:function(){return v};return g.d(y,"a",y),y},g.o=function(v,y){return{}.hasOwnProperty.call(v,y)},g.p="",g(g.s=0)}([function(G,W,g){g.r(W),g.d(W,"Promise",function(){return x}),g.d(W,"TYPES",function(){return _t}),g.d(W,"ProxyWindow",function(){return B}),g.d(W,"setup",function(){return wt}),g.d(W,"destroy",function(){return Qt}),g.d(W,"serializeMessage",function(){return Yt}),g.d(W,"deserializeMessage",function(){return kt}),g.d(W,"createProxyWindow",function(){return Kt}),g.d(W,"toProxyWindow",function(){return Xt}),g.d(W,"on",function(){return $}),g.d(W,"once",function(){return $t}),g.d(W,"send",function(){return Y}),g.d(W,"markWindowKnown",function(){return rt}),g.d(W,"cleanUpWindow",function(){return ne}),g.d(W,"bridge",function(){});function v(n){return{}.toString.call(n)==="[object RegExp]"}var y=`Call was rejected by callee.\r
2
- `;function F(n){return n===void 0&&(n=window),n.location.protocol}function K(n){if(n===void 0&&(n=window),n.mockDomain){var e=n.mockDomain.split("//")[0];if(e)return e}return F(n)}function tn(n){return n===void 0&&(n=window),K(n)==="about:"}function V(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Fn(n){if(n===void 0&&(n=window),n&&!V(n))try{return n.opener}catch{}}function wn(n){try{return!0}catch{}return!1}function mn(n){n===void 0&&(n=window);var e=n.location;if(!e)throw new Error("Can not read window location");var t=F(n);if(!t)throw new Error("Can not read window protocol");if(t==="file:")return"file://";if(t==="about:"){var r=V(n);return r&&wn()?mn(r):"about://"}var o=e.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function C(n){n===void 0&&(n=window);var e=mn(n);return e&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:e}function X(n){if(!function(e){try{if(e===window)return!0}catch{}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&t.enumerable===!1)return!1}catch{}try{if(tn(e)&&wn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),K(r)==="mock:"}(e)&&wn())return!0}catch{}try{if(mn(e)===mn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||tn(n)&&wn()||C(window)===C(n))return!0}catch{}return!1}function pn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Hn(n,e){if(!n||!e)return!1;var t=V(e);return t?t===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(e).indexOf(n)!==-1}function Un(n){var e=[],t;try{t=n.frames}catch{t=n}var r;try{r=t.length}catch{}if(r===0)return e;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=t[o]}catch{continue}e.push(i)}return e}for(var a=0;a<100;a++){var s=void 0;try{s=t[a]}catch{return e}if(!s)return e;e.push(s)}return e}var zt=[],jt=[];function J(n,e){e===void 0&&(e=!0);try{if(n===window)return!1}catch{return!0}try{if(!n)return!0}catch{return!0}try{if(n.closed)return!0}catch(o){return!o||o.message!==y}if(e&&X(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var t=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(zt,n);if(t!==-1){var r=jt[t];if(r&&function(o){if(!o.contentWindow||!o.parentNode)return!0;var i=o.ownerDocument;if(i&&i.documentElement&&!i.documentElement.contains(o)){for(var a=o;a.parentNode&&a.parentNode!==a;)a=a.parentNode;if(!a.host||!i.documentElement.contains(a.host))return!0}return!1}(r))return!0}return!1}function Bn(n){return n===void 0&&(n=window),Fn(n=n||window)||V(n)||void 0}function en(n,e){if(typeof n=="string"){if(typeof e=="string")return n==="*"||e===n;if(v(e)||Array.isArray(e))return!1}return v(n)?v(e)?n.toString()===e.toString():!Array.isArray(e)&&!!e.match(n):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!v(e)&&n.some(function(t){return en(t,e)}))}function gn(n){try{if(n===window)return!0}catch(e){if(e&&e.message===y)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(e){if(e&&e.message===y)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.self===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.parent===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.top===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in n&&"self"in n&&"location"in n)return!0}catch{}return!1}function Gn(n){if(X(n))return pn(n).frameElement;for(var e=0,t=document.querySelectorAll("iframe");e<t.length;e++){var r=t[e];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function Tt(n){if(function(t){return t===void 0&&(t=window),!!V(t)}(n)){var e=Gn(n);if(e&&e.parentElement){e.parentElement.removeChild(e);return}}try{n.close()}catch{}}function Q(n){try{if(!n)return!1;if(typeof Promise<"u"&&n instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&n instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var t=e.call(n);if(t==="[object Window]"||t==="[object global]"||t==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var Jn=[],rn=[],bn=0,on;function qn(){if(!bn&&on){var n=on;on=null,n.resolve()}}function Pn(){bn+=1}function an(){bn-=1,qn()}var x=function(){function n(t){var r=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],t){var o,i,a=!1,s=!1,c=!1;Pn();try{t(function(u){c?r.resolve(u):(a=!0,o=u)},function(u){c?r.reject(u):(s=!0,i=u)})}catch(u){an(),this.reject(u);return}an(),c=!0,a?this.resolve(o):s&&this.reject(i)}}var e=n.prototype;return e.resolve=function(t){if(this.resolved||this.rejected)return this;if(Q(t))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=t,this.dispatch(),this},e.reject=function(t){var r=this;if(this.resolved||this.rejected)return this;if(Q(t))throw new Error("Can not reject promise with another promise");if(!t){var o=t&&typeof t.toString=="function"?t.toString():{}.toString.call(t);t=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=t,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(Jn.indexOf(i)===-1){Jn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<rn.length;s++)rn[s](i,a)}}(t,r)},1),this.dispatch(),this},e.asyncReject=function(t){return this.errorHandled=!0,this.reject(t),this},e.dispatch=function(){var t=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(t||r)){this.dispatching=!0,Pn();for(var i=function(l,p){return l.then(function(w){p.resolve(w)},function(w){p.reject(w)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,h=s.promise,d=void 0;if(t)try{d=c?c(this.value):this.value}catch(l){h.reject(l);continue}else if(r){if(!u){h.reject(this.error);continue}try{d=u(this.error)}catch(l){h.reject(l);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?h.resolve(f.value):h.reject(f.error),f.errorHandled=!0}else Q(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?h.resolve(d.value):h.reject(d.error):i(d,h):h.resolve(d)}o.length=0,this.dispatching=!1,an()}},e.then=function(t,r){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.then expected a function for success handler");if(r&&typeof r!="function"&&!r.call)throw new Error("Promise.then expected a function for error handler");var o=new n;return this.handlers.push({promise:o,onSuccess:t,onError:r}),this.errorHandled=!0,this.dispatch(),o},e.catch=function(t){return this.then(void 0,t)},e.finally=function(t){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(t).then(function(){return r})},function(r){return n.try(t).then(function(){throw r})})},e.timeout=function(t,r){var o=this;if(this.resolved||this.rejected)return this;var i=setTimeout(function(){o.resolved||o.rejected||o.reject(r||new Error("Promise timed out after "+t+"ms"))},t);return this.then(function(a){return clearTimeout(i),a})},e.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(t){return t instanceof n?t:Q(t)?new n(function(r,o){return t.then(r,o)}):new n().resolve(t)},n.reject=function(t){return new n().reject(t)},n.asyncReject=function(t){return new n().asyncReject(t)},n.all=function(t){var r=new n,o=t.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,h,d){return h.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},s=0;s<t.length;s++){var c=t[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!Q(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(t){var r={},o=[],i=function(s){if(t.hasOwnProperty(s)){var c=t[s];Q(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in t)i(a);return n.all(o).then(function(){return r})},n.map=function(t,r){return n.all(t.map(r))},n.onPossiblyUnhandledException=function(t){return function(r){return rn.push(r),{cancel:function(){rn.splice(rn.indexOf(r),1)}}}(t)},n.try=function(t,r,o){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.try expected a function");var i;Pn();try{i=t.apply(r,o||[])}catch(a){return an(),n.reject(a)}return an(),n.resolve(i)},n.delay=function(t){return new n(function(r){setTimeout(r,t)})},n.isPromise=function(t){return!!(t&&t instanceof n)||Q(t)},n.flush=function(){return function(t){var r=on=on||new t;return qn(),r}(n)},n}();function yn(n,e){for(var t=0;t<n.length;t++)try{if(n[t]===e)return t}catch{}return-1}var In=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var t=new WeakMap,r={};return Object.freeze(r),t.set(r,"__testvalue__"),t.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var t=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(gn(i)&&J(i)){if(t)try{t.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},e.isSafeToReadWrite=function(t){return!gn(t)},e.set=function(t,r){if(!t)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(t,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var i=this.name,a=t[i];a&&a[0]===t?a[1]=r:Object.defineProperty(t,i,{value:[t,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=yn(s,t);u===-1?(s.push(t),c.push(r)):c[u]=r},e.get=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return r.get(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return o&&o[0]===t?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=yn(this.keys,t);if(i!==-1)return this.values[i]},e.delete=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];o&&o[0]===t&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=yn(i,t);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},e.has=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return!(!o||o[0]!==t)}catch{}return this._cleanupClosedWindows(),yn(this.keys,t)!==-1},e.getOrSet=function(t,r){if(this.has(t))return this.get(t);var o=r();return this.set(t,o),o},n}();function Zn(n){return n.name||n.__name__||n.displayName||"anonymous"}function Vn(n,e){try{delete n.name,n.name=e}catch{}return n.__name__=n.displayName=e,n}function Z(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(e){if(typeof btoa=="function")return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(t,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var En;function $n(n){try{return JSON.stringify([].slice.call(n),function(e,t){return typeof t=="function"?"memoize["+function(r){if(En=En||new In,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=En.get(r);return o||(o=typeof r+":"+Z(),En.set(r,o)),o}(t)+"]":typeof window<"u"&&t instanceof window.Element||t!==null&&typeof t=="object"&&t.nodeType===1&&typeof t.style=="object"&&typeof t.ownerDocument=="object"?{}:t})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ct(){return{}}var un=0,Yn=0;function cn(n,e){e===void 0&&(e={});var t=e.thisNamespace,r=t!==void 0&&t,o=e.time,i,a,s=un;un+=1;var c=function(){for(var u=arguments.length,h=new Array(u),d=0;d<u;d++)h[d]=arguments[d];s<Yn&&(i=null,a=null,s=un,un+=1);var f;f=r?(a=a||new In).getOrSet(this,Ct):i=i||{};var l;try{l=$n(h)}catch{return n.apply(this,arguments)}var p=f[l];if(p&&o&&Date.now()-p.time<o&&(delete f[l],p=null),p)return p.value;var w=Date.now(),m=n.apply(this,arguments);return f[l]={time:w,value:m},m};return c.reset=function(){i=null,a=null},Vn(c,(e.name||Zn(n))+"::memoized")}cn.clear=function(){Yn=un};function Mt(n){var e={};function t(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=$n(a);return e.hasOwnProperty(c)||(e[c]=x.try(function(){return n.apply(o,r)}).finally(function(){delete e[c]})),e[c]}return t.reset=function(){e={}},Vn(t,Zn(n)+"::promiseMemoized")}function _(){}function sn(n,e){if(e===void 0&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if(typeof n=="string")return n;if(n instanceof Error){var t=n&&n.stack,r=n&&n.message;if(t&&r)return t.indexOf(r)!==-1?t:r+`
3
- `+t;if(t)return t;if(r)return r}return n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}catch(o){return"Error while stringifying error: "+sn(o,e+1)}}function kn(n){return typeof n=="string"?n:n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}cn(function(n){if(Object.values)return Object.values(n);var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(n[t]);return e});function On(n){return{}.toString.call(n)==="[object RegExp]"}function dn(n,e,t){if(n.hasOwnProperty(e))return n[e];var r=t();return n[e]=r,r}function Kn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function Xn(){return!!document.body&&document.readyState==="complete"}function Qn(){return!!document.body&&document.readyState==="interactive"}cn(function(){return new x(function(n){if(Xn()||Qn())return n();var e=setInterval(function(){if(Xn()||Qn())return clearInterval(e),n()},10)})});var Wn=typeof document<"u"?document.currentScript:null,Lt=cn(function(){if(Wn||(Wn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),e=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),t=e&&e[1];if(!t)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===t)return i}}catch{}}()))return Wn;throw new Error("Can not determine current script")}),Ft=Z();cn(function(){var n;try{n=Lt()}catch{return Ft}var e=n.getAttribute("data-uid");if(e&&typeof e=="string"||(e=n.getAttribute("data-uid-auto"))&&typeof e=="string")return e;if(n.src){var t=function(r){for(var o="",i=0;i<r.length;i++){var a=r[i].charCodeAt(0)*i;r[i+1]&&(a+=r[i+1].charCodeAt(0)*(i-1)),o+=String.fromCharCode(97+Math.abs(a)%26)}return o}(JSON.stringify({src:n.src,dataset:n.dataset}));e="uid_"+t.slice(t.length-30)}else e=Z();return n.setAttribute("data-uid-auto",e),e});function fn(n){n===void 0&&(n=window);var e="__post_robot_10_0_46__";return n!==window?n[e]:n[e]=n[e]||{}}var _n=function(){return{}};function z(n,e){return n===void 0&&(n="store"),e===void 0&&(e=_n),dn(fn(),n,function(){var t=e();return{has:function(r){return t.hasOwnProperty(r)},get:function(r,o){return t.hasOwnProperty(r)?t[r]:o},set:function(r,o){return t[r]=o,o},del:function(r){delete t[r]},getOrSet:function(r,o){return dn(t,r,o)},reset:function(){t=e()},keys:function(){return Object.keys(t)}}})}var Ht=function(){};function xn(){var n=fn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Ht,n.WINDOW_WILDCARD}function M(n,e){return n===void 0&&(n="store"),e===void 0&&(e=_n),z("windowStore").getOrSet(n,function(){var t=new In,r=function(o){return t.getOrSet(o,e)};return{has:function(o){return r(o).hasOwnProperty(n)},get:function(o,i){var a=r(o);return a.hasOwnProperty(n)?a[n]:i},set:function(o,i){return r(o)[n]=i,i},del:function(o){delete r(o)[n]},getOrSet:function(o,i){return dn(r(o),n,i)}}})}function nt(){return z("instance").getOrSet("instanceID",Z)}function tt(n,e){var t=e.domain,r=M("helloPromises"),o=r.get(n);o&&o.resolve({domain:t});var i=x.resolve({domain:t});return r.set(n,i),i}function Dn(n,e){return(0,e.send)(n,"postrobot_hello",{instanceID:nt()},{domain:"*",timeout:-1}).then(function(t){var r=t.origin,o=t.data.instanceID;return tt(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function et(n,e){var t=e.send;return M("windowInstanceIDPromises").getOrSet(n,function(){return Dn(n,{send:t}).then(function(r){return r.instanceID})})}function rt(n){M("knownWindows").set(n,!0)}function An(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function ot(n){return n===void 0?"undefined":n===null?"null":Array.isArray(n)?"array":typeof n=="function"?"function":typeof n=="object"?n instanceof Error?"error":typeof n.then=="function"?"promise":{}.toString.call(n)==="[object RegExp]"?"regex":{}.toString.call(n)==="[object Date]"?"date":"object":typeof n=="string"?"string":typeof n=="number"?"number":typeof n=="boolean"?"boolean":void 0}function nn(n,e){return{__type__:n,__val__:e}}var H,Ut=((H={}).function=function(){},H.error=function(n){return nn("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},H.promise=function(){},H.regex=function(n){return nn("regex",n.source)},H.date=function(n){return nn("date",n.toJSON())},H.array=function(n){return n},H.object=function(n){return n},H.string=function(n){return n},H.number=function(n){return n},H.boolean=function(n){return n},H.null=function(n){return n},H[void 0]=function(n){return nn("undefined",n)},H),Bt={},U,Gt=((U={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},U.error=function(n){var e=n.stack,t=n.code,r=n.data,o=new Error(n.message);return o.code=t,r&&(o.data=r),o.stack=e+`
1
+ (function(N,O){typeof exports=="object"&&typeof module<"u"?module.exports=O():typeof define=="function"&&define.amd?define(O):(N=typeof globalThis<"u"?globalThis:N||self,N["soyio-widget"]=O())})(this,function(){"use strict";var te=Object.defineProperty;var ee=(N,O,T)=>O in N?te(N,O,{enumerable:!0,configurable:!0,writable:!0,value:T}):N[O]=T;var ln=(N,O,T)=>(ee(N,typeof O!="symbol"?O+"":O,T),T),re=(N,O,T)=>{if(!O.has(N))throw TypeError("Cannot "+T)};var wt=(N,O,T)=>{if(O.has(N))throw TypeError("Cannot add the same private member more than once");O instanceof WeakSet?O.add(N):O.set(N,T)};var mt=(N,O,T)=>(re(N,O,"access private method"),T);var vn,pt;var N=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function O(D){return D&&D.__esModule&&Object.prototype.hasOwnProperty.call(D,"default")?D.default:D}var T={exports:{}},Mn={exports:{}};(function(D,C){(function(G,W){D.exports=W()})(typeof self<"u"?self:N,function(){return function(G){var W={};function g(v){if(W[v])return W[v].exports;var y=W[v]={i:v,l:!1,exports:{}};return G[v].call(y.exports,y,y.exports,g),y.l=!0,y.exports}return g.m=G,g.c=W,g.d=function(v,y,F){g.o(v,y)||Object.defineProperty(v,y,{enumerable:!0,get:F})},g.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},g.t=function(v,y){if(1&y&&(v=g(v)),8&y||4&y&&typeof v=="object"&&v&&v.__esModule)return v;var F=Object.create(null);if(g.r(F),Object.defineProperty(F,"default",{enumerable:!0,value:v}),2&y&&typeof v!="string")for(var K in v)g.d(F,K,(function(tn){return v[tn]}).bind(null,K));return F},g.n=function(v){var y=v&&v.__esModule?function(){return v.default}:function(){return v};return g.d(y,"a",y),y},g.o=function(v,y){return{}.hasOwnProperty.call(v,y)},g.p="",g(g.s=0)}([function(G,W,g){g.r(W),g.d(W,"Promise",function(){return x}),g.d(W,"TYPES",function(){return _t}),g.d(W,"ProxyWindow",function(){return B}),g.d(W,"setup",function(){return vt}),g.d(W,"destroy",function(){return Qt}),g.d(W,"serializeMessage",function(){return Yt}),g.d(W,"deserializeMessage",function(){return kt}),g.d(W,"createProxyWindow",function(){return Kt}),g.d(W,"toProxyWindow",function(){return Xt}),g.d(W,"on",function(){return $}),g.d(W,"once",function(){return $t}),g.d(W,"send",function(){return Y}),g.d(W,"markWindowKnown",function(){return et}),g.d(W,"cleanUpWindow",function(){return ne}),g.d(W,"bridge",function(){});function v(n){return{}.toString.call(n)==="[object RegExp]"}var y=`Call was rejected by callee.\r
2
+ `;function F(n){return n===void 0&&(n=window),n.location.protocol}function K(n){if(n===void 0&&(n=window),n.mockDomain){var e=n.mockDomain.split("//")[0];if(e)return e}return F(n)}function tn(n){return n===void 0&&(n=window),K(n)==="about:"}function V(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function wn(n){if(n===void 0&&(n=window),n&&!V(n))try{return n.opener}catch{}}function mn(n){try{return!0}catch{}return!1}function pn(n){n===void 0&&(n=window);var e=n.location;if(!e)throw new Error("Can not read window location");var t=F(n);if(!t)throw new Error("Can not read window protocol");if(t==="file:")return"file://";if(t==="about:"){var r=V(n);return r&&mn()?pn(r):"about://"}var o=e.host;if(!o)throw new Error("Can not read window host");return t+"//"+o}function M(n){n===void 0&&(n=window);var e=pn(n);return e&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:e}function X(n){if(!function(e){try{if(e===window)return!0}catch{}try{var t=Object.getOwnPropertyDescriptor(e,"location");if(t&&t.enumerable===!1)return!1}catch{}try{if(tn(e)&&mn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),K(r)==="mock:"}(e)&&mn())return!0}catch{}try{if(pn(e)===pn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||tn(n)&&mn()||M(window)===M(n))return!0}catch{}return!1}function gn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Fn(n,e){if(!n||!e)return!1;var t=V(e);return t?t===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(e).indexOf(n)!==-1}function Hn(n){var e=[],t;try{t=n.frames}catch{t=n}var r;try{r=t.length}catch{}if(r===0)return e;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=t[o]}catch{continue}e.push(i)}return e}for(var a=0;a<100;a++){var s=void 0;try{s=t[a]}catch{return e}if(!s)return e;e.push(s)}return e}var zt=[],jt=[];function J(n,e){e===void 0&&(e=!0);try{if(n===window)return!1}catch{return!0}try{if(!n)return!0}catch{return!0}try{if(n.closed)return!0}catch(o){return!o||o.message!==y}if(e&&X(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var t=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(zt,n);if(t!==-1){var r=jt[t];if(r&&function(o){if(!o.contentWindow||!o.parentNode)return!0;var i=o.ownerDocument;if(i&&i.documentElement&&!i.documentElement.contains(o)){for(var a=o;a.parentNode&&a.parentNode!==a;)a=a.parentNode;if(!a.host||!i.documentElement.contains(a.host))return!0}return!1}(r))return!0}return!1}function Un(n){return n===void 0&&(n=window),wn(n=n||window)||V(n)||void 0}function en(n,e){if(typeof n=="string"){if(typeof e=="string")return n==="*"||e===n;if(v(e)||Array.isArray(e))return!1}return v(n)?v(e)?n.toString()===e.toString():!Array.isArray(e)&&!!e.match(n):!!Array.isArray(n)&&(Array.isArray(e)?JSON.stringify(n)===JSON.stringify(e):!v(e)&&n.some(function(t){return en(t,e)}))}function yn(n){try{if(n===window)return!0}catch(e){if(e&&e.message===y)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(e){if(e&&e.message===y)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.self===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.parent===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.top===n)return!0}catch(e){if(e&&e.message===y)return!0}try{if(n&&n.__cross_domain_utils_window_check__==="__unlikely_value__")return!1}catch{return!0}try{if("postMessage"in n&&"self"in n&&"location"in n)return!0}catch{}return!1}function Bn(n){if(X(n))return gn(n).frameElement;for(var e=0,t=document.querySelectorAll("iframe");e<t.length;e++){var r=t[e];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function Tt(n){if(function(t){return t===void 0&&(t=window),!!V(t)}(n)){var e=Bn(n);if(e&&e.parentElement){e.parentElement.removeChild(e);return}}try{n.close()}catch{}}function Q(n){try{if(!n)return!1;if(typeof Promise<"u"&&n instanceof Promise)return!0;if(typeof window<"u"&&typeof window.Window=="function"&&n instanceof window.Window||typeof window<"u"&&typeof window.constructor=="function"&&n instanceof window.constructor)return!1;var e={}.toString;if(e){var t=e.call(n);if(t==="[object Window]"||t==="[object global]"||t==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var Gn=[],rn=[],Pn=0,on;function Jn(){if(!Pn&&on){var n=on;on=null,n.resolve()}}function In(){Pn+=1}function an(){Pn-=1,Jn()}var x=function(){function n(t){var r=this;if(this.resolved=void 0,this.rejected=void 0,this.errorHandled=void 0,this.value=void 0,this.error=void 0,this.handlers=void 0,this.dispatching=void 0,this.stack=void 0,this.resolved=!1,this.rejected=!1,this.errorHandled=!1,this.handlers=[],t){var o,i,a=!1,s=!1,c=!1;In();try{t(function(u){c?r.resolve(u):(a=!0,o=u)},function(u){c?r.reject(u):(s=!0,i=u)})}catch(u){an(),this.reject(u);return}an(),c=!0,a?this.resolve(o):s&&this.reject(i)}}var e=n.prototype;return e.resolve=function(t){if(this.resolved||this.rejected)return this;if(Q(t))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=t,this.dispatch(),this},e.reject=function(t){var r=this;if(this.resolved||this.rejected)return this;if(Q(t))throw new Error("Can not reject promise with another promise");if(!t){var o=t&&typeof t.toString=="function"?t.toString():{}.toString.call(t);t=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=t,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(Gn.indexOf(i)===-1){Gn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<rn.length;s++)rn[s](i,a)}}(t,r)},1),this.dispatch(),this},e.asyncReject=function(t){return this.errorHandled=!0,this.reject(t),this},e.dispatch=function(){var t=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(t||r)){this.dispatching=!0,In();for(var i=function(l,p){return l.then(function(w){p.resolve(w)},function(w){p.reject(w)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,h=s.promise,d=void 0;if(t)try{d=c?c(this.value):this.value}catch(l){h.reject(l);continue}else if(r){if(!u){h.reject(this.error);continue}try{d=u(this.error)}catch(l){h.reject(l);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?h.resolve(f.value):h.reject(f.error),f.errorHandled=!0}else Q(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?h.resolve(d.value):h.reject(d.error):i(d,h):h.resolve(d)}o.length=0,this.dispatching=!1,an()}},e.then=function(t,r){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.then expected a function for success handler");if(r&&typeof r!="function"&&!r.call)throw new Error("Promise.then expected a function for error handler");var o=new n;return this.handlers.push({promise:o,onSuccess:t,onError:r}),this.errorHandled=!0,this.dispatch(),o},e.catch=function(t){return this.then(void 0,t)},e.finally=function(t){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(t).then(function(){return r})},function(r){return n.try(t).then(function(){throw r})})},e.timeout=function(t,r){var o=this;if(this.resolved||this.rejected)return this;var i=setTimeout(function(){o.resolved||o.rejected||o.reject(r||new Error("Promise timed out after "+t+"ms"))},t);return this.then(function(a){return clearTimeout(i),a})},e.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},e.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(t){return t instanceof n?t:Q(t)?new n(function(r,o){return t.then(r,o)}):new n().resolve(t)},n.reject=function(t){return new n().reject(t)},n.asyncReject=function(t){return new n().asyncReject(t)},n.all=function(t){var r=new n,o=t.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,h,d){return h.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},s=0;s<t.length;s++){var c=t[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!Q(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(t){var r={},o=[],i=function(s){if(t.hasOwnProperty(s)){var c=t[s];Q(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in t)i(a);return n.all(o).then(function(){return r})},n.map=function(t,r){return n.all(t.map(r))},n.onPossiblyUnhandledException=function(t){return function(r){return rn.push(r),{cancel:function(){rn.splice(rn.indexOf(r),1)}}}(t)},n.try=function(t,r,o){if(t&&typeof t!="function"&&!t.call)throw new Error("Promise.try expected a function");var i;In();try{i=t.apply(r,o||[])}catch(a){return an(),n.reject(a)}return an(),n.resolve(i)},n.delay=function(t){return new n(function(r){setTimeout(r,t)})},n.isPromise=function(t){return!!(t&&t instanceof n)||Q(t)},n.flush=function(){return function(t){var r=on=on||new t;return Jn(),r}(n)},n}();function En(n,e){for(var t=0;t<n.length;t++)try{if(n[t]===e)return t}catch{}return-1}var On=function(){function n(){if(this.name=void 0,this.weakmap=void 0,this.keys=void 0,this.values=void 0,this.name="__weakmap_"+(1e9*Math.random()>>>0)+"__",function(){if(typeof WeakMap>"u"||Object.freeze===void 0)return!1;try{var t=new WeakMap,r={};return Object.freeze(r),t.set(r,"__testvalue__"),t.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var e=n.prototype;return e._cleanupClosedWindows=function(){for(var t=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(yn(i)&&J(i)){if(t)try{t.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},e.isSafeToReadWrite=function(t){return!yn(t)},e.set=function(t,r){if(!t)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(t,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var i=this.name,a=t[i];a&&a[0]===t?a[1]=r:Object.defineProperty(t,i,{value:[t,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=En(s,t);u===-1?(s.push(t),c.push(r)):c[u]=r},e.get=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return r.get(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return o&&o[0]===t?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=En(this.keys,t);if(i!==-1)return this.values[i]},e.delete=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(t)}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];o&&o[0]===t&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=En(i,t);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},e.has=function(t){if(!t)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(t))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(t))try{var o=t[this.name];return!(!o||o[0]!==t)}catch{}return this._cleanupClosedWindows(),En(this.keys,t)!==-1},e.getOrSet=function(t,r){if(this.has(t))return this.get(t);var o=r();return this.set(t,o),o},n}();function qn(n){return n.name||n.__name__||n.displayName||"anonymous"}function Zn(n,e){try{delete n.name,n.name=e}catch{}return n.__name__=n.displayName=e,n}function Z(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(e){if(typeof btoa=="function")return btoa(encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,function(t,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(e,"utf8").toString("base64").replace(/[=]/g,"");throw new Error("Can not find window.btoa or Buffer")}(new Date().toISOString().slice(11,19).replace("T",".")).replace(/[^a-zA-Z0-9]/g,"").toLowerCase()}var Wn;function Vn(n){try{return JSON.stringify([].slice.call(n),function(e,t){return typeof t=="function"?"memoize["+function(r){if(Wn=Wn||new On,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=Wn.get(r);return o||(o=typeof r+":"+Z(),Wn.set(r,o)),o}(t)+"]":typeof window<"u"&&t instanceof window.Element||t!==null&&typeof t=="object"&&t.nodeType===1&&typeof t.style=="object"&&typeof t.ownerDocument=="object"?{}:t})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ct(){return{}}var un=0,$n=0;function cn(n,e){e===void 0&&(e={});var t=e.thisNamespace,r=t!==void 0&&t,o=e.time,i,a,s=un;un+=1;var c=function(){for(var u=arguments.length,h=new Array(u),d=0;d<u;d++)h[d]=arguments[d];s<$n&&(i=null,a=null,s=un,un+=1);var f;f=r?(a=a||new On).getOrSet(this,Ct):i=i||{};var l;try{l=Vn(h)}catch{return n.apply(this,arguments)}var p=f[l];if(p&&o&&Date.now()-p.time<o&&(delete f[l],p=null),p)return p.value;var w=Date.now(),m=n.apply(this,arguments);return f[l]={time:w,value:m},m};return c.reset=function(){i=null,a=null},Zn(c,(e.name||qn(n))+"::memoized")}cn.clear=function(){$n=un};function Mt(n){var e={};function t(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=Vn(a);return e.hasOwnProperty(c)||(e[c]=x.try(function(){return n.apply(o,r)}).finally(function(){delete e[c]})),e[c]}return t.reset=function(){e={}},Zn(t,qn(n)+"::promiseMemoized")}function _(){}function sn(n,e){if(e===void 0&&(e=1),e>=3)return"stringifyError stack overflow";try{if(!n)return"<unknown error: "+{}.toString.call(n)+">";if(typeof n=="string")return n;if(n instanceof Error){var t=n&&n.stack,r=n&&n.message;if(t&&r)return t.indexOf(r)!==-1?t:r+`
3
+ `+t;if(t)return t;if(r)return r}return n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}catch(o){return"Error while stringifying error: "+sn(o,e+1)}}function Yn(n){return typeof n=="string"?n:n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}cn(function(n){if(Object.values)return Object.values(n);var e=[];for(var t in n)n.hasOwnProperty(t)&&e.push(n[t]);return e});function Dn(n){return{}.toString.call(n)==="[object RegExp]"}function dn(n,e,t){if(n.hasOwnProperty(e))return n[e];var r=t();return n[e]=r,r}function kn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function Kn(){return!!document.body&&document.readyState==="complete"}function Xn(){return!!document.body&&document.readyState==="interactive"}cn(function(){return new x(function(n){if(Kn()||Xn())return n();var e=setInterval(function(){if(Kn()||Xn())return clearInterval(e),n()},10)})});var xn=typeof document<"u"?document.currentScript:null,Lt=cn(function(){if(xn||(xn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),e=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),t=e&&e[1];if(!t)return;for(var r=0,o=[].slice.call(document.getElementsByTagName("script")).reverse();r<o.length;r++){var i=o[r];if(i.src&&i.src===t)return i}}catch{}}()))return xn;throw new Error("Can not determine current script")}),Ft=Z();cn(function(){var n;try{n=Lt()}catch{return Ft}var e=n.getAttribute("data-uid");if(e&&typeof e=="string"||(e=n.getAttribute("data-uid-auto"))&&typeof e=="string")return e;if(n.src){var t=function(r){for(var o="",i=0;i<r.length;i++){var a=r[i].charCodeAt(0)*i;r[i+1]&&(a+=r[i+1].charCodeAt(0)*(i-1)),o+=String.fromCharCode(97+Math.abs(a)%26)}return o}(JSON.stringify({src:n.src,dataset:n.dataset}));e="uid_"+t.slice(t.length-30)}else e=Z();return n.setAttribute("data-uid-auto",e),e});function fn(n){n===void 0&&(n=window);var e="__post_robot_10_0_46__";return n!==window?n[e]:n[e]=n[e]||{}}var Qn=function(){return{}};function z(n,e){return n===void 0&&(n="store"),e===void 0&&(e=Qn),dn(fn(),n,function(){var t=e();return{has:function(r){return t.hasOwnProperty(r)},get:function(r,o){return t.hasOwnProperty(r)?t[r]:o},set:function(r,o){return t[r]=o,o},del:function(r){delete t[r]},getOrSet:function(r,o){return dn(t,r,o)},reset:function(){t=e()},keys:function(){return Object.keys(t)}}})}var Ht=function(){};function Sn(){var n=fn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Ht,n.WINDOW_WILDCARD}function L(n,e){return n===void 0&&(n="store"),e===void 0&&(e=Qn),z("windowStore").getOrSet(n,function(){var t=new On,r=function(o){return t.getOrSet(o,e)};return{has:function(o){return r(o).hasOwnProperty(n)},get:function(o,i){var a=r(o);return a.hasOwnProperty(n)?a[n]:i},set:function(o,i){return r(o)[n]=i,i},del:function(o){delete r(o)[n]},getOrSet:function(o,i){return dn(r(o),n,i)}}})}function _n(){return z("instance").getOrSet("instanceID",Z)}function nt(n,e){var t=e.domain,r=L("helloPromises"),o=r.get(n);o&&o.resolve({domain:t});var i=x.resolve({domain:t});return r.set(n,i),i}function An(n,e){return(0,e.send)(n,"postrobot_hello",{instanceID:_n()},{domain:"*",timeout:-1}).then(function(t){var r=t.origin,o=t.data.instanceID;return nt(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function tt(n,e){var t=e.send;return L("windowInstanceIDPromises").getOrSet(n,function(){return An(n,{send:t}).then(function(r){return r.instanceID})})}function et(n){L("knownWindows").set(n,!0)}function Nn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function rt(n){return n===void 0?"undefined":n===null?"null":Array.isArray(n)?"array":typeof n=="function"?"function":typeof n=="object"?n instanceof Error?"error":typeof n.then=="function"?"promise":{}.toString.call(n)==="[object RegExp]"?"regex":{}.toString.call(n)==="[object Date]"?"date":"object":typeof n=="string"?"string":typeof n=="number"?"number":typeof n=="boolean"?"boolean":void 0}function nn(n,e){return{__type__:n,__val__:e}}var H,Ut=((H={}).function=function(){},H.error=function(n){return nn("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},H.promise=function(){},H.regex=function(n){return nn("regex",n.source)},H.date=function(n){return nn("date",n.toJSON())},H.array=function(n){return n},H.object=function(n){return n},H.string=function(n){return n},H.number=function(n){return n},H.boolean=function(n){return n},H.null=function(n){return n},H[void 0]=function(n){return nn("undefined",n)},H),Bt={},U,Gt=((U={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},U.error=function(n){var e=n.stack,t=n.code,r=n.data,o=new Error(n.message);return o.code=t,r&&(o.data=r),o.stack=e+`
4
4
 
5
- `+o.stack,o},U.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},U.regex=function(n){return new RegExp(n)},U.date=function(n){return new Date(n)},U.array=function(n){return n},U.object=function(n){return n},U.string=function(n){return n},U.number=function(n){return n},U.boolean=function(n){return n},U.null=function(n){return n},U[void 0]=function(){},U),Jt={};new x(function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval(function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)},10)});function Nn(){for(var n=z("idToProxyWindow"),e=0,t=n.keys();e<t.length;e++){var r=t[e];n.get(r).shouldClean()&&n.del(r)}}function it(n,e){var t=e.send,r=e.id,o=r===void 0?Z():r,i=n.then(function(c){if(X(c))return pn(c).name}),a=n.then(function(c){if(J(c))throw new Error("Window is closed, can not determine type");return Fn(c)?"popup":"iframe"});i.catch(_),a.catch(_);var s=function(){return n.then(function(c){if(!J(c))return X(c)?pn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:Mt(function(){return n.then(function(c){return et(c,{send:t})})}),close:function(){return n.then(Tt)},getName:s,focus:function(){return n.then(function(c){c.focus()})},isClosed:function(){return n.then(function(c){return J(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(h){var d=window.location.protocol+"//"+window.location.host,f=u.method,l=f===void 0?"get":f,p=u.body;if(c.indexOf("/")===0)c=""+d+c;else if(!c.match(/^https?:\/\//)&&c.indexOf(d)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(c));if(l==="post")return s().then(function(w){if(!w)throw new Error("Can not post to window without target name");(function(m){var S=m.url,R=m.target,P=m.body,b=m.method,j=b===void 0?"post":b,E=document.createElement("form");if(E.setAttribute("target",R),E.setAttribute("method",j),E.setAttribute("action",S),E.style.display="none",P)for(var I=0,q=Object.keys(P);I<q.length;I++){var A,hn=q[I],Tn=document.createElement("input");Tn.setAttribute("name",hn),Tn.setAttribute("value",(A=P[hn])==null?void 0:A.toString()),E.appendChild(Tn)}Kn().appendChild(E),E.submit(),Kn().removeChild(E)})({url:c,target:w,method:l,body:p})});if(l!=="get")throw new Error("Unsupported method: "+l);if(X(h))try{if(h.location&&typeof h.location.replace=="function"){h.location.replace(c);return}}catch{}h.location=c})},setName:function(c){return n.then(function(u){var h=X(u),d=Gn(u);if(!h)throw new Error("Can not set name for cross-domain window: "+c);pn(u).name=c,d&&d.setAttribute("name",c),i=x.resolve(c)})}}}var B=function(){function n(t){var r=t.send,o=t.win,i=t.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new x,this.serializedWindow=i||it(this.actualWindowPromise,{send:r}),z("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType().then(function(t){return t==="popup"})},e.setLocation=function(t,r){var o=this;return this.serializedWindow.setLocation(t,r).then(function(){return o})},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(t){var r=this;return this.serializedWindow.setName(t).then(function(){return r})},e.close=function(){var t=this;return this.serializedWindow.close().then(function(){return t})},e.focus=function(){var t=this,r=this.isPopup(),o=this.getName(),i=x.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return x.all([i,a]).then(function(){return t})},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(t,r){var o=r.send;this.actualWindow=t,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=it(this.actualWindowPromise,{send:o,id:this.getID()}),M("winToProxyWindow").set(t,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(t,r){var o=this,i=r.send;return x.try(function(){return o.actualWindow?t===o.actualWindow:x.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:et(t,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(t,{send:i}),s})})},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return!!(this.actualWindow&&J(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(t){return n.isProxyWindow(t)?t.unwrap():t},n.serialize=function(t,r){var o=r.send;return Nn(),n.toProxyWindow(t,{send:o}).serialize()},n.deserialize=function(t,r){var o=r.send;return Nn(),z("idToProxyWindow").get(t.id)||new n({serializedWindow:t,send:o})},n.isProxyWindow=function(t){return!!(t&&!gn(t)&&t.isProxyWindow)},n.toProxyWindow=function(t,r){var o=r.send;if(Nn(),n.isProxyWindow(t))return t;var i=t;return M("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function Rn(n,e,t,r,o){var i=M("methodStore"),a=z("proxyWindowMethods");B.isProxyWindow(r)?a.set(n,{val:e,name:t,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:t,val:e,source:r})}function at(n,e){var t=M("methodStore"),r=z("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[e]||r.get(e)}function ut(n,e,t,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,z("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(h){var d=h.source,f=h.origin,l=h.data,p=l.id,w=l.name,m=at(d,p);if(!m)throw new Error("Could not find method '"+w+"' with id: "+l.id+" in "+C(window));var S=m.source,R=m.domain,P=m.val;return x.try(function(){if(!en(R,f))throw new Error("Method '"+l.name+"' domain "+JSON.stringify(On(m.domain)?m.domain.source:m.domain)+" does not match origin "+f+" in "+C(window));if(B.isProxyWindow(S))return S.matchWindow(d,{send:s}).then(function(b){if(!b)throw new Error("Method call '"+l.name+"' failed - proxy window does not match source in "+C(window))})}).then(function(){return P.apply({source:d,origin:f},l.args)},function(b){return x.try(function(){if(P.onError)return P.onError(b)}).then(function(){throw b.stack&&(b.stack="Remote call to "+w+"("+function(j){return j===void 0&&(j=[]),(E=j,[].slice.call(E)).map(function(I){return typeof I=="string"?"'"+I+"'":I===void 0?"undefined":I===null?"null":typeof I=="boolean"?I.toString():Array.isArray(I)?"[ ... ]":typeof I=="object"?"{ ... }":typeof I=="function"?"() => { ... }":"<"+typeof I+">"}).join(", ");var E}(l.args)+`) failed
5
+ `+o.stack,o},U.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},U.regex=function(n){return new RegExp(n)},U.date=function(n){return new Date(n)},U.array=function(n){return n},U.object=function(n){return n},U.string=function(n){return n},U.number=function(n){return n},U.boolean=function(n){return n},U.null=function(n){return n},U[void 0]=function(){},U),Jt={};new x(function(n){if(window.document&&window.document.body)return n(window.document.body);var e=setInterval(function(){if(window.document&&window.document.body)return clearInterval(e),n(window.document.body)},10)});function Rn(){for(var n=z("idToProxyWindow"),e=0,t=n.keys();e<t.length;e++){var r=t[e];n.get(r).shouldClean()&&n.del(r)}}function ot(n,e){var t=e.send,r=e.id,o=r===void 0?Z():r,i=n.then(function(c){if(X(c))return gn(c).name}),a=n.then(function(c){if(J(c))throw new Error("Window is closed, can not determine type");return wn(c)?"popup":"iframe"});i.catch(_),a.catch(_);var s=function(){return n.then(function(c){if(!J(c))return X(c)?gn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:Mt(function(){return n.then(function(c){return tt(c,{send:t})})}),close:function(){return n.then(Tt)},getName:s,focus:function(){return n.then(function(c){c.focus()})},isClosed:function(){return n.then(function(c){return J(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(h){var d=window.location.protocol+"//"+window.location.host,f=u.method,l=f===void 0?"get":f,p=u.body;if(c.indexOf("/")===0)c=""+d+c;else if(!c.match(/^https?:\/\//)&&c.indexOf(d)!==0)throw new Error("Expected url to be http or https url, or absolute path, got "+JSON.stringify(c));if(l==="post")return s().then(function(w){if(!w)throw new Error("Can not post to window without target name");(function(m){var S=m.url,R=m.target,P=m.body,b=m.method,j=b===void 0?"post":b,E=document.createElement("form");if(E.setAttribute("target",R),E.setAttribute("method",j),E.setAttribute("action",S),E.style.display="none",P)for(var I=0,q=Object.keys(P);I<q.length;I++){var A,hn=q[I],Cn=document.createElement("input");Cn.setAttribute("name",hn),Cn.setAttribute("value",(A=P[hn])==null?void 0:A.toString()),E.appendChild(Cn)}kn().appendChild(E),E.submit(),kn().removeChild(E)})({url:c,target:w,method:l,body:p})});if(l!=="get")throw new Error("Unsupported method: "+l);if(X(h))try{if(h.location&&typeof h.location.replace=="function"){h.location.replace(c);return}}catch{}h.location=c})},setName:function(c){return n.then(function(u){var h=X(u),d=Bn(u);if(!h)throw new Error("Can not set name for cross-domain window: "+c);gn(u).name=c,d&&d.setAttribute("name",c),i=x.resolve(c)})}}}var B=function(){function n(t){var r=t.send,o=t.win,i=t.serializedWindow;this.id=void 0,this.isProxyWindow=!0,this.serializedWindow=void 0,this.actualWindow=void 0,this.actualWindowPromise=void 0,this.send=void 0,this.name=void 0,this.actualWindowPromise=new x,this.serializedWindow=i||ot(this.actualWindowPromise,{send:r}),z("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var e=n.prototype;return e.getID=function(){return this.serializedWindow.id},e.getType=function(){return this.serializedWindow.getType()},e.isPopup=function(){return this.getType().then(function(t){return t==="popup"})},e.setLocation=function(t,r){var o=this;return this.serializedWindow.setLocation(t,r).then(function(){return o})},e.getName=function(){return this.serializedWindow.getName()},e.setName=function(t){var r=this;return this.serializedWindow.setName(t).then(function(){return r})},e.close=function(){var t=this;return this.serializedWindow.close().then(function(){return t})},e.focus=function(){var t=this,r=this.isPopup(),o=this.getName(),i=x.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return x.all([i,a]).then(function(){return t})},e.isClosed=function(){return this.serializedWindow.isClosed()},e.getWindow=function(){return this.actualWindow},e.setWindow=function(t,r){var o=r.send;this.actualWindow=t,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=ot(this.actualWindowPromise,{send:o,id:this.getID()}),L("winToProxyWindow").set(t,this)},e.awaitWindow=function(){return this.actualWindowPromise},e.matchWindow=function(t,r){var o=this,i=r.send;return x.try(function(){return o.actualWindow?t===o.actualWindow:x.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:tt(t,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(t,{send:i}),s})})},e.unwrap=function(){return this.actualWindow||this},e.getInstanceID=function(){return this.serializedWindow.getInstanceID()},e.shouldClean=function(){return!!(this.actualWindow&&J(this.actualWindow))},e.serialize=function(){return this.serializedWindow},n.unwrap=function(t){return n.isProxyWindow(t)?t.unwrap():t},n.serialize=function(t,r){var o=r.send;return Rn(),n.toProxyWindow(t,{send:o}).serialize()},n.deserialize=function(t,r){var o=r.send;return Rn(),z("idToProxyWindow").get(t.id)||new n({serializedWindow:t,send:o})},n.isProxyWindow=function(t){return!!(t&&!yn(t)&&t.isProxyWindow)},n.toProxyWindow=function(t,r){var o=r.send;if(Rn(),n.isProxyWindow(t))return t;var i=t;return L("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function zn(n,e,t,r,o){var i=L("methodStore"),a=z("proxyWindowMethods");B.isProxyWindow(r)?a.set(n,{val:e,name:t,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:t,val:e,source:r})}function it(n,e){var t=L("methodStore"),r=z("proxyWindowMethods");return t.getOrSet(n,function(){return{}})[e]||r.get(e)}function at(n,e,t,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,z("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(h){var d=h.source,f=h.origin,l=h.data,p=l.id,w=l.name,m=it(d,p);if(!m)throw new Error("Could not find method '"+w+"' with id: "+l.id+" in "+M(window));var S=m.source,R=m.domain,P=m.val;return x.try(function(){if(!en(R,f))throw new Error("Method '"+l.name+"' domain "+JSON.stringify(Dn(m.domain)?m.domain.source:m.domain)+" does not match origin "+f+" in "+M(window));if(B.isProxyWindow(S))return S.matchWindow(d,{send:s}).then(function(b){if(!b)throw new Error("Method call '"+l.name+"' failed - proxy window does not match source in "+M(window))})}).then(function(){return P.apply({source:d,origin:f},l.args)},function(b){return x.try(function(){if(P.onError)return P.onError(b)}).then(function(){throw b.stack&&(b.stack="Remote call to "+w+"("+function(j){return j===void 0&&(j=[]),(E=j,[].slice.call(E)).map(function(I){return typeof I=="string"?"'"+I+"'":I===void 0?"undefined":I===null?"null":typeof I=="boolean"?I.toString():Array.isArray(I)?"[ ... ]":typeof I=="object"?"{ ... }":typeof I=="function"?"() => { ... }":"<"+typeof I+">"}).join(", ");var E}(l.args)+`) failed
6
6
 
7
- `+b.stack),b})}).then(function(b){return{result:b,id:p,name:w}})})});var i,a,s,c=t.__id__||Z();n=B.unwrap(n);var u=t.__name__||t.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),B.isProxyWindow(n)?(Rn(c,t,u,n,e),n.awaitWindow().then(function(h){Rn(c,t,u,h,e)})):Rn(c,t,u,n,e),nn("cross_domain_function",{id:c,name:u})}function ct(n,e,t,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=Bt);var u=JSON.stringify(s,function(h){var d=this[h];if(An(this))return d;var f=ot(d);if(!f)return d;var l=c[f]||Ut[f];return l?l(d,h):d});return u===void 0?"undefined":u}(t,((o={}).promise=function(s,c){return function(u,h,d,f,l){return nn("cross_domain_zalgo_promise",{then:ut(u,h,function(p,w){return d.then(p,w)},f,{on:l.on,send:l.send})})}(n,e,s,c,{on:i,send:a})},o.function=function(s,c){return ut(n,e,s,c,{on:i,send:a})},o.object=function(s){return gn(s)||B.isProxyWindow(s)?nn("cross_domain_window",B.serialize(s,{send:a})):s},o))}function st(n,e,t,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=Jt),a!=="undefined")return JSON.parse(a,function(c,u){if(An(this))return u;var h,d;if(An(u)?(h=u.__type__,d=u.__val__):(h=ot(u),d=u),!h)return d;var f=s[h]||Gt[h];return f?f(d,c):d})}(t,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new x(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,h){var d=u.id,f=u.name,l=h.send,p=function(m){m===void 0&&(m={});function S(){var R=arguments;return B.toProxyWindow(s,{send:l}).awaitWindow().then(function(P){var b=at(P,d);if(b&&b.val!==S)return b.val.apply({source:window,origin:C()},R);var j=[].slice.call(R);return m.fireAndForget?l(P,"postrobot_method",{id:d,name:f,args:j},{domain:c,fireAndForget:!0}):l(P,"postrobot_method",{id:d,name:f,args:j},{domain:c,fireAndForget:!1}).then(function(E){return E.data.result})}).catch(function(P){throw P})}return S.__name__=f,S.__origin__=c,S.__source__=s,S.__id__=d,S.origin=c,S},w=p();return w.fireAndForget=p({fireAndForget:!0}),w}(n,e,a,{send:i})},o.cross_domain_window=function(a){return B.deserialize(a,{send:i})},o))}var zn={};zn.postrobot_post_message=function(n,e,t){t.indexOf("file:")===0&&(t="*"),n.postMessage(e,t)};function jn(n,e,t,r){var o=r.on,i=r.send;return x.try(function(){var a=M().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(t),a.flush=a.flush||x.flush().then(function(){if(J(n))throw new Error("Window is closed");var s=ct(n,e,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(zn),h=[],d=0;d<u.length;d++){var f=u[d];try{zn[f](n,s,e)}catch(l){h.push(l)}}if(h.length===u.length)throw new Error(`All post-robot messaging strategies failed:
7
+ `+b.stack),b})}).then(function(b){return{result:b,id:p,name:w}})})});var i,a,s,c=t.__id__||Z();n=B.unwrap(n);var u=t.__name__||t.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),B.isProxyWindow(n)?(zn(c,t,u,n,e),n.awaitWindow().then(function(h){zn(c,t,u,h,e)})):zn(c,t,u,n,e),nn("cross_domain_function",{id:c,name:u})}function ut(n,e,t,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=Bt);var u=JSON.stringify(s,function(h){var d=this[h];if(Nn(this))return d;var f=rt(d);if(!f)return d;var l=c[f]||Ut[f];return l?l(d,h):d});return u===void 0?"undefined":u}(t,((o={}).promise=function(s,c){return function(u,h,d,f,l){return nn("cross_domain_zalgo_promise",{then:at(u,h,function(p,w){return d.then(p,w)},f,{on:l.on,send:l.send})})}(n,e,s,c,{on:i,send:a})},o.function=function(s,c){return at(n,e,s,c,{on:i,send:a})},o.object=function(s){return yn(s)||B.isProxyWindow(s)?nn("cross_domain_window",B.serialize(s,{send:a})):s},o))}function ct(n,e,t,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=Jt),a!=="undefined")return JSON.parse(a,function(c,u){if(Nn(this))return u;var h,d;if(Nn(u)?(h=u.__type__,d=u.__val__):(h=rt(u),d=u),!h)return d;var f=s[h]||Gt[h];return f?f(d,c):d})}(t,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new x(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,h){var d=u.id,f=u.name,l=h.send,p=function(m){m===void 0&&(m={});function S(){var R=arguments;return B.toProxyWindow(s,{send:l}).awaitWindow().then(function(P){var b=it(P,d);if(b&&b.val!==S)return b.val.apply({source:window,origin:M()},R);var j=[].slice.call(R);return m.fireAndForget?l(P,"postrobot_method",{id:d,name:f,args:j},{domain:c,fireAndForget:!0}):l(P,"postrobot_method",{id:d,name:f,args:j},{domain:c,fireAndForget:!1}).then(function(E){return E.data.result})}).catch(function(P){throw P})}return S.__name__=f,S.__origin__=c,S.__source__=s,S.__id__=d,S.origin=c,S},w=p();return w.fireAndForget=p({fireAndForget:!0}),w}(n,e,a,{send:i})},o.cross_domain_window=function(a){return B.deserialize(a,{send:i})},o))}var jn={};jn.postrobot_post_message=function(n,e,t){t.indexOf("file:")===0&&(t="*"),n.postMessage(e,t)};function Tn(n,e,t,r){var o=r.on,i=r.send;return x.try(function(){var a=L().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(t),a.flush=a.flush||x.flush().then(function(){if(J(n))throw new Error("Window is closed");var s=ut(n,e,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(jn),h=[],d=0;d<u.length;d++){var f=u[d];try{jn[f](n,s,e)}catch(l){h.push(l)}}if(h.length===u.length)throw new Error(`All post-robot messaging strategies failed:
8
8
 
9
9
  `+h.map(function(l,p){return p+". "+sn(l)}).join(`
10
10
 
11
- `))}),a.flush.then(function(){delete a.flush})}).then(_)}function dt(n){return z("responseListeners").get(n)}function ft(n){z("responseListeners").del(n)}function ht(n){return z("erroredResponseListeners").has(n)}function lt(n){var e=n.name,t=n.win,r=n.domain,o=M("requestListeners");if(t==="*"&&(t=null),r==="*"&&(r=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[t,xn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[e];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var h=0,d=u.__domain_regex__;h<d.length;h++){var f=d[h],l=f.listener;if(en(f.regex,r))return l}}if(u["*"])return u["*"]}}}}}function qt(n,e,t,r){var o=r.on,i=r.send,a=lt({name:t.name,win:n,domain:e}),s=t.name==="postrobot_method"&&t.data&&typeof t.data.name=="string"?t.data.name+"()":t.name;function c(u,h,d){return x.flush().then(function(){if(!t.fireAndForget&&!J(n))try{return jn(n,e,{id:Z(),origin:C(window),type:"postrobot_message_response",hash:t.hash,name:t.name,ack:u,data:h,error:d},{on:o,send:i})}catch(f){throw new Error("Send response message failed for "+s+" in "+C()+`
11
+ `))}),a.flush.then(function(){delete a.flush})}).then(_)}function st(n){return z("responseListeners").get(n)}function dt(n){z("responseListeners").del(n)}function ft(n){return z("erroredResponseListeners").has(n)}function ht(n){var e=n.name,t=n.win,r=n.domain,o=L("requestListeners");if(t==="*"&&(t=null),r==="*"&&(r=null),!e)throw new Error("Name required to get request listener");for(var i=0,a=[t,Sn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[e];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var h=0,d=u.__domain_regex__;h<d.length;h++){var f=d[h],l=f.listener;if(en(f.regex,r))return l}}if(u["*"])return u["*"]}}}}}function qt(n,e,t,r){var o=r.on,i=r.send,a=ht({name:t.name,win:n,domain:e}),s=t.name==="postrobot_method"&&t.data&&typeof t.data.name=="string"?t.data.name+"()":t.name;function c(u,h,d){return x.flush().then(function(){if(!t.fireAndForget&&!J(n))try{return Tn(n,e,{id:Z(),origin:M(window),type:"postrobot_message_response",hash:t.hash,name:t.name,ack:u,data:h,error:d},{on:o,send:i})}catch(f){throw new Error("Send response message failed for "+s+" in "+M()+`
12
12
 
13
- `+sn(f))}})}return x.all([x.flush().then(function(){if(!t.fireAndForget&&!J(n))try{return jn(n,e,{id:Z(),origin:C(window),type:"postrobot_message_ack",hash:t.hash,name:t.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+C()+`
13
+ `+sn(f))}})}return x.all([x.flush().then(function(){if(!t.fireAndForget&&!J(n))try{return Tn(n,e,{id:Z(),origin:M(window),type:"postrobot_message_ack",hash:t.hash,name:t.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+M()+`
14
14
 
15
- `+sn(u))}}),x.try(function(){if(!a)throw new Error("No handler found for post message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:e,data:t.data})}).then(function(u){return c("success",u)},function(u){return c("error",null,u)})]).then(_).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function Zt(n,e,t){if(!ht(t.hash)){var r=dt(t.hash);if(!r)throw new Error("No handler found for post message ack for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!en(r.domain,e))throw new Error("Ack origin "+e+" does not match domain "+r.domain.toString());if(n!==r.win)throw new Error("Ack source does not match registered window")}catch(o){r.promise.reject(o)}r.ack=!0}}function Vt(n,e,t){if(!ht(t.hash)){var r=dt(t.hash);if(!r)throw new Error("No handler found for post message response for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!en(r.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":v(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");ft(t.hash),t.ack==="error"?r.promise.reject(t.error):t.ack==="success"&&r.promise.resolve({source:n,origin:e,data:t.data})}}function vt(n,e){var t=e.on,r=e.send,o=z("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(h,d,f,l){var p=l.on,w=l.send,m;try{m=st(d,f,h,{on:p,send:w})}catch{return}if(m&&typeof m=="object"&&m!==null){var S=m.__post_robot_10_0_46__;if(Array.isArray(S))return S}}(n.data,i,a,{on:t,send:r});if(s){rt(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),J(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?qt(i,a,u,{on:t,send:r}):u.type==="postrobot_message_response"?Vt(i,a,u):u.type==="postrobot_message_ack"&&Zt(i,a,u)}catch(h){setTimeout(function(){throw h},0)}}}}function $(n,e,t){if(!n)throw new Error("Expected name");if(typeof(e=e||{})=="function"&&(t=e,e={}),!t)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,h=M("requestListeners");if(!s||typeof s!="string")throw new Error("Name required to add request listener");if(c&&c!=="*"&&B.isProxyWindow(c)){var d=c.awaitWindow().then(function(A){return o({name:s,win:A,domain:u},a)});return{cancel:function(){d.then(function(A){return A.cancel()},_)}}}var f=c;if(Array.isArray(f)){for(var l=[],p=0,w=f;p<w.length;p++)l.push(o({name:s,domain:u,win:w[p]},a));return{cancel:function(){for(var A=0;A<l.length;A++)l[A].cancel()}}}if(Array.isArray(u)){for(var m=[],S=0,R=u;S<R.length;S++)m.push(o({name:s,win:f,domain:R[S]},a));return{cancel:function(){for(var A=0;A<m.length;A++)m[A].cancel()}}}var P=lt({name:s,win:f,domain:u});f&&f!=="*"||(f=xn());var b=(u=u||"*").toString();if(P)throw f&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(f===xn()?"wildcard":"specified")+" window"):f?new Error("Request listener already exists for "+s+" for "+(f===xn()?"wildcard":"specified")+" window"):u?new Error("Request listener already exists for "+s+" on domain "+u.toString()):new Error("Request listener already exists for "+s);var j=h.getOrSet(f,function(){return{}}),E=dn(j,s,function(){return{}}),I,q;return On(u)?(I=dn(E,"__domain_regex__",function(){return[]})).push(q={regex:u,listener:a}):E[b]=a,{cancel:function(){delete E[b],q&&(I.splice(I.indexOf(q,1)),I.length||delete E.__domain_regex__),Object.keys(E).length||delete j[s],f&&!Object.keys(j).length&&h.del(f)}}}({name:n,win:e.window,domain:e.domain||"*"},{handler:t||e.handler,handleError:e.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function $t(n,e,t){typeof(e=e||{})=="function"&&(t=e,e={});var r=new x,o;return e.errorHandler=function(i){o.cancel(),r.reject(i)},o=$(n,e,function(i){if(o.cancel(),r.resolve(i),t)return t(i)}),r.cancel=o.cancel,r}var Y=function n(e,t,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return B.toProxyWindow(e,{send:n}).awaitWindow().then(function(u){return x.try(function(){if(function(h,d,f){if(!h)throw new Error("Expected name");if(f&&typeof f!="string"&&!Array.isArray(f)&&!On(f))throw new TypeError("Can not send "+h+". Expected domain "+JSON.stringify(f)+" to be a string, array, or regex");if(J(d))throw new Error("Can not send "+h+". Target window is closed")}(t,u,i),function(h,d){var f=Bn(d);if(f)return f===h;if(d===h||function(w){w===void 0&&(w=window);try{if(w.top)return w.top}catch{}if(V(w)===w)return w;try{if(Hn(window,w)&&window.top)return window.top}catch{}try{if(Hn(w,window)&&window.top)return window.top}catch{}for(var m=0,S=function P(b){for(var j=[],E=0,I=Un(b);E<I.length;E++){var q=I[E];j.push(q);for(var A=0,hn=P(q);A<hn.length;A++)j.push(hn[A])}return j}(w);m<S.length;m++){var R=S[m];try{if(R.top)return R.top}catch{}if(V(R)===R)return R}}(d)===d)return!1;for(var l=0,p=Un(h);l<p.length;l++)if(p[l]===d)return!0;return!1}(window,u))return function(h,d,f){d===void 0&&(d=5e3),f===void 0&&(f="Window");var l=function(p){return M("helloPromises").getOrSet(p,function(){return new x})}(h);return d!==-1&&(l=l.timeout(d,new Error(f+" did not load after "+d+"ms"))),l}(u,s)}).then(function(h){return function(d,f,l,p){var w=p.send;return x.try(function(){return typeof f=="string"?f:x.try(function(){return l||Dn(d,{send:w}).then(function(m){return m.domain})}).then(function(m){if(!en(f,f))throw new Error("Domain "+kn(f)+" does not match "+kn(f));return m})})}(u,i,(h===void 0?{}:h).domain,{send:n})}).then(function(h){var d=h,f=t==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":t,l=new x,p=t+"_"+Z();if(!c){var w={name:t,win:u,domain:d,promise:l};(function(E,I){z("responseListeners").set(E,I)})(p,w);var m=M("requestPromises").getOrSet(u,function(){return[]});m.push(l),l.catch(function(){(function(E){z("erroredResponseListeners").set(E,!0)})(p),ft(p)});var S=function(E){return M("knownWindows").get(E,!1)}(u)?1e4:2e3,R=a,P=S,b=R,j=function(E,I){var q;return function A(){q=setTimeout(function(){(function(){if(J(u))return l.reject(new Error("Window closed for "+t+" before "+(w.ack?"response":"ack")));if(w.cancelled)return l.reject(new Error("Response listener was cancelled for "+t));P=Math.max(P-500,0),b!==-1&&(b=Math.max(b-500,0)),w.ack||P!==0?b===0&&l.reject(new Error("No response for postMessage "+f+" in "+C()+" in "+R+"ms")):l.reject(new Error("No ack for postMessage "+f+" in "+C()+" in "+S+"ms"))})(),A()},500)}(),{cancel:function(){clearTimeout(q)}}}();l.finally(function(){j.cancel(),m.splice(m.indexOf(l,1))}).catch(_)}return jn(u,d,{id:Z(),origin:C(window),type:"postrobot_message_request",hash:p,name:t,data:r,fireAndForget:c},{on:$,send:n}).then(function(){return c?l.resolve():l},function(E){throw new Error("Send request message failed for "+f+" in "+C()+`
15
+ `+sn(u))}}),x.try(function(){if(!a)throw new Error("No handler found for post message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:e,data:t.data})}).then(function(u){return c("success",u)},function(u){return c("error",null,u)})]).then(_).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function Zt(n,e,t){if(!ft(t.hash)){var r=st(t.hash);if(!r)throw new Error("No handler found for post message ack for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!en(r.domain,e))throw new Error("Ack origin "+e+" does not match domain "+r.domain.toString());if(n!==r.win)throw new Error("Ack source does not match registered window")}catch(o){r.promise.reject(o)}r.ack=!0}}function Vt(n,e,t){if(!ft(t.hash)){var r=st(t.hash);if(!r)throw new Error("No handler found for post message response for message: "+t.name+" from "+e+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!en(r.domain,e))throw new Error("Response origin "+e+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":v(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");dt(t.hash),t.ack==="error"?r.promise.reject(t.error):t.ack==="success"&&r.promise.resolve({source:n,origin:e,data:t.data})}}function lt(n,e){var t=e.on,r=e.send,o=z("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(h,d,f,l){var p=l.on,w=l.send,m;try{m=ct(d,f,h,{on:p,send:w})}catch{return}if(m&&typeof m=="object"&&m!==null){var S=m.__post_robot_10_0_46__;if(Array.isArray(S))return S}}(n.data,i,a,{on:t,send:r});if(s){et(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),J(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?qt(i,a,u,{on:t,send:r}):u.type==="postrobot_message_response"?Vt(i,a,u):u.type==="postrobot_message_ack"&&Zt(i,a,u)}catch(h){setTimeout(function(){throw h},0)}}}}function $(n,e,t){if(!n)throw new Error("Expected name");if(typeof(e=e||{})=="function"&&(t=e,e={}),!t)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,h=L("requestListeners");if(!s||typeof s!="string")throw new Error("Name required to add request listener");if(c&&c!=="*"&&B.isProxyWindow(c)){var d=c.awaitWindow().then(function(A){return o({name:s,win:A,domain:u},a)});return{cancel:function(){d.then(function(A){return A.cancel()},_)}}}var f=c;if(Array.isArray(f)){for(var l=[],p=0,w=f;p<w.length;p++)l.push(o({name:s,domain:u,win:w[p]},a));return{cancel:function(){for(var A=0;A<l.length;A++)l[A].cancel()}}}if(Array.isArray(u)){for(var m=[],S=0,R=u;S<R.length;S++)m.push(o({name:s,win:f,domain:R[S]},a));return{cancel:function(){for(var A=0;A<m.length;A++)m[A].cancel()}}}var P=ht({name:s,win:f,domain:u});f&&f!=="*"||(f=Sn());var b=(u=u||"*").toString();if(P)throw f&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(f===Sn()?"wildcard":"specified")+" window"):f?new Error("Request listener already exists for "+s+" for "+(f===Sn()?"wildcard":"specified")+" window"):u?new Error("Request listener already exists for "+s+" on domain "+u.toString()):new Error("Request listener already exists for "+s);var j=h.getOrSet(f,function(){return{}}),E=dn(j,s,function(){return{}}),I,q;return Dn(u)?(I=dn(E,"__domain_regex__",function(){return[]})).push(q={regex:u,listener:a}):E[b]=a,{cancel:function(){delete E[b],q&&(I.splice(I.indexOf(q,1)),I.length||delete E.__domain_regex__),Object.keys(E).length||delete j[s],f&&!Object.keys(j).length&&h.del(f)}}}({name:n,win:e.window,domain:e.domain||"*"},{handler:t||e.handler,handleError:e.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function $t(n,e,t){typeof(e=e||{})=="function"&&(t=e,e={});var r=new x,o;return e.errorHandler=function(i){o.cancel(),r.reject(i)},o=$(n,e,function(i){if(o.cancel(),r.resolve(i),t)return t(i)}),r.cancel=o.cancel,r}var Y=function n(e,t,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return B.toProxyWindow(e,{send:n}).awaitWindow().then(function(u){return x.try(function(){if(function(h,d,f){if(!h)throw new Error("Expected name");if(f&&typeof f!="string"&&!Array.isArray(f)&&!Dn(f))throw new TypeError("Can not send "+h+". Expected domain "+JSON.stringify(f)+" to be a string, array, or regex");if(J(d))throw new Error("Can not send "+h+". Target window is closed")}(t,u,i),function(h,d){var f=Un(d);if(f)return f===h;if(d===h||function(w){w===void 0&&(w=window);try{if(w.top)return w.top}catch{}if(V(w)===w)return w;try{if(Fn(window,w)&&window.top)return window.top}catch{}try{if(Fn(w,window)&&window.top)return window.top}catch{}for(var m=0,S=function P(b){for(var j=[],E=0,I=Hn(b);E<I.length;E++){var q=I[E];j.push(q);for(var A=0,hn=P(q);A<hn.length;A++)j.push(hn[A])}return j}(w);m<S.length;m++){var R=S[m];try{if(R.top)return R.top}catch{}if(V(R)===R)return R}}(d)===d)return!1;for(var l=0,p=Hn(h);l<p.length;l++)if(p[l]===d)return!0;return!1}(window,u))return function(h,d,f){d===void 0&&(d=5e3),f===void 0&&(f="Window");var l=function(p){return L("helloPromises").getOrSet(p,function(){return new x})}(h);return d!==-1&&(l=l.timeout(d,new Error(f+" did not load after "+d+"ms"))),l}(u,s)}).then(function(h){return function(d,f,l,p){var w=p.send;return x.try(function(){return typeof f=="string"?f:x.try(function(){return l||An(d,{send:w}).then(function(m){return m.domain})}).then(function(m){if(!en(f,f))throw new Error("Domain "+Yn(f)+" does not match "+Yn(f));return m})})}(u,i,(h===void 0?{}:h).domain,{send:n})}).then(function(h){var d=h,f=t==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":t,l=new x,p=t+"_"+Z();if(!c){var w={name:t,win:u,domain:d,promise:l};(function(E,I){z("responseListeners").set(E,I)})(p,w);var m=L("requestPromises").getOrSet(u,function(){return[]});m.push(l),l.catch(function(){(function(E){z("erroredResponseListeners").set(E,!0)})(p),dt(p)});var S=function(E){return L("knownWindows").get(E,!1)}(u)?1e4:2e3,R=a,P=S,b=R,j=function(E,I){var q;return function A(){q=setTimeout(function(){(function(){if(J(u))return l.reject(new Error("Window closed for "+t+" before "+(w.ack?"response":"ack")));if(w.cancelled)return l.reject(new Error("Response listener was cancelled for "+t));P=Math.max(P-500,0),b!==-1&&(b=Math.max(b-500,0)),w.ack||P!==0?b===0&&l.reject(new Error("No response for postMessage "+f+" in "+M()+" in "+R+"ms")):l.reject(new Error("No ack for postMessage "+f+" in "+M()+" in "+S+"ms"))})(),A()},500)}(),{cancel:function(){clearTimeout(q)}}}();l.finally(function(){j.cancel(),m.splice(m.indexOf(l,1))}).catch(_)}return Tn(u,d,{id:Z(),origin:M(window),type:"postrobot_message_request",hash:p,name:t,data:r,fireAndForget:c},{on:$,send:n}).then(function(){return c?l.resolve():l},function(E){throw new Error("Send request message failed for "+f+" in "+M()+`
16
16
 
17
- `+sn(E))})})})};function Yt(n,e,t){return ct(n,e,t,{on:$,send:Y})}function kt(n,e,t){return st(n,e,t,{on:$,send:Y})}function Kt(n){return new B({send:Y,win:n})}function Xt(n){return B.toProxyWindow(n,{send:Y})}function wt(){fn().initialized||(fn().initialized=!0,e=(n={on:$,send:Y}).on,t=n.send,(r=fn()).receiveMessage=r.receiveMessage||function(o){return vt(o,{on:e,send:t})},function(o){var i=o.on,a=o.send;z().getOrSet("postMessageListener",function(){return function(s,c,u){return s.addEventListener("message",u),{cancel:function(){s.removeEventListener("message",u)}}}(window,0,function(s){(function(c,u){var h=u.on,d=u.send;x.try(function(){var f=c.source||c.sourceElement,l=c.origin||c.originalEvent&&c.originalEvent.origin,p=c.data;if(l==="null"&&(l="file://"),f){if(!l)throw new Error("Post message did not have origin domain");vt({source:f,origin:l,data:p},{on:h,send:d})}})})(s,{on:i,send:a})})})}({on:$,send:Y}),function(o){var i=o.on,a=o.send;z("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return tt(u.source,{domain:u.origin}),{instanceID:nt()}}),c=Bn();return c&&Dn(c,{send:a}).catch(function(u){}),s})}({on:$,send:Y}));var n,e,t,r}function Qt(){(function(){for(var e=z("responseListeners"),t=0,r=e.keys();t<r.length;t++){var o=r[t],i=e.get(o);i&&(i.cancelled=!0),e.del(o)}})(),(n=z().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var _t=!0;function ne(n){for(var e=0,t=M("requestPromises").get(n,[]);e<t.length;e++)t[e].reject(new Error("Window "+(J(n)?"closed":"cleaned up")+" before response")).catch(_)}wt()}])})})(Ln);var Pt=Ln.exports;(function(D){D.exports=Pt,D.exports.default=D.exports})(Mn);var It=Mn.exports;const Ot=bt(It),Dt="WIDGET_EVENT";function At(D){const{onEvent:T}=D;Ot.on(Dt,G=>{T(G.data),L.includes(G.data.eventName)?xt():G.data.eventName===yt&&Cn()})}function Nt(D){At(D)}class Rt{constructor(T){mt(this,vn);ln(this,"flow");ln(this,"configProps");ln(this,"onEvent");ln(this,"isSandbox");this.flow=T.flow,this.configProps=T.configProps,this.onEvent=T.onEvent,this.isSandbox=T.isSandbox??!1,this.validateProps(),Wt(this.flow,this.configProps,this.isSandbox,T.developmentUrl),Nt({onEvent:pt(this,vn,gt).bind(this)})}validateProps(){if(this.flow==="authenticate"){if(!this.configProps.identityId)throw new Error("identityId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}else if(this.flow==="register"){if(!this.configProps.flowTemplateId)throw new Error("flowTemplateId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}}}return vn=new WeakSet,gt=function(T){this.onEvent(T)},Rt});
17
+ `+sn(E))})})})};function Yt(n,e,t){return ut(n,e,t,{on:$,send:Y})}function kt(n,e,t){return ct(n,e,t,{on:$,send:Y})}function Kt(n){return new B({send:Y,win:n})}function Xt(n){return B.toProxyWindow(n,{send:Y})}function vt(){fn().initialized||(fn().initialized=!0,e=(n={on:$,send:Y}).on,t=n.send,(r=fn()).receiveMessage=r.receiveMessage||function(o){return lt(o,{on:e,send:t})},function(o){var i=o.on,a=o.send;z().getOrSet("postMessageListener",function(){return function(s,c,u){return s.addEventListener("message",u),{cancel:function(){s.removeEventListener("message",u)}}}(window,0,function(s){(function(c,u){var h=u.on,d=u.send;x.try(function(){var f=c.source||c.sourceElement,l=c.origin||c.originalEvent&&c.originalEvent.origin,p=c.data;if(l==="null"&&(l="file://"),f){if(!l)throw new Error("Post message did not have origin domain");lt({source:f,origin:l,data:p},{on:h,send:d})}})})(s,{on:i,send:a})})})}({on:$,send:Y}),function(o){var i=o.on,a=o.send;z("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return nt(u.source,{domain:u.origin}),{instanceID:_n()}}),c=Un();return c&&An(c,{send:a}).catch(function(u){}),s})}({on:$,send:Y}));var n,e,t,r}function Qt(){(function(){for(var e=z("responseListeners"),t=0,r=e.keys();t<r.length;t++){var o=r[t],i=e.get(o);i&&(i.cancelled=!0),e.del(o)}})(),(n=z().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var _t=!0;function ne(n){for(var e=0,t=L("requestPromises").get(n,[]);e<t.length;e++)t[e].reject(new Error("Window "+(J(n)?"closed":"cleaned up")+" before response")).catch(_)}vt()}])})})(Mn);var gt=Mn.exports;(function(D){D.exports=gt,D.exports.default=D.exports})(T);var yt=T.exports;const Et=O(yt),Wt="WIDGET_EVENT",xt="https://app.soyio.id/widget",St="https://sandbox.soyio.id/widget",bt=["IDENTITY_AUTHENTICATED","IDENTITY_REGISTERED"],Pt="WIDGET_CLOSED";function It(D,C,G,W){const g=W||(G?St:xt),v=Object.entries(C).filter(([,y])=>y).map(([y,F])=>`${y}=${encodeURIComponent(F)}`).join("&");return`${g}/${D}?platform=web&${v}`}let k=null;function bn(){if(k&&!k.closed)k.focus();else throw new Error("Popup window does not exist or is closed.")}function Ot(D,C,G,W){const g=It(D,C,G,W),v=510,y=720,F=window.innerWidth?window.innerWidth:document.documentElement.clientWidth?document.documentElement.clientWidth:window.screen.width,K=window.innerHeight?window.innerHeight:document.documentElement.clientHeight?document.documentElement.clientHeight:window.screen.height,tn=F/2-v/2,V=K/2-y/2;document.body.style.filter="blur(5px)",document.body.addEventListener("click",wn=>{bn(),wn.preventDefault()}),k=window.open(g,"Soyio",`scrollbars=yes, width=${v}, height=${y}, top=${V}, left=${tn}`),bn()}function Ln(){document.body.style.filter="",document.body.removeEventListener("click",bn)}function Dt(){k&&(k.close(),k=null),Ln()}function At(D){const{onEvent:C}=D;Et.on(Wt,G=>{C(G.data),bt.includes(G.data.eventName)?Dt():G.data.eventName===Pt&&Ln()})}function Nt(D){At(D)}class Rt{constructor(C){wt(this,vn);ln(this,"flow");ln(this,"configProps");ln(this,"onEvent");ln(this,"isSandbox");this.flow=C.flow,this.configProps=C.configProps,this.onEvent=C.onEvent,this.isSandbox=C.isSandbox??!1,this.validateProps(),Ot(this.flow,this.configProps,this.isSandbox,C.developmentUrl),Nt({onEvent:mt(this,vn,pt).bind(this)})}validateProps(){if(this.flow==="authenticate"){if(!this.configProps.identityId)throw new Error("identityId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}else if(this.flow==="register"){if(!this.configProps.flowTemplateId)throw new Error("flowTemplateId is required");if(!this.configProps.companyId)throw new Error("companyId is required")}}}return vn=new WeakSet,pt=function(C){this.onEvent(C)},Rt});
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",
@@ -16,26 +16,30 @@
16
16
  "README.md"
17
17
  ],
18
18
  "scripts": {
19
+ "bump!": "sh scripts/bump.sh",
19
20
  "dev": "vite",
20
21
  "build": "tsc && vite build",
21
22
  "preview": "vite preview",
22
23
  "lint": "eslint . --ext .ts",
23
- "test": "vitest"
24
+ "test": "vitest",
25
+ "version:get": "node -p \"require('./package.json').version\""
24
26
  },
25
27
  "devDependencies": {
26
28
  "@types/node": "^20.10.1",
27
29
  "@typescript-eslint/eslint-plugin": "^6.13.2",
28
30
  "@typescript-eslint/parser": "^6.13.2",
29
- "eslint": "^8.54.0",
30
- "eslint-plugin-import": "^2.29.0",
31
- "eslint-plugin-platanus": "^0.1.0",
32
- "happy-dom": "^12.10.3",
31
+ "eslint": "^8.57.0",
32
+ "eslint-config-airbnb-base": "^15.0.0",
33
+ "eslint-plugin-eslint-comments": "^3.2.0",
34
+ "eslint-plugin-import": "^2.29.1",
35
+ "eslint-plugin-tsdoc": "^0.2.17",
36
+ "typedoc": "^0.25.12",
33
37
  "typescript": "^5.2.2",
34
- "vite": "^5.0.0",
35
- "vite-plugin-dts": "^3.6.4",
36
38
  "vitest": "^0.34.6"
37
39
  },
38
40
  "dependencies": {
41
+ "vite": "^5.0.0",
42
+ "vite-plugin-dts": "^3.6.4",
39
43
  "post-robot": "^10.0.46"
40
44
  }
41
45
  }