@myop/sdk 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled-declarations.d.ts +27 -200
- package/dist/cjs/{_IframeSDK.012474c1.min.js → _IframeSDK.2f50c32c.min.js} +1 -1
- package/dist/cjs/{_IframeSDK.c7f71dba.js → _IframeSDK.b80455bf.js} +45 -31
- package/dist/cjs/{_IframeSDK.c7f71dba.js.map → _IframeSDK.b80455bf.js.map} +3 -3
- package/dist/cjs/_MyopHelpers.3d50ac48.min.js +1 -0
- package/dist/cjs/_MyopHelpers.7baba8b8.js +462 -0
- package/dist/cjs/_MyopHelpers.7baba8b8.js.map +7 -0
- package/dist/cjs/{_WebComponentSDK.15ffefb6.min.js → _WebComponentSDK.37374c87.min.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.93d3959a.js → _WebComponentSDK.687ea8cb.js} +45 -31
- package/dist/cjs/{_WebComponentSDK.93d3959a.js.map → _WebComponentSDK.687ea8cb.js.map} +3 -3
- package/dist/cjs/{_hostSDK.a852b7b7.min.js → _hostSDK.48a55f66.min.js} +1 -1
- package/dist/cjs/{_hostSDK.eeb98d7f.js → _hostSDK.e09022f6.js} +45 -31
- package/dist/cjs/{_hostSDK.eeb98d7f.js.map → _hostSDK.e09022f6.js.map} +3 -3
- package/dist/cjs/myop_sdk.js +14 -14
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +3947 -0
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +7 -0
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -0
- package/dist/module/Iframe/index.js +49 -33
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +52 -120
- package/dist/module/SDK.js.map +3 -3
- package/dist/module/helpers/CloudRepository.d.ts +27 -185
- package/dist/module/helpers/index.d.ts +0 -1
- package/dist/module/helpers/index.js +52 -2521
- package/dist/module/helpers/index.js.map +4 -4
- package/dist/module/host/index.js +49 -33
- package/dist/module/host/index.js.map +3 -3
- package/dist/module/webcomponent/index.js +49 -33
- package/dist/module/webcomponent/index.js.map +3 -3
- package/package.json +1 -1
- package/dist/cjs/_MyopHelpers.75e0fd8d.js +0 -2810
- package/dist/cjs/_MyopHelpers.75e0fd8d.js.map +0 -7
- package/dist/cjs/_MyopHelpers.ecfd80d9.min.js +0 -1
- package/dist/module/helpers/enableV2.d.ts +0 -12
|
@@ -1436,220 +1436,48 @@ declare module "@myop/sdk/helpers/configBuilder" {
|
|
|
1436
1436
|
}
|
|
1437
1437
|
}
|
|
1438
1438
|
declare module "@myop/sdk/helpers/CloudRepository" {
|
|
1439
|
-
import { IUserFlow } from "@myop/sdk/common";
|
|
1439
|
+
import { IUserFlow, v2_IVariantConfig } from "@myop/sdk/common";
|
|
1440
1440
|
/**
|
|
1441
|
+
* CloudRepository - Unified cloud data access layer for Myop components
|
|
1441
1442
|
*
|
|
1442
|
-
*
|
|
1443
|
-
*
|
|
1444
|
-
*
|
|
1445
|
-
*
|
|
1446
|
-
* ## Class Structure
|
|
1447
|
-
*
|
|
1448
|
-
* ### Constructor
|
|
1449
|
-
*
|
|
1450
|
-
* ```typescript
|
|
1451
|
-
* constructor(private _baseUrl = 'https://cloud.myop.dev')
|
|
1452
|
-
* ```
|
|
1453
|
-
*
|
|
1454
|
-
* **Parameters:**
|
|
1455
|
-
* - `_baseUrl` (optional): The base URL for the Myop.dev cloud API. Defaults to `'https://cloud.myop.dev'`
|
|
1456
|
-
*
|
|
1457
|
-
* ### Static Properties
|
|
1458
|
-
*
|
|
1459
|
-
* #### Main
|
|
1460
|
-
* ```typescript
|
|
1461
|
-
* static Main = new CloudRepository();
|
|
1462
|
-
* ```
|
|
1463
|
-
*
|
|
1464
|
-
* A singleton instance of the `CloudRepository` class that can be used throughout the application without creating multiple instances.
|
|
1465
|
-
*
|
|
1466
|
-
* ### Private Properties
|
|
1467
|
-
*
|
|
1468
|
-
* #### userFlows
|
|
1469
|
-
* ```typescript
|
|
1470
|
-
* private userFlows: Record<string, Promise<IUserFlow>> = {};
|
|
1471
|
-
* ```
|
|
1472
|
-
*
|
|
1473
|
-
* A cache object that stores promises for user flows, indexed by flow ID. This prevents duplicate API calls for the same flow and ensures consistent data retrieval.
|
|
1474
|
-
*
|
|
1475
|
-
* #### _baseUrl
|
|
1476
|
-
* ```typescript
|
|
1477
|
-
* private _baseUrl: string
|
|
1478
|
-
* ```
|
|
1479
|
-
*
|
|
1480
|
-
* The base URL for the cloud API endpoints, set during construction.
|
|
1481
|
-
*
|
|
1482
|
-
* ## Methods
|
|
1483
|
-
*
|
|
1484
|
-
* ### fetchFlow(flowId: string)
|
|
1485
|
-
*
|
|
1486
|
-
* Retrieves a complete user flow from the cloud repository, including all resolved components.
|
|
1487
|
-
*
|
|
1488
|
-
* **Parameters:**
|
|
1489
|
-
* - `flowId`: The unique identifier for the user flow to retrieve
|
|
1490
|
-
*
|
|
1491
|
-
* **Returns:**
|
|
1492
|
-
* - `Promise<IUserFlow>`: A promise that resolves to the complete user flow object
|
|
1493
|
-
*
|
|
1494
|
-
* **Behavior:**
|
|
1495
|
-
* - Implements request caching to avoid duplicate API calls for the same flow ID
|
|
1496
|
-
* - Makes a GET request to `/flow?id={flowId}&resolve=components`
|
|
1497
|
-
* - Automatically resolves component references within the flow
|
|
1498
|
-
* - Stores the promise in the cache for future use
|
|
1499
|
-
*
|
|
1500
|
-
* **Example Usage:**
|
|
1501
|
-
* ```typescript
|
|
1502
|
-
* const flow = await CloudRepository.Main.fetchFlow('my-flow-id');
|
|
1503
|
-
* console.log(flow.components);
|
|
1504
|
-
* ```
|
|
1505
|
-
*
|
|
1506
|
-
* ### fetchComponent(componentId: string, flowId: string)
|
|
1507
|
-
*
|
|
1508
|
-
* Retrieves a specific component from within a user flow.
|
|
1509
|
-
*
|
|
1510
|
-
* **Parameters:**
|
|
1511
|
-
* - `componentId`: The unique identifier for the component to retrieve
|
|
1512
|
-
* - `flowId`: The unique identifier for the user flow containing the component
|
|
1513
|
-
*
|
|
1514
|
-
* **Returns:**
|
|
1515
|
-
* - `Promise<Component | undefined>`: A promise that resolves to the component object if found, or undefined if not found
|
|
1516
|
-
*
|
|
1517
|
-
* **Behavior:**
|
|
1518
|
-
* - First fetches the complete flow using `fetchFlow()`
|
|
1519
|
-
* - Searches through the flow's components array to find the matching component
|
|
1520
|
-
* - Uses the component's `type.id` property for matching
|
|
1521
|
-
*
|
|
1522
|
-
* **Example Usage:**
|
|
1523
|
-
* ```typescript
|
|
1524
|
-
* const component = await CloudRepository.Main.fetchComponent('button-component', 'my-flow-id');
|
|
1525
|
-
* if (component) {
|
|
1526
|
-
* console.log('Component found:', component);
|
|
1527
|
-
* } else {
|
|
1528
|
-
* console.log('Component not found in flow');
|
|
1529
|
-
* }
|
|
1530
|
-
* ```
|
|
1531
|
-
*
|
|
1532
|
-
* ## API Integration
|
|
1533
|
-
*
|
|
1534
|
-
* ### Endpoint Structure
|
|
1535
|
-
*
|
|
1536
|
-
* The class integrates with the following Myop.dev cloud API endpoint:
|
|
1537
|
-
*
|
|
1538
|
-
* ```
|
|
1539
|
-
* GET {baseUrl}/flow?id={flowId}&resolve=components
|
|
1540
|
-
* ```
|
|
1541
|
-
*
|
|
1542
|
-
* **Query Parameters:**
|
|
1543
|
-
* - `id`: The flow identifier
|
|
1544
|
-
* - `resolve=components`: Instructs the API to include resolved component data in the response
|
|
1545
|
-
*
|
|
1546
|
-
* ### Response Format
|
|
1547
|
-
*
|
|
1548
|
-
* The API is expected to return a JSON response with the following structure:
|
|
1549
|
-
*
|
|
1550
|
-
* ```json
|
|
1551
|
-
* {
|
|
1552
|
-
* "item": {
|
|
1553
|
-
* // IUserFlow object with resolved components
|
|
1554
|
-
* "components": [
|
|
1555
|
-
* {
|
|
1556
|
-
* "type": {
|
|
1557
|
-
* "id": "component-id"
|
|
1558
|
-
* }
|
|
1559
|
-
* // ... other component properties
|
|
1560
|
-
* }
|
|
1561
|
-
* ]
|
|
1562
|
-
* // ... other flow properties
|
|
1563
|
-
* }
|
|
1564
|
-
* }
|
|
1565
|
-
* ```
|
|
1566
|
-
*
|
|
1567
|
-
* ## Caching Strategy
|
|
1568
|
-
*
|
|
1569
|
-
* The `CloudRepository` implements a promise-based caching mechanism:
|
|
1570
|
-
*
|
|
1571
|
-
* 1. **Cache Key**: Flow ID is used as the cache key
|
|
1572
|
-
* 2. **Cache Value**: Promises are cached rather than resolved values to handle concurrent requests
|
|
1573
|
-
* 3. **Cache Duration**: Cache persists for the lifetime of the repository instance
|
|
1574
|
-
* 4. **Cache Invalidation**: No automatic cache invalidation is implemented
|
|
1575
|
-
*
|
|
1576
|
-
* ## Error Handling
|
|
1577
|
-
*
|
|
1578
|
-
* - Network errors and API failures are propagated through promise rejection
|
|
1579
|
-
* - No specific error handling or retry logic is implemented at the repository level
|
|
1580
|
-
* - Consumers should implement appropriate error handling when calling repository methods
|
|
1581
|
-
*
|
|
1582
|
-
* ## Usage Patterns
|
|
1583
|
-
*
|
|
1584
|
-
* ### Singleton Access
|
|
1585
|
-
* ```typescript
|
|
1586
|
-
* import { CloudRepository } from './path/to/CloudRepository';
|
|
1587
|
-
*
|
|
1588
|
-
* // Use the singleton instance
|
|
1589
|
-
* const flow = await CloudRepository.Main.fetchFlow('flow-id');
|
|
1590
|
-
* ```
|
|
1591
|
-
*
|
|
1592
|
-
* ### Custom Instance
|
|
1593
|
-
* ```typescript
|
|
1594
|
-
* // Create a custom instance with different base URL
|
|
1595
|
-
* const customRepo = new CloudRepository('https://custom-api.example.com');
|
|
1596
|
-
* const flow = await customRepo.fetchFlow('flow-id');
|
|
1597
|
-
* ```
|
|
1598
|
-
*
|
|
1599
|
-
* ### Component Retrieval
|
|
1600
|
-
* ```typescript
|
|
1601
|
-
* // Get a specific component from a flow
|
|
1602
|
-
* const component = await CloudRepository.Main.fetchComponent('component-id', 'flow-id');
|
|
1603
|
-
* ```
|
|
1604
|
-
*
|
|
1605
|
-
* ## Dependencies
|
|
1606
|
-
*
|
|
1607
|
-
* - **IUserFlow**: Interface imported from `../common` that defines the structure of user flow objects
|
|
1608
|
-
* - **Fetch API**: Uses the native `fetch` function for HTTP requests
|
|
1609
|
-
*
|
|
1610
|
-
* ## Performance Considerations
|
|
1611
|
-
*
|
|
1612
|
-
* - **Caching**: Prevents duplicate API calls for the same flow ID
|
|
1613
|
-
* - **Promise Caching**: Handles concurrent requests efficiently by caching promises
|
|
1614
|
-
* - **Component Resolution**: The `resolve=components` parameter ensures components are fully resolved in a single API call
|
|
1615
|
-
*
|
|
1616
|
-
* ## Future Enhancements
|
|
1617
|
-
*
|
|
1618
|
-
* The class structure suggests planned functionality that could be implemented:
|
|
1619
|
-
*
|
|
1620
|
-
* - **Component Caching**: The commented `components` property indicates potential individual component caching
|
|
1621
|
-
* - **Cache Invalidation**: Methods to clear or refresh cached data
|
|
1622
|
-
* - **Error Retry Logic**: Automatic retry mechanisms for failed requests
|
|
1623
|
-
* - **Batch Operations**: Methods to fetch multiple flows or components in a single request
|
|
1624
|
-
*
|
|
1443
|
+
* Supports both v2 (default) and v1 modes:
|
|
1444
|
+
* - v2: Uses /consume endpoint for fetching variants
|
|
1445
|
+
* - v1: Uses /flow endpoint for fetching user flows
|
|
1625
1446
|
*/
|
|
1626
1447
|
export class CloudRepository {
|
|
1627
1448
|
private _baseUrl;
|
|
1628
1449
|
static Main: CloudRepository;
|
|
1450
|
+
private variants;
|
|
1629
1451
|
private userFlows;
|
|
1630
1452
|
constructor(_baseUrl?: string);
|
|
1631
|
-
|
|
1453
|
+
/**
|
|
1454
|
+
* Check if a component is already cached/preloaded (v2)
|
|
1455
|
+
*/
|
|
1456
|
+
isPreloaded(componentId: string): boolean;
|
|
1457
|
+
/**
|
|
1458
|
+
* Fetch a v2 component variant
|
|
1459
|
+
*/
|
|
1460
|
+
fetchComponentV2(componentId: string, environmentIdentifier?: string): Promise<v2_IVariantConfig>;
|
|
1461
|
+
/**
|
|
1462
|
+
* Fetch a v1 component from a flow
|
|
1463
|
+
*/
|
|
1464
|
+
fetchComponentV1(componentId: string, flowId?: string): Promise<import("common").IComponentConfig>;
|
|
1632
1465
|
fetchAutoFlow(componentId: string): Promise<IUserFlow>;
|
|
1633
1466
|
fetchFlow(flowId: string): Promise<IUserFlow>;
|
|
1467
|
+
/**
|
|
1468
|
+
* @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly
|
|
1469
|
+
* Defaults to v1 behavior for backward compatibility with existing code
|
|
1470
|
+
*/
|
|
1471
|
+
fetchComponent(componentId: string, flowId?: string): Promise<import("common").IComponentConfig>;
|
|
1634
1472
|
}
|
|
1473
|
+
/**
|
|
1474
|
+
* @deprecated Use CloudRepository instead
|
|
1475
|
+
*/
|
|
1476
|
+
export const v2_CloudRepository: typeof CloudRepository;
|
|
1635
1477
|
}
|
|
1636
1478
|
declare module "@myop/sdk/helpers/exec" {
|
|
1637
1479
|
export const exec: (getter: any) => Promise<any>;
|
|
1638
1480
|
}
|
|
1639
|
-
declare module "@myop/sdk/helpers/enableV2" {
|
|
1640
|
-
import { v2_IVariantConfig } from "@myop/sdk/common";
|
|
1641
|
-
import { loaderOptions } from "@myop/sdk/host/hostSDK";
|
|
1642
|
-
export class v2_CloudRepository {
|
|
1643
|
-
private _baseUrl;
|
|
1644
|
-
static Main: v2_CloudRepository;
|
|
1645
|
-
private variants;
|
|
1646
|
-
constructor(_baseUrl?: string);
|
|
1647
|
-
fetchComponent(componentId: string, environmentIdentifier?: string): Promise<v2_IVariantConfig>;
|
|
1648
|
-
}
|
|
1649
|
-
export const enableV2: (environmentIdentifier: string, cloudRepository?: v2_CloudRepository) => {
|
|
1650
|
-
loadComponent: (componentId: string, container: HTMLElement, options?: loaderOptions) => Promise<import("host").IMyopComponent<any, any>>;
|
|
1651
|
-
};
|
|
1652
|
-
}
|
|
1653
1481
|
declare module "@myop/sdk/helpers" {
|
|
1654
1482
|
export * from "@myop/sdk/helpers/applyStylesheet";
|
|
1655
1483
|
export * from "@myop/sdk/helpers/iframeSkinUrlTokenizer";
|
|
@@ -1657,7 +1485,6 @@ declare module "@myop/sdk/helpers" {
|
|
|
1657
1485
|
export * from "@myop/sdk/helpers/configBuilder";
|
|
1658
1486
|
export * from "@myop/sdk/helpers/CloudRepository";
|
|
1659
1487
|
export * from "@myop/sdk/helpers/exec";
|
|
1660
|
-
export * from "@myop/sdk/helpers/enableV2";
|
|
1661
1488
|
}
|
|
1662
1489
|
declare module "@myop/sdk/host/myopOverride" {
|
|
1663
1490
|
import { IComponentConfig } from "@myop/sdk/common";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var xt=Object.defineProperty,Gt=Object.defineProperties;var Jt=Object.getOwnPropertyDescriptors;var Ct=Object.getOwnPropertySymbols;var Xt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable;var Qe=(o,n,e)=>n in o?xt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))Xt.call(n,e)&&Qe(o,e,n[e]);if(Ct)for(var e of Ct(n))Qt.call(n,e)&&Qe(o,e,n[e]);return o},B=(o,n)=>Gt(o,Jt(n));var Zt=(o,n)=>{for(var e in n)xt(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>Qe(o,typeof n!="symbol"?n+"":n,e);var j=class{constructor(n,e,t,r,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var bt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},h=class{constructor(n){this.messageToHost=n}},fe=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var c={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var ge={};Zt(ge,{AddEventListenerMessage:()=>nt,BaseMyopMessage:()=>M,BindClickMessage:()=>et,ChangeTextMessage:()=>tt,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>A,CreateRefComponentMessage:()=>ne,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>it,DetectedMyopRefsMessage:()=>V,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>z,EnvelopedMessage:()=>oe,EventListenerCallbackMessage:()=>U,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>F,GetAttributeMessage:()=>at,GetAttributeReplayMessage:()=>se,GetElementValueMessage:()=>st,InitMessage:()=>G,InitRequest:()=>N,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>re,MyopBindMessage:()=>T,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>Ye,Ref:()=>_,RefComponentCreatedMessage:()=>D,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>ot,SetInnerHtml:()=>rt,SetMutationObserverMessage:()=>pt,SetResizeObserverMessage:()=>mt,stripFunction:()=>Et});var v=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Yt=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var en=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Ze=o=>{let n=en(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Yt(n.slice(t,t+16)));return e};var wt=o=>new Promise(n=>setTimeout(n,o));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",v());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Ye=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},T=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",v())}},_=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=B(y({},this),{component:null})}static create(n,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(r,t)}};var Tt="ClickReplayMessage",et=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Tt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},A=class extends w{constructor(){super(...arguments);s(this,"messageType",Tt)}};var tt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var St="ExecuteScriptReplyMessage",tn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,nn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Et=o=>{let n=o.match(tn);if(n)return n[1]||n[3];{let e=o.match(nn);if(e)return e[1].trim()}},E=class extends T{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",St);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Et(this.content)}};s(E,"replierKey","send"),s(E,"completeStreamKey","completeStream");var F=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",St)}};var $=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(m.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=B(y({},t),{_script:e.toString()})}};var Rt="EventListenerCallbackMessage",nt=class extends T{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Rt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},U=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Rt);this.content={e:t}}};var ot=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var vt="ElementValueReplayMessage",st=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",vt);s(this,"messageType","GetElementValueMessage")}},z=class extends w{constructor(e){super();this.content=e;s(this,"messageType",vt)}};var rt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var G=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends G{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},N=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var kt="RefComponentCreatedMessage",ne=class extends T{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",kt);s(this,"messageType","CreateRefComponentMessage")}},D=class extends w{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",kt)}};var oe=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Ht="DetectedMyopRefsMessage",it=class extends T{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Ht)}},V=class extends w{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Ht);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Bt="GetAttributeReplayMessage",at=class extends T{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",Bt);s(this,"messageType","GetAttributeMessage")}},se=class extends w{constructor(e){super();this.content=e;s(this,"messageType",Bt)}};var k=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var pt=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},re=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Dt="CleanupReplayMessage",ie=class extends T{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Dt);s(this,"messageType","CleanupMessage")}},ae=class extends w{constructor(e){super();this.customCleanup=e;s(this,"messageType",Dt)}};var pe=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var mt=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},me=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var dt=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},J=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===c.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===c.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new dt(r),this.messageToHost(new te(r));return}if(t.messageType===c.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(m=>m.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(m=>m.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===c.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],bt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var L={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ue={message:"message",code:"code"},X=class{};s(X,"code","code"),s(X,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ye={Segment:"Segment",Promo:"Promo",AB:"AB"},Q=class{constructor(n,e){this.container=n;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var he=class extends h{constructor(){super(...arguments);s(this,"messageType",c.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new j(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new V(e.handlerUniqueId,r))})}};var I=(o,n)=>n.querySelectorAll("[".concat(S.id,"='").concat(o.refConfig.selector,"']")),Lt=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Me=class extends h{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new A,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Ie=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var ct=o=>o!==Object(o),on=o=>typeof o=="function",lt=o=>{if(ct(o))return!0;if(on(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!lt(e))return!1}else{if(ct(e))continue;return!1}}return!0},R=(o,n={},e=!0,t=new WeakMap)=>{if(ct(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let r=[];t.set(o,r);for(let i=0;i<o.length;i++){let a=o[i];r[i]=R(a,n,e,t)}return r}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let r={};t.set(o,r);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(r[i]=R(o[i],!0,e,t)):typeof a=="object"&&(r[i]=R(o[i],a,e,t)))}return r}return{}};var Ce=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=R,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var xe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"executor",e=>{Ce(e,r=>{this.messageToHost(new F(e.handlerUniqueId,r))},new Q(document.documentElement))})}};var be="__federation__",_t="onLoad";var Z=(o,n)=>{window[be]&&window[be][o]&&window[be][o][_t]&&window[be][o][_t]({[o]:n})};var we=class extends h{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new U(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Te=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var P=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});s(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let r=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(n);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===c.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,r=>r.replayToHandler===n.handlerUniqueId,r=>{n.handler(r),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new ie(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Pt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var de=class extends P{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new oe(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var sn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},Se=(o,n,e,t,r,i)=>{let a=sn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},Ot=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Kt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},At=(o,n,e)=>{let t=n.reduce((i,a)=>B(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Ot(p,a,o))return!1;if(p.behavior.type===ue.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let d=p.behavior;return o.element.contentWindow[d.remap||a]}return Kt(p,a,o),!1}return p.mode==="output"?new Promise(m=>{let d=[];p.behavior.ref&&d.push(_.create(p.behavior.ref)),d.push(f=>{m(f)}),p.behavior.params&&d.push(...p.behavior.params);let l=ge[p.behavior.message];o.send(new l(...d))}):null},set:(i,a,p)=>{let m=t[a];if(Ot(m,a,o))return!1;if(m.behavior.type===ue.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let l=m.behavior;return o.element.contentWindow[l.remap||a]=p,!0}return Kt(m,a,o),!1}else if(m.mode==="input")if(m.behavior.type==="message"){let d=[];m.behavior.ref&&d.push(_.create(m.behavior.ref)),d.push(p),m.behavior.params&&d.push(...m.behavior.params);let l=ge[m.behavior.message];return o.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(m.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},rn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{lt(p)||Pt.notSerializableRefCall(t,p)}),n.send(new $(({ref:p,propName:m,functionArgs:d,makeSerializable:l})=>{if(p){let f=p[m];return l(typeof f=="function"?p[m](...d):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),ft=async(o,n,e,t)=>{let r=o.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(n.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new ne(o.refConfig,n,B(y({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(m),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(f=>f.id==p.id);if(l!==p){r.refs[o.refConfig.name]=l,i(l);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;d.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(x=>x.type.id===f.componentDefinitionId).type,u=new de(g,p);u.setInitiated(),p.refs[f.refName]=u,e.push(u)});try{await gt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},gt=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let r=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==X.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(m=n.instance.resolvedNestedComponents)==null?void 0:m.find(g=>g.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=_.create("",i,o);try{let g=await ft(f,l,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let d=_.create("",i,o);o.refs[i.name]=rn(d,o),a()}catch(d){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new E(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:m}=document.documentElement.getBoundingClientRect();t({height:p,width:m})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new E(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});s(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new E(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===c.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Se(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===c.In.MutationObserverMessage||e.messageType===c.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){s(this,"appendChild",(n,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var an=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Ee=class extends O{constructor(){super(...arguments);s(this,"type",L.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),d="myop-comp-".concat(m);a=document.createElement("iframe"),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(a.style.visibility="hidden"),a=this.appendChild(r,a,i);let l=t.loader.url;i!=null&&i._hasParent&&(l=an(l,"_myop-comp",m));let f="";i!=null&&i.elementAttributes&&(f=Object.entries(i==null?void 0:i.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(d,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",';\n "\n src="').concat(l,'"\n ').concat(f,"\n ></iframe>"),a=r.querySelector("#".concat(d))}return new Y(e,t,r,a,i)})}};var Re={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Re.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=Se(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var ut={},ve=class extends O{constructor(){super(...arguments);s(this,"type",L.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;ut[a.url]?console.log("Module alreday loaded or in loading process"):ut[a.url]=new Promise((d,l)=>{let f=a.url,g=document.createElement("script");g.type="module",g.src=f,g.onload=()=>{d()},g.onerror=()=>{l()},document.head.appendChild(g)}),await ut[a.url],await wt(1);let p="myop-comp-".concat(v()),m=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),i!=null&&i._environment&&(m._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ke="0.2.3";var C=class extends fe{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(B(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var He=class extends C{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new A(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var Be=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var De=class extends Q{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Le=class extends C{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(S.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(S.id);p&&i.push(new j(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new V(e.handlerUniqueId,i))});s(this,"messageType",c.DetectMyopRefsMessage)}};var _e=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Pe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=d=>{r(new U(e.handlerUniqueId,R(d,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Oe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=H.Instance(),m=p.components.find(g=>g.id===e.options.id);m&&m.dispose();let d=p.components.indexOf(m);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(l.refs).forEach(g=>{let u=l.refs[g];u=u.__nonProxied||u,u.componentDefinition&&f.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new D(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{Ce(e,a=>{r(new F(e.handlerUniqueId,a))},t)})}};var Ft=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Ft(i),required:i.required,validity:R(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(m):(e.unmappedData.push(e.formData[p]),e.formData[p]=m):e.formData[p]=m:e.unmappedData.push(m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ae=class extends C{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new z(Ft(a)),e)})})}};var Fe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends J{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Re.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===c.InitMessage){let p=a.content.id;this.components[p].context=new De(e,t)}}}),setTimeout(()=>{this.messageToHost(new N)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new Be(this.messageToHost,this.components),new Fe(this.messageToHost,this.components),new He(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Pe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new Oe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};Z("WebComponentSDK",ce);var $t=[],$e,Ut=async()=>($e||($e=new ce,$e.init()),$e);function pn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===q.open?"open":"closed",t=this.attachShadow({mode:e});Ut().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var mn=(o,n,e)=>{customElements.define(o,pn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},dn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),cn=o=>(o=dn(o),o.replace(/_/g,"-"));var Ue=class extends O{constructor(){super(...arguments);s(this,"type",L.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===q.localFrame){let d=v(),l="myop-comp-".concat(d),f=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(f.style.visibility="hidden"),f=this.appendChild(r,f,i),f.id=l,f.setAttribute("style","\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ")),r.appendChild(f);let g=f.contentDocument||f.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let K=new DOMParser().parseFromString(a.HTML,"text/html"),Xe=K.getElementById("myop_preview");Xe==null||Xe.removeAttribute("type");let Mt=K.implementation.createHTMLDocument();Mt.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let It=Mt.body.firstChild;It&&K.head&&K.head.insertBefore(K.importNode(It,!0),K.head.firstChild),u=K.documentElement.outerHTML}g.writeln(u),g.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>\n <script>\n \n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n \n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n \n __myop_init().then();\n \n <\/script>')),g.close();let x=new Y(e,t,r,f,i);return a.autoHeight&&(f.onload=()=>{x.observeSizeBasedOnDocumentElement()}),x}if(a.shadowRootMode===q.none){let d=document.createElement("template");d.innerHTML=a.HTML,m=d.content.firstElementChild,Ut().then(l=>{l.connectedCallback(m,m)})}else{let d=cn(e.name+t.id);$t.includes(d)||(mn(d,a.HTML,a.shadowRootMode),$t.push(d)),m=document.createElement(d)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ze=class ze{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"userFlows",{})}async fetchComponent(n,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}};s(ze,"Main",new ze);var le=ze;var Ne=class Ne{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{})}async fetchComponent(n,e){return this.variants[n]||(this.variants[n]=new Promise(async(t,r)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(e))).json();t(a.item)}catch(i){r(i)}})),await this.variants[n]}};s(Ne,"Main",new Ne);var zt=Ne;var Nt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=Ze(t);switch(r){case"component":{let[a,p]=i,m=await le.Main.fetchComponent(a);if(m&&m.type.skins.find(l=>l.id===p))return m.instance.skinSelector={type:W.Dedicated,skin:{id:p}},m}break;default:{let[a,p]=Ze(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===o.type.id);if(d&&d.instance.skinSelector.type===W.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(f=>f.id===p);if((l==null?void 0:l.type)===ye.Segment){let f=l,u=d.instance.skinSelector.segments.find(x=>x.segmentId===f.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var Vt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",ke);s(this,"type2InstanceCount",{});s(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});s(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==c.EnvelopedMessage)return;let e=n.data;if(e.messageType===c.InitRequest){this.components2init.forEach(r=>{r.send(new G(r.id))});return}if(e.messageType===c.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===c.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===k.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});s(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});s(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Ee,new ve,new Ue];if(this.componentsLoaders=[...e],n){let t={};n.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(n.type){case"DedicatedSkin":case W.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case W.Segmented:{let p=await r(n.segments,async m=>{if(m.segmentId==="Default")return!0;let d=e.find(u=>u.type===ye.Segment?u.segment.id===m.segmentId:!1);if(!d)throw new Error("experience not found");let f=d.segment,g=(t||{})[f.function];return g?await g():(console.warn("segmentId:".concat(m.segmentId,", ").concat(f.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(n,e,t)=>{var l,f,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Nt(n);r&&(n=r);let i=y(y({},(l=this.loaderHooks)!=null?l:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){n=y({},n),n.instance=y({},n.instance);let x=await this.runSkinSelector(n,i);if(!x)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(x=await t.hooks.afterSkinSelected(y({},x))),n.instance.skinSelector={type:W.Dedicated,skin:x},t&&(t=y({},t),delete t.hooks),await ft(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let m=this.componentsLoaders.find(x=>x.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await m.load(n.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(x=>x!==d),this.components2init=this.components2init.filter(x=>x!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=At(d,n.type.props,p));try{await gt(d,n,this.components)}catch(x){throw x}return t!=null&&t.skipInit||await d.initiated(),d});s(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,n.container,y({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(r),r.show(),n.dispose(),r}else{let r=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,y({relative:{direction:"before",child:r}},t))}})}};s(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Vt});if(!window.myop.hostSDK){let o=new H;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Vt}),window.myop.hostSDK=o}var yt=window.myop.hostSDK;Z("hostSDK",yt);var Ve=class extends h{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await H.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(m=>{let d=a.refs[m];d=d.__nonProxied||d,d.componentDefinition&&p.push({refName:m,componentDefinitionId:d.componentDefinition.id})}),this.messageToHost(new D(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var qt=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),r={attributes:!0,childList:!0,subtree:!0};return t.observe(o,r),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var qe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&qt(document.body,()=>{this.messageToHost(new re)})})}};var Wt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Wt(i),required:i.required,validity:R(i.validity,!0),myopId:a};e.unmappedData.push(m),p&&(!e.formData[p]||!e.formData[p].value||m.value)&&(e.formData[p]=m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},We=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new z(Wt(r)),e)})})}};var je=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetAttributeMessage);s(this,"executor",e=>{let t=Lt(e.ref,document);t&&this.messageToHost(new se(t.getAttribute(e.name)),e)})}};var Ge=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var Je=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var ht=class extends J{constructor(){super();s(this,"version",ke);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new Ie(this.messageToHost),new Je(this.messageToHost),new Me(this.messageToHost),new he(this.messageToHost),new xe(this.messageToHost),new we(this.messageToHost),new Te(this.messageToHost),new We(this.messageToHost),new qe(this.messageToHost),new Ge(this.messageToHost),new je(this.messageToHost),new Ve(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new N)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",ht);export{ht as IframeSDK};
|
|
1
|
+
var It=Object.defineProperty,qt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var Mt=Object.getOwnPropertySymbols;var jt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var Je=(o,n,e)=>n in o?It(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))jt.call(n,e)&&Je(o,e,n[e]);if(Mt)for(var e of Mt(n))Gt.call(n,e)&&Je(o,e,n[e]);return o},B=(o,n)=>qt(o,Wt(n));var Jt=(o,n)=>{for(var e in n)It(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>Je(o,typeof n!="symbol"?n+"":n,e);var j=class{constructor(n,e,t,r,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var xt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},h=class{constructor(n){this.messageToHost=n}},fe=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var c={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var ge={};Jt(ge,{AddEventListenerMessage:()=>et,BaseMyopMessage:()=>M,BindClickMessage:()=>Ze,ChangeTextMessage:()=>Ye,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>A,CreateRefComponentMessage:()=>ne,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>st,DetectedMyopRefsMessage:()=>V,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>U,EnvelopedMessage:()=>oe,EventListenerCallbackMessage:()=>z,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>F,GetAttributeMessage:()=>rt,GetAttributeReplayMessage:()=>se,GetElementValueMessage:()=>nt,InitMessage:()=>G,InitRequest:()=>N,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>re,MyopBindMessage:()=>T,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>Qe,Ref:()=>_,RefComponentCreatedMessage:()=>D,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>tt,SetInnerHtml:()=>ot,SetMutationObserverMessage:()=>it,SetResizeObserverMessage:()=>at,stripFunction:()=>Tt});var v=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Xt=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var Qt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Xe=o=>{let n=Qt(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Xt(n.slice(t,t+16)));return e};var Ct=o=>new Promise(n=>setTimeout(n,o));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",v());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Qe=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},T=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",v())}},_=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=B(y({},this),{component:null})}static create(n,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(r,t)}};var bt="ClickReplayMessage",Ze=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},A=class extends w{constructor(){super(...arguments);s(this,"messageType",bt)}};var Ye=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var wt="ExecuteScriptReplyMessage",Zt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Yt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Tt=o=>{let n=o.match(Zt);if(n)return n[1]||n[3];{let e=o.match(Yt);if(e)return e[1].trim()}},E=class extends T{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",wt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Tt(this.content)}};s(E,"replierKey","send"),s(E,"completeStreamKey","completeStream");var F=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",wt)}};var $=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(m.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=B(y({},t),{_script:e.toString()})}};var St="EventListenerCallbackMessage",et=class extends T{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",St);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},z=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",St);this.content={e:t}}};var tt=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var Et="ElementValueReplayMessage",nt=class extends T{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Et);s(this,"messageType","GetElementValueMessage")}},U=class extends w{constructor(e){super();this.content=e;s(this,"messageType",Et)}};var ot=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var G=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends G{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},N=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var Rt="RefComponentCreatedMessage",ne=class extends T{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",Rt);s(this,"messageType","CreateRefComponentMessage")}},D=class extends w{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",Rt)}};var oe=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var vt="DetectedMyopRefsMessage",st=class extends T{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",vt)}},V=class extends w{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",vt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var kt="GetAttributeReplayMessage",rt=class extends T{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",kt);s(this,"messageType","GetAttributeMessage")}},se=class extends w{constructor(e){super();this.content=e;s(this,"messageType",kt)}};var k=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var it=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},re=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Ht="CleanupReplayMessage",ie=class extends T{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Ht);s(this,"messageType","CleanupMessage")}},ae=class extends w{constructor(e){super();this.customCleanup=e;s(this,"messageType",Ht)}};var pe=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var at=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},me=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var pt=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},J=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===c.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===c.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new pt(r),this.messageToHost(new te(r));return}if(t.messageType===c.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(m=>m.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(m=>m.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===c.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],xt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var L={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var mt={message:"message",code:"code"},X=class{};s(X,"code","code"),s(X,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ue={Segment:"Segment",Promo:"Promo",AB:"AB"},Q=class{constructor(n,e){this.container=n;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var ye=class extends h{constructor(){super(...arguments);s(this,"messageType",c.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new j(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new V(e.handlerUniqueId,r))})}};var I=(o,n)=>n.querySelectorAll("[".concat(S.id,"='").concat(o.refConfig.selector,"']")),Bt=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var he=class extends h{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new A,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Me=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var dt=o=>o!==Object(o),en=o=>typeof o=="function",ct=o=>{if(dt(o))return!0;if(en(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!ct(e))return!1}else{if(dt(e))continue;return!1}}return!0},R=(o,n={},e=!0,t=new WeakMap)=>{if(dt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let r=[];t.set(o,r);for(let i=0;i<o.length;i++){let a=o[i];r[i]=R(a,n,e,t)}return r}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let r={};t.set(o,r);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(r[i]=R(o[i],!0,e,t)):typeof a=="object"&&(r[i]=R(o[i],a,e,t)))}return r}return{}};var Ie=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=R,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var xe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"executor",e=>{Ie(e,r=>{this.messageToHost(new F(e.handlerUniqueId,r))},new Q(document.documentElement))})}};var Ce="__federation__",Dt="onLoad";var Z=(o,n)=>{window[Ce]&&window[Ce][o]&&window[Ce][o][Dt]&&window[Ce][o][Dt]({[o]:n})};var be=class extends h{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new z(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var we=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var P=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});s(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let r=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(n);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===c.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,r=>r.replayToHandler===n.handlerUniqueId,r=>{n.handler(r),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=b.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new ie(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Lt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var de=class extends P{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new oe(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var tn=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},Te=(o,n,e,t,r,i)=>{let a=tn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},_t=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Pt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},Ot=(o,n,e)=>{let t=n.reduce((i,a)=>B(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(_t(p,a,o))return!1;if(p.behavior.type===mt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let d=p.behavior;return o.element.contentWindow[d.remap||a]}return Pt(p,a,o),!1}return p.mode==="output"?new Promise(m=>{let d=[];p.behavior.ref&&d.push(_.create(p.behavior.ref)),d.push(f=>{m(f)}),p.behavior.params&&d.push(...p.behavior.params);let l=ge[p.behavior.message];o.send(new l(...d))}):null},set:(i,a,p)=>{let m=t[a];if(_t(m,a,o))return!1;if(m.behavior.type===mt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let l=m.behavior;return o.element.contentWindow[l.remap||a]=p,!0}return Pt(m,a,o),!1}else if(m.mode==="input")if(m.behavior.type==="message"){let d=[];m.behavior.ref&&d.push(_.create(m.behavior.ref)),d.push(p),m.behavior.params&&d.push(...m.behavior.params);let l=ge[m.behavior.message];return o.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(m.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},nn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{ct(p)||Lt.notSerializableRefCall(t,p)}),n.send(new $(({ref:p,propName:m,functionArgs:d,makeSerializable:l})=>{if(p){let f=p[m];return l(typeof f=="function"?p[m](...d):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),lt=async(o,n,e,t)=>{let r=o.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(n.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new ne(o.refConfig,n,B(y({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(m),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(f=>f.id==p.id);if(l!==p){r.refs[o.refConfig.name]=l,i(l);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;d.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(C=>C.type.id===f.componentDefinitionId).type,u=new de(g,p);u.setInitiated(),p.refs[f.refName]=u,e.push(u)});try{await ft(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},ft=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let r=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==X.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(m=n.instance.resolvedNestedComponents)==null?void 0:m.find(g=>g.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=_.create("",i,o);try{let g=await lt(f,l,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let d=_.create("",i,o);o.refs[i.name]=nn(d,o),a()}catch(d){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new E(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:m}=document.documentElement.getBoundingClientRect();t({height:p,width:m})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new E(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});s(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new E(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===c.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Te(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===c.In.MutationObserverMessage||e.messageType===c.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){s(this,"appendChild",(n,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var on=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Se=class extends O{constructor(){super(...arguments);s(this,"type",L.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),d="myop-comp-".concat(m);a=document.createElement("iframe"),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(a.style.visibility="hidden"),a=this.appendChild(r,a,i);let l=t.loader.url;i!=null&&i._hasParent&&(l=on(l,"_myop-comp",m));let f="";i!=null&&i.elementAttributes&&(f=Object.entries(i==null?void 0:i.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(d,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",';\n "\n src="').concat(l,'"\n ').concat(f,"\n ></iframe>"),a=r.querySelector("#".concat(d))}return new Y(e,t,r,a,i)})}};var Ee={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Ee.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=Te(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var gt={},Re=class extends O{constructor(){super(...arguments);s(this,"type",L.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;gt[a.url]?console.log("Module alreday loaded or in loading process"):gt[a.url]=new Promise((d,l)=>{let f=a.url,g=document.createElement("script");g.type="module",g.src=f,g.onload=()=>{d()},g.onerror=()=>{l()},document.head.appendChild(g)}),await gt[a.url],await Ct(1);let p="myop-comp-".concat(v()),m=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),i!=null&&i._environment&&(m._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ve="0.2.4";var x=class extends fe{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(B(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ke=class extends x{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new A(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var He=class extends x{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Be=class extends Q{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var De=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(S.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(S.id);p&&i.push(new j(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new V(e.handlerUniqueId,i))});s(this,"messageType",c.DetectMyopRefsMessage)}};var Le=class extends x{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var _e=class extends x{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=d=>{r(new z(e.handlerUniqueId,R(d,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Pe=class extends x{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=H.Instance(),m=p.components.find(g=>g.id===e.options.id);m&&m.dispose();let d=p.components.indexOf(m);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(l.refs).forEach(g=>{let u=l.refs[g];u=u.__nonProxied||u,u.componentDefinition&&f.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new D(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Oe=class extends x{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{Ie(e,a=>{r(new F(e.handlerUniqueId,a))},t)})}};var Kt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Kt(i),required:i.required,validity:R(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(m):(e.unmappedData.push(e.formData[p]),e.formData[p]=m):e.formData[p]=m:e.unmappedData.push(m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ke=class extends x{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new U(Kt(a)),e)})})}};var Ae=class extends x{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends J{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Ee.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===c.InitMessage){let p=a.content.id;this.components[p].context=new Be(e,t)}}}),setTimeout(()=>{this.messageToHost(new N)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new He(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new De(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Oe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Pe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};Z("WebComponentSDK",ce);var At=[],Fe,Ft=async()=>(Fe||(Fe=new ce,Fe.init()),Fe);function sn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===q.open?"open":"closed",t=this.attachShadow({mode:e});Ft().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var rn=(o,n,e)=>{customElements.define(o,sn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},an=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),pn=o=>(o=an(o),o.replace(/_/g,"-"));var $e=class extends O{constructor(){super(...arguments);s(this,"type",L.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===q.localFrame){let d=v(),l="myop-comp-".concat(d),f=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(f.style.visibility="hidden"),f=this.appendChild(r,f,i),f.id=l,f.setAttribute("style","\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ")),r.appendChild(f);let g=f.contentDocument||f.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let K=new DOMParser().parseFromString(a.HTML,"text/html"),Ge=K.getElementById("myop_preview");Ge==null||Ge.removeAttribute("type");let yt=K.implementation.createHTMLDocument();yt.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ht=yt.body.firstChild;ht&&K.head&&K.head.insertBefore(K.importNode(ht,!0),K.head.firstChild),u=K.documentElement.outerHTML}g.writeln(u),g.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>\n <script>\n \n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n \n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n \n __myop_init().then();\n \n <\/script>')),g.close();let C=new Y(e,t,r,f,i);return a.autoHeight&&(f.onload=()=>{C.observeSizeBasedOnDocumentElement()}),C}if(a.shadowRootMode===q.none){let d=document.createElement("template");d.innerHTML=a.HTML,m=d.content.firstElementChild,Ft().then(l=>{l.connectedCallback(m,m)})}else{let d=pn(e.name+t.id);At.includes(d)||(rn(d,a.HTML,a.shadowRootMode),At.push(d)),m=document.createElement(d)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ze=class ze{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"userFlows",{})}isPreloaded(n){return n in this.variants}async fetchComponentV2(n,e){return this.variants[n]||(this.variants[n]=new Promise(async(t,r)=>{try{let a=await(await fetch("".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(e))).json();t(a.item)}catch(i){r(i)}})),await this.variants[n]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};s(ze,"Main",new ze);var le=ze;var $t=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=Xe(t);switch(r){case"component":{let[a,p]=i,m=await le.Main.fetchComponent(a);if(m&&m.type.skins.find(l=>l.id===p))return m.instance.skinSelector={type:W.Dedicated,skin:{id:p}},m}break;default:{let[a,p]=Xe(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===o.type.id);if(d&&d.instance.skinSelector.type===W.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(f=>f.id===p);if((l==null?void 0:l.type)===ue.Segment){let f=l,u=d.instance.skinSelector.segments.find(C=>C.segmentId===f.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var zt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",ve);s(this,"type2InstanceCount",{});s(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});s(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==c.EnvelopedMessage)return;let e=n.data;if(e.messageType===c.InitRequest){this.components2init.forEach(r=>{r.send(new G(r.id))});return}if(e.messageType===c.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===c.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===k.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});s(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});s(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Se,new Re,new $e];if(this.componentsLoaders=[...e],n){let t={};n.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(n.type){case"DedicatedSkin":case W.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case W.Segmented:{let p=await r(n.segments,async m=>{if(m.segmentId==="Default")return!0;let d=e.find(u=>u.type===ue.Segment?u.segment.id===m.segmentId:!1);if(!d)throw new Error("experience not found");let f=d.segment,g=(t||{})[f.function];return g?await g():(console.warn("segmentId:".concat(m.segmentId,", ").concat(f.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(n,e,t)=>{var l,f,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await $t(n);r&&(n=r);let i=y(y({},(l=this.loaderHooks)!=null?l:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){n=y({},n),n.instance=y({},n.instance);let C=await this.runSkinSelector(n,i);if(!C)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(C=await t.hooks.afterSkinSelected(y({},C))),n.instance.skinSelector={type:W.Dedicated,skin:C},t&&(t=y({},t),delete t.hooks),await lt(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let m=this.componentsLoaders.find(C=>C.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await m.load(n.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(C=>C!==d),this.components2init=this.components2init.filter(C=>C!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=Ot(d,n.type.props,p));try{await ft(d,n,this.components)}catch(C){throw C}return t!=null&&t.skipInit||await d.initiated(),d});s(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,n.container,y({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(r),r.show(),n.dispose(),r}else{let r=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,y({relative:{direction:"before",child:r}},t))}})}};s(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:zt});if(!window.myop.hostSDK){let o=new H;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:zt}),window.myop.hostSDK=o}var mn=window.myop.hostSDK;Z("hostSDK",mn);var Ue=class extends h{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await H.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(m=>{let d=a.refs[m];d=d.__nonProxied||d,d.componentDefinition&&p.push({refName:m,componentDefinitionId:d.componentDefinition.id})}),this.messageToHost(new D(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Ut=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),r={attributes:!0,childList:!0,subtree:!0};return t.observe(o,r),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var Ne=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&Ut(document.body,()=>{this.messageToHost(new re)})})}};var Nt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:Nt(i),required:i.required,validity:R(i.validity,!0),myopId:a};e.unmappedData.push(m),p&&(!e.formData[p]||!e.formData[p].value||m.value)&&(e.formData[p]=m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ve=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new U(Nt(r)),e)})})}};var qe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetAttributeMessage);s(this,"executor",e=>{let t=Bt(e.ref,document);t&&this.messageToHost(new se(t.getAttribute(e.name)),e)})}};var We=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var je=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var ut=class extends J{constructor(){super();s(this,"version",ve);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new Me(this.messageToHost),new je(this.messageToHost),new he(this.messageToHost),new ye(this.messageToHost),new xe(this.messageToHost),new be(this.messageToHost),new we(this.messageToHost),new Ve(this.messageToHost),new Ne(this.messageToHost),new We(this.messageToHost),new qe(this.messageToHost),new Ue(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new N)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",ut);export{ut as IframeSDK};
|
|
@@ -1731,7 +1731,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
1731
1731
|
};
|
|
1732
1732
|
|
|
1733
1733
|
// version:myop-sdk-version
|
|
1734
|
-
var myop_sdk_version_default = "0.2.
|
|
1734
|
+
var myop_sdk_version_default = "0.2.4";
|
|
1735
1735
|
|
|
1736
1736
|
// src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
|
|
1737
1737
|
var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
|
|
@@ -2171,12 +2171,46 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
2171
2171
|
|
|
2172
2172
|
// src/helpers/CloudRepository.ts
|
|
2173
2173
|
var _CloudRepository = class _CloudRepository {
|
|
2174
|
-
// private components: Record<string, Promise<IUserFlow>> = {};
|
|
2175
2174
|
constructor(_baseUrl = "https://cloud.myop.dev") {
|
|
2176
2175
|
this._baseUrl = _baseUrl;
|
|
2176
|
+
// v2 cache
|
|
2177
|
+
__publicField(this, "variants", {});
|
|
2178
|
+
// v1 cache
|
|
2177
2179
|
__publicField(this, "userFlows", {});
|
|
2178
2180
|
}
|
|
2179
|
-
|
|
2181
|
+
// ============ V2 Methods (Default) ============
|
|
2182
|
+
/**
|
|
2183
|
+
* Check if a component is already cached/preloaded (v2)
|
|
2184
|
+
*/
|
|
2185
|
+
isPreloaded(componentId) {
|
|
2186
|
+
return componentId in this.variants;
|
|
2187
|
+
}
|
|
2188
|
+
/**
|
|
2189
|
+
* Fetch a v2 component variant
|
|
2190
|
+
*/
|
|
2191
|
+
async fetchComponentV2(componentId, environmentIdentifier) {
|
|
2192
|
+
if (!this.variants[componentId]) {
|
|
2193
|
+
this.variants[componentId] = new Promise(
|
|
2194
|
+
async (resolve, reject) => {
|
|
2195
|
+
try {
|
|
2196
|
+
const res = await fetch(
|
|
2197
|
+
"".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(environmentIdentifier)
|
|
2198
|
+
);
|
|
2199
|
+
const json = await res.json();
|
|
2200
|
+
resolve(json.item);
|
|
2201
|
+
} catch (e) {
|
|
2202
|
+
reject(e);
|
|
2203
|
+
}
|
|
2204
|
+
}
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
return await this.variants[componentId];
|
|
2208
|
+
}
|
|
2209
|
+
// ============ V1 Methods (Legacy) ============
|
|
2210
|
+
/**
|
|
2211
|
+
* Fetch a v1 component from a flow
|
|
2212
|
+
*/
|
|
2213
|
+
async fetchComponentV1(componentId, flowId) {
|
|
2180
2214
|
if (flowId) {
|
|
2181
2215
|
const flow = await this.fetchFlow(flowId);
|
|
2182
2216
|
return flow.components.find((c) => c.type.id === componentId);
|
|
@@ -2221,38 +2255,18 @@ var _CloudRepository = class _CloudRepository {
|
|
|
2221
2255
|
}
|
|
2222
2256
|
return await this.userFlows[flowId];
|
|
2223
2257
|
}
|
|
2258
|
+
// ============ Backward Compatibility ============
|
|
2259
|
+
/**
|
|
2260
|
+
* @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly
|
|
2261
|
+
* Defaults to v1 behavior for backward compatibility with existing code
|
|
2262
|
+
*/
|
|
2263
|
+
async fetchComponent(componentId, flowId) {
|
|
2264
|
+
return this.fetchComponentV1(componentId, flowId);
|
|
2265
|
+
}
|
|
2224
2266
|
};
|
|
2225
2267
|
__publicField(_CloudRepository, "Main", new _CloudRepository());
|
|
2226
2268
|
var CloudRepository = _CloudRepository;
|
|
2227
2269
|
|
|
2228
|
-
// src/helpers/enableV2.ts
|
|
2229
|
-
var _v2_CloudRepository = class _v2_CloudRepository {
|
|
2230
|
-
constructor(_baseUrl = "https://cloud.myop.dev") {
|
|
2231
|
-
this._baseUrl = _baseUrl;
|
|
2232
|
-
__publicField(this, "variants", {});
|
|
2233
|
-
}
|
|
2234
|
-
async fetchComponent(componentId, environmentIdentifier) {
|
|
2235
|
-
if (!this.variants[componentId]) {
|
|
2236
|
-
this.variants[componentId] = new Promise(
|
|
2237
|
-
async (resolve, reject) => {
|
|
2238
|
-
try {
|
|
2239
|
-
const res = await fetch(
|
|
2240
|
-
"".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(environmentIdentifier)
|
|
2241
|
-
);
|
|
2242
|
-
const json = await res.json();
|
|
2243
|
-
resolve(json.item);
|
|
2244
|
-
} catch (e) {
|
|
2245
|
-
reject(e);
|
|
2246
|
-
}
|
|
2247
|
-
}
|
|
2248
|
-
);
|
|
2249
|
-
}
|
|
2250
|
-
return await this.variants[componentId];
|
|
2251
|
-
}
|
|
2252
|
-
};
|
|
2253
|
-
__publicField(_v2_CloudRepository, "Main", new _v2_CloudRepository());
|
|
2254
|
-
var v2_CloudRepository = _v2_CloudRepository;
|
|
2255
|
-
|
|
2256
2270
|
// src/host/myopOverride.ts
|
|
2257
2271
|
var checkMyopOverride = async (componentConfig) => {
|
|
2258
2272
|
try {
|