@myop/sdk 0.1.40 → 0.1.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/bundled-declarations.d.ts +24 -9
  2. package/dist/cjs/{_IframeSDK.5af88b19.js → _IframeSDK.4fce182a.js} +36 -21
  3. package/dist/cjs/_IframeSDK.4fce182a.js.map +7 -0
  4. package/dist/cjs/_IframeSDK.6ba9f7e0.min.js +1 -0
  5. package/dist/cjs/{_WebComponentSDK.dec2905a.js → _WebComponentSDK.a2aed5b5.js} +36 -21
  6. package/dist/cjs/_WebComponentSDK.a2aed5b5.js.map +7 -0
  7. package/dist/cjs/_WebComponentSDK.dc12528b.min.js +1 -0
  8. package/dist/cjs/_hostSDK.5ea0f6d9.min.js +1 -0
  9. package/dist/cjs/{_hostSDK.fcf2c04e.js → _hostSDK.f1314596.js} +36 -21
  10. package/dist/cjs/_hostSDK.f1314596.js.map +7 -0
  11. package/dist/cjs/myop_sdk.js +11 -11
  12. package/dist/cjs/myop_sdk.js.map +1 -1
  13. package/dist/cjs/myop_sdk.min.js +1 -1
  14. package/dist/module/Iframe/index.js +42 -22
  15. package/dist/module/Iframe/index.js.map +2 -2
  16. package/dist/module/SDK.js +42 -22
  17. package/dist/module/SDK.js.map +2 -2
  18. package/dist/module/common/index.d.ts +23 -9
  19. package/dist/module/common/index.js +11 -1
  20. package/dist/module/common/index.js.map +2 -2
  21. package/dist/module/host/hostSDK.d.ts +1 -0
  22. package/dist/module/host/index.js +42 -22
  23. package/dist/module/host/index.js.map +2 -2
  24. package/dist/module/webcomponent/index.js +42 -22
  25. package/dist/module/webcomponent/index.js.map +2 -2
  26. package/package.json +1 -1
  27. package/dist/cjs/_IframeSDK.3a618a6c.min.js +0 -1
  28. package/dist/cjs/_IframeSDK.5af88b19.js.map +0 -7
  29. package/dist/cjs/_WebComponentSDK.54454042.min.js +0 -1
  30. package/dist/cjs/_WebComponentSDK.dec2905a.js.map +0 -7
  31. package/dist/cjs/_hostSDK.47eaab83.min.js +0 -1
  32. package/dist/cjs/_hostSDK.fcf2c04e.js.map +0 -7
