@soyio/soyio-widget 2.1.0 → 2.3.0

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/README.md CHANGED
@@ -28,11 +28,11 @@ yarn add @soyio/soyio-widget
28
28
 
29
29
  Integrate the widget into your frontend framework using the script below. Ensure to replace placeholders (e.g., \<request>, \<company id>) with actual values relevant to your implementation.
30
30
 
31
- ## Browser compatibility notes
31
+ ## Browser Compatibility Notes
32
32
 
33
33
  **Important Safari Limitation**: In Safari browsers, the widget can only be opened as a result of a direct user interaction (like a click event). This is due to Safari's security policies regarding popup windows. Always ensure the widget initialization is triggered by a user action when supporting Safari browsers.
34
34
 
35
- ### 1. Disclosure Request
35
+ ## Disclosure Request
36
36
 
37
37
  A **`disclosure_request`** is a process that a user goes through where they are verified, and then they share the necessary data as required by each company.
38
38
  This verification can happen in one of the following two ways:
@@ -41,9 +41,9 @@ This verification can happen in one of the following two ways:
41
41
 
42
42
  2. **Authentication**: Through an access key (passkey) or facial video. This can occur when a user has already been validated previously with Soyio.
43
43
 
44
- To instantiate this process in the code, you have two options
44
+ To instantiate this process in the code, you have two options:
45
45
 
46
- #### 1.a Disclosure requests on-the-fly
46
+ ### 1. Disclosure Requests On-the-fly
47
47
 
48
48
  This doesn't require any previous setup. Given your company and disclosure template IDs, you can create disclosure requests freely when the user starts the widget.
49
49
 
@@ -86,7 +86,7 @@ Optional props:
86
86
  - `forceError`
87
87
  - `customColor`.
88
88
 
89
- #### 1.b Created disclosure request
89
+ ### 2. Created Disclosure Request
90
90
 
91
91
  You can alternatively create a disclosure request beforehand with some **matchers** to make sure the person completing the request matches the one that your application thinks it is.
92
92
 
@@ -131,7 +131,50 @@ Optional properties:
131
131
 
132
132
  Note: User and template properties are not specified here because they must be specified when creating the disclosure request beforehand.
133
133
 
134
- ### 2. Signature attempt
134
+ ### Disclosure Request Events
135
+
136
+ The `onEvent` callback is designed to handle various events that occur during widget interaction. Specifically, it receives detailed information upon the successful completion of user request. Here are the events it handles:
137
+
138
+ - **`DISCLOSURE_REQUEST_SUCCESSFUL`**: This event occurs when a user successfully completes a `disclosure_request`. The identity verification could have been a `validation` or `authentication`.
139
+
140
+ - `eventName`: The name of the event, in this case, `'DISCLOSURE_REQUEST_SUCCESSFUL'`.
141
+ - `verificationMethod`: Takes the values of `authentication` or `validation`.
142
+ - `identityId`: The unique identifier for the verified identity.
143
+ - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
144
+
145
+ - **`DENIED_CAMERA_PERMISSION`**: Event triggered when user denies camera permissions. It closes the widget.
146
+ - **`UNEXPECTED_ERROR`**: Event triggered when user exits because of an unexpected error.
147
+
148
+ - **`WIDGET_CLOSED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
149
+
150
+ - `{ eventName: 'WIDGET_CLOSED' }`.
151
+
152
+ - **`WIDGET_OPENED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
153
+ - `{ eventName: 'WIDGET_CLOSED' }`.
154
+
155
+ ### Disclosure Request Attribute Descriptions
156
+
157
+ - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
158
+ - **`userReference`**: A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
159
+ - **`userEmail`**: The user's email address. If not provided, Soyio will prompt the user to enter their email.
160
+ - **`templateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user, as well as the mandatory data that the user is asked to share with the company. It must start with `'dtpl_'`.
161
+ - **`disclosureRequestId`**: If created beforehand, you can target a specific disclosure request that the user must complete. It is useful if you need to match some data between the disclosure process and your database records. It must start with `'dreq_'`
162
+ - **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
163
+ - **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
164
+ - **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
165
+ - **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
166
+ - **`customColor`**: A hex code string that specifies the base color of the interface.
167
+
168
+ ### Force Error Types
169
+
170
+ The `forceError` parameter can simulate the following error conditions:
171
+
172
+ - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
173
+ - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
174
+ - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
175
+ - `'expiration_error'`: Occurs when there is an issue with the identity provider that prevents the validation of one or both documents provided by the user, due to unspecified problems in the validation process.
176
+
177
+ ## Signature Attempt
135
178
 
136
179
  The **`signature_attempt`** is a process where, using a previously created `signature_attempt_id`, a request is initiated in which a user can digitally sign a document. To sign the document, the user must be authenticated. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
137
180
 
@@ -170,62 +213,123 @@ Optional props:
170
213
  - `forceError`
171
214
  - `customColor`.
172
215
 
173
- ### Attribute Descriptions
216
+ ### Signature Attempt Events
217
+
218
+ - **`IDENTITY_SIGNATURE`**: This event occurs when a user successfully completes a signature attempt. The event object includes:
219
+
220
+ - `eventName`: The name of the event, in this case, `'IDENTITY_SIGNATURE'`.
221
+ - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
222
+
223
+ - **`REJECTED_SIGNATURE`**: Event triggered when user clicks the "reject" button in the signature attempt. The event object includes:
224
+
225
+ - `identityId`: The unique identifier for the identity.
226
+ - `userReference`: The userReference used in the validation attempt for the identity.
227
+
228
+ ### Signature Attempt Attribute Descriptions
174
229
 
175
- - **`companyId`**: The unique identifier for the company, must start with `'com_'`.
176
- - **`userReference`**: A reference identifier provided by the company for the user engaging with the widget. This identifier is used in events (`onEvent` and `webhooks`) to inform the company which user the events are associated with.
177
- - **`userEmail`**: The user's email address. If not provided, Soyio will prompt the user to enter their email.
178
- - **`templateId`**: Identifier of template. Specifies the order and quantity of documents requested from the user, as well as the mandatory data that the user is asked to share with the company. It must start with `'dtpl_'`.
179
- - **`disclosureRequestId`**: If created beforehand, you can target a specific disclosure request that the user must complete. It is useful if you need to match some data between the disclosure process and your database records. It must start with `'dreq_'`
180
230
  - **`signatureAttemptId`**: Identifier of signature attempt obtained when creating the `SignatureAttempt`. It must start with `'sa_'`.
181
- - **`identityId`**: This identifier must start with `'id_'` and signifies the user's identity.
182
231
  - **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
183
232
  - **`forceError`**: Triggers specific errors for testing or debugging. Used to simulate failure scenarios. Only works in `sandbox` mode.
184
233
  - **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
185
234
  - **`customColor`**: A hex code string that specifies the base color of the interface.
186
235
 
187
- ### Events
236
+ ### Force Error Types
188
237
 
189
- The `onEvent` callback is designed to handle various events that occur during widget interaction. Specifically, it receives detailed information upon the successful completion of user request. Here are the events it handles:
238
+ The `forceError` parameter can simulate the following error conditions:
190
239
 
191
- - **`DISCLOSURE_REQUEST_SUCCESSFUL`**: This event occurs when a user successfully completes a `disclosure_request`. The identity verification could have been a `validation` or `authentication`.
240
+ - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
241
+ - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
242
+ - `'expiration_error'`: Occurs when there is an issue with the identity provider that prevents the validation of one or both documents provided by the user, due to unspecified problems in the validation process.
192
243
 
193
- - `eventName`: The name of the event, in this case, `'DISCLOSURE_REQUEST_SUCCESSFUL'`.
194
- - `verificationMethod`: Takes the values of `authentication` or `validation`.
195
- - `identityId`: The unique identifier for the verified identity.
196
- - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
244
+ ## Auth Request
197
245
 
198
- - **`IDENTITY_SIGNATURE`**: This event occurs when a user successfully completes a signature attempt. The event object includes:
246
+ The **`auth_request`** is a process where, using a previously created `auth_request_id`, a request is initiated in which a user can authenticate. This authentication can occur either through an access key or facial video. It's important to note that for this request, the user must have been previously verified with Soyio.
199
247
 
200
- - `eventName`: The name of the event, in this case, `'IDENTITY_SIGNATURE'`.
201
- - `userReference`: The reference identifier for the user, facilitating the association of the event with the user within the company's context.
248
+ ```html
249
+ <button id="start-auth-request">Start auth request</button>
202
250
 
203
- - **`DENIED_CAMERA_PERMISSION`**: Event triggered when user denies camera permissions. It closes the widget.
204
- - **`UNEXPECTED_ERROR`**: Event triggered when user exits because of an unexpected error.
251
+ <script>
252
+ import { SoyioWidget } from "@soyio/soyio-widget";
205
253
 
206
- - **`REJECTED_SIGNATURE`**: Event triggered when user clicks the "reject" button in the signature attempt. The event object includes:
254
+ // Widget configuration
255
+ const widgetConfig = {
256
+ request: "authentication",
257
+ configProps: {
258
+ authRequestId: "<auth request id>",
259
+ customColor: "<custom color>",
260
+ },
261
+ onEvent: (data) => console.log(data),
262
+ isSandbox: true,
263
+ };
207
264
 
208
- - `identityId`: The unique identifier for the identity.
209
- - `userReference`: The userReference used in the validation attempt for the identity.
265
+ // Function to create the widget
266
+ function initWidget() {
267
+ new SoyioWidget(widgetConfig);
268
+ }
210
269
 
211
- - **`WIDGET_CLOSED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
270
+ // Add event listener to the button to create the widget on click
271
+ document
272
+ .getElementById("start-auth-request")
273
+ .addEventListener("click", initWidget);
274
+ </script>
275
+ ```
212
276
 
213
- - `{ eventName: 'WIDGET_CLOSED' }`.
277
+ Optional props:
214
278
 
215
- - **`WIDGET_OPENED`**: This event occurs when the user closes the `Soyio` pop up. The event object is as follows:
216
- - `{ eventName: 'WIDGET_CLOSED' }`.
279
+ - `customColor`.
217
280
 
218
- #### Force error types
281
+ ### Auth Request Attribute Descriptions
219
282
 
220
- The `forceError` parameter can simulate the following error conditions:
283
+ - **`authRequestId`**: Identifier of auth request obtained when creating the `AuthRequest`. It must start with `'authreq_'`.
284
+ - **`isSandbox`**: Indicates if the widget should operate in sandbox mode, defaulting to `false`.
285
+ - **`onEvent`**: A callback function triggered upon event occurrences, used for capturing and logging event-related data.
286
+ - **`customColor`**: A hex code string that specifies the base color of the interface.
221
287
 
222
- - `'facial_validation_error'`: Simulates a failure in the facial video liveness test, indicating the system could not verify the user's live presence.
223
- - `'document_validation_error'`: Indicates an issue with validating the photos of the documents provided by the user.
224
- - `'unknown_error'`: Generates a generic error, representing an unspecified problem.
225
- - `'expiration_error'`: Occurs when there is an issue with the identity provider that prevents the validation of one or both documents provided by the user, due to unspecified problems in the validation process.
226
- - `'camera_permission_error'`: Happens when the user does not grant the necessary permissions to access the camera, preventing the completion of the disclosure or signature request.
288
+ ## Consent Request Box
289
+
290
+ The **`ConsentRequestBox`** is a component that allows you to embed a consent request directly within your webpage, rather than opening it in a popup window. This is particularly useful when you want to integrate the consent flow seamlessly into your application's interface.
291
+
292
+ ```html
293
+ <!-- Add a container div where the consent request will be mounted -->
294
+ <div id="consent-request-box"></div>
295
+
296
+ <script>
297
+ import { ConsentRequestBox } from "@soyio/soyio-widget";
298
+
299
+ // Configuration for the consent request
300
+ const consentRequestOptions = {
301
+ consentRequestId: "<consent request id>",
302
+ onEvent: (data) => console.log(data),
303
+ isSandbox: true, // Optional, defaults to false
304
+ };
305
+
306
+ // Wait for DOM to be fully loaded
307
+ document.addEventListener("DOMContentLoaded", () => {
308
+ // Create and mount the consent request box
309
+ new ConsentRequestBox(consentRequestOptions).mount("#consent-request-box");
310
+ });
311
+ </script>
312
+ ```
313
+
314
+ ### Consent Request Box Events
315
+
316
+ The `onEvent` follows the following format:
317
+
318
+ ```typescript
319
+ {
320
+ eventName: 'CONSENT_CHECKBOX_CHANGE',
321
+ entityId: `ent_${string}`,
322
+ isSelected: boolean
323
+ }
324
+ ```
325
+
326
+ ### Attribute Descriptions
327
+
328
+ - **`consentRequestId`**: Identifier of consent request obtained when creating the `ConsentRequest`. It must start with `'consentreq_'`.
329
+ - **`entityId`**: Identifier of entity obtained when creating the `ConsentRequest`. It must start with `'ent_'`.
330
+ - **`isSelected`**: Boolean value indicating whether the consent checkbox is selected or not.
227
331
 
228
- #### Typescript
332
+ ## TypeScript
229
333
 
230
334
  The `SoyioTypes` module from the `@soyio/soyio-widget` package provides TypeScript type definitions that you can use to integrate the SoyioWidget more seamlessly into your TypeScript projects.
231
335
 
