@myop/sdk 0.4.0-beta.2 → 0.4.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/bundled-declarations.d.ts +29 -30
  2. package/dist/cjs/_IframeSDK.3faa31eb.min.js +1 -0
  3. package/dist/cjs/{_IframeSDK.a43cfa7d.js → _IframeSDK.c2e3efb9.js} +79 -57
  4. package/dist/cjs/_IframeSDK.c2e3efb9.js.map +7 -0
  5. package/dist/cjs/{_WebComponentSDK.0f6ef369.js → _WebComponentSDK.3728ca8b.js} +35 -12
  6. package/dist/cjs/_WebComponentSDK.3728ca8b.js.map +7 -0
  7. package/dist/cjs/_WebComponentSDK.e517f1a4.min.js +1 -0
  8. package/dist/cjs/_hostSDK.48b3ff7a.min.js +1 -0
  9. package/dist/cjs/{_hostSDK.38fcc5b4.js → _hostSDK.94744d97.js} +35 -12
  10. package/dist/cjs/_hostSDK.94744d97.js.map +7 -0
  11. package/dist/cjs/myop_sdk.js +11 -11
  12. package/dist/cjs/myop_sdk.js.map +1 -1
  13. package/dist/cjs/myop_sdk.min.js +1 -1
  14. package/dist/cjs-bundled/myop_sdk.bundled.js +81 -58
  15. package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
  16. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  17. package/dist/module/Iframe/IframeSDK.d.ts +26 -30
  18. package/dist/module/Iframe/index.js +80 -58
  19. package/dist/module/Iframe/index.js.map +3 -3
  20. package/dist/module/SDK.js +81 -58
  21. package/dist/module/SDK.js.map +3 -3
  22. package/dist/module/embeddedSDK.js +1 -1
  23. package/dist/module/host/components/IMyopComponent.d.ts +3 -0
  24. package/dist/module/host/embeddedSDK.js +1 -1
  25. package/dist/module/host/index.js +36 -13
  26. package/dist/module/host/index.js.map +2 -2
  27. package/dist/module/webcomponent/index.js +36 -13
  28. package/dist/module/webcomponent/index.js.map +2 -2
  29. package/package.json +1 -1
  30. package/dist/cjs/_IframeSDK.8f08de4b.min.js +0 -1
  31. package/dist/cjs/_IframeSDK.a43cfa7d.js.map +0 -7
  32. package/dist/cjs/_WebComponentSDK.0f6ef369.js.map +0 -7
  33. package/dist/cjs/_WebComponentSDK.649e5e47.min.js +0 -1
  34. package/dist/cjs/_hostSDK.131fedc9.min.js +0 -1
  35. package/dist/cjs/_hostSDK.38fcc5b4.js.map +0 -7
@@ -1262,6 +1262,9 @@ declare module "@myop/sdk/host/components/IMyopComponent" {
1262
1262
  initiated: () => Promise<any>;
1263
1263
  private sendCleanupMessage;
1264
1264
  send(message: BaseMyopMessage): CleanupHandler;
1265
+ /** Runs the 'onDispose' handlers once. hostSDK registers the one that unregisters
1266
+ * this component, so it has to run on EVERY dispose path, initiated or not. */
1267
+ private runDisposeHandlers;
1265
1268
  dispose(): void;
1266
1269
  props: P;
1267
1270
  refs: R;
@@ -1483,41 +1486,37 @@ declare module "@myop/sdk/Iframe/IframeSDK" {
1483
1486
  messageToHost: (message: MyopBindReplayMessage, replayTo?: MyopBindMessage) => void;
1484
1487
  supportedHandlers: BaseMessageHandler[];
1485
1488
  /**
1486
- * Announce this frame until the host answers, not once.
1489
+ * The window this frame answers to. Defaults to the parent, which is correct for a
1490
+ * component mounted directly by the page's own host.
1487
1491
  *
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.
1492
+ * IT IS NOT ALWAYS THE PARENT. A host can mount a component into a container that
1493
+ * lives inside ANOTHER component's document -- Pic-Time's reel templates are mounted
1494
+ * by the top-level host into `#reelSlot` inside the reel dialog's frame. The real host
1495
+ * is then a GRANDparent, and `window.parent` is a frame that knows nothing about this
1496
+ * component: its nested hostSDK has no entry for it and its IframeSDK drops messages
1497
+ * from a child. Replies sent to the parent are simply lost.
1495
1498
  *
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.
1499
+ * So we adopt whoever actually talks to us, the first time an ancestor does.
1500
+ */
1501
+ private hostWindow;
1502
+ /**
1503
+ * Commands (including ExecuteScript) must come from a window this frame is actually
1504
+ * nested inside -- never from an opener or a sibling that merely holds a reference.
1506
1505
  *
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.
1506
+ * THIS USED TO COMPARE AGAINST `window.parent` ALONE, and that was a regression I
1507
+ * shipped in 0.4.0-beta: it silently dropped the host's InitMessage for any component
1508
+ * mounted cross-document, because the host is a grandparent there. The frame then
1509
+ * announced for its full 10s budget into a parent that never answers and rejected with
1510
+ * timeout_10000 having registered nothing. Reproduced live on Pic-Time's QA page
1511
+ * 2026-10-17: 15 InitRequests, 0 InitResponses, `IframeSDK.components` empty.
1512
+ * 0.3.36 had no guard at all, which is why it worked.
1514
1513
  *
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.
1514
+ * Walking the ancestor chain keeps the security property -- an opener or a sibling is
1515
+ * not an ancestor -- while allowing a host any number of frames up. The walk is
1516
+ * bounded, and reading `.parent` across origins is allowed (only the reference is
1517
+ * compared, never touched).
1519
1518
  */
1520
- private announceUntilAnswered;
1519
+ private isFromHostChain;
1521
1520
  init: () => void;
1522
1521
  }
1523
1522
  }
@@ -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 We={};no(We,{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"},Ke={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 H={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(H.id,"]")),s=[];t.forEach(i=>{let a=i.getAttribute(H.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(H.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)||W.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)),this.dispose())},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()}:()=>{}}runDisposeHandlers(){let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)})}dispose(){if(this.markedForDisposed=!0,!this.isInitiated){this.runDisposeHandlers(),this.messageHandlers={},this.id+="_disposed";return}console.log("disposing component",this.id),this.send(new He),this.runDisposeHandlers(),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"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}:void 0;if(o instanceof q&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?m=>{if(m===void 0)return o.getData();o.initWithData(m)}: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(u=>{d(u)}),p.behavior.params&&c.push(...p.behavior.params);let m=We[p.behavior.message];o.send(new m(...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 m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof q&&o.isolated){let m=d.behavior.remap||a;if(m==="myop_cta_handler")return o.setCtaHandler(p),!0;if(m==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===U.HTMLLoader&&e.loader.shadowRootMode===se.localFrame){let m=d.behavior,u=o.element.contentWindow,f=m.remap||a;if(u[f]=p,f==="myop_cta_handler"&&u.__myop_cta_queue){let g=u.__myop_cta_queue;u.__myop_cta_queue=null,g.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 m=We[d.behavior.message];return o.send(new m(...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:m})=>{if(p){let u=p[d];return m(typeof u=="function"?p[d](...c):u,!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);let d=()=>{let m=e.indexOf(p);m!==-1&&e.splice(m,1)};await s.initiated();let c=setTimeout(()=>{d(),a("timeout")},5e3);s.send(new ve(o.refConfig,n,z(h({},t||{}),{id:p.id,_hasParent:!0}),async m=>{if(clearTimeout(c),m.failed){d(),a("CreateRefComponentMessage failed");return}let u=e.find(f=>f.id==p.id);if(u&&u!==p){d(),s.refs[o.refConfig.name]=u,i(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;m.nestedRefs.forEach(f=>{let g=n.instance.resolvedNestedComponents.find(R=>R.type.id===f.componentDefinitionId).type,l=new Be(g,p);l.setInitiated(),p.refs[f.refName]=l,e.push(l)});try{await Wt(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(f){a(f)}}))})},Wt=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 m=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(f=>f.type.id===c);if(!m)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let u=j.create("",i,o);try{let f=await Ft(u,m,e);o.refs[i.name]=f,a()}catch(f){p(f)}}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=(g,l,R)=>l!==void 0&&g<l?l:R!==void 0&&g>R?R:g,a=g=>{if(g===void 0)return;if(typeof g=="number")return g;let l=parseFloat(g);return isNaN(l)?void 0:l},p=()=>{var Jt,Xt,Zt,en,tn,nn,on,sn;let g=t.contentDocument;if(!g)return;let l=this._autoSizeOptions,R=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(),Kn=ce.width===0,Nn=ce.height===0||ce.height===pe,le=(l!=null&&l.forceAutoSize||Kn)&&!_,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,K=this.container,qn=K.style.transition;t.style.transition="none",K.style.transition="none";let qt=t.getBoundingClientRect().height,Vt=t.getBoundingClientRect().width,jt=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Gt=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.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=K.style.minHeight,Jn=K.style.minWidth;ze&&(K.style.minHeight="".concat(qt,"px")),Ae&&(K.style.minWidth="".concat(Vt,"px")),ze&&(t.style.height="0px"),Ae&&(t.style.width="0px"),Ie=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),we=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let rn=ze&&we<2,an=Ae&&Ie<2;if(rn||an){let $e=g.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; }"),g.head.appendChild($e),Ie=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),we=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),$e.remove()}K.style.minHeight=Qn,K.style.minWidth=Jn}let Yt=i(Ie,R,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,K.style.transition=qn;let Gn=le&&k!==void 0&&Ie>k,Yn=me&&T!==void 0&&we>T;g.documentElement.style.overflowX=Gn?"auto":"",g.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()}))},m=new ResizeObserver(()=>c());m.observe(s.body),m.observe(s.documentElement);let u=new MutationObserver(()=>c());u.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let f=()=>{m.disconnect(),u.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=f,f});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,t;(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(),(t=this.IframeElement.parentNode)==null||t.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=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),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(),m="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=m;let u="\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=u,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=t.loader.url;i!=null&&i._hasParent&&(f=lo(f,"_myop-comp",c)),a.src=f,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 Kt={},Ze=class extends G{constructor(){super(...arguments);r(this,"type",U.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;Kt[a.url]?console.log("Module alreday loaded or in loading process"):Kt[a.url]=new Promise((c,m)=>{let u=a.url,f=document.createElement("script");f.type="module",f.src=u,f.onload=()=>{c()},f.onerror=()=>{m()},document.head.appendChild(f)}),await Kt[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.3";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 m=this._delivery.cache&&!this._staticMode&&!i,u=m?A.key(this.deliveryHost(),n,s,i,this._delivery.minify?"min":"raw"):"",f=m?await A.get(u):null;if(f&&A.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,s),this.variants[a].resolved=f.config,p(f.config);return}if(f&&f.tag){let V="/consume?ids=".concat(n,"&env=").concat(s)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.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(f),f.storedAt=Date.now(),f.windowMs=A.windowFrom(T.headers)||f.windowMs,await A.put(f),this.variants[a].resolved=f.config,p(f.config);return}let Y=(pe.items||[])[0];if(Y){let P=_n(Y);this._deliveryStats.fromNetwork++,await A.put({key:u,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 g=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!g.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(g.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let R=(await g.json()).item;if(!R){d(new Error('Component "'.concat(n,'" not found')));return}if(!R.consume_variant||!R.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let k=_n(R);this._deliveryStats.fromNetwork++,m&&await A.put({key:u,config:k,tag:R.tag||null,storedAt:Date.now(),windowMs:A.windowFrom(g.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(H.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(H.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(H.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=W.Instance(),d=p.components.find(f=>f.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let m=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),u=[];Object.keys(m.refs).forEach(f=>{let g=m.refs[f];g=g.__nonProxied||g,g.componentDefinition&&u.push({refName:f,componentDefinitionId:g.componentDefinition.id})}),s(new N(e.handlerUniqueId,u))}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(H.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 m="myop-comp-".concat(D()),u;if(a.shadowRootMode===se.localFrame){let f=D(),g="myop-comp-".concat(f),l=document.createElement("iframe");l.id=g,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 R=[],k=c?{open(){},writeln(w){R.push(w)},close(){l.srcdoc=R.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 f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,zn().then(g=>{g.connectedCallback(u,u)})}else{let f=xo(e.name+t.id);On.includes(f)||(Io(f,a.HTML,a.shadowRootMode),On.push(f)),u=document.createElement(f)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),u.id=m,i!=null&&i.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),this.appendChild(s,u,i),new be(e,t,s,u,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(Mo)}async resolveRenderMode(e,t,s,i,a){var m,u,f,g;let p=i?"webComponent":s.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(g=a==null?void 0:a.renderPolicy)!=null?g:(f=(u=(m=window==null?void 0:window.myop)==null?void 0:m.hostSDK)==null?void 0:u.getRenderPolicy)==null?void 0:f.call(u),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 m="myop-comp-".concat(D()),u=document.createElement(c);u.id=m,a!=null&&a.hidden&&(u.style.opacity="0",u.style.position="absolute",u.style.height="0",u.style.width="0",u.style.pointerEvents="none",u.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,u,a);let f=new re(e,t,s,u,c,a);return(a==null?void 0:a.data)!==void 0&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};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(m=>m.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(m=>m.type.id===o.type.id);if(c&&c.instance.skinSelector.type===ie.Segmented&&c.instance.resolvedExperiences){let m=c.instance.resolvedExperiences.find(u=>u.id===p);if((m==null?void 0:m.type)===Ke.Segment){let u=m,g=c.instance.skinSelector.segments.find(l=>l.segmentId===u.segment.id);if(g)return c.instance.skinSelector=g==null?void 0:g.skinSelector,c}}}break}}}finally{return null}};var $n="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",W=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){let i=this.components2init.filter(p=>{let d=p.element;return(d==null?void 0:d.nodeName)==="IFRAME"&&d.contentWindow===n.source});(i.length?i:this.components2init).forEach(p=>{p.send(new te(p.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(g=>g.type===Ke.Segment?g.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let u=c.segment,f=(t||{})[u.function];return f?await f():(console.warn("segmentId:".concat(d.segmentId,", ").concat(u.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 m,u,f,g;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({},(m=this.loaderHooks)!=null?m:{}),(u=t==null?void 0:t.hooks)!=null?u:{}),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(f=t==null?void 0:t.hooks)!=null&&f.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");(g=t==null?void 0:t.hooks)!=null&&g.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.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),c.isInitiated||c.send(new te(c.id)),(!t||t.connectProps!==!1)&&(c=En(c,n.type.props,p));try{await Wt(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(W,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:$n});if(!window.myop.hostSDK){let o=new W;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(H.id,"='").concat(e.refConfig.selector,"']"));if(s.length===1){let a=await W.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 Wn=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(H.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Wn(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(Wn(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,a;!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,(a=(i=this.hostWindow)!=null?i:window.parent)==null||a.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,"hostWindow",window.parent);r(this,"isFromHostChain",e=>{if(!e||e===window)return!0;let t=window;for(let s=0;s<32;s++){let i=t.parent;if(!i||i===t)return!1;if(e===i)return!0;t=i}return!1});r(this,"init",()=>{window.onmessage=e=>{var t;this.isFromHostChain(e.source)&&(e.source&&e.source!==window&&((t=e.data)==null?void 0:t.messageType)===y.InitMessage&&(this.hostWindow=e.source),this.handleIncomeMessages(e))},this.messageToHost(new ne)});window.myop||(window.myop={}),window.myop.IframeSDK=this}};Me("IframeSDK",Ut);export{Ut as IframeSDK};
@@ -1008,6 +1008,7 @@ var BaseMyopComponent = class {
1008
1008
  setTimeout(() => {
1009
1009
  if (!this.isInitiated && this._whenInitiatedReject && !this._markedForDisposed) {
1010
1010
  this._whenInitiatedReject("timeout_".concat(timeout, " ").concat(this.id));
1011
+ this.dispose();
1011
1012
  }
1012
1013
  }, timeout);
1013
1014
  this.initiated().then(() => {
@@ -1091,19 +1092,27 @@ var BaseMyopComponent = class {
1091
1092
  };
1092
1093
  }
1093
1094
  }
1095
+ /** Runs the 'onDispose' handlers once. hostSDK registers the one that unregisters
1096
+ * this component, so it has to run on EVERY dispose path, initiated or not. */
1097
+ runDisposeHandlers() {
1098
+ const onDisposeHandlers = this.messageHandlers["onDispose"];
1099
+ if (onDisposeHandlers) {
1100
+ onDisposeHandlers.forEach((disposeHandler) => {
1101
+ disposeHandler(null);
1102
+ });
1103
+ }
1104
+ }
1094
1105
  dispose() {
1095
1106
  this.markedForDisposed = true;
1096
1107
  if (!this.isInitiated) {
1108
+ this.runDisposeHandlers();
1109
+ this.messageHandlers = {};
1110
+ this.id += "_disposed";
1097
1111
  return;
1098
1112
  }
1099
1113
  console.log("disposing component", this.id);
1100
1114
  this.send(new DisposeMessage());
1101
- const onDisposeHandlers = this.messageHandlers["onDispose"];
1102
- if (onDisposeHandlers) {
1103
- onDisposeHandlers.forEach((disposeHandler) => {
1104
- disposeHandler(null);
1105
- });
1106
- }
1115
+ this.runDisposeHandlers();
1107
1116
  this.messageHandlers = {};
1108
1117
  this.id += "_disposed";
1109
1118
  this.isInitiated = false;
@@ -1506,8 +1515,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
1506
1515
  return new Promise(async (resolve, reject) => {
1507
1516
  const refComponent = new MyopRefComponent(componentConfig.type, component, options);
1508
1517
  components.push(refComponent);
1518
+ const unregister = () => {
1519
+ const at = components.indexOf(refComponent);
1520
+ if (at !== -1) components.splice(at, 1);
1521
+ };
1509
1522
  await component.initiated();
1510
1523
  const timeout = setTimeout(() => {
1524
+ unregister();
1511
1525
  reject("timeout");
1512
1526
  }, 5e3);
1513
1527
  component.send(new CreateRefComponentMessage(
@@ -1520,11 +1534,13 @@ var createRefComponent = async (ref, componentConfig, components, options) => {
1520
1534
  async (message) => {
1521
1535
  clearTimeout(timeout);
1522
1536
  if (message.failed) {
1537
+ unregister();
1523
1538
  reject("CreateRefComponentMessage failed");
1524
1539
  return;
1525
1540
  }
1526
1541
  const implementationComponent = components.find((c) => c.id == refComponent.id);
1527
- if (implementationComponent !== refComponent) {
1542
+ if (implementationComponent && implementationComponent !== refComponent) {
1543
+ unregister();
1528
1544
  component.refs[ref.refConfig.name] = implementationComponent;
1529
1545
  resolve(implementationComponent);
1530
1546
  return;
@@ -1888,7 +1904,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1888
1904
  return cleanupHandler;
1889
1905
  });
1890
1906
  __publicField(this, "dispose", () => {
1891
- var _a;
1907
+ var _a, _b;
1892
1908
  (_a = this._bridgeSizeCleanup) == null ? void 0 : _a.call(this);
1893
1909
  if (this._autoSizeCleanup) {
1894
1910
  this._autoSizeCleanup();
@@ -1901,7 +1917,7 @@ var MyopIframeComponent = class extends BaseMyopComponent {
1901
1917
  if (this.cleanupInspect)
1902
1918
  this.cleanupInspect();
1903
1919
  super.dispose();
1904
- this.IframeElement.parentNode.removeChild(this.IframeElement);
1920
+ (_b = this.IframeElement.parentNode) == null ? void 0 : _b.removeChild(this.IframeElement);
1905
1921
  });
1906
1922
  this.element = this.IframeElement;
1907
1923
  this._lastData = options == null ? void 0 : options.data;
@@ -2173,7 +2189,7 @@ var WebcomponentLoader = class extends BaseMyopLoader {
2173
2189
  };
2174
2190
 
2175
2191
  // version:myop-sdk-version
2176
- var myop_sdk_version_default = "0.4.0-beta.2";
2192
+ var myop_sdk_version_default = "0.4.0-beta.3";
2177
2193
 
2178
2194
  // src/helpers/deliveryStore.ts
2179
2195
  var DB_NAME = "myop-delivery";
@@ -3629,7 +3645,12 @@ var HostSDK = class {
3629
3645
  }
3630
3646
  const myopMessage = event.data;
3631
3647
  if (myopMessage.messageType === MyopMessages.InitRequest) {
3632
- this.components2init.forEach((component2) => {
3648
+ const fromAskingFrame = this.components2init.filter((component2) => {
3649
+ const element = component2.element;
3650
+ return (element == null ? void 0 : element.nodeName) === "IFRAME" && element.contentWindow === event.source;
3651
+ });
3652
+ const targets = fromAskingFrame.length ? fromAskingFrame : this.components2init;
3653
+ targets.forEach((component2) => {
3633
3654
  component2.send(new InitMessage(component2.id));
3634
3655
  });
3635
3656
  return;
@@ -3846,7 +3867,6 @@ var HostSDK = class {
3846
3867
  let component = await componentLoader.load(componentConfig.type, selectedSkin, container, options);
3847
3868
  if (!component.isInitiated) {
3848
3869
  this.components2init.push(component);
3849
- component.send(new InitMessage(component.id));
3850
3870
  }
3851
3871
  component.bind("onDispose", () => {
3852
3872
  this.components = this.components.filter((c) => c !== component);
@@ -3854,6 +3874,9 @@ var HostSDK = class {
3854
3874
  return true;
3855
3875
  });
3856
3876
  this.components.push(component);
3877
+ if (!component.isInitiated) {
3878
+ component.send(new InitMessage(component.id));
3879
+ }
3857
3880
  if (!options || options.connectProps !== false) {
3858
3881
  component = connectProps(component, componentConfig.type.props, selectedSkin);
3859
3882
  }
@@ -4107,7 +4130,7 @@ var IframeSDK = class extends BaseMyopSDK {
4107
4130
  super();
4108
4131
  __publicField(this, "version", myop_sdk_version_default);
4109
4132
  __publicField(this, "messageToHost", (message, replayTo) => {
4110
- var _a;
4133
+ var _a, _b;
4111
4134
  if (!message.replayToHandler && (replayTo == null ? void 0 : replayTo.handlerUniqueId))
4112
4135
  message.replayToHandler = replayTo.handlerUniqueId;
4113
4136
  const componentIds = Object.keys(this.components);
@@ -4121,7 +4144,7 @@ var IframeSDK = class extends BaseMyopSDK {
4121
4144
  if (!message.source)
4122
4145
  message.source = componentIds[0];
4123
4146
  message.direction = MessageDirection.up;
4124
- (_a = window.parent) == null ? void 0 : _a.postMessage(__spreadValues({}, message), "*");
4147
+ (_b = (_a = this.hostWindow) != null ? _a : window.parent) == null ? void 0 : _b.postMessage(__spreadValues({}, message), "*");
4125
4148
  });
4126
4149
  __publicField(this, "supportedHandlers", [
4127
4150
  new ChangeTextHandler(this.messageToHost),
@@ -4139,59 +4162,58 @@ var IframeSDK = class extends BaseMyopSDK {
4139
4162
  new CreateRefComponentMessageHandler2(this.messageToHost)
4140
4163
  ]);
4141
4164
  /**
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.
4165
+ * The window this frame answers to. Defaults to the parent, which is correct for a
4166
+ * component mounted directly by the page's own host.
4151
4167
  *
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.
4168
+ * IT IS NOT ALWAYS THE PARENT. A host can mount a component into a container that
4169
+ * lives inside ANOTHER component's document -- Pic-Time's reel templates are mounted
4170
+ * by the top-level host into `#reelSlot` inside the reel dialog's frame. The real host
4171
+ * is then a GRANDparent, and `window.parent` is a frame that knows nothing about this
4172
+ * component: its nested hostSDK has no entry for it and its IframeSDK drops messages
4173
+ * from a child. Replies sent to the parent are simply lost.
4154
4174
  *
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.
4175
+ * So we adopt whoever actually talks to us, the first time an ancestor does.
4176
+ */
4177
+ __publicField(this, "hostWindow", window.parent);
4178
+ /**
4179
+ * Commands (including ExecuteScript) must come from a window this frame is actually
4180
+ * nested inside -- never from an opener or a sibling that merely holds a reference.
4162
4181
  *
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.
4182
+ * THIS USED TO COMPARE AGAINST `window.parent` ALONE, and that was a regression I
4183
+ * shipped in 0.4.0-beta: it silently dropped the host's InitMessage for any component
4184
+ * mounted cross-document, because the host is a grandparent there. The frame then
4185
+ * announced for its full 10s budget into a parent that never answers and rejected with
4186
+ * timeout_10000 having registered nothing. Reproduced live on Pic-Time's QA page
4187
+ * 2026-10-17: 15 InitRequests, 0 InitResponses, `IframeSDK.components` empty.
4188
+ * 0.3.36 had no guard at all, which is why it worked.
4170
4189
  *
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.
4190
+ * Walking the ancestor chain keeps the security property -- an opener or a sibling is
4191
+ * not an ancestor -- while allowing a host any number of frames up. The walk is
4192
+ * bounded, and reading `.parent` across origins is allowed (only the reference is
4193
+ * compared, never touched).
4175
4194
  */
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();
4195
+ __publicField(this, "isFromHostChain", (source) => {
4196
+ if (!source) return true;
4197
+ if (source === window) return true;
4198
+ let current = window;
4199
+ for (let depth = 0; depth < 32; depth++) {
4200
+ const parent = current.parent;
4201
+ if (!parent || parent === current) return false;
4202
+ if (source === parent) return true;
4203
+ current = parent;
4204
+ }
4205
+ return false;
4188
4206
  });
4189
4207
  __publicField(this, "init", () => {
4190
4208
  window.onmessage = (event) => {
4191
- if (event.source && event.source !== window.parent && event.source !== window) return;
4209
+ var _a;
4210
+ if (!this.isFromHostChain(event.source)) return;
4211
+ if (event.source && event.source !== window && ((_a = event.data) == null ? void 0 : _a.messageType) === MyopMessages.InitMessage) {
4212
+ this.hostWindow = event.source;
4213
+ }
4192
4214
  this.handleIncomeMessages(event);
4193
4215
  };
4194
- this.announceUntilAnswered();
4216
+ this.messageToHost(new InitRequest());
4195
4217
  });
4196
4218
  if (!window.myop) {
4197
4219
  window.myop = {};