@myop/sdk 0.2.6 → 0.2.7

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 (43) hide show
  1. package/README.md +3 -3
  2. package/dist/bundled-declarations.d.ts +67 -7
  3. package/dist/cjs/_IframeSDK.43696632.min.js +1 -0
  4. package/dist/cjs/{_IframeSDK.2793f0c2.js → _IframeSDK.65146759.js} +185 -33
  5. package/dist/cjs/_IframeSDK.65146759.js.map +7 -0
  6. package/dist/cjs/{_MyopHelpers.7baba8b8.js → _MyopHelpers.02c01d3a.js} +96 -11
  7. package/dist/cjs/{_MyopHelpers.7baba8b8.js.map → _MyopHelpers.02c01d3a.js.map} +3 -3
  8. package/dist/cjs/_MyopHelpers.abd584e8.min.js +1 -0
  9. package/dist/cjs/{_WebComponentSDK.ba6c3d1b.js → _WebComponentSDK.4a661403.js} +185 -33
  10. package/dist/cjs/_WebComponentSDK.4a661403.js.map +7 -0
  11. package/dist/cjs/_WebComponentSDK.5d90b79c.min.js +1 -0
  12. package/dist/cjs/{_hostSDK.71e17cf2.js → _hostSDK.933cfab5.js} +185 -33
  13. package/dist/cjs/_hostSDK.933cfab5.js.map +7 -0
  14. package/dist/cjs/_hostSDK.98520a3d.min.js +1 -0
  15. package/dist/cjs/myop_sdk.js +14 -14
  16. package/dist/cjs/myop_sdk.js.map +1 -1
  17. package/dist/cjs/myop_sdk.min.js +1 -1
  18. package/dist/cjs-bundled/myop_sdk.bundled.js +188 -35
  19. package/dist/cjs-bundled/myop_sdk.bundled.js.map +2 -2
  20. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  21. package/dist/module/Iframe/index.js +209 -60
  22. package/dist/module/Iframe/index.js.map +3 -3
  23. package/dist/module/SDK.js +211 -61
  24. package/dist/module/SDK.js.map +2 -2
  25. package/dist/module/helpers/CloudRepository.d.ts +15 -6
  26. package/dist/module/helpers/index.js +97 -12
  27. package/dist/module/helpers/index.js.map +3 -3
  28. package/dist/module/host/components/IMyopComponent.d.ts +43 -0
  29. package/dist/module/host/components/myopIframeComponent.d.ts +8 -1
  30. package/dist/module/host/components/myopRefComponent.d.ts +2 -2
  31. package/dist/module/host/index.d.ts +1 -0
  32. package/dist/module/host/index.js +209 -60
  33. package/dist/module/host/index.js.map +3 -3
  34. package/dist/module/webcomponent/index.js +209 -60
  35. package/dist/module/webcomponent/index.js.map +3 -3
  36. package/package.json +1 -1
  37. package/dist/cjs/_IframeSDK.2793f0c2.js.map +0 -7
  38. package/dist/cjs/_IframeSDK.fb84c8eb.min.js +0 -1
  39. package/dist/cjs/_MyopHelpers.3d50ac48.min.js +0 -1
  40. package/dist/cjs/_WebComponentSDK.0fee50b6.min.js +0 -1
  41. package/dist/cjs/_WebComponentSDK.ba6c3d1b.js.map +0 -7
  42. package/dist/cjs/_hostSDK.159c1adb.min.js +0 -1
  43. package/dist/cjs/_hostSDK.71e17cf2.js.map +0 -7
@@ -0,0 +1 @@
1
+ var gt=Object.defineProperty,$t=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ft=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Wt=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={}))Ut.call(n,e)&&Fe(o,e,n[e]);if(ft)for(var e of ft(n))Wt.call(n,e)&&Fe(o,e,n[e]);return o},H=(o,n)=>$t(o,zt(n));var Nt=(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 le=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()}},$e=class{constructor(n){this.messageToHost=n}},fe=class extends $e{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 ge={};Nt(ge,{AddEventListenerMessage:()=>Ve,BaseMyopMessage:()=>y,BindClickMessage:()=>We,ChangeTextMessage:()=>Ne,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>Q,CreateRefComponentMessage:()=>oe,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>Je,DetectedMyopRefsMessage:()=>re,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>ee,EnvelopedMessage:()=>se,EventListenerCallbackMessage:()=>Z,ExecuteComponentMethod:()=>R,ExecuteScriptMessage:()=>w,ExecuteScriptReplyMessage:()=>Y,GetAttributeMessage:()=>Xe,GetAttributeReplayMessage:()=>Qe,GetElementValueMessage:()=>je,InitMessage:()=>N,InitRequest:()=>ne,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>Ze,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>C,MyopElementMessage:()=>Ue,Ref:()=>P,RefComponentCreatedMessage:()=>V,ResizeObserverMessage:()=>tt,SetAttributeMessage:()=>qe,SetInnerHtml:()=>Ge,SetMutationObserverMessage:()=>Ye,SetResizeObserverMessage:()=>et,stripFunction:()=>It});var T=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Vt=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var qt=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var ze=o=>{let n=qt(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(Vt(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",T());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}},Ue=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",T())}},P=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",We=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",ht);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},Q=class extends C{constructor(){super(...arguments);r(this,"messageType",ht)}};var Ne=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*$/,Gt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,It=o=>{let n=o.match(jt);if(n)return n[1]||n[3];{let e=o.match(Gt);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 Y=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Mt)}};var $=class extends w{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=H(h({},t),{_script:e.toString()})}};var Ct="EventListenerCallbackMessage",Ve=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}},Z=class extends C{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Ct);this.content={e:t}}};var qe=class extends y{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var xt="ElementValueReplayMessage",je=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",xt);r(this,"messageType","GetElementValueMessage")}},ee=class extends C{constructor(e){super();this.content=e;r(this,"messageType",xt)}};var Ge=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}},te=class extends N{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},ne=class extends y{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var bt="RefComponentCreatedMessage",oe=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 se=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",Je=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",St)}},re=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",Xe=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",wt);r(this,"messageType","GetAttributeMessage")}},Qe=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 Ye=class extends y{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},Ze=class extends y{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var Tt="CleanupReplayMessage",ie=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",Tt);r(this,"messageType","CleanupMessage")}},ae=class extends C{constructor(e){super();this.customCleanup=e;r(this,"messageType",Tt)}};var pe=class extends y{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var et=class extends y{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},tt=class extends y{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var nt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},ue=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 nt(s),this.messageToHost(new te(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(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.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 ae(!!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 B={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var z={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 U={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},he={Segment:"Segment",Promo:"Promo",AB:"AB"},ye=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 Me={webcomponent_message_key:"myop_webcomponent_message"};var I=class extends fe{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 D={id:"myop-id"};var E=(o,n)=>n.querySelectorAll("[".concat(D.id,"='").concat(o.refConfig.selector,"']"));var Ie=class extends I{constructor(){super(...arguments);r(this,"messageType",g.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=E(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new Q(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Ce=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{E(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var xe=class extends ye{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var be=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(D.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(D.id);p&&i.push(new le(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new re(e.handlerUniqueId,i))});r(this,"messageType",g.DetectMyopRefsMessage)}};var Se="__federation__",Rt="onLoad";var we=(o,n)=>{window[Se]&&window[Se][o]&&window[Se][o][Rt]&&window[Se][o][Rt]({[o]:n})};var Te=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{E(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var ot=o=>o!==Object(o),Jt=o=>typeof o=="function",st=o=>{if(ot(o))return!0;if(Jt(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!st(e))return!1}else{if(ot(e))continue;return!1}}return!0},L=(o,n={},e=!0,t=new WeakMap)=>{if(ot(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]=L(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]=L(o[i],!0,e,t)):typeof a=="object"&&(s[i]=L(o[i],a,e,t)))}return s}return{}};var Re=class extends I{constructor(){super(...arguments);r(this,"messageType",g.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=E(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{s(new Z(e.handlerUniqueId,L(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var O=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)||K.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 ie(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Et={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 O{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 se(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 Xt=(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},Ee=(o,n,e,t,s,i)=>{let a=Xt("".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===B.HTMLLoader&&e.loader.shadowRootMode===z.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return kt(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(P.create(p.behavior.ref)),c.push(m=>{d(m)}),p.behavior.params&&c.push(...p.behavior.params);let l=ge[p.behavior.message];o.send(new l(...c))}):null},set:(i,a,p)=>{let d=t[a];if(vt(d,a,o))return!1;if(d.behavior.type===j.code){if(e.loader.type===B.HTMLLoader&&e.loader.shadowRootMode===z.localFrame){let l=d.behavior;return o.element.contentWindow[l.remap||a]=p,!0}return kt(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(P.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let l=ge[d.behavior.message];return o.send(new l(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},Qt=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{st(p)||Et.notSerializableRefCall(t,p)}),n.send(new $(({ref:p,propName:d,functionArgs:c,makeSerializable:l})=>{if(p){let m=p[d];return l(typeof m=="function"?p[d](...c):m,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),rt=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 d=setTimeout(()=>{a("timeout")},5e3);s.send(new oe(o.refConfig,n,H(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.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;c.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 it(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(m){a(m)}}))})},it=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 d;if(i.behavior.type==q.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let l=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=P.create("",i,o);try{let f=await rt(m,l,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let c=P.create("",i,o);o.refs[i.name]=Qt(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(i){throw i}};var G=class extends O{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:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});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 pt;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),d=a(e==null?void 0:e.maxWidth),c=a(e==null?void 0:e.minHeight),l=a(e==null?void 0:e.maxHeight),m=(pt=e==null?void 0:e.loaderMinHeight)!=null?pt:50,f=(e==null?void 0:e.explicitWidth)!==void 0,u=(e==null?void 0:e.explicitHeight)!==void 0,M=this.container.getBoundingClientRect(),Ke=M.width===0,v=M.height===0||M.height===m,_=(e!=null&&e.forceAutoSize||Ke)&&!f,F=(e!=null&&e.forceAutoSize||v)&&!u;if(!_&&!F)return()=>{};let X=()=>{var k;let S=t.contentDocument;if(S){let W=S.documentElement.getBoundingClientRect(),dt=Math.ceil(W.width),ct=Math.ceil(W.height),mt=i(dt,p,d),lt=i(ct,c,l);_&&(t.style.width="".concat(mt,"px")),F&&(t.style.height="".concat(lt,"px"));let At=_&&d!==void 0&&dt>d,Ft=F&&l!==void 0&&ct>l;S.documentElement.style.overflowX=At?"auto":"hidden",S.documentElement.style.overflowY=Ft?"auto":"hidden",(k=e==null?void 0:e.onSizeChange)==null||k.call(e,{width:mt,height:lt,autoSizingWidth:_,autoSizingHeight:F})}};X();let Ae=new ResizeObserver(X);return Ae.observe(s.body),Ae.observe(s.documentElement),()=>{Ae.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=Ee(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 A=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 Yt=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},ve=class extends A{constructor(){super(...arguments);r(this,"type",B.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 d=T(),c="myop-comp-".concat(d);a=document.createElement("iframe"),a.id=c;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=Yt(m,"_myop-comp",d)),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 O{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(Me.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=Ee(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 at={},ke=class extends A{constructor(){super(...arguments);r(this,"type",B.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;at[a.url]?console.log("Module alreday loaded or in loading process"):at[a.url]=new Promise((c,l)=>{let m=a.url,f=document.createElement("script");f.type="module",f.src=m,f.onload=()=>{c()},f.onerror=()=>{l()},document.head.appendChild(f)}),await at[a.url],await yt(1);let p="myop-comp-".concat(T()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new J(e,t,s,d,i)})}};var Bt="0.2.7";var Dt=[],He,Lt=async()=>(He||(He=new ce,He.init()),He);function Zt(o,n){return class extends HTMLElement{connectedCallback(){let e=n===z.open?"open":"closed",t=this.attachShadow({mode:e});Lt().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var en=(o,n,e)=>{customElements.define(o,Zt(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},tn=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),nn=o=>(o=tn(o),o.replace(/_/g,"-"));var Be=class extends A{constructor(){super(...arguments);r(this,"type",B.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p="myop-comp-".concat(T()),d;if(a.shadowRootMode===z.localFrame){let c=T(),l="myop-comp-".concat(c),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 v=new DOMParser().parseFromString(a.HTML,"text/html"),_=v.getElementById("myop_preview");_==null||_.removeAttribute("type");let F=v.implementation.createHTMLDocument();F.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let X=F.body.firstChild;X&&v.head&&v.head.insertBefore(v.importNode(X,!0),v.head.firstChild),u=v.documentElement.outerHTML}f.writeln(u),f.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>\n <script>\n \n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n \n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK()\n sdk.init();\n }\n \n __myop_init().then();\n \n <\/script>')),f.close();let M=new G(e,t,s,m,i);return a.autoHeight&&(m.onload=()=>{M.observeSizeBasedOnDocumentElement()}),M}if(a.shadowRootMode===z.none){let c=document.createElement("template");c.innerHTML=a.HTML,d=c.content.firstElementChild,Lt().then(l=>{l.connectedCallback(d,d)})}else{let c=nn(e.name+t.id);Dt.includes(c)||(en(c,a.HTML,a.shadowRootMode),Dt.push(c)),d=document.createElement(c)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),this.appendChild(s,d,i),new J(e,t,s,d,i)})}};var on=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}),De=class De{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 d="".concat(this._baseUrl,"/consume?id=").concat(n,"&env=").concat(s);t&&(d+="&preview=true");let m=(await(await fetch(d)).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=on(m);a(f)}catch(d){p(d)}})),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(De,"Main",new De);var me=De;var _t=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=ze(t);switch(s){case"component":{let[a,p]=i,d=await me.Main.fetchComponent(a);if(d&&d.type.skins.find(l=>l.id===p))return d.instance.skinSelector={type:U.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=ze(t),c=(await me.Main.fetchFlow(a)).components.find(l=>l.type.id===o.type.id);if(c&&c.instance.skinSelector.type===U.Segmented&&c.instance.resolvedExperiences){let l=c.instance.resolvedExperiences.find(m=>m.id===p);if((l==null?void 0:l.type)===he.Segment){let m=l,u=c.instance.skinSelector.segments.find(M=>M.segmentId===m.segment.id);if(u)return c.instance.skinSelector=u==null?void 0:u.skinSelector,c}}}break}}}finally{return null}};var Pt="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",K=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"initiated",!1);r(this,"version",Bt);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 ve,new ke,new Be];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 d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case U.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case U.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(u=>u.type===he.Segment?u.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let m=c.segment,f=(t||{})[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,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 _t(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:U.Dedicated,skin:M},t&&(t=h({},t),delete t.hooks),await rt(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(M=>M.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(M=>M!==c),this.components2init=this.components2init.filter(M=>M!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=Ht(c,n.type.props,p));try{await it(c,n,this.components)}catch(M){throw M}return t!=null&&t.skipInit||await c.initiated(),c});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(K,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Pt});if(!window.myop.hostSDK){let o=new K;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Pt}),window.myop.hostSDK=o}var sn=window.myop.hostSDK;we("hostSDK",sn);var Le=class extends I{constructor(){super(...arguments);r(this,"messageType",g.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(D.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=K.Instance(),d=p.components.find(f=>f.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,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 Ot=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=L,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var _e=class extends I{constructor(){super(...arguments);r(this,"messageType",g.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{Ot(e,a=>{s(new Y(e.handlerUniqueId,a))},t)})}};var Kt=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(D.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Kt(i),required:i.required,validity:L(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Pe=class extends I{constructor(){super(...arguments);r(this,"messageType",g.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{E(e.ref,t.shadowRoot).forEach(a=>{s(new ee(Kt(a)),e)})})}};var Oe=class extends I{constructor(){super(...arguments);r(this,"messageType",g.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{E(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends ue{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Me.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 xe(e,t)}}}),setTimeout(()=>{this.messageToHost(new ne)},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 Ce(this.messageToHost,this.components),new Oe(this.messageToHost,this.components),new Ie(this.messageToHost,this.components),new be(this.messageToHost,this.components),new Te(this.messageToHost,this.components),new Re(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Pe(this.messageToHost,this.components),new Le(this.messageToHost,this.components)]);r(this,"init",()=>{})}};we("WebComponentSDK",ce);export{ce as WebComponentSDK};
@@ -1324,6 +1324,83 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1324
1324
  }));
1325
1325
  return cleanupHandler;
1326
1326
  });
1327
+ /**
1328
+ * Observes the iframe content size and automatically syncs it to the iframe element.
1329
+ * Uses direct contentDocument access (same-origin only) for accurate measurements.
1330
+ * @param options - Configuration options including size change callback and min/max constraints
1331
+ * @returns Cleanup function to stop observing
1332
+ */
1333
+ __publicField(this, "observeAutoSize", (options) => {
1334
+ var _a;
1335
+ const iframe = this.IframeElement;
1336
+ const doc = iframe.contentDocument;
1337
+ if (!doc) {
1338
+ console.warn("[MyopIframeComponent] Cannot observe auto size: contentDocument not accessible");
1339
+ return () => {
1340
+ };
1341
+ }
1342
+ const clamp = (value, min, max) => {
1343
+ if (min !== void 0 && value < min) return min;
1344
+ if (max !== void 0 && value > max) return max;
1345
+ return value;
1346
+ };
1347
+ const parseSize = (value) => {
1348
+ if (value === void 0) return void 0;
1349
+ if (typeof value === "number") return value;
1350
+ const parsed = parseFloat(value);
1351
+ return isNaN(parsed) ? void 0 : parsed;
1352
+ };
1353
+ const minWidth = parseSize(options == null ? void 0 : options.minWidth);
1354
+ const maxWidth = parseSize(options == null ? void 0 : options.maxWidth);
1355
+ const minHeight = parseSize(options == null ? void 0 : options.minHeight);
1356
+ const maxHeight = parseSize(options == null ? void 0 : options.maxHeight);
1357
+ const loaderMinHeight = (_a = options == null ? void 0 : options.loaderMinHeight) != null ? _a : 50;
1358
+ const hasExplicitWidth = (options == null ? void 0 : options.explicitWidth) !== void 0;
1359
+ const hasExplicitHeight = (options == null ? void 0 : options.explicitHeight) !== void 0;
1360
+ const containerRect = this.container.getBoundingClientRect();
1361
+ const collapsedWidth = containerRect.width === 0;
1362
+ const collapsedHeight = containerRect.height === 0 || containerRect.height === loaderMinHeight;
1363
+ const shouldAutoWidth = (options == null ? void 0 : options.forceAutoSize) ? !hasExplicitWidth : collapsedWidth && !hasExplicitWidth;
1364
+ const shouldAutoHeight = (options == null ? void 0 : options.forceAutoSize) ? !hasExplicitHeight : collapsedHeight && !hasExplicitHeight;
1365
+ if (!shouldAutoWidth && !shouldAutoHeight) {
1366
+ return () => {
1367
+ };
1368
+ }
1369
+ const updateSize = () => {
1370
+ var _a2;
1371
+ const contentDoc = iframe.contentDocument;
1372
+ if (contentDoc) {
1373
+ const rect = contentDoc.documentElement.getBoundingClientRect();
1374
+ const contentWidth = Math.ceil(rect.width);
1375
+ const contentHeight = Math.ceil(rect.height);
1376
+ const width = clamp(contentWidth, minWidth, maxWidth);
1377
+ const height = clamp(contentHeight, minHeight, maxHeight);
1378
+ if (shouldAutoWidth) {
1379
+ iframe.style.width = "".concat(width, "px");
1380
+ }
1381
+ if (shouldAutoHeight) {
1382
+ iframe.style.height = "".concat(height, "px");
1383
+ }
1384
+ const isWidthConstrained = shouldAutoWidth && maxWidth !== void 0 && contentWidth > maxWidth;
1385
+ const isHeightConstrained = shouldAutoHeight && maxHeight !== void 0 && contentHeight > maxHeight;
1386
+ contentDoc.documentElement.style.overflowX = isWidthConstrained ? "auto" : "hidden";
1387
+ contentDoc.documentElement.style.overflowY = isHeightConstrained ? "auto" : "hidden";
1388
+ (_a2 = options == null ? void 0 : options.onSizeChange) == null ? void 0 : _a2.call(options, {
1389
+ width,
1390
+ height,
1391
+ autoSizingWidth: shouldAutoWidth,
1392
+ autoSizingHeight: shouldAutoHeight
1393
+ });
1394
+ }
1395
+ };
1396
+ updateSize();
1397
+ const resizeObserver = new ResizeObserver(updateSize);
1398
+ resizeObserver.observe(doc.body);
1399
+ resizeObserver.observe(doc.documentElement);
1400
+ return () => {
1401
+ resizeObserver.disconnect();
1402
+ };
1403
+ });
1327
1404
  __publicField(this, "setSizeBasedOnDocumentElement", () => {
1328
1405
  const cleanupHandler = this.send(new ExecuteScriptMessage(() => {
1329
1406
  const { height, width } = document.documentElement.getBoundingClientRect();
@@ -1454,25 +1531,25 @@ var MyopIframeLoader = class extends BaseMyopLoader {
1454
1531
  const uniqId = uuidv4();
1455
1532
  const domId = "myop-comp-".concat(uniqId);
1456
1533
  IframeElement = document.createElement("iframe");
1457
- if (!container.querySelector('[id^="myop-comp-"]'))
1458
- container.innerHTML = "";
1459
- if (options == null ? void 0 : options.hidden) {
1460
- IframeElement.style.visibility = "hidden";
1534
+ IframeElement.id = domId;
1535
+ const iframeStyles = "\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(typedLoaderConfig.autoHeight || !typedLoaderConfig.height ? "100%" : typedLoaderConfig.height, ";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat((options == null ? void 0 : options.hidden) ? "0" : "1", ";\n pointer-events: ").concat((options == null ? void 0 : options.hidden) ? "none" : "all", ";\n ");
1536
+ IframeElement.style.cssText = iframeStyles;
1537
+ if (options == null ? void 0 : options.elementAttributes) {
1538
+ Object.entries(options.elementAttributes).forEach(([key, value]) => {
1539
+ if (value === "" || value === null || value === void 0) {
1540
+ IframeElement.setAttribute(key, "");
1541
+ } else {
1542
+ IframeElement.setAttribute(key, String(value));
1543
+ }
1544
+ });
1461
1545
  }
1462
- IframeElement = this.appendChild(container, IframeElement, options);
1463
1546
  let url2load = skin.loader.url;
1464
1547
  if (options == null ? void 0 : options._hasParent)
1465
1548
  url2load = addQueryParam(url2load, "_myop-comp", uniqId);
1466
- let elementAttributesString = "";
1467
- if (options == null ? void 0 : options.elementAttributes)
1468
- elementAttributesString = Object.entries(options == null ? void 0 : options.elementAttributes).map(([key, value]) => {
1469
- if (value === "" || value === null || value === void 0) {
1470
- return key;
1471
- }
1472
- return "".concat(key, '="').concat(String(value), '"');
1473
- }).join(" ");
1474
- IframeElement.outerHTML = '<iframe \n id="'.concat(domId, '"\n style="\n padding: 0;\n margin: 0;\n height: ').concat(typedLoaderConfig.autoHeight || !typedLoaderConfig.height ? "" : typedLoaderConfig.height, "; \n width : 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat((options == null ? void 0 : options.hidden) ? "0" : "1", ";\n position: ").concat((options == null ? void 0 : options.hidden) ? "absolute" : "static", ";\n pointer-events: ").concat((options == null ? void 0 : options.hidden) ? "none" : "all", ';\n "\n src="').concat(url2load, '"\n ').concat(elementAttributesString, "\n ></iframe>");
1475
- IframeElement = container.querySelector("#".concat(domId));
1549
+ IframeElement.src = url2load;
1550
+ if (!container.querySelector('[id^="myop-comp-"]'))
1551
+ container.innerHTML = "";
1552
+ IframeElement = this.appendChild(container, IframeElement, options);
1476
1553
  }
1477
1554
  return new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
1478
1555
  });
@@ -1588,7 +1665,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1588
1665
  };
1589
1666
 
1590
1667
  // version:myop-sdk-version
1591
- var myop_sdk_version_default = "0.2.6";
1668
+ var myop_sdk_version_default = "0.2.7";
1592
1669
 
1593
1670
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
1594
1671
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
@@ -1980,15 +2057,11 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
1980
2057
  const uniqId = uuidv4();
1981
2058
  const domId2 = "myop-comp-".concat(uniqId);
1982
2059
  let IframeElement = document.createElement("iframe");
2060
+ IframeElement.id = domId2;
2061
+ IframeElement.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((options == null ? void 0 : options.hidden) ? "0" : "1", ";\n width: 100%;\n height: 100%;\n pointer-events: ").concat((options == null ? void 0 : options.hidden) ? "none" : "all", ";\n ");
1983
2062
  if (!container.querySelector('[id^="myop-comp-"]'))
1984
2063
  container.innerHTML = "";
1985
- if (options == null ? void 0 : options.hidden) {
1986
- IframeElement.style.visibility = "hidden";
1987
- }
1988
2064
  IframeElement = this.appendChild(container, IframeElement, options);
1989
- IframeElement.id = domId2;
1990
- IframeElement.setAttribute("style", "\n display: block;\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat((options == null ? void 0 : options.hidden) ? "0" : "1", ";\n width: 100%;\n height: 100%;\n position: ").concat((options == null ? void 0 : options.hidden) ? "absolute" : "static", ";\n pointer-events: ").concat((options == null ? void 0 : options.hidden) ? "none" : "all", ";\n "));
1991
- container.appendChild(IframeElement);
1992
2065
  const doc = IframeElement.contentDocument || IframeElement.contentWindow.document;
1993
2066
  doc.open();
1994
2067
  let HTML2Render = loaderConfig.HTML;
@@ -2049,6 +2122,57 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
2049
2122
  };
2050
2123
 
2051
2124
  // src/helpers/CloudRepository.ts
2125
+ var convertV2VariantToComponentConfig = (config) => {
2126
+ return {
2127
+ instance: {
2128
+ id: "auto",
2129
+ componentId: config.componentId,
2130
+ componentName: config.name,
2131
+ skinSelector: {
2132
+ type: "Dedicated",
2133
+ skin: {
2134
+ id: "skin_auto_v2_converted"
2135
+ }
2136
+ }
2137
+ },
2138
+ type: {
2139
+ id: config.id,
2140
+ name: config.name,
2141
+ description: config.description,
2142
+ props: [
2143
+ {
2144
+ id: "in_auto_v2_converted",
2145
+ name: "myop_init_interface",
2146
+ type: "any",
2147
+ behavior: {
2148
+ type: PropConfigBehaviorTypes.code
2149
+ }
2150
+ },
2151
+ {
2152
+ id: "out_auto_v2_converted",
2153
+ name: "myop_cta_handler",
2154
+ type: "any",
2155
+ behavior: {
2156
+ type: PropConfigBehaviorTypes.code
2157
+ }
2158
+ }
2159
+ ],
2160
+ refs: [],
2161
+ skins: [
2162
+ {
2163
+ id: "skin_auto_v2_converted",
2164
+ name: "auto_v2_converted",
2165
+ description: "",
2166
+ //TODO : handle empty :
2167
+ // @ts-ignore
2168
+ loader: config.consume_variant[0].loader
2169
+ }
2170
+ ],
2171
+ defaultSkin: 0
2172
+ },
2173
+ name: config.name
2174
+ };
2175
+ };
2052
2176
  var _CloudRepository = class _CloudRepository {
2053
2177
  constructor(_baseUrl = "https://cloud.myop.dev") {
2054
2178
  this._baseUrl = _baseUrl;
@@ -2056,34 +2180,62 @@ var _CloudRepository = class _CloudRepository {
2056
2180
  __publicField(this, "variants", {});
2057
2181
  // v1 cache
2058
2182
  __publicField(this, "userFlows", {});
2183
+ __publicField(this, "_defaultEnv", "production");
2184
+ }
2185
+ /**
2186
+ * Set the default environment for this CloudRepository instance
2187
+ */
2188
+ setEnvironment(env) {
2189
+ this._defaultEnv = env;
2190
+ }
2191
+ /**
2192
+ * Get the current default environment
2193
+ */
2194
+ getDefaultEnvironment() {
2195
+ return this._defaultEnv;
2059
2196
  }
2060
2197
  // ============ V2 Methods (Default) ============
2061
2198
  /**
2062
2199
  * Check if a component is already cached/preloaded (v2)
2063
2200
  */
2064
- isPreloaded(componentId) {
2065
- return componentId in this.variants;
2201
+ isPreloaded(componentId, env, preview) {
2202
+ const cacheKey = "".concat(componentId, ":").concat(env || this._defaultEnv, ":").concat(preview ? "preview" : "live");
2203
+ return cacheKey in this.variants;
2066
2204
  }
2067
2205
  /**
2068
- * Fetch a v2 component variant
2206
+ * Fetch a v2 component config
2069
2207
  */
2070
- async fetchComponentV2(componentId, environmentIdentifier) {
2071
- if (!this.variants[componentId]) {
2072
- this.variants[componentId] = new Promise(
2208
+ async fetchComponentV2(componentId, environmentIdentifier, preview) {
2209
+ const env = environmentIdentifier || this._defaultEnv;
2210
+ const cacheKey = "".concat(componentId, ":").concat(env, ":").concat(preview ? "preview" : "live");
2211
+ if (!this.variants[cacheKey]) {
2212
+ this.variants[cacheKey] = new Promise(
2073
2213
  async (resolve, reject) => {
2074
2214
  try {
2075
- const res = await fetch(
2076
- "".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(environmentIdentifier)
2077
- );
2215
+ let url = "".concat(this._baseUrl, "/consume?id=").concat(componentId, "&env=").concat(env);
2216
+ if (preview) {
2217
+ url += "&preview=true";
2218
+ }
2219
+ const res = await fetch(url);
2078
2220
  const json = await res.json();
2079
- resolve(json.item);
2221
+ const variant = json.item;
2222
+ if (!variant) {
2223
+ reject(new Error('Component "'.concat(componentId, '" not found')));
2224
+ return;
2225
+ }
2226
+ if (!variant.consume_variant || !variant.consume_variant.length) {
2227
+ reject(new Error('Component "'.concat(componentId, '" has no implementation for environment "').concat(env, '"')));
2228
+ return;
2229
+ }
2230
+ const componentConfig = convertV2VariantToComponentConfig(variant);
2231
+ resolve(componentConfig);
2080
2232
  } catch (e) {
2081
2233
  reject(e);
2082
2234
  }
2083
2235
  }
2084
2236
  );
2085
2237
  }
2086
- return await this.variants[componentId];
2238
+ return await this.variants[cacheKey];
2087
2239
  }
2088
2240
  // ============ V1 Methods (Legacy) ============
2089
2241
  /**