package/dist/index.d.ts CHANGED
@@ -1,80 +1,42 @@
1
- declare type AttemptConfig = DisclosureRequestConfig | SignatureAttemptConfig;
2
-
3
- declare type DisclosureRequestConfig = {
4
- request: 'disclosure';
5
- configProps: DisclosureRequestProps;
6
- onEvent: (data: EventData) => void;
7
- isSandbox?: boolean;
8
- developmentUrl?: string;
9
- };
10
-
11
- declare type DisclosureRequestProps = NewDisclosureRequestProps | ExistingDisclosureRequestProps;
12
-
13
- declare type EventData = {
14
- eventName: 'IDENTITY_VALIDATED' | 'IDENTITY_AUTHENTICATED' | 'IDENTITY_SIGNATURE' | 'DENIED_CAMERA_PERMISSION' | 'REJECTED_SIGNATURE' | 'DISCLOSURE_REQUEST_SUCCESSFUL' | 'UNEXPECTED_ERROR';
15
- identityId: string;
16
- userReference?: string;
17
- };
18
-
19
- declare type ExistingDisclosureRequestProps = {
20
- companyId?: never;
21
- templateId?: never;
22
- disclosureRequestId: string;
23
- userReference?: never;
24
- userEmail?: never;
25
- forceError?: ForceErrors;
26
- customColor?: string;
27
- };
28
-
29
- declare type ForceErrors = 'facial_validation_error' | 'document_validation_error' | 'unknown_error' | 'expiration_error' | 'camera_permission_error';
30
-
31
- declare type NewDisclosureRequestProps = {
32
- companyId: string;
33
- templateId: string;
34
- disclosureRequestId?: never;
35
- userReference: string;
36
- userEmail?: string;
37
- forceError?: ForceErrors;
38
- customColor?: string;
39
- };
40
-
41
- declare type Request_2 = 'disclosure' | 'signature';
42
-
43
- declare type SignatureAttemptConfig = {
44
- request: 'signature';
45
- configProps: SignatureAttemptProps;
46
- onEvent: (data: EventData) => void;
47
- isSandbox?: boolean;
48
- developmentUrl?: string;
49
- };
50
-
51
- declare type SignatureAttemptProps = {
52
- signatureAttemptId: string;
53
- forceError?: ForceErrors;
54
- customColor?: string;
55
- };
1
+ import { AuthRequestConfig } from './widget/types';
2
+ import { AuthRequestProps } from './widget/types';
3
+ import { ConsentRequestBox } from './embeds';
4
+ import { ConsentRequestConfig } from './embeds/types';
5
+ import { ConsentRequestEvent } from './embeds/types';
6
+ import { DisclosureRequestConfig } from './widget/types';
7
+ import { DisclosureRequestProps } from './widget/types';
8
+ import { EventData } from './widget/types';
9
+ import { ExistingDisclosureRequestProps } from './widget/types';
10
+ import { ForceErrors } from './widget/types';
11
+ import { NewDisclosureRequestProps } from './widget/types';
12
+ import { Request as Request_2 } from './widget/types';
13
+ import { RequestConfig } from './widget/types';
14
+ import { SignatureAttemptProps } from './widget/types';
15
+ import { SignatureRequestConfig } from './widget/types';
16
+ import { SoyioWidget } from './widget';
17
+
18
+ export { ConsentRequestBox }
56
19
 
57
20
  declare namespace SoyioTypes {
58
21
  export {
22
+ ConsentRequestEvent,
23
+ ConsentRequestConfig,
59
24
  ForceErrors,
60
25
  Request_2 as Request,
61
26
  NewDisclosureRequestProps,
62
27
  ExistingDisclosureRequestProps,
63
28
  DisclosureRequestProps,
64
29
  SignatureAttemptProps,
30
+ AuthRequestProps,
65
31
  EventData,
66
32
  DisclosureRequestConfig,
67
- SignatureAttemptConfig,
68
- AttemptConfig
33
+ SignatureRequestConfig,
34
+ AuthRequestConfig,
35
+ RequestConfig
69
36
  }
70
37
  }
71
38
  export { SoyioTypes }
72
39
 
73
- declare class SoyioWidget {
74
- #private;
75
- private onEvent;
76
- constructor(options: SoyioTypes.AttemptConfig);
77
- }
78
40
  export { SoyioWidget }
79
41
  export default SoyioWidget;
80
42
 
