@myop/sdk 0.3.8 → 0.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{_IframeSDK.3a01f95a.js → _IframeSDK.119c0f6d.js} +1 -1
- package/dist/cjs/{_IframeSDK.3a01f95a.js.map → _IframeSDK.119c0f6d.js.map} +1 -1
- package/dist/cjs/{_IframeSDK.75aeb332.min.js → _IframeSDK.2c0a1224.min.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.e345ed2a.min.js → _WebComponentSDK.04e0d474.min.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.abdb86a3.js → _WebComponentSDK.61164d48.js} +1 -1
- package/dist/cjs/{_WebComponentSDK.abdb86a3.js.map → _WebComponentSDK.61164d48.js.map} +1 -1
- package/dist/cjs/{_hostSDK.881787f6.min.js → _hostSDK.6d93430d.min.js} +1 -1
- package/dist/cjs/{_hostSDK.9dbd966e.js → _hostSDK.d6305c86.js} +1 -1
- package/dist/cjs/{_hostSDK.9dbd966e.js.map → _hostSDK.d6305c86.js.map} +1 -1
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.js +2 -2
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +1 -1
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/index.js +2 -2
- package/dist/module/Iframe/index.js.map +1 -1
- package/dist/module/SDK.js +2 -2
- package/dist/module/SDK.js.map +1 -1
- package/dist/module/host/index.js +2 -2
- package/dist/module/host/index.js.map +1 -1
- package/dist/module/webcomponent/index.js +2 -2
- package/dist/module/webcomponent/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var kt=Object.defineProperty,sn=Object.defineProperties;var rn=Object.getOwnPropertyDescriptors;var vt=Object.getOwnPropertySymbols;var an=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable;var st=(o,n,e)=>n in o?kt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))an.call(n,e)&&st(o,e,n[e]);if(vt)for(var e of vt(n))pn.call(n,e)&&st(o,e,n[e]);return o},_=(o,n)=>sn(o,rn(n));var cn=(o,n)=>{for(var e in n)kt(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>st(o,typeof n!="symbol"?n+"":n,e);var Y=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 Ht=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},h=class{constructor(n){this.messageToHost=n}},Se=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var d={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 we={};cn(we,{AddEventListenerMessage:()=>ct,BaseMyopMessage:()=>M,BindClickMessage:()=>at,ChangeTextMessage:()=>pt,CleanupMessage:()=>ge,CleanupReplayMessage:()=>ue,ClickReplayMessage:()=>F,CreateRefComponentMessage:()=>me,CustomRefMessage:()=>U,DetectMyopRefsMessage:()=>ft,DetectedMyopRefsMessage:()=>q,DisposeMessage:()=>ye,ElementValueReplayMessage:()=>W,EnvelopedMessage:()=>de,EventListenerCallbackMessage:()=>N,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>R,ExecuteScriptReplyMessage:()=>$,GetAttributeMessage:()=>gt,GetAttributeReplayMessage:()=>le,GetElementValueMessage:()=>dt,InitMessage:()=>Z,InitRequest:()=>V,InitResponse:()=>ce,MessageDirection:()=>b,MutationObserverMessage:()=>fe,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>S,MyopElementMessage:()=>it,Ref:()=>A,RefComponentCreatedMessage:()=>O,ResizeObserverMessage:()=>he,SetAttributeMessage:()=>mt,SetInnerHtml:()=>lt,SetMutationObserverMessage:()=>ut,SetResizeObserverMessage:()=>yt,stripFunction:()=>_t});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 dn=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 rt=o=>{let n=dn(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 M=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}},it=class extends M{constructor(e){super();this.ref=e}},S=class extends M{constructor(e){super();this.replayToHandler=e}},w=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",H())}},A=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=_(y({},this),{component:null})}static create(n,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(r,t)}};var Bt="ClickReplayMessage",at=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},F=class extends S{constructor(){super(...arguments);s(this,"messageType",Bt)}};var pt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var Lt="ExecuteScriptReplyMessage",ln=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,fn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,_t=o=>{let n=o.match(ln);if(n)return n[1]||n[3];{let e=o.match(fn);if(e)return e[1].trim()}},R=class extends w{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=_t(this.content)}};s(R,"replierKey","send"),s(R,"completeStreamKey","completeStream");var $=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",Lt)}};var U=class extends R{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:c})=>{let m=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(c.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},r);this.scriptInputs=t;this.scriptInputs=_(y({},t),{_script:e.toString()})}};var Ot="EventListenerCallbackMessage",ct=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Ot);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},N=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Ot);this.content={e:t}}};var mt=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var Pt="ElementValueReplayMessage",dt=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Pt);s(this,"messageType","GetElementValueMessage")}},W=class extends S{constructor(e){super();this.content=e;s(this,"messageType",Pt)}};var lt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var Z=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ce=class extends Z{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},V=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var At="RefComponentCreatedMessage",me=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",At);s(this,"messageType","CreateRefComponentMessage")}},O=class extends S{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",At)}};var de=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Kt="DetectedMyopRefsMessage",ft=class extends w{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Kt)}},q=class extends S{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Kt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var zt="GetAttributeReplayMessage",gt=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",zt);s(this,"messageType","GetAttributeMessage")}},le=class extends S{constructor(e){super();this.content=e;s(this,"messageType",zt)}};var D=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var ut=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},fe=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Ft="CleanupReplayMessage",ge=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Ft);s(this,"messageType","CleanupMessage")}},ue=class extends S{constructor(e){super();this.customCleanup=e;s(this,"messageType",Ft)}};var ye=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var yt=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},he=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var ht=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},ee=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===d.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===d.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new ht(r),this.messageToHost(new ce(r));return}if(t.messageType===d.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(c=>c.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(c=>c.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===d.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ue(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Ht(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 P={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var j={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var oe={message:"message",code:"code"},te=class{};s(te,"code","code"),s(te,"component","component");var G={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Te={Segment:"Segment",Promo:"Promo",AB:"AB"},ne=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 T={id:"myop-id"};var Ee=class extends h{constructor(){super(...arguments);s(this,"messageType",d.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(T.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(T.id);a&&r.push(new Y(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new q(e.handlerUniqueId,r))})}};var I=(o,n)=>n.querySelectorAll("[".concat(T.id,"='").concat(o.refConfig.selector,"']")),$t=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Re=class extends h{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new F,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var ve=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var Mt=o=>o!==Object(o),gn=o=>typeof o=="function",It=o=>{if(Mt(o))return!0;if(gn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!It(e))return!1}else{if(Mt(e))continue;return!1}}return!0},v=(o,n={},e=!0,t=new WeakMap)=>{if(Mt(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]=v(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]=v(o[i],!0,e,t)):typeof a=="object"&&(r[i]=v(o[i],a,e,t)))}return r}return{}};var ke=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=v,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var He=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"executor",e=>{ke(e,r=>{this.messageToHost(new $(e.handlerUniqueId,r))},new ne(document.documentElement))})}};var De="__federation__",Ut="onLoad";var se=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Ut]&&window[De][o][Ut]({[o]:n})};var Be=class extends h{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new N(e.handlerUniqueId,v(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Le=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var K=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===d.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 ge(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ye);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Nt={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 Me=class extends K{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 de(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var un=(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},_e=(o,n,e,t,r,i)=>{let a=un("".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)}},Wt=(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),Vt=(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."))},qt=(o,n,e)=>{let t=n.reduce((i,a)=>_(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Wt(p,a,o))return!1;if(p.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return Vt(p,a,o),!1}return p.mode==="output"?new Promise(c=>{let m=[];p.behavior.ref&&m.push(A.create(p.behavior.ref)),m.push(l=>{c(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=we[p.behavior.message];o.send(new f(...m))}):null},set:(i,a,p)=>{let c=t[a];if(Wt(c,a,o))return!1;if(c.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let f=c.behavior;return o.element.contentWindow[f.remap||a]=p,!0}return Vt(c,a,o),!1}else if(c.mode==="input")if(c.behavior.type==="message"){let m=[];c.behavior.ref&&m.push(A.create(c.behavior.ref)),m.push(p),c.behavior.params&&m.push(...c.behavior.params);let f=we[c.behavior.message];return o.send(new f(...m)),!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(c.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},yn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{It(p)||Nt.notSerializableRefCall(t,p)}),n.send(new U(({ref:p,propName:c,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[c];return f(typeof l=="function"?p[c](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new U(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),Ct=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 Me(n.type,r,t);e.push(p),await r.initiated();let c=setTimeout(()=>{a("timeout")},5e3);r.send(new me(o.refConfig,n,_(y({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.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;m.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(C=>C.type.id===l.componentDefinitionId).type,u=new Me(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await xt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},xt=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 c;if(i.behavior.type==te.component){if(t){a();return}let m=i.behavior.componentId;m||(m=i.behavior.instance.componentId);let f=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(g=>g.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=A.create("",i,o);try{let g=await Ct(l,f,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let m=A.create("",i,o);o.refs[i.name]=yn(m,o),a()}catch(m){}}));try{await Promise.all(r)}catch(i){throw i}};var re=class extends K{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 R(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new R(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();t({height:p,width:c})});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 pe;let t=this.IframeElement,r=t.contentDocument;if(!r)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(E,L,Q)=>L!==void 0&&E<L?L:Q!==void 0&&E>Q?Q:E,a=E=>{if(E===void 0)return;if(typeof E=="number")return E;let L=parseFloat(E);return isNaN(L)?void 0:L},p=a(e==null?void 0:e.minWidth),c=a(e==null?void 0:e.maxWidth),m=a(e==null?void 0:e.minHeight),f=a(e==null?void 0:e.maxHeight),l=(pe=e==null?void 0:e.loaderMinHeight)!=null?pe:50,g=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,C=this.container.getBoundingClientRect(),xe=C.width===0,be=C.height===0||C.height===l,ae=(e!=null&&e.forceAutoSize||xe)&&!g,k=(e!=null&&e.forceAutoSize||be)&&!u;if(!ae&&!k)return()=>{};let X=()=>{var L;let E=t.contentDocument;if(E){let Q=E.documentElement.getBoundingClientRect(),wt=Math.ceil(Q.width),Tt=Math.ceil(Q.height),Et=i(wt,p,c),Rt=i(Tt,m,f);ae&&(t.style.width="".concat(Et,"px")),k&&(t.style.height="".concat(Rt,"px"));let nn=ae&&c!==void 0&&wt>c,on=k&&f!==void 0&&Tt>f;E.documentElement.style.overflowX=nn?"auto":"hidden",E.documentElement.style.overflowY=on?"auto":"hidden",(L=e==null?void 0:e.onSizeChange)==null||L.call(e,{width:Et,height:Rt,autoSizingWidth:ae,autoSizingHeight:k})}};X();let J=new ResizeObserver(X);return J.observe(r.body),J.observe(r.documentElement),()=>{J.disconnect()}});s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new R(()=>{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 R(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===d.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=_e(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===d.In.MutationObserverMessage||e.messageType===d.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var z=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 hn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Oe=class extends z{constructor(){super(...arguments);s(this,"type",P.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 c=H(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;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=hn(l,"_myop-comp",c)),a.src=l,r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),a=this.appendChild(r,a,i)}return new re(e,t,r,a,i)})}};var Pe={webcomponent_message_key:"myop_webcomponent_message"};var ie=class extends K{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Pe.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=_e(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 bt={},Ae=class extends z{constructor(){super(...arguments);s(this,"type",P.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;bt[a.url]?console.log("Module alreday loaded or in loading process"):bt[a.url]=new Promise((m,f)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{m()},g.onerror=()=>{f()},document.head.appendChild(g)}),await bt[a.url],await Dt(1);let p="myop-comp-".concat(H()),c=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),i!=null&&i._environment&&(c._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var Ke="0.3.8";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(_(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ze=class extends x{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=()=>{r(new F(e.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var Fe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var $e=class extends ne{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ue=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(T.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(T.id);p&&i.push(new Y(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new q(e.handlerUniqueId,i))});s(this,"messageType",d.DetectMyopRefsMessage)}};var Ne=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var We=class extends x{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=m=>{r(new N(e.handlerUniqueId,v(m,e.serializableSkeleton)))};p.addEventListener(e.type,c),a.push(()=>{p.removeEventListener(e.type,c)})}),()=>{a.forEach(p=>p())}})}};var Ve=class extends x{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),c=p.components.find(g=>g.id===e.options.id);c&&c.dispose();let m=p.components.indexOf(c);m!==-1&&p.components.splice(m,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 O(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var qe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{ke(e,a=>{r(new $(e.handlerUniqueId,a))},t)})}};var jt=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(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:jt(i),required:i.required,validity:v(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(c):(e.unmappedData.push(e.formData[p]),e.formData[p]=c):e.formData[p]=c:e.unmappedData.push(c)}}),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},je=class extends x{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new W(jt(a)),e)})})}};var Ge=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Ie=class extends ee{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Pe.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===d.InitMessage){let p=a.content.id;this.components[p].context=new $e(e,t)}}}),setTimeout(()=>{this.messageToHost(new V)},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 Fe(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Ue(this.messageToHost,this.components),new Ne(this.messageToHost,this.components),new We(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ve(this.messageToHost,this.components)]);s(this,"init",()=>{})}};se("WebComponentSDK",Ie);var Gt="";var Jt=[],Xe,Qt=async()=>(Xe||(Xe=new Ie,Xe.init()),Xe);function Mn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===j.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var In=(o,n,e)=>{customElements.define(o,Mn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Cn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),xn=o=>(o=Cn(o),o.replace(/_/g,"-"));var Je=class extends z{constructor(){super(...arguments);s(this,"type",P.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(H()),c;if(a.shadowRootMode===j.localFrame){let m=H(),f="myop-comp-".concat(m),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 k=new DOMParser().parseFromString(a.HTML,"text/html"),X=k.getElementById("myop_preview");X==null||X.removeAttribute("type");let J=k.implementation.createHTMLDocument();J.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let pe=J.body.firstChild;pe&&k.head&&k.head.insertBefore(k.importNode(pe,!0),k.head.firstChild),u=k.documentElement.outerHTML}g.writeln(u);let C='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),xe="<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>";g.writeln("".concat(C).concat(xe)),g.close();let be=new re(e,t,r,l,i);return a.autoHeight&&(l.onload=()=>{be.observeSizeBasedOnDocumentElement()}),be}if(a.shadowRootMode===j.none){let m=document.createElement("template");m.innerHTML=a.HTML,c=m.content.firstElementChild,Qt().then(f=>{f.connectedCallback(c,c)})}else{let m=xn(e.name+t.id);Jt.includes(m)||(In(m,a.HTML,a.shadowRootMode),Jt.push(m)),c=document.createElement(m)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var bn=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:oe.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:oe.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=class Qe{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"userFlows",{});s(this,"_defaultEnv","production")}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants}async fetchComponentV2(n,e,t){let r=e||this._defaultEnv,i="".concat(n,":").concat(r,":").concat(t?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,p)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(r);t&&(c+="&preview=true");let l=(await(await fetch(c)).json()).item;if(!l){p(new Error('Component "'.concat(n,'" not found')));return}if(!l.consume_variant||!l.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(r,'"')));return}let g=bn(l);a(g)}catch(c){p(c)}})),await this.variants[i]}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(Qe,"Main",new Qe);var Ce=Qe;var Yt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=rt(t);switch(r){case"component":{let[a,p]=i,c=await Ce.Main.fetchComponent(a);if(c&&c.type.skins.find(f=>f.id===p))return c.instance.skinSelector={type:G.Dedicated,skin:{id:p}},c}break;default:{let[a,p]=rt(t),m=(await Ce.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===G.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Te.Segment){let l=f,u=m.instance.skinSelector.segments.find(C=>C.segmentId===l.segment.id);if(u)return m.instance.skinSelector=u==null?void 0:u.skinSelector,m}}}break}}}finally{return null}};var Zt="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",Ke);s(this,"type2InstanceCount",{});s(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});s(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==d.EnvelopedMessage)return;let e=n.data;if(e.messageType===d.InitRequest){this.components2init.forEach(r=>{r.send(new Z(r.id))});return}if(e.messageType===d.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===d.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===D.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 Oe,new Ae,new Je];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 c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case G.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case G.Segmented:{let p=await r(n.segments,async c=>{if(c.segmentId==="Default")return!0;let m=e.find(u=>u.type===Te.Segment?u.segment.id===c.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(c.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 Yt(n);r&&(n=r);let i=y(y({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=y({},n),n.instance=y({},n.instance);let C=await this.runSkinSelector(n,i);if(!C)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(C=await t.hooks.afterSkinSelected(y({},C))),n.instance.skinSelector={type:G.Dedicated,skin:C},t&&(t=y({},t),delete t.hooks),await Ct(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let c=this.componentsLoaders.find(C=>C.type===p.loader.type);if(!c){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await c.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(C=>C!==m),this.components2init=this.components2init.filter(C=>C!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=qt(m,n.type.props,p));try{await xt(m,n,this.components)}catch(C){throw C}return t!=null&&t.skipInit||await m.initiated(),m});s(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,n.container,y({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(r),r.show(),n.dispose(),r}else{let r=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,y({relative:{direction:"before",child:r}},t))}})}};s(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt}),window.myop.hostSDK=o}var Sn=window.myop.hostSDK;se("hostSDK",Sn);var Ye=class extends h{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(T.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(c=>{let m=a.refs[c];m=m.__nonProxied||m,m.componentDefinition&&p.push({refName:c,componentDefinitionId:m.componentDefinition.id})}),this.messageToHost(new O(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var en=(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 Ze=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&en(document.body,()=>{this.messageToHost(new fe)})})}};var tn=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(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:tn(i),required:i.required,validity:v(i.validity,!0),myopId:a};e.unmappedData.push(c),p&&(!e.formData[p]||!e.formData[p].value||c.value)&&(e.formData[p]=c)}}),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},et=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new W(tn(r)),e)})})}};var tt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetAttributeMessage);s(this,"executor",e=>{let t=$t(e.ref,document);t&&this.messageToHost(new le(t.getAttribute(e.name)),e)})}};var nt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new he)});return t.observe(document.body),()=>{t.disconnect()}})}};var ot=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var St=class extends ee{constructor(){super();s(this,"version",Ke);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new ve(this.messageToHost),new ot(this.messageToHost),new Re(this.messageToHost),new Ee(this.messageToHost),new He(this.messageToHost),new Be(this.messageToHost),new Le(this.messageToHost),new et(this.messageToHost),new Ze(this.messageToHost),new nt(this.messageToHost),new tt(this.messageToHost),new Ye(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new V)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};se("IframeSDK",St);export{St as IframeSDK};
|
|
1
|
+
var kt=Object.defineProperty,sn=Object.defineProperties;var rn=Object.getOwnPropertyDescriptors;var vt=Object.getOwnPropertySymbols;var an=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable;var st=(o,n,e)=>n in o?kt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,y=(o,n)=>{for(var e in n||(n={}))an.call(n,e)&&st(o,e,n[e]);if(vt)for(var e of vt(n))pn.call(n,e)&&st(o,e,n[e]);return o},_=(o,n)=>sn(o,rn(n));var cn=(o,n)=>{for(var e in n)kt(o,e,{get:n[e],enumerable:!0})};var s=(o,n,e)=>st(o,typeof n!="symbol"?n+"":n,e);var Y=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 Ht=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},h=class{constructor(n){this.messageToHost=n}},Se=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var d={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 we={};cn(we,{AddEventListenerMessage:()=>ct,BaseMyopMessage:()=>M,BindClickMessage:()=>at,ChangeTextMessage:()=>pt,CleanupMessage:()=>ge,CleanupReplayMessage:()=>ue,ClickReplayMessage:()=>F,CreateRefComponentMessage:()=>me,CustomRefMessage:()=>U,DetectMyopRefsMessage:()=>ft,DetectedMyopRefsMessage:()=>q,DisposeMessage:()=>ye,ElementValueReplayMessage:()=>W,EnvelopedMessage:()=>de,EventListenerCallbackMessage:()=>N,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>R,ExecuteScriptReplyMessage:()=>$,GetAttributeMessage:()=>gt,GetAttributeReplayMessage:()=>le,GetElementValueMessage:()=>dt,InitMessage:()=>Z,InitRequest:()=>V,InitResponse:()=>ce,MessageDirection:()=>b,MutationObserverMessage:()=>fe,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>S,MyopElementMessage:()=>it,Ref:()=>A,RefComponentCreatedMessage:()=>O,ResizeObserverMessage:()=>he,SetAttributeMessage:()=>mt,SetInnerHtml:()=>lt,SetMutationObserverMessage:()=>ut,SetResizeObserverMessage:()=>yt,stripFunction:()=>_t});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 dn=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 rt=o=>{let n=dn(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 M=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}},it=class extends M{constructor(e){super();this.ref=e}},S=class extends M{constructor(e){super();this.replayToHandler=e}},w=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",H())}},A=class o{constructor(n,e){this.refConfig=n;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=_(y({},this),{component:null})}static create(n,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(r,t)}};var Bt="ClickReplayMessage",at=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Bt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},F=class extends S{constructor(){super(...arguments);s(this,"messageType",Bt)}};var pt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var Lt="ExecuteScriptReplyMessage",ln=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,fn=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,_t=o=>{let n=o.match(ln);if(n)return n[1]||n[3];{let e=o.match(fn);if(e)return e[1].trim()}},R=class extends w{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=_t(this.content)}};s(R,"replierKey","send"),s(R,"completeStreamKey","completeStream");var $=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",Lt)}};var U=class extends R{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:c})=>{let m=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return m.length?(c.ref=m[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},r);this.scriptInputs=t;this.scriptInputs=_(y({},t),{_script:e.toString()})}};var Ot="EventListenerCallbackMessage",ct=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",Ot);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},N=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",Ot);this.content={e:t}}};var mt=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var Pt="ElementValueReplayMessage",dt=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",Pt);s(this,"messageType","GetElementValueMessage")}},W=class extends S{constructor(e){super();this.content=e;s(this,"messageType",Pt)}};var lt=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var Z=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ce=class extends Z{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},V=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var At="RefComponentCreatedMessage",me=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",At);s(this,"messageType","CreateRefComponentMessage")}},O=class extends S{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",At)}};var de=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Kt="DetectedMyopRefsMessage",ft=class extends w{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Kt)}},q=class extends S{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Kt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var zt="GetAttributeReplayMessage",gt=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",zt);s(this,"messageType","GetAttributeMessage")}},le=class extends S{constructor(e){super();this.content=e;s(this,"messageType",zt)}};var D=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var ut=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},fe=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var Ft="CleanupReplayMessage",ge=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",Ft);s(this,"messageType","CleanupMessage")}},ue=class extends S{constructor(e){super();this.customCleanup=e;s(this,"messageType",Ft)}};var ye=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var yt=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},he=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var ht=class{constructor(n,e){this.id=n;this.context=e;s(this,"send",n=>{})}},ee=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===d.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===d.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new ht(r),this.messageToHost(new ce(r));return}if(t.messageType===d.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(c=>c.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(c=>c.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===d.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ue(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Ht(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 P={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var j={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var oe={message:"message",code:"code"},te=class{};s(te,"code","code"),s(te,"component","component");var G={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Te={Segment:"Segment",Promo:"Promo",AB:"AB"},ne=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 T={id:"myop-id"};var Ee=class extends h{constructor(){super(...arguments);s(this,"messageType",d.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(T.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(T.id);a&&r.push(new Y(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new q(e.handlerUniqueId,r))})}};var I=(o,n)=>n.querySelectorAll("[".concat(T.id,"='").concat(o.refConfig.selector,"']")),$t=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Re=class extends h{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new F,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var ve=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var Mt=o=>o!==Object(o),gn=o=>typeof o=="function",It=o=>{if(Mt(o))return!0;if(gn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!It(e))return!1}else{if(Mt(e))continue;return!1}}return!0},v=(o,n={},e=!0,t=new WeakMap)=>{if(Mt(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]=v(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]=v(o[i],!0,e,t)):typeof a=="object"&&(r[i]=v(o[i],a,e,t)))}return r}return{}};var ke=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=v,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var He=class extends h{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"executor",e=>{ke(e,r=>{this.messageToHost(new $(e.handlerUniqueId,r))},new ne(document.documentElement))})}};var De="__federation__",Ut="onLoad";var se=(o,n)=>{window[De]&&window[De][o]&&window[De][o][Ut]&&window[De][o][Ut]({[o]:n})};var Be=class extends h{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new N(e.handlerUniqueId,v(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Le=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var K=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===d.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 ge(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ye);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Nt={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 Me=class extends K{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 de(this.id,e)),e.handler=t,r});s(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var un=(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},_e=(o,n,e,t,r,i)=>{let a=un("".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)}},Wt=(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),Vt=(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."))},qt=(o,n,e)=>{let t=n.reduce((i,a)=>_(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Wt(p,a,o))return!1;if(p.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let m=p.behavior;return o.element.contentWindow[m.remap||a]}return Vt(p,a,o),!1}return p.mode==="output"?new Promise(c=>{let m=[];p.behavior.ref&&m.push(A.create(p.behavior.ref)),m.push(l=>{c(l)}),p.behavior.params&&m.push(...p.behavior.params);let f=we[p.behavior.message];o.send(new f(...m))}):null},set:(i,a,p)=>{let c=t[a];if(Wt(c,a,o))return!1;if(c.behavior.type===oe.code){if(e.loader.type===P.HTMLLoader&&e.loader.shadowRootMode===j.localFrame){let f=c.behavior;return o.element.contentWindow[f.remap||a]=p,!0}return Vt(c,a,o),!1}else if(c.mode==="input")if(c.behavior.type==="message"){let m=[];c.behavior.ref&&m.push(A.create(c.behavior.ref)),m.push(p),c.behavior.params&&m.push(...c.behavior.params);let f=we[c.behavior.message];return o.send(new f(...m)),!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(c.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,r),o},yn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{It(p)||Nt.notSerializableRefCall(t,p)}),n.send(new U(({ref:p,propName:c,functionArgs:m,makeSerializable:f})=>{if(p){let l=p[c];return f(typeof l=="function"?p[c](...m):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return n.send(new U(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),Ct=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 Me(n.type,r,t);e.push(p),await r.initiated();let c=setTimeout(()=>{a("timeout")},5e3);r.send(new me(o.refConfig,n,_(y({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.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;m.nestedRefs.forEach(l=>{let g=n.instance.resolvedNestedComponents.find(C=>C.type.id===l.componentDefinitionId).type,u=new Me(g,p);u.setInitiated(),p.refs[l.refName]=u,e.push(u)});try{await xt(p,n,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},xt=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 c;if(i.behavior.type==te.component){if(t){a();return}let m=i.behavior.componentId;m||(m=i.behavior.instance.componentId);let f=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(g=>g.type.id===m);if(!f)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=A.create("",i,o);try{let g=await Ct(l,f,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let m=A.create("",i,o);o.refs[i.name]=yn(m,o),a()}catch(m){}}));try{await Promise.all(r)}catch(i){throw i}};var re=class extends K{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 R(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>this.send(new R(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();t({height:p,width:c})});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 pe;let t=this.IframeElement,r=t.contentDocument;if(!r)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(E,L,Q)=>L!==void 0&&E<L?L:Q!==void 0&&E>Q?Q:E,a=E=>{if(E===void 0)return;if(typeof E=="number")return E;let L=parseFloat(E);return isNaN(L)?void 0:L},p=a(e==null?void 0:e.minWidth),c=a(e==null?void 0:e.maxWidth),m=a(e==null?void 0:e.minHeight),f=a(e==null?void 0:e.maxHeight),l=(pe=e==null?void 0:e.loaderMinHeight)!=null?pe:50,g=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,C=this.container.getBoundingClientRect(),xe=C.width===0,be=C.height===0||C.height===l,ae=(e!=null&&e.forceAutoSize||xe)&&!g,k=(e!=null&&e.forceAutoSize||be)&&!u;if(!ae&&!k)return()=>{};let X=()=>{var L;let E=t.contentDocument;if(E){let Q=E.documentElement.getBoundingClientRect(),wt=Math.ceil(Q.width),Tt=Math.ceil(Q.height),Et=i(wt,p,c),Rt=i(Tt,m,f);ae&&(t.style.width="".concat(Et,"px")),k&&(t.style.height="".concat(Rt,"px"));let nn=ae&&c!==void 0&&wt>c,on=k&&f!==void 0&&Tt>f;E.documentElement.style.overflowX=nn?"auto":"hidden",E.documentElement.style.overflowY=on?"auto":"hidden",(L=e==null?void 0:e.onSizeChange)==null||L.call(e,{width:Et,height:Rt,autoSizingWidth:ae,autoSizingHeight:k})}};X();let J=new ResizeObserver(X);return J.observe(r.body),J.observe(r.documentElement),()=>{J.disconnect()}});s(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new R(()=>{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 R(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===d.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=_e(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===d.In.MutationObserverMessage||e.messageType===d.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var z=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 hn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Oe=class extends z{constructor(){super(...arguments);s(this,"type",P.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 c=H(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;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=hn(l,"_myop-comp",c)),a.src=l,r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),a=this.appendChild(r,a,i)}return new re(e,t,r,a,i)})}};var Pe={webcomponent_message_key:"myop_webcomponent_message"};var ie=class extends K{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Pe.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=_e(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 bt={},Ae=class extends z{constructor(){super(...arguments);s(this,"type",P.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;bt[a.url]?console.log("Module alreday loaded or in loading process"):bt[a.url]=new Promise((m,f)=>{let l=a.url,g=document.createElement("script");g.type="module",g.src=l,g.onload=()=>{m()},g.onerror=()=>{f()},document.head.appendChild(g)}),await bt[a.url],await Dt(1);let p="myop-comp-".concat(H()),c=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),i!=null&&i._environment&&(c._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var Ke="0.3.9";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(_(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ze=class extends x{constructor(){super(...arguments);s(this,"messageType",d.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=()=>{r(new F(e.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var Fe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var $e=class extends ne{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Ue=class extends x{constructor(){super(...arguments);s(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(T.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(T.id);p&&i.push(new Y(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new q(e.handlerUniqueId,i))});s(this,"messageType",d.DetectMyopRefsMessage)}};var Ne=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var We=class extends x{constructor(){super(...arguments);s(this,"messageType",d.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=m=>{r(new N(e.handlerUniqueId,v(m,e.serializableSkeleton)))};p.addEventListener(e.type,c),a.push(()=>{p.removeEventListener(e.type,c)})}),()=>{a.forEach(p=>p())}})}};var Ve=class extends x{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(T.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=B.Instance(),c=p.components.find(g=>g.id===e.options.id);c&&c.dispose();let m=p.components.indexOf(c);m!==-1&&p.components.splice(m,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 O(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var qe=class extends x{constructor(){super(...arguments);s(this,"messageType",d.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{ke(e,a=>{r(new $(e.handlerUniqueId,a))},t)})}};var jt=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(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:jt(i),required:i.required,validity:v(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(c):(e.unmappedData.push(e.formData[p]),e.formData[p]=c):e.formData[p]=c:e.unmappedData.push(c)}}),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},je=class extends x{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new W(jt(a)),e)})})}};var Ge=class extends x{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Ie=class extends ee{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(this,"connectedCallback",(e,t)=>{e.addEventListener(Pe.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===d.InitMessage){let p=a.content.id;this.components[p].context=new $e(e,t)}}}),setTimeout(()=>{this.messageToHost(new V)},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 Fe(this.messageToHost,this.components),new Ge(this.messageToHost,this.components),new ze(this.messageToHost,this.components),new Ue(this.messageToHost,this.components),new Ne(this.messageToHost,this.components),new We(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new je(this.messageToHost,this.components),new Ve(this.messageToHost,this.components)]);s(this,"init",()=>{})}};se("WebComponentSDK",Ie);var Gt="";var Jt=[],Xe,Qt=async()=>(Xe||(Xe=new Ie,Xe.init()),Xe);function Mn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===j.open?"open":"closed",t=this.attachShadow({mode:e});Qt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var In=(o,n,e)=>{customElements.define(o,Mn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},Cn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),xn=o=>(o=Cn(o),o.replace(/_/g,"-"));var Je=class extends z{constructor(){super(...arguments);s(this,"type",P.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(H()),c;if(a.shadowRootMode===j.localFrame){let m=H(),f="myop-comp-".concat(m),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 k=new DOMParser().parseFromString(a.HTML,"text/html"),X=k.getElementById("myop_preview");X==null||X.removeAttribute("type");let J=k.implementation.createHTMLDocument();J.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let pe=J.body.firstChild;pe&&k.head&&k.head.insertBefore(k.importNode(pe,!0),k.head.firstChild),u=k.documentElement.outerHTML}g.writeln(u);let C='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),xe="<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>";g.writeln("".concat(C).concat(xe)),g.close();let be=new re(e,t,r,l,i);return a.autoHeight&&(l.onload=()=>{be.observeSizeBasedOnDocumentElement()}),be}if(a.shadowRootMode===j.none){let m=document.createElement("template");m.innerHTML=a.HTML,c=m.content.firstElementChild,Qt().then(f=>{f.connectedCallback(c,c)})}else{let m=xn(e.name+t.id);Jt.includes(m)||(In(m,a.HTML,a.shadowRootMode),Jt.push(m)),c=document.createElement(m)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(r,c,i),new ie(e,t,r,c,i)})}};var bn=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:oe.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:oe.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=class Qe{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;s(this,"variants",{});s(this,"userFlows",{});s(this,"_defaultEnv","production")}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants}async fetchComponentV2(n,e,t){let r=e||this._defaultEnv,i="".concat(n,":").concat(r,":").concat(t?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,p)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(r);t&&(c+="&preview=true");let l=(await(await fetch(c)).json()).item;if(!l){p(new Error('Component "'.concat(n,'" not found')));return}if(!l.consume_variant||!l.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(r,'"')));return}let g=bn(l);a(g)}catch(c){p(c)}})),await this.variants[i]}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(Qe,"Main",new Qe);var Ce=Qe;var Yt=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[r,...i]=rt(t);switch(r){case"component":{let[a,p]=i,c=await Ce.Main.fetchComponent(a);if(c&&c.type.skins.find(f=>f.id===p))return c.instance.skinSelector={type:G.Dedicated,skin:{id:p}},c}break;default:{let[a,p]=rt(t),m=(await Ce.Main.fetchFlow(a)).components.find(f=>f.type.id===o.type.id);if(m&&m.instance.skinSelector.type===G.Segmented&&m.instance.resolvedExperiences){let f=m.instance.resolvedExperiences.find(l=>l.id===p);if((f==null?void 0:f.type)===Te.Segment){let l=f,u=m.instance.skinSelector.segments.find(C=>C.segmentId===l.segment.id);if(u)return m.instance.skinSelector=u==null?void 0:u.skinSelector,m}}}break}}}finally{return null}};var Zt="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",Ke);s(this,"type2InstanceCount",{});s(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});s(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==d.EnvelopedMessage)return;let e=n.data;if(e.messageType===d.InitRequest){this.components2init.forEach(r=>{r.send(new Z(r.id))});return}if(e.messageType===d.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===d.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.down){r.message.messageType===D.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 Oe,new Ae,new Je];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 c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case G.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case G.Segmented:{let p=await r(n.segments,async c=>{if(c.segmentId==="Default")return!0;let m=e.find(u=>u.type===Te.Segment?u.segment.id===c.segmentId:!1);if(!m)throw new Error("experience not found");let l=m.segment,g=(t||{})[l.function];return g?await g():(console.warn("segmentId:".concat(c.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 Yt(n);r&&(n=r);let i=y(y({},(f=this.loaderHooks)!=null?f:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),a=e;if(a.myop)if(a.component){n=y({},n),n.instance=y({},n.instance);let C=await this.runSkinSelector(n,i);if(!C)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(C=await t.hooks.afterSkinSelected(y({},C))),n.instance.skinSelector={type:G.Dedicated,skin:C},t&&(t=y({},t),delete t.hooks),await Ct(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let c=this.componentsLoaders.find(C=>C.type===p.loader.type);if(!c){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let m=await c.load(n.type,p,e,t);m.isInitiated||this.components2init.push(m),m.bind("onDispose",()=>(this.components=this.components.filter(C=>C!==m),this.components2init=this.components2init.filter(C=>C!==m),!0)),this.components.push(m),(!t||t.connectProps!==!1)&&(m=qt(m,n.type.props,p));try{await xt(m,n,this.components)}catch(C){throw C}return t!=null&&t.skipInit||await m.initiated(),m});s(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,n.container,y({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(r),r.show(),n.dispose(),r}else{let r=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,y({relative:{direction:"before",child:r}},t))}})}};s(B,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt});if(!window.myop.hostSDK){let o=new B;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Zt}),window.myop.hostSDK=o}var Sn=window.myop.hostSDK;se("hostSDK",Sn);var Ye=class extends h{constructor(){super(...arguments);s(this,"messageType",d.CreateRefComponentMessage);s(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(T.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(c=>{let m=a.refs[c];m=m.__nonProxied||m,m.componentDefinition&&p.push({refName:c,componentDefinitionId:m.componentDefinition.id})}),this.messageToHost(new O(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(e.handlerUniqueId,[],!0));debugger}})().then()})}};var en=(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 Ze=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&en(document.body,()=>{this.messageToHost(new fe)})})}};var tn=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(T.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:tn(i),required:i.required,validity:v(i.validity,!0),myopId:a};e.unmappedData.push(c),p&&(!e.formData[p]||!e.formData[p].value||c.value)&&(e.formData[p]=c)}}),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},et=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new W(tn(r)),e)})})}};var tt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.GetAttributeMessage);s(this,"executor",e=>{let t=$t(e.ref,document);t&&this.messageToHost(new le(t.getAttribute(e.name)),e)})}};var nt=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new he)});return t.observe(document.body),()=>{t.disconnect()}})}};var ot=class extends h{constructor(){super(...arguments);s(this,"messageType",d.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var St=class extends ee{constructor(){super();s(this,"version",Ke);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new ve(this.messageToHost),new ot(this.messageToHost),new Re(this.messageToHost),new Ee(this.messageToHost),new He(this.messageToHost),new Be(this.messageToHost),new Le(this.messageToHost),new et(this.messageToHost),new Ze(this.messageToHost),new nt(this.messageToHost),new tt(this.messageToHost),new Ye(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new V)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};se("IframeSDK",St);export{St as IframeSDK};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var gt=Object.defineProperty,Ut=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var ft=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Fe=(o,n,e)=>n in o?gt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Nt.call(n,e)&&Fe(o,e,n[e]);if(ft)for(var e of ft(n))Vt.call(n,e)&&Fe(o,e,n[e]);return o},H=(o,n)=>Ut(o,Wt(n));var qt=(o,n)=>{for(var e in n)gt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>Fe(o,typeof n!="symbol"?n+"":n,e);var ue=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var ut=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},ze=class{constructor(n){this.messageToHost=n}},ye=class extends ze{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var g={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 he={};qt(he,{AddEventListenerMessage:()=>qe,BaseMyopMessage:()=>y,BindClickMessage:()=>Ne,ChangeTextMessage:()=>Ve,CleanupMessage:()=>ae,CleanupReplayMessage:()=>pe,ClickReplayMessage:()=>Y,CreateRefComponentMessage:()=>se,CustomRefMessage:()=>A,DetectMyopRefsMessage:()=>Xe,DetectedMyopRefsMessage:()=>ie,DisposeMessage:()=>ce,ElementValueReplayMessage:()=>te,EnvelopedMessage:()=>re,EventListenerCallbackMessage:()=>ee,ExecuteComponentMethod:()=>R,ExecuteScriptMessage:()=>w,ExecuteScriptReplyMessage:()=>Z,GetAttributeMessage:()=>Qe,GetAttributeReplayMessage:()=>Ye,GetElementValueMessage:()=>Ge,InitMessage:()=>N,InitRequest:()=>oe,InitResponse:()=>ne,MessageDirection:()=>b,MutationObserverMessage:()=>et,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>We,Ref:()=>L,RefComponentCreatedMessage:()=>V,ResizeObserverMessage:()=>nt,SetAttributeMessage:()=>je,SetInnerHtml:()=>Je,SetMutationObserverMessage:()=>Ze,SetResizeObserverMessage:()=>tt,stripFunction:()=>It});var E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var jt=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 Gt=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 Ue=o=>{let n=Gt(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(jt(n.slice(t,t+16)));return e};var yt=o=>new Promise(n=>setTimeout(n,o));var b=class{};r(b,"down","down"),r(b,"up","up");var y=class{constructor(){r(this,"id",E());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},We=class extends y{constructor(e){super();this.ref=e}},C=class extends y{constructor(e){super();this.replayToHandler=e}},x=class extends y{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",E())}},L=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=H(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var ht="ClickReplayMessage",Ne=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",ht);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},Y=class extends C{constructor(){super(...arguments);r(this,"messageType",ht)}};var Ve=class extends y{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Mt="ExecuteScriptReplyMessage",Jt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Xt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,It=o=>{let n=o.match(Jt);if(n)return n[1]||n[3];{let e=o.match(Xt);if(e)return e[1].trim()}},w=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Mt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=It(this.content)}};r(w,"replierKey","send"),r(w,"completeStreamKey","completeStream");var Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Mt)}};var A=class extends w{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:c})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(c.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},s);this.scriptInputs=t;this.scriptInputs=H(h({},t),{_script:e.toString()})}};var Ct="EventListenerCallbackMessage",qe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Ct);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ee=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Ct);this.content={e:t}}};var je=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var xt="ElementValueReplayMessage",Ge=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",xt);r(this,"messageType","GetElementValueMessage")}},te=class extends C{constructor(e){super();this.content=e;r(this,"messageType",xt)}};var Je=class extends y{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var N=class extends y{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ne=class extends N{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},oe=class extends y{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var bt="RefComponentCreatedMessage",se=class extends x{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",bt);r(this,"messageType","CreateRefComponentMessage")}},V=class extends C{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",bt)}};var re=class extends y{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var St="DetectedMyopRefsMessage",Xe=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",St)}},ie=class extends C{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",St);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var wt="GetAttributeReplayMessage",Qe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",wt);r(this,"messageType","GetAttributeMessage")}},Ye=class extends C{constructor(e){super();this.content=e;r(this,"messageType",wt)}};var R=class extends y{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ze=class extends y{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},et=class extends y{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var Tt="CleanupReplayMessage",ae=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",Tt);r(this,"messageType","CleanupMessage")}},pe=class extends C{constructor(e){super();this.customCleanup=e;r(this,"messageType",Tt)}};var ce=class extends y{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var tt=class extends y{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},nt=class extends y{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var ot=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},Me=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(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===g.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===g.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new ot(s),this.messageToHost(new ne(s));return}if(t.messageType===g.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(c=>c.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(c=>c.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===g.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new pe(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],ut(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!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 D={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var $={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var j={message:"message",code:"code"},q=class{};r(q,"code","code"),r(q,"component","component");var F={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ce={Segment:"Segment",Promo:"Promo",AB:"AB"},Ie=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var xe={webcomponent_message_key:"myop_webcomponent_message"};var I=class extends ye{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(H(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,s)}else debugger}else debugger})}};var B={id:"myop-id"};var v=(o,n)=>n.querySelectorAll("[".concat(B.id,"='").concat(o.refConfig.selector,"']"));var be=class extends I{constructor(){super(...arguments);r(this,"messageType",g.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=v(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=()=>{s(new Y(e.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var Se=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var we=class extends Ie{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Te=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(B.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(B.id);p&&i.push(new ue(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new ie(e.handlerUniqueId,i))});r(this,"messageType",g.DetectMyopRefsMessage)}};var Ee="__federation__",Et="onLoad";var Re=(o,n)=>{window[Ee]&&window[Ee][o]&&window[Ee][o][Et]&&window[Ee][o][Et]({[o]:n})};var ve=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var st=o=>o!==Object(o),Qt=o=>typeof o=="function",rt=o=>{if(st(o))return!0;if(Qt(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!rt(e))return!1}else{if(st(e))continue;return!1}}return!0},_=(o,n={},e=!0,t=new WeakMap)=>{if(st(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=_(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=_(o[i],!0,e,t)):typeof a=="object"&&(s[i]=_(o[i],a,e,t)))}return s}return{}};var ke=class extends I{constructor(){super(...arguments);r(this,"messageType",g.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=v(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=d=>{s(new ee(e.handlerUniqueId,_(d,e.serializableSkeleton)))};p.addEventListener(e.type,c),a.push(()=>{p.removeEventListener(e.type,c)})}),()=>{a.forEach(p=>p())}})}};var P=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(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 s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||O.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),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===g.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(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),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,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new ae(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ce);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Rt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var de=class extends P{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new re(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new R("dispose")),super.dispose()})}hide(){this.send(new R("hide"))}show(){this.send(new R("show"))}inspect(){return this.send(new R("inspect"))}setHeightBasedOnDocumentElement(){this.send(new R("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new R("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var Yt=(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},He=(o,n,e,t,s,i)=>{let a=Yt("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.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),kt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},Ht=(o,n,e)=>{let t=n.reduce((i,a)=>H(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(vt(p,a,o))return!1;if(p.behavior.type===j.code){if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===$.localFrame){let d=p.behavior;return o.element.contentWindow[d.remap||a]}return kt(p,a,o),!1}return p.mode==="output"?new Promise(c=>{let d=[];p.behavior.ref&&d.push(L.create(p.behavior.ref)),d.push(m=>{c(m)}),p.behavior.params&&d.push(...p.behavior.params);let l=he[p.behavior.message];o.send(new l(...d))}):null},set:(i,a,p)=>{let c=t[a];if(vt(c,a,o))return!1;if(c.behavior.type===j.code){if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===$.localFrame){let l=c.behavior;return o.element.contentWindow[l.remap||a]=p,!0}return kt(c,a,o),!1}else if(c.mode==="input")if(c.behavior.type==="message"){let d=[];c.behavior.ref&&d.push(L.create(c.behavior.ref)),d.push(p),c.behavior.params&&d.push(...c.behavior.params);let l=he[c.behavior.message];return o.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(c.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Zt=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{rt(p)||Rt.notSerializableRefCall(t,p)}),n.send(new A(({ref:p,propName:c,functionArgs:d,makeSerializable:l})=>{if(p){let m=p[c];return l(typeof m=="function"?p[c](...d):m,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new A(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),it=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(n.type,s,t);e.push(p),await s.initiated();let c=setTimeout(()=>{a("timeout")},5e3);s.send(new se(o.refConfig,n,H(h({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(c),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(m=>m.id==p.id);if(l!==p){s.refs[o.refConfig.name]=l,i(l);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;d.nestedRefs.forEach(m=>{let f=n.instance.resolvedNestedComponents.find(M=>M.type.id===m.componentDefinitionId).type,u=new de(f,p);u.setInitiated(),p.refs[m.refName]=u,e.push(u)});try{await at(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(m){a(m)}}))})},at=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var c;if(i.behavior.type==q.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(f=>f.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=L.create("",i,o);try{let f=await it(m,l,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let d=L.create("",i,o);o.refs[i.name]=Zt(d,o),a()}catch(d){}}));try{await Promise.all(s)}catch(i){throw i}};var G=class extends P{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new w(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new w(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();t({height:p,width:c})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{var Q;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(S,k,W)=>k!==void 0&&S<k?k:W!==void 0&&S>W?W:S,a=S=>{if(S===void 0)return;if(typeof S=="number")return S;let k=parseFloat(S);return isNaN(k)?void 0:k},p=a(e==null?void 0:e.minWidth),c=a(e==null?void 0:e.maxWidth),d=a(e==null?void 0:e.minHeight),l=a(e==null?void 0:e.maxHeight),m=(Q=e==null?void 0:e.loaderMinHeight)!=null?Q:50,f=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,M=this.container.getBoundingClientRect(),fe=M.width===0,ge=M.height===0||M.height===m,X=(e!=null&&e.forceAutoSize||fe)&&!f,T=(e!=null&&e.forceAutoSize||ge)&&!u;if(!X&&!T)return()=>{};let z=()=>{var k;let S=t.contentDocument;if(S){let W=S.documentElement.getBoundingClientRect(),ct=Math.ceil(W.width),dt=Math.ceil(W.height),mt=i(ct,p,c),lt=i(dt,d,l);X&&(t.style.width="".concat(mt,"px")),T&&(t.style.height="".concat(lt,"px"));let Ft=X&&c!==void 0&&ct>c,zt=T&&l!==void 0&&dt>l;S.documentElement.style.overflowX=Ft?"auto":"hidden",S.documentElement.style.overflowY=zt?"auto":"hidden",(k=e==null?void 0:e.onSizeChange)==null||k.call(e,{width:mt,height:lt,autoSizingWidth:X,autoSizingHeight:T})}};z();let U=new ResizeObserver(z);return U.observe(s.body),U.observe(s.documentElement),()=>{U.disconnect()}});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new w(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new w(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===g.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(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=He(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===g.In.MutationObserverMessage||e.messageType===g.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var K=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var en=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},De=class extends K{constructor(){super(...arguments);r(this,"type",D.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=E(),d="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=d;let l="\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=l,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([f,u])=>{u===""||u===null||u===void 0?a.setAttribute(f,""):a.setAttribute(f,String(u))});let m=t.loader.url;i!=null&&i._hasParent&&(m=en(m,"_myop-comp",c)),a.src=m,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}return new G(e,t,s,a,i)})}};var J=class extends P{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent(xe.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=He(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 pt={},Be=class extends K{constructor(){super(...arguments);r(this,"type",D.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;pt[a.url]?console.log("Module alreday loaded or in loading process"):pt[a.url]=new Promise((d,l)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{d()},f.onerror=()=>{l()},document.head.appendChild(f)}),await pt[a.url],await yt(1);let p="myop-comp-".concat(E()),c=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),i!=null&&i._environment&&(c._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,c,i),new J(e,t,s,c,i)})}};var Dt="0.3.8";var Bt="";var Lt=[],_e,Pt=async()=>(_e||(_e=new me,_e.init()),_e);function tn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===$.open?"open":"closed",t=this.attachShadow({mode:e});Pt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var nn=(o,n,e)=>{customElements.define(o,tn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},on=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),sn=o=>(o=on(o),o.replace(/_/g,"-"));var Le=class extends K{constructor(){super(...arguments);r(this,"type",D.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p="myop-comp-".concat(E()),c;if(a.shadowRootMode===$.localFrame){let d=E(),l="myop-comp-".concat(d),m=document.createElement("iframe");m.id=l,m.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 "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),m=this.appendChild(s,m,i);let f=m.contentDocument||m.contentWindow.document;f.open();let u=a.HTML;if(i!=null&&i._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),z=T.getElementById("myop_preview");z==null||z.removeAttribute("type");let U=T.implementation.createHTMLDocument();U.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let Q=U.body.firstChild;Q&&T.head&&T.head.insertBefore(T.importNode(Q,!0),T.head.firstChild),u=T.documentElement.outerHTML}f.writeln(u);let M='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),fe="<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>";f.writeln("".concat(M).concat(fe)),f.close();let ge=new G(e,t,s,m,i);return a.autoHeight&&(m.onload=()=>{ge.observeSizeBasedOnDocumentElement()}),ge}if(a.shadowRootMode===$.none){let d=document.createElement("template");d.innerHTML=a.HTML,c=d.content.firstElementChild,Pt().then(l=>{l.connectedCallback(c,c)})}else{let d=sn(e.name+t.id);Lt.includes(d)||(nn(d,a.HTML,a.shadowRootMode),Lt.push(d)),c=document.createElement(d)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(s,c,i),new J(e,t,s,c,i)})}};var rn=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:j.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:j.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Pe=class Pe{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"userFlows",{});r(this,"_defaultEnv","production")}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants}async fetchComponentV2(n,e,t){let s=e||this._defaultEnv,i="".concat(n,":").concat(s,":").concat(t?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,p)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(s);t&&(c+="&preview=true");let m=(await(await fetch(c)).json()).item;if(!m){p(new Error('Component "'.concat(n,'" not found')));return}if(!m.consume_variant||!m.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let f=rn(m);a(f)}catch(c){p(c)}})),await this.variants[i]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.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(s){t(s)}})),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(s){t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(Pe,"Main",new Pe);var le=Pe;var Ot=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=Ue(t);switch(s){case"component":{let[a,p]=i,c=await le.Main.fetchComponent(a);if(c&&c.type.skins.find(l=>l.id===p))return c.instance.skinSelector={type:F.Dedicated,skin:{id:p}},c}break;default:{let[a,p]=Ue(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===o.type.id);if(d&&d.instance.skinSelector.type===F.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(m=>m.id===p);if((l==null?void 0:l.type)===Ce.Segment){let m=l,u=d.instance.skinSelector.segments.find(M=>M.segmentId===m.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var Kt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",O=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"initiated",!1);r(this,"version",Dt);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==g.EnvelopedMessage)return;let e=n.data;if(e.messageType===g.InitRequest){this.components2init.forEach(s=>{s.send(new N(s.id))});return}if(e.messageType===g.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let s=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===g.EnvelopedMessage){let s=e,i=this.components.find(a=>a.id===s.destination);if(i){if(s.direction===b.down){s.message.messageType===R.name?i.onMessageReceived(s.message):(s.message.route=s.route,i.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.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)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new De,new Be,new Le];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let i=new s(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case F.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case F.Segmented:{let p=await s(n.segments,async c=>{if(c.segmentId==="Default")return!0;let d=e.find(u=>u.type===Ce.Segment?u.segment.id===c.segmentId:!1);if(!d)throw new Error("experience not found");let m=d.segment,f=(t||{})[m.function];return f?await f():(console.warn("segmentId:".concat(c.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var l,m,f,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await Ot(n);s&&(n=s);let i=h(h({},(l=this.loaderHooks)!=null?l:{}),(m=t==null?void 0:t.hooks)!=null?m:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let M=await this.runSkinSelector(n,i);if(!M)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(M=await t.hooks.afterSkinSelected(h({},M))),n.instance.skinSelector={type:F.Dedicated,skin:M},t&&(t=h({},t),delete t.hooks),await it(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 c=this.componentsLoaders.find(M=>M.type===p.loader.type);if(!c){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await c.load(n.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(M=>M!==d),this.components2init=this.components2init.filter(M=>M!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=Ht(d,n.type.props,p));try{await at(d,n,this.components)}catch(M){throw M}return t!=null&&t.skipInit||await d.initiated(),d});r(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 s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(O,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Kt});if(!window.myop.hostSDK){let o=new O;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Kt}),window.myop.hostSDK=o}var an=window.myop.hostSDK;Re("hostSDK",an);var Oe=class extends I{constructor(){super(...arguments);r(this,"messageType",g.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(B.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=O.Instance(),c=p.components.find(f=>f.id===e.options.id);c&&c.dispose();let d=p.components.indexOf(c);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),m=[];Object.keys(l.refs).forEach(f=>{let u=l.refs[f];u=u.__nonProxied||u,u.componentDefinition&&m.push({refName:f,componentDefinitionId:u.componentDefinition.id})}),s(new V(e.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new V(e.handlerUniqueId,[],!0));debugger}})().then()})}};var At=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=_,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var Ke=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{At(e,a=>{s(new Z(e.handlerUniqueId,a))},t)})}};var $t=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(B.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:$t(i),required:i.required,validity:_(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(c):(e.unmappedData.push(e.formData[p]),e.formData[p]=c):e.formData[p]=c:e.unmappedData.push(c)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ae=class extends I{constructor(){super(...arguments);r(this,"messageType",g.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{v(e.ref,t.shadowRoot).forEach(a=>{s(new te($t(a)),e)})})}};var $e=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var me=class extends Me{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(xe.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===g.InitMessage){let p=a.content.id;this.components[p].context=new we(e,t)}}}),setTimeout(()=>{this.messageToHost(new oe)},1)});r(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Se(this.messageToHost,this.components),new $e(this.messageToHost,this.components),new be(this.messageToHost,this.components),new Te(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new Oe(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Re("WebComponentSDK",me);export{me as WebComponentSDK};
|
|
1
|
+
var gt=Object.defineProperty,Ut=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var ft=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,Vt=Object.prototype.propertyIsEnumerable;var Fe=(o,n,e)=>n in o?gt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))Nt.call(n,e)&&Fe(o,e,n[e]);if(ft)for(var e of ft(n))Vt.call(n,e)&&Fe(o,e,n[e]);return o},H=(o,n)=>Ut(o,Wt(n));var qt=(o,n)=>{for(var e in n)gt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>Fe(o,typeof n!="symbol"?n+"":n,e);var ue=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var ut=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},ze=class{constructor(n){this.messageToHost=n}},ye=class extends ze{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var g={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 he={};qt(he,{AddEventListenerMessage:()=>qe,BaseMyopMessage:()=>y,BindClickMessage:()=>Ne,ChangeTextMessage:()=>Ve,CleanupMessage:()=>ae,CleanupReplayMessage:()=>pe,ClickReplayMessage:()=>Y,CreateRefComponentMessage:()=>se,CustomRefMessage:()=>A,DetectMyopRefsMessage:()=>Xe,DetectedMyopRefsMessage:()=>ie,DisposeMessage:()=>ce,ElementValueReplayMessage:()=>te,EnvelopedMessage:()=>re,EventListenerCallbackMessage:()=>ee,ExecuteComponentMethod:()=>R,ExecuteScriptMessage:()=>w,ExecuteScriptReplyMessage:()=>Z,GetAttributeMessage:()=>Qe,GetAttributeReplayMessage:()=>Ye,GetElementValueMessage:()=>Ge,InitMessage:()=>N,InitRequest:()=>oe,InitResponse:()=>ne,MessageDirection:()=>b,MutationObserverMessage:()=>et,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>We,Ref:()=>L,RefComponentCreatedMessage:()=>V,ResizeObserverMessage:()=>nt,SetAttributeMessage:()=>je,SetInnerHtml:()=>Je,SetMutationObserverMessage:()=>Ze,SetResizeObserverMessage:()=>tt,stripFunction:()=>It});var E=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var jt=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 Gt=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 Ue=o=>{let n=Gt(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(jt(n.slice(t,t+16)));return e};var yt=o=>new Promise(n=>setTimeout(n,o));var b=class{};r(b,"down","down"),r(b,"up","up");var y=class{constructor(){r(this,"id",E());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},We=class extends y{constructor(e){super();this.ref=e}},C=class extends y{constructor(e){super();this.replayToHandler=e}},x=class extends y{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",E())}},L=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=H(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var ht="ClickReplayMessage",Ne=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",ht);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},Y=class extends C{constructor(){super(...arguments);r(this,"messageType",ht)}};var Ve=class extends y{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Mt="ExecuteScriptReplyMessage",Jt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Xt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,It=o=>{let n=o.match(Jt);if(n)return n[1]||n[3];{let e=o.match(Xt);if(e)return e[1].trim()}},w=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Mt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=It(this.content)}};r(w,"replierKey","send"),r(w,"completeStreamKey","completeStream");var Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Mt)}};var A=class extends w{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:c})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(c.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(c)):null},s);this.scriptInputs=t;this.scriptInputs=H(h({},t),{_script:e.toString()})}};var Ct="EventListenerCallbackMessage",qe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Ct);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ee=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Ct);this.content={e:t}}};var je=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var xt="ElementValueReplayMessage",Ge=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",xt);r(this,"messageType","GetElementValueMessage")}},te=class extends C{constructor(e){super();this.content=e;r(this,"messageType",xt)}};var Je=class extends y{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var N=class extends y{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ne=class extends N{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},oe=class extends y{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var bt="RefComponentCreatedMessage",se=class extends x{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",bt);r(this,"messageType","CreateRefComponentMessage")}},V=class extends C{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",bt)}};var re=class extends y{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var St="DetectedMyopRefsMessage",Xe=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",St)}},ie=class extends C{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",St);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var wt="GetAttributeReplayMessage",Qe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",wt);r(this,"messageType","GetAttributeMessage")}},Ye=class extends C{constructor(e){super();this.content=e;r(this,"messageType",wt)}};var R=class extends y{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ze=class extends y{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},et=class extends y{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var Tt="CleanupReplayMessage",ae=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",Tt);r(this,"messageType","CleanupMessage")}},pe=class extends C{constructor(e){super();this.customCleanup=e;r(this,"messageType",Tt)}};var ce=class extends y{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var tt=class extends y{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},nt=class extends y{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var ot=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},Me=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(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===g.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===g.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new ot(s),this.messageToHost(new ne(s));return}if(t.messageType===g.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(c=>c.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(c=>c.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===g.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new pe(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],ut(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!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 D={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var $={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var j={message:"message",code:"code"},q=class{};r(q,"code","code"),r(q,"component","component");var F={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},Ce={Segment:"Segment",Promo:"Promo",AB:"AB"},Ie=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var xe={webcomponent_message_key:"myop_webcomponent_message"};var I=class extends ye{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(H(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,s)}else debugger}else debugger})}};var B={id:"myop-id"};var v=(o,n)=>n.querySelectorAll("[".concat(B.id,"='").concat(o.refConfig.selector,"']"));var be=class extends I{constructor(){super(...arguments);r(this,"messageType",g.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=v(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=()=>{s(new Y(e.handlerUniqueId))};p.addEventListener("click",c),a.push(()=>{p.removeEventListener("click",c)})}),()=>{a.forEach(p=>p())}})}};var Se=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var we=class extends Ie{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Te=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(B.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(B.id);p&&i.push(new ue(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new ie(e.handlerUniqueId,i))});r(this,"messageType",g.DetectMyopRefsMessage)}};var Ee="__federation__",Et="onLoad";var Re=(o,n)=>{window[Ee]&&window[Ee][o]&&window[Ee][o][Et]&&window[Ee][o][Et]({[o]:n})};var ve=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var st=o=>o!==Object(o),Qt=o=>typeof o=="function",rt=o=>{if(st(o))return!0;if(Qt(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!rt(e))return!1}else{if(st(e))continue;return!1}}return!0},_=(o,n={},e=!0,t=new WeakMap)=>{if(st(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=_(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=_(o[i],!0,e,t)):typeof a=="object"&&(s[i]=_(o[i],a,e,t)))}return s}return{}};var ke=class extends I{constructor(){super(...arguments);r(this,"messageType",g.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=v(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let c=d=>{s(new ee(e.handlerUniqueId,_(d,e.serializableSkeleton)))};p.addEventListener(e.type,c),a.push(()=>{p.removeEventListener(e.type,c)})}),()=>{a.forEach(p=>p())}})}};var P=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(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 s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||O.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),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===g.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(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=b.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),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,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new ae(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new ce);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Rt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var de=class extends P{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new re(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new R("dispose")),super.dispose()})}hide(){this.send(new R("hide"))}show(){this.send(new R("show"))}inspect(){return this.send(new R("inspect"))}setHeightBasedOnDocumentElement(){this.send(new R("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new R("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var Yt=(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},He=(o,n,e,t,s,i)=>{let a=Yt("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.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),kt=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},Ht=(o,n,e)=>{let t=n.reduce((i,a)=>H(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(vt(p,a,o))return!1;if(p.behavior.type===j.code){if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===$.localFrame){let d=p.behavior;return o.element.contentWindow[d.remap||a]}return kt(p,a,o),!1}return p.mode==="output"?new Promise(c=>{let d=[];p.behavior.ref&&d.push(L.create(p.behavior.ref)),d.push(m=>{c(m)}),p.behavior.params&&d.push(...p.behavior.params);let l=he[p.behavior.message];o.send(new l(...d))}):null},set:(i,a,p)=>{let c=t[a];if(vt(c,a,o))return!1;if(c.behavior.type===j.code){if(e.loader.type===D.HTMLLoader&&e.loader.shadowRootMode===$.localFrame){let l=c.behavior;return o.element.contentWindow[l.remap||a]=p,!0}return kt(c,a,o),!1}else if(c.mode==="input")if(c.behavior.type==="message"){let d=[];c.behavior.ref&&d.push(L.create(c.behavior.ref)),d.push(p),c.behavior.params&&d.push(...c.behavior.params);let l=he[c.behavior.message];return o.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(c.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Zt=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{rt(p)||Rt.notSerializableRefCall(t,p)}),n.send(new A(({ref:p,propName:c,functionArgs:d,makeSerializable:l})=>{if(p){let m=p[c];return l(typeof m=="function"?p[c](...d):m,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new A(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),it=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(n.type,s,t);e.push(p),await s.initiated();let c=setTimeout(()=>{a("timeout")},5e3);s.send(new se(o.refConfig,n,H(h({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(c),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(m=>m.id==p.id);if(l!==p){s.refs[o.refConfig.name]=l,i(l);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;d.nestedRefs.forEach(m=>{let f=n.instance.resolvedNestedComponents.find(M=>M.type.id===m.componentDefinitionId).type,u=new de(f,p);u.setInitiated(),p.refs[m.refName]=u,e.push(u)});try{await at(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(m){a(m)}}))})},at=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var c;if(i.behavior.type==q.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(c=n.instance.resolvedNestedComponents)==null?void 0:c.find(f=>f.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=L.create("",i,o);try{let f=await it(m,l,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let d=L.create("",i,o);o.refs[i.name]=Zt(d,o),a()}catch(d){}}));try{await Promise.all(s)}catch(i){throw i}};var G=class extends P{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new w(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new w(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:c}=document.documentElement.getBoundingClientRect();t({height:p,width:c})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{var Q;let t=this.IframeElement,s=t.contentDocument;if(!s)return console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible"),()=>{};let i=(S,k,W)=>k!==void 0&&S<k?k:W!==void 0&&S>W?W:S,a=S=>{if(S===void 0)return;if(typeof S=="number")return S;let k=parseFloat(S);return isNaN(k)?void 0:k},p=a(e==null?void 0:e.minWidth),c=a(e==null?void 0:e.maxWidth),d=a(e==null?void 0:e.minHeight),l=a(e==null?void 0:e.maxHeight),m=(Q=e==null?void 0:e.loaderMinHeight)!=null?Q:50,f=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,M=this.container.getBoundingClientRect(),fe=M.width===0,ge=M.height===0||M.height===m,X=(e!=null&&e.forceAutoSize||fe)&&!f,T=(e!=null&&e.forceAutoSize||ge)&&!u;if(!X&&!T)return()=>{};let z=()=>{var k;let S=t.contentDocument;if(S){let W=S.documentElement.getBoundingClientRect(),ct=Math.ceil(W.width),dt=Math.ceil(W.height),mt=i(ct,p,c),lt=i(dt,d,l);X&&(t.style.width="".concat(mt,"px")),T&&(t.style.height="".concat(lt,"px"));let Ft=X&&c!==void 0&&ct>c,zt=T&&l!==void 0&&dt>l;S.documentElement.style.overflowX=Ft?"auto":"hidden",S.documentElement.style.overflowY=zt?"auto":"hidden",(k=e==null?void 0:e.onSizeChange)==null||k.call(e,{width:mt,height:lt,autoSizingWidth:X,autoSizingHeight:T})}};z();let U=new ResizeObserver(z);return U.observe(s.body),U.observe(s.documentElement),()=>{U.disconnect()}});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new w(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new w(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===g.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(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=He(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===g.In.MutationObserverMessage||e.messageType===g.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var K=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var en=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},De=class extends K{constructor(){super(...arguments);r(this,"type",D.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=E(),d="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=d;let l="\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=l,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([f,u])=>{u===""||u===null||u===void 0?a.setAttribute(f,""):a.setAttribute(f,String(u))});let m=t.loader.url;i!=null&&i._hasParent&&(m=en(m,"_myop-comp",c)),a.src=m,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}return new G(e,t,s,a,i)})}};var J=class extends P{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent(xe.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=He(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 pt={},Be=class extends K{constructor(){super(...arguments);r(this,"type",D.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;pt[a.url]?console.log("Module alreday loaded or in loading process"):pt[a.url]=new Promise((d,l)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{d()},f.onerror=()=>{l()},document.head.appendChild(f)}),await pt[a.url],await yt(1);let p="myop-comp-".concat(E()),c=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),i!=null&&i._environment&&(c._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,c,i),new J(e,t,s,c,i)})}};var Dt="0.3.9";var Bt="";var Lt=[],_e,Pt=async()=>(_e||(_e=new me,_e.init()),_e);function tn(o,n){return class extends HTMLElement{connectedCallback(){let e=n===$.open?"open":"closed",t=this.attachShadow({mode:e});Pt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var nn=(o,n,e)=>{customElements.define(o,tn(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},on=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),sn=o=>(o=on(o),o.replace(/_/g,"-"));var Le=class extends K{constructor(){super(...arguments);r(this,"type",D.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p="myop-comp-".concat(E()),c;if(a.shadowRootMode===$.localFrame){let d=E(),l="myop-comp-".concat(d),m=document.createElement("iframe");m.id=l,m.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 "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),m=this.appendChild(s,m,i);let f=m.contentDocument||m.contentWindow.document;f.open();let u=a.HTML;if(i!=null&&i._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),z=T.getElementById("myop_preview");z==null||z.removeAttribute("type");let U=T.implementation.createHTMLDocument();U.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let Q=U.body.firstChild;Q&&T.head&&T.head.insertBefore(T.importNode(Q,!0),T.head.firstChild),u=T.documentElement.outerHTML}f.writeln(u);let M='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),fe="<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>";f.writeln("".concat(M).concat(fe)),f.close();let ge=new G(e,t,s,m,i);return a.autoHeight&&(m.onload=()=>{ge.observeSizeBasedOnDocumentElement()}),ge}if(a.shadowRootMode===$.none){let d=document.createElement("template");d.innerHTML=a.HTML,c=d.content.firstElementChild,Pt().then(l=>{l.connectedCallback(c,c)})}else{let d=sn(e.name+t.id);Lt.includes(d)||(nn(d,a.HTML,a.shadowRootMode),Lt.push(d)),c=document.createElement(d)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),c.id=p,i!=null&&i.hidden&&(c.style.opacity="0",c.style.position="absolute",c.style.height="0",c.style.width="0",c.style.pointerEvents="none",c.style.visibility="hidden"),this.appendChild(s,c,i),new J(e,t,s,c,i)})}};var rn=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:j.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:j.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Pe=class Pe{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"userFlows",{});r(this,"_defaultEnv","production")}setEnvironment(n){this._defaultEnv=n}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants}async fetchComponentV2(n,e,t){let s=e||this._defaultEnv,i="".concat(n,":").concat(s,":").concat(t?"preview":"live");return this.variants[i]||(this.variants[i]=new Promise(async(a,p)=>{try{let c="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(s);t&&(c+="&preview=true");let m=(await(await fetch(c)).json()).item;if(!m){p(new Error('Component "'.concat(n,'" not found')));return}if(!m.consume_variant||!m.consume_variant.length){p(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let f=rn(m);a(f)}catch(c){p(c)}})),await this.variants[i]}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.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(s){t(s)}})),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(s){t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(Pe,"Main",new Pe);var le=Pe;var Ot=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=Ue(t);switch(s){case"component":{let[a,p]=i,c=await le.Main.fetchComponent(a);if(c&&c.type.skins.find(l=>l.id===p))return c.instance.skinSelector={type:F.Dedicated,skin:{id:p}},c}break;default:{let[a,p]=Ue(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===o.type.id);if(d&&d.instance.skinSelector.type===F.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(m=>m.id===p);if((l==null?void 0:l.type)===Ce.Segment){let m=l,u=d.instance.skinSelector.segments.find(M=>M.segmentId===m.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var Kt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",O=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"initiated",!1);r(this,"version",Dt);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==b.up&&n.data.messageType!==g.EnvelopedMessage)return;let e=n.data;if(e.messageType===g.InitRequest){this.components2init.forEach(s=>{s.send(new N(s.id))});return}if(e.messageType===g.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let s=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(e.messageType===g.EnvelopedMessage){let s=e,i=this.components.find(a=>a.id===s.destination);if(i){if(s.direction===b.down){s.message.messageType===R.name?i.onMessageReceived(s.message):(s.message.route=s.route,i.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let t=this.components.find(s=>s.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)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new De,new Be,new Le];if(this.componentsLoaders=[...e],n){let t={};n.forEach(s=>{let i=new s(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(s=>{t[s.type]||(t[s.type]=s)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let c of a)if(await p(c))return c}switch(n.type){case"DedicatedSkin":case F.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case F.Segmented:{let p=await s(n.segments,async c=>{if(c.segmentId==="Default")return!0;let d=e.find(u=>u.type===Ce.Segment?u.segment.id===c.segmentId:!1);if(!d)throw new Error("experience not found");let m=d.segment,f=(t||{})[m.function];return f?await f():(console.warn("segmentId:".concat(c.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var l,m,f,u;if(!e){debugger;throw new Error("no container was found for this component")}let s=await Ot(n);s&&(n=s);let i=h(h({},(l=this.loaderHooks)!=null?l:{}),(m=t==null?void 0:t.hooks)!=null?m:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let M=await this.runSkinSelector(n,i);if(!M)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(M=await t.hooks.afterSkinSelected(h({},M))),n.instance.skinSelector={type:F.Dedicated,skin:M},t&&(t=h({},t),delete t.hooks),await it(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 c=this.componentsLoaders.find(M=>M.type===p.loader.type);if(!c){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await c.load(n.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(M=>M!==d),this.components2init=this.components2init.filter(M=>M!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=Ht(d,n.type.props,p));try{await at(d,n,this.components)}catch(M){throw M}return t!=null&&t.skipInit||await d.initiated(),d});r(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 s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(O,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Kt});if(!window.myop.hostSDK){let o=new O;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Kt}),window.myop.hostSDK=o}var an=window.myop.hostSDK;Re("hostSDK",an);var Oe=class extends I{constructor(){super(...arguments);r(this,"messageType",g.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(B.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=O.Instance(),c=p.components.find(f=>f.id===e.options.id);c&&c.dispose();let d=p.components.indexOf(c);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),m=[];Object.keys(l.refs).forEach(f=>{let u=l.refs[f];u=u.__nonProxied||u,u.componentDefinition&&m.push({refName:f,componentDefinitionId:u.componentDefinition.id})}),s(new V(e.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new V(e.handlerUniqueId,[],!0));debugger}})().then()})}};var At=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=_,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var Ke=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{At(e,a=>{s(new Z(e.handlerUniqueId,a))},t)})}};var $t=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(B.id),p=i.getAttribute("name"),c={id:i.id,name:p,value:$t(i),required:i.required,validity:_(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(c):(e.unmappedData.push(e.formData[p]),e.formData[p]=c):e.formData[p]=c:e.unmappedData.push(c)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ae=class extends I{constructor(){super(...arguments);r(this,"messageType",g.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{v(e.ref,t.shadowRoot).forEach(a=>{s(new te($t(a)),e)})})}};var $e=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{v(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var me=class extends Me{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(xe.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===g.InitMessage){let p=a.content.id;this.components[p].context=new we(e,t)}}}),setTimeout(()=>{this.messageToHost(new oe)},1)});r(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Se(this.messageToHost,this.components),new $e(this.messageToHost,this.components),new be(this.messageToHost,this.components),new Te(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new Oe(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Re("WebComponentSDK",me);export{me as WebComponentSDK};
|
|
@@ -1805,7 +1805,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
1805
1805
|
};
|
|
1806
1806
|
|
|
1807
1807
|
// version:myop-sdk-version
|
|
1808
|
-
var myop_sdk_version_default = "0.3.
|
|
1808
|
+
var myop_sdk_version_default = "0.3.9";
|
|
1809
1809
|
|
|
1810
1810
|
// src/host/embeddedSDK.ts
|
|
1811
1811
|
var EMBEDDED_SDK_CONTENT = "";
|