@myop/sdk 0.1.41 → 0.1.43

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.125baf65.min.js +1 -0
  3. package/dist/cjs/{_IframeSDK.56815070.js → _IframeSDK.d40f5d05.js} +20 -7
  4. package/dist/cjs/_IframeSDK.d40f5d05.js.map +7 -0
  5. package/dist/cjs/{_WebComponentSDK.285151df.js → _WebComponentSDK.82d073da.js} +20 -7
  6. package/dist/cjs/_WebComponentSDK.82d073da.js.map +7 -0
  7. package/dist/cjs/_WebComponentSDK.e5da466e.min.js +1 -0
  8. package/dist/cjs/_hostSDK.78b64302.min.js +1 -0
  9. package/dist/cjs/{_hostSDK.397d0006.js → _hostSDK.cc791efe.js} +20 -7
  10. package/dist/cjs/_hostSDK.cc791efe.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 +26 -8
  15. package/dist/module/Iframe/index.js.map +3 -3
  16. package/dist/module/SDK.js +26 -8
  17. package/dist/module/SDK.js.map +3 -3
  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 +26 -8
  23. package/dist/module/host/index.js.map +3 -3
  24. package/dist/module/webcomponent/index.js +26 -8
  25. package/dist/module/webcomponent/index.js.map +3 -3
  26. package/package.json +1 -1
  27. package/dist/cjs/_IframeSDK.09ec9f1b.min.js +0 -1
  28. package/dist/cjs/_IframeSDK.56815070.js.map +0 -7
  29. package/dist/cjs/_WebComponentSDK.285151df.js.map +0 -7
  30. package/dist/cjs/_WebComponentSDK.c0cd7c5f.min.js +0 -1
  31. package/dist/cjs/_hostSDK.0bd6ebc8.min.js +0 -1
  32. package/dist/cjs/_hostSDK.397d0006.js.map +0 -7
@@ -212,23 +212,37 @@ declare module "@myop/sdk/common" {
212
212
  type: PropType;
213
213
  messageType: MyopMessageKey;
214
214
  }
215
- type IPropConfigMode = 'input' | 'output';
216
- type IPropConfigBehaviorType = 'message';
215
+ export const PropMessageModes: {
216
+ readonly input: "input";
217
+ readonly output: "output";
218
+ };
219
+ export const PropConfigBehaviorTypes: {
220
+ readonly message: "message";
221
+ readonly code: "code";
222
+ };
217
223
  export interface IPropMessageBehaviorParam {
218
224
  value: string;
219
225
  }
226
+ export interface IPropBehavior {
227
+ type: keyof typeof PropConfigBehaviorTypes;
228
+ }
229
+ export interface IPropCodeBehavior extends IPropBehavior {
230
+ type: "code";
231
+ remap?: string;
232
+ }
233
+ export interface IPropMessageBehavior extends IPropBehavior {
234
+ type: "message";
235
+ message: MyopMessageKey;
236
+ ref: string;
237
+ params: IPropMessageBehaviorParam[];
238
+ mode: keyof typeof PropMessageModes;
239
+ }
220
240
  export interface IPropConfig {
221
241
  id: string;
222
242
  name: string;
223
243
  description: string;
224
244
  type: PropType;
225
- mode: IPropConfigMode;
226
- behavior: {
227
- type: IPropConfigBehaviorType;
228
- message: MyopMessageKey;
229
- ref: string;
230
- params: IPropMessageBehaviorParam[];
231
- };
245
+ behavior: IPropBehavior;
232
246
  }
233
247
  export class RefBehaviorType {
234
248
  static code: "code";
@@ -1598,6 +1612,7 @@ declare module "@myop/sdk/host/hostSDK" {
1598
1612
  elementAttributes?: ElementAttributes;
1599
1613
  _environment?: IEnvironment;
1600
1614
  _hasParent?: boolean;
1615
+ _inspection?: boolean;
1601
1616
  }
1602
1617
  export const hostSDK: HostSDK;
1603
1618
  global {
@@ -0,0 +1 @@
1
+ var ht=Object.defineProperty,Ut=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var yt=Object.getOwnPropertySymbols;var Nt=Object.prototype.hasOwnProperty,qt=Object.prototype.propertyIsEnumerable;var Qe=(o,s,e)=>s in o?ht(o,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[s]=e,u=(o,s)=>{for(var e in s||(s={}))Nt.call(s,e)&&Qe(o,e,s[e]);if(yt)for(var e of yt(s))qt.call(s,e)&&Qe(o,e,s[e]);return o},D=(o,s)=>Ut(o,zt(s));var Wt=(o,s)=>{for(var e in s)ht(o,e,{get:s[e],enumerable:!0})};var n=(o,s,e)=>Qe(o,typeof s!="symbol"?s+"":s,e);var W=class{constructor(s,e,t,r,i){this.myopId=s;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;n(this,"type","MyopElementRef")}};var Mt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let s=await o;typeof s=="function"&&s()}},y=class{constructor(s){this.messageToHost=s}},le=class extends y{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var d={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var fe={};Wt(fe,{AddEventListenerMessage:()=>tt,BaseMyopMessage:()=>h,BindClickMessage:()=>Ye,ChangeTextMessage:()=>et,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>A,CreateRefComponentMessage:()=>se,CustomRefMessage:()=>$,DetectMyopRefsMessage:()=>rt,DetectedMyopRefsMessage:()=>q,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>z,EnvelopedMessage:()=>oe,EventListenerCallbackMessage:()=>U,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>F,GetAttributeMessage:()=>it,GetAttributeReplayMessage:()=>ne,GetElementValueMessage:()=>ot,InitMessage:()=>V,InitRequest:()=>N,InitResponse:()=>te,MessageDirection:()=>C,MutationObserverMessage:()=>re,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>b,MyopElementMessage:()=>Ze,Ref:()=>L,RefComponentCreatedMessage:()=>B,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>st,SetInnerHtml:()=>nt,SetMutationObserverMessage:()=>at,SetResizeObserverMessage:()=>pt,stripFunction:()=>wt});var v=()=>"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 s=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[s.slice(0,8),s.slice(8,12),s.slice(12,16),s.slice(16,20),s.slice(20)].join("-")};var Gt=o=>{let s=o.replace(/-/g,"+").replace(/_/g,"/");for(;s.length%4;)s+="=";let e=atob(s);return Uint8Array.from(e,t=>t.charCodeAt(0))};var It=o=>{let s=Gt(o);if(s.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<s.length;t+=16)e.push(Vt(s.slice(t,t+16)));return e};var xt=o=>new Promise(s=>setTimeout(s,o));var C=class{};n(C,"down","down"),n(C,"up","up");var h=class{constructor(){n(this,"id",v());n(this,"myop",!0);n(this,"content");n(this,"source");n(this,"destination");n(this,"route");n(this,"ref");n(this,"direction");n(this,"cleanable",!1)}static create(...s){return new this(...s)}isTypeof(s){return s.messageType===this.messageType}},Ze=class extends h{constructor(e){super();this.ref=e}},b=class extends h{constructor(e){super();this.replayToHandler=e}},w=class extends h{constructor(e){super();this.handler=e;n(this,"handlerUniqueId",v())}},L=class o{constructor(s,e){this.refConfig=s;this.component=e;n(this,"myop",!0);n(this,"__nonProxied");this.__nonProxied=D(u({},this),{component:null})}static create(s,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:s,behavior:{type:"code"}}),new o(r,t)}};var Ct="ClickReplayMessage",Ye=class extends w{constructor(e,t){super(t);this.ref=e;n(this,"replyMessageKey",Ct);n(this,"messageType","BindClickMessage");n(this,"cleanable",!0)}},A=class extends b{constructor(){super(...arguments);n(this,"messageType",Ct)}};var et=class extends h{constructor(e,t){super();this.ref=e;n(this,"messageType","ChangeTextMessage");this.content=t}};var bt="ExecuteScriptReplyMessage",jt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Jt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,wt=o=>{let s=o.match(jt);if(s)return s[1]||s[3];{let e=o.match(Jt);if(e)return e[1].trim()}},E=class extends w{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;n(this,"replyMessageKey",bt);n(this,"messageType","ExecuteScriptMessage");n(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=wt(this.content)}};n(E,"replierKey","send"),n(E,"completeStreamKey","completeStream");var F=class extends b{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;n(this,"messageType",bt)}};var $=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(m.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=D(u({},t),{_script:e.toString()})}};var Tt="EventListenerCallbackMessage",tt=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;n(this,"replyMessageKey",Tt);n(this,"messageType","AddEventListenerMessage");n(this,"cleanable",!0);n(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},U=class extends b{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;n(this,"messageType",Tt);this.content={e:t}}};var st=class extends h{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;n(this,"messageType","SetAttributeMessage")}};var St="ElementValueReplayMessage",ot=class extends w{constructor(e,t){super(t);this.ref=e;n(this,"replyMessageKey",St);n(this,"messageType","GetElementValueMessage")}},z=class extends b{constructor(e){super();this.content=e;n(this,"messageType",St)}};var nt=class extends h{constructor(e,t){super();this.ref=e;n(this,"messageType","SetInnerHtml");this.content=t}};var V=class extends h{constructor(e){super();n(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends V{constructor(){super(...arguments);n(this,"messageType","InitResponse")}},N=class extends h{constructor(){super(...arguments);n(this,"messageType","InitRequest")}};var Et="RefComponentCreatedMessage",se=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;n(this,"replyMessageKey",Et);n(this,"messageType","CreateRefComponentMessage")}},B=class extends b{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;n(this,"messageType",Et)}};var oe=class extends h{constructor(e,t){super();this.destination=e;this.message=t;n(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Rt="DetectedMyopRefsMessage",rt=class extends w{constructor(){super(...arguments);n(this,"messageType","DetectMyopRefsMessage");n(this,"replyMessageKey",Rt)}},q=class extends b{constructor(e,t){super(e);this.replayToHandler=e;n(this,"messageType",Rt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var vt="GetAttributeReplayMessage",it=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;n(this,"replyMessageKey",vt);n(this,"messageType","GetAttributeMessage")}},ne=class extends b{constructor(e){super();this.content=e;n(this,"messageType",vt)}};var k=class extends h{constructor(e){super();this.method=e;n(this,"messageType","ExecuteComponentMethod")}};var at=class extends h{constructor(){super(...arguments);n(this,"messageType","SetMutationObserverMessage")}},re=class extends h{constructor(){super(...arguments);n(this,"messageType","MutationObserverMessage")}};var kt="CleanupReplayMessage",ie=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;n(this,"replyMessageKey",kt);n(this,"messageType","CleanupMessage")}},ae=class extends b{constructor(e){super();this.customCleanup=e;n(this,"messageType",kt)}};var pe=class extends h{constructor(){super(...arguments);n(this,"messageType","DisposeMessage")}};var pt=class extends h{constructor(){super(...arguments);n(this,"cleanable",!0);n(this,"messageType","SetResizeObserverMessage")}},me=class extends h{constructor(){super(...arguments);n(this,"messageType","ResizeObserverMessage")}};var mt=class{constructor(s,e){this.id=s;this.context=e;n(this,"send",s=>{})}},G=class{constructor(){n(this,"messageToHandleAfterInit",[]);n(this,"components",{});n(this,"alwaysPassEnvelopesToHost",!1);n(this,"messageCleanupCache",{})}handleIncomeMessages(s){let e=s.data?s.data:s.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==C.down)return;if(t.messageType===d.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===d.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new mt(r),this.messageToHost(new te(r));return}if(t.messageType===d.EnvelopedMessage){let r=t,i=r.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(m=>m.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(m=>m.id===r.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===d.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Mt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let r=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){r=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var X={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader"};var ge={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var j=class{};n(j,"code","code"),n(j,"component","component");var Q={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ue={Segment:"Segment",Promo:"Promo",AB:"AB"},J=class{constructor(s,e){this.container=s;this.shadowRoot=e;n(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));n(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var ye=class extends y{constructor(){super(...arguments);n(this,"messageType",d.DetectMyopRefsMessage);n(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new W(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new q(e.handlerUniqueId,r))})}};var M=(o,s)=>s.querySelectorAll("[".concat(S.id,"='").concat(o.refConfig.selector,"']")),Ht=(o,s)=>{let e=M(o,s);return e.length?e.item(0):null};var he=class extends y{constructor(){super(...arguments);n(this,"messageType",d.BindClickMessage);n(this,"executor",e=>{let t=[];return M(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new A,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Me=class extends y{constructor(){super(...arguments);n(this,"messageType",d.ChangeTextMessage);n(this,"executor",e=>{M(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var ct=o=>o!==Object(o),Xt=o=>typeof o=="function",dt=o=>{if(ct(o))return!0;if(Xt(o)||Object.getPrototypeOf(o))return!1;for(let s in o){let e=o[s];if(typeof e=="object"){if(!dt(e))return!1}else{if(ct(e))continue;return!1}}return!0},R=(o,s={},e=!0,t=new WeakMap)=>{if(ct(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let r=[];t.set(o,r);for(let i=0;i<o.length;i++){let a=o[i];r[i]=R(a,s,e,t)}return r}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let r={};t.set(o,r);for(let i in o){let a=typeof s=="boolean"?s:s[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(r[i]=R(o[i],!0,e,t)):typeof a=="object"&&(r[i]=R(o[i],a,e,t)))}return r}return{}};var Ie=(o,s,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=R,t.send=s,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);s(i)};var xe=class extends y{constructor(){super(...arguments);n(this,"messageType",d.ExecuteScriptMessage);n(this,"executor",e=>{Ie(e,r=>{this.messageToHost(new F(e.handlerUniqueId,r))},new J(document.documentElement))})}};var Ce="__federation__",Dt="onLoad";var Z=(o,s)=>{window[Ce]&&window[Ce][o]&&window[Ce][o][Dt]&&window[Ce][o][Dt]({[o]:s})};var be=class extends y{constructor(){super(...arguments);n(this,"messageType",d.AddEventListenerMessage);n(this,"executor",e=>{let t=M(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new U(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var we=class extends y{constructor(){super(...arguments);n(this,"messageType",d.SetAttributeMessage);n(this,"executor",e=>{M(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var _=class{constructor(s,e,t){this.componentDefinition=s;this.container=e;n(this,"id","");n(this,"messageHandlers",{});n(this,"element");n(this,"_markedForDisposed",!1);n(this,"bind",(s,e)=>{this.messageHandlers[s]||(this.messageHandlers[s]=[]),this.messageHandlers[s].includes(e)||this.messageHandlers[s].push(e)});n(this,"bindWhen",(s,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[s]||(this.messageHandlers[s]=[]);let r=this.messageHandlers[s],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});n(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});n(this,"isInitiated",!1);n(this,"_whenInitiatedResolve");n(this,"_whenInitiatedReject");n(this,"_whenInitiated",new Promise((s,e)=>{this._whenInitiatedResolve=s,this._whenInitiatedReject=e}));n(this,"initiated",()=>this._whenInitiated);n(this,"props",{});n(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(s);let r=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(r," ").concat(this.id))},r),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(s){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=s}onMessageReceived(s){if(s.messageType===d.ExecuteComponentMethod){let t=s;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[s.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(s)}),t}return!1}sendCleanupMessage(s){s.source=this.id,s.destination=this.id,s.direction=C.down;let e=this.bindWhen(s.replyMessageKey,r=>r.replayToHandler===s.handlerUniqueId,r=>{s.handler(r),e()}),t=s.handler;delete s.handler,this.send(s),s.handler=t}send(s){s.source||(s.source=this.id),s.destination||(s.destination=this.id),s.direction=C.down;let e;if(s.handler){let t=s;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete s.handler}return s.ref&&(s.ref=s.ref.__nonProxied||s.ref),s.cleanable?()=>{this.sendCleanupMessage(new ie(s.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let s=this.messageHandlers.onDispose;s&&s.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Bt={notSerializableRefCall:(o,s)=>{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(s," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var ce=class extends _{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;n(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new oe(this.id,e)),e.handler=t,r});n(this,"dispose",()=>{this.isInitiated&&this.send(new k("dispose")),super.dispose()})}hide(){this.send(new k("hide"))}show(){this.send(new k("show"))}inspect(){return this.send(new k("inspect"))}setHeightBasedOnDocumentElement(){this.send(new k("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new k("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var Qt=(o,s,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(s,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},Te=(o,s,e,t,r,i)=>{let a=Qt("".concat(i.name," : ").concat(s),e,i);return t.insertBefore(a,r),r.style.border="1px solid #007BFF",r.style.display="block",()=>{r.style.border="unset",t.removeChild(a)}},Lt=(o,s)=>{let e=s.reduce((r,i)=>D(u({},r),{[i.name]:u({},i)}),{}),t={get:(r,i)=>{let a=e[i];return a.mode==="output"?new Promise(p=>{let m=[];a.behavior.ref&&m.push(L.create(a.behavior.ref)),m.push(g=>{p(g)}),a.behavior.params&&m.push(...a.behavior.params);let c=fe[a.behavior.message];o.send(new c(...m))}):null},set:(r,i,a)=>{let p=e[i];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(i,"\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 m=[];p.behavior.ref&&m.push(L.create(p.behavior.ref)),m.push(a),p.behavior.params&&m.push(...p.behavior.params);let c=fe[p.behavior.message];return o.send(new c(...m)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(i,"\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,t),o},Zt=(o,s)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{dt(p)||Bt.notSerializableRefCall(t,p)}),s.send(new $(({ref:p,propName:m,functionArgs:c,makeSerializable:g})=>{if(p){let l=p[m];return g(typeof l=="function"?p[m](...c):l,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return s.send(new $(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),lt=async(o,s,e,t)=>{let r=o.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new ce(s.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new se(o.refConfig,s,D(u({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(m),c.failed){a("CreateRefComponentMessage failed");return}let g=e.find(l=>l.id==p.id);if(g!==p){r.refs[o.refConfig.name]=g,i(g);return}else p.setInitiated(),r.refs[o.refConfig.name]=p;c.nestedRefs.forEach(l=>{let f=s.instance.resolvedNestedComponents.find(P=>P.type.id===l.componentDefinitionId).type,I=new ce(f,p);I.setInitiated(),p.refs[l.refName]=I,e.push(I)});try{await ft(p,s,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(l){a(l)}}))})},ft=async(o,s,e,t=!1)=>{o.refs||(o.refs={});let r=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==j.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let g=(m=s.instance.resolvedNestedComponents)==null?void 0:m.find(f=>f.type.id===c);if(!g)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let l=L.create("",i,o);try{let f=await lt(l,g,e);o.refs[i.name]=f,a()}catch(f){p(f)}}else try{let c=L.create("",i,o);o.refs[i.name]=Zt(c,o),a()}catch(c){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends _{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;n(this,"cleanupInspect");n(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});n(this,"observeSizeBasedOnDocumentElement",()=>{let e=this.send(new E(({send:t})=>{let{height:r,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:m}=document.documentElement.getBoundingClientRect();t({height:p,width:m})});return a.observe(document.documentElement),a.observe(document.body),{height:r,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")}))});n(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new E(()=>{let{height:t,width:r}=document.documentElement.getBoundingClientRect();return{height:t,width:r}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});n(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new E(()=>{let r=0;return r++,r--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+r+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});n(this,"send",e=>{var i,a;let t=u({},e);if(t.messageType===d.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=C.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});n(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Te(this.id,"MyopIframeComponent",10,this.container,this.IframeElement,this.componentDefinition),()=>{this.cleanupInspect(),this.cleanupInspect=void 0})}hide(){this.IframeElement.style.opacity="0",this.IframeElement.style.position="absolute",this.IframeElement.style.pointerEvents="none",this.IframeElement.style.visibility="hidden"}show(){this.IframeElement.style.opacity="1",this.IframeElement.style.position="unset",this.IframeElement.style.pointerEvents="all",this.IframeElement.style.visibility="visible"}onMessageReceived(e){return e.messageType===d.In.MutationObserverMessage||e.messageType===d.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){n(this,"appendChild",(s,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return s.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return s.insertBefore(e,i||null)}}else return s.appendChild(e)})}};var Yt=(o,s,e)=>{let t=new URL(o);return t.searchParams.append(s,e),t.toString()},Se=class extends O{constructor(){super(...arguments);n(this,"type",X.IframeLoader);n(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),c="myop-comp-".concat(m);a=document.createElement("iframe"),r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(a.style.visibility="hidden"),a=this.appendChild(r,a,i);let g=t.loader.url;i!=null&&i._hasParent&&(g=Yt(g,"_myop-comp",m));let l="";i!=null&&i.elementAttributes&&(l=Object.entries(i==null?void 0:i.elementAttributes).map(([f,I])=>I===""||I===null||I===void 0?f:"".concat(f,'="').concat(String(I),'"')).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(i!=null&&i.hidden?"0":"1",";\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",';\n "\n src="').concat(g,'"\n ').concat(l,"\n ></iframe>"),a=r.querySelector("#".concat(c))}return new Y(e,t,r,a,i)})}};var Ee={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends _{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;n(this,"cleanupInspect",()=>{});n(this,"send",e=>{let t=u({},e),r=super.send(t),i=new CustomEvent(Ee.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});n(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=Te(this.id,"MyopWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}};var gt={},Re=class extends O{constructor(){super(...arguments);n(this,"type",X.WebComponentLoader);n(this,"load",async(e,t,r,i)=>{let a=t.loader;gt[a.url]?console.log("Module alreday loaded or in loading process"):gt[a.url]=new Promise((c,g)=>{let l=a.url,f=document.createElement("script");f.type="module",f.src=l,f.onload=()=>{c()},f.onerror=()=>{g()},document.head.appendChild(f)}),await gt[a.url],await xt(1);let p="myop-comp-".concat(v()),m=document.createElement(a.tag);return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),i!=null&&i._environment&&(m._myopEnvironment=i==null?void 0:i._environment),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ve="0.1.43";var x=class extends le{constructor(e,t){super(e);this.context=t;n(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(D(u({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ke=class extends x{constructor(){super(...arguments);n(this,"messageType",d.BindClickMessage);n(this,"innerExecutor",(e,t,r)=>{let i=M(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new A(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var He=class extends x{constructor(){super(...arguments);n(this,"messageType",d.ChangeTextMessage);n(this,"innerExecutor",(e,t)=>{M(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var De=class extends J{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var Be=class extends x{constructor(){super(...arguments);n(this,"innerExecutor",(e,t)=>{let r=t.shadowRoot.querySelectorAll("[".concat(S.id,"]")),i=[];r.forEach(a=>{let p=a.getAttribute(S.id);p&&i.push(new W(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new q(e.handlerUniqueId,i))});n(this,"messageType",d.DetectMyopRefsMessage)}};var Le=class extends x{constructor(){super(...arguments);n(this,"messageType",d.SetAttributeMessage);n(this,"innerExecutor",(e,t)=>{M(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var _e=class extends x{constructor(){super(...arguments);n(this,"messageType",d.AddEventListenerMessage);n(this,"innerExecutor",(e,t,r)=>{let i=M(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=c=>{r(new U(e.handlerUniqueId,R(c,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Oe=class extends x{constructor(){super(...arguments);n(this,"messageType",d.CreateRefComponentMessage);n(this,"innerExecutor",(e,t,r)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=H.Instance(),m=p.components.find(f=>f.id===e.options.id);m&&m.dispose();let c=p.components.indexOf(m);c!==-1&&p.components.splice(c,1);let g=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),l=[];Object.keys(g.refs).forEach(f=>{let I=g.refs[f];I=I.__nonProxied||I,I.componentDefinition&&l.push({refName:f,componentDefinitionId:I.componentDefinition.id})}),r(new B(e.handlerUniqueId,l))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new B(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Pe=class extends x{constructor(){super(...arguments);n(this,"messageType",d.ExecuteScriptMessage);n(this,"innerExecutor",(e,t,r)=>{Ie(e,a=>{r(new F(e.handlerUniqueId,a))},t)})}};var _t=o=>{if(!o)return null;if(o.tagName==="FORM"){let s=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:_t(i),required:i.required,validity:R(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(m):(e.unmappedData.push(e.formData[p]),e.formData[p]=m):e.formData[p]=m:e.unmappedData.push(m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},Ke=class extends x{constructor(){super(...arguments);n(this,"messageType",d.GetElementValueMessage);n(this,"innerExecutor",(e,t,r)=>{M(e.ref,t.shadowRoot).forEach(a=>{r(new z(_t(a)),e)})})}};var Ae=class extends x{constructor(){super(...arguments);n(this,"messageType",d.SetInnerHtml);n(this,"innerExecutor",(e,t)=>{M(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var de=class extends G{constructor(){super(...arguments);n(this,"alwaysPassEnvelopesToHost",!0);n(this,"connectedCallback",(e,t)=>{e.addEventListener(Ee.webcomponent_message_key,r=>{let i=r.data?r.data:r.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(r),a.messageType===d.InitMessage){let p=a.content.id;this.components[p].context=new De(e,t)}}}),setTimeout(()=>{this.messageToHost(new N)},1)});n(this,"messageToHost",(e,t)=>{e.direction=C.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});n(this,"supportedHandlers",[new He(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new Be(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Pe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Oe(this.messageToHost,this.components)]);n(this,"init",()=>{})}};Z("WebComponentSDK",de);var Ot=[],Fe,Pt=async()=>(Fe||(Fe=new de,Fe.init()),Fe);function es(o,s){return class extends HTMLElement{connectedCallback(){let e=s===ge.open?"open":"closed",t=this.attachShadow({mode:e});Pt().then(r=>{r.connectedCallback(this,t),t.innerHTML=o})}}}var ts=(o,s,e)=>{customElements.define(o,es(s,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},ss=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),os=o=>(o=ss(o),o.replace(/_/g,"-"));var $e=class extends O{constructor(){super(...arguments);n(this,"type",X.HTMLLoader);n(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===ge.localFrame){let c=v(),g="myop-comp-".concat(c),l=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(l.style.visibility="hidden"),l=this.appendChild(r,l,i),l.id=g,l.setAttribute("style","\n padding: 0;\n margin: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n position: ").concat(i!=null&&i.hidden?"absolute":"static",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ")),r.appendChild(l);let f=l.contentDocument||l.contentWindow.document;f.open();let I=a.HTML;if(i!=null&&i._inspection){let T=new DOMParser().parseFromString(a.HTML,"text/html"),K=T.implementation.createHTMLDocument();K.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let Xe=K.body.firstChild;Xe&&T.head&&T.head.insertBefore(T.importNode(Xe,!0),T.head.firstChild),I=T.documentElement.outerHTML}f.writeln(I),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 P=new Y(e,t,r,l,i);return l.onload=()=>{P.observeSizeBasedOnDocumentElement()},P}if(a.shadowRootMode===ge.none){let c=document.createElement("template");c.innerHTML=a.HTML,m=c.content.firstElementChild,Pt().then(g=>{g.connectedCallback(m,m)})}else{let c=os(e.name+t.id);Ot.includes(c)||(ts(c,a.HTML,a.shadowRootMode),Ot.push(c)),m=document.createElement(c)}return r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),m.id=p,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(r,m,i),new ee(e,t,r,m,i)})}};var ze=class ze{constructor(s="https://cloud.myop.dev"){this._baseUrl=s;n(this,"userFlows",{})}async fetchComponent(s,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===s):(await this.fetchAutoFlow(s)).components[0]}async fetchAutoFlow(s){return this.userFlows[s]||(this.userFlows[s]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(s,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[s]}async fetchFlow(s){return this.userFlows[s]||(this.userFlows[s]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(s,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[s]}};n(ze,"Main",new ze);var Ue=ze;var Kt=async o=>{try{let s=new URL(window.location.href),t=new URLSearchParams(s.search).get("myopOverride");if(t){let[r,i]=It(t),p=(await Ue.Main.fetchFlow(r)).components.find(m=>m.type.id===o.type.id);if(p&&p.instance.skinSelector.type===Q.Segmented&&p.instance.resolvedExperiences){let m=p.instance.resolvedExperiences.find(c=>c.id===i);if((m==null?void 0:m.type)===ue.Segment){let c=m,l=p.instance.skinSelector.segments.find(f=>f.segmentId===c.segment.id);if(l)return p.instance.skinSelector=l==null?void 0:l.skinSelector,p}}}}finally{return null}};var At="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){n(this,"components2init",[]);n(this,"components",[]);n(this,"componentsLoaders",[]);n(this,"initiated",!1);n(this,"version",ve);n(this,"type2InstanceCount",{});n(this,"assignId",s=>(this.type2InstanceCount[s.id]||(this.type2InstanceCount[s.id]=0),"".concat(s.id,"_").concat(++this.type2InstanceCount[s.id])));n(this,"inspected",!1);n(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(s=>{s.inspect&&s.inspect()}))});n(this,"incomingMessageHandler",s=>{if(s.origin,document.location.origin,s.data.myop){if(s.data.direction!==C.up&&s.data.messageType!==d.EnvelopedMessage)return;let e=s.data;if(e.messageType===d.InitRequest){this.components2init.forEach(r=>{r.send(new V(r.id))});return}if(e.messageType===d.InitResponse){this.components2init=this.components2init.filter(i=>i.id!==e.content.id);let r=this.components.find(i=>{var a;return i.id===((a=e.content)==null?void 0:a.id)});r==null||r.setInitiated();return}if(e.messageType===d.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===C.down){r.message.messageType===k.name?i.onMessageReceived(r.message):(r.message.route=r.route,i.send(r.message));return}}else{let a=this.components.find(p=>p.id===r.message.destination);a&&a.send(r.message)}return}let t=this.components.find(r=>r.id===e.destination);if(!t){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e);return}if(t){if(t.onMessageReceived(e))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(e)}}});n(this,"send",s=>{let e=new MessageEvent("",{data:s});this.incomingMessageHandler(e)});n(this,"init",s=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Se,new Re,new $e];if(this.componentsLoaders=[...e],s){let t={};s.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});n(this,"_getSkinIdBySkinSelector",async(s,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(s.type){case"DedicatedSkin":case Q.Dedicated:return((i=s.skin)==null?void 0:i.id)||s.skins[0].id;case Q.Segmented:{let p=await r(s.segments,async m=>{if(m.segmentId==="Default")return!0;let c=e.find(I=>I.type===ue.Segment?I.segment.id===m.segmentId:!1);if(!c)throw new Error("experience not found");let l=c.segment,f=(t||{})[l.function];return f?await f():(console.warn("segmentId:".concat(m.segmentId,", ").concat(l.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});n(this,"runSkinSelector",async(s,e)=>{let t=await this._getSkinIdBySkinSelector(s.instance.skinSelector,s.instance.resolvedExperiences,e);return s.type.skins.find(r=>r.id===t)});n(this,"loaderHooks");n(this,"loadComponent",async(s,e,t)=>{var g,l,f,I,P,Je;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Kt(s);r&&(s=r);let i=e;if(i.myop)if(i.component){s=u({},s),s.instance=u({},s.instance);let T=u(u({},(g=this.loaderHooks)!=null?g:{}),(l=t==null?void 0:t.hooks)!=null?l:{}),K=await this.runSkinSelector(s,T);if(!K)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(K=await t.hooks.afterSkinSelected(u({},K))),s.instance.skinSelector={type:Q.Dedicated,skin:K},t&&(t=u({},t),delete t.hooks),await lt(i,s,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let a=u(u({},(I=this.loaderHooks)!=null?I:{}),(P=t==null?void 0:t.hooks)!=null?P:{}),p=await this.runSkinSelector(s,a);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(Je=t==null?void 0:t.hooks)!=null&&Je.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(u({},p)));let m=this.componentsLoaders.find(T=>T.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await m.load(s.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(T=>T!==c),this.components2init=this.components2init.filter(T=>T!==c),!0)),this.components.push(c),t!=null&&t.connectProps&&(c=Lt(c,s.type.props));try{await ft(c,s,this.components)}catch(T){throw T}return t!=null&&t.skipInit||await c.initiated(),c});n(this,"navigate",async(s,e,t)=>{if(s.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,s.container,u({hidden:!0,relative:{direction:"after",child:s.element}},t));return t.init&&await t.init(r),r.show(),s.dispose(),r}else{let r=s.element.nextSibling;return s.dispose(),this.loadComponent(e,s.container,u({relative:{direction:"before",child:r}},t))}})}};n(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:At});if(!window.myop.hostSDK){let o=new H;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:At}),window.myop.hostSDK=o}var ns=window.myop.hostSDK;Z("hostSDK",ns);var Ne=class extends y{constructor(){super(...arguments);n(this,"messageType",d.CreateRefComponentMessage);n(this,"executor",e=>{(async()=>{let r=document.querySelectorAll("[".concat(S.id,"='").concat(e.refConfig.selector,"']"));if(r.length===1){let a=await H.Instance().loadComponent(e.nestedComponentConfig,r.item(0),e.options),p=[];Object.keys(a.refs).forEach(m=>{let c=a.refs[m];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:m,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new B(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new B(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Ft=(o,s)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(s),r={attributes:!0,childList:!0,subtree:!0};return t.observe(o,r),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",s,!1),o.addEventListener("DOMNodeRemoved",s,!1))};var qe=class extends y{constructor(){super(...arguments);n(this,"messageType",d.SetMutationObserverMessage);n(this,"executor",e=>{e.source&&Ft(document.body,()=>{this.messageToHost(new re)})})}};var $t=o=>{if(!o)return null;if(o.tagName==="FORM"){let s=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),r=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(S.id),p=i.getAttribute("name"),m={id:i.id,name:p,value:$t(i),required:i.required,validity:R(i.validity,!0),myopId:a};e.unmappedData.push(m),p&&(!e.formData[p]||!e.formData[p].value||m.value)&&(e.formData[p]=m)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},We=class extends y{constructor(){super(...arguments);n(this,"messageType",d.GetElementValueMessage);n(this,"executor",e=>{M(e.ref,document).forEach(r=>{this.messageToHost(new z($t(r)),e)})})}};var Ve=class extends y{constructor(){super(...arguments);n(this,"messageType",d.GetAttributeMessage);n(this,"executor",e=>{let t=Ht(e.ref,document);t&&this.messageToHost(new ne(t.getAttribute(e.name)),e)})}};var Ge=class extends y{constructor(){super(...arguments);n(this,"messageType",d.SetResizeObserverMessage);n(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var je=class extends y{constructor(){super(...arguments);n(this,"messageType",d.SetInnerHtml);n(this,"executor",e=>{M(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var ut=class extends G{constructor(){super();n(this,"version",ve);n(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=C.up,(i=window.parent)==null||i.postMessage(u({},e),"*")});n(this,"supportedHandlers",[new Me(this.messageToHost),new je(this.messageToHost),new he(this.messageToHost),new ye(this.messageToHost),new xe(this.messageToHost),new be(this.messageToHost),new we(this.messageToHost),new We(this.messageToHost),new qe(this.messageToHost),new Ge(this.messageToHost),new Ve(this.messageToHost),new Ne(this.messageToHost)]);n(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new N)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",ut);export{ut as IframeSDK};
@@ -1685,7 +1685,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
1685
1685
  };
1686
1686
 
1687
1687
  // version:myop-sdk-version
1688
- var myop_sdk_version_default = "0.1.41";
1688
+ var myop_sdk_version_default = "0.1.43";
1689
1689
 
1690
1690
  // src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
1691
1691
  var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
@@ -2066,7 +2066,19 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
2066
2066
  container.appendChild(IframeElement);
2067
2067
  const doc = IframeElement.contentDocument || IframeElement.contentWindow.document;
2068
2068
  doc.open();
2069
- doc.writeln(loaderConfig.HTML);
2069
+ let HTML2Render = loaderConfig.HTML;
2070
+ if (options == null ? void 0 : options._inspection) {
2071
+ const parser = new DOMParser();
2072
+ const _doc = parser.parseFromString(loaderConfig.HTML, "text/html");
2073
+ const temp = _doc.implementation.createHTMLDocument();
2074
+ temp.body.innerHTML = "<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";
2075
+ const node = temp.body.firstChild;
2076
+ if (node && _doc.head) {
2077
+ _doc.head.insertBefore(_doc.importNode(node, true), _doc.head.firstChild);
2078
+ }
2079
+ HTML2Render = _doc.documentElement.outerHTML;
2080
+ }
2081
+ doc.writeln(HTML2Render);
2070
2082
  doc.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(
2071
2083
  // @ts-ignore
2072
2084
  window.__federation__
@@ -2394,7 +2406,7 @@ var HostSDK = class {
2394
2406
  });
2395
2407
  __publicField(this, "loaderHooks");
2396
2408
  __publicField(this, "loadComponent", async (componentConfig, container, options) => {
2397
- var _a, _b, _c, _d;
2409
+ var _a, _b, _c, _d, _e, _f;
2398
2410
  if (!container) {
2399
2411
  debugger;
2400
2412
  throw new Error("no container was found for this component");
@@ -2408,8 +2420,8 @@ var HostSDK = class {
2408
2420
  if (ref.component) {
2409
2421
  componentConfig = __spreadValues({}, componentConfig);
2410
2422
  componentConfig.instance = __spreadValues({}, componentConfig.instance);
2411
- const hooks = __spreadValues(__spreadValues({}, (_a = this.loaderHooks) != null ? _a : {}), (_b = options == null ? void 0 : options.hooks) != null ? _b : {});
2412
- let selectedSkin2 = await this.runSkinSelector(componentConfig, hooks);
2423
+ const hooks2 = __spreadValues(__spreadValues({}, (_a = this.loaderHooks) != null ? _a : {}), (_b = options == null ? void 0 : options.hooks) != null ? _b : {});
2424
+ let selectedSkin2 = await this.runSkinSelector(componentConfig, hooks2);
2413
2425
  if (!selectedSkin2) {
2414
2426
  throw new Error("runSkinSelector failed to choose skin, check the provided config");
2415
2427
  }
@@ -2432,11 +2444,12 @@ var HostSDK = class {
2432
2444
  }
2433
2445
  }
2434
2446
  container = container;
2435
- let selectedSkin = await this.runSkinSelector(componentConfig, options == null ? void 0 : options.hooks);
2447
+ const hooks = __spreadValues(__spreadValues({}, (_d = this.loaderHooks) != null ? _d : {}), (_e = options == null ? void 0 : options.hooks) != null ? _e : {});
2448
+ let selectedSkin = await this.runSkinSelector(componentConfig, hooks);
2436
2449
  if (!selectedSkin) {
2437
2450
  throw new Error("runSkinSelector failed to choose skin, check the provided config");
2438
2451
  }
2439
- if ((_d = options == null ? void 0 : options.hooks) == null ? void 0 : _d.afterSkinSelected) {
2452
+ if ((_f = options == null ? void 0 : options.hooks) == null ? void 0 : _f.afterSkinSelected) {
2440
2453
  selectedSkin = await options.hooks.afterSkinSelected(__spreadValues({}, selectedSkin));
2441
2454
  }
2442
2455
  const componentLoader = this.componentsLoaders.find((loader) => loader.type === selectedSkin.loader.type);