package/dist/index.js CHANGED
@@ -1,81 +1,139 @@
1
- var I = Object.defineProperty;
2
- var S = (e, t, n) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var f = (e, t, n) => (S(e, typeof t != "symbol" ? t + "" : t, n), n), _ = (e, t, n) => {
4
- if (!t.has(e))
5
- throw TypeError("Cannot " + n);
1
+ var b = Object.defineProperty;
2
+ var U = (n, e, t) => e in n ? b(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var d = (n, e, t) => (U(n, typeof e != "symbol" ? e + "" : e, t), t), N = (n, e, t) => {
4
+ if (!e.has(n))
5
+ throw TypeError("Cannot " + t);
6
6
  };
7
- var p = (e, t, n) => {
8
- if (t.has(e))
7
+ var h = (n, e, t) => {
8
+ if (e.has(n))
9
9
  throw TypeError("Cannot add the same private member more than once");
10
- t instanceof WeakSet ? t.add(e) : t.set(e, n);
10
+ e instanceof WeakSet ? e.add(n) : e.set(n, t);
11
11
  };
12
- var w = (e, t, n) => (_(e, t, "access private method"), n);
13
- const R = "WIDGET_EVENT", T = "https://app.soyio.id/widget", g = "https://sandbox.soyio.id/widget", y = [
12
+ var p = (n, e, t) => (N(n, e, "access private method"), t);
13
+ const I = "soyio-consent-request-iframe", v = "https://app.soyio.id", _ = "https://sandbox.soyio.id", g = [
14
14
  "DISCLOSURE_REQUEST_SUCCESSFUL",
15
15
  "IDENTITY_REGISTERED",
16
16
  "IDENTITY_SIGNATURE",
17
17
  "UNEXPECTED_ERROR",
18
18
  "DENIED_CAMERA_PERMISSION",
19
19
  "REJECTED_SIGNATURE"
20
- ], b = "WIDGET_CLOSED";
21
- function v(e) {
22
- return "disclosureRequestId" in e.configProps ? ["disclosures", e.configProps.disclosureRequestId].join("/") : e.request;
20
+ ], C = "WIDGET_CLOSED";
21
+ function D() {
22
+ const n = document.getElementById(I);
23
+ n && (console.warn("ConsentRequestBox iframe already exists. Removing existing before mounting new one."), n.remove());
23
24
  }
24
- function N(e) {
25
- const t = e.isSandbox ?? !1, n = e.developmentUrl || (t ? g : T), o = Object.entries(e.configProps).filter(([c, s]) => s || c === "disclosureRequestId").map(([c, s]) => `${c}=${encodeURIComponent(s)}`).join("&"), r = v(e);
26
- return `${n}/${r}?sdk=web&${o}`;
25
+ function L(n) {
26
+ const e = document.querySelector(n);
27
+ if (!e)
28
+ throw new Error(`Iframe div container with id '${n}' not found`);
29
+ if (e.tagName.toLowerCase() !== "div")
30
+ throw new Error(`Iframe container with id '${n}' must be a <div> element`);
31
+ return e;
27
32
  }
28
- const U = !!(typeof window < "u" && window.document && window.document.createElement), D = 500;
29
- let i = null, u = null;
30
- function E(e = null) {
31
- i && !i.closed && i.focus(), e == null || e.preventDefault();
33
+ function O(n) {
34
+ const e = document.createElement("iframe");
35
+ return e.id = I, e.style.zIndex = String(Number.MAX_SAFE_INTEGER), e.style.width = "100%", e.style.height = "100%", e.style.border = "none", e.src = n, e;
32
36
  }
33
- function a() {
34
- document.body.style.filter = "", document.body.removeEventListener("click", E);
35
- }
36
- function P() {
37
- u = setInterval(() => {
38
- (!i || i.closed) && (u && clearInterval(u), a());
39
- }, D);
40
- }
41
- function C(e) {
42
- const t = N(e), n = 510, o = 720, r = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : window.screen.width, c = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : window.screen.height, s = r / 2 - n / 2, m = c / 2 - o / 2;
43
- document.body.style.filter = "blur(5px)", document.body.addEventListener("click", E), i = window.open(t, "Soyio", `scrollbars=yes, width=${n}, height=${o}, top=${m}, left=${s}`), E(), P();
44
- }
45
- function L() {
46
- i && (i.close(), i = null), a();
37
+ function $(n) {
38
+ const e = n.isSandbox ?? !1;
39
+ return `${n.developmentUrl || (e ? _ : v)}/embed/consents/${n.consentRequestId}`;
47
40
  }
41
+ const x = "IFRAME_EVENT";
48
42
  let l = null;
49
- function O() {
43
+ function S() {
50
44
  l && (l.cancel(), l = null);
51
45
  }
52
- async function W(e) {
53
- const { onEvent: t } = e, n = await import("./index-yZw-yxuV.js").then((o) => o.i);
54
- l && O(), l = n.on(R, async (o) => {
55
- t(o.data), y.includes(o.data.eventName) ? L() : o.data.eventName === b && a();
46
+ async function A(n) {
47
+ const { onEvent: e } = n, t = await import("./index-yZw-yxuV.js").then((o) => o.i);
48
+ l && S(), l = t.on(x, async (o) => {
49
+ const r = o.data;
50
+ e(r);
56
51
  });
57
52
  }
58
- function $(e) {
59
- W(e);
53
+ class Y {
54
+ constructor(e) {
55
+ d(this, "options");
56
+ d(this, "iframe", null);
57
+ this.options = e, A({ onEvent: this.options.onEvent.bind(this) });
58
+ }
59
+ mount(e) {
60
+ D();
61
+ const t = L(e), o = $(this.options);
62
+ return this.iframe = O(o), t.appendChild(this.iframe), this;
63
+ }
64
+ unmount() {
65
+ S(), this.iframe && (this.iframe.remove(), this.iframe = null);
66
+ }
60
67
  }
61
- const x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
68
+ const z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
62
69
  __proto__: null
63
70
  }, Symbol.toStringTag, { value: "Module" }));
64
- var d, h;
65
- class A {
66
- constructor(t) {
67
- p(this, d);
68
- f(this, "onEvent");
69
- this.onEvent = t.onEvent, U && (C(t), $({
70
- onEvent: w(this, d, h).bind(this)
71
+ function H(n) {
72
+ let e = "widget/";
73
+ return "disclosureRequestId" in n.configProps ? e += ["disclosures", n.configProps.disclosureRequestId].join("/") : e += n.request, e;
74
+ }
75
+ function G(n) {
76
+ const e = n.isSandbox ?? !1, t = n.developmentUrl || (e ? _ : v), o = Object.entries(n.configProps).filter(([c, s]) => s || c === "disclosureRequestId").map(([c, s]) => `${c}=${encodeURIComponent(s)}`).join("&"), r = H(n);
77
+ return `${t}/${r}?sdk=web&${o}`;
78
+ }
79
+ const W = !!(typeof window < "u" && window.document && window.document.createElement);
80
+ let i = null, E = null;
81
+ function f(n = null) {
82
+ i && !i.closed && i.focus(), n == null || n.preventDefault();
83
+ }
84
+ function m() {
85
+ document.body.style.filter = "", document.body.removeEventListener("click", f);
86
+ }
87
+ function M() {
88
+ E = setInterval(() => {
89
+ (!i || i.closed) && (E && clearInterval(E), m());
90
+ }, 500);
91
+ }
92
+ function F(n) {
93
+ const e = G(n), t = 420, o = 720, r = window.screenLeft !== void 0 ? window.screenLeft : window.screenX, c = window.screenTop !== void 0 ? window.screenTop : window.screenY, s = window.innerWidth || document.documentElement.clientWidth || window.screen.width, y = window.innerHeight || document.documentElement.clientHeight || window.screen.height, w = s / window.screen.availWidth, P = (s - t) / 2 / w + r, R = (y - o) / 2 / w + c;
94
+ document.body.style.filter = "blur(5px)", document.body.addEventListener("click", f), i = window.open(
95
+ e,
96
+ "Soyio",
97
+ `scrollbars=yes,
98
+ width=${t},
99
+ height=${o},
100
+ top=${R},
101
+ left=${P}`
102
+ ), f(), M();
103
+ }
104
+ function V() {
105
+ i && (i.close(), i = null), m();
106
+ }
107
+ const q = "WIDGET_EVENT";
108
+ let a = null;
109
+ function j() {
110
+ a && (a.cancel(), a = null);
111
+ }
112
+ async function k(n) {
113
+ const { onEvent: e } = n, t = await import("./index-yZw-yxuV.js").then((o) => o.i);
114
+ a && j(), a = t.on(q, async (o) => {
115
+ e(o.data), g.includes(o.data.eventName) ? V() : o.data.eventName === C && m();
116
+ });
117
+ }
118
+ function B(n) {
119
+ k(n);
120
+ }
121
+ var u, T;
122
+ class K {
123
+ constructor(e) {
124
+ h(this, u);
125
+ d(this, "onEvent");
126
+ this.onEvent = e.onEvent, W && (F(e), B({
127
+ onEvent: p(this, u, T).bind(this)
71
128
  }));
72
129
  }
73
130
  }
74
- d = new WeakSet(), h = function(t) {
75
- this.onEvent(t);
131
+ u = new WeakSet(), T = function(e) {
132
+ this.onEvent(e);
76
133
  };
77
134
  export {
78
- x as SoyioTypes,
79
- A as SoyioWidget,
80
- A as default
135
+ Y as ConsentRequestBox,
136
+ z as SoyioTypes,
137
+ K as SoyioWidget,
138
+ K as default
81
139
  };
@@ -1,17 +1,21 @@
1
- (function(D,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(D=typeof globalThis<"u"?globalThis:D||self,A(D["soyio-widget"]={}))})(this,function(D){"use strict";var ft=Object.defineProperty;var lt=(D,A,F)=>A in D?ft(D,A,{enumerable:!0,configurable:!0,writable:!0,value:F}):D[A]=F;var ye=(D,A,F)=>(lt(D,typeof A!="symbol"?A+"":A,F),F),ht=(D,A,F)=>{if(!A.has(D))throw TypeError("Cannot "+F)};var Ee=(D,A,F)=>{if(A.has(D))throw TypeError("Cannot add the same private member more than once");A instanceof WeakSet?A.add(D):A.set(D,F)};var We=(D,A,F)=>(ht(D,A,"access private method"),F);var hn,Se;function A(E,T){for(var C=0;C<T.length;C++){const y=T[C];if(typeof y!="string"&&!Array.isArray(y)){for(const w in y)if(w!=="default"&&!(w in E)){const v=Object.getOwnPropertyDescriptor(y,w);v&&Object.defineProperty(E,w,v.get?v:{enumerable:!0,get:()=>y[w]})}}}return Object.freeze(Object.defineProperty(E,Symbol.toStringTag,{value:"Module"}))}const F="WIDGET_EVENT",be="https://app.soyio.id/widget",xe="https://sandbox.soyio.id/widget",Pe=["DISCLOSURE_REQUEST_SUCCESSFUL","IDENTITY_REGISTERED","IDENTITY_SIGNATURE","UNEXPECTED_ERROR","DENIED_CAMERA_PERMISSION","REJECTED_SIGNATURE"],Oe="WIDGET_CLOSED";function Ie(E){return"disclosureRequestId"in E.configProps?["disclosures",E.configProps.disclosureRequestId].join("/"):E.request}function De(E){const T=E.isSandbox??!1,C=E.developmentUrl||(T?xe:be),y=Object.entries(E.configProps).filter(([v,W])=>W||v==="disclosureRequestId").map(([v,W])=>`${v}=${encodeURIComponent(W)}`).join("&"),w=Ie(E);return`${C}/${w}?sdk=web&${y}`}const Ae=!!(typeof window<"u"&&window.document&&window.document.createElement),Re=500;let k=null,bn=null;function xn(E=null){k&&!k.closed&&k.focus(),E==null||E.preventDefault()}function Pn(){document.body.style.filter="",document.body.removeEventListener("click",xn)}function Ne(){bn=setInterval(()=>{(!k||k.closed)&&(bn&&clearInterval(bn),Pn())},Re)}function je(E){const T=De(E),C=510,y=720,w=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,W=w/2-C/2,q=v/2-y/2;document.body.style.filter="blur(5px)",document.body.addEventListener("click",xn),k=window.open(T,"Soyio",`scrollbars=yes, width=${C}, height=${y}, top=${q}, left=${W}`),xn(),Ne()}function ze(){k&&(k.close(),k=null),Pn()}let en=null;function Ce(){en&&(en.cancel(),en=null)}async function Te(E){const{onEvent:T}=E,C=await Promise.resolve().then(()=>Be);en&&Ce(),en=C.on(F,async y=>{T(y.data),Pe.includes(y.data.eventName)?ze():y.data.eventName===Oe&&Pn()})}function Me(E){Te(E)}const Le=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));class Ln{constructor(T){Ee(this,hn);ye(this,"onEvent");this.onEvent=T.onEvent,Ae&&(je(T),Me({onEvent:We(this,hn,Se).bind(this)}))}}hn=new WeakSet,Se=function(T){this.onEvent(T)};var Fe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ue(E){return E&&E.__esModule&&Object.prototype.hasOwnProperty.call(E,"default")?E.default:E}var Fn={exports:{}},Un={exports:{}};(function(E,T){(function(C,y){E.exports=y()})(typeof self<"u"?self:Fe,function(){return function(C){var y={};function w(v){if(y[v])return y[v].exports;var W=y[v]={i:v,l:!1,exports:{}};return C[v].call(W.exports,W,W.exports,w),W.l=!0,W.exports}return w.m=C,w.c=y,w.d=function(v,W,q){w.o(v,W)||Object.defineProperty(v,W,{enumerable:!0,get:q})},w.r=function(v){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(v,"__esModule",{value:!0})},w.t=function(v,W){if(1&W&&(v=w(v)),8&W||4&W&&typeof v=="object"&&v&&v.__esModule)return v;var q=Object.create(null);if(w.r(q),Object.defineProperty(q,"default",{enumerable:!0,value:v}),2&W&&typeof v!="string")for(var tn in v)w.d(q,tn,(function(vn){return v[vn]}).bind(null,tn));return q},w.n=function(v){var W=v&&v.__esModule?function(){return v.default}:function(){return v};return w.d(W,"a",W),W},w.o=function(v,W){return{}.hasOwnProperty.call(v,W)},w.p="",w(w.s=0)}([function(C,y,w){w.r(y),w.d(y,"Promise",function(){return b}),w.d(y,"TYPES",function(){return st}),w.d(y,"ProxyWindow",function(){return B}),w.d(y,"setup",function(){return ge}),w.d(y,"destroy",function(){return ct}),w.d(y,"serializeMessage",function(){return ot}),w.d(y,"deserializeMessage",function(){return it}),w.d(y,"createProxyWindow",function(){return at}),w.d(y,"toProxyWindow",function(){return ut}),w.d(y,"on",function(){return V}),w.d(y,"once",function(){return rt}),w.d(y,"send",function(){return $}),w.d(y,"markWindowKnown",function(){return ae}),w.d(y,"cleanUpWindow",function(){return dt}),w.d(y,"bridge",function(){});function v(n){return{}.toString.call(n)==="[object RegExp]"}var W=`Call was rejected by callee.\r
2
- `;function q(n){return n===void 0&&(n=window),n.location.protocol}function tn(n){if(n===void 0&&(n=window),n.mockDomain){var t=n.mockDomain.split("//")[0];if(t)return t}return q(n)}function vn(n){return n===void 0&&(n=window),tn(n)==="about:"}function Y(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Bn(n){if(n===void 0&&(n=window),n&&!Y(n))try{return n.opener}catch{}}function wn(n){try{return!0}catch{}return!1}function mn(n){n===void 0&&(n=window);var t=n.location;if(!t)throw new Error("Can not read window location");var e=q(n);if(!e)throw new Error("Can not read window protocol");if(e==="file:")return"file://";if(e==="about:"){var r=Y(n);return r&&wn()?mn(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return e+"//"+o}function M(n){n===void 0&&(n=window);var t=mn(n);return t&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:t}function K(n){if(!function(t){try{if(t===window)return!0}catch{}try{var e=Object.getOwnPropertyDescriptor(t,"location");if(e&&e.enumerable===!1)return!1}catch{}try{if(vn(t)&&wn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),tn(r)==="mock:"}(t)&&wn())return!0}catch{}try{if(mn(t)===mn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||vn(n)&&wn()||M(window)===M(n))return!0}catch{}return!1}function pn(n){if(!K(n))throw new Error("Expected window to be same domain");return n}function Gn(n,t){if(!n||!t)return!1;var e=Y(t);return e?e===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(t).indexOf(n)!==-1}function Jn(n){var t=[],e;try{e=n.frames}catch{e=n}var r;try{r=e.length}catch{}if(r===0)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch{continue}t.push(i)}return t}for(var a=0;a<100;a++){var s=void 0;try{s=e[a]}catch{return t}if(!s)return t;t.push(s)}return t}var Ge=[],Je=[];function G(n,t){t===void 0&&(t=!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!==W}if(t&&K(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var e=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(Ge,n);if(e!==-1){var r=Je[e];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 qn(n){return n===void 0&&(n=window),Bn(n=n||window)||Y(n)||void 0}function nn(n,t){if(typeof n=="string"){if(typeof t=="string")return n==="*"||t===n;if(v(t)||Array.isArray(t))return!1}return v(n)?v(t)?n.toString()===t.toString():!Array.isArray(t)&&!!t.match(n):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!v(t)&&n.some(function(e){return nn(e,t)}))}function gn(n){try{if(n===window)return!0}catch(t){if(t&&t.message===W)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(t){if(t&&t.message===W)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.self===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.parent===n)return!0}catch(t){if(t&&t.message===W)return!0}try{if(n&&n.top===n)return!0}catch(t){if(t&&t.message===W)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 Zn(n){if(K(n))return pn(n).frameElement;for(var t=0,e=document.querySelectorAll("iframe");t<e.length;t++){var r=e[t];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function qe(n){if(function(e){return e===void 0&&(e=window),!!Y(e)}(n)){var t=Zn(n);if(t&&t.parentElement){t.parentElement.removeChild(t);return}}try{n.close()}catch{}}function X(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 t={}.toString;if(t){var e=t.call(n);if(e==="[object Window]"||e==="[object global]"||e==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var kn=[],rn=[],On=0,on;function Vn(){if(!On&&on){var n=on;on=null,n.resolve()}}function In(){On+=1}function an(){On-=1,Vn()}var b=function(){function n(e){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=[],e){var o,i,a=!1,s=!1,c=!1;In();try{e(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 t=n.prototype;return t.resolve=function(e){if(this.resolved||this.rejected)return this;if(X(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},t.reject=function(e){var r=this;if(this.resolved||this.rejected)return this;if(X(e))throw new Error("Can not reject promise with another promise");if(!e){var o=e&&typeof e.toString=="function"?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(kn.indexOf(i)===-1){kn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<rn.length;s++)rn[s](i,a)}}(e,r)},1),this.dispatch(),this},t.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},t.dispatch=function(){var e=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(e||r)){this.dispatching=!0,In();for(var i=function(h,g){return h.then(function(m){g.resolve(m)},function(m){g.reject(m)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,l=s.promise,d=void 0;if(e)try{d=c?c(this.value):this.value}catch(h){l.reject(h);continue}else if(r){if(!u){l.reject(this.error);continue}try{d=u(this.error)}catch(h){l.reject(h);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?l.resolve(f.value):l.reject(f.error),f.errorHandled=!0}else X(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?l.resolve(d.value):l.reject(d.error):i(d,l):l.resolve(d)}o.length=0,this.dispatching=!1,an()}},t.then=function(e,r){if(e&&typeof e!="function"&&!e.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:e,onError:r}),this.errorHandled=!0,this.dispatch(),o},t.catch=function(e){return this.then(void 0,e)},t.finally=function(e){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(e).then(function(){return r})},function(r){return n.try(e).then(function(){throw r})})},t.timeout=function(e,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 "+e+"ms"))},e);return this.then(function(a){return clearTimeout(i),a})},t.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},t.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(e){return e instanceof n?e:X(e)?new n(function(r,o){return e.then(r,o)}):new n().resolve(e)},n.reject=function(e){return new n().reject(e)},n.asyncReject=function(e){return new n().asyncReject(e)},n.all=function(e){var r=new n,o=e.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,l,d){return l.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},s=0;s<e.length;s++){var c=e[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!X(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(e){var r={},o=[],i=function(s){if(e.hasOwnProperty(s)){var c=e[s];X(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in e)i(a);return n.all(o).then(function(){return r})},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(e){return function(r){return rn.push(r),{cancel:function(){rn.splice(rn.indexOf(r),1)}}}(e)},n.try=function(e,r,o){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.try expected a function");var i;In();try{i=e.apply(r,o||[])}catch(a){return an(),n.reject(a)}return an(),n.resolve(i)},n.delay=function(e){return new n(function(r){setTimeout(r,e)})},n.isPromise=function(e){return!!(e&&e instanceof n)||X(e)},n.flush=function(){return function(e){var r=on=on||new e;return Vn(),r}(n)},n}();function yn(n,t){for(var e=0;e<n.length;e++)try{if(n[e]===t)return e}catch{}return-1}var Dn=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 e=new WeakMap,r={};return Object.freeze(r),e.set(r,"__testvalue__"),e.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var t=n.prototype;return t._cleanupClosedWindows=function(){for(var e=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(gn(i)&&G(i)){if(e)try{e.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},t.isSafeToReadWrite=function(e){return!gn(e)},t.set=function(e,r){if(!e)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(e,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var i=this.name,a=e[i];a&&a[0]===e?a[1]=r:Object.defineProperty(e,i,{value:[e,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=yn(s,e);u===-1?(s.push(e),c.push(r)):c[u]=r},t.get=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return r.get(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return o&&o[0]===e?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=yn(this.keys,e);if(i!==-1)return this.values[i]},t.delete=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];o&&o[0]===e&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=yn(i,e);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},t.has=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return!(!o||o[0]!==e)}catch{}return this._cleanupClosedWindows(),yn(this.keys,e)!==-1},t.getOrSet=function(e,r){if(this.has(e))return this.get(e);var o=r();return this.set(e,o),o},n}();function $n(n){return n.name||n.__name__||n.displayName||"anonymous"}function Yn(n,t){try{delete n.name,n.name=t}catch{}return n.__name__=n.displayName=t,n}function Z(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(t){if(typeof btoa=="function")return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(t,"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 Kn(n){try{return JSON.stringify([].slice.call(n),function(t,e){return typeof e=="function"?"memoize["+function(r){if(En=En||new Dn,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}(e)+"]":typeof window<"u"&&e instanceof window.Element||e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"?{}:e})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function Ze(){return{}}var un=0,Xn=0;function cn(n,t){t===void 0&&(t={});var e=t.thisNamespace,r=e!==void 0&&e,o=t.time,i,a,s=un;un+=1;var c=function(){for(var u=arguments.length,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];s<Xn&&(i=null,a=null,s=un,un+=1);var f;f=r?(a=a||new Dn).getOrSet(this,Ze):i=i||{};var h;try{h=Kn(l)}catch{return n.apply(this,arguments)}var g=f[h];if(g&&o&&Date.now()-g.time<o&&(delete f[h],g=null),g)return g.value;var m=Date.now(),p=n.apply(this,arguments);return f[h]={time:m,value:p},p};return c.reset=function(){i=null,a=null},Yn(c,(t.name||$n(n))+"::memoized")}cn.clear=function(){Xn=un};function ke(n){var t={};function e(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=Kn(a);return t.hasOwnProperty(c)||(t[c]=b.try(function(){return n.apply(o,r)}).finally(function(){delete t[c]})),t[c]}return e.reset=function(){t={}},Yn(e,$n(n)+"::promiseMemoized")}function _(){}function sn(n,t){if(t===void 0&&(t=1),t>=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 e=n&&n.stack,r=n&&n.message;if(e&&r)return e.indexOf(r)!==-1?e:r+`
3
- `+e;if(e)return e;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,t+1)}}function _n(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 t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(n[e]);return t});function An(n){return{}.toString.call(n)==="[object RegExp]"}function dn(n,t,e){if(n.hasOwnProperty(t))return n[t];var r=e();return n[t]=r,r}function Qn(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function ne(){return!!document.body&&document.readyState==="complete"}function ee(){return!!document.body&&document.readyState==="interactive"}cn(function(){return new b(function(n){if(ne()||ee())return n();var t=setInterval(function(){if(ne()||ee())return clearInterval(t),n()},10)})});var Wn=typeof document<"u"?document.currentScript:null,Ve=cn(function(){if(Wn||(Wn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),t=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),e=t&&t[1];if(!e)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===e)return i}}catch{}}()))return Wn;throw new Error("Can not determine current script")}),$e=Z();cn(function(){var n;try{n=Ve()}catch{return $e}var t=n.getAttribute("data-uid");if(t&&typeof t=="string"||(t=n.getAttribute("data-uid-auto"))&&typeof t=="string")return t;if(n.src){var e=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}));t="uid_"+e.slice(e.length-30)}else t=Z();return n.setAttribute("data-uid-auto",t),t});function fn(n){n===void 0&&(n=window);var t="__post_robot_10_0_46__";return n!==window?n[t]:n[t]=n[t]||{}}var te=function(){return{}};function j(n,t){return n===void 0&&(n="store"),t===void 0&&(t=te),dn(fn(),n,function(){var e=t();return{has:function(r){return e.hasOwnProperty(r)},get:function(r,o){return e.hasOwnProperty(r)?e[r]:o},set:function(r,o){return e[r]=o,o},del:function(r){delete e[r]},getOrSet:function(r,o){return dn(e,r,o)},reset:function(){e=t()},keys:function(){return Object.keys(e)}}})}var Ye=function(){};function Sn(){var n=fn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new Ye,n.WINDOW_WILDCARD}function L(n,t){return n===void 0&&(n="store"),t===void 0&&(t=te),j("windowStore").getOrSet(n,function(){var e=new Dn,r=function(o){return e.getOrSet(o,t)};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 re(){return j("instance").getOrSet("instanceID",Z)}function oe(n,t){var e=t.domain,r=L("helloPromises"),o=r.get(n);o&&o.resolve({domain:e});var i=b.resolve({domain:e});return r.set(n,i),i}function Rn(n,t){return(0,t.send)(n,"postrobot_hello",{instanceID:re()},{domain:"*",timeout:-1}).then(function(e){var r=e.origin,o=e.data.instanceID;return oe(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function ie(n,t){var e=t.send;return L("windowInstanceIDPromises").getOrSet(n,function(){return Rn(n,{send:e}).then(function(r){return r.instanceID})})}function ae(n){L("knownWindows").set(n,!0)}function Nn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function ue(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 Q(n,t){return{__type__:n,__val__:t}}var U,Ke=((U={}).function=function(){},U.error=function(n){return Q("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},U.promise=function(){},U.regex=function(n){return Q("regex",n.source)},U.date=function(n){return Q("date",n.toJSON())},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(n){return Q("undefined",n)},U),Xe={},H,_e=((H={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},H.error=function(n){var t=n.stack,e=n.code,r=n.data,o=new Error(n.message);return o.code=e,r&&(o.data=r),o.stack=t+`
1
+ (function(R,A){typeof exports=="object"&&typeof module<"u"?A(exports):typeof define=="function"&&define.amd?define(["exports"],A):(R=typeof globalThis<"u"?globalThis:R||self,A(R["soyio-widget"]={}))})(this,function(R){"use strict";var bt=Object.defineProperty;var xt=(R,A,M)=>A in R?bt(R,A,{enumerable:!0,configurable:!0,writable:!0,value:M}):R[A]=M;var xn=(R,A,M)=>(xt(R,typeof A!="symbol"?A+"":A,M),M),Pt=(R,A,M)=>{if(!A.has(R))throw TypeError("Cannot "+M)};var Pe=(R,A,M)=>{if(A.has(R))throw TypeError("Cannot add the same private member more than once");A instanceof WeakSet?A.add(R):A.set(R,M)};var Ie=(R,A,M)=>(Pt(R,A,"access private method"),M);var wn,Oe;function A(v,W){for(var N=0;N<W.length;N++){const p=W[N];if(typeof p!="string"&&!Array.isArray(p)){for(const m in p)if(m!=="default"&&!(m in v)){const w=Object.getOwnPropertyDescriptor(p,m);w&&Object.defineProperty(v,m,w.get?w:{enumerable:!0,get:()=>p[m]})}}}return Object.freeze(Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}))}const M="soyio-consent-request-iframe",Fn="https://app.soyio.id",Hn="https://sandbox.soyio.id",De=["DISCLOSURE_REQUEST_SUCCESSFUL","IDENTITY_REGISTERED","IDENTITY_SIGNATURE","UNEXPECTED_ERROR","DENIED_CAMERA_PERMISSION","REJECTED_SIGNATURE"],Re="WIDGET_CLOSED",Ae=420,Ne=720,Te=500;function Ce(){const v=document.getElementById(M);v&&(console.warn("ConsentRequestBox iframe already exists. Removing existing before mounting new one."),v.remove())}function je(v){const W=document.querySelector(v);if(!W)throw new Error(`Iframe div container with id '${v}' not found`);if(W.tagName.toLowerCase()!=="div")throw new Error(`Iframe container with id '${v}' must be a <div> element`);return W}function ze(v){const W=document.createElement("iframe");return W.id=M,W.style.zIndex=String(Number.MAX_SAFE_INTEGER),W.style.width="100%",W.style.height="100%",W.style.border="none",W.src=v,W}function Me(v){const W=v.isSandbox??!1;return`${v.developmentUrl||(W?Hn:Fn)}/embed/consents/${v.consentRequestId}`}const Le="IFRAME_EVENT";let rn=null;function Bn(){rn&&(rn.cancel(),rn=null)}async function Ue(v){const{onEvent:W}=v,N=await Promise.resolve().then(()=>_n);rn&&Bn(),rn=N.on(Le,async p=>{const m=p.data;W(m)})}class Fe{constructor(W){xn(this,"options");xn(this,"iframe",null);this.options=W,Ue({onEvent:this.options.onEvent.bind(this)})}mount(W){Ce();const N=je(W),p=Me(this.options);return this.iframe=ze(p),N.appendChild(this.iframe),this}unmount(){Bn(),this.iframe&&(this.iframe.remove(),this.iframe=null)}}const He=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));function Be(v){let W="widget/";return"disclosureRequestId"in v.configProps?W+=["disclosures",v.configProps.disclosureRequestId].join("/"):W+=v.request,W}function Ge(v){const W=v.isSandbox??!1,N=v.developmentUrl||(W?Hn:Fn),p=Object.entries(v.configProps).filter(([w,S])=>S||w==="disclosureRequestId").map(([w,S])=>`${w}=${encodeURIComponent(S)}`).join("&"),m=Be(v);return`${N}/${m}?sdk=web&${p}`}const qe=!!(typeof window<"u"&&window.document&&window.document.createElement);let _=null,Pn=null;function In(v=null){_&&!_.closed&&_.focus(),v==null||v.preventDefault()}function On(){document.body.style.filter="",document.body.removeEventListener("click",In)}function $e(){Pn=setInterval(()=>{(!_||_.closed)&&(Pn&&clearInterval(Pn),On())},Te)}function Je(v){const W=Ge(v),N=Ae,p=Ne,m=window.screenLeft!==void 0?window.screenLeft:window.screenX,w=window.screenTop!==void 0?window.screenTop:window.screenY,S=window.innerWidth||document.documentElement.clientWidth||window.screen.width,$=window.innerHeight||document.documentElement.clientHeight||window.screen.height,Z=S/window.screen.availWidth,en=(S-N)/2/Z+m,V=($-p)/2/Z+w;document.body.style.filter="blur(5px)",document.body.addEventListener("click",In),_=window.open(W,"Soyio",`scrollbars=yes,
2
+ width=${N},
3
+ height=${p},
4
+ top=${V},
5
+ left=${en}`),In(),$e()}function _e(){_&&(_.close(),_=null),On()}const Ve="WIDGET_EVENT";let on=null;function Ze(){on&&(on.cancel(),on=null)}async function ke(v){const{onEvent:W}=v,N=await Promise.resolve().then(()=>_n);on&&Ze(),on=N.on(Ve,async p=>{W(p.data),De.includes(p.data.eventName)?_e():p.data.eventName===Re&&On()})}function Ye(v){ke(v)}class Gn{constructor(W){Pe(this,wn);xn(this,"onEvent");this.onEvent=W.onEvent,qe&&(Je(W),Ye({onEvent:Ie(this,wn,Oe).bind(this)}))}}wn=new WeakSet,Oe=function(W){this.onEvent(W)};var Xe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ke(v){return v&&v.__esModule&&Object.prototype.hasOwnProperty.call(v,"default")?v.default:v}var qn={exports:{}},$n={exports:{}};(function(v,W){(function(N,p){v.exports=p()})(typeof self<"u"?self:Xe,function(){return function(N){var p={};function m(w){if(p[w])return p[w].exports;var S=p[w]={i:w,l:!1,exports:{}};return N[w].call(S.exports,S,S.exports,m),S.l=!0,S.exports}return m.m=N,m.c=p,m.d=function(w,S,$){m.o(w,S)||Object.defineProperty(w,S,{enumerable:!0,get:$})},m.r=function(w){typeof Symbol<"u"&&Symbol.toStringTag&&Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(w,"__esModule",{value:!0})},m.t=function(w,S){if(1&S&&(w=m(w)),8&S||4&S&&typeof w=="object"&&w&&w.__esModule)return w;var $=Object.create(null);if(m.r($),Object.defineProperty($,"default",{enumerable:!0,value:w}),2&S&&typeof w!="string")for(var Z in w)m.d($,Z,(function(en){return w[en]}).bind(null,Z));return $},m.n=function(w){var S=w&&w.__esModule?function(){return w.default}:function(){return w};return m.d(S,"a",S),S},m.o=function(w,S){return{}.hasOwnProperty.call(w,S)},m.p="",m(m.s=0)}([function(N,p,m){m.r(p),m.d(p,"Promise",function(){return x}),m.d(p,"TYPES",function(){return Wt}),m.d(p,"ProxyWindow",function(){return B}),m.d(p,"setup",function(){return xe}),m.d(p,"destroy",function(){return Et}),m.d(p,"serializeMessage",function(){return mt}),m.d(p,"deserializeMessage",function(){return pt}),m.d(p,"createProxyWindow",function(){return gt}),m.d(p,"toProxyWindow",function(){return yt}),m.d(p,"on",function(){return k}),m.d(p,"once",function(){return wt}),m.d(p,"send",function(){return Y}),m.d(p,"markWindowKnown",function(){return le}),m.d(p,"cleanUpWindow",function(){return St}),m.d(p,"bridge",function(){});function w(n){return{}.toString.call(n)==="[object RegExp]"}var S=`Call was rejected by callee.\r
6
+ `;function $(n){return n===void 0&&(n=window),n.location.protocol}function Z(n){if(n===void 0&&(n=window),n.mockDomain){var t=n.mockDomain.split("//")[0];if(t)return t}return $(n)}function en(n){return n===void 0&&(n=window),Z(n)==="about:"}function V(n){if(n===void 0&&(n=window),n)try{if(n.parent&&n.parent!==n)return n.parent}catch{}}function Vn(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 t=n.location;if(!t)throw new Error("Can not read window location");var e=$(n);if(!e)throw new Error("Can not read window protocol");if(e==="file:")return"file://";if(e==="about:"){var r=V(n);return r&&mn()?pn(r):"about://"}var o=t.host;if(!o)throw new Error("Can not read window host");return e+"//"+o}function L(n){n===void 0&&(n=window);var t=pn(n);return t&&n.mockDomain&&n.mockDomain.indexOf("mock:")===0?n.mockDomain:t}function X(n){if(!function(t){try{if(t===window)return!0}catch{}try{var e=Object.getOwnPropertyDescriptor(t,"location");if(e&&e.enumerable===!1)return!1}catch{}try{if(en(t)&&mn())return!0}catch{}try{if(function(r){return r===void 0&&(r=window),Z(r)==="mock:"}(t)&&mn())return!0}catch{}try{if(pn(t)===pn(window))return!0}catch{}return!1}(n))return!1;try{if(n===window||en(n)&&mn()||L(window)===L(n))return!0}catch{}return!1}function gn(n){if(!X(n))throw new Error("Expected window to be same domain");return n}function Zn(n,t){if(!n||!t)return!1;var e=V(t);return e?e===n:function(r){var o=[];try{for(;r.parent!==r;)o.push(r.parent),r=r.parent}catch{}return o}(t).indexOf(n)!==-1}function kn(n){var t=[],e;try{e=n.frames}catch{e=n}var r;try{r=e.length}catch{}if(r===0)return t;if(r){for(var o=0;o<r;o++){var i=void 0;try{i=e[o]}catch{continue}t.push(i)}return t}for(var a=0;a<100;a++){var s=void 0;try{s=e[a]}catch{return t}if(!s)return t;t.push(s)}return t}var nt=[],et=[];function G(n,t){t===void 0&&(t=!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!==S}if(t&&X(n))try{if(n.mockclosed)return!0}catch{}try{if(!n.parent||!n.top)return!0}catch{}var e=function(o,i){for(var a=0;a<o.length;a++)try{if(o[a]===i)return a}catch{}return-1}(nt,n);if(e!==-1){var r=et[e];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 Yn(n){return n===void 0&&(n=window),Vn(n=n||window)||V(n)||void 0}function tn(n,t){if(typeof n=="string"){if(typeof t=="string")return n==="*"||t===n;if(w(t)||Array.isArray(t))return!1}return w(n)?w(t)?n.toString()===t.toString():!Array.isArray(t)&&!!t.match(n):!!Array.isArray(n)&&(Array.isArray(t)?JSON.stringify(n)===JSON.stringify(t):!w(t)&&n.some(function(e){return tn(e,t)}))}function yn(n){try{if(n===window)return!0}catch(t){if(t&&t.message===S)return!0}try{if({}.toString.call(n)==="[object Window]")return!0}catch(t){if(t&&t.message===S)return!0}try{if(window.Window&&n instanceof window.Window)return!0}catch(t){if(t&&t.message===S)return!0}try{if(n&&n.self===n)return!0}catch(t){if(t&&t.message===S)return!0}try{if(n&&n.parent===n)return!0}catch(t){if(t&&t.message===S)return!0}try{if(n&&n.top===n)return!0}catch(t){if(t&&t.message===S)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 Xn(n){if(X(n))return gn(n).frameElement;for(var t=0,e=document.querySelectorAll("iframe");t<e.length;t++){var r=e[t];if(r&&r.contentWindow&&r.contentWindow===n)return r}}function tt(n){if(function(e){return e===void 0&&(e=window),!!V(e)}(n)){var t=Xn(n);if(t&&t.parentElement){t.parentElement.removeChild(t);return}}try{n.close()}catch{}}function K(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 t={}.toString;if(t){var e=t.call(n);if(e==="[object Window]"||e==="[object global]"||e==="[object DOMWindow]")return!1}if(typeof n.then=="function")return!0}catch{return!1}return!1}var Kn=[],an=[],Dn=0,un;function Qn(){if(!Dn&&un){var n=un;un=null,n.resolve()}}function Rn(){Dn+=1}function cn(){Dn-=1,Qn()}var x=function(){function n(e){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=[],e){var o,i,a=!1,s=!1,c=!1;Rn();try{e(function(u){c?r.resolve(u):(a=!0,o=u)},function(u){c?r.reject(u):(s=!0,i=u)})}catch(u){cn(),this.reject(u);return}cn(),c=!0,a?this.resolve(o):s&&this.reject(i)}}var t=n.prototype;return t.resolve=function(e){if(this.resolved||this.rejected)return this;if(K(e))throw new Error("Can not resolve promise with another promise");return this.resolved=!0,this.value=e,this.dispatch(),this},t.reject=function(e){var r=this;if(this.resolved||this.rejected)return this;if(K(e))throw new Error("Can not reject promise with another promise");if(!e){var o=e&&typeof e.toString=="function"?e.toString():{}.toString.call(e);e=new Error("Expected reject to be called with Error, got "+o)}return this.rejected=!0,this.error=e,this.errorHandled||setTimeout(function(){r.errorHandled||function(i,a){if(Kn.indexOf(i)===-1){Kn.push(i),setTimeout(function(){throw i},1);for(var s=0;s<an.length;s++)an[s](i,a)}}(e,r)},1),this.dispatch(),this},t.asyncReject=function(e){return this.errorHandled=!0,this.reject(e),this},t.dispatch=function(){var e=this.resolved,r=this.rejected,o=this.handlers;if(!this.dispatching&&(e||r)){this.dispatching=!0,Rn();for(var i=function(h,E){return h.then(function(g){E.resolve(g)},function(g){E.reject(g)})},a=0;a<o.length;a++){var s=o[a],c=s.onSuccess,u=s.onError,l=s.promise,d=void 0;if(e)try{d=c?c(this.value):this.value}catch(h){l.reject(h);continue}else if(r){if(!u){l.reject(this.error);continue}try{d=u(this.error)}catch(h){l.reject(h);continue}}if(d instanceof n&&(d.resolved||d.rejected)){var f=d;f.resolved?l.resolve(f.value):l.reject(f.error),f.errorHandled=!0}else K(d)?d instanceof n&&(d.resolved||d.rejected)?d.resolved?l.resolve(d.value):l.reject(d.error):i(d,l):l.resolve(d)}o.length=0,this.dispatching=!1,cn()}},t.then=function(e,r){if(e&&typeof e!="function"&&!e.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:e,onError:r}),this.errorHandled=!0,this.dispatch(),o},t.catch=function(e){return this.then(void 0,e)},t.finally=function(e){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.finally expected a function");return this.then(function(r){return n.try(e).then(function(){return r})},function(r){return n.try(e).then(function(){throw r})})},t.timeout=function(e,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 "+e+"ms"))},e);return this.then(function(a){return clearTimeout(i),a})},t.toPromise=function(){if(typeof Promise>"u")throw new TypeError("Could not find Promise");return Promise.resolve(this)},t.lazy=function(){return this.errorHandled=!0,this},n.resolve=function(e){return e instanceof n?e:K(e)?new n(function(r,o){return e.then(r,o)}):new n().resolve(e)},n.reject=function(e){return new n().reject(e)},n.asyncReject=function(e){return new n().asyncReject(e)},n.all=function(e){var r=new n,o=e.length,i=[].slice();if(!o)return r.resolve(i),r;for(var a=function(u,l,d){return l.then(function(f){i[u]=f,(o-=1)==0&&r.resolve(i)},function(f){d.reject(f)})},s=0;s<e.length;s++){var c=e[s];if(c instanceof n){if(c.resolved){i[s]=c.value,o-=1;continue}}else if(!K(c)){i[s]=c,o-=1;continue}a(s,n.resolve(c),r)}return o===0&&r.resolve(i),r},n.hash=function(e){var r={},o=[],i=function(s){if(e.hasOwnProperty(s)){var c=e[s];K(c)?o.push(c.then(function(u){r[s]=u})):r[s]=c}};for(var a in e)i(a);return n.all(o).then(function(){return r})},n.map=function(e,r){return n.all(e.map(r))},n.onPossiblyUnhandledException=function(e){return function(r){return an.push(r),{cancel:function(){an.splice(an.indexOf(r),1)}}}(e)},n.try=function(e,r,o){if(e&&typeof e!="function"&&!e.call)throw new Error("Promise.try expected a function");var i;Rn();try{i=e.apply(r,o||[])}catch(a){return cn(),n.reject(a)}return cn(),n.resolve(i)},n.delay=function(e){return new n(function(r){setTimeout(r,e)})},n.isPromise=function(e){return!!(e&&e instanceof n)||K(e)},n.flush=function(){return function(e){var r=un=un||new e;return Qn(),r}(n)},n}();function En(n,t){for(var e=0;e<n.length;e++)try{if(n[e]===t)return e}catch{}return-1}var An=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 e=new WeakMap,r={};return Object.freeze(r),e.set(r,"__testvalue__"),e.get(r)==="__testvalue__"}catch{return!1}}())try{this.weakmap=new WeakMap}catch{}this.keys=[],this.values=[]}var t=n.prototype;return t._cleanupClosedWindows=function(){for(var e=this.weakmap,r=this.keys,o=0;o<r.length;o++){var i=r[o];if(yn(i)&&G(i)){if(e)try{e.delete(i)}catch{}r.splice(o,1),this.values.splice(o,1),o-=1}}},t.isSafeToReadWrite=function(e){return!yn(e)},t.set=function(e,r){if(!e)throw new Error("WeakMap expected key");var o=this.weakmap;if(o)try{o.set(e,r)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var i=this.name,a=e[i];a&&a[0]===e?a[1]=r:Object.defineProperty(e,i,{value:[e,r],writable:!0});return}catch{}this._cleanupClosedWindows();var s=this.keys,c=this.values,u=En(s,e);u===-1?(s.push(e),c.push(r)):c[u]=r},t.get=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return r.get(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return o&&o[0]===e?o[1]:void 0}catch{}this._cleanupClosedWindows();var i=En(this.keys,e);if(i!==-1)return this.values[i]},t.delete=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{r.delete(e)}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];o&&o[0]===e&&(o[0]=o[1]=void 0)}catch{}this._cleanupClosedWindows();var i=this.keys,a=En(i,e);a!==-1&&(i.splice(a,1),this.values.splice(a,1))},t.has=function(e){if(!e)throw new Error("WeakMap expected key");var r=this.weakmap;if(r)try{if(r.has(e))return!0}catch{delete this.weakmap}if(this.isSafeToReadWrite(e))try{var o=e[this.name];return!(!o||o[0]!==e)}catch{}return this._cleanupClosedWindows(),En(this.keys,e)!==-1},t.getOrSet=function(e,r){if(this.has(e))return this.get(e);var o=r();return this.set(e,o),o},n}();function ne(n){return n.name||n.__name__||n.displayName||"anonymous"}function ee(n,t){try{delete n.name,n.name=t}catch{}return n.__name__=n.displayName=t,n}function J(){var n="0123456789abcdef";return"uid_"+"xxxxxxxxxx".replace(/./g,function(){return n.charAt(Math.floor(Math.random()*n.length))})+"_"+function(t){if(typeof btoa=="function")return btoa(encodeURIComponent(t).replace(/%([0-9A-F]{2})/g,function(e,r){return String.fromCharCode(parseInt(r,16))})).replace(/[=]/g,"");if(typeof Buffer<"u")return Buffer.from(t,"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 te(n){try{return JSON.stringify([].slice.call(n),function(t,e){return typeof e=="function"?"memoize["+function(r){if(Wn=Wn||new An,r==null||typeof r!="object"&&typeof r!="function")throw new Error("Invalid object");var o=Wn.get(r);return o||(o=typeof r+":"+J(),Wn.set(r,o)),o}(e)+"]":typeof window<"u"&&e instanceof window.Element||e!==null&&typeof e=="object"&&e.nodeType===1&&typeof e.style=="object"&&typeof e.ownerDocument=="object"?{}:e})}catch{throw new Error("Arguments not serializable -- can not be used to memoize")}}function rt(){return{}}var sn=0,re=0;function dn(n,t){t===void 0&&(t={});var e=t.thisNamespace,r=e!==void 0&&e,o=t.time,i,a,s=sn;sn+=1;var c=function(){for(var u=arguments.length,l=new Array(u),d=0;d<u;d++)l[d]=arguments[d];s<re&&(i=null,a=null,s=sn,sn+=1);var f;f=r?(a=a||new An).getOrSet(this,rt):i=i||{};var h;try{h=te(l)}catch{return n.apply(this,arguments)}var E=f[h];if(E&&o&&Date.now()-E.time<o&&(delete f[h],E=null),E)return E.value;var g=Date.now(),y=n.apply(this,arguments);return f[h]={time:g,value:y},y};return c.reset=function(){i=null,a=null},ee(c,(t.name||ne(n))+"::memoized")}dn.clear=function(){re=sn};function ot(n){var t={};function e(){for(var r=arguments,o=this,i=arguments.length,a=new Array(i),s=0;s<i;s++)a[s]=arguments[s];var c=te(a);return t.hasOwnProperty(c)||(t[c]=x.try(function(){return n.apply(o,r)}).finally(function(){delete t[c]})),t[c]}return e.reset=function(){t={}},ee(e,ne(n)+"::promiseMemoized")}function Q(){}function fn(n,t){if(t===void 0&&(t=1),t>=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 e=n&&n.stack,r=n&&n.message;if(e&&r)return e.indexOf(r)!==-1?e:r+`
7
+ `+e;if(e)return e;if(r)return r}return n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}catch(o){return"Error while stringifying error: "+fn(o,t+1)}}function oe(n){return typeof n=="string"?n:n&&n.toString&&typeof n.toString=="function"?n.toString():{}.toString.call(n)}dn(function(n){if(Object.values)return Object.values(n);var t=[];for(var e in n)n.hasOwnProperty(e)&&t.push(n[e]);return t});function Nn(n){return{}.toString.call(n)==="[object RegExp]"}function ln(n,t,e){if(n.hasOwnProperty(t))return n[t];var r=e();return n[t]=r,r}function ie(){var n=document.body;if(!n)throw new Error("Body element not found");return n}function ae(){return!!document.body&&document.readyState==="complete"}function ue(){return!!document.body&&document.readyState==="interactive"}dn(function(){return new x(function(n){if(ae()||ue())return n();var t=setInterval(function(){if(ae()||ue())return clearInterval(t),n()},10)})});var Sn=typeof document<"u"?document.currentScript:null,it=dn(function(){if(Sn||(Sn=function(){try{var n=function(){try{throw new Error("_")}catch(a){return a.stack||""}}(),t=/.*at [^(]*\((.*):(.+):(.+)\)$/gi.exec(n),e=t&&t[1];if(!e)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===e)return i}}catch{}}()))return Sn;throw new Error("Can not determine current script")}),at=J();dn(function(){var n;try{n=it()}catch{return at}var t=n.getAttribute("data-uid");if(t&&typeof t=="string"||(t=n.getAttribute("data-uid-auto"))&&typeof t=="string")return t;if(n.src){var e=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}));t="uid_"+e.slice(e.length-30)}else t=J();return n.setAttribute("data-uid-auto",t),t});function hn(n){n===void 0&&(n=window);var t="__post_robot_10_0_46__";return n!==window?n[t]:n[t]=n[t]||{}}var ce=function(){return{}};function j(n,t){return n===void 0&&(n="store"),t===void 0&&(t=ce),ln(hn(),n,function(){var e=t();return{has:function(r){return e.hasOwnProperty(r)},get:function(r,o){return e.hasOwnProperty(r)?e[r]:o},set:function(r,o){return e[r]=o,o},del:function(r){delete e[r]},getOrSet:function(r,o){return ln(e,r,o)},reset:function(){e=t()},keys:function(){return Object.keys(e)}}})}var ut=function(){};function bn(){var n=hn();return n.WINDOW_WILDCARD=n.WINDOW_WILDCARD||new ut,n.WINDOW_WILDCARD}function U(n,t){return n===void 0&&(n="store"),t===void 0&&(t=ce),j("windowStore").getOrSet(n,function(){var e=new An,r=function(o){return e.getOrSet(o,t)};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 ln(r(o),n,i)}}})}function se(){return j("instance").getOrSet("instanceID",J)}function de(n,t){var e=t.domain,r=U("helloPromises"),o=r.get(n);o&&o.resolve({domain:e});var i=x.resolve({domain:e});return r.set(n,i),i}function Tn(n,t){return(0,t.send)(n,"postrobot_hello",{instanceID:se()},{domain:"*",timeout:-1}).then(function(e){var r=e.origin,o=e.data.instanceID;return de(n,{domain:r}),{win:n,domain:r,instanceID:o}})}function fe(n,t){var e=t.send;return U("windowInstanceIDPromises").getOrSet(n,function(){return Tn(n,{send:e}).then(function(r){return r.instanceID})})}function le(n){U("knownWindows").set(n,!0)}function Cn(n){return typeof n=="object"&&n!==null&&typeof n.__type__=="string"}function he(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,t){return{__type__:n,__val__:t}}var F,ct=((F={}).function=function(){},F.error=function(n){return nn("error",{message:n.message,stack:n.stack,code:n.code,data:n.data})},F.promise=function(){},F.regex=function(n){return nn("regex",n.source)},F.date=function(n){return nn("date",n.toJSON())},F.array=function(n){return n},F.object=function(n){return n},F.string=function(n){return n},F.number=function(n){return n},F.boolean=function(n){return n},F.null=function(n){return n},F[void 0]=function(n){return nn("undefined",n)},F),st={},H,dt=((H={}).function=function(){throw new Error("Function serialization is not implemented; nothing to deserialize")},H.error=function(n){var t=n.stack,e=n.code,r=n.data,o=new Error(n.message);return o.code=e,r&&(o.data=r),o.stack=t+`
4
8
 
5
- `+o.stack,o},H.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},H.regex=function(n){return new RegExp(n)},H.date=function(n){return new Date(n)},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(){},H),Qe={};new b(function(n){if(window.document&&window.document.body)return n(window.document.body);var t=setInterval(function(){if(window.document&&window.document.body)return clearInterval(t),n(window.document.body)},10)});function jn(){for(var n=j("idToProxyWindow"),t=0,e=n.keys();t<e.length;t++){var r=e[t];n.get(r).shouldClean()&&n.del(r)}}function ce(n,t){var e=t.send,r=t.id,o=r===void 0?Z():r,i=n.then(function(c){if(K(c))return pn(c).name}),a=n.then(function(c){if(G(c))throw new Error("Window is closed, can not determine type");return Bn(c)?"popup":"iframe"});i.catch(_),a.catch(_);var s=function(){return n.then(function(c){if(!G(c))return K(c)?pn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:ke(function(){return n.then(function(c){return ie(c,{send:e})})}),close:function(){return n.then(qe)},getName:s,focus:function(){return n.then(function(c){c.focus()})},isClosed:function(){return n.then(function(c){return G(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(l){var d=window.location.protocol+"//"+window.location.host,f=u.method,h=f===void 0?"get":f,g=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(h==="post")return s().then(function(m){if(!m)throw new Error("Can not post to window without target name");(function(p){var x=p.url,N=p.target,O=p.body,P=p.method,z=P===void 0?"post":P,S=document.createElement("form");if(S.setAttribute("target",N),S.setAttribute("method",z),S.setAttribute("action",x),S.style.display="none",O)for(var I=0,J=Object.keys(O);I<J.length;I++){var R,ln=J[I],Mn=document.createElement("input");Mn.setAttribute("name",ln),Mn.setAttribute("value",(R=O[ln])==null?void 0:R.toString()),S.appendChild(Mn)}Qn().appendChild(S),S.submit(),Qn().removeChild(S)})({url:c,target:m,method:h,body:g})});if(h!=="get")throw new Error("Unsupported method: "+h);if(K(l))try{if(l.location&&typeof l.location.replace=="function"){l.location.replace(c);return}}catch{}l.location=c})},setName:function(c){return n.then(function(u){var l=K(u),d=Zn(u);if(!l)throw new Error("Can not set name for cross-domain window: "+c);pn(u).name=c,d&&d.setAttribute("name",c),i=b.resolve(c)})}}}var B=function(){function n(e){var r=e.send,o=e.win,i=e.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 b,this.serializedWindow=i||ce(this.actualWindowPromise,{send:r}),j("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var t=n.prototype;return t.getID=function(){return this.serializedWindow.id},t.getType=function(){return this.serializedWindow.getType()},t.isPopup=function(){return this.getType().then(function(e){return e==="popup"})},t.setLocation=function(e,r){var o=this;return this.serializedWindow.setLocation(e,r).then(function(){return o})},t.getName=function(){return this.serializedWindow.getName()},t.setName=function(e){var r=this;return this.serializedWindow.setName(e).then(function(){return r})},t.close=function(){var e=this;return this.serializedWindow.close().then(function(){return e})},t.focus=function(){var e=this,r=this.isPopup(),o=this.getName(),i=b.hash({isPopup:r,name:o}).then(function(s){var c=s.name;s.isPopup&&c&&window.open("",c,"noopener")}),a=this.serializedWindow.focus();return b.all([i,a]).then(function(){return e})},t.isClosed=function(){return this.serializedWindow.isClosed()},t.getWindow=function(){return this.actualWindow},t.setWindow=function(e,r){var o=r.send;this.actualWindow=e,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=ce(this.actualWindowPromise,{send:o,id:this.getID()}),L("winToProxyWindow").set(e,this)},t.awaitWindow=function(){return this.actualWindowPromise},t.matchWindow=function(e,r){var o=this,i=r.send;return b.try(function(){return o.actualWindow?e===o.actualWindow:b.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:ie(e,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(e,{send:i}),s})})},t.unwrap=function(){return this.actualWindow||this},t.getInstanceID=function(){return this.serializedWindow.getInstanceID()},t.shouldClean=function(){return!!(this.actualWindow&&G(this.actualWindow))},t.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var o=r.send;return jn(),n.toProxyWindow(e,{send:o}).serialize()},n.deserialize=function(e,r){var o=r.send;return jn(),j("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:o})},n.isProxyWindow=function(e){return!!(e&&!gn(e)&&e.isProxyWindow)},n.toProxyWindow=function(e,r){var o=r.send;if(jn(),n.isProxyWindow(e))return e;var i=e;return L("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function zn(n,t,e,r,o){var i=L("methodStore"),a=j("proxyWindowMethods");B.isProxyWindow(r)?a.set(n,{val:t,name:e,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:e,val:t,source:r})}function se(n,t){var e=L("methodStore"),r=j("proxyWindowMethods");return e.getOrSet(n,function(){return{}})[t]||r.get(t)}function de(n,t,e,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,j("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(l){var d=l.source,f=l.origin,h=l.data,g=h.id,m=h.name,p=se(d,g);if(!p)throw new Error("Could not find method '"+m+"' with id: "+h.id+" in "+M(window));var x=p.source,N=p.domain,O=p.val;return b.try(function(){if(!nn(N,f))throw new Error("Method '"+h.name+"' domain "+JSON.stringify(An(p.domain)?p.domain.source:p.domain)+" does not match origin "+f+" in "+M(window));if(B.isProxyWindow(x))return x.matchWindow(d,{send:s}).then(function(P){if(!P)throw new Error("Method call '"+h.name+"' failed - proxy window does not match source in "+M(window))})}).then(function(){return O.apply({source:d,origin:f},h.args)},function(P){return b.try(function(){if(O.onError)return O.onError(P)}).then(function(){throw P.stack&&(P.stack="Remote call to "+m+"("+function(z){return z===void 0&&(z=[]),(S=z,[].slice.call(S)).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 S}(h.args)+`) failed
9
+ `+o.stack,o},H.promise=function(){throw new Error("Promise serialization is not implemented; nothing to deserialize")},H.regex=function(n){return new RegExp(n)},H.date=function(n){return new Date(n)},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(){},H),ft={};new x(function(n){if(window.document&&window.document.body)return n(window.document.body);var t=setInterval(function(){if(window.document&&window.document.body)return clearInterval(t),n(window.document.body)},10)});function jn(){for(var n=j("idToProxyWindow"),t=0,e=n.keys();t<e.length;t++){var r=e[t];n.get(r).shouldClean()&&n.del(r)}}function ve(n,t){var e=t.send,r=t.id,o=r===void 0?J():r,i=n.then(function(c){if(X(c))return gn(c).name}),a=n.then(function(c){if(G(c))throw new Error("Window is closed, can not determine type");return Vn(c)?"popup":"iframe"});i.catch(Q),a.catch(Q);var s=function(){return n.then(function(c){if(!G(c))return X(c)?gn(c).name:i})};return{id:o,getType:function(){return a},getInstanceID:ot(function(){return n.then(function(c){return fe(c,{send:e})})}),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 G(c)})},setLocation:function(c,u){return u===void 0&&(u={}),n.then(function(l){var d=window.location.protocol+"//"+window.location.host,f=u.method,h=f===void 0?"get":f,E=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(h==="post")return s().then(function(g){if(!g)throw new Error("Can not post to window without target name");(function(y){var P=y.url,C=y.target,O=y.body,I=y.method,z=I===void 0?"post":I,b=document.createElement("form");if(b.setAttribute("target",C),b.setAttribute("method",z),b.setAttribute("action",P),b.style.display="none",O)for(var D=0,q=Object.keys(O);D<q.length;D++){var T,vn=q[D],Un=document.createElement("input");Un.setAttribute("name",vn),Un.setAttribute("value",(T=O[vn])==null?void 0:T.toString()),b.appendChild(Un)}ie().appendChild(b),b.submit(),ie().removeChild(b)})({url:c,target:g,method:h,body:E})});if(h!=="get")throw new Error("Unsupported method: "+h);if(X(l))try{if(l.location&&typeof l.location.replace=="function"){l.location.replace(c);return}}catch{}l.location=c})},setName:function(c){return n.then(function(u){var l=X(u),d=Xn(u);if(!l)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(e){var r=e.send,o=e.win,i=e.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||ve(this.actualWindowPromise,{send:r}),j("idToProxyWindow").set(this.getID(),this),o&&this.setWindow(o,{send:r})}var t=n.prototype;return t.getID=function(){return this.serializedWindow.id},t.getType=function(){return this.serializedWindow.getType()},t.isPopup=function(){return this.getType().then(function(e){return e==="popup"})},t.setLocation=function(e,r){var o=this;return this.serializedWindow.setLocation(e,r).then(function(){return o})},t.getName=function(){return this.serializedWindow.getName()},t.setName=function(e){var r=this;return this.serializedWindow.setName(e).then(function(){return r})},t.close=function(){var e=this;return this.serializedWindow.close().then(function(){return e})},t.focus=function(){var e=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 e})},t.isClosed=function(){return this.serializedWindow.isClosed()},t.getWindow=function(){return this.actualWindow},t.setWindow=function(e,r){var o=r.send;this.actualWindow=e,this.actualWindowPromise.resolve(this.actualWindow),this.serializedWindow=ve(this.actualWindowPromise,{send:o,id:this.getID()}),U("winToProxyWindow").set(e,this)},t.awaitWindow=function(){return this.actualWindowPromise},t.matchWindow=function(e,r){var o=this,i=r.send;return x.try(function(){return o.actualWindow?e===o.actualWindow:x.hash({proxyInstanceID:o.getInstanceID(),knownWindowInstanceID:fe(e,{send:i})}).then(function(a){var s=a.proxyInstanceID===a.knownWindowInstanceID;return s&&o.setWindow(e,{send:i}),s})})},t.unwrap=function(){return this.actualWindow||this},t.getInstanceID=function(){return this.serializedWindow.getInstanceID()},t.shouldClean=function(){return!!(this.actualWindow&&G(this.actualWindow))},t.serialize=function(){return this.serializedWindow},n.unwrap=function(e){return n.isProxyWindow(e)?e.unwrap():e},n.serialize=function(e,r){var o=r.send;return jn(),n.toProxyWindow(e,{send:o}).serialize()},n.deserialize=function(e,r){var o=r.send;return jn(),j("idToProxyWindow").get(e.id)||new n({serializedWindow:e,send:o})},n.isProxyWindow=function(e){return!!(e&&!yn(e)&&e.isProxyWindow)},n.toProxyWindow=function(e,r){var o=r.send;if(jn(),n.isProxyWindow(e))return e;var i=e;return U("winToProxyWindow").get(i)||new n({win:i,send:o})},n}();function zn(n,t,e,r,o){var i=U("methodStore"),a=j("proxyWindowMethods");B.isProxyWindow(r)?a.set(n,{val:t,name:e,domain:o,source:r}):(a.del(n),i.getOrSet(r,function(){return{}})[n]={domain:o,name:e,val:t,source:r})}function we(n,t){var e=U("methodStore"),r=j("proxyWindowMethods");return e.getOrSet(n,function(){return{}})[t]||r.get(t)}function me(n,t,e,r,o){a=(i={on:o.on,send:o.send}).on,s=i.send,j("builtinListeners").getOrSet("functionCalls",function(){return a("postrobot_method",{domain:"*"},function(l){var d=l.source,f=l.origin,h=l.data,E=h.id,g=h.name,y=we(d,E);if(!y)throw new Error("Could not find method '"+g+"' with id: "+h.id+" in "+L(window));var P=y.source,C=y.domain,O=y.val;return x.try(function(){if(!tn(C,f))throw new Error("Method '"+h.name+"' domain "+JSON.stringify(Nn(y.domain)?y.domain.source:y.domain)+" does not match origin "+f+" in "+L(window));if(B.isProxyWindow(P))return P.matchWindow(d,{send:s}).then(function(I){if(!I)throw new Error("Method call '"+h.name+"' failed - proxy window does not match source in "+L(window))})}).then(function(){return O.apply({source:d,origin:f},h.args)},function(I){return x.try(function(){if(O.onError)return O.onError(I)}).then(function(){throw I.stack&&(I.stack="Remote call to "+g+"("+function(z){return z===void 0&&(z=[]),(b=z,[].slice.call(b)).map(function(D){return typeof D=="string"?"'"+D+"'":D===void 0?"undefined":D===null?"null":typeof D=="boolean"?D.toString():Array.isArray(D)?"[ ... ]":typeof D=="object"?"{ ... }":typeof D=="function"?"() => { ... }":"<"+typeof D+">"}).join(", ");var b}(h.args)+`) failed
6
10
 
7
- `+P.stack),P})}).then(function(P){return{result:P,id:g,name:m}})})});var i,a,s,c=e.__id__||Z();n=B.unwrap(n);var u=e.__name__||e.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),B.isProxyWindow(n)?(zn(c,e,u,n,t),n.awaitWindow().then(function(l){zn(c,e,u,l,t)})):zn(c,e,u,n,t),Q("cross_domain_function",{id:c,name:u})}function fe(n,t,e,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=Xe);var u=JSON.stringify(s,function(l){var d=this[l];if(Nn(this))return d;var f=ue(d);if(!f)return d;var h=c[f]||Ke[f];return h?h(d,l):d});return u===void 0?"undefined":u}(e,((o={}).promise=function(s,c){return function(u,l,d,f,h){return Q("cross_domain_zalgo_promise",{then:de(u,l,function(g,m){return d.then(g,m)},f,{on:h.on,send:h.send})})}(n,t,s,c,{on:i,send:a})},o.function=function(s,c){return de(n,t,s,c,{on:i,send:a})},o.object=function(s){return gn(s)||B.isProxyWindow(s)?Q("cross_domain_window",B.serialize(s,{send:a})):s},o))}function le(n,t,e,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=Qe),a!=="undefined")return JSON.parse(a,function(c,u){if(Nn(this))return u;var l,d;if(Nn(u)?(l=u.__type__,d=u.__val__):(l=ue(u),d=u),!l)return d;var f=s[l]||_e[l];return f?f(d,c):d})}(e,((o={}).cross_domain_zalgo_promise=function(a){return function(s,c,u){return new b(u.then)}(0,0,a)},o.cross_domain_function=function(a){return function(s,c,u,l){var d=u.id,f=u.name,h=l.send,g=function(p){p===void 0&&(p={});function x(){var N=arguments;return B.toProxyWindow(s,{send:h}).awaitWindow().then(function(O){var P=se(O,d);if(P&&P.val!==x)return P.val.apply({source:window,origin:M()},N);var z=[].slice.call(N);return p.fireAndForget?h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!0}):h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!1}).then(function(S){return S.data.result})}).catch(function(O){throw O})}return x.__name__=f,x.__origin__=c,x.__source__=s,x.__id__=d,x.origin=c,x},m=g();return m.fireAndForget=g({fireAndForget:!0}),m}(n,t,a,{send:i})},o.cross_domain_window=function(a){return B.deserialize(a,{send:i})},o))}var Cn={};Cn.postrobot_post_message=function(n,t,e){e.indexOf("file:")===0&&(e="*"),n.postMessage(t,e)};function Tn(n,t,e,r){var o=r.on,i=r.send;return b.try(function(){var a=L().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(e),a.flush=a.flush||b.flush().then(function(){if(G(n))throw new Error("Window is closed");var s=fe(n,t,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(Cn),l=[],d=0;d<u.length;d++){var f=u[d];try{Cn[f](n,s,t)}catch(h){l.push(h)}}if(l.length===u.length)throw new Error(`All post-robot messaging strategies failed:
11
+ `+I.stack),I})}).then(function(I){return{result:I,id:E,name:g}})})});var i,a,s,c=e.__id__||J();n=B.unwrap(n);var u=e.__name__||e.name||r;return typeof u=="string"&&typeof u.indexOf=="function"&&u.indexOf("anonymous::")===0&&(u=u.replace("anonymous::",r+"::")),B.isProxyWindow(n)?(zn(c,e,u,n,t),n.awaitWindow().then(function(l){zn(c,e,u,l,t)})):zn(c,e,u,n,t),nn("cross_domain_function",{id:c,name:u})}function pe(n,t,e,r){var o,i=r.on,a=r.send;return function(s,c){c===void 0&&(c=st);var u=JSON.stringify(s,function(l){var d=this[l];if(Cn(this))return d;var f=he(d);if(!f)return d;var h=c[f]||ct[f];return h?h(d,l):d});return u===void 0?"undefined":u}(e,((o={}).promise=function(s,c){return function(u,l,d,f,h){return nn("cross_domain_zalgo_promise",{then:me(u,l,function(E,g){return d.then(E,g)},f,{on:h.on,send:h.send})})}(n,t,s,c,{on:i,send:a})},o.function=function(s,c){return me(n,t,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 ge(n,t,e,r){var o,i=r.send;return function(a,s){if(s===void 0&&(s=ft),a!=="undefined")return JSON.parse(a,function(c,u){if(Cn(this))return u;var l,d;if(Cn(u)?(l=u.__type__,d=u.__val__):(l=he(u),d=u),!l)return d;var f=s[l]||dt[l];return f?f(d,c):d})}(e,((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,l){var d=u.id,f=u.name,h=l.send,E=function(y){y===void 0&&(y={});function P(){var C=arguments;return B.toProxyWindow(s,{send:h}).awaitWindow().then(function(O){var I=we(O,d);if(I&&I.val!==P)return I.val.apply({source:window,origin:L()},C);var z=[].slice.call(C);return y.fireAndForget?h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!0}):h(O,"postrobot_method",{id:d,name:f,args:z},{domain:c,fireAndForget:!1}).then(function(b){return b.data.result})}).catch(function(O){throw O})}return P.__name__=f,P.__origin__=c,P.__source__=s,P.__id__=d,P.origin=c,P},g=E();return g.fireAndForget=E({fireAndForget:!0}),g}(n,t,a,{send:i})},o.cross_domain_window=function(a){return B.deserialize(a,{send:i})},o))}var Mn={};Mn.postrobot_post_message=function(n,t,e){e.indexOf("file:")===0&&(e="*"),n.postMessage(t,e)};function Ln(n,t,e,r){var o=r.on,i=r.send;return x.try(function(){var a=U().getOrSet(n,function(){return{}});return a.buffer=a.buffer||[],a.buffer.push(e),a.flush=a.flush||x.flush().then(function(){if(G(n))throw new Error("Window is closed");var s=pe(n,t,((c={}).__post_robot_10_0_46__=a.buffer||[],c),{on:o,send:i}),c;delete a.buffer;for(var u=Object.keys(Mn),l=[],d=0;d<u.length;d++){var f=u[d];try{Mn[f](n,s,t)}catch(h){l.push(h)}}if(l.length===u.length)throw new Error(`All post-robot messaging strategies failed:
8
12
 
9
- `+l.map(function(h,g){return g+". "+sn(h)}).join(`
13
+ `+l.map(function(h,E){return E+". "+fn(h)}).join(`
10
14
 
11
- `))}),a.flush.then(function(){delete a.flush})}).then(_)}function he(n){return j("responseListeners").get(n)}function ve(n){j("responseListeners").del(n)}function we(n){return j("erroredResponseListeners").has(n)}function me(n){var t=n.name,e=n.win,r=n.domain,o=L("requestListeners");if(e==="*"&&(e=null),r==="*"&&(r=null),!t)throw new Error("Name required to get request listener");for(var i=0,a=[e,Sn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[t];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var l=0,d=u.__domain_regex__;l<d.length;l++){var f=d[l],h=f.listener;if(nn(f.regex,r))return h}}if(u["*"])return u["*"]}}}}}function nt(n,t,e,r){var o=r.on,i=r.send,a=me({name:e.name,win:n,domain:t}),s=e.name==="postrobot_method"&&e.data&&typeof e.data.name=="string"?e.data.name+"()":e.name;function c(u,l,d){return b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Tn(n,t,{id:Z(),origin:M(window),type:"postrobot_message_response",hash:e.hash,name:e.name,ack:u,data:l,error:d},{on:o,send:i})}catch(f){throw new Error("Send response message failed for "+s+" in "+M()+`
15
+ `))}),a.flush.then(function(){delete a.flush})}).then(Q)}function ye(n){return j("responseListeners").get(n)}function Ee(n){j("responseListeners").del(n)}function We(n){return j("erroredResponseListeners").has(n)}function Se(n){var t=n.name,e=n.win,r=n.domain,o=U("requestListeners");if(e==="*"&&(e=null),r==="*"&&(r=null),!t)throw new Error("Name required to get request listener");for(var i=0,a=[e,bn()];i<a.length;i++){var s=a[i];if(s){var c=o.get(s);if(c){var u=c[t];if(u){if(r&&typeof r=="string"){if(u[r])return u[r];if(u.__domain_regex__)for(var l=0,d=u.__domain_regex__;l<d.length;l++){var f=d[l],h=f.listener;if(tn(f.regex,r))return h}}if(u["*"])return u["*"]}}}}}function lt(n,t,e,r){var o=r.on,i=r.send,a=Se({name:e.name,win:n,domain:t}),s=e.name==="postrobot_method"&&e.data&&typeof e.data.name=="string"?e.data.name+"()":e.name;function c(u,l,d){return x.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Ln(n,t,{id:J(),origin:L(window),type:"postrobot_message_response",hash:e.hash,name:e.name,ack:u,data:l,error:d},{on:o,send:i})}catch(f){throw new Error("Send response message failed for "+s+" in "+L()+`
12
16
 
13
- `+sn(f))}})}return b.all([b.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Tn(n,t,{id:Z(),origin:M(window),type:"postrobot_message_ack",hash:e.hash,name:e.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+M()+`
17
+ `+fn(f))}})}return x.all([x.flush().then(function(){if(!e.fireAndForget&&!G(n))try{return Ln(n,t,{id:J(),origin:L(window),type:"postrobot_message_ack",hash:e.hash,name:e.name},{on:o,send:i})}catch(u){throw new Error("Send ack message failed for "+s+" in "+L()+`
14
18
 
15
- `+sn(u))}}),b.try(function(){if(!a)throw new Error("No handler found for post message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:t,data:e.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 et(n,t,e){if(!we(e.hash)){var r=he(e.hash);if(!r)throw new Error("No handler found for post message ack for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!nn(r.domain,t))throw new Error("Ack origin "+t+" 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 tt(n,t,e){if(!we(e.hash)){var r=he(e.hash);if(!r)throw new Error("No handler found for post message response for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!nn(r.domain,t))throw new Error("Response origin "+t+" 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");ve(e.hash),e.ack==="error"?r.promise.reject(e.error):e.ack==="success"&&r.promise.resolve({source:n,origin:t,data:e.data})}}function pe(n,t){var e=t.on,r=t.send,o=j("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(l,d,f,h){var g=h.on,m=h.send,p;try{p=le(d,f,l,{on:g,send:m})}catch{return}if(p&&typeof p=="object"&&p!==null){var x=p.__post_robot_10_0_46__;if(Array.isArray(x))return x}}(n.data,i,a,{on:e,send:r});if(s){ae(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),G(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?nt(i,a,u,{on:e,send:r}):u.type==="postrobot_message_response"?tt(i,a,u):u.type==="postrobot_message_ack"&&et(i,a,u)}catch(l){setTimeout(function(){throw l},0)}}}}function V(n,t,e){if(!n)throw new Error("Expected name");if(typeof(t=t||{})=="function"&&(e=t,t={}),!e)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,l=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(R){return o({name:s,win:R,domain:u},a)});return{cancel:function(){d.then(function(R){return R.cancel()},_)}}}var f=c;if(Array.isArray(f)){for(var h=[],g=0,m=f;g<m.length;g++)h.push(o({name:s,domain:u,win:m[g]},a));return{cancel:function(){for(var R=0;R<h.length;R++)h[R].cancel()}}}if(Array.isArray(u)){for(var p=[],x=0,N=u;x<N.length;x++)p.push(o({name:s,win:f,domain:N[x]},a));return{cancel:function(){for(var R=0;R<p.length;R++)p[R].cancel()}}}var O=me({name:s,win:f,domain:u});f&&f!=="*"||(f=Sn());var P=(u=u||"*").toString();if(O)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 z=l.getOrSet(f,function(){return{}}),S=dn(z,s,function(){return{}}),I,J;return An(u)?(I=dn(S,"__domain_regex__",function(){return[]})).push(J={regex:u,listener:a}):S[P]=a,{cancel:function(){delete S[P],J&&(I.splice(I.indexOf(J,1)),I.length||delete S.__domain_regex__),Object.keys(S).length||delete z[s],f&&!Object.keys(z).length&&l.del(f)}}}({name:n,win:t.window,domain:t.domain||"*"},{handler:e||t.handler,handleError:t.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function rt(n,t,e){typeof(t=t||{})=="function"&&(e=t,t={});var r=new b,o;return t.errorHandler=function(i){o.cancel(),r.reject(i)},o=V(n,t,function(i){if(o.cancel(),r.resolve(i),e)return e(i)}),r.cancel=o.cancel,r}var $=function n(t,e,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return B.toProxyWindow(t,{send:n}).awaitWindow().then(function(u){return b.try(function(){if(function(l,d,f){if(!l)throw new Error("Expected name");if(f&&typeof f!="string"&&!Array.isArray(f)&&!An(f))throw new TypeError("Can not send "+l+". Expected domain "+JSON.stringify(f)+" to be a string, array, or regex");if(G(d))throw new Error("Can not send "+l+". Target window is closed")}(e,u,i),function(l,d){var f=qn(d);if(f)return f===l;if(d===l||function(m){m===void 0&&(m=window);try{if(m.top)return m.top}catch{}if(Y(m)===m)return m;try{if(Gn(window,m)&&window.top)return window.top}catch{}try{if(Gn(m,window)&&window.top)return window.top}catch{}for(var p=0,x=function O(P){for(var z=[],S=0,I=Jn(P);S<I.length;S++){var J=I[S];z.push(J);for(var R=0,ln=O(J);R<ln.length;R++)z.push(ln[R])}return z}(m);p<x.length;p++){var N=x[p];try{if(N.top)return N.top}catch{}if(Y(N)===N)return N}}(d)===d)return!1;for(var h=0,g=Jn(l);h<g.length;h++)if(g[h]===d)return!0;return!1}(window,u))return function(l,d,f){d===void 0&&(d=5e3),f===void 0&&(f="Window");var h=function(g){return L("helloPromises").getOrSet(g,function(){return new b})}(l);return d!==-1&&(h=h.timeout(d,new Error(f+" did not load after "+d+"ms"))),h}(u,s)}).then(function(l){return function(d,f,h,g){var m=g.send;return b.try(function(){return typeof f=="string"?f:b.try(function(){return h||Rn(d,{send:m}).then(function(p){return p.domain})}).then(function(p){if(!nn(f,f))throw new Error("Domain "+_n(f)+" does not match "+_n(f));return p})})}(u,i,(l===void 0?{}:l).domain,{send:n})}).then(function(l){var d=l,f=e==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":e,h=new b,g=e+"_"+Z();if(!c){var m={name:e,win:u,domain:d,promise:h};(function(S,I){j("responseListeners").set(S,I)})(g,m);var p=L("requestPromises").getOrSet(u,function(){return[]});p.push(h),h.catch(function(){(function(S){j("erroredResponseListeners").set(S,!0)})(g),ve(g)});var x=function(S){return L("knownWindows").get(S,!1)}(u)?1e4:2e3,N=a,O=x,P=N,z=function(S,I){var J;return function R(){J=setTimeout(function(){(function(){if(G(u))return h.reject(new Error("Window closed for "+e+" before "+(m.ack?"response":"ack")));if(m.cancelled)return h.reject(new Error("Response listener was cancelled for "+e));O=Math.max(O-500,0),P!==-1&&(P=Math.max(P-500,0)),m.ack||O!==0?P===0&&h.reject(new Error("No response for postMessage "+f+" in "+M()+" in "+N+"ms")):h.reject(new Error("No ack for postMessage "+f+" in "+M()+" in "+x+"ms"))})(),R()},500)}(),{cancel:function(){clearTimeout(J)}}}();h.finally(function(){z.cancel(),p.splice(p.indexOf(h,1))}).catch(_)}return Tn(u,d,{id:Z(),origin:M(window),type:"postrobot_message_request",hash:g,name:e,data:r,fireAndForget:c},{on:V,send:n}).then(function(){return c?h.resolve():h},function(S){throw new Error("Send request message failed for "+f+" in "+M()+`
19
+ `+fn(u))}}),x.try(function(){if(!a)throw new Error("No handler found for post message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);return a.handler({source:n,origin:t,data:e.data})}).then(function(u){return c("success",u)},function(u){return c("error",null,u)})]).then(Q).catch(function(u){if(a&&a.handleError)return a.handleError(u);throw u})}function ht(n,t,e){if(!We(e.hash)){var r=ye(e.hash);if(!r)throw new Error("No handler found for post message ack for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);try{if(!tn(r.domain,t))throw new Error("Ack origin "+t+" 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,t,e){if(!We(e.hash)){var r=ye(e.hash);if(!r)throw new Error("No handler found for post message response for message: "+e.name+" from "+t+" in "+window.location.protocol+"//"+window.location.host+window.location.pathname);if(!tn(r.domain,t))throw new Error("Response origin "+t+" does not match domain "+(o=r.domain,Array.isArray(o)?"("+o.join(" | ")+")":w(o)?"RegExp("+o.toString()+")":o.toString()));var o;if(n!==r.win)throw new Error("Response source does not match registered window");Ee(e.hash),e.ack==="error"?r.promise.reject(e.error):e.ack==="success"&&r.promise.resolve({source:n,origin:t,data:e.data})}}function be(n,t){var e=t.on,r=t.send,o=j("receivedMessages");try{if(!window||window.closed||!n.source)return}catch{return}var i=n.source,a=n.origin,s=function(l,d,f,h){var E=h.on,g=h.send,y;try{y=ge(d,f,l,{on:E,send:g})}catch{return}if(y&&typeof y=="object"&&y!==null){var P=y.__post_robot_10_0_46__;if(Array.isArray(P))return P}}(n.data,i,a,{on:e,send:r});if(s){le(i);for(var c=0;c<s.length;c++){var u=s[c];if(o.has(u.id)||(o.set(u.id,!0),G(i)&&!u.fireAndForget))return;u.origin.indexOf("file:")===0&&(a="file://");try{u.type==="postrobot_message_request"?lt(i,a,u,{on:e,send:r}):u.type==="postrobot_message_response"?vt(i,a,u):u.type==="postrobot_message_ack"&&ht(i,a,u)}catch(l){setTimeout(function(){throw l},0)}}}}function k(n,t,e){if(!n)throw new Error("Expected name");if(typeof(t=t||{})=="function"&&(e=t,t={}),!e)throw new Error("Expected handler");var r=function o(i,a){var s=i.name,c=i.win,u=i.domain,l=U("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(T){return o({name:s,win:T,domain:u},a)});return{cancel:function(){d.then(function(T){return T.cancel()},Q)}}}var f=c;if(Array.isArray(f)){for(var h=[],E=0,g=f;E<g.length;E++)h.push(o({name:s,domain:u,win:g[E]},a));return{cancel:function(){for(var T=0;T<h.length;T++)h[T].cancel()}}}if(Array.isArray(u)){for(var y=[],P=0,C=u;P<C.length;P++)y.push(o({name:s,win:f,domain:C[P]},a));return{cancel:function(){for(var T=0;T<y.length;T++)y[T].cancel()}}}var O=Se({name:s,win:f,domain:u});f&&f!=="*"||(f=bn());var I=(u=u||"*").toString();if(O)throw f&&u?new Error("Request listener already exists for "+s+" on domain "+u.toString()+" for "+(f===bn()?"wildcard":"specified")+" window"):f?new Error("Request listener already exists for "+s+" for "+(f===bn()?"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 z=l.getOrSet(f,function(){return{}}),b=ln(z,s,function(){return{}}),D,q;return Nn(u)?(D=ln(b,"__domain_regex__",function(){return[]})).push(q={regex:u,listener:a}):b[I]=a,{cancel:function(){delete b[I],q&&(D.splice(D.indexOf(q,1)),D.length||delete b.__domain_regex__),Object.keys(b).length||delete z[s],f&&!Object.keys(z).length&&l.del(f)}}}({name:n,win:t.window,domain:t.domain||"*"},{handler:e||t.handler,handleError:t.errorHandler||function(o){throw o}});return{cancel:function(){r.cancel()}}}function wt(n,t,e){typeof(t=t||{})=="function"&&(e=t,t={});var r=new x,o;return t.errorHandler=function(i){o.cancel(),r.reject(i)},o=k(n,t,function(i){if(o.cancel(),r.resolve(i),e)return e(i)}),r.cancel=o.cancel,r}var Y=function n(t,e,r,o){var i=(o=o||{}).domain||"*",a=o.timeout||-1,s=o.timeout||5e3,c=o.fireAndForget||!1;return B.toProxyWindow(t,{send:n}).awaitWindow().then(function(u){return x.try(function(){if(function(l,d,f){if(!l)throw new Error("Expected name");if(f&&typeof f!="string"&&!Array.isArray(f)&&!Nn(f))throw new TypeError("Can not send "+l+". Expected domain "+JSON.stringify(f)+" to be a string, array, or regex");if(G(d))throw new Error("Can not send "+l+". Target window is closed")}(e,u,i),function(l,d){var f=Yn(d);if(f)return f===l;if(d===l||function(g){g===void 0&&(g=window);try{if(g.top)return g.top}catch{}if(V(g)===g)return g;try{if(Zn(window,g)&&window.top)return window.top}catch{}try{if(Zn(g,window)&&window.top)return window.top}catch{}for(var y=0,P=function O(I){for(var z=[],b=0,D=kn(I);b<D.length;b++){var q=D[b];z.push(q);for(var T=0,vn=O(q);T<vn.length;T++)z.push(vn[T])}return z}(g);y<P.length;y++){var C=P[y];try{if(C.top)return C.top}catch{}if(V(C)===C)return C}}(d)===d)return!1;for(var h=0,E=kn(l);h<E.length;h++)if(E[h]===d)return!0;return!1}(window,u))return function(l,d,f){d===void 0&&(d=5e3),f===void 0&&(f="Window");var h=function(E){return U("helloPromises").getOrSet(E,function(){return new x})}(l);return d!==-1&&(h=h.timeout(d,new Error(f+" did not load after "+d+"ms"))),h}(u,s)}).then(function(l){return function(d,f,h,E){var g=E.send;return x.try(function(){return typeof f=="string"?f:x.try(function(){return h||Tn(d,{send:g}).then(function(y){return y.domain})}).then(function(y){if(!tn(f,f))throw new Error("Domain "+oe(f)+" does not match "+oe(f));return y})})}(u,i,(l===void 0?{}:l).domain,{send:n})}).then(function(l){var d=l,f=e==="postrobot_method"&&r&&typeof r.name=="string"?r.name+"()":e,h=new x,E=e+"_"+J();if(!c){var g={name:e,win:u,domain:d,promise:h};(function(b,D){j("responseListeners").set(b,D)})(E,g);var y=U("requestPromises").getOrSet(u,function(){return[]});y.push(h),h.catch(function(){(function(b){j("erroredResponseListeners").set(b,!0)})(E),Ee(E)});var P=function(b){return U("knownWindows").get(b,!1)}(u)?1e4:2e3,C=a,O=P,I=C,z=function(b,D){var q;return function T(){q=setTimeout(function(){(function(){if(G(u))return h.reject(new Error("Window closed for "+e+" before "+(g.ack?"response":"ack")));if(g.cancelled)return h.reject(new Error("Response listener was cancelled for "+e));O=Math.max(O-500,0),I!==-1&&(I=Math.max(I-500,0)),g.ack||O!==0?I===0&&h.reject(new Error("No response for postMessage "+f+" in "+L()+" in "+C+"ms")):h.reject(new Error("No ack for postMessage "+f+" in "+L()+" in "+P+"ms"))})(),T()},500)}(),{cancel:function(){clearTimeout(q)}}}();h.finally(function(){z.cancel(),y.splice(y.indexOf(h,1))}).catch(Q)}return Ln(u,d,{id:J(),origin:L(window),type:"postrobot_message_request",hash:E,name:e,data:r,fireAndForget:c},{on:k,send:n}).then(function(){return c?h.resolve():h},function(b){throw new Error("Send request message failed for "+f+" in "+L()+`
16
20
 
17
- `+sn(S))})})})};function ot(n,t,e){return fe(n,t,e,{on:V,send:$})}function it(n,t,e){return le(n,t,e,{on:V,send:$})}function at(n){return new B({send:$,win:n})}function ut(n){return B.toProxyWindow(n,{send:$})}function ge(){fn().initialized||(fn().initialized=!0,t=(n={on:V,send:$}).on,e=n.send,(r=fn()).receiveMessage=r.receiveMessage||function(o){return pe(o,{on:t,send:e})},function(o){var i=o.on,a=o.send;j().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 l=u.on,d=u.send;b.try(function(){var f=c.source||c.sourceElement,h=c.origin||c.originalEvent&&c.originalEvent.origin,g=c.data;if(h==="null"&&(h="file://"),f){if(!h)throw new Error("Post message did not have origin domain");pe({source:f,origin:h,data:g},{on:l,send:d})}})})(s,{on:i,send:a})})})}({on:V,send:$}),function(o){var i=o.on,a=o.send;j("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return oe(u.source,{domain:u.origin}),{instanceID:re()}}),c=qn();return c&&Rn(c,{send:a}).catch(function(u){}),s})}({on:V,send:$}));var n,t,e,r}function ct(){(function(){for(var t=j("responseListeners"),e=0,r=t.keys();e<r.length;e++){var o=r[e],i=t.get(o);i&&(i.cancelled=!0),t.del(o)}})(),(n=j().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var st=!0;function dt(n){for(var t=0,e=L("requestPromises").get(n,[]);t<e.length;t++)e[t].reject(new Error("Window "+(G(n)?"closed":"cleaned up")+" before response")).catch(_)}ge()}])})})(Un);var He=Un.exports;(function(E){E.exports=He,E.exports.default=E.exports})(Fn);var Hn=Fn.exports;const Be=A({__proto__:null,default:Ue(Hn)},[Hn]);D.SoyioTypes=Le,D.SoyioWidget=Ln,D.default=Ln,Object.defineProperties(D,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
21
+ `+fn(b))})})})};function mt(n,t,e){return pe(n,t,e,{on:k,send:Y})}function pt(n,t,e){return ge(n,t,e,{on:k,send:Y})}function gt(n){return new B({send:Y,win:n})}function yt(n){return B.toProxyWindow(n,{send:Y})}function xe(){hn().initialized||(hn().initialized=!0,t=(n={on:k,send:Y}).on,e=n.send,(r=hn()).receiveMessage=r.receiveMessage||function(o){return be(o,{on:t,send:e})},function(o){var i=o.on,a=o.send;j().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 l=u.on,d=u.send;x.try(function(){var f=c.source||c.sourceElement,h=c.origin||c.originalEvent&&c.originalEvent.origin,E=c.data;if(h==="null"&&(h="file://"),f){if(!h)throw new Error("Post message did not have origin domain");be({source:f,origin:h,data:E},{on:l,send:d})}})})(s,{on:i,send:a})})})}({on:k,send:Y}),function(o){var i=o.on,a=o.send;j("builtinListeners").getOrSet("helloListener",function(){var s=i("postrobot_hello",{domain:"*"},function(u){return de(u.source,{domain:u.origin}),{instanceID:se()}}),c=Yn();return c&&Tn(c,{send:a}).catch(function(u){}),s})}({on:k,send:Y}));var n,t,e,r}function Et(){(function(){for(var t=j("responseListeners"),e=0,r=t.keys();e<r.length;e++){var o=r[e],i=t.get(o);i&&(i.cancelled=!0),t.del(o)}})(),(n=j().get("postMessageListener"))&&n.cancel();var n;delete window.__post_robot_10_0_46__}var Wt=!0;function St(n){for(var t=0,e=U("requestPromises").get(n,[]);t<e.length;t++)e[t].reject(new Error("Window "+(G(n)?"closed":"cleaned up")+" before response")).catch(Q)}xe()}])})})($n);var Qe=$n.exports;(function(v){v.exports=Qe,v.exports.default=v.exports})(qn);var Jn=qn.exports;const _n=A({__proto__:null,default:Ke(Jn)},[Jn]);R.ConsentRequestBox=Fe,R.SoyioTypes=He,R.SoyioWidget=Gn,R.default=Gn,Object.defineProperties(R,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soyio/soyio-widget",
3
- "version": "2.1.0",
3
+ "version": "2.3.0",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.cjs",
6
6
  "module": "./dist/index.js",