@@ -1 +0,0 @@
1
- var Ze=Object.defineProperty,xt=Object.defineProperties;var bt=Object.getOwnPropertyDescriptors;var Qe=Object.getOwnPropertySymbols;var Tt=Object.prototype.hasOwnProperty,wt=Object.prototype.propertyIsEnumerable;var ke=(o,n,t)=>n in o?Ze(o,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[n]=t,h=(o,n)=>{for(var t in n||(n={}))Tt.call(n,t)&&ke(o,t,n[t]);if(Qe)for(var t of Qe(n))wt.call(n,t)&&ke(o,t,n[t]);return o},R=(o,n)=>xt(o,bt(n));var St=(o,n)=>{for(var t in n)Ze(o,t,{get:n[t],enumerable:!0})};var i=(o,n,t)=>ke(o,typeof n!="symbol"?n+"":n,t);var ne=class{constructor(n,t,e,s,r){this.myopId=n;this.htmlTagName=t;this.BoundingRect=e;this.offsetTop=s;this.offsetLeft=r;i(this,"type","MyopElementRef")}};var Ye=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},He=class{constructor(n){this.messageToHost=n}},oe=class extends He{constructor(t,e){super(t);this.messageToHost=t;this.context=e}};var l={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 se={};St(se,{AddEventListenerMessage:()=>_e,BaseMyopMessage:()=>y,BindClickMessage:()=>Be,ChangeTextMessage:()=>Le,CleanupMessage:()=>Q,CleanupReplayMessage:()=>Z,ClickReplayMessage:()=>z,CreateRefComponentMessage:()=>G,CustomRefMessage:()=>L,DetectMyopRefsMessage:()=>Fe,DetectedMyopRefsMessage:()=>X,DisposeMessage:()=>Y,ElementValueReplayMessage:()=>q,EnvelopedMessage:()=>J,EventListenerCallbackMessage:()=>W,ExecuteComponentMethod:()=>w,ExecuteScriptMessage:()=>b,ExecuteScriptReplyMessage:()=>N,GetAttributeMessage:()=>$e,GetAttributeReplayMessage:()=>Ae,GetElementValueMessage:()=>Oe,InitMessage:()=>P,InitRequest:()=>j,InitResponse:()=>V,MessageDirection:()=>x,MutationObserverMessage:()=>ze,MyopBindMessage:()=>C,MyopBindReplayMessage:()=>I,MyopElementMessage:()=>De,Ref:()=>k,RefComponentCreatedMessage:()=>O,ResizeObserverMessage:()=>We,SetAttributeMessage:()=>Pe,SetInnerHtml:()=>Ke,SetMutationObserverMessage:()=>Ue,SetResizeObserverMessage:()=>Ne,stripFunction:()=>st});var T=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Rt=o=>{let n=[...o].map(t=>t.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 Et=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let t=atob(n);return Uint8Array.from(t,e=>e.charCodeAt(0))};var et=o=>{let n=Et(o);if(n.length%16!==0)throw new Error("Invalid input length");let t=[];for(let e=0;e<n.length;e+=16)t.push(Rt(n.slice(e,e+16)));return t};var tt=o=>new Promise(n=>setTimeout(n,o));var x=class{};i(x,"down","down"),i(x,"up","up");var y=class{constructor(){i(this,"id",T());i(this,"myop",!0);i(this,"content");i(this,"source");i(this,"destination");i(this,"route");i(this,"ref");i(this,"direction");i(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},De=class extends y{constructor(t){super();this.ref=t}},I=class extends y{constructor(t){super();this.replayToHandler=t}},C=class extends y{constructor(t){super();this.handler=t;i(this,"handlerUniqueId",T())}},k=class o{constructor(n,t){this.refConfig=n;this.component=t;i(this,"myop",!0);i(this,"__nonProxied");this.__nonProxied=R(h({},this),{component:null})}static create(n,t,e){let s=t;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,e)}};var nt="ClickReplayMessage",Be=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",nt);i(this,"messageType","BindClickMessage");i(this,"cleanable",!0)}},z=class extends I{constructor(){super(...arguments);i(this,"messageType",nt)}};var Le=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","ChangeTextMessage");this.content=e}};var ot="ExecuteScriptReplyMessage",vt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,kt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,st=o=>{let n=o.match(vt);if(n)return n[1]||n[3];{let t=o.match(kt);if(t)return t[1].trim()}},b=class extends C{constructor(t,e=()=>{},s){super(e);this.scriptInputs=s;i(this,"replyMessageKey",ot);i(this,"messageType","ExecuteScriptMessage");i(this,"script","");this.script=t.toString(),this.content=t.toString(),this.content=st(this.content)}};i(b,"replierKey","send"),i(b,"completeStreamKey","completeStream");var N=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.content=e;i(this,"messageType",ot)}};var L=class extends b{constructor(t,e,s=()=>{}){super(({rootRef:r,elementId:a,_script:p,__scriptInputs:d})=>{let c=(r.shadowRoot||r.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=e;this.scriptInputs=R(h({},e),{_script:t.toString()})}};var rt="EventListenerCallbackMessage",_e=class extends C{constructor(t,e,s){super(s);this.ref=t;this.type=e;this.handler=s;i(this,"replyMessageKey",rt);i(this,"messageType","AddEventListenerMessage");i(this,"cleanable",!0);i(this,"serializableSkeleton",!1)}withSerializableSkeleton(t){return this.serializableSkeleton=t,this}},W=class extends I{constructor(t,e){super(t);this.replayToHandler=t;this.e=e;i(this,"messageType",rt);this.content={e}}};var Pe=class extends y{constructor(t,e,s){super();this.ref=t;this.name=e;this.value=s;i(this,"messageType","SetAttributeMessage")}};var it="ElementValueReplayMessage",Oe=class extends C{constructor(t,e){super(e);this.ref=t;i(this,"replyMessageKey",it);i(this,"messageType","GetElementValueMessage")}},q=class extends I{constructor(t){super();this.content=t;i(this,"messageType",it)}};var Ke=class extends y{constructor(t,e){super();this.ref=t;i(this,"messageType","SetInnerHtml");this.content=e}};var P=class extends y{constructor(t){super();i(this,"messageType","InitMessage");this.content={id:t}}isTypeof(t){return t.messageType===this.messageType}},V=class extends P{constructor(){super(...arguments);i(this,"messageType","InitResponse")}},j=class extends y{constructor(){super(...arguments);i(this,"messageType","InitRequest")}};var at="RefComponentCreatedMessage",G=class extends C{constructor(t,e,s,r){super(r);this.refConfig=t;this.nestedComponentConfig=e;this.options=s;i(this,"replyMessageKey",at);i(this,"messageType","CreateRefComponentMessage")}},O=class extends I{constructor(t,e,s){super(t);this.replayToHandler=t;this.nestedRefs=e;this.failed=s;i(this,"messageType",at)}};var J=class extends y{constructor(t,e){super();this.destination=t;this.message=e;i(this,"messageType","EnvelopedMessage");let s=e;this.route=[t,...s.route?s.route:[]]}};var pt="DetectedMyopRefsMessage",Fe=class extends C{constructor(){super(...arguments);i(this,"messageType","DetectMyopRefsMessage");i(this,"replyMessageKey",pt)}},X=class extends I{constructor(t,e){super(t);this.replayToHandler=t;i(this,"messageType",pt);this.content=e}isTypeof(t){return t.messageType===this.messageType}};var dt="GetAttributeReplayMessage",$e=class extends C{constructor(t,e,s){super(s);this.ref=t;this.name=e;i(this,"replyMessageKey",dt);i(this,"messageType","GetAttributeMessage")}},Ae=class extends I{constructor(t){super();this.content=t;i(this,"messageType",dt)}};var w=class extends y{constructor(t){super();this.method=t;i(this,"messageType","ExecuteComponentMethod")}};var Ue=class extends y{constructor(){super(...arguments);i(this,"messageType","SetMutationObserverMessage")}},ze=class extends y{constructor(){super(...arguments);i(this,"messageType","MutationObserverMessage")}};var ct="CleanupReplayMessage",Q=class extends C{constructor(t,e){super(e);this.cleanupForMessageId=t;i(this,"replyMessageKey",ct);i(this,"messageType","CleanupMessage")}},Z=class extends I{constructor(t){super();this.customCleanup=t;i(this,"messageType",ct)}};var Y=class extends y{constructor(){super(...arguments);i(this,"messageType","DisposeMessage")}};var Ne=class extends y{constructor(){super(...arguments);i(this,"cleanable",!0);i(this,"messageType","SetResizeObserverMessage")}},We=class extends y{constructor(){super(...arguments);i(this,"messageType","ResizeObserverMessage")}};var qe=class{constructor(n,t){this.id=n;this.context=t;i(this,"send",n=>{})}},re=class{constructor(){i(this,"messageToHandleAfterInit",[]);i(this,"components",{});i(this,"alwaysPassEnvelopesToHost",!1);i(this,"messageCleanupCache",{})}handleIncomeMessages(n){let t=n.data?n.data:n.detail;if(!(!t||!t.myop)){let e=t;if(e.direction!==x.down)return;if(e.messageType===l.DisposeMessage){e.destination&&delete this.components[e.destination];return}if(e.messageType===l.InitMessage){let s=e.content.id;if(this.components[s])return;this.components[s]=new qe(s),this.messageToHost(new V(s));return}if(e.messageType===l.EnvelopedMessage){let s=e,r=s.message;if(e=r,this.alwaysPassEnvelopesToHost||this.components[e.destination]){let a=myop.hostSDK.components.find(d=>d.id===r.destination);if(a){a.send(r);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(r);return}}else return}if(e.messageType){if(e.messageType===l.CleanupMessage){let r=e,a=this.messageCleanupCache[r.cleanupForMessageId],p=new Z(!!a);p.destination=e.destination,a?(delete this.messageCleanupCache[r.cleanupForMessageId],Ye(a).then(()=>{this.messageToHost(p,r)}).catch(()=>{})):this.messageToHost(p,r);return}let s=!1;this.supportedHandlers.forEach(r=>{if(r.messageType===e.messageType){s=!0;let a=r.executor(e);if(e.cleanable&&a&&(this.messageCleanupCache[e.id]=a),a&&!e.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.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&&e.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(e.messageType,", handler executor was - ").concat(r.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 F={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"};var ae={open:"open",closed:"closed",none:"none",localFrame:"localFrame"},K=class{};i(K,"code","code"),i(K,"component","component");var $={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},pe={Segment:"Segment",Promo:"Promo",AB:"AB"},ie=class{constructor(n,t){this.container=n;this.shadowRoot=t;i(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));i(this,"getRoot",()=>this.shadowRoot||this.container)}};var de={webcomponent_message_key:"myop_webcomponent_message"};var M=class extends oe{constructor(t,e){super(t);this.context=e;i(this,"executor",t=>{if(t.destination){let e=t.destination;if(this.context[e].context){let s=(r,a)=>{this.messageToHost(R(h({},r),{source:t.destination?t.destination:t.source,destination:t.source?t.source:t.destination}),a)};return this.innerExecutor(t,this.context[e].context,s)}else debugger}else debugger})}};var E={id:"myop-id"};var S=(o,n)=>n.querySelectorAll("[".concat(E.id,"='").concat(o.refConfig.selector,"']"));var ce=class extends M{constructor(){super(...arguments);i(this,"messageType",l.BindClickMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let d=()=>{s(new z(t.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var me=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ChangeTextMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.textContent=t.content})})}};var le=class extends ie{constructor(t,e){super(t,e);this.container=t;this.shadowRoot=e}};var fe=class extends M{constructor(){super(...arguments);i(this,"innerExecutor",(t,e)=>{let s=e.shadowRoot.querySelectorAll("[".concat(E.id,"]")),r=[];s.forEach(a=>{let p=a.getAttribute(E.id);p&&r.push(new ne(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new X(t.handlerUniqueId,r))});i(this,"messageType",l.DetectMyopRefsMessage)}};var ge="__federation__",mt="onLoad";var ue=(o,n)=>{window[ge]&&window[ge][o]&&window[ge][o][mt]&&window[ge][o][mt]({[o]:n})};var ye=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetAttributeMessage);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.setAttribute(t.name,t.value)})})}};var Ve=o=>o!==Object(o),Ht=o=>typeof o=="function",je=o=>{if(Ve(o))return!0;if(Ht(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let t=o[n];if(typeof t=="object"){if(!je(t))return!1}else{if(Ve(t))continue;return!1}}return!0},v=(o,n={},t=!0,e=new WeakMap)=>{if(Ve(o))return o;if(Array.isArray(o)){if(e.has(o))return e.get(o);let s=[];e.set(o,s);for(let r=0;r<o.length;r++){let a=o[r];s[r]=v(a,n,t,e)}return s}if(o!==null&&typeof o=="object"){if(e.has(o))return e.get(o);let s={};e.set(o,s);for(let r in o){let a=typeof n=="boolean"?n:n[r];a&&(a===!0?(t?o[r]!==void 0:o[r])&&(s[r]=v(o[r],!0,t,e)):typeof a=="object"&&(s[r]=v(o[r],a,t,e)))}return s}return{}};var he=class extends M{constructor(){super(...arguments);i(this,"messageType",l.AddEventListenerMessage);i(this,"innerExecutor",(t,e,s)=>{let r=S(t.ref,e.shadowRoot),a=[];return r.forEach(p=>{let d=c=>{s(new W(t.handlerUniqueId,v(c,t.serializableSkeleton)))};p.addEventListener(t.type,d),a.push(()=>{p.removeEventListener(t.type,d)})}),()=>{a.forEach(p=>p())}})}};var H=class{constructor(n,t,e){this.componentDefinition=n;this.container=t;i(this,"id","");i(this,"messageHandlers",{});i(this,"element");i(this,"_markedForDisposed",!1);i(this,"bind",(n,t)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(t)||this.messageHandlers[n].push(t)});i(this,"bindWhen",(n,t,e)=>{if(!e)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],r=a=>t(a)?(e(a),!0):!1;return s.push(r),()=>{let a=s.indexOf(r);a>-1&&s.splice(a,1)}});i(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});i(this,"isInitiated",!1);i(this,"_whenInitiatedResolve");i(this,"_whenInitiatedReject");i(this,"_whenInitiated",new Promise((n,t)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=t}));i(this,"initiated",()=>this._whenInitiated);i(this,"props",{});i(this,"refs",{});this.id=(e==null?void 0:e.id)||D.Instance().assignId(n);let s=e!=null&&e.timeout?e==null?void 0:e.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===l.ExecuteComponentMethod){let e=n;return this[e.method]?this[e.method](e.content):console.log("method not found ".concat(e.method," on component"),this),!0}let t=this.messageHandlers[n.messageType];if(t&&t.length){let e=!1;return t.forEach(s=>{e=e||s(n)}),e}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=x.down;let t=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),t()}),e=n.handler;delete n.handler,this.send(n),n.handler=e}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=x.down;let t;if(n.handler){let e=n;t=this.bindWhen(e.replyMessageKey,s=>s.replayToHandler===e.handlerUniqueId,e.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Q(n.id,e=>{})),t&&t()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new Y);let n=this.messageHandlers.onDispose;n&&n.forEach(t=>{t(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var lt={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var ee=class extends H{constructor(t,e,s){super(t,e.container,s);this.componentDefinition=t;this.parent=e;i(this,"send",t=>{let e=t.handler,s=super.send(t);return this.parent.send(new J(this.id,t)),t.handler=e,s});i(this,"dispose",()=>{this.isInitiated&&this.send(new w("dispose")),super.dispose()})}hide(){this.send(new w("hide"))}show(){this.send(new w("show"))}inspect(){return this.send(new w("inspect"))}setHeightBasedOnDocumentElement(){this.send(new w("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new w("setHeightBasedOnScrollHeight"))}onMessageReceived(t){return super.onMessageReceived(t)}};var Dt=(o,n,t)=>{let e=document.createElement("a");return e.textContent=o,e.style.position="relative",e.style.padding="0 5px",e.style.fontSize="14px",e.style.top="0",e.style.top="".concat(n,"px"),e.style.transform="translateX(-50%)",e.target="_blank",e.href="https://dashboard.myop.dev/dashboard/component/".concat(t.id),e},Me=(o,n,t,e,s,r)=>{let a=Dt("".concat(r.name," : ").concat(n),t,r);return e.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",e.removeChild(a)}},ft=(o,n)=>{let t=n.reduce((s,r)=>R(h({},s),{[r.name]:h({},r)}),{}),e={get:(s,r)=>{let a=t[r];return a.mode==="output"?new Promise(p=>{let d=[];a.behavior.ref&&d.push(k.create(a.behavior.ref)),d.push(u=>{p(u)}),a.behavior.params&&d.push(...a.behavior.params);let c=se[a.behavior.message];o.send(new c(...d))}):null},set:(s,r,a)=>{let p=t[r];if(!p)throw new 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(r,"\n")+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(o.componentDefinition.id," or consult the developer guide."));if(p.mode==="input")if(p.behavior.type==="message"){let d=[];p.behavior.ref&&d.push(k.create(p.behavior.ref)),d.push(a),p.behavior.params&&d.push(...p.behavior.params);let c=se[p.behavior.message];return o.send(new c(...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(r,"\n")+"Behavior Field: ".concat(p.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,e),o},Bt=(o,n)=>new Proxy(o,{get(t,e){return t[e]?t[e]:(...r)=>new Promise(a=>{r.forEach(p=>{je(p)||lt.notSerializableRefCall(e,p)}),n.send(new L(({ref:p,propName:d,functionArgs:c,makeSerializable:u})=>{if(p){let m=p[d];return u(typeof m=="function"?p[d](...c):m,!0)}return null},{elementId:t.refConfig.selector,propName:e,functionArgs:r},p=>{a(p.content)}))})},set(t,e,s){return n.send(new L(({ref:r,propName:a,propValue:p})=>{r&&(r[a]=p)},{elementId:t.refConfig.selector,propValue:s,propName:e},r=>{})),!0}}),Ge=async(o,n,t,e)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(r,a)=>{let p=new ee(n.type,s,e);t.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new G(o.refConfig,n,R(h({},e||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let u=t.find(m=>m.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,r(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(m=>{let f=n.instance.resolvedNestedComponents.find(_=>_.type.id===m.componentDefinitionId).type,g=new ee(f,p);g.setInitiated(),p.refs[m.refName]=g,t.push(g)});try{await Je(p,n,t,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),r(p)}catch(m){a(m)}}))})},Je=async(o,n,t,e=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(r=>new Promise(async(a,p)=>{var d;if(r.behavior.type==K.component){if(e){a();return}let c=r.behavior.componentId;c||(c=r.behavior.instance.componentId);let u=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=k.create("",r,o);try{let f=await Ge(m,u,t);o.refs[r.name]=f,a()}catch(f){p(f)}}else try{let c=k.create("",r,o);o.refs[r.name]=Bt(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(r){throw r}};var A=class extends H{constructor(t,e,s,r,a){super(t,s,a);this.componentConfig=t;this.container=s;this.IframeElement=r;i(this,"cleanupInspect");i(this,"setHeightBasedOnDocumentElement",()=>{let t=this.send(new b(()=>window.document.documentElement.scrollHeight,e=>{this.IframeElement.style.height="".concat(e.content,"px"),t()}))});i(this,"observeSizeBasedOnDocumentElement",()=>{let t=this.send(new b(({send:e})=>{let{height:s,width:r}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();e({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:r}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px")}))});i(this,"setSizeBasedOnDocumentElement",()=>{let t=this.send(new b(()=>{let{height:e,width:s}=document.documentElement.getBoundingClientRect();return{height:e,width:s}},e=>{this.IframeElement.style.width="".concat(e.content.width,"px"),this.IframeElement.style.height="".concat(e.content.height,"px"),t()}))});i(this,"setHeightBasedOnScrollHeight",()=>{let t=this.send(new b(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},e=>{this.IframeElement.style.height=e.content,t()}))});i(this,"send",t=>{var r,a;let e=h({},t);if(e.messageType===l.ExecuteComponentMethod)return this[e.method](),()=>{};e.direction=x.down;let s=super.send(e);return(a=(r=this.IframeElement)==null?void 0:r.contentWindow)==null||a.postMessage(e,"*"),s});i(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});e.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Me(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(t){return t.messageType===l.In.MutationObserverMessage||t.messageType===l.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(t)}};var B=class{constructor(){i(this,"appendChild",(n,t,e)=>{var s;if(e!=null&&e.relative){if(e.relative.direction==="before")return n.insertBefore(t,e.relative.child);if(e.relative.direction==="after"){let r=(s=e.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(t,r||null)}}else return n.appendChild(t)})}};var Lt=(o,n,t)=>{let e=new URL(o);return e.searchParams.append(n,t),e.toString()},Ie=class extends B{constructor(){super(...arguments);i(this,"type",F.IframeLoader);i(this,"load",async(t,e,s,r)=>{let a,p=e.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 d=T(),c="myop-comp-".concat(d);a=document.createElement("iframe"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(a.style.visibility="hidden"),a=this.appendChild(s,a,r);let u=e.loader.url;r!=null&&r._hasParent&&(u=Lt(u,"_myop-comp",d));let m="";r!=null&&r.elementAttributes&&(m=Object.entries(r==null?void 0:r.elementAttributes).map(([f,g])=>g===""||g===null||g===void 0?f:"".concat(f,'="').concat(String(g),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(c,'"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(p.autoHeight||!p.height?"":p.height,"; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(r!=null&&r.hidden?"0":"1",";\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",';\n "\n src="').concat(u,'"\n ').concat(m,"\n ></iframe>"),a=s.querySelector("#".concat(c))}return new A(t,e,s,a,r)})}};var U=class extends H{constructor(t,e,s,r,a){super(t,s,a);this.container=s;this.customElement=r;i(this,"cleanupInspect",()=>{});i(this,"send",t=>{let e=h({},t),s=super.send(e),r=new CustomEvent(de.webcomponent_message_key,{detail:e});try{this.customElement.dispatchEvent(r)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});i(this,"dispose",()=>{var t;super.dispose(),(t=this.customElement.parentNode)==null||t.removeChild(this.customElement)});this.element=r}inspect(){return this.cleanupInspect=Me(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 Xe={},Ce=class extends B{constructor(){super(...arguments);i(this,"type",F.WebComponentLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader;Xe[a.url]?console.log("Module alreday loaded or in loading process"):Xe[a.url]=new Promise((c,u)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{c()},f.onerror=()=>{u()},document.head.appendChild(f)}),await Xe[a.url],await tt(1);let p="myop-comp-".concat(T()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),r!=null&&r._environment&&(d._myopEnvironment=r==null?void 0:r._environment),this.appendChild(s,d,r),new U(t,e,s,d,r)})}};var gt="0.1.40";var ut=[],xe,yt=async()=>(xe||(xe=new te,xe.init()),xe);function _t(o,n){return class extends HTMLElement{connectedCallback(){let t=n===ae.open?"open":"closed",e=this.attachShadow({mode:t});yt().then(s=>{s.connectedCallback(this,e),e.innerHTML=o})}}}var Pt=(o,n,t)=>{customElements.define(o,_t(n,t)),console.log("define('".concat(o,"') was called, web component ready to use"))},Ot=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),Kt=o=>(o=Ot(o),o.replace(/_/g,"-"));var be=class extends B{constructor(){super(...arguments);i(this,"type",F.HTMLLoader);i(this,"load",async(t,e,s,r)=>{let a=e.loader,p="myop-comp-".concat(T()),d;if(a.shadowRootMode===ae.localFrame){let c=T(),u="myop-comp-".concat(c),m=document.createElement("iframe");s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),r!=null&&r.hidden&&(m.style.visibility="hidden"),m=this.appendChild(s,m,r),m.id=u,m.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(r!=null&&r.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(r!=null&&r.hidden?"absolute":"static",";\n pointer-events: ").concat(r!=null&&r.hidden?"none":"all",";\n ")),s.appendChild(m);let f=m.contentDocument||m.contentWindow.document;f.open(),f.writeln(a.HTML),f.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,"\"><\/script>\n <script>\n window.__federation__ = \n { ...window.__federation__,\n //TODO : get from ENV at build time, \n // inject value to module at build time \n // today we doing so just for the CJS version \n __public_path__ :'https://cdn.myop.dev/sdk/next',\n ...").concat(JSON.stringify(window.__federation__),"};\n const init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n init().then();\n <\/script>")),f.close();let g=new A(t,e,s,m,r);return m.onload=()=>{g.observeSizeBasedOnDocumentElement()},g}if(a.shadowRootMode===ae.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,yt().then(u=>{u.connectedCallback(d,d)})}else{let c=Kt(t.name+e.id);ut.includes(c)||(Pt(c,a.HTML,a.shadowRootMode),ut.push(c)),d=document.createElement(c)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,r!=null&&r.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,r),new U(t,e,s,d,r)})}};var we=class we{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;i(this,"userFlows",{})}async fetchComponent(n,t){return t?(await this.fetchFlow(t)).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(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(t,e)=>{try{let r=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();t(r.item)}catch(s){e(s)}})),await this.userFlows[n]}};i(we,"Main",new we);var Te=we;var ht=async o=>{let n=new URL(window.location.href),e=new URLSearchParams(n.search).get("myopOverride");if(e){let[s,r]=et(e),p=(await Te.Main.fetchFlow(s)).components.find(d=>d.type.id===o.type.id);if(p&&p.instance.skinSelector.type===$.Segmented&&p.instance.resolvedExperiences){let d=p.instance.resolvedExperiences.find(c=>c.id===r);if((d==null?void 0:d.type)===pe.Segment){let c=d,m=p.instance.skinSelector.segments.find(f=>f.segmentId===c.segment.id);if(m)return p.instance.skinSelector=m==null?void 0:m.skinSelector,p}}}return null};var Mt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",D=class{constructor(){i(this,"components2init",[]);i(this,"components",[]);i(this,"componentsLoaders",[]);i(this,"initiated",!1);i(this,"version",gt);i(this,"type2InstanceCount",{});i(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));i(this,"inspected",!1);i(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});i(this,"incomingMessageHandler",n=>{if(n.origin,document.location.origin,n.data.myop){if(n.data.direction!==x.up&&n.data.messageType!==l.EnvelopedMessage)return;let t=n.data;if(t.messageType===l.InitRequest){this.components2init.forEach(s=>{s.send(new P(s.id))});return}if(t.messageType===l.InitResponse){this.components2init=this.components2init.filter(r=>r.id!==t.content.id);let s=this.components.find(r=>{var a;return r.id===((a=t.content)==null?void 0:a.id)});s==null||s.setInitiated();return}if(t.messageType===l.EnvelopedMessage){let s=t,r=this.components.find(a=>a.id===s.destination);if(r){if(s.direction===x.down){s.message.messageType===w.name?r.onMessageReceived(s.message):(s.message.route=s.route,r.send(s.message));return}}else{let a=this.components.find(p=>p.id===s.message.destination);a&&a.send(s.message)}return}let e=this.components.find(s=>s.id===t.destination);if(!e){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(e){if(e.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});i(this,"send",n=>{let t=new MessageEvent("",{data:n});this.incomingMessageHandler(t)});i(this,"init",n=>{if(this.initiated)throw new Error("hostSDK already initiated");let t=[new Ie,new Ce,new be];if(this.componentsLoaders=[...t],n){let e={};n.forEach(s=>{let r=new s(this.componentsLoaders);e[r.type]=r}),this.componentsLoaders.forEach(s=>{e[s.type]||(e[s.type]=s)}),this.componentsLoaders=Object.values(e)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});i(this,"_getSkinIdBySkinSelector",async(n,t=[],e)=>{var r;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case $.Dedicated:return((r=n.skin)==null?void 0:r.id)||n.skins[0].id;case $.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=t.find(g=>g.type===pe.Segment?g.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let m=c.segment,f=(e||{})[m.function];return f?await f():(console.warn("segmentId:".concat(d.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,t);debugger}break;default:debugger}return""});i(this,"runSkinSelector",async(n,t)=>{let e=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,t);return n.type.skins.find(s=>s.id===e)});i(this,"loaderHooks");i(this,"loadComponent",async(n,t,e)=>{var c,u,m,f;if(!t){debugger;throw new Error("no container was found for this component")}let s=await ht(n);s&&(n=s);let r=t;if(r.myop)if(r.component){n=h({},n),n.instance=h({},n.instance);let g=h(h({},(c=this.loaderHooks)!=null?c:{}),(u=e==null?void 0:e.hooks)!=null?u:{}),_=await this.runSkinSelector(n,g);if(!_)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(m=e==null?void 0:e.hooks)!=null&&m.afterSkinSelected&&(_=await e.hooks.afterSkinSelected(h({},_))),n.instance.skinSelector={type:$.Dedicated,skin:_},e&&(e=h({},e),delete e.hooks),await Ge(r,n,this.components,e)}else throw new Error("load component got a detached ref.");t=t;let a=await this.runSkinSelector(n,e==null?void 0:e.hooks);if(!a)throw new Error("runSkinSelector failed to choose skin, check the provided config");(f=e==null?void 0:e.hooks)!=null&&f.afterSkinSelected&&(a=await e.hooks.afterSkinSelected(h({},a)));let p=this.componentsLoaders.find(g=>g.type===a.loader.type);if(!p){debugger;throw new Error('no loader "'.concat(a.loader.type,'" was found for component'))}let d=await p.load(n.type,a,t,e);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(g=>g!==d),this.components2init=this.components2init.filter(g=>g!==d),!0)),this.components.push(d),e!=null&&e.connectProps&&(d=ft(d,n.type.props));try{await Je(d,n,this.components)}catch(g){throw g}return e!=null&&e.skipInit||await d.initiated(),d});i(this,"navigate",async(n,t,e)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(e!=null&&e.staged){let s=await this.loadComponent(t,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},e));return e.init&&await e.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(t,n.container,h({relative:{direction:"before",child:s}},e))}})}};i(D,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Mt});if(!window.myop.hostSDK){let o=new D;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Mt}),window.myop.hostSDK=o}var Ft=window.myop.hostSDK;ue("hostSDK",Ft);var Se=class extends M{constructor(){super(...arguments);i(this,"messageType",l.CreateRefComponentMessage);i(this,"innerExecutor",(t,e,s)=>{(async()=>{let a=e.shadowRoot.querySelectorAll("[".concat(E.id,"='").concat(t.refConfig.selector,"']"));if(a.length===1){let p=D.Instance(),d=p.components.find(f=>f.id===t.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let u=await p.loadComponent(t.nestedComponentConfig,a.item(0),t.options),m=[];Object.keys(u.refs).forEach(f=>{let g=u.refs[f];g=g.__nonProxied||g,g.componentDefinition&&m.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new O(t.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new O(t.handlerUniqueId,[],!0));debugger}})().then()})}};var It=(o,n,t)=>{let e=o.scriptInputs?o.scriptInputs:{};e.makeSerializable=v,e.send=n,e.rootRef=t,e.__scriptInputs=e;let r=new Function("return (".concat(o.script,")(...arguments)"))(e);n(r)};var Re=class extends M{constructor(){super(...arguments);i(this,"messageType",l.ExecuteScriptMessage);i(this,"innerExecutor",(t,e,s)=>{It(t,a=>{s(new N(t.handlerUniqueId,a))},e)})}};var Ct=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),t={formData:{},unmappedData:[]},e=o.querySelectorAll("input, select, textarea"),s=-1;return e.forEach(r=>{if(typeof r.value=="string"){let a=r.getAttribute(E.id),p=r.getAttribute("name"),d={id:r.id,name:p,value:Ct(r),required:r.required,validity:v(r.validity,!0),myopId:a};p?t.formData[p]?t.formData[p].value?t.unmappedData.push(d):(t.unmappedData.push(t.formData[p]),t.formData[p]=d):t.formData[p]=d:t.unmappedData.push(d)}}),t}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},Ee=class extends M{constructor(){super(...arguments);i(this,"messageType",l.GetElementValueMessage);i(this,"innerExecutor",(t,e,s)=>{S(t.ref,e.shadowRoot).forEach(a=>{s(new q(Ct(a)),t)})})}};var ve=class extends M{constructor(){super(...arguments);i(this,"messageType",l.SetInnerHtml);i(this,"innerExecutor",(t,e)=>{S(t.ref,e.shadowRoot).forEach(r=>{r.innerHTML=t.content})})}};var te=class extends re{constructor(){super(...arguments);i(this,"alwaysPassEnvelopesToHost",!0);i(this,"connectedCallback",(t,e)=>{t.addEventListener(de.webcomponent_message_key,s=>{let r=s.data?s.data:s.detail;if(!r||!r.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=r;if(this.handleIncomeMessages(s),a.messageType===l.InitMessage){let p=a.content.id;this.components[p].context=new le(t,e)}}}),setTimeout(()=>{this.messageToHost(new j)},1)});i(this,"messageToHost",(t,e)=>{t.direction=x.up,!t.replayToHandler&&(e!=null&&e.handlerUniqueId)&&(t.replayToHandler=e.handlerUniqueId),window.myop.hostSDK.send(t)});i(this,"supportedHandlers",[new me(this.messageToHost,this.components),new ve(this.messageToHost,this.components),new ce(this.messageToHost,this.components),new fe(this.messageToHost,this.components),new ye(this.messageToHost,this.components),new he(this.messageToHost,this.components),new Re(this.messageToHost,this.components),new Ee(this.messageToHost,this.components),new Se(this.messageToHost,this.components)]);i(this,"init",()=>{})}};ue("WebComponentSDK",te);export{te as WebComponentSDK};