@myop/sdk 0.4.0-beta.0 → 0.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundled-declarations.d.ts +36 -0
- package/dist/cjs/_IframeSDK.8f08de4b.min.js +1 -0
- package/dist/cjs/{_IframeSDK.096d8320.js → _IframeSDK.a43cfa7d.js} +55 -4
- package/dist/cjs/_IframeSDK.a43cfa7d.js.map +7 -0
- package/dist/cjs/{_WebComponentSDK.e9e877db.js → _WebComponentSDK.0f6ef369.js} +6 -3
- package/dist/cjs/_WebComponentSDK.0f6ef369.js.map +7 -0
- package/dist/cjs/_WebComponentSDK.649e5e47.min.js +1 -0
- package/dist/cjs/_hostSDK.131fedc9.min.js +1 -0
- package/dist/cjs/{_hostSDK.0c271647.js → _hostSDK.38fcc5b4.js} +6 -3
- package/dist/cjs/_hostSDK.38fcc5b4.js.map +7 -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/cjs-bundled/myop_sdk.bundled.js +56 -5
- package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
- package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
- package/dist/module/Iframe/IframeSDK.d.ts +36 -0
- package/dist/module/Iframe/index.js +56 -5
- package/dist/module/Iframe/index.js.map +3 -3
- package/dist/module/SDK.js +56 -5
- package/dist/module/SDK.js.map +3 -3
- package/dist/module/embeddedSDK.js +1 -1
- package/dist/module/host/embeddedSDK.js +1 -1
- package/dist/module/host/index.js +7 -4
- package/dist/module/host/index.js.map +2 -2
- package/dist/module/webcomponent/index.js +7 -4
- package/dist/module/webcomponent/index.js.map +2 -2
- package/package.json +1 -1
- package/dist/cjs/_IframeSDK.096d8320.js.map +0 -7
- package/dist/cjs/_IframeSDK.8e791f92.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.4a87f826.min.js +0 -1
- package/dist/cjs/_WebComponentSDK.e9e877db.js.map +0 -7
- package/dist/cjs/_hostSDK.0c271647.js.map +0 -7
- package/dist/cjs/_hostSDK.7d759290.min.js +0 -1
|
@@ -1482,6 +1482,42 @@ declare module "@myop/sdk/Iframe/IframeSDK" {
|
|
|
1482
1482
|
constructor();
|
|
1483
1483
|
messageToHost: (message: MyopBindReplayMessage, replayTo?: MyopBindMessage) => void;
|
|
1484
1484
|
supportedHandlers: BaseMessageHandler[];
|
|
1485
|
+
/**
|
|
1486
|
+
* Announce this frame until the host answers, not once.
|
|
1487
|
+
*
|
|
1488
|
+
* The host only learns a component exists AFTER `await componentLoader.load(...)`
|
|
1489
|
+
* resolves (hostSDK.ts:433-437 — the line above it already calls this a race). A frame
|
|
1490
|
+
* that boots inside that await announces itself to a host whose components2init is
|
|
1491
|
+
* still empty: the host iterates nothing, sends no InitMessage, and a single-shot
|
|
1492
|
+
* announce leaves the frame waiting forever. The visible symptom is initiated()
|
|
1493
|
+
* rejecting with timeout_<ms>, with exactly one message on the wire -- InitRequest,
|
|
1494
|
+
* never InitResponse.
|
|
1495
|
+
*
|
|
1496
|
+
* Minification made it common rather than rare: a smaller payload boots the frame
|
|
1497
|
+
* sooner, landing it deeper inside the window. Reported by a customer 2026-10-17.
|
|
1498
|
+
*
|
|
1499
|
+
* Re-announcing is safe and idempotent. The host replies to InitRequest by sending
|
|
1500
|
+
* InitMessage to every component still awaiting init; a frame that has already
|
|
1501
|
+
* registered that id ignores the repeat (BaseMyopSDK: `if (this.components[id]) return`).
|
|
1502
|
+
* So a late answer costs one extra round trip and nothing else.
|
|
1503
|
+
*
|
|
1504
|
+
* Backs off 50ms -> 1s and stops the moment any component registers, so the common
|
|
1505
|
+
* case sends exactly one message.
|
|
1506
|
+
*
|
|
1507
|
+
* THE CAP IS A CONSTANT, and it should ideally be the host's own `options.timeout`
|
|
1508
|
+
* so the frame never gives up before the host does. That was tried on 2026-10-17 and
|
|
1509
|
+
* REVERTED: the budget has to reach the frame through the init script that
|
|
1510
|
+
* HTMLComponentLoader generates, and `${...}` interpolated into that template does
|
|
1511
|
+
* not survive the build -- the transpiled `.concat()` leaks into the emitted script
|
|
1512
|
+
* as literal text, the frame parses no number, and it silently falls back to the
|
|
1513
|
+
* default. It looked correct in source and in the bundle, and only the e2e caught it.
|
|
1514
|
+
*
|
|
1515
|
+
* 10s is chosen to exceed BaseMyopComponent's 5s default, so the frame outlives the
|
|
1516
|
+
* common host deadline. This only matters in the pathological case: with the host now
|
|
1517
|
+
* sending InitMessage on registration (hostSDK.ts), the retry is a backstop that in
|
|
1518
|
+
* practice never fires.
|
|
1519
|
+
*/
|
|
1520
|
+
private announceUntilAnswered;
|
|
1485
1521
|
init: () => void;
|
|
1486
1522
|
}
|
|
1487
1523
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var dn=Object.defineProperty,Xn=Object.defineProperties;var Zn=Object.getOwnPropertyDescriptors;var pn=Object.getOwnPropertySymbols;var eo=Object.prototype.hasOwnProperty,to=Object.prototype.propertyIsEnumerable;var St=(o,n,e)=>n in o?dn(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))eo.call(n,e)&&St(o,e,n[e]);if(pn)for(var e of pn(n))to.call(n,e)&&St(o,e,n[e]);return o},z=(o,n)=>Xn(o,Zn(n));var no=(o,n)=>{for(var e in n)dn(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>St(o,typeof n!="symbol"?n+"":n,e);var fe=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var cn=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},M=class{constructor(n){this.messageToHost=n}},Fe=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var y={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 Ke={};no(Ke,{AddEventListenerMessage:()=>Ht,BaseMyopMessage:()=>C,BindClickMessage:()=>_t,ChangeTextMessage:()=>Rt,CleanupMessage:()=>_e,CleanupReplayMessage:()=>Re,ClickReplayMessage:()=>Q,CreateRefComponentMessage:()=>ve,CustomRefMessage:()=>X,DetectMyopRefsMessage:()=>Lt,DetectedMyopRefsMessage:()=>oe,DisposeMessage:()=>He,ElementValueReplayMessage:()=>ee,EnvelopedMessage:()=>Se,EventListenerCallbackMessage:()=>Z,ExecuteComponentMethod:()=>O,ExecuteScriptMessage:()=>B,ExecuteScriptReplyMessage:()=>J,GetAttributeMessage:()=>Pt,GetAttributeReplayMessage:()=>Ee,GetElementValueMessage:()=>Dt,InitMessage:()=>te,InitRequest:()=>ne,InitResponse:()=>xe,MessageDirection:()=>v,MutationObserverMessage:()=>Te,MyopBindMessage:()=>E,MyopBindReplayMessage:()=>S,MyopElementMessage:()=>Tt,Ref:()=>j,RefComponentCreatedMessage:()=>N,ResizeObserverMessage:()=>De,SetAttributeMessage:()=>kt,SetInnerHtml:()=>Bt,SetMutationObserverMessage:()=>Ot,SetResizeObserverMessage:()=>ke,stripFunction:()=>un});var D=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var oo=o=>{let n=[...o].map(e=>e.toString(16).padStart(2,"0")).join("");return[n.slice(0,8),n.slice(8,12),n.slice(12,16),n.slice(16,20),n.slice(20)].join("-")};var so=o=>{let n=o.replace(/-/g,"+").replace(/_/g,"/");for(;n.length%4;)n+="=";let e=atob(n);return Uint8Array.from(e,t=>t.charCodeAt(0))};var Et=o=>{let n=so(o);if(n.length%16!==0)throw new Error("Invalid input length");let e=[];for(let t=0;t<n.length;t+=16)e.push(oo(n.slice(t,t+16)));return e};var ln=o=>new Promise(n=>setTimeout(n,o));var v=class{};r(v,"down","down"),r(v,"up","up");var C=class{constructor(){r(this,"id",D());r(this,"myop",!0);r(this,"content");r(this,"source");r(this,"destination");r(this,"route");r(this,"ref");r(this,"direction");r(this,"cleanable",!1)}static create(...n){return new this(...n)}isTypeof(n){return n.messageType===this.messageType}},Tt=class extends C{constructor(e){super();this.ref=e}},S=class extends C{constructor(e){super();this.replayToHandler=e}},E=class extends C{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",D())}},j=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=z(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var mn="ClickReplayMessage",_t=class extends E{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",mn);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},Q=class extends S{constructor(){super(...arguments);r(this,"messageType",mn)}};var Rt=class extends C{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var fn="ExecuteScriptReplyMessage",io=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,ro=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,un=o=>{let n=o.match(io);if(n)return n[1]||n[3];{let e=o.match(ro);if(e)return e[1].trim()}},B=class extends E{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",fn);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=un(this.content)}};r(B,"replierKey","send"),r(B,"completeStreamKey","completeStream");var J=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",fn)}};var X=class extends B{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=z(h({},t),{_script:e.toString()})}};var gn="EventListenerCallbackMessage",Ht=class extends E{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",gn);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},Z=class extends S{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",gn);this.content={e:t}}};var kt=class extends C{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var yn="ElementValueReplayMessage",Dt=class extends E{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",yn);r(this,"messageType","GetElementValueMessage")}},ee=class extends S{constructor(e){super();this.content=e;r(this,"messageType",yn)}};var Bt=class extends C{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var te=class extends C{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},xe=class extends te{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},ne=class extends C{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var hn="RefComponentCreatedMessage",ve=class extends E{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",hn);r(this,"messageType","CreateRefComponentMessage")}},N=class extends S{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",hn)}};var Se=class extends C{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var Mn="DetectedMyopRefsMessage",Lt=class extends E{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",Mn)}},oe=class extends S{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",Mn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var Cn="GetAttributeReplayMessage",Pt=class extends E{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",Cn);r(this,"messageType","GetAttributeMessage")}},Ee=class extends S{constructor(e){super();this.content=e;r(this,"messageType",Cn)}};var O=class extends C{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ot=class extends C{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},Te=class extends C{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var bn="CleanupReplayMessage",_e=class extends E{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",bn);r(this,"messageType","CleanupMessage")}},Re=class extends S{constructor(e){super();this.customCleanup=e;r(this,"messageType",bn)}};var He=class extends C{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ke=class extends C{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},De=class extends C{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var zt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},ue=class{constructor(){r(this,"messageToHandleAfterInit",[]);r(this,"components",{});r(this,"alwaysPassEnvelopesToHost",!1);r(this,"messageCleanupCache",{})}handleIncomeMessages(n){let e=n.data?n.data:n.detail;if(!(!e||!e.myop)){let t=e;if(t.direction!==v.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new zt(s),this.messageToHost(new xe(s));return}if(t.messageType===y.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new Re(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],cn(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var U={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var se={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var he={message:"message",code:"code"},ge=class{};r(ge,"code","code"),r(ge,"component","component");var ie={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},We={Segment:"Segment",Promo:"Promo",AB:"AB"},ye=class{constructor(n,e){this.container=n;this.shadowRoot=e;r(this,"getRootDiv",()=>(this.shadowRoot||this.container).querySelector("div"));r(this,"getRoot",()=>this.shadowRoot||this.container)}};var R={id:"myop-id"};var Ne=class extends M{constructor(){super(...arguments);r(this,"messageType",y.DetectMyopRefsMessage);r(this,"executor",e=>{let t=document.querySelectorAll("[".concat(R.id,"]")),s=[];t.forEach(i=>{let a=i.getAttribute(R.id);a&&s.push(new fe(a,i.tagName,i.getBoundingClientRect()))}),this.messageToHost(new oe(e.handlerUniqueId,s))})}};var I=(o,n)=>n.querySelectorAll("[".concat(R.id,"='").concat(o.refConfig.selector,"']")),In=(o,n)=>{let e=I(o,n);return e.length?e.item(0):null};var Ue=class extends M{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"executor",e=>{let t=[];return I(e.ref,document).forEach(i=>{let a=()=>{this.messageToHost(new Q,e)};i.addEventListener("click",a);let p=()=>{i.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(i=>i())}})}};var qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.textContent=e.content})})}};var At=o=>o!==Object(o),ao=o=>typeof o=="function",$t=o=>{if(At(o))return!0;if(ao(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!$t(e))return!1}else{if(At(e))continue;return!1}}return!0},L=(o,n={},e=!0,t=new WeakMap)=>{if(At(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=L(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=L(o[i],!0,e,t)):typeof a=="object"&&(s[i]=L(o[i],a,e,t)))}return s}return{}};var Ve=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=L,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var je=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"executor",e=>{Ve(e,s=>{this.messageToHost(new J(e.handlerUniqueId,s))},new ye(document.documentElement))})}};var Ge="__federation__",wn="onLoad";var Me=(o,n)=>{window[Ge]&&window[Ge][o]&&window[Ge][o][wn]&&window[Ge][o][wn]({[o]:n})};var Ye=class extends M{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"executor",e=>{let t=I(e.ref,document),s=[];return t.forEach(i=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new Z(e.handlerUniqueId,L(p,e.serializableSkeleton)))})};i.addEventListener(e.type,a),s.push(()=>{i.removeEventListener(e.type,a)})}),()=>{s.forEach(i=>{i()})}})}};var Qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.setAttribute(e.name,e.value)})})}};var F=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||K.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===y.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=v.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=v.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new _e(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new He);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var xn={notSerializableRefCall:(o,n)=>{throw new Error("\nThe input provided to '".concat(o.toString(),"' is not serializable. Serialization is required to ensure that the data can be safely transferred to the skin implementation. \nThe following types of data are considered non-serializable and cannot be processed:\n\n- Functions\n- DOM elements\n- Class instances\n- Circular references\n- Symbols\n- BigInt values\n\nIn the following execution we detected :\n~~~~~~~~\n").concat(n," \n~~~~~~~~\nas not serializable.\n\nTo resolve this issue, please ensure that all inputs passed to '").concat(o.toString(),"' are in a serializable format.\nThis typically includes primitive types (strings, numbers, booleans), arrays, and plain objects. \nIf you need to include complex data types, consider converting them to a serializable structure before passing them to the function.\nOr use Myop message that support it: CustomRefMessage, AddEventListenerMessage or ExecuteScriptMessage.\n\nSuggested Fix:\n1. Remove or replace non-serializable values from your input.\n2. If using objects, ensure they do not contain any functions or circular references.\n3. Convert any class instances to plain objects or JSON-compatible formats.\n4. Use dedicated Myop message.\n\nFor more details on serialization and Myop message examples, refer to https://docs.myop.dev.\n\n"))}};var Be=class extends F{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new Se(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new O("dispose")),super.dispose()})}hide(){this.send(new O("hide"))}show(){this.send(new O("show"))}inspect(){return this.send(new O("inspect"))}setHeightBasedOnDocumentElement(){this.send(new O("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new O("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var re=class extends F{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",e=>{let t=e.detail;t!=null&&t.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}))});r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=Ce(this.id,"MyopExtractedWebComponent",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=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}};var po=(o,n,e)=>{let t=document.createElement("a");return t.textContent=o,t.style.position="relative",t.style.padding="0 5px",t.style.fontSize="14px",t.style.top="0",t.style.top="".concat(n,"px"),t.style.transform="translateX(-50%)",t.target="_blank",t.href="https://dashboard.myop.dev/dashboard/component/".concat(e.id),t},Ce=(o,n,e,t,s,i)=>{let a=po("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},vn=(o,n,e)=>o?!1:(console.error("Error: Undefined Prop\n\nIt looks like you've tried to use a prop that hasn't been defined.\nPlease check the prop name for any typos or ensure that it is properly defined in the component's prop list.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide.")),!0),Sn=(o,n,e)=>{console.error("Error: Code Prop Not Supported\n\nCurrently, code props are only supported in local frame components.\n\u26A0\uFE0F This is a work in progress feature \u2014 code props will be supported in upcoming versions.\n\nIn the meantime, you can use message props.\n\n"+"Prop Name: ".concat(n,"\n")+"Component: ".concat(e.componentDefinition.name,", ID: ").concat(e.componentDefinition.id,"\n\n")+"For more information, refer to the component page https://dashboard.myop.dev/dashboard/component/".concat(e.componentDefinition.id," or consult the developer guide."))},En=(o,n,e)=>{let t=n.reduce((i,a)=>z(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(vn(p,a,o))return!1;if(p.behavior.type===he.code){if(o instanceof re)return(p.behavior.remap||a)==="myop_init_interface"?u=>{if(u===void 0)return o.getData();o.initWithData(u)}:void 0;if(o instanceof q&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?u=>{if(u===void 0)return o.getData();o.initWithData(u)}:void 0;if(e.loader.type===U.HTMLLoader&&e.loader.shadowRootMode===se.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return Sn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(j.create(p.behavior.ref)),c.push(m=>{d(m)}),p.behavior.params&&c.push(...p.behavior.params);let u=Ke[p.behavior.message];o.send(new u(...c))}):null},set:(i,a,p)=>{let d=t[a];if(vn(d,a,o))return!1;if(d.behavior.type===he.code){if(o instanceof re){let u=d.behavior.remap||a;if(u==="myop_cta_handler")return o.setCtaHandler(p),!0;if(u==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof q&&o.isolated){let u=d.behavior.remap||a;if(u==="myop_cta_handler")return o.setCtaHandler(p),!0;if(u==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===U.HTMLLoader&&e.loader.shadowRootMode===se.localFrame){let u=d.behavior,m=o.element.contentWindow,g=u.remap||a;if(m[g]=p,g==="myop_cta_handler"&&m.__myop_cta_queue){let f=m.__myop_cta_queue;m.__myop_cta_queue=null,f.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return Sn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(j.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let u=Ke[d.behavior.message];return o.send(new u(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},co=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{$t(p)||xn.notSerializableRefCall(t,p)}),n.send(new X(({ref:p,propName:d,functionArgs:c,makeSerializable:u})=>{if(p){let m=p[d];return u(typeof m=="function"?p[d](...c):m,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new X(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),Ft=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new Be(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new ve(o.refConfig,n,z(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let u=e.find(m=>m.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,i(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(m=>{let g=n.instance.resolvedNestedComponents.find(l=>l.type.id===m.componentDefinitionId).type,f=new Be(g,p);f.setInitiated(),p.refs[m.refName]=f,e.push(f)});try{await Kt(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(m){a(m)}}))})},Kt=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==ge.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let u=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=j.create("",i,o);try{let g=await Ft(m,u,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let c=j.create("",i,o);o.refs[i.name]=co(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(i){throw i}};var q=class extends F{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"isolated",!1);r(this,"_lastData");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_isoMsgHandler");r(this,"_isoSizeOpts");r(this,"_isoAutoSize",!1);r(this,"_isoLastSize");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new B(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new B(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this.isolated)return this._isoSizeOpts=e,this._isoAutoSize=!0,this._isoLastSize&&this._applyIsoSize(this._isoLastSize.height,this._isoLastSize.width),()=>{this._isoAutoSize=!1,this._isoSizeOpts=void 0};if(this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return this.observeHeightViaBridge();let i=(f,l,H)=>l!==void 0&&f<l?l:H!==void 0&&f>H?H:f,a=f=>{if(f===void 0)return;if(typeof f=="number")return f;let l=parseFloat(f);return isNaN(l)?void 0:l},p=()=>{var Jt,Xt,Zt,en,tn,nn,on,sn;let f=t.contentDocument;if(!f)return;let l=this._autoSizeOptions,H=a(l==null?void 0:l.minWidth),k=a(l==null?void 0:l.maxWidth),V=a(l==null?void 0:l.minHeight),T=a(l==null?void 0:l.maxHeight),pe=(Jt=l==null?void 0:l.loaderMinHeight)!=null?Jt:50,Y=((Xt=this.sizeMeta)==null?void 0:Xt.width)==="100%"?"100%":void 0,P=((Zt=this.sizeMeta)==null?void 0:Zt.height)==="100%"?"100%":void 0,w=(tn=(en=l==null?void 0:l.explicitWidth)!=null?en:Y)!=null?tn:"100%",b=(nn=l==null?void 0:l.explicitHeight)!=null?nn:P,_=w!==void 0,de=b!==void 0,ce=this.container.getBoundingClientRect(),Wn=ce.width===0,Nn=ce.height===0||ce.height===pe,le=(l!=null&&l.forceAutoSize||Wn)&&!_,me=(l!=null&&l.forceAutoSize||Nn)&&!de;if(!le&&!me){t.style.width=typeof w=="number"?"".concat(w,"px"):"100%",t.style.height=typeof b=="number"?"".concat(b,"px"):"100%",(on=l==null?void 0:l.onSizeChange)==null||on.call(l,{width:typeof w=="number"?w:void 0,height:typeof b=="number"?b:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Un=t.style.transition,W=this.container,qn=W.style.transition;t.style.transition="none",W.style.transition="none";let qt=t.getBoundingClientRect().height,Vt=t.getBoundingClientRect().width,jt=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height)),Gt=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),Ie=Gt,we=jt,Vn=me&&jt>qt+1,jn=le&&Gt>Vt+1,ze=me&&!Vn,Ae=le&&!jn;if(ze||Ae){let Qn=W.style.minHeight,Jn=W.style.minWidth;ze&&(W.style.minHeight="".concat(qt,"px")),Ae&&(W.style.minWidth="".concat(Vt,"px")),ze&&(t.style.height="0px"),Ae&&(t.style.width="0px"),Ie=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),we=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height));let rn=ze&&we<2,an=Ae&&Ie<2;if(rn||an){let $e=f.createElement("style");$e.id="__myop_measure";let vt=[];rn&&vt.push("height: auto !important","min-height: 0 !important","max-height: none !important"),an&&vt.push("width: auto !important","min-width: 0 !important","max-width: none !important"),$e.textContent="*, *::before, *::after { ".concat(vt.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),f.head.appendChild($e),Ie=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),we=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height)),$e.remove()}W.style.minHeight=Qn,W.style.minWidth=Jn}let Yt=i(Ie,H,k),Qt=i(we,V,T);le?t.style.width="".concat(Yt,"px"):t.style.width=typeof w=="number"?"".concat(w,"px"):"100%",me?t.style.height="".concat(Qt,"px"):t.style.height=typeof b=="number"?"".concat(b,"px"):"100%",t.offsetHeight,t.style.transition=Un,W.style.transition=qn;let Gn=le&&k!==void 0&&Ie>k,Yn=me&&T!==void 0&&we>T;f.documentElement.style.overflowX=Gn?"auto":"",f.documentElement.style.overflowY=Yn?"auto":"",(sn=l==null?void 0:l.onSizeChange)==null||sn.call(l,{width:Yt,height:Qt,autoSizingWidth:le,autoSizingHeight:me})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},u=new ResizeObserver(()=>c());u.observe(s.body),u.observe(s.documentElement);let m=new MutationObserver(()=>c());m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let g=()=>{u.disconnect(),m.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=g,g});r(this,"_bridgeSizeCleanup");r(this,"observeHeightViaBridge",()=>{if(this._bridgeSizeCleanup)return this._bridgeSizeCleanup;let e,t=!1,s=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=s,this.initiated().then(()=>{t||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),e=this.send(new ke))}).catch(i=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(i))}),s});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new B(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new B(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=v.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{var e;(e=this._bridgeSizeCleanup)==null||e.call(this),this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this._isoMsgHandler&&(window.removeEventListener("message",this._isoMsgHandler),this._isoMsgHandler=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=e=>{if(e.source!==this.IframeElement.contentWindow)return;let t=e.data;!t||t.__myop!==!0||(t.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}):t.type==="myop:size"&&this._applyIsoSize(t.height,t.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(e){var t,s;this._lastData=e,(s=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||s.postMessage({__myop:!0,type:"myop:init",data:e},"*")}getData(){return this._lastData}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let s=this._isoSizeOpts,i=u=>u===void 0?void 0:typeof u=="number"?u:isNaN(parseFloat(u))?void 0:parseFloat(u),a=i(s==null?void 0:s.minHeight),p=i(s==null?void 0:s.maxHeight),d=e;a!==void 0&&d<a&&(d=a),p!==void 0&&d>p&&(d=p),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=d+"px",this.IframeElement.style.width="100%",(c=s==null?void 0:s.onSizeChange)==null||c.call(s,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=Ce(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===y.In.MutationObserverMessage||e.messageType===y.In.ResizeObserverMessage?(this.setHeightBasedOnScrollHeight(),!0):super.onMessageReceived(e)}};var G=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var lo=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},Je=class extends G{constructor(){super(...arguments);r(this,"type",U.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=D(),u="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=u;let m="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=m,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([f,l])=>{l===""||l===null||l===void 0?a.setAttribute(f,""):a.setAttribute(f,String(l))});let g=t.loader.url;i!=null&&i._hasParent&&(g=lo(g,"_myop-comp",c)),a.src=g,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}let d=new q(e,t,s,a,i);return p.autoHeight&&(i==null?void 0:i.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var Xe={webcomponent_message_key:"myop_webcomponent_message"};var be=class extends F{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent(Xe.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=Ce(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 Wt={},Ze=class extends G{constructor(){super(...arguments);r(this,"type",U.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;Wt[a.url]?console.log("Module alreday loaded or in loading process"):Wt[a.url]=new Promise((c,u)=>{let m=a.url,g=document.createElement("script");g.type="module",g.src=m,g.onload=()=>{c()},g.onerror=()=>{u()},document.head.appendChild(g)}),await Wt[a.url],await ln(1);let p="myop-comp-".concat(D()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new be(e,t,s,d,i)})}};var et="0.4.0-beta.2";var mo="myop-delivery",ot="components";var tt=null;function fo(){return tt||(tt=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(mo,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(ot)||e.createObjectStore(ot,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),tt)}function nt(o,n){return fo().then(e=>new Promise(t=>{if(!e)return t(null);try{let s=e.transaction(ot,o),i=n(s.objectStore(ot));i.onsuccess=()=>t(i.result),i.onerror=()=>t(null),s.onabort=()=>t(null)}catch(s){t(null)}}))}var Nt="myop.d.";function Tn(o,n,e){try{localStorage.setItem(Nt+o,JSON.stringify({t:n,e}))}catch(t){}}function uo(o){try{localStorage.removeItem(Nt+o)}catch(n){}}var Le=new Map,A={key(o,n,e,t,s){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(s||"raw")},async get(o){let n=Le.get(o);if(n)return n;let e=await nt("readonly",t=>t.get(o));return e&&(Le.set(o,e),Tn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){Le.set(o.key,o),Tn(o.key,o.tag,o.storedAt+o.windowMs),await nt("readwrite",n=>n.put(o))},async drop(o){Le.delete(o),uo(o),await nt("readwrite",n=>n.delete(o))},fresh(o){return!!o&&Date.now()-o.storedAt<o.windowMs},windowFrom(o){let n=o.get("cache-control")||"";if(/no-store|no-cache/i.test(n))return 0;let e=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!e)return 0;let t=Number(e[1]),s=Number(o.get("age")||0);return Math.max(0,t-(isNaN(s)?0:s))*1e3},async clear(){Le.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Nt)&&localStorage.removeItem(n)}}catch(o){}await nt("readwrite",o=>o.clear())}};var _n=o=>({instance:{id:"auto",componentId:o.componentId,componentName:o.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:o.id,name:o.name,description:o.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:he.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:he.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),st="__MYOP_CLOUD_REPOSITORY_MAIN__",go=()=>{if(typeof window<"u")return window[st];if(typeof globalThis<"u")return globalThis[st]},yo=o=>{typeof window<"u"&&(window[st]=o),typeof globalThis<"u"&&(globalThis[st]=o)},$=class ${constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"preloadedComponents",{});r(this,"userFlows",{});r(this,"_defaultEnv","production");r(this,"_envExplicitlySet",!1);r(this,"_staticMode",!1);r(this,"_queryParams",{});r(this,"_delivery",{minify:!1,host:null,cache:!1});r(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});r(this,"_localServes",new Map);r(this,"_flushBound",!1)}static get Main(){let n=go();return n||($._main||($._main=new $,yo($._main)),$._main)}static sizeOfHeld(n){var e,t,s,i,a;try{return(((a=(i=(s=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:s[0])==null?void 0:i.loader)==null?void 0:a.HTML)||"").length}catch(p){return 0}}setDelivery(n={}){n.minify!==void 0&&(this._delivery.minify=!!n.minify),n.host!==void 0&&(this._delivery.host=n.host),n.cache!==void 0&&(this._delivery.cache=!!n.cache)}deliveryStats(){var n;return z(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:$.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache})}async refreshDelivery(){await A.clear()}noteLocalServe(n,e){let t=this._localServes.get(n);t?t.count++:this._localServes.set(n,{env:e,count:1}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let n=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",n),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let n=[...this._localServes.entries()].map(([e,t])=>"".concat(e,":").concat(t.env,":").concat(t.count)).join(",");this._localServes.clear();try{let e="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(e,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(e){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var i;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let s=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!s)return s&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!s)throw a;this._deliveryStats.lastError=String((i=a==null?void 0:a.message)!=null?i:a)}return this._deliveryStats.fellBack++,console.warn("[myop] delivery host failed (".concat(this._deliveryStats.lastError,") \u2014 falling back to ").concat(this._baseUrl)),await fetch("".concat(this._baseUrl).concat(n))}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,e,t){return this.fetchComponentV2(n,e,t)}async fetchComponentV2(n,e,t){let{env:s,usePreview:i,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:s,usePreview:i,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:s,preview:i}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let V=i?"preview":s;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(V,".json");let T=new URLSearchParams(this._queryParams).toString();T&&(c+="?".concat(T))}else c="/consume?id=".concat(n,"&env=").concat(s),i&&(c+="&preview=true"),this._delivery.minify&&!i&&(c+="&opt=min");let u=this._delivery.cache&&!this._staticMode&&!i,m=u?A.key(this.deliveryHost(),n,s,i,this._delivery.minify?"min":"raw"):"",g=u?await A.get(m):null;if(g&&A.fresh(g)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,s),this.variants[a].resolved=g.config,p(g.config);return}if(g&&g.tag){let V="/consume?ids=".concat(n,"&env=").concat(s)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(g.tag));this._deliveryStats.revalidations++;try{let T=await this.deliveryFetch(V);if(T.ok){let pe=await T.json();if((pe.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=$.sizeOfHeld(g),g.storedAt=Date.now(),g.windowMs=A.windowFrom(T.headers)||g.windowMs,await A.put(g),this.variants[a].resolved=g.config,p(g.config);return}let Y=(pe.items||[])[0];if(Y){let P=_n(Y);this._deliveryStats.fromNetwork++,await A.put({key:m,config:P,tag:Y.tag||null,storedAt:Date.now(),windowMs:A.windowFrom(T.headers),host:this.deliveryHost()}),this.variants[a].resolved=P,p(P);return}}}catch(T){}}let f=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!f.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(f.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let H=(await f.json()).item;if(!H){d(new Error('Component "'.concat(n,'" not found')));return}if(!H.consume_variant||!H.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let k=_n(H);this._deliveryStats.fromNetwork++,u&&await A.put({key:m,config:k,tag:H.tag||null,storedAt:Date.now(),windowMs:A.windowFrom(f.headers),host:this.deliveryHost()}),this.variants[a].resolved=k,p(k)}catch(c){delete this.variants[a],d(c)}})),await this.variants[a]}getResolvedConfig(n,e,t){var i;let{cacheKey:s}=this.resolveParams(n,e,t);return((i=this.variants[s])==null?void 0:i.resolved)||null}resolveParams(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let d=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!d}return{env:a,usePreview:p,cacheKey:"".concat(n,":").concat(a,":").concat(p?"preview":"live")}}hydrateComponent(n,e,t,s){let{env:i,usePreview:a,cacheKey:p}=this.resolveParams(n,t,s),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:i,preview:a}}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r($,"_main",null),r($,"DEFAULT_HOST","https://cloud.myop.dev");var ae=$;var it=ae.Main;var ho="https://delivery.myop.dev",Rn=(o={})=>{var e,t;let n=o.minify!==!1||o.cache===!0;return it.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,host:o.host!==void 0?o.host:n?ho:null}),Pe()},Hn=async()=>(await it.refreshDelivery(),Pe()),Pe=()=>it.deliveryStats(),kn=()=>(it.setDelivery({minify:!1,cache:!1,host:null}),Pe());var x=class extends Fe{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(z(h({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var rt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new Q(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var at=class extends x{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var pt=class extends ye{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var dt=class extends x{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(R.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(R.id);p&&i.push(new fe(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new oe(e.handlerUniqueId,i))});r(this,"messageType",y.DetectMyopRefsMessage)}};var ct=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var lt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=I(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{s(new Z(e.handlerUniqueId,L(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var mt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(R.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=K.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let u=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),m=[];Object.keys(u.refs).forEach(g=>{let f=u.refs[g];f=f.__nonProxied||f,f.componentDefinition&&m.push({refName:g,componentDefinitionId:f.componentDefinition.id})}),s(new N(e.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new N(e.handlerUniqueId,[],!0));debugger}})().then()})}};var ft=class extends x{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{Ve(e,a=>{s(new J(e.handlerUniqueId,a))},t)})}};var Dn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(R.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Dn(i),required:i.required,validity:L(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},ut=class extends x{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{I(e.ref,t.shadowRoot).forEach(a=>{s(new ee(Dn(a)),e)})})}};var gt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{I(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Oe=class extends ue{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Xe.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===y.InitMessage){let p=a.content.id;this.components[p].context=new pt(e,t)}}}),setTimeout(()=>{this.messageToHost(new ne)},1)});r(this,"messageToHost",(e,t)=>{e.direction=v.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new at(this.messageToHost,this.components),new gt(this.messageToHost,this.components),new rt(this.messageToHost,this.components),new dt(this.messageToHost,this.components),new ct(this.messageToHost,this.components),new lt(this.messageToHost,this.components),new ft(this.messageToHost,this.components),new ut(this.messageToHost,this.components),new mt(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Me("WebComponentSDK",Oe);var Bn="";var Mo="<!-- myop-web-component -->",Co="myop-web-component",Pn=new Map,On=[],yt,zn=async()=>(yt||(yt=new Oe,yt.init()),yt);function bo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===se.open?"open":"closed",t=this.attachShadow({mode:e});zn().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var Io=(o,n,e)=>{customElements.define(o,bo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},wo=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),xo=o=>(o=wo(o),o.replace(/_/g,"-"));var ht=class extends G{constructor(){super(...arguments);r(this,"type",U.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,i);if(d===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(p){if(d!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(e.id,'"'));return this.loadExtractedWebComponent(e,t,s,a.HTML,i)}let u="myop-comp-".concat(D()),m;if(a.shadowRootMode===se.localFrame){let g=D(),f="myop-comp-".concat(g),l=document.createElement("iframe");l.id=f,c&&l.setAttribute("sandbox","allow-scripts allow-forms allow-popups"),l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let H=[],k=c?{open(){},writeln(w){H.push(w)},close(){l.srcdoc=H.join("\n")}}:(()=>{let w=l.contentDocument||l.contentWindow.document;return w.open(),w})(),V=null;{let _=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(_)try{V=JSON.parse(_.getAttribute("content")||"{}")}catch(de){}}let T=a.HTML;if(i!=null&&i._inspection){let b=new DOMParser().parseFromString(a.HTML,"text/html"),_=b.getElementById("myop_preview");_==null||_.removeAttribute("type");let de=b.implementation.createHTMLDocument();de.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let ce=de.body.firstChild;ce&&b.head&&b.head.insertBefore(b.importNode(ce,!0),b.head.firstChild),T="<!DOCTYPE html>"+b.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let b=new DOMParser().parseFromString(a.HTML,"text/html"),_=b.getElementById("myop_preview");_&&(_.remove(),T="<!DOCTYPE html>"+b.documentElement.outerHTML)}if(i!=null&&i.injectCss){let b=new DOMParser().parseFromString(T,"text/html"),_=b.createElement("style");_.setAttribute("data-myop-injected","true"),_.textContent=i.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(b.head||b.documentElement).appendChild(_),T="<!DOCTYPE html>"+b.documentElement.outerHTML}k.writeln(T);let pe='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),Y="<script>\n window.__federation__.__public_path__ = window.__federation__.__public_path__;\n const __myop_init = async () => {\n const {IframeSDK} = (await window.myop.rootSDK.getIframeModule());\n const sdk = new IframeSDK();\n sdk.init();\n }\n __myop_init().then();\n <\/script>";if(c||k.writeln("".concat(pe).concat(Y)),!c&&(i==null?void 0:i.data)!==void 0){let w="<script>\n window.__myop_cta_queue = [];\n window.myop_cta_handler = function(action, payload) {\n window.__myop_cta_queue.push({action: action, payload: payload});\n };\n <\/script>",b=JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"),_='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(b,";\n var scriptEl = document.getElementById('__myop_init_data_script');\n\n var callInitInterface = function(fn) {\n var startTime = performance.now();\n // Mark as pre-injected data call for extension tracking\n window.__myop_init_preinjected = true;\n try {\n fn(data);\n } finally {\n window.__myop_init_preinjected = false;\n }\n var duration = performance.now() - startTime;\n\n // Notify extension via postMessage (init* = pre-injected)\n try {\n window.parent.postMessage({\n type: 'MYOP_PREINJECTED_INIT',\n payload: {\n data: data,\n duration: duration,\n timestamp: Date.now()\n }\n }, '*');\n } catch (e) {}\n\n // Cleanup: remove script tag and stored data\n if (scriptEl && scriptEl.parentNode) {\n scriptEl.parentNode.removeChild(scriptEl);\n }\n delete window.__myop_init_data;\n };\n\n if (typeof window.myop_init_interface === 'function') {\n // Function already exists - call immediately\n callInitInterface(window.myop_init_interface);\n } else {\n // Function not yet defined - store data and watch for definition\n window.__myop_init_data = data;\n\n var _original;\n Object.defineProperty(window, 'myop_init_interface', {\n configurable: true,\n enumerable: true,\n set: function(fn) {\n _original = fn;\n if (window.__myop_init_data !== undefined) {\n var storedData = window.__myop_init_data;\n delete window.__myop_init_data;\n callInitInterface(fn);\n }\n },\n get: function() {\n return _original;\n }\n });\n }\n })();\n <\/script>");k.writeln(w+_)}if(c){let w=(i==null?void 0:i.data)!==void 0?JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";k.writeln(this.buildIsolationBridge(w))}k.close();let P=new q(e,t,s,l,i);return c&&P.enableIsolation(),P.sizeMeta=V,P.initiated().then(()=>{if((i==null?void 0:i.autoSize)===!1)return;let w=!1;P.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!w&&!(i!=null&&i.hidden)&&(w=!0,P.show())}})}),P}if(a.shadowRootMode===se.none){let g=document.createElement("template");g.innerHTML=a.HTML,m=g.content.firstElementChild,zn().then(f=>{f.connectedCallback(m,m)})}else{let g=xo(e.name+t.id);On.includes(g)||(Io(g,a.HTML,a.shadowRootMode),On.push(g)),m=document.createElement(g)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),m.id=u,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(s,m,i),new be(e,t,s,m,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(Mo)}async resolveRenderMode(e,t,s,i,a){var u,m,g,f;let p=i?"webComponent":s.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(f=a==null?void 0:a.renderPolicy)!=null?f:(g=(m=(u=window==null?void 0:window.myop)==null?void 0:u.hostSDK)==null?void 0:m.getRenderPolicy)==null?void 0:g.call(m),c=d?await d({componentDefinition:e,skin:t,requestedMode:p,isWebComponent:i}):p;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(e){return"<script>\n (function () {\n var __initial = ".concat(e,";\n var __pending;\n // data-out (cta)\n window.myop_cta_handler = function (action, payload) {\n try { parent.postMessage({ __myop: true, type: 'myop:cta', action: action, payload: payload }, '*'); } catch (e) {}\n };\n function callInit(data) {\n if (typeof window.myop_init_interface === 'function') { window.myop_init_interface(data); return true; }\n return false;\n }\n // data-in (init updates)\n window.addEventListener('message', function (e) {\n var d = e.data;\n if (!d || d.__myop !== true) return;\n if (d.type === 'myop:init') { if (!callInit(d.data)) __pending = d.data; }\n });\n // first render: use a pending update if one arrived, else the baked initial data\n (function flushInitial() {\n var data = (__pending !== undefined) ? __pending : __initial;\n if (data === undefined) return;\n if (callInit(data)) { __pending = undefined; __initial = undefined; }\n else requestAnimationFrame(flushInitial);\n })();\n // resize (report content size)\n function contentHeight() {\n // Measure the BODY (content box). documentElement.scrollHeight includes\n // the iframe viewport \u2014 which we're driving \u2014 so it would report the\n // current frame height, not the content, and never shrink.\n var b = document.body;\n if (b) return Math.max(b.scrollHeight, b.offsetHeight);\n return document.documentElement.scrollHeight;\n }\n function postSize() {\n try {\n parent.postMessage({\n __myop: true, type: 'myop:size',\n height: contentHeight(),\n width: document.documentElement.scrollWidth\n }, '*');\n } catch (e) {}\n }\n // Observe the BODY (reflows with content) \u2014 not documentElement, whose box is\n // the iframe viewport and would feed back into a resize loop. A MutationObserver\n // catches content swaps (e.g. innerHTML re-render) that don't change body's box.\n if (window.ResizeObserver) {\n try { var __ro = new ResizeObserver(postSize); if (document.body) __ro.observe(document.body); } catch (e) {}\n }\n if (window.MutationObserver && document.body) {\n try { new MutationObserver(postSize).observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true }); } catch (e) {}\n }\n window.addEventListener('load', postSize);\n postSize();\n })();\n <\/script>")}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(Co);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){let s=Pn.get(t);if(s)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(s,">")),s;let i=document.createElement("script");i.textContent=e,i.id="myop-extracted-".concat(t),document.head.appendChild(i);let a=window.__MYOP_TAG_NAME__;return a&&Pn.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(p,d);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let u="myop-comp-".concat(D()),m=document.createElement(c);m.id=u,a!=null&&a.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"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,m,a);let g=new re(e,t,s,m,c,a);return(a==null?void 0:a.data)!==void 0&&g.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),g}};var An=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=Et(t);switch(s){case"component":{let[a,p]=i,d=await ae.Main.fetchComponent(a);if(d&&d.type.skins.find(u=>u.id===p))return d.instance.skinSelector={type:ie.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=Et(t),c=(await ae.Main.fetchFlow(a)).components.find(u=>u.type.id===o.type.id);if(c&&c.instance.skinSelector.type===ie.Segmented&&c.instance.resolvedExperiences){let u=c.instance.resolvedExperiences.find(m=>m.id===p);if((u==null?void 0:u.type)===We.Segment){let m=u,f=c.instance.skinSelector.segments.find(l=>l.segmentId===m.segment.id);if(f)return c.instance.skinSelector=f==null?void 0:f.skinSelector,c}}}break}}}finally{return null}};var $n="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",K=class{constructor(){r(this,"components2init",[]);r(this,"components",[]);r(this,"componentsLoaders",[]);r(this,"_renderPolicy");r(this,"setRenderPolicy",n=>{this._renderPolicy=n});r(this,"getRenderPolicy",()=>this._renderPolicy);r(this,"initiated",!1);r(this,"version",et);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"isTrustedSource",n=>{if(!n||n===window)return!0;let e=t=>{let s=t.element;return(s==null?void 0:s.nodeName)==="IFRAME"&&s.contentWindow===n};return this.components.some(e)||this.components2init.some(e)});r(this,"incomingMessageHandler",n=>{var e;if((e=n.data)!=null&&e.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==v.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){this.components2init.forEach(i=>{i.send(new te(i.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==t.content.id);let i=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});i==null||i.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let i=t,a=this.components.find(p=>p.id===i.destination);if(a){if(i.direction===v.down){i.message.messageType===O.name?a.onMessageReceived(i.message):(i.message.route=i.route,a.send(i.message));return}}else{let p=this.components.find(d=>d.id===i.message.destination);p&&p.send(i.message)}return}let s=this.components.find(i=>i.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let e=[new Je,new Ze,new ht];this.componentsLoaders=[...e],n&&this._registerLoaders(n),window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_registerLoaders",n=>{let e={};n.forEach(t=>{let s=new t(this.componentsLoaders);e[s.type]=s}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case ie.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case ie.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(f=>f.type===We.Segment?f.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let m=c.segment,g=(t||{})[m.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var u,m,g,f;if(!e){debugger;throw new Error("no container was found for this component")}let s=await An(n);s&&(n=s);let i=h(h({},(u=this.loaderHooks)!=null?u:{}),(m=t==null?void 0:t.hooks)!=null?m:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,i);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:ie.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await Ft(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||(this.components2init.push(c),c.send(new te(c.id))),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=En(c,n.type.props,p));try{await Kt(c,n,this.components)}catch(l){throw l}return t!=null&&t.skipInit||await c.initiated(),c});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(K,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$n});if(!window.myop.hostSDK){let o=new K;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$n}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>Rn(n);o.stats=Pe,o.off=kn,o.refresh=Hn,window.myop.delivery=o}var vo=window.myop.hostSDK;Me("hostSDK",vo);var Mt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"executor",e=>{(async()=>{let s=document.querySelectorAll("[".concat(R.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await K.Instance().loadComponent(e.nestedComponentConfig,s.item(0),e.options),p=[];Object.keys(a.refs).forEach(d=>{let c=a.refs[d];c=c.__nonProxied||c,c.componentDefinition&&p.push({refName:d,componentDefinitionId:c.componentDefinition.id})}),this.messageToHost(new N(e.handlerUniqueId,p))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new N(e.handlerUniqueId,[],!0));debugger}})().then()})}};var Fn=(o,n)=>{if(!o){console.log("n");return}let e=window.MutationObserver||window.WebKitMutationObserver;if(!(!o||o.nodeType!==1))if(e){let t=new e(n),s={attributes:!0,childList:!0,subtree:!0};return t.observe(o,s),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var Ct=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetMutationObserverMessage);r(this,"executor",e=>{e.source&&Fn(document.body,()=>{this.messageToHost(new Te)})})}};var Kn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(R.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Kn(i),required:i.required,validity:L(i.validity,!0),myopId:a};e.unmappedData.push(d),p&&(!e.formData[p]||!e.formData[p].value||d.value)&&(e.formData[p]=d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},bt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"executor",e=>{I(e.ref,document).forEach(s=>{this.messageToHost(new ee(Kn(s)),e)})})}};var It=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetAttributeMessage);r(this,"executor",e=>{let t=In(e.ref,document);t&&this.messageToHost(new Ee(t.getAttribute(e.name)),e)})}};var wt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetResizeObserverMessage);r(this,"executor",e=>{let t=new ResizeObserver(s=>{this.messageToHost(new De)});return t.observe(document.body),()=>{t.disconnect()}})}};var xt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"executor",e=>{I(e.ref,document).forEach(s=>{s.innerHTML=e.content})})}};var Ut=class extends ue{constructor(){super();r(this,"version",et);r(this,"messageToHost",(e,t)=>{var i;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let s=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=s[0]),e.source||(e.source=s[0]),e.direction=v.up,(i=window.parent)==null||i.postMessage(h({},e),"*")});r(this,"supportedHandlers",[new qe(this.messageToHost),new xt(this.messageToHost),new Ue(this.messageToHost),new Ne(this.messageToHost),new je(this.messageToHost),new Ye(this.messageToHost),new Qe(this.messageToHost),new bt(this.messageToHost),new Ct(this.messageToHost),new wt(this.messageToHost),new It(this.messageToHost),new Mt(this.messageToHost)]);r(this,"announceUntilAnswered",(e=1e4)=>{let t=50,s=0,i=()=>{Object.keys(this.components).length>0||s>e||(this.messageToHost(new ne),s+=t,t=Math.min(t*2,1e3),setTimeout(i,t))};i()});r(this,"init",()=>{window.onmessage=e=>{e.source&&e.source!==window.parent&&e.source!==window||this.handleIncomeMessages(e)},this.announceUntilAnswered()});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Me("IframeSDK",Ut);export{Ut as IframeSDK};
|
|
@@ -1838,7 +1838,8 @@ var MyopIframeComponent = class extends BaseMyopComponent {
|
|
|
1838
1838
|
this.IframeElement.style.width = "100%";
|
|
1839
1839
|
this.setHeightBasedOnScrollHeight();
|
|
1840
1840
|
observerCleanup = this.send(new SetResizeObserverMessage());
|
|
1841
|
-
}).catch(() => {
|
|
1841
|
+
}).catch((e) => {
|
|
1842
|
+
console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id, ": ").concat(e));
|
|
1842
1843
|
});
|
|
1843
1844
|
return cleanup;
|
|
1844
1845
|
});
|
|
@@ -2172,7 +2173,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
|
|
|
2172
2173
|
};
|
|
2173
2174
|
|
|
2174
2175
|
// version:myop-sdk-version
|
|
2175
|
-
var myop_sdk_version_default = "0.4.0-beta.
|
|
2176
|
+
var myop_sdk_version_default = "0.4.0-beta.2";
|
|
2176
2177
|
|
|
2177
2178
|
// src/helpers/deliveryStore.ts
|
|
2178
2179
|
var DB_NAME = "myop-delivery";
|
|
@@ -3843,8 +3844,10 @@ var HostSDK = class {
|
|
|
3843
3844
|
throw new Error('no loader "'.concat(selectedSkin.loader.type, '" was found for component'));
|
|
3844
3845
|
}
|
|
3845
3846
|
let component = await componentLoader.load(componentConfig.type, selectedSkin, container, options);
|
|
3846
|
-
if (!component.isInitiated)
|
|
3847
|
+
if (!component.isInitiated) {
|
|
3847
3848
|
this.components2init.push(component);
|
|
3849
|
+
component.send(new InitMessage(component.id));
|
|
3850
|
+
}
|
|
3848
3851
|
component.bind("onDispose", () => {
|
|
3849
3852
|
this.components = this.components.filter((c) => c !== component);
|
|
3850
3853
|
this.components2init = this.components2init.filter((c) => c !== component);
|
|
@@ -4135,12 +4138,60 @@ var IframeSDK = class extends BaseMyopSDK {
|
|
|
4135
4138
|
//composite support messages :
|
|
4136
4139
|
new CreateRefComponentMessageHandler2(this.messageToHost)
|
|
4137
4140
|
]);
|
|
4141
|
+
/**
|
|
4142
|
+
* Announce this frame until the host answers, not once.
|
|
4143
|
+
*
|
|
4144
|
+
* The host only learns a component exists AFTER `await componentLoader.load(...)`
|
|
4145
|
+
* resolves (hostSDK.ts:433-437 — the line above it already calls this a race). A frame
|
|
4146
|
+
* that boots inside that await announces itself to a host whose components2init is
|
|
4147
|
+
* still empty: the host iterates nothing, sends no InitMessage, and a single-shot
|
|
4148
|
+
* announce leaves the frame waiting forever. The visible symptom is initiated()
|
|
4149
|
+
* rejecting with timeout_<ms>, with exactly one message on the wire -- InitRequest,
|
|
4150
|
+
* never InitResponse.
|
|
4151
|
+
*
|
|
4152
|
+
* Minification made it common rather than rare: a smaller payload boots the frame
|
|
4153
|
+
* sooner, landing it deeper inside the window. Reported by a customer 2026-10-17.
|
|
4154
|
+
*
|
|
4155
|
+
* Re-announcing is safe and idempotent. The host replies to InitRequest by sending
|
|
4156
|
+
* InitMessage to every component still awaiting init; a frame that has already
|
|
4157
|
+
* registered that id ignores the repeat (BaseMyopSDK: `if (this.components[id]) return`).
|
|
4158
|
+
* So a late answer costs one extra round trip and nothing else.
|
|
4159
|
+
*
|
|
4160
|
+
* Backs off 50ms -> 1s and stops the moment any component registers, so the common
|
|
4161
|
+
* case sends exactly one message.
|
|
4162
|
+
*
|
|
4163
|
+
* THE CAP IS A CONSTANT, and it should ideally be the host's own `options.timeout`
|
|
4164
|
+
* so the frame never gives up before the host does. That was tried on 2026-10-17 and
|
|
4165
|
+
* REVERTED: the budget has to reach the frame through the init script that
|
|
4166
|
+
* HTMLComponentLoader generates, and `${...}` interpolated into that template does
|
|
4167
|
+
* not survive the build -- the transpiled `.concat()` leaks into the emitted script
|
|
4168
|
+
* as literal text, the frame parses no number, and it silently falls back to the
|
|
4169
|
+
* default. It looked correct in source and in the bundle, and only the e2e caught it.
|
|
4170
|
+
*
|
|
4171
|
+
* 10s is chosen to exceed BaseMyopComponent's 5s default, so the frame outlives the
|
|
4172
|
+
* common host deadline. This only matters in the pathological case: with the host now
|
|
4173
|
+
* sending InitMessage on registration (hostSDK.ts), the retry is a backstop that in
|
|
4174
|
+
* practice never fires.
|
|
4175
|
+
*/
|
|
4176
|
+
__publicField(this, "announceUntilAnswered", (budgetMs = 1e4) => {
|
|
4177
|
+
let wait2 = 50;
|
|
4178
|
+
let waited = 0;
|
|
4179
|
+
const tick = () => {
|
|
4180
|
+
if (Object.keys(this.components).length > 0) return;
|
|
4181
|
+
if (waited > budgetMs) return;
|
|
4182
|
+
this.messageToHost(new InitRequest());
|
|
4183
|
+
waited += wait2;
|
|
4184
|
+
wait2 = Math.min(wait2 * 2, 1e3);
|
|
4185
|
+
setTimeout(tick, wait2);
|
|
4186
|
+
};
|
|
4187
|
+
tick();
|
|
4188
|
+
});
|
|
4138
4189
|
__publicField(this, "init", () => {
|
|
4139
4190
|
window.onmessage = (event) => {
|
|
4140
4191
|
if (event.source && event.source !== window.parent && event.source !== window) return;
|
|
4141
4192
|
this.handleIncomeMessages(event);
|
|
4142
4193
|
};
|
|
4143
|
-
this.
|
|
4194
|
+
this.announceUntilAnswered();
|
|
4144
4195
|
});
|
|
4145
4196
|
if (!window.myop) {
|
|
4146
4197
|
window.myop = {};
|