@myop/sdk 0.3.13 → 0.3.14

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.
Files changed (27) hide show
  1. package/README.md +1 -19
  2. package/dist/cjs/{_IframeSDK.5b34af50.min.js → _IframeSDK.6575ebb7.min.js} +1 -1
  3. package/dist/cjs/{_IframeSDK.06523760.js → _IframeSDK.fe91981e.js} +1 -1
  4. package/dist/cjs/{_IframeSDK.06523760.js.map → _IframeSDK.fe91981e.js.map} +1 -1
  5. package/dist/cjs/{_WebComponentSDK.acba38a4.min.js → _WebComponentSDK.384a170a.min.js} +1 -1
  6. package/dist/cjs/{_WebComponentSDK.4ed98c20.js → _WebComponentSDK.eb8de391.js} +1 -1
  7. package/dist/cjs/{_WebComponentSDK.4ed98c20.js.map → _WebComponentSDK.eb8de391.js.map} +1 -1
  8. package/dist/cjs/{_hostSDK.f8d320df.js → _hostSDK.40194c35.js} +1 -1
  9. package/dist/cjs/{_hostSDK.f8d320df.js.map → _hostSDK.40194c35.js.map} +1 -1
  10. package/dist/cjs/{_hostSDK.dc07390b.min.js → _hostSDK.994f6668.min.js} +1 -1
  11. package/dist/cjs/myop_sdk.js +11 -11
  12. package/dist/cjs/myop_sdk.js.map +1 -1
  13. package/dist/cjs/myop_sdk.min.js +1 -1
  14. package/dist/cjs-bundled/myop_sdk.bundled.js +2 -2
  15. package/dist/cjs-bundled/myop_sdk.bundled.js.map +1 -1
  16. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  17. package/dist/module/Iframe/index.js +2 -2
  18. package/dist/module/Iframe/index.js.map +1 -1
  19. package/dist/module/SDK.js +2 -2
  20. package/dist/module/SDK.js.map +1 -1
  21. package/dist/module/embeddedSDK.js +1 -1
  22. package/dist/module/host/embeddedSDK.js +1 -1
  23. package/dist/module/host/index.js +2 -2
  24. package/dist/module/host/index.js.map +1 -1
  25. package/dist/module/webcomponent/index.js +2 -2
  26. package/dist/module/webcomponent/index.js.map +1 -1
  27. package/package.json +1 -1
package/README.md CHANGED
@@ -408,25 +408,7 @@ For comprehensive documentation, guides, and examples, visit **[docs.myop.dev](h
408
408
 
409
409
  - [Getting Started Guide](https://docs.myop.dev/docs/quickstart)
410
410
  - [SDK Reference](https://docs.myop.dev/docs/sdk)
411
-
412
- ## Development
413
-
414
- ```bash
415
- # Install dependencies
416
- npm install
417
-
418
- # Start development server
419
- npm run dev
420
-
421
- # Run tests
422
- npm test
423
-
424
- # Build for production
425
- npm run build
426
-
427
- # Generate documentation
428
- npm run build:docs
429
- ```
411
+ - [Auto-Generated Packages](https://docs.myop.dev/docs/learnMyop/AutoGeneratedPackages)
430
412
 
431
413
  ## Related Resources
432
414
 
@@ -1 +1 @@
1
- var Ht=Object.defineProperty,rn=Object.defineProperties;var an=Object.getOwnPropertyDescriptors;var kt=Object.getOwnPropertySymbols;var pn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var rt=(o,n,e)=>n in o?Ht(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))pn.call(n,e)&&rt(o,e,n[e]);if(kt)for(var e of kt(n))dn.call(n,e)&&rt(o,e,n[e]);return o},O=(o,n)=>rn(o,an(n));var cn=(o,n)=>{for(var e in n)Ht(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>rt(o,typeof n!="symbol"?n+"":n,e);var te=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 _t=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},M=class{constructor(n){this.messageToHost=n}},Se=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var m={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 Te={};cn(Te,{AddEventListenerMessage:()=>ct,BaseMyopMessage:()=>I,BindClickMessage:()=>pt,ChangeTextMessage:()=>dt,CleanupMessage:()=>ye,CleanupReplayMessage:()=>he,ClickReplayMessage:()=>N,CreateRefComponentMessage:()=>le,CustomRefMessage:()=>V,DetectMyopRefsMessage:()=>gt,DetectedMyopRefsMessage:()=>J,DisposeMessage:()=>Me,ElementValueReplayMessage:()=>j,EnvelopedMessage:()=>fe,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>_,ExecuteScriptMessage:()=>v,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>ut,GetAttributeReplayMessage:()=>ge,GetElementValueMessage:()=>lt,InitMessage:()=>ne,InitRequest:()=>G,InitResponse:()=>me,MessageDirection:()=>b,MutationObserverMessage:()=>ue,MyopBindMessage:()=>S,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>at,Ref:()=>F,RefComponentCreatedMessage:()=>P,ResizeObserverMessage:()=>Ie,SetAttributeMessage:()=>mt,SetInnerHtml:()=>ft,SetMutationObserverMessage:()=>yt,SetResizeObserverMessage:()=>ht,stripFunction:()=>Ot});var H=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var mn=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 ln=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 it=o=>{let n=ln(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(mn(n.slice(t,t+16)));return e};var Dt=o=>new Promise(n=>setTimeout(n,o));var b=class{};s(b,"down","down"),s(b,"up","up");var I=class{constructor(){s(this,"id",H());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}},at=class extends I{constructor(e){super();this.ref=e}},w=class extends I{constructor(e){super();this.replayToHandler=e}},S=class extends I{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",H())}},F=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=O(h({},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",pt=class extends S{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},N=class extends w{constructor(){super(...arguments);s(this,"messageType",Bt)}};var dt=class extends I{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var Lt="ExecuteScriptReplyMessage",fn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,gn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Ot=o=>{let n=o.match(fn);if(n)return n[1]||n[3];{let e=o.match(gn);if(e)return e[1].trim()}},v=class extends S{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",Lt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Ot(this.content)}};s(v,"replierKey","send"),s(v,"completeStreamKey","completeStream");var W=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",Lt)}};var V=class extends v{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},r);this.scriptInputs=t;this.scriptInputs=O(h({},t),{_script:e.toString()})}};var Pt="EventListenerCallbackMessage",ct=class extends S{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Pt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},q=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Pt);this.content={e:t}}};var mt=class extends I{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var At="ElementValueReplayMessage",lt=class extends S{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",At);s(this,"messageType","GetElementValueMessage")}},j=class extends w{constructor(e){super();this.content=e;s(this,"messageType",At)}};var ft=class extends I{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var ne=class extends I{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},me=class extends ne{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},G=class extends I{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var Kt="RefComponentCreatedMessage",le=class extends S{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",Kt);s(this,"messageType","CreateRefComponentMessage")}},P=class extends w{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",Kt)}};var fe=class extends I{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 Ft="DetectedMyopRefsMessage",gt=class extends S{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Ft)}},J=class extends w{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Ft);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var zt="GetAttributeReplayMessage",ut=class extends S{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",zt);s(this,"messageType","GetAttributeMessage")}},ge=class extends w{constructor(e){super();this.content=e;s(this,"messageType",zt)}};var _=class extends I{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var yt=class extends I{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},ue=class extends I{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var $t="CleanupReplayMessage",ye=class extends S{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",$t);s(this,"messageType","CleanupMessage")}},he=class extends w{constructor(e){super();this.customCleanup=e;s(this,"messageType",$t)}};var Me=class extends I{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var ht=class extends I{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},Ie=class extends I{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var Mt=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},oe=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===m.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===m.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new Mt(r),this.messageToHost(new me(r));return}if(t.messageType===m.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===m.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new he(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],_t(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 A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Y={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ie={message:"message",code:"code"},se=class{};s(se,"code","code"),s(se,"component","component");var X={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ee={Segment:"Segment",Promo:"Promo",AB:"AB"},re=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 E={id:"myop-id"};var Re=class extends M{constructor(){super(...arguments);s(this,"messageType",m.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(E.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(E.id);a&&r.push(new te(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new J(e.handlerUniqueId,r))})}};var C=(o,n)=>n.querySelectorAll("[".concat(E.id,"='").concat(o.refConfig.selector,"']")),Ut=(o,n)=>{let e=C(o,n);return e.length?e.item(0):null};var ve=class extends M{constructor(){super(...arguments);s(this,"messageType",m.BindClickMessage);s(this,"executor",e=>{let t=[];return C(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new N,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var ke=class extends M{constructor(){super(...arguments);s(this,"messageType",m.ChangeTextMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var It=o=>o!==Object(o),un=o=>typeof o=="function",Ct=o=>{if(It(o))return!0;if(un(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(It(e))continue;return!1}}return!0},k=(o,n={},e=!0,t=new WeakMap)=>{if(It(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]=k(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]=k(o[i],!0,e,t)):typeof a=="object"&&(r[i]=k(o[i],a,e,t)))}return r}return{}};var He=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=k,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var _e=class extends M{constructor(){super(...arguments);s(this,"messageType",m.ExecuteScriptMessage);s(this,"executor",e=>{He(e,r=>{this.messageToHost(new W(e.handlerUniqueId,r))},new re(document.documentElement))})}};var De="__federation__",Nt="onLoad";var ae=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Nt]&&window[De][o][Nt]({[o]:n})};var Be=class extends M{constructor(){super(...arguments);s(this,"messageType",m.AddEventListenerMessage);s(this,"executor",e=>{let t=C(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new q(e.handlerUniqueId,k(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Le=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetAttributeMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var z=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)||B.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===m.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 ye(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Me);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Wt={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 Ce=class extends z{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 fe(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new _("dispose")),super.dispose()})}hide(){this.send(new _("hide"))}show(){this.send(new _("show"))}inspect(){return this.send(new _("inspect"))}setHeightBasedOnDocumentElement(){this.send(new _("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new _("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var yn=(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},Oe=(o,n,e,t,r,i)=>{let a=yn("".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)}},Vt=(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),qt=(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."))},jt=(o,n,e)=>{let t=n.reduce((i,a)=>O(h({},i),{[a.name]:h({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Vt(p,a,o))return!1;if(p.behavior.type===ie.code){if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return qt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(F.create(p.behavior.ref)),c.push(l=>{d(l)}),p.behavior.params&&c.push(...p.behavior.params);let f=Te[p.behavior.message];o.send(new f(...c))}):null},set:(i,a,p)=>{let d=t[a];if(Vt(d,a,o))return!1;if(d.behavior.type===ie.code){if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let f=d.behavior,l=o.element.contentWindow,g=f.remap||a;if(l[g]=p,g==="myop_cta_handler"&&l.__myop_cta_queue){let u=l.__myop_cta_queue;l.__myop_cta_queue=null,u.forEach(y=>{o.markedForDisposed||p(y.action,y.payload)})}return!0}return qt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(F.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let f=Te[d.behavior.message];return o.send(new f(...c)),!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(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},hn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{Ct(p)||Wt.notSerializableRefCall(t,p)}),n.send(new V(({ref:p,propName:d,functionArgs:c,makeSerializable:f})=>{if(p){let l=p[d];return f(typeof l=="function"?p[d](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new V(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),xt=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 Ce(n.type,r,t);e.push(p),await r.initiated();let d=setTimeout(()=>{a("timeout")},5e3);r.send(new le(o.refConfig,n,O(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){r.refs[o.refConfig.name]=f,i(f);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(y=>y.type.id===l.componentDefinitionId).type,u=new Ce(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await bt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},bt=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 d;if(i.behavior.type==se.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=F.create("",i,o);try{let g=await xt(l,f,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let c=F.create("",i,o);o.refs[i.name]=hn(c,o),a()}catch(c){}}));try{await Promise.all(r)}catch(i){throw i}};var pe=class extends z{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 v(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new v(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});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,"observeAutoSize",e=>{var ce;let t=this.IframeElement,r=t.contentDocument;if(!r)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(R,L,ee)=>L!==void 0&&R<L?L:ee!==void 0&&R>ee?ee:R,a=R=>{if(R===void 0)return;if(typeof R=="number")return R;let L=parseFloat(R);return isNaN(L)?void 0:L},p=a(e==null?void 0:e.minWidth),d=a(e==null?void 0:e.maxWidth),c=a(e==null?void 0:e.minHeight),f=a(e==null?void 0:e.maxHeight),l=(ce=e==null?void 0:e.loaderMinHeight)!=null?ce:50,g=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,y=this.container.getBoundingClientRect(),Q=y.width===0,we=y.height===0||y.height===l,K=(e!=null&&e.forceAutoSize||Q)&&!g,T=(e!=null&&e.forceAutoSize||we)&&!u;if(!K&&!T)return()=>{};let D=()=>{var L;let R=t.contentDocument;if(R){let ee=R.documentElement.getBoundingClientRect(),Tt=Math.ceil(ee.width),Et=Math.ceil(ee.height),Rt=i(Tt,p,d),vt=i(Et,c,f);K&&(t.style.width="".concat(Rt,"px")),T&&(t.style.height="".concat(vt,"px"));let on=K&&d!==void 0&&Tt>d,sn=T&&f!==void 0&&Et>f;R.documentElement.style.overflowX=on?"auto":"hidden",R.documentElement.style.overflowY=sn?"auto":"hidden",(L=e==null?void 0:e.onSizeChange)==null||L.call(e,{width:Rt,height:vt,autoSizingWidth:K,autoSizingHeight:T})}};D();let Z=new ResizeObserver(D);return Z.observe(r.body),Z.observe(r.documentElement),()=>{Z.disconnect()}});s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new v(()=>{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 v(()=>{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=h({},e);if(t.messageType===m.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=Oe(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===m.In.MutationObserverMessage||e.messageType===m.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var $=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 Mn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Pe=class extends ${constructor(){super(...arguments);s(this,"type",A.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 d=H(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=f,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,u])=>{u===""||u===null||u===void 0?a.setAttribute(g,""):a.setAttribute(g,String(u))});let l=t.loader.url;i!=null&&i._hasParent&&(l=Mn(l,"_myop-comp",d)),a.src=l,r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),a=this.appendChild(r,a,i)}return new pe(e,t,r,a,i)})}};var Ae={webcomponent_message_key:"myop_webcomponent_message"};var de=class extends z{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=h({},e),r=super.send(t),i=new CustomEvent(Ae.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=Oe(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 wt={},Ke=class extends ${constructor(){super(...arguments);s(this,"type",A.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;wt[a.url]?console.log("Module alreday loaded or in loading process"):wt[a.url]=new Promise((c,f)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{c()},g.onerror=()=>{f()},document.head.appendChild(g)}),await wt[a.url],await Dt(1);let p="myop-comp-".concat(H()),d=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,d,i),new de(e,t,r,d,i)})}};var Fe="0.3.13";var x=class extends Se{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(O(h({},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 ze=class extends x{constructor(){super(...arguments);s(this,"messageType",m.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=C(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{r(new N(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var $e=class extends x{constructor(){super(...arguments);s(this,"messageType",m.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Ue=class extends re{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ne=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(E.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(E.id);p&&i.push(new te(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new J(e.handlerUniqueId,i))});s(this,"messageType",m.DetectMyopRefsMessage)}};var We=class extends x{constructor(){super(...arguments);s(this,"messageType",m.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Ve=class extends x{constructor(){super(...arguments);s(this,"messageType",m.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=C(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{r(new q(e.handlerUniqueId,k(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var qe=class extends x{constructor(){super(...arguments);s(this,"messageType",m.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(g=>{let u=f.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new P(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new P(e.handlerUniqueId,[],!0));debugger}})().then()})}};var je=class extends x{constructor(){super(...arguments);s(this,"messageType",m.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{He(e,a=>{r(new W(e.handlerUniqueId,a))},t)})}};var Gt=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(E.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Gt(i),required:i.required,validity:k(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),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},Ge=class extends x{constructor(){super(...arguments);s(this,"messageType",m.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{C(e.ref,t.shadowRoot).forEach(a=>{r(new j(Gt(a)),e)})})}};var Je=class extends x{constructor(){super(...arguments);s(this,"messageType",m.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var xe=class extends oe{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Ae.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===m.InitMessage){let p=a.content.id;this.components[p].context=new Ue(e,t)}}}),setTimeout(()=>{this.messageToHost(new G)},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 $e(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Ne(this.messageToHost,this.components),new We(this.messageToHost,this.components),new Ve(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new qe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};ae("WebComponentSDK",xe);var Jt="";var Xt=[],Ye,Qt=async()=>(Ye||(Ye=new xe,Ye.init()),Ye);function In(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Y.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var Cn=(o,n,e)=>{customElements.define(o,In(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},xn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),bn=o=>(o=xn(o),o.replace(/_/g,"-"));var Xe=class extends ${constructor(){super(...arguments);s(this,"type",A.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(H()),d;if(a.shadowRootMode===Y.localFrame){let c=H(),f="myop-comp-".concat(c),l=document.createElement("iframe");l.id=f,l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),l=this.appendChild(r,l,i);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),D=T.getElementById("myop_preview");D==null||D.removeAttribute("type");let Z=T.implementation.createHTMLDocument();Z.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ce=Z.body.firstChild;ce&&T.head&&T.head.insertBefore(T.importNode(ce,!0),T.head.firstChild),u=T.documentElement.outerHTML}else{let T=new DOMParser().parseFromString(a.HTML,"text/html"),D=T.getElementById("myop_preview");D&&(D.remove(),u=T.documentElement.outerHTML)}g.writeln(u);let y='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),Q="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(g.writeln("".concat(y).concat(Q)),(i==null?void 0:i.data)!==void 0){let K="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",T=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),D='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(T,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");g.writeln(K+D)}g.close();let we=new pe(e,t,r,l,i);return a.autoHeight&&(l.onload=()=>{we.observeSizeBasedOnDocumentElement()}),we}if(a.shadowRootMode===Y.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Qt().then(f=>{f.connectedCallback(d,d)})}else{let c=bn(e.name+t.id);Xt.includes(c)||(Cn(c,a.HTML,a.shadowRootMode),Xt.push(c)),d=document.createElement(c)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(r,d,i),new de(e,t,r,d,i)})}};var wn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:ie.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ie.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Qe="__MYOP_CLOUD_REPOSITORY_MAIN__",Sn=()=>{if(typeof window<"u")return window[Qe];if(typeof globalThis<"u")return globalThis[Qe]},Tn=o=>{typeof window<"u"&&(window[Qe]=o),typeof globalThis<"u"&&(globalThis[Qe]=o)},U=class U{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"preloadedComponents",{});s(this,"userFlows",{});s(this,"_defaultEnv","production")}static get Main(){let n=Sn();return n||(U._main||(U._main=new U,Tn(U._main)),U._main)}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let r=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;!i&&r?(a=r.env,p=r.preview):(a=e||this._defaultEnv,p=t===!0?!0:t===!1?!1:!e);let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(c,f)=>{try{let l="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(l+="&preview=true");let y=(await(await fetch(l)).json()).item;if(!y){f(new Error('Component "'.concat(n,'" not found')));return}if(!y.consume_variant||!y.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let Q=wn(y);c(Q)}catch(l){f(l)}})),await this.variants[d]}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(U,"_main",null);var be=U;var Zt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=it(t);switch(r){case"component":{let[a,p]=i,d=await be.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:X.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=it(t),c=(await be.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(c&&c.instance.skinSelector.type===X.Segmented&&c.instance.resolvedExperiences){let f=c.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Ee.Segment){let l=f,u=c.instance.skinSelector.segments.find(y=>y.segmentId===l.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var en="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",B=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",Fe);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!==m.EnvelopedMessage)return;let e=n.data;if(e.messageType===m.InitRequest){this.components2init.forEach(r=>{r.send(new ne(r.id))});return}if(e.messageType===m.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===m.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===_.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 Pe,new Ke,new Xe];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 d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case X.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case X.Segmented:{let p=await r(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===Ee.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.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 f,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Zt(n);r&&(n=r);let i=h(h({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let y=await this.runSkinSelector(n,i);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(y=await t.hooks.afterSkinSelected(h({},y))),n.instance.skinSelector={type:X.Dedicated,skin:y},t&&(t=h({},t),delete t.hooks),await xt(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(h({},p)));let d=this.componentsLoaders.find(y=>y.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==c),this.components2init=this.components2init.filter(y=>y!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=jt(c,n.type.props,p));try{await bt(c,n,this.components)}catch(y){throw y}return t!=null&&t.skipInit||await c.initiated(),c});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,h({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,h({relative:{direction:"before",child:r}},t))}})}};s(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en}),window.myop.hostSDK=o}var En=window.myop.hostSDK;ae("hostSDK",En);var Ze=class extends M{constructor(){super(...arguments);s(this,"messageType",m.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await B.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new P(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new P(e.handlerUniqueId,[],!0));debugger}})().then()})}};var tn=(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 et=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&tn(document.body,()=>{this.messageToHost(new ue)})})}};var nn=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(E.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:nn(i),required:i.required,validity:k(i.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),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},tt=class extends M{constructor(){super(...arguments);s(this,"messageType",m.GetElementValueMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{this.messageToHost(new j(nn(r)),e)})})}};var nt=class extends M{constructor(){super(...arguments);s(this,"messageType",m.GetAttributeMessage);s(this,"executor",e=>{let t=Ut(e.ref,document);t&&this.messageToHost(new ge(t.getAttribute(e.name)),e)})}};var ot=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new Ie)});return t.observe(document.body),()=>{t.disconnect()}})}};var st=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetInnerHtml);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var St=class extends oe{constructor(){super();s(this,"version",Fe);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(h({},e),"*")});s(this,"supportedHandlers",[new ke(this.messageToHost),new st(this.messageToHost),new ve(this.messageToHost),new Re(this.messageToHost),new _e(this.messageToHost),new Be(this.messageToHost),new Le(this.messageToHost),new tt(this.messageToHost),new et(this.messageToHost),new ot(this.messageToHost),new nt(this.messageToHost),new Ze(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new G)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};ae("IframeSDK",St);export{St as IframeSDK};
1
+ var Ht=Object.defineProperty,rn=Object.defineProperties;var an=Object.getOwnPropertyDescriptors;var kt=Object.getOwnPropertySymbols;var pn=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable;var rt=(o,n,e)=>n in o?Ht(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))pn.call(n,e)&&rt(o,e,n[e]);if(kt)for(var e of kt(n))dn.call(n,e)&&rt(o,e,n[e]);return o},O=(o,n)=>rn(o,an(n));var cn=(o,n)=>{for(var e in n)Ht(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>rt(o,typeof n!="symbol"?n+"":n,e);var te=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 _t=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},M=class{constructor(n){this.messageToHost=n}},Se=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var m={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 Te={};cn(Te,{AddEventListenerMessage:()=>ct,BaseMyopMessage:()=>I,BindClickMessage:()=>pt,ChangeTextMessage:()=>dt,CleanupMessage:()=>ye,CleanupReplayMessage:()=>he,ClickReplayMessage:()=>N,CreateRefComponentMessage:()=>le,CustomRefMessage:()=>V,DetectMyopRefsMessage:()=>gt,DetectedMyopRefsMessage:()=>J,DisposeMessage:()=>Me,ElementValueReplayMessage:()=>j,EnvelopedMessage:()=>fe,EventListenerCallbackMessage:()=>q,ExecuteComponentMethod:()=>_,ExecuteScriptMessage:()=>v,ExecuteScriptReplyMessage:()=>W,GetAttributeMessage:()=>ut,GetAttributeReplayMessage:()=>ge,GetElementValueMessage:()=>lt,InitMessage:()=>ne,InitRequest:()=>G,InitResponse:()=>me,MessageDirection:()=>b,MutationObserverMessage:()=>ue,MyopBindMessage:()=>S,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>at,Ref:()=>F,RefComponentCreatedMessage:()=>P,ResizeObserverMessage:()=>Ie,SetAttributeMessage:()=>mt,SetInnerHtml:()=>ft,SetMutationObserverMessage:()=>yt,SetResizeObserverMessage:()=>ht,stripFunction:()=>Ot});var H=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var mn=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 ln=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 it=o=>{let n=ln(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(mn(n.slice(t,t+16)));return e};var Dt=o=>new Promise(n=>setTimeout(n,o));var b=class{};s(b,"down","down"),s(b,"up","up");var I=class{constructor(){s(this,"id",H());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}},at=class extends I{constructor(e){super();this.ref=e}},w=class extends I{constructor(e){super();this.replayToHandler=e}},S=class extends I{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",H())}},F=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=O(h({},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",pt=class extends S{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},N=class extends w{constructor(){super(...arguments);s(this,"messageType",Bt)}};var dt=class extends I{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var Lt="ExecuteScriptReplyMessage",fn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,gn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Ot=o=>{let n=o.match(fn);if(n)return n[1]||n[3];{let e=o.match(gn);if(e)return e[1].trim()}},v=class extends S{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",Lt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Ot(this.content)}};s(v,"replierKey","send"),s(v,"completeStreamKey","completeStream");var W=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",Lt)}};var V=class extends v{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},r);this.scriptInputs=t;this.scriptInputs=O(h({},t),{_script:e.toString()})}};var Pt="EventListenerCallbackMessage",ct=class extends S{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Pt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},q=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Pt);this.content={e:t}}};var mt=class extends I{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var At="ElementValueReplayMessage",lt=class extends S{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",At);s(this,"messageType","GetElementValueMessage")}},j=class extends w{constructor(e){super();this.content=e;s(this,"messageType",At)}};var ft=class extends I{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var ne=class extends I{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},me=class extends ne{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},G=class extends I{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var Kt="RefComponentCreatedMessage",le=class extends S{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",Kt);s(this,"messageType","CreateRefComponentMessage")}},P=class extends w{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",Kt)}};var fe=class extends I{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 Ft="DetectedMyopRefsMessage",gt=class extends S{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Ft)}},J=class extends w{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Ft);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var zt="GetAttributeReplayMessage",ut=class extends S{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",zt);s(this,"messageType","GetAttributeMessage")}},ge=class extends w{constructor(e){super();this.content=e;s(this,"messageType",zt)}};var _=class extends I{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var yt=class extends I{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},ue=class extends I{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var $t="CleanupReplayMessage",ye=class extends S{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",$t);s(this,"messageType","CleanupMessage")}},he=class extends w{constructor(e){super();this.customCleanup=e;s(this,"messageType",$t)}};var Me=class extends I{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var ht=class extends I{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},Ie=class extends I{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var Mt=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},oe=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===m.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===m.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new Mt(r),this.messageToHost(new me(r));return}if(t.messageType===m.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===m.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new he(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],_t(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 A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Y={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ie={message:"message",code:"code"},se=class{};s(se,"code","code"),s(se,"component","component");var X={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ee={Segment:"Segment",Promo:"Promo",AB:"AB"},re=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 E={id:"myop-id"};var Re=class extends M{constructor(){super(...arguments);s(this,"messageType",m.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(E.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(E.id);a&&r.push(new te(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new J(e.handlerUniqueId,r))})}};var C=(o,n)=>n.querySelectorAll("[".concat(E.id,"='").concat(o.refConfig.selector,"']")),Ut=(o,n)=>{let e=C(o,n);return e.length?e.item(0):null};var ve=class extends M{constructor(){super(...arguments);s(this,"messageType",m.BindClickMessage);s(this,"executor",e=>{let t=[];return C(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new N,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var ke=class extends M{constructor(){super(...arguments);s(this,"messageType",m.ChangeTextMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var It=o=>o!==Object(o),un=o=>typeof o=="function",Ct=o=>{if(It(o))return!0;if(un(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(It(e))continue;return!1}}return!0},k=(o,n={},e=!0,t=new WeakMap)=>{if(It(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]=k(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]=k(o[i],!0,e,t)):typeof a=="object"&&(r[i]=k(o[i],a,e,t)))}return r}return{}};var He=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=k,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var _e=class extends M{constructor(){super(...arguments);s(this,"messageType",m.ExecuteScriptMessage);s(this,"executor",e=>{He(e,r=>{this.messageToHost(new W(e.handlerUniqueId,r))},new re(document.documentElement))})}};var De="__federation__",Nt="onLoad";var ae=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Nt]&&window[De][o][Nt]({[o]:n})};var Be=class extends M{constructor(){super(...arguments);s(this,"messageType",m.AddEventListenerMessage);s(this,"executor",e=>{let t=C(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new q(e.handlerUniqueId,k(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Le=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetAttributeMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var z=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)||B.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===m.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 ye(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Me);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Wt={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 Ce=class extends z{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 fe(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new _("dispose")),super.dispose()})}hide(){this.send(new _("hide"))}show(){this.send(new _("show"))}inspect(){return this.send(new _("inspect"))}setHeightBasedOnDocumentElement(){this.send(new _("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new _("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var yn=(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},Oe=(o,n,e,t,r,i)=>{let a=yn("".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)}},Vt=(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),qt=(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."))},jt=(o,n,e)=>{let t=n.reduce((i,a)=>O(h({},i),{[a.name]:h({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Vt(p,a,o))return!1;if(p.behavior.type===ie.code){if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return qt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(F.create(p.behavior.ref)),c.push(l=>{d(l)}),p.behavior.params&&c.push(...p.behavior.params);let f=Te[p.behavior.message];o.send(new f(...c))}):null},set:(i,a,p)=>{let d=t[a];if(Vt(d,a,o))return!1;if(d.behavior.type===ie.code){if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let f=d.behavior,l=o.element.contentWindow,g=f.remap||a;if(l[g]=p,g==="myop_cta_handler"&&l.__myop_cta_queue){let u=l.__myop_cta_queue;l.__myop_cta_queue=null,u.forEach(y=>{o.markedForDisposed||p(y.action,y.payload)})}return!0}return qt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(F.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let f=Te[d.behavior.message];return o.send(new f(...c)),!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(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},hn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{Ct(p)||Wt.notSerializableRefCall(t,p)}),n.send(new V(({ref:p,propName:d,functionArgs:c,makeSerializable:f})=>{if(p){let l=p[d];return f(typeof l=="function"?p[d](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new V(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),xt=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 Ce(n.type,r,t);e.push(p),await r.initiated();let d=setTimeout(()=>{a("timeout")},5e3);r.send(new le(o.refConfig,n,O(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let f=e.find(l=>l.id==p.id);if(f!==p){r.refs[o.refConfig.name]=f,i(f);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(y=>y.type.id===l.componentDefinitionId).type,u=new Ce(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await bt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},bt=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 d;if(i.behavior.type==se.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let f=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=F.create("",i,o);try{let g=await xt(l,f,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let c=F.create("",i,o);o.refs[i.name]=hn(c,o),a()}catch(c){}}));try{await Promise.all(r)}catch(i){throw i}};var pe=class extends z{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 v(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new v(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});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,"observeAutoSize",e=>{var ce;let t=this.IframeElement,r=t.contentDocument;if(!r)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(R,L,ee)=>L!==void 0&&R<L?L:ee!==void 0&&R>ee?ee:R,a=R=>{if(R===void 0)return;if(typeof R=="number")return R;let L=parseFloat(R);return isNaN(L)?void 0:L},p=a(e==null?void 0:e.minWidth),d=a(e==null?void 0:e.maxWidth),c=a(e==null?void 0:e.minHeight),f=a(e==null?void 0:e.maxHeight),l=(ce=e==null?void 0:e.loaderMinHeight)!=null?ce:50,g=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,y=this.container.getBoundingClientRect(),Q=y.width===0,we=y.height===0||y.height===l,K=(e!=null&&e.forceAutoSize||Q)&&!g,T=(e!=null&&e.forceAutoSize||we)&&!u;if(!K&&!T)return()=>{};let D=()=>{var L;let R=t.contentDocument;if(R){let ee=R.documentElement.getBoundingClientRect(),Tt=Math.ceil(ee.width),Et=Math.ceil(ee.height),Rt=i(Tt,p,d),vt=i(Et,c,f);K&&(t.style.width="".concat(Rt,"px")),T&&(t.style.height="".concat(vt,"px"));let on=K&&d!==void 0&&Tt>d,sn=T&&f!==void 0&&Et>f;R.documentElement.style.overflowX=on?"auto":"hidden",R.documentElement.style.overflowY=sn?"auto":"hidden",(L=e==null?void 0:e.onSizeChange)==null||L.call(e,{width:Rt,height:vt,autoSizingWidth:K,autoSizingHeight:T})}};D();let Z=new ResizeObserver(D);return Z.observe(r.body),Z.observe(r.documentElement),()=>{Z.disconnect()}});s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new v(()=>{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 v(()=>{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=h({},e);if(t.messageType===m.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=Oe(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===m.In.MutationObserverMessage||e.messageType===m.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var $=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 Mn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Pe=class extends ${constructor(){super(...arguments);s(this,"type",A.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 d=H(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;let f="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=f,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,u])=>{u===""||u===null||u===void 0?a.setAttribute(g,""):a.setAttribute(g,String(u))});let l=t.loader.url;i!=null&&i._hasParent&&(l=Mn(l,"_myop-comp",d)),a.src=l,r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),a=this.appendChild(r,a,i)}return new pe(e,t,r,a,i)})}};var Ae={webcomponent_message_key:"myop_webcomponent_message"};var de=class extends z{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=h({},e),r=super.send(t),i=new CustomEvent(Ae.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=Oe(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 wt={},Ke=class extends ${constructor(){super(...arguments);s(this,"type",A.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;wt[a.url]?console.log("Module alreday loaded or in loading process"):wt[a.url]=new Promise((c,f)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{c()},g.onerror=()=>{f()},document.head.appendChild(g)}),await wt[a.url],await Dt(1);let p="myop-comp-".concat(H()),d=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,d,i),new de(e,t,r,d,i)})}};var Fe="0.3.14";var x=class extends Se{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(O(h({},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 ze=class extends x{constructor(){super(...arguments);s(this,"messageType",m.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=C(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{r(new N(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var $e=class extends x{constructor(){super(...arguments);s(this,"messageType",m.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Ue=class extends re{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ne=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(E.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(E.id);p&&i.push(new te(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new J(e.handlerUniqueId,i))});s(this,"messageType",m.DetectMyopRefsMessage)}};var We=class extends x{constructor(){super(...arguments);s(this,"messageType",m.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var Ve=class extends x{constructor(){super(...arguments);s(this,"messageType",m.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=C(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{r(new q(e.handlerUniqueId,k(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var qe=class extends x{constructor(){super(...arguments);s(this,"messageType",m.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let f=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(f.refs).forEach(g=>{let u=f.refs[g];u=u.__nonProxied||u,u.componentDefinition&&l.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new P(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new P(e.handlerUniqueId,[],!0));debugger}})().then()})}};var je=class extends x{constructor(){super(...arguments);s(this,"messageType",m.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{He(e,a=>{r(new W(e.handlerUniqueId,a))},t)})}};var Gt=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(E.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Gt(i),required:i.required,validity:k(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),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},Ge=class extends x{constructor(){super(...arguments);s(this,"messageType",m.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{C(e.ref,t.shadowRoot).forEach(a=>{r(new j(Gt(a)),e)})})}};var Je=class extends x{constructor(){super(...arguments);s(this,"messageType",m.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{C(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var xe=class extends oe{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Ae.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===m.InitMessage){let p=a.content.id;this.components[p].context=new Ue(e,t)}}}),setTimeout(()=>{this.messageToHost(new G)},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 $e(this.messageToHost,this.components),new Je(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Ne(this.messageToHost,this.components),new We(this.messageToHost,this.components),new Ve(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new qe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};ae("WebComponentSDK",xe);var Jt="";var Xt=[],Ye,Qt=async()=>(Ye||(Ye=new xe,Ye.init()),Ye);function In(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Y.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var Cn=(o,n,e)=>{customElements.define(o,In(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},xn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),bn=o=>(o=xn(o),o.replace(/_/g,"-"));var Xe=class extends ${constructor(){super(...arguments);s(this,"type",A.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(H()),d;if(a.shadowRootMode===Y.localFrame){let c=H(),f="myop-comp-".concat(c),l=document.createElement("iframe");l.id=f,l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),l=this.appendChild(r,l,i);let g=l.contentDocument||l.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),D=T.getElementById("myop_preview");D==null||D.removeAttribute("type");let Z=T.implementation.createHTMLDocument();Z.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ce=Z.body.firstChild;ce&&T.head&&T.head.insertBefore(T.importNode(ce,!0),T.head.firstChild),u=T.documentElement.outerHTML}else{let T=new DOMParser().parseFromString(a.HTML,"text/html"),D=T.getElementById("myop_preview");D&&(D.remove(),u=T.documentElement.outerHTML)}g.writeln(u);let y='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),Q="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(g.writeln("".concat(y).concat(Q)),(i==null?void 0:i.data)!==void 0){let K="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",T=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),D='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(T,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");g.writeln(K+D)}g.close();let we=new pe(e,t,r,l,i);return a.autoHeight&&(l.onload=()=>{we.observeSizeBasedOnDocumentElement()}),we}if(a.shadowRootMode===Y.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Qt().then(f=>{f.connectedCallback(d,d)})}else{let c=bn(e.name+t.id);Xt.includes(c)||(Cn(c,a.HTML,a.shadowRootMode),Xt.push(c)),d=document.createElement(c)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(r,d,i),new de(e,t,r,d,i)})}};var wn=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:ie.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ie.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Qe="__MYOP_CLOUD_REPOSITORY_MAIN__",Sn=()=>{if(typeof window<"u")return window[Qe];if(typeof globalThis<"u")return globalThis[Qe]},Tn=o=>{typeof window<"u"&&(window[Qe]=o),typeof globalThis<"u"&&(globalThis[Qe]=o)},U=class U{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"preloadedComponents",{});s(this,"userFlows",{});s(this,"_defaultEnv","production")}static get Main(){let n=Sn();return n||(U._main||(U._main=new U,Tn(U._main)),U._main)}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async fetchComponentV2(n,e,t){let r=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;!i&&r?(a=r.env,p=r.preview):(a=e||this._defaultEnv,p=t===!0?!0:t===!1?!1:!e);let d="".concat(n,":").concat(a,":").concat(p?"preview":"live");return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:a,usePreview:p,cacheKey:d,cached:d in this.variants}),this.variants[d]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:a,preview:p}),this.variants[d]=new Promise(async(c,f)=>{try{let l="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(a);p&&(l+="&preview=true");let y=(await(await fetch(l)).json()).item;if(!y){f(new Error('Component "'.concat(n,'" not found')));return}if(!y.consume_variant||!y.consume_variant.length){f(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(a,'"')));return}let Q=wn(y);c(Q)}catch(l){f(l)}})),await this.variants[d]}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(U,"_main",null);var be=U;var Zt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=it(t);switch(r){case"component":{let[a,p]=i,d=await be.Main.fetchComponent(a);if(d&&d.type.skins.find(f=>f.id===p))return d.instance.skinSelector={type:X.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=it(t),c=(await be.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(c&&c.instance.skinSelector.type===X.Segmented&&c.instance.resolvedExperiences){let f=c.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Ee.Segment){let l=f,u=c.instance.skinSelector.segments.find(y=>y.segmentId===l.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var en="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",B=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",Fe);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!==m.EnvelopedMessage)return;let e=n.data;if(e.messageType===m.InitRequest){this.components2init.forEach(r=>{r.send(new ne(r.id))});return}if(e.messageType===m.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===m.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===_.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 Pe,new Ke,new Xe];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 d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case X.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case X.Segmented:{let p=await r(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===Ee.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(l.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 f,l,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Zt(n);r&&(n=r);let i=h(h({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let y=await this.runSkinSelector(n,i);if(!y)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(y=await t.hooks.afterSkinSelected(h({},y))),n.instance.skinSelector={type:X.Dedicated,skin:y},t&&(t=h({},t),delete t.hooks),await xt(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(h({},p)));let d=this.componentsLoaders.find(y=>y.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(y=>y!==c),this.components2init=this.components2init.filter(y=>y!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=jt(c,n.type.props,p));try{await bt(c,n,this.components)}catch(y){throw y}return t!=null&&t.skipInit||await c.initiated(),c});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,h({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,h({relative:{direction:"before",child:r}},t))}})}};s(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:en}),window.myop.hostSDK=o}var En=window.myop.hostSDK;ae("hostSDK",En);var Ze=class extends M{constructor(){super(...arguments);s(this,"messageType",m.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(E.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await B.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new P(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new P(e.handlerUniqueId,[],!0));debugger}})().then()})}};var tn=(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 et=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&tn(document.body,()=>{this.messageToHost(new ue)})})}};var nn=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(E.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:nn(i),required:i.required,validity:k(i.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),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},tt=class extends M{constructor(){super(...arguments);s(this,"messageType",m.GetElementValueMessage);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{this.messageToHost(new j(nn(r)),e)})})}};var nt=class extends M{constructor(){super(...arguments);s(this,"messageType",m.GetAttributeMessage);s(this,"executor",e=>{let t=Ut(e.ref,document);t&&this.messageToHost(new ge(t.getAttribute(e.name)),e)})}};var ot=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new Ie)});return t.observe(document.body),()=>{t.disconnect()}})}};var st=class extends M{constructor(){super(...arguments);s(this,"messageType",m.SetInnerHtml);s(this,"executor",e=>{C(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var St=class extends oe{constructor(){super();s(this,"version",Fe);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(h({},e),"*")});s(this,"supportedHandlers",[new ke(this.messageToHost),new st(this.messageToHost),new ve(this.messageToHost),new Re(this.messageToHost),new _e(this.messageToHost),new Be(this.messageToHost),new Le(this.messageToHost),new tt(this.messageToHost),new et(this.messageToHost),new ot(this.messageToHost),new nt(this.messageToHost),new Ze(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new G)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};ae("IframeSDK",St);export{St as IframeSDK};
@@ -1818,7 +1818,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1818
1818
  };
1819
1819
 
1820
1820
  // version:myop-sdk-version
1821
- var myop_sdk_version_default = "0.3.13";
1821
+ var myop_sdk_version_default = "0.3.14";
1822
1822
 
1823
1823
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
1824
1824
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {