@myop/sdk 0.1.44 → 0.1.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/bundled-declarations.d.ts +9 -1
- package/dist/cjs/_IframeSDK.71663203.min.js +1 -0
- package/dist/cjs/{_IframeSDK.dd7fa267.js → _IframeSDK.b1e6c181.js} +4 -6
- package/dist/cjs/_IframeSDK.b1e6c181.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.3474ea7a.min.js +1 -0
- package/dist/cjs/{_WebComponentSDK.d843788d.js → _WebComponentSDK.bf4ad0dd.js} +4 -6
- package/dist/cjs/_WebComponentSDK.bf4ad0dd.js.map +7 -0
- package/dist/cjs/{_hostSDK.a057f932.js → _hostSDK.7c59d1ae.js} +4 -6
- package/dist/cjs/_hostSDK.7c59d1ae.js.map +7 -0
- package/dist/cjs/_hostSDK.8b543e61.min.js +1 -0
- package/dist/cjs/myop_sdk.js +11 -11
- package/dist/cjs/myop_sdk.js.map +1 -1
- package/dist/cjs/myop_sdk.min.js +1 -1
- package/dist/module/Iframe/index.js +15 -19
- package/dist/module/Iframe/index.js.map +2 -2
- package/dist/module/SDK.js +15 -19
- package/dist/module/SDK.js.map +2 -2
- package/dist/module/common/index.d.ts +9 -1
- package/dist/module/common/index.js +3 -2
- package/dist/module/common/index.js.map +2 -2
- package/dist/module/host/index.js +15 -19
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/webcomponent/index.js +15 -19
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.dd7fa267.js.map +0 -7
- package/dist/cjs/_IframeSDK.f382f9c1.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.9306948e.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.d843788d.js.map +0 -7
- package/dist/cjs/_hostSDK.39162c05.min.js +0 -1
- package/dist/cjs/_hostSDK.a057f932.js.map +0 -7
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ You can load the Root SDK into your application in one of two ways:
|
|
|
35
35
|
|
|
36
36
|
1. **Via CDN (Script Tag):**
|
|
37
37
|
```html
|
|
38
|
-
<script src="https://
|
|
38
|
+
<script src="https://cdn.myop.dev/sdk/next/myop_sdk.min.js"></script>
|
|
39
39
|
<script>
|
|
40
40
|
// Initialize the SDK
|
|
41
41
|
const { hostSDK } = await window.myop.rootSDK.getHostModule();
|
|
@@ -149,6 +149,7 @@ declare module "@myop/sdk/common" {
|
|
|
149
149
|
readonly IframeLoader: "IframeLoader";
|
|
150
150
|
readonly WebComponentLoader: "WebComponentLoader";
|
|
151
151
|
readonly HTMLLoader: "HTMLLoader";
|
|
152
|
+
readonly MinimizedLoader: "MinimizedLoader";
|
|
152
153
|
};
|
|
153
154
|
export type SkinLoaderType = keyof typeof SkinLoaders;
|
|
154
155
|
export type PropType = 'any' | 'string' | 'number' | string;
|
|
@@ -186,6 +187,9 @@ declare module "@myop/sdk/common" {
|
|
|
186
187
|
height?: string;
|
|
187
188
|
width?: string;
|
|
188
189
|
}
|
|
190
|
+
export interface IMinimizedLoaderConfig extends ISkinLoaderConfig {
|
|
191
|
+
type: "MinimizedLoader";
|
|
192
|
+
}
|
|
189
193
|
interface DashboardObject {
|
|
190
194
|
_temp_client_id?: string;
|
|
191
195
|
}
|
|
@@ -387,13 +391,17 @@ declare module "@myop/sdk/common" {
|
|
|
387
391
|
components: IComponentInstanceConfig[];
|
|
388
392
|
origins: string[];
|
|
389
393
|
experiences: IExperience[];
|
|
394
|
+
branch?: string;
|
|
390
395
|
}
|
|
391
396
|
export interface IComponentConfig {
|
|
392
397
|
instance: IComponentInstanceConfig;
|
|
393
398
|
type: IComponentDefinitionConfig;
|
|
394
399
|
name: string;
|
|
395
400
|
}
|
|
396
|
-
|
|
401
|
+
interface IBranchable {
|
|
402
|
+
branch?: string;
|
|
403
|
+
}
|
|
404
|
+
export interface IUserFlow extends Omit<IUserFlowDefinition, 'components'>, IBranchable {
|
|
397
405
|
components: IComponentConfig[];
|
|
398
406
|
}
|
|
399
407
|
export class RootRef {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var Mt=Object.defineProperty,qt=Object.defineProperties;var Wt=Object.getOwnPropertyDescriptors;var ht=Object.getOwnPropertySymbols;var Vt=Object.prototype.hasOwnProperty,Gt=Object.prototype.propertyIsEnumerable;var je=(n,o,e)=>o in n?Mt(n,o,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[o]=e,y=(n,o)=>{for(var e in o||(o={}))Vt.call(o,e)&&je(n,e,o[e]);if(ht)for(var e of ht(o))Gt.call(o,e)&&je(n,e,o[e]);return n},B=(n,o)=>qt(n,Wt(o));var jt=(n,o)=>{for(var e in o)Mt(n,e,{get:o[e],enumerable:!0})};var s=(n,o,e)=>je(n,typeof o!="symbol"?o+"":o,e);var G=class{constructor(o,e,t,r,i){this.myopId=o;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=r;this.offsetLeft=i;s(this,"type","MyopElementRef")}};var It=async n=>{if(typeof n=="function")n();else if(n instanceof Promise){let o=await n;typeof o=="function"&&o()}},h=class{constructor(o){this.messageToHost=o}},fe=class extends h{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var c={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={};jt(ge,{AddEventListenerMessage:()=>Ye,BaseMyopMessage:()=>M,BindClickMessage:()=>Qe,ChangeTextMessage:()=>Ze,CleanupMessage:()=>ie,CleanupReplayMessage:()=>ae,ClickReplayMessage:()=>K,CreateRefComponentMessage:()=>oe,CustomRefMessage:()=>F,DetectMyopRefsMessage:()=>nt,DetectedMyopRefsMessage:()=>N,DisposeMessage:()=>pe,ElementValueReplayMessage:()=>z,EnvelopedMessage:()=>ne,EventListenerCallbackMessage:()=>$,ExecuteComponentMethod:()=>k,ExecuteScriptMessage:()=>E,ExecuteScriptReplyMessage:()=>A,GetAttributeMessage:()=>st,GetAttributeReplayMessage:()=>se,GetElementValueMessage:()=>tt,InitMessage:()=>j,InitRequest:()=>U,InitResponse:()=>te,MessageDirection:()=>b,MutationObserverMessage:()=>re,MyopBindMessage:()=>w,MyopBindReplayMessage:()=>T,MyopElementMessage:()=>Xe,Ref:()=>_,RefComponentCreatedMessage:()=>D,ResizeObserverMessage:()=>me,SetAttributeMessage:()=>et,SetInnerHtml:()=>ot,SetMutationObserverMessage:()=>rt,SetResizeObserverMessage:()=>it,stripFunction:()=>Tt});var v=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,n=>(+n^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+n/4).toString(16));var Jt=n=>{let o=[...n].map(e=>e.toString(16).padStart(2,"0")).join("");return[o.slice(0,8),o.slice(8,12),o.slice(12,16),o.slice(16,20),o.slice(20)].join("-")};var Xt=n=>{let o=n.replace(/-/g,"+").replace(/_/g,"/");for(;o.length%4;)o+="=";let e=atob(o);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Je=n=>{let o=Xt(n);if(o.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<o.length;t+=16)e.push(Jt(o.slice(t,t+16)));return e};var Ct=n=>new Promise(o=>setTimeout(o,n));var b=class{};s(b,"down","down"),s(b,"up","up");var M=class{constructor(){s(this,"id",v());s(this,"myop",!0);s(this,"content");s(this,"source");s(this,"destination");s(this,"route");s(this,"ref");s(this,"direction");s(this,"cleanable",!1)}static create(...o){return new this(...o)}isTypeof(o){return o.messageType===this.messageType}},Xe=class extends M{constructor(e){super();this.ref=e}},T=class extends M{constructor(e){super();this.replayToHandler=e}},w=class extends M{constructor(e){super();this.handler=e;s(this,"handlerUniqueId",v())}},_=class n{constructor(o,e){this.refConfig=o;this.component=e;s(this,"myop",!0);s(this,"__nonProxied");this.__nonProxied=B(y({},this),{component:null})}static create(o,e,t){let r=e;return r||(r={id:"",name:"",description:"",selectorType:"id-attribute",selector:o,behavior:{type:"code"}}),new n(r,t)}};var xt="ClickReplayMessage",Qe=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",xt);s(this,"messageType","BindClickMessage");s(this,"cleanable",!0)}},K=class extends T{constructor(){super(...arguments);s(this,"messageType",xt)}};var Ze=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","ChangeTextMessage");this.content=t}};var bt="ExecuteScriptReplyMessage",Qt=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Zt=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Tt=n=>{let o=n.match(Qt);if(o)return o[1]||o[3];{let e=n.match(Zt);if(e)return e[1].trim()}},E=class extends w{constructor(e,t=()=>{},r){super(t);this.scriptInputs=r;s(this,"replyMessageKey",bt);s(this,"messageType","ExecuteScriptMessage");s(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Tt(this.content)}};s(E,"replierKey","send"),s(E,"completeStreamKey","completeStream");var A=class extends T{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;s(this,"messageType",bt)}};var F=class extends E{constructor(e,t,r=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:m})=>{let d=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return d.length?(m.ref=d[0],new Function("return (".concat(p,")(...arguments)"))(m)):null},r);this.scriptInputs=t;this.scriptInputs=B(y({},t),{_script:e.toString()})}};var wt="EventListenerCallbackMessage",Ye=class extends w{constructor(e,t,r){super(r);this.ref=e;this.type=t;this.handler=r;s(this,"replyMessageKey",wt);s(this,"messageType","AddEventListenerMessage");s(this,"cleanable",!0);s(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},$=class extends T{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;s(this,"messageType",wt);this.content={e:t}}};var et=class extends M{constructor(e,t,r){super();this.ref=e;this.name=t;this.value=r;s(this,"messageType","SetAttributeMessage")}};var St="ElementValueReplayMessage",tt=class extends w{constructor(e,t){super(t);this.ref=e;s(this,"replyMessageKey",St);s(this,"messageType","GetElementValueMessage")}},z=class extends T{constructor(e){super();this.content=e;s(this,"messageType",St)}};var ot=class extends M{constructor(e,t){super();this.ref=e;s(this,"messageType","SetInnerHtml");this.content=t}};var j=class extends M{constructor(e){super();s(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},te=class extends j{constructor(){super(...arguments);s(this,"messageType","InitResponse")}},U=class extends M{constructor(){super(...arguments);s(this,"messageType","InitRequest")}};var Et="RefComponentCreatedMessage",oe=class extends w{constructor(e,t,r,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=r;s(this,"replyMessageKey",Et);s(this,"messageType","CreateRefComponentMessage")}},D=class extends T{constructor(e,t,r){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=r;s(this,"messageType",Et)}};var ne=class extends M{constructor(e,t){super();this.destination=e;this.message=t;s(this,"messageType","EnvelopedMessage");let r=t;this.route=[e,...r.route?r.route:[]]}};var Rt="DetectedMyopRefsMessage",nt=class extends w{constructor(){super(...arguments);s(this,"messageType","DetectMyopRefsMessage");s(this,"replyMessageKey",Rt)}},N=class extends T{constructor(e,t){super(e);this.replayToHandler=e;s(this,"messageType",Rt);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var vt="GetAttributeReplayMessage",st=class extends w{constructor(e,t,r){super(r);this.ref=e;this.name=t;s(this,"replyMessageKey",vt);s(this,"messageType","GetAttributeMessage")}},se=class extends T{constructor(e){super();this.content=e;s(this,"messageType",vt)}};var k=class extends M{constructor(e){super();this.method=e;s(this,"messageType","ExecuteComponentMethod")}};var rt=class extends M{constructor(){super(...arguments);s(this,"messageType","SetMutationObserverMessage")}},re=class extends M{constructor(){super(...arguments);s(this,"messageType","MutationObserverMessage")}};var kt="CleanupReplayMessage",ie=class extends w{constructor(e,t){super(t);this.cleanupForMessageId=e;s(this,"replyMessageKey",kt);s(this,"messageType","CleanupMessage")}},ae=class extends T{constructor(e){super();this.customCleanup=e;s(this,"messageType",kt)}};var pe=class extends M{constructor(){super(...arguments);s(this,"messageType","DisposeMessage")}};var it=class extends M{constructor(){super(...arguments);s(this,"cleanable",!0);s(this,"messageType","SetResizeObserverMessage")}},me=class extends M{constructor(){super(...arguments);s(this,"messageType","ResizeObserverMessage")}};var at=class{constructor(o,e){this.id=o;this.context=e;s(this,"send",o=>{})}},J=class{constructor(){s(this,"messageToHandleAfterInit",[]);s(this,"components",{});s(this,"alwaysPassEnvelopesToHost",!1);s(this,"messageCleanupCache",{})}handleIncomeMessages(o){let e=o.data?o.data:o.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==b.down)return;if(t.messageType===c.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===c.InitMessage){let r=t.content.id;if(this.components[r])return;this.components[r]=new at(r),this.messageToHost(new te(r));return}if(t.messageType===c.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===c.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new ae(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],It(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 L={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var q={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var pt={message:"message",code:"code"},X=class{};s(X,"code","code"),s(X,"component","component");var W={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ue={Segment:"Segment",Promo:"Promo",AB:"AB"},Q=class{constructor(o,e){this.container=o;this.shadowRoot=e;s(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));s(this,"getRoot",()=>this.shadowRoot||this.container)}};var S={id:"myop-id"};var ye=class extends h{constructor(){super(...arguments);s(this,"messageType",c.DetectMyopRefsMessage);s(this,"executor",e=>{let t=document.querySelectorAll("[".concat(S.id,"]")),r=[];t.forEach(i=>{let a=i.getAttribute(S.id);a&&r.push(new G(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new N(e.handlerUniqueId,r))})}};var I=(n,o)=>o.querySelectorAll("[".concat(S.id,"='").concat(n.refConfig.selector,"']")),Ht=(n,o)=>{let e=I(n,o);return e.length?e.item(0):null};var he=class extends h{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new K,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var Me=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.textContent=e.content})})}};var mt=n=>n!==Object(n),Yt=n=>typeof n=="function",dt=n=>{if(mt(n))return!0;if(Yt(n)||Object.getPrototypeOf(n))return!1;for(let o in n){let e=n[o];if(typeof e=="object"){if(!dt(e))return!1}else{if(mt(e))continue;return!1}}return!0},R=(n,o={},e=!0,t=new WeakMap)=>{if(mt(n))return n;if(Array.isArray(n)){if(t.has(n))return t.get(n);let r=[];t.set(n,r);for(let i=0;i<n.length;i++){let a=n[i];r[i]=R(a,o,e,t)}return r}if(n!==null&&typeof n=="object"){if(t.has(n))return t.get(n);let r={};t.set(n,r);for(let i in n){let a=typeof o=="boolean"?o:o[i];a&&(a===!0?(e?n[i]!==void 0:n[i])&&(r[i]=R(n[i],!0,e,t)):typeof a=="object"&&(r[i]=R(n[i],a,e,t)))}return r}return{}};var Ie=(n,o,e)=>{let t=n.scriptInputs?n.scriptInputs:{};t.makeSerializable=R,t.send=o,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(n.script,")(...arguments)"))(t);o(i)};var Ce=class extends h{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"executor",e=>{Ie(e,r=>{this.messageToHost(new A(e.handlerUniqueId,r))},new Q(document.documentElement))})}};var xe="__federation__",Bt="onLoad";var Z=(n,o)=>{window[xe]&&window[xe][n]&&window[xe][n][Bt]&&window[xe][n][Bt]({[n]:o})};var be=class extends h{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"executor",e=>{let t=I(e.ref,document),r=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new $(e.handlerUniqueId,R(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),r.push(()=>{i.removeEventListener(e.type,a)})}),()=>{r.forEach(i=>{i()})}})}};var Te=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.setAttribute(e.name,e.value)})})}};var P=class{constructor(o,e,t){this.componentDefinition=o;this.container=e;s(this,"id","");s(this,"messageHandlers",{});s(this,"element");s(this,"_markedForDisposed",!1);s(this,"bind",(o,e)=>{this.messageHandlers[o]||(this.messageHandlers[o]=[]),this.messageHandlers[o].includes(e)||this.messageHandlers[o].push(e)});s(this,"bindWhen",(o,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[o]||(this.messageHandlers[o]=[]);let r=this.messageHandlers[o],i=a=>e(a)?(t(a),!0):!1;return r.push(i),()=>{let a=r.indexOf(i);a>-1&&r.splice(a,1)}});s(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});s(this,"isInitiated",!1);s(this,"_whenInitiatedResolve");s(this,"_whenInitiatedReject");s(this,"_whenInitiated",new Promise((o,e)=>{this._whenInitiatedResolve=o,this._whenInitiatedReject=e}));s(this,"initiated",()=>this._whenInitiated);s(this,"props",{});s(this,"refs",{});this.id=(t==null?void 0:t.id)||H.Instance().assignId(o);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(o){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=o}onMessageReceived(o){if(o.messageType===c.ExecuteComponentMethod){let t=o;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[o.messageType];if(e&&e.length){let t=!1;return e.forEach(r=>{t=t||r(o)}),t}return!1}sendCleanupMessage(o){o.source=this.id,o.destination=this.id,o.direction=b.down;let e=this.bindWhen(o.replyMessageKey,r=>r.replayToHandler===o.handlerUniqueId,r=>{o.handler(r),e()}),t=o.handler;delete o.handler,this.send(o),o.handler=t}send(o){o.source||(o.source=this.id),o.destination||(o.destination=this.id),o.direction=b.down;let e;if(o.handler){let t=o;e=this.bindWhen(t.replyMessageKey,r=>r.replayToHandler===t.handlerUniqueId,t.handler),delete o.handler}return o.ref&&(o.ref=o.ref.__nonProxied||o.ref),o.cleanable?()=>{this.sendCleanupMessage(new ie(o.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new pe);let o=this.messageHandlers.onDispose;o&&o.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var Dt={notSerializableRefCall:(n,o)=>{throw new Error("\nThe input provided to '".concat(n.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(o," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(n.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var de=class extends P{constructor(e,t,r){super(e,t.container,r);this.componentDefinition=e;this.parent=t;s(this,"send",e=>{let t=e.handler,r=super.send(e);return this.parent.send(new ne(this.id,e)),e.handler=t,r});s(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 eo=(n,o,e)=>{let t=document.createElement("a");return t.textContent=n,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(o,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},we=(n,o,e,t,r,i)=>{let a=eo("".concat(i.name," : ").concat(o),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=(n,o,e)=>n?!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(o,"\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),_t=(n,o,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(o,"\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."))},Pt=(n,o,e)=>{let t=o.reduce((i,a)=>B(y({},i),{[a.name]:y({},a)}),{}),r={get:(i,a)=>{let p=t[a];if(Lt(p,a,n))return!1;if(p.behavior.type===pt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let d=p.behavior;return n.element.contentWindow[d.remap||a]}return _t(p,a,n),!1}return p.mode==="output"?new Promise(m=>{let d=[];p.behavior.ref&&d.push(_.create(p.behavior.ref)),d.push(f=>{m(f)}),p.behavior.params&&d.push(...p.behavior.params);let l=ge[p.behavior.message];n.send(new l(...d))}):null},set:(i,a,p)=>{let m=t[a];if(Lt(m,a,n))return!1;if(m.behavior.type===pt.code){if(e.loader.type===L.HTMLLoader&&e.loader.shadowRootMode===q.localFrame){let l=m.behavior;return n.element.contentWindow[l.remap||a]=p,!0}return _t(m,a,n),!1}else if(m.mode==="input")if(m.behavior.type==="message"){let d=[];m.behavior.ref&&d.push(_.create(m.behavior.ref)),d.push(p),m.behavior.params&&d.push(...m.behavior.params);let l=ge[m.behavior.message];return n.send(new l(...d)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(n.componentDefinition.name,", ID: ").concat(n.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(m.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return n.props={},n.props=new Proxy(n.props,r),n},to=(n,o)=>new Proxy(n,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{dt(p)||Dt.notSerializableRefCall(t,p)}),o.send(new F(({ref:p,propName:m,functionArgs:d,makeSerializable:l})=>{if(p){let f=p[m];return l(typeof f=="function"?p[m](...d):f,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,r){return o.send(new F(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:r,propName:t},i=>{})),!0}}),ct=async(n,o,e,t)=>{let r=n.component;if(!r)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new de(o.type,r,t);e.push(p),await r.initiated();let m=setTimeout(()=>{a("timeout")},5e3);r.send(new oe(n.refConfig,o,B(y({},t||{}),{id:p.id,_hasParent:!0}),async d=>{if(clearTimeout(m),d.failed){a("CreateRefComponentMessage failed");return}let l=e.find(f=>f.id==p.id);if(l!==p){r.refs[n.refConfig.name]=l,i(l);return}else p.setInitiated(),r.refs[n.refConfig.name]=p;d.nestedRefs.forEach(f=>{let g=o.instance.resolvedNestedComponents.find(x=>x.type.id===f.componentDefinitionId).type,u=new de(g,p);u.setInitiated(),p.refs[f.refName]=u,e.push(u)});try{await lt(p,o,e,!0),r.setHeightBasedOnScrollHeight&&r.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},lt=async(n,o,e,t=!1)=>{n.refs||(n.refs={});let r=Object.values(n.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var m;if(i.behavior.type==X.component){if(t){a();return}let d=i.behavior.componentId;d||(d=i.behavior.instance.componentId);let l=(m=o.instance.resolvedNestedComponents)==null?void 0:m.find(g=>g.type.id===d);if(!l)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let f=_.create("",i,n);try{let g=await ct(f,l,e);n.refs[i.name]=g,a()}catch(g){p(g)}}else try{let d=_.create("",i,n);n.refs[i.name]=to(d,n),a()}catch(d){}}));try{await Promise.all(r)}catch(i){throw i}};var Y=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.componentConfig=e;this.container=r;this.IframeElement=i;s(this,"cleanupInspect");s(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new E(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});s(this,"observeSizeBasedOnDocumentElement",()=>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")})));s(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()}))});s(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()}))});s(this,"send",e=>{var i,a;let t=y({},e);if(t.messageType===c.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=b.down;let r=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),r});s(this,"dispose",()=>{this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});t.loader.autoHeight&&this.initiated().then(()=>{this.setHeightBasedOnScrollHeight()}),this.element=this.IframeElement}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=we(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===c.In.MutationObserverMessage||e.messageType===c.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var O=class{constructor(){s(this,"appendChild",(o,e,t)=>{var r;if(t!=null&&t.relative){if(t.relative.direction==="before")return o.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(r=t.relative.child)==null?void 0:r.nextSibling;return o.insertBefore(e,i||null)}}else return o.appendChild(e)})}};var oo=(n,o,e)=>{let t=new URL(n);return t.searchParams.append(o,e),t.toString()},Se=class extends O{constructor(){super(...arguments);s(this,"type",L.IframeLoader);s(this,"load",async(e,t,r,i)=>{let a,p=t.loader;if((r==null?void 0:r.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,r),a=r,a.src=p.url;else{let m=v(),d="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 l=t.loader.url;i!=null&&i._hasParent&&(l=oo(l,"_myop-comp",m));let f="";i!=null&&i.elementAttributes&&(f=Object.entries(i==null?void 0:i.elementAttributes).map(([g,u])=>u===""||u===null||u===void 0?g:"".concat(g,'="').concat(String(u),'"')).join(" ")),a.outerHTML='<iframe \n id="'.concat(d,'"\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(l,'"\n ').concat(f,"\n ></iframe>"),a=r.querySelector("#".concat(d))}return new Y(e,t,r,a,i)})}};var Ee={webcomponent_message_key:"myop_webcomponent_message"};var ee=class extends P{constructor(e,t,r,i,a){super(e,r,a);this.container=r;this.customElement=i;s(this,"cleanupInspect",()=>{});s(this,"send",e=>{let t=y({},e),r=super.send(t),i=new CustomEvent(Ee.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return r});s(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=we(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 ft={},Re=class extends O{constructor(){super(...arguments);s(this,"type",L.WebComponentLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader;ft[a.url]?console.log("Module alreday loaded or in loading process"):ft[a.url]=new Promise((d,l)=>{let f=a.url,g=document.createElement("script");g.type="module",g.src=f,g.onload=()=>{d()},g.onerror=()=>{l()},document.head.appendChild(g)}),await ft[a.url],await Ct(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.46";var C=class extends fe{constructor(e,t){super(e);this.context=t;s(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let r=(i,a)=>{this.messageToHost(B(y({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,r)}else debugger}else debugger})}};var ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.BindClickMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=()=>{r(new K(e.handlerUniqueId))};p.addEventListener("click",m),a.push(()=>{p.removeEventListener("click",m)})}),()=>{a.forEach(p=>p())}})}};var He=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ChangeTextMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Be=class extends Q{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var De=class extends C{constructor(){super(...arguments);s(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 G(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new N(e.handlerUniqueId,i))});s(this,"messageType",c.DetectMyopRefsMessage)}};var Le=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetAttributeMessage);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var _e=class extends C{constructor(){super(...arguments);s(this,"messageType",c.AddEventListenerMessage);s(this,"innerExecutor",(e,t,r)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let m=d=>{r(new $(e.handlerUniqueId,R(d,e.serializableSkeleton)))};p.addEventListener(e.type,m),a.push(()=>{p.removeEventListener(e.type,m)})}),()=>{a.forEach(p=>p())}})}};var Pe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(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(g=>g.id===e.options.id);m&&m.dispose();let d=p.components.indexOf(m);d!==-1&&p.components.splice(d,1);let l=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),f=[];Object.keys(l.refs).forEach(g=>{let u=l.refs[g];u=u.__nonProxied||u,u.componentDefinition&&f.push({refName:g,componentDefinitionId:u.componentDefinition.id})}),r(new D(e.handlerUniqueId,f))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Oe=class extends C{constructor(){super(...arguments);s(this,"messageType",c.ExecuteScriptMessage);s(this,"innerExecutor",(e,t,r)=>{Ie(e,a=>{r(new A(e.handlerUniqueId,a))},t)})}};var Ot=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.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:Ot(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 n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},Ke=class extends C{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"innerExecutor",(e,t,r)=>{I(e.ref,t.shadowRoot).forEach(a=>{r(new z(Ot(a)),e)})})}};var Ae=class extends C{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var ce=class extends J{constructor(){super(...arguments);s(this,"alwaysPassEnvelopesToHost",!0);s(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===c.InitMessage){let p=a.content.id;this.components[p].context=new Be(e,t)}}}),setTimeout(()=>{this.messageToHost(new U)},1)});s(this,"messageToHost",(e,t)=>{e.direction=b.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});s(this,"supportedHandlers",[new He(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new ke(this.messageToHost,this.components),new De(this.messageToHost,this.components),new Le(this.messageToHost,this.components),new _e(this.messageToHost,this.components),new Oe(this.messageToHost,this.components),new Ke(this.messageToHost,this.components),new Pe(this.messageToHost,this.components)]);s(this,"init",()=>{})}};Z("WebComponentSDK",ce);var Kt=[],Fe,At=async()=>(Fe||(Fe=new ce,Fe.init()),Fe);function no(n,o){return class extends HTMLElement{connectedCallback(){let e=o===q.open?"open":"closed",t=this.attachShadow({mode:e});At().then(r=>{r.connectedCallback(this,t),t.innerHTML=n})}}}var so=(n,o,e)=>{customElements.define(n,no(o,e)),console.log("define('".concat(n,"') was called, web component ready to use"))},ro=n=>n.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),io=n=>(n=ro(n),n.replace(/_/g,"-"));var $e=class extends O{constructor(){super(...arguments);s(this,"type",L.HTMLLoader);s(this,"load",async(e,t,r,i)=>{let a=t.loader,p="myop-comp-".concat(v()),m;if(a.shadowRootMode===q.localFrame){let d=v(),l="myop-comp-".concat(d),f=document.createElement("iframe");r.querySelector('[id^="myop-comp-"]')||(r.innerHTML=""),i!=null&&i.hidden&&(f.style.visibility="hidden"),f=this.appendChild(r,f,i),f.id=l,f.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(f);let g=f.contentDocument||f.contentWindow.document;g.open();let u=a.HTML;if(i!=null&&i._inspection){let V=new DOMParser().parseFromString(a.HTML,"text/html"),ut=V.implementation.createHTMLDocument();ut.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let yt=ut.body.firstChild;yt&&V.head&&V.head.insertBefore(V.importNode(yt,!0),V.head.firstChild),u=V.documentElement.outerHTML}g.writeln(u),g.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>')),g.close();let x=new Y(e,t,r,f,i);return a.autoHeight&&(f.onload=()=>{x.observeSizeBasedOnDocumentElement()}),x}if(a.shadowRootMode===q.none){let d=document.createElement("template");d.innerHTML=a.HTML,m=d.content.firstElementChild,At().then(l=>{l.connectedCallback(m,m)})}else{let d=io(e.name+t.id);Kt.includes(d)||(so(d,a.HTML,a.shadowRootMode),Kt.push(d)),m=document.createElement(d)}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(o="https://cloud.myop.dev"){this._baseUrl=o;s(this,"userFlows",{})}async fetchComponent(o,e){return e?(await this.fetchFlow(e)).components.find(r=>r.type.id===o):(await this.fetchAutoFlow(o)).components[0]}async fetchAutoFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&auto=true"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}async fetchFlow(o){return this.userFlows[o]||(this.userFlows[o]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(o,"&resolve=components"))).json();e(i.item)}catch(r){t(r)}})),await this.userFlows[o]}};s(ze,"Main",new ze);var le=ze;var Ft=async n=>{try{let o=new URL(window.location.href),t=new URLSearchParams(o.search).get("myopOverride");if(t){let[r,...i]=Je(t);switch(r){case"component":{let[a,p]=i,m=await le.Main.fetchComponent(a);if(m&&m.type.skins.find(l=>l.id===p))return m.instance.skinSelector={type:W.Dedicated,skin:{id:p}},m}break;default:{let[a,p]=Je(t),d=(await le.Main.fetchFlow(a)).components.find(l=>l.type.id===n.type.id);if(d&&d.instance.skinSelector.type===W.Segmented&&d.instance.resolvedExperiences){let l=d.instance.resolvedExperiences.find(f=>f.id===p);if((l==null?void 0:l.type)===ue.Segment){let f=l,u=d.instance.skinSelector.segments.find(x=>x.segmentId===f.segment.id);if(u)return d.instance.skinSelector=u==null?void 0:u.skinSelector,d}}}break}}}finally{return null}};var $t="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",H=class{constructor(){s(this,"components2init",[]);s(this,"components",[]);s(this,"componentsLoaders",[]);s(this,"initiated",!1);s(this,"version",ve);s(this,"type2InstanceCount",{});s(this,"assignId",o=>(this.type2InstanceCount[o.id]||(this.type2InstanceCount[o.id]=0),"".concat(o.id,"_").concat(++this.type2InstanceCount[o.id])));s(this,"inspected",!1);s(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(o=>{o.inspect&&o.inspect()}))});s(this,"incomingMessageHandler",o=>{if(o.origin,document.location.origin,o.data.myop){if(o.data.direction!==b.up&&o.data.messageType!==c.EnvelopedMessage)return;let e=o.data;if(e.messageType===c.InitRequest){this.components2init.forEach(r=>{r.send(new j(r.id))});return}if(e.messageType===c.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===c.EnvelopedMessage){let r=e,i=this.components.find(a=>a.id===r.destination);if(i){if(r.direction===b.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)}}});s(this,"send",o=>{let e=new MessageEvent("",{data:o});this.incomingMessageHandler(e)});s(this,"init",o=>{if(this.initiated)throw new Error("hostSDK already initiated");let e=[new Se,new Re,new $e];if(this.componentsLoaders=[...e],o){let t={};o.forEach(r=>{let i=new r(this.componentsLoaders);t[i.type]=i}),this.componentsLoaders.forEach(r=>{t[r.type]||(t[r.type]=r)}),this.componentsLoaders=Object.values(t)}window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});s(this,"_getSkinIdBySkinSelector",async(o,e=[],t)=>{var i;async function r(a,p){for(let m of a)if(await p(m))return m}switch(o.type){case"DedicatedSkin":case W.Dedicated:return((i=o.skin)==null?void 0:i.id)||o.skins[0].id;case W.Segmented:{let p=await r(o.segments,async m=>{if(m.segmentId==="Default")return!0;let d=e.find(u=>u.type===ue.Segment?u.segment.id===m.segmentId:!1);if(!d)throw new Error("experience not found");let f=d.segment,g=(t||{})[f.function];return g?await g():(console.warn("segmentId:".concat(m.segmentId,", ").concat(f.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});s(this,"runSkinSelector",async(o,e)=>{let t=await this._getSkinIdBySkinSelector(o.instance.skinSelector,o.instance.resolvedExperiences,e);return o.type.skins.find(r=>r.id===t)});s(this,"loaderHooks");s(this,"loadComponent",async(o,e,t)=>{var l,f,g,u;if(!e){debugger;throw new Error("no container was found for this component")}let r=await Ft(o);r&&(o=r);let i=y(y({},(l=this.loaderHooks)!=null?l:{}),(f=t==null?void 0:t.hooks)!=null?f:{}),a=e;if(a.myop)if(a.component){o=y({},o),o.instance=y({},o.instance);let x=await this.runSkinSelector(o,i);if(!x)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(x=await t.hooks.afterSkinSelected(y({},x))),o.instance.skinSelector={type:W.Dedicated,skin:x},t&&(t=y({},t),delete t.hooks),await ct(a,o,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(o,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(u=t==null?void 0:t.hooks)!=null&&u.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(y({},p)));let m=this.componentsLoaders.find(x=>x.type===p.loader.type);if(!m){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let d=await m.load(o.type,p,e,t);d.isInitiated||this.components2init.push(d),d.bind("onDispose",()=>(this.components=this.components.filter(x=>x!==d),this.components2init=this.components2init.filter(x=>x!==d),!0)),this.components.push(d),(!t||t.connectProps!==!1)&&(d=Pt(d,o.type.props,p));try{await lt(d,o,this.components)}catch(x){throw x}return t!=null&&t.skipInit||await d.initiated(),d});s(this,"navigate",async(o,e,t)=>{if(o.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let r=await this.loadComponent(e,o.container,y({hidden:!0,relative:{direction:"after",child:o.element}},t));return t.init&&await t.init(r),r.show(),o.dispose(),r}else{let r=o.element.nextSibling;return o.dispose(),this.loadComponent(e,o.container,y({relative:{direction:"before",child:r}},t))}})}};s(H,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$t});if(!window.myop.hostSDK){let n=new H;n.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$t}),window.myop.hostSDK=n}var ao=window.myop.hostSDK;Z("hostSDK",ao);var Ue=class extends h{constructor(){super(...arguments);s(this,"messageType",c.CreateRefComponentMessage);s(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 d=a.refs[m];d=d.__nonProxied||d,d.componentDefinition&&p.push({refName:m,componentDefinitionId:d.componentDefinition.id})}),this.messageToHost(new D(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new D(e.handlerUniqueId,[],!0));debugger}})().then()})}};var zt=(n,o)=>{if(!n){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!n||n.nodeType!==1))if(e){let t=new e(o),r={attributes:!0,childList:!0,subtree:!0};return t.observe(n,r),t}else window.addEventListener&&(n.addEventListener("DOMNodeInserted",o,!1),n.addEventListener("DOMNodeRemoved",o,!1))};var Ne=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetMutationObserverMessage);s(this,"executor",e=>{e.source&&zt(document.body,()=>{this.messageToHost(new re)})})}};var Ut=n=>{if(!n)return null;if(n.tagName==="FORM"){let o=new FormData(n),e={formData:{},unmappedData:[]},t=n.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:Ut(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 n.type==="checkbox"||n.type==="radio"?n.checked?n.value:null:n.tagName==="INPUT"||n.tagName==="TEXTAREA"||n.tagName==="SELECT"?n.value:n.isContentEditable?n.innerText||n.textContent:null},qe=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetElementValueMessage);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{this.messageToHost(new z(Ut(r)),e)})})}};var We=class extends h{constructor(){super(...arguments);s(this,"messageType",c.GetAttributeMessage);s(this,"executor",e=>{let t=Ht(e.ref,document);t&&this.messageToHost(new se(t.getAttribute(e.name)),e)})}};var Ve=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetResizeObserverMessage);s(this,"executor",e=>{let t=new ResizeObserver(r=>{this.messageToHost(new me)});return t.observe(document.body),()=>{t.disconnect()}})}};var Ge=class extends h{constructor(){super(...arguments);s(this,"messageType",c.SetInnerHtml);s(this,"executor",e=>{I(e.ref,document).forEach(r=>{r.innerHTML=e.content})})}};var gt=class extends J{constructor(){super();s(this,"version",ve);s(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let r=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=r[0]),e.source||(e.source=r[0]),e.direction=b.up,(i=window.parent)==null||i.postMessage(y({},e),"*")});s(this,"supportedHandlers",[new Me(this.messageToHost),new Ge(this.messageToHost),new he(this.messageToHost),new ye(this.messageToHost),new Ce(this.messageToHost),new be(this.messageToHost),new Te(this.messageToHost),new qe(this.messageToHost),new Ne(this.messageToHost),new Ve(this.messageToHost),new We(this.messageToHost),new Ue(this.messageToHost)]);s(this,"init",()=>{window.onmessage=this.handleIncomeMessages.bind(this),this.messageToHost(new U)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Z("IframeSDK",gt);export{gt as IframeSDK};
|
|
@@ -676,7 +676,8 @@ var BaseMyopSDK = class {
|
|
|
676
676
|
var SkinLoaders = {
|
|
677
677
|
"IframeLoader": "IframeLoader",
|
|
678
678
|
"WebComponentLoader": "WebComponentLoader",
|
|
679
|
-
"HTMLLoader": "HTMLLoader"
|
|
679
|
+
"HTMLLoader": "HTMLLoader",
|
|
680
|
+
"MinimizedLoader": "MinimizedLoader"
|
|
680
681
|
};
|
|
681
682
|
var ShadowRootModeType = {
|
|
682
683
|
"open": "open",
|
|
@@ -1730,7 +1731,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
1730
1731
|
};
|
|
1731
1732
|
|
|
1732
1733
|
// version:myop-sdk-version
|
|
1733
|
-
var myop_sdk_version_default = "0.1.
|
|
1734
|
+
var myop_sdk_version_default = "0.1.46";
|
|
1734
1735
|
|
|
1735
1736
|
// src/webcomponent/messageHandlers/BaseWebComponentMessageHandler.ts
|
|
1736
1737
|
var BaseWebComponentMessageHandler = class extends BaseContextMessageHandler {
|
|
@@ -2124,10 +2125,7 @@ var HTMLComponentLoader = class extends BaseMyopLoader {
|
|
|
2124
2125
|
HTML2Render = _doc.documentElement.outerHTML;
|
|
2125
2126
|
}
|
|
2126
2127
|
doc.writeln(HTML2Render);
|
|
2127
|
-
doc.writeln('<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__, "
|
|
2128
|
-
// @ts-ignore
|
|
2129
|
-
window.__federation__
|
|
2130
|
-
), "};\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>"));
|
|
2128
|
+
doc.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>'));
|
|
2131
2129
|
doc.close();
|
|
2132
2130
|
const comp = new MyopIframeComponent(componentDefinition, skin, container, IframeElement, options);
|
|
2133
2131
|
if (loaderConfig.autoHeight) {
|