@myop/sdk 0.4.0-beta.5 → 0.4.0-beta.6

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 (48) hide show
  1. package/README.md +13 -0
  2. package/dist/bundled-declarations.d.ts +87 -4
  3. package/dist/cjs/{_IframeSDK.ac4c28cf.js → _IframeSDK.49662e01.js} +97 -18
  4. package/dist/cjs/_IframeSDK.49662e01.js.map +7 -0
  5. package/dist/cjs/_IframeSDK.d4a97876.min.js +1 -0
  6. package/dist/cjs/_MyopHelpers.12acc780.min.js +1 -0
  7. package/dist/cjs/{_MyopHelpers.efed13e4.js → _MyopHelpers.2c449e7a.js} +78 -15
  8. package/dist/cjs/_MyopHelpers.2c449e7a.js.map +7 -0
  9. package/dist/cjs/_WebComponentSDK.1addf28b.min.js +1 -0
  10. package/dist/cjs/{_WebComponentSDK.4085389a.js → _WebComponentSDK.d5f9105b.js} +97 -18
  11. package/dist/cjs/_WebComponentSDK.d5f9105b.js.map +7 -0
  12. package/dist/cjs/_hostSDK.6dab59cb.min.js +1 -0
  13. package/dist/cjs/{_hostSDK.46b85afc.js → _hostSDK.8cf37510.js} +97 -18
  14. package/dist/cjs/_hostSDK.8cf37510.js.map +7 -0
  15. package/dist/cjs/myop_sdk.js +14 -14
  16. package/dist/cjs/myop_sdk.js.map +1 -1
  17. package/dist/cjs/myop_sdk.min.js +1 -1
  18. package/dist/cjs-bundled/myop_sdk.bundled.js +107 -21
  19. package/dist/cjs-bundled/myop_sdk.bundled.js.map +3 -3
  20. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  21. package/dist/module/Iframe/index.js +98 -19
  22. package/dist/module/Iframe/index.js.map +2 -2
  23. package/dist/module/SDK.js +107 -21
  24. package/dist/module/SDK.js.map +3 -3
  25. package/dist/module/common/index.d.ts +5 -0
  26. package/dist/module/common/index.js +1 -1
  27. package/dist/module/common/index.js.map +2 -2
  28. package/dist/module/embeddedSDK.js +1 -1
  29. package/dist/module/helpers/CloudRepository.d.ts +36 -1
  30. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +42 -2
  31. package/dist/module/helpers/index.js +77 -16
  32. package/dist/module/helpers/index.js.map +2 -2
  33. package/dist/module/host/components/IMyopComponent.d.ts +3 -0
  34. package/dist/module/host/embeddedSDK.js +1 -1
  35. package/dist/module/host/hostSDK.d.ts +1 -1
  36. package/dist/module/host/index.js +98 -19
  37. package/dist/module/host/index.js.map +2 -2
  38. package/dist/module/webcomponent/index.js +98 -19
  39. package/dist/module/webcomponent/index.js.map +2 -2
  40. package/package.json +1 -1
  41. package/dist/cjs/_IframeSDK.47f37ec9.min.js +0 -1
  42. package/dist/cjs/_IframeSDK.ac4c28cf.js.map +0 -7
  43. package/dist/cjs/_MyopHelpers.91004b19.min.js +0 -1
  44. package/dist/cjs/_MyopHelpers.efed13e4.js.map +0 -7
  45. package/dist/cjs/_WebComponentSDK.4085389a.js.map +0 -7
  46. package/dist/cjs/_WebComponentSDK.4ca43f0a.min.js +0 -1
  47. package/dist/cjs/_hostSDK.0443afcd.min.js +0 -1
  48. package/dist/cjs/_hostSDK.46b85afc.js.map +0 -7
@@ -0,0 +1 @@
1
+ var dn=Object.defineProperty,eo=Object.defineProperties;var to=Object.getOwnPropertyDescriptors;var pn=Object.getOwnPropertySymbols;var no=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable;var vt=(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={}))no.call(n,e)&&vt(o,e,n[e]);if(pn)for(var e of pn(n))oo.call(n,e)&&vt(o,e,n[e]);return o},z=(o,n)=>eo(o,to(n));var so=(o,n)=>{for(var e in n)dn(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>vt(o,typeof n!="symbol"?n+"":n,e);var ue=class{constructor(n,e,t,i,s){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=i;this.offsetLeft=s;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}},We=class extends M{constructor(e,t){super(e);this.messageToHost=e;this.context=t}};var y={InitRequest:"InitRequest",InitResponse:"InitResponse",InitMessage:"InitMessage",DisposeMessage:"DisposeMessage",ChangeTextMessage:"ChangeTextMessage",BindClickMessage:"BindClickMessage",DetectMyopRefsMessage:"DetectMyopRefsMessage",ExecuteScriptMessage:"ExecuteScriptMessage",AddEventListenerMessage:"AddEventListenerMessage",SetAttributeMessage:"SetAttributeMessage",CreateRefComponentMessage:"CreateRefComponentMessage",EnvelopedMessage:"EnvelopedMessage",GetElementValueMessage:"GetElementValueMessage",GetAttributeMessage:"GetAttributeMessage",SetInnerHtml:"SetInnerHtml",ExecuteComponentMethod:"ExecuteComponentMethod",SetMutationObserverMessage:"SetMutationObserverMessage",SetResizeObserverMessage:"SetResizeObserverMessage",CleanupMessage:"CleanupMessage",In:{DetectedMyopRefsMessage:"DetectedMyopRefsMessage",ClickReplayMessage:"ClickReplayMessage",ExecuteScriptReplyMessage:"ExecuteScriptReplyMessage",EventListenerCallbackMessage:"EventListenerCallbackMessage",ElementValueReplayMessage:"ElementValueReplayMessage",GetAttributeReplayMessage:"GetAttributeReplayMessage",RefComponentCreatedMessage:"RefComponentCreatedMessage",EnvelopedMessage:"EnvelopedMessage",MutationObserverMessage:"MutationObserverMessage",CleanupReplayMessage:"CleanupReplayMessage",ResizeObserverMessage:"ResizeObserverMessage"}};var Ke={};so(Ke,{AddEventListenerMessage:()=>Ht,BaseMyopMessage:()=>b,BindClickMessage:()=>_t,ChangeTextMessage:()=>Rt,CleanupMessage:()=>_e,CleanupReplayMessage:()=>Re,ClickReplayMessage:()=>Q,CreateRefComponentMessage:()=>Se,CustomRefMessage:()=>X,DetectMyopRefsMessage:()=>Lt,DetectedMyopRefsMessage:()=>oe,DisposeMessage:()=>He,ElementValueReplayMessage:()=>ee,EnvelopedMessage:()=>ve,EventListenerCallbackMessage:()=>Z,ExecuteComponentMethod:()=>O,ExecuteScriptMessage:()=>B,ExecuteScriptReplyMessage:()=>J,GetAttributeMessage:()=>Pt,GetAttributeReplayMessage:()=>Ee,GetElementValueMessage:()=>Dt,InitMessage:()=>te,InitRequest:()=>ne,InitResponse:()=>xe,MessageDirection:()=>S,MutationObserverMessage:()=>Te,MyopBindMessage:()=>E,MyopBindReplayMessage:()=>v,MyopElementMessage:()=>Tt,Ref:()=>j,RefComponentCreatedMessage:()=>N,ResizeObserverMessage:()=>De,SetAttributeMessage:()=>kt,SetInnerHtml:()=>Bt,SetMutationObserverMessage:()=>Ot,SetResizeObserverMessage:()=>ke,stripFunction:()=>fn});var D=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var io=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 ro=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=ro(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(io(n.slice(t,t+16)));return e};var ln=o=>new Promise(n=>setTimeout(n,o));var S=class{};r(S,"down","down"),r(S,"up","up");var b=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 b{constructor(e){super();this.ref=e}},v=class extends b{constructor(e){super();this.replayToHandler=e}},E=class extends b{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 i=e;return i||(i={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(i,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 v{constructor(){super(...arguments);r(this,"messageType",mn)}};var Rt=class extends b{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var un="ExecuteScriptReplyMessage",ao=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,po=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,fn=o=>{let n=o.match(ao);if(n)return n[1]||n[3];{let e=o.match(po);if(e)return e[1].trim()}},B=class extends E{constructor(e,t=()=>{},i){super(t);this.scriptInputs=i;r(this,"replyMessageKey",un);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=fn(this.content)}};r(B,"replierKey","send"),r(B,"completeStreamKey","completeStream");var J=class extends v{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",un)}};var X=class extends B{constructor(e,t,i=()=>{}){super(({rootRef:s,elementId:a,_script:p,__scriptInputs:d})=>{let c=(s.shadowRoot||s.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},i);this.scriptInputs=t;this.scriptInputs=z(h({},t),{_script:e.toString()})}};var gn="EventListenerCallbackMessage",Ht=class extends E{constructor(e,t,i){super(i);this.ref=e;this.type=t;this.handler=i;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 v{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",gn);this.content={e:t}}};var kt=class extends b{constructor(e,t,i){super();this.ref=e;this.name=t;this.value=i;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 v{constructor(e){super();this.content=e;r(this,"messageType",yn)}};var Bt=class extends b{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var te=class extends b{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 b{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var hn="RefComponentCreatedMessage",Se=class extends E{constructor(e,t,i,s){super(s);this.refConfig=e;this.nestedComponentConfig=t;this.options=i;r(this,"replyMessageKey",hn);r(this,"messageType","CreateRefComponentMessage")}},N=class extends v{constructor(e,t,i){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=i;r(this,"messageType",hn)}};var ve=class extends b{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let i=t;this.route=[e,...i.route?i.route:[]]}};var Mn="DetectedMyopRefsMessage",Lt=class extends E{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",Mn)}},oe=class extends v{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",Mn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var bn="GetAttributeReplayMessage",Pt=class extends E{constructor(e,t,i){super(i);this.ref=e;this.name=t;r(this,"replyMessageKey",bn);r(this,"messageType","GetAttributeMessage")}},Ee=class extends v{constructor(e){super();this.content=e;r(this,"messageType",bn)}};var O=class extends b{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var Ot=class extends b{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},Te=class extends b{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var Cn="CleanupReplayMessage",_e=class extends E{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",Cn);r(this,"messageType","CleanupMessage")}},Re=class extends v{constructor(e){super();this.customCleanup=e;r(this,"messageType",Cn)}};var He=class extends b{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ke=class extends b{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},De=class extends b{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var zt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},fe=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!==S.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let i=t.content.id;if(this.components[i])return;this.components[i]=new zt(i),this.messageToHost(new xe(i));return}if(t.messageType===y.EnvelopedMessage){let i=t,s=i.message;if(t=s,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===s.destination);if(a){a.send(s);return}let p=myop.hostSDK.components.find(d=>d.id===i.destination);if(p){p.send(s);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let s=t,a=this.messageCleanupCache[s.cleanupForMessageId],p=new Re(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[s.cleanupForMessageId],cn(a).then(()=>{this.messageToHost(p,s)}).catch(()=>{})):this.messageToHost(p,s);return}let i=!1;this.supportedHandlers.forEach(s=>{if(s.messageType===t.messageType){i=!0;let a=s.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(s.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(s.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"},Ne={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 Ue=class extends M{constructor(){super(...arguments);r(this,"messageType",y.DetectMyopRefsMessage);r(this,"executor",e=>{let t=document.querySelectorAll("[".concat(H.id,"]")),i=[];t.forEach(s=>{let a=s.getAttribute(H.id);a&&i.push(new ue(a,s.tagName,s.getBoundingClientRect()))}),this.messageToHost(new oe(e.handlerUniqueId,i))})}};var w=(o,n)=>n.querySelectorAll("[".concat(H.id,"='").concat(o.refConfig.selector,"']")),wn=(o,n)=>{let e=w(o,n);return e.length?e.item(0):null};var Ve=class extends M{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"executor",e=>{let t=[];return w(e.ref,document).forEach(s=>{let a=()=>{this.messageToHost(new Q,e)};s.addEventListener("click",a);let p=()=>{s.removeEventListener("click",a)};t.push(p)}),()=>{t.forEach(s=>s())}})}};var qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{i.textContent=e.content})})}};var At=o=>o!==Object(o),co=o=>typeof o=="function",$t=o=>{if(At(o))return!0;if(co(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 i=[];t.set(o,i);for(let s=0;s<o.length;s++){let a=o[s];i[s]=L(a,n,e,t)}return i}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let i={};t.set(o,i);for(let s in o){let a=typeof n=="boolean"?n:n[s];a&&(a===!0?(e?o[s]!==void 0:o[s])&&(i[s]=L(o[s],!0,e,t)):typeof a=="object"&&(i[s]=L(o[s],a,e,t)))}return i}return{}};var je=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=L,t.send=n,t.rootRef=e,t.__scriptInputs=t;let s=new Function("return (".concat(o.script,")(...arguments)"))(t);n(s)};var Ge=class extends M{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"executor",e=>{je(e,i=>{this.messageToHost(new J(e.handlerUniqueId,i))},new ye(document.documentElement))})}};var Ye="__federation__",In="onLoad";var Me=(o,n)=>{window[Ye]&&window[Ye][o]&&window[Ye][o][In]&&window[Ye][o][In]({[o]:n})};var Qe=class extends M{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"executor",e=>{let t=w(e.ref,document),i=[];return t.forEach(s=>{let a=p=>{requestAnimationFrame(()=>{this.messageToHost(new Z(e.handlerUniqueId,L(p,e.serializableSkeleton)))})};s.addEventListener(e.type,a),i.push(()=>{s.removeEventListener(e.type,a)})}),()=>{i.forEach(s=>{s()})}})}};var Je=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{i.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 i=this.messageHandlers[n],s=a=>e(a)?(t(a),!0):!1;return i.push(s),()=>{let a=i.indexOf(s);a>-1&&i.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 i=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&(this._whenInitiatedReject("timeout_".concat(i," ").concat(this.id)),this.dispose())},i),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get uiTags(){var n;return((n=this.componentDefinition)==null?void 0:n.uiTags)||[]}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(i=>{t=t||i(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=S.down;let e=this.bindWhen(n.replyMessageKey,i=>i.replayToHandler===n.handlerUniqueId,i=>{n.handler(i),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=S.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,i=>i.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,i){super(e,t.container,i);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,i=super.send(e);return this.parent.send(new ve(this.id,e)),e.handler=t,i});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,i,s,a,p){super(e,i,p);this.container=i;this.customElement=s;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,"_autoSizeOptions");r(this,"observeAutoSize",e=>{this._autoSizeOptions=e;let t=this.customElement;try{getComputedStyle(t).display==="inline"&&(t.style.display="block")}catch(d){}let i=d=>{if(d===void 0)return;if(typeof d=="number")return d;let c=parseFloat(d);return isNaN(c)?void 0:c},s=(d,c,m)=>c!==void 0&&d<c?c:m!==void 0&&d>m?m:d,a=()=>{var u;let d=this._autoSizeOptions,c=t.getBoundingClientRect(),m=(d==null?void 0:d.explicitHeight)===void 0;(u=d==null?void 0:d.onSizeChange)==null||u.call(d,{width:c.width,height:m?s(c.height,i(d==null?void 0:d.minHeight),i(d==null?void 0:d.maxHeight)):c.height,autoSizingWidth:!1,autoSizingHeight:m})},p;try{p=new ResizeObserver(()=>a()),p.observe(t)}catch(d){}return a(),()=>{p==null||p.disconnect(),this._autoSizeOptions=void 0}});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=s,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=be(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(i=>{this.markedForDisposed||e(i.action,i.payload)})}}};var lo=(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},be=(o,n,e,t,i,s)=>{let a=lo("".concat(s.name," : ").concat(n),e,s);return t.insertBefore(a,i),i.style.border="1px solid #007BFF",i.style.display="block",()=>{i.style.border="unset",t.removeChild(a)}},Sn=(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),vn=(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((s,a)=>z(h({},s),{[a.name]:h({},a)}),{}),i={get:(s,a)=>{let p=t[a];if(Sn(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 V&&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 vn(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=Ke[p.behavior.message];o.send(new m(...c))}):null},set:(s,a,p)=>{let d=t[a];if(Sn(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 V&&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 vn(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=Ke[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,i),o},mo=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...s)=>new Promise(a=>{s.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:s},p=>{a(p.content)}))})},set(e,t,i){return n.send(new X(({ref:s,propName:a,propValue:p})=>{s&&(s[a]=p)},{elementId:e.refConfig.selector,propValue:i,propName:t},s=>{})),!0}}),Ft=async(o,n,e,t)=>{let i=o.component;if(!i)throw new Error("cant createRefComponent with detached ref");return new Promise(async(s,a)=>{let p=new Be(n.type,i,t);e.push(p);let d=()=>{let m=e.indexOf(p);m!==-1&&e.splice(m,1)};await i.initiated();let c=setTimeout(()=>{d(),a("timeout")},5e3);i.send(new Se(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(),i.refs[o.refConfig.name]=u,s(u);return}else p.setInitiated(),i.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),i.setHeightBasedOnScrollHeight&&i.setHeightBasedOnScrollHeight(),s(p)}catch(f){a(f)}}))})},Wt=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let i=Object.values(o.componentDefinition.refs).map(s=>new Promise(async(a,p)=>{var d;if(s.behavior.type==ge.component){if(t){a();return}let c=s.behavior.componentId;c||(c=s.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("",s,o);try{let f=await Ft(u,m,e);o.refs[s.name]=f,a()}catch(f){p(f)}}else try{let c=j.create("",s,o);o.refs[s.name]=mo(c,o),a()}catch(c){}}));try{await Promise.all(i)}catch(s){throw s}};var V=class extends F{constructor(e,t,i,s,a){super(e,i,a);this.componentConfig=e;this.container=i;this.IframeElement=s;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:i,width:s}=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:i,width:s}},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,i=t.contentDocument;if(!i)return this.observeHeightViaBridge();let s=(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),q=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,I=(tn=(en=l==null?void 0:l.explicitWidth)!=null?en:Y)!=null?tn:"100%",C=(nn=l==null?void 0:l.explicitHeight)!=null?nn:P,_=I!==void 0,de=C!==void 0,ce=this.container.getBoundingClientRect(),Un=ce.width===0,Vn=ce.height===0||ce.height===pe,le=(l!=null&&l.forceAutoSize||Un)&&!_,me=(l!=null&&l.forceAutoSize||Vn)&&!de;if(!le&&!me){t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(on=l==null?void 0:l.onSizeChange)==null||on.call(l,{width:typeof I=="number"?I:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let qn=t.style.transition,K=this.container,jn=K.style.transition;t.style.transition="none",K.style.transition="none";let Vt=t.getBoundingClientRect().height,qt=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)),we=Gt,Ie=jt,Gn=me&&jt>Vt+1,Yn=le&&Gt>qt+1,Ae=me&&!Gn,$e=le&&!Yn;if(Ae||$e){let Xn=K.style.minHeight,Zn=K.style.minWidth;Ae&&(K.style.minHeight="".concat(Vt,"px")),$e&&(K.style.minWidth="".concat(qt,"px")),Ae&&(t.style.height="0px"),$e&&(t.style.width="0px"),we=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),Ie=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height));let rn=Ae&&Ie<2,an=$e&&we<2;if(rn||an){let Fe=g.createElement("style");Fe.id="__myop_measure";let St=[];rn&&St.push("height: auto !important","min-height: 0 !important","max-height: none !important"),an&&St.push("width: auto !important","min-width: 0 !important","max-width: none !important"),Fe.textContent="*, *::before, *::after { ".concat(St.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),g.head.appendChild(Fe),we=Math.ceil(Math.max(g.documentElement.scrollWidth,g.body.scrollWidth,g.body.getBoundingClientRect().width)),Ie=Math.ceil(Math.max(g.documentElement.scrollHeight,g.body.scrollHeight,g.body.getBoundingClientRect().height)),Fe.remove()}K.style.minHeight=Xn,K.style.minWidth=Zn}let Yt=s(we,R,k),Qt=s(Ie,q,T);le?t.style.width="".concat(Yt,"px"):t.style.width=typeof I=="number"?"".concat(I,"px"):"100%",me?t.style.height="".concat(Qt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=qn,K.style.transition=jn;let Qn=le&&k!==void 0&&we>k,Jn=me&&T!==void 0&&Ie>T;g.documentElement.style.overflowX=Qn?"auto":"",g.documentElement.style.overflowY=Jn?"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(i.body),m.observe(i.documentElement);let u=new MutationObserver(()=>c());u.observe(i.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,i=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=i,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(s=>{console.warn("[MyopIframeComponent] auto-height skipped for ".concat(this.id,": ").concat(s))}),i});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new B(()=>{let{height:t,width:i}=document.documentElement.getBoundingClientRect();return{height:t,width:i}},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 i=0;return i++,i--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+i+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var s,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=S.down;let i=super.send(t);return(a=(s=this.IframeElement)==null?void 0:s.contentWindow)==null||a.postMessage(t,"*"),i});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,i;this._lastData=e,(i=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||i.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(i=>{this.markedForDisposed||e(i.action,i.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let i=this._isoSizeOpts,s=m=>m===void 0?void 0:typeof m=="number"?m:isNaN(parseFloat(m))?void 0:parseFloat(m),a=s(i==null?void 0:i.minHeight),p=s(i==null?void 0:i.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=i==null?void 0:i.onSizeChange)==null||c.call(i,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=be(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 i;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let s=(i=t.relative.child)==null?void 0:i.nextSibling;return n.insertBefore(e,s||null)}}else return n.appendChild(e)})}};var uo=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},fo=(o,n)=>{let e=o.getAttribute("src");if(!e||!n)return!1;let t=i=>{let s=new URL(i,document.baseURI);return s.hash="",s.pathname.length>1&&(s.pathname=s.pathname.replace(/\/$/,"")),s.href};try{return t(e)===t(n)}catch(i){return!1}},Xe=class extends G{constructor(){super(...arguments);r(this,"type",U.IframeLoader);r(this,"load",async(e,t,i,s)=>{let a,p=t.loader;if((i==null?void 0:i.nodeName)==="IFRAME")a=i,fo(a,p.url)||(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(s!=null&&s.hidden?"0":"1",";\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n ");a.style.cssText=u,s!=null&&s.elementAttributes&&Object.entries(s.elementAttributes).forEach(([g,l])=>{l===""||l===null||l===void 0?a.setAttribute(g,""):a.setAttribute(g,String(l))});let f=t.loader.url;s!=null&&s._hasParent&&(f=uo(f,"_myop-comp",c)),a.src=f,i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),a=this.appendChild(i,a,s)}let d=new V(e,t,i,a,s);return p.autoHeight&&(s==null?void 0:s.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var Ze={webcomponent_message_key:"myop_webcomponent_message"};var Ce=class extends F{constructor(e,t,i,s,a){super(e,i,a);this.container=i;this.customElement=s;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),i=super.send(t),s=new CustomEvent(Ze.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(s)}catch(a){console.log("error while trying to dispatchEvent",a)}return i});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=s}inspect(){return this.cleanupInspect=be(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={},et=class extends G{constructor(){super(...arguments);r(this,"type",U.WebComponentLoader);r(this,"load",async(e,t,i,s)=>{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 i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),d.id=p,s!=null&&s.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"),s!=null&&s._environment&&(d._myopEnvironment=s==null?void 0:s._environment),this.appendChild(i,d,s),new Ce(e,t,i,d,s)})}};var tt="0.4.0-beta.6";var go="myop-delivery",st="components";var nt=null;function yo(){return nt||(nt=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(go,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(st)||e.createObjectStore(st,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),nt)}function ot(o,n){return yo().then(e=>new Promise(t=>{if(!e)return t(null);try{let i=e.transaction(st,o),s=n(i.objectStore(st));s.onsuccess=()=>t(s.result),s.onerror=()=>t(null),i.onabort=()=>t(null)}catch(i){t(null)}}))}var Nt="myop.d.";function Tn(o,n,e){try{localStorage.setItem(Nt+o,JSON.stringify({t:n,e}))}catch(t){}}function ho(o){try{localStorage.removeItem(Nt+o)}catch(n){}}var Le=new Map,A={key(o,n,e,t,i){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(i||"raw")},async get(o){let n=Le.get(o);if(n)return n;let e=await ot("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 ot("readwrite",n=>n.put(o))},async drop(o){Le.delete(o),ho(o),await ot("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]),i=Number(o.get("age")||0);return Math.max(0,t-(isNaN(i)?0:i))*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 ot("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,uiTags:Array.isArray(o.uiTags)?o.uiTags:[]},name:o.name}),it="__MYOP_CLOUD_REPOSITORY_MAIN__",Mo=()=>{if(typeof window<"u")return window[it];if(typeof globalThis<"u")return globalThis[it]},bo=o=>{typeof window<"u"&&(window[it]=o),typeof globalThis<"u"&&(globalThis[it]=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,flow:!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);r(this,"_hydratedV1",new Set)}static get Main(){let n=Mo();return n||($._main||($._main=new $,bo($._main)),$._main)}static sizeOfHeld(n){var e,t,i,s,a;try{return(((a=(s=(i=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:i[0])==null?void 0:s.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),n.flow!==void 0&&(this._delivery.flow=!!n.flow)}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,flow:this._delivery.flow})}async refreshDelivery(){await A.clear()}noteLocalServe(n,e,t){let i=t?"".concat(n,":").concat(t):n,s=this._localServes.get(i);s?s.count++:this._localServes.set(i,{id:n,env:e,count:1,source:t}),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])=>"".concat(e.id,":").concat(e.env,":").concat(e.count).concat(e.source?":"+e.source:"")).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 s;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let i=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!i)return i&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!i)throw a;this._deliveryStats.lastError=String((s=a==null?void 0:a.message)!=null?s: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:i,usePreview:s,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:i,usePreview:s,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:i,preview:s}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let q=s?"preview":i;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(q,".json");let T=new URLSearchParams(this._queryParams).toString();T&&(c+="?".concat(T))}else c="/consume?id=".concat(n,"&env=").concat(i),s&&(c+="&preview=true"),this._delivery.minify&&!s&&(c+="&opt=min");let m=this._delivery.cache&&!this._staticMode&&!s,u=m?A.key(this.deliveryHost(),n,i,s,this._delivery.minify?"min":"raw"):"",f=m?await A.get(u):null;if(f&&A.fresh(f)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,i),this.variants[a].resolved=f.config,p(f.config);return}if(f&&f.tag){let q="/consume?ids=".concat(n,"&env=").concat(i)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(f.tag));this._deliveryStats.revalidations++;try{let T=await this.deliveryFetch(q);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(i,'"')));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 s;let{cacheKey:i}=this.resolveParams(n,e,t);return((s=this.variants[i])==null?void 0:s.resolved)||null}getComponentTags(n,e,t){var i,s;return((s=(i=this.getResolvedConfig(n,e,t))==null?void 0:i.type)==null?void 0:s.uiTags)||[]}resolveParams(n,e,t){let i=this.preloadedComponents[n],s=e!==void 0||t!==void 0,a,p;if(!s&&i)a=i.env,p=i.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,i){let{env:s,usePreview:a,cacheKey:p}=this.resolveParams(n,t,i),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:s,preview:a}}hydrateV1Component(n,e){var i,s;let t=(i=e==null?void 0:e.item)!=null?i:e;if(!((s=t==null?void 0:t.components)!=null&&s.length))throw new Error("hydrateV1Component(".concat(n,"): not a /flow?auto=true response"));this.userFlows[n]=Promise.resolve(t),this._hydratedV1.add(n)}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(i=>i.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this._hydratedV1.delete(n)&&this.noteLocalServe(n,"v1_auto_flow","h"),this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i="/flow?id=".concat(n,"&auto=true"),a=await(this._delivery.flow&&this._delivery.host?await this.deliveryFetch(i):await fetch("".concat(this._baseUrl).concat(i))).json();e(a.item)}catch(i){delete this.userFlows[n],t(i)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let s=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(s.item)}catch(i){delete this.userFlows[n],t(i)}})),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 Pe=ae.Main;var Co="https://delivery.myop.dev",Rn=(o={})=>{var e,t,i;let n=o.minify!==!1||o.cache===!0||o.flow===!0;return Pe.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,flow:(i=o.flow)!=null?i:!1,host:o.host!==void 0?o.host:n?Co:null}),Oe()},Hn=async()=>(await Pe.refreshDelivery(),Oe()),Oe=()=>Pe.deliveryStats(),kn=()=>(Pe.setDelivery({minify:!1,cache:!1,flow:!1,host:null}),Oe());var Dn=o=>{for(let[n,e]of Object.entries(o))Pe.hydrateV1Component(n,e)};var x=class extends We{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 i=(s,a)=>{this.messageToHost(z(h({},s),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,i)}else debugger}else debugger})}};var rt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,i)=>{let s=w(e.ref,t.shadowRoot),a=[];return s.forEach(p=>{let d=()=>{i(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)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.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 i=t.shadowRoot.querySelectorAll("[".concat(H.id,"]")),s=[];i.forEach(a=>{let p=a.getAttribute(H.id);p&&s.push(new ue(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new oe(e.handlerUniqueId,s))});r(this,"messageType",y.DetectMyopRefsMessage)}};var ct=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.setAttribute(e.name,e.value)})})}};var lt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,i)=>{let s=w(e.ref,t.shadowRoot),a=[];return s.forEach(p=>{let d=c=>{i(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,i)=>{(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})}),i(new N(e.handlerUniqueId,u))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new N(e.handlerUniqueId,[],!0));debugger}})().then()})}};var ut=class extends x{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,i)=>{je(e,a=>{i(new J(e.handlerUniqueId,a))},t)})}};var Bn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),i=-1;return t.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(H.id),p=s.getAttribute("name"),d={id:s.id,name:p,value:Bn(s),required:s.required,validity:L(s.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},ft=class extends x{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,i)=>{w(e.ref,t.shadowRoot).forEach(a=>{i(new ee(Bn(a)),e)})})}};var gt=class extends x{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{w(e.ref,t.shadowRoot).forEach(s=>{s.innerHTML=e.content})})}};var ze=class extends fe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener(Ze.webcomponent_message_key,i=>{let s=i.data?i.data:i.detail;if(!s||!s.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=s;if(this.handleIncomeMessages(i),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=S.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 ut(this.messageToHost,this.components),new ft(this.messageToHost,this.components),new mt(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Me("WebComponentSDK",ze);var Ln="";var wo="<!-- myop-web-component -->",On="myop-web-component",zn=new Map,An=[],yt,$n=async()=>(yt||(yt=new ze,yt.init()),yt);function Io(o,n){return class extends HTMLElement{connectedCallback(){let e=n===se.open?"open":"closed",t=this.attachShadow({mode:e});$n().then(i=>{i.connectedCallback(this,t),t.innerHTML=o})}}}var xo=(o,n,e)=>{customElements.define(o,Io(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},So=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),vo=o=>(o=So(o),o.replace(/_/g,"-"));var ht=class extends G{constructor(){super(...arguments);r(this,"type",U.HTMLLoader);r(this,"load",async(e,t,i,s)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,s);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,i,a.HTML,s)}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(s!=null&&s.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(s!=null&&s.hidden?"none":"all",";\n "),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),l=this.appendChild(i,l,s);let R=[],k=c?{open(){},writeln(I){R.push(I)},close(){l.srcdoc=R.join("\n")}}:(()=>{let I=l.contentDocument||l.contentWindow.document;return I.open(),I})(),q=null;{let _=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(_)try{q=JSON.parse(_.getAttribute("content")||"{}")}catch(de){}}let T=a.HTML;if(s!=null&&s._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),_=C.getElementById("myop_preview");_==null||_.removeAttribute("type");let de=C.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&&C.head&&C.head.insertBefore(C.importNode(ce,!0),C.head.firstChild),T="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((s==null?void 0:s.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),_=C.getElementById("myop_preview");_&&(_.remove(),T="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(s!=null&&s.injectCss){let C=new DOMParser().parseFromString(T,"text/html"),_=C.createElement("style");_.setAttribute("data-myop-injected","true"),_.textContent=s.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(_),T="<!DOCTYPE html>"+C.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&&(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null){let I="<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>",C=JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"),_='<script id="__myop_init_data_script">\n (function() {\n var data = '.concat(C,";\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(I+_)}if(c){let I=(s==null?void 0:s.data)!==void 0&&(s==null?void 0:s.data)!==null?JSON.stringify(s.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";k.writeln(this.buildIsolationBridge(I))}k.close();let P=new V(e,t,i,l,s);return c&&P.enableIsolation(),P.sizeMeta=q,P.initiated().then(()=>{if((s==null?void 0:s.autoSize)===!1)return;let I=!1;P.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!I&&!(s!=null&&s.hidden)&&(I=!0,P.show())}})}),P}if(a.shadowRootMode===se.none){let f=document.createElement("template");f.innerHTML=a.HTML,u=f.content.firstElementChild,$n().then(g=>{g.connectedCallback(u,u)})}else{let f=vo(e.name+t.id);An.includes(f)||(xo(f,a.HTML,a.shadowRootMode),An.push(f)),u=document.createElement(f)}return i.querySelector('[id^="myop-comp-"]')||(i.innerHTML=""),u.id=m,s!=null&&s.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(i,u,s),new Ce(e,t,i,u,s)})}isMyopWebComponent(e){return e.trimStart().startsWith(wo)?!0:new RegExp("<script[^>]*\\sid=[\"']?".concat(On,"[\"'\\s>]"),"i").test(e)}async resolveRenderMode(e,t,i,s,a){var m,u,f,g;let p=s?"webComponent":i.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:s}):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 s=new DOMParser().parseFromString(e,"text/html").getElementById(On);return(s==null?void 0:s.textContent)||null}executeWebComponentScript(e,t){let i=zn.get(t);if(i)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(i,">")),i;let s=document.createElement("script");s.textContent=e,s.id="myop-extracted-".concat(t),document.head.appendChild(s);let a=window.__MYOP_TAG_NAME__;return a&&zn.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,i,s,a){let p=this.extractWebComponentScript(s);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"),i.querySelector('[id^="myop-comp-"]')||(i.innerHTML="");let f=new re(e,t,i,u,c,a);return this.appendChild(i,u,a),(a==null?void 0:a.data)!==void 0&&(a==null?void 0:a.data)!==null&&f.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),f}};var Fn=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[i,...s]=Et(t);switch(i){case"component":{let[a,p]=s,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)===Ne.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 Wn="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",tt);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 i=t.element;return(i==null?void 0:i.nodeName)==="IFRAME"&&i.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!==S.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){let s=this.components2init.filter(p=>{let d=p.element;return(d==null?void 0:d.nodeName)==="IFRAME"&&d.contentWindow===n.source});(s.length?s: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 s=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});s==null||s.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let s=t,a=this.components.find(p=>p.id===s.destination);if(a){if(s.direction===S.down){s.message.messageType===O.name?a.onMessageReceived(s.message):(s.message.route=s.route,a.send(s.message));return}}else{let p=this.components.find(d=>d.id===s.message.destination);p&&p.send(s.message)}return}let i=this.components.find(s=>s.id===t.destination);if(!i){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(i){if(i.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 Xe,new et,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 i=new t(this.componentsLoaders);e[i.type]=i}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var s;async function i(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case ie.Dedicated:return((s=n.skin)==null?void 0:s.id)||n.skins[0].id;case ie.Segmented:{let p=await i(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(g=>g.type===Ne.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(i=>i.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 i=await Fn(n);i&&(n=i);let s=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,s);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,s);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 i=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(i),i.show(),n.dispose(),i}else{let i=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:i}},t))}})}};r(W,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Wn});if(!window.myop.hostSDK){let o=new W;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:Wn}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>Rn(n);o.stats=Oe,o.off=kn,o.refresh=Hn,window.myop.delivery=o}window.myop&&!window.myop.hydrateV1&&(window.myop.hydrateV1=Dn);var Eo=window.myop.hostSDK;Me("hostSDK",Eo);var Mt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"executor",e=>{(async()=>{let i=document.querySelectorAll("[".concat(H.id,"='").concat(e.refConfig.selector,"']"));if(i.length===1){let a=await W.Instance().loadComponent(e.nestedComponentConfig,i.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 Kn=(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),i={attributes:!0,childList:!0,subtree:!0};return t.observe(o,i),t}else window.addEventListener&&(o.addEventListener("DOMNodeInserted",n,!1),o.addEventListener("DOMNodeRemoved",n,!1))};var bt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetMutationObserverMessage);r(this,"executor",e=>{e.source&&Kn(document.body,()=>{this.messageToHost(new Te)})})}};var Nn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),i=-1;return t.forEach(s=>{if(typeof s.value=="string"){let a=s.getAttribute(H.id),p=s.getAttribute("name"),d={id:s.id,name:p,value:Nn(s),required:s.required,validity:L(s.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},Ct=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"executor",e=>{w(e.ref,document).forEach(i=>{this.messageToHost(new ee(Nn(i)),e)})})}};var wt=class extends M{constructor(){super(...arguments);r(this,"messageType",y.GetAttributeMessage);r(this,"executor",e=>{let t=wn(e.ref,document);t&&this.messageToHost(new Ee(t.getAttribute(e.name)),e)})}};var It=class extends M{constructor(){super(...arguments);r(this,"messageType",y.SetResizeObserverMessage);r(this,"executor",e=>{let t=new ResizeObserver(i=>{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=>{w(e.ref,document).forEach(i=>{i.innerHTML=e.content})})}};var Ut=class extends fe{constructor(){super();r(this,"version",tt);r(this,"messageToHost",(e,t)=>{var s,a;!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId);let i=Object.keys(this.components);e.destination||(t!=null&&t.route?e.destination=t.route[t.route.length-1]:e.destination=i[0]),e.source||(e.source=i[0]),e.direction=S.up,(a=(s=this.hostWindow)!=null?s:window.parent)==null||a.postMessage(h({},e),"*")});r(this,"supportedHandlers",[new qe(this.messageToHost),new xt(this.messageToHost),new Ve(this.messageToHost),new Ue(this.messageToHost),new Ge(this.messageToHost),new Qe(this.messageToHost),new Je(this.messageToHost),new Ct(this.messageToHost),new bt(this.messageToHost),new It(this.messageToHost),new wt(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 i=0;i<32;i++){let s=t.parent;if(!s||s===t)return!1;if(e===s)return!0;t=s}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};
@@ -0,0 +1 @@
1
+ var J=Object.defineProperty,ne=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var Y=Object.getOwnPropertySymbols;var re=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var V=(t,e,s)=>e in t?J(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,C=(t,e)=>{for(var s in e||(e={}))re.call(e,s)&&V(t,s,e[s]);if(Y)for(var s of Y(e))ie.call(e,s)&&V(t,s,e[s]);return t},w=(t,e)=>ne(t,oe(e));var ae=(t,e)=>{for(var s in e)J(t,s,{get:e[s],enumerable:!0})};var o=(t,e,s)=>V(t,typeof e!="symbol"?e+"":e,s);var k="__federation__",Q="onLoad";var X=(t,e)=>{window[k]&&window[k][t]&&window[k][t][Q]&&window[k][t][Q]({[t]:e})};var G={};ae(G,{CloudRepository:()=>x,ComponentConfig:()=>j,DELIVERY_HOST:()=>se,SkinConfig:()=>N,addClass:()=>ue,applyStylesheet:()=>ge,applyStylesheetLink:()=>me,changeSkinUrlByTokenizer:()=>fe,createIframeSkinByTokenizer:()=>Z,delivery:()=>Be,deliveryOff:()=>De,deliveryRefresh:()=>Pe,deliveryStats:()=>$,enableLocalDev:()=>_e,enableSelfHosted:()=>ke,exec:()=>Se,getCloudRepository:()=>Te,getComponentTags:()=>$e,getPreloadedParams:()=>Re,getResolvedConfig:()=>He,hydrateComponents:()=>Oe,hydrateV1Components:()=>Ae,isPreloaded:()=>we,preloadComponents:()=>Fe,removeClass:()=>he,setCloudRepository:()=>Le,setCloudRepositoryUrl:()=>Ee,setEnvironment:()=>Ke,v2_CloudRepository:()=>be});var m=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+t/4).toString(16));var y=class{constructor(){o(this,"id",m());o(this,"myop",!0);o(this,"content");o(this,"source");o(this,"destination");o(this,"route");o(this,"ref");o(this,"direction");o(this,"cleanable",!1)}static create(...e){return new this(...e)}isTypeof(e){return e.messageType===this.messageType}};var f=class extends y{constructor(s){super();this.handler=s;o(this,"handlerUniqueId",m())}};var pe="ExecuteScriptReplyMessage",ce=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,le=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,de=t=>{let e=t.match(ce);if(e)return e[1]||e[3];{let s=t.match(le);if(s)return s[1].trim()}},u=class extends f{constructor(s,n=()=>{},r){super(n);this.scriptInputs=r;o(this,"replyMessageKey",pe);o(this,"messageType","ExecuteScriptMessage");o(this,"script","");this.script=s.toString(),this.content=s.toString(),this.content=de(this.content)}};o(u,"replierKey","send"),o(u,"completeStreamKey","completeStream");var R=class extends u{constructor(s,n,r=()=>{}){super(({rootRef:i,elementId:a,_script:g,__scriptInputs:l})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(l.ref=c[0],new Function("return (".concat(g,")(...arguments)"))(l)):null},r);this.scriptInputs=n;this.scriptInputs=w(C({},n),{_script:s.toString()})}};var ge=(t,e,s)=>{let n="myop-css-".concat(m());return t.send(new u(({rootRef:r,_stylesheet:i,_tagId:a,_css:g})=>{let l=document.createElement("style");l.type="text/css";let c=g;for(let I in i){c+="".concat(I," { ");let S=i[I];for(let d in S)c+="".concat(d,": ").concat(S[d],"; ");c+="} "}l.appendChild(document.createTextNode(c)),l.id=a,(r.shadowRoot||r.container).appendChild(l)},()=>{},{_stylesheet:e,_css:s||"",_tagId:n})),()=>{t.send(new u(({rootRef:r,_tagId:i})=>{let a=(r.shadowRoot||document).getElementById(i);a&&a.remove()},()=>{},{_tagId:n}))}},me=(t,e)=>{let s="myop-css-".concat(m());return t.send(new u(({rootRef:n,_tagId:r,_link:i})=>{let a=document.createElement("link");a.id=r,a.rel="stylesheet",a.href=i,document.head.appendChild(a),(n.shadowRoot||n.container).appendChild(a)},()=>{},{_link:e,_tagId:s})),()=>{t.send(new u(({rootRef:n,_tagId:r})=>{let i=(n.shadowRoot||document).getElementById(r);i&&i.remove()},()=>{},{_tagId:s}))}};var ye=(t,e)=>{let s=new RegExp(Object.keys(e).join("|"),"g");return t.replace(s,n=>(e[n]||n).toString())},Z=(t,e)=>{let s=t.loader;if(s.type!=="IframeLoader")throw new Error('iframeSkinUrlTokenizer received skin with loader type "'.concat(s.type,'", currently only "IframeLoader" is supported'));return t.loader=C({},t.loader),t.loader.url=ye(t.loader.url,e),t},fe=t=>async e=>Z(e,t);var ue=(t,e,s)=>{t.send(new R(({ref:n,_className:r})=>{n==null||n.classList.add(r)},{elementId:s,_className:e}))},he=(t,e,s)=>{t.send(new R(({ref:n,_className:r})=>{n==null||n.classList.remove(r)},{elementId:s,_className:e}))};var B=class B{constructor(){o(this,"_runTimeInstanceId","runtime-instance-id-"+m());o(this,"_runTimeId","runtime-id-"+m());o(this,"_runTimeName","runtime-name-"+m());o(this,"id",this._runTimeId);o(this,"name",this._runTimeName);o(this,"description","");o(this,"loader",null);o(this,"withLoader",e=>(this.loader=e,this));o(this,"withHTMLLoader",e=>(e.type="HTMLLoader",this.loader=e,this));o(this,"build",()=>this)}};o(B,"create",()=>new B);var N=B,P=class P{constructor(){o(this,"_runTimeInstanceId","runtime-instance-id-"+m());o(this,"_runTimeId","runtime-id-"+m());o(this,"_runTimeName","runtime-name-"+m());o(this,"instance",{id:this._runTimeInstanceId,componentId:this._runTimeId,componentName:this._runTimeName,skinSelector:null});o(this,"name",this._runTimeName);o(this,"type",{id:this._runTimeId,name:this._runTimeName,description:"",props:[],refs:[],skins:[],defaultSkin:0});o(this,"withInstance",e=>(this.instance=e,this));o(this,"withType",e=>(this.type=e,this));o(this,"withName",e=>(this.name=e,this));o(this,"withDefaultSkin",e=>(this.type.skins.push(e),this.type.defaultSkin=this.type.skins.length-1,this.instance.skinSelector={type:"Dedicated",skin:{id:e.id}},this));o(this,"withRef",e=>(this.type.refs.push(e),this));o(this,"withBasicRef",e=>{let s={id:"",name:e,description:"",selectorType:"id-attribute",selector:e,behavior:{type:"code"}};return this.type.refs.push(s),this});o(this,"build",()=>JSON.parse(JSON.stringify(this)))}};o(P,"create",()=>new P);var j=P;var z={message:"message",code:"code"};var Me="myop-delivery",K="components";var D=null;function xe(){return D||(D=new Promise(t=>{try{if(typeof indexedDB>"u")return t(null);let e=indexedDB.open(Me,1);e.onupgradeneeded=()=>{let s=e.result;s.objectStoreNames.contains(K)||s.createObjectStore(K,{keyPath:"key"})},e.onsuccess=()=>t(e.result),e.onerror=()=>t(null),e.onblocked=()=>t(null)}catch(e){t(null)}}),D)}function L(t,e){return xe().then(s=>new Promise(n=>{if(!s)return n(null);try{let r=s.transaction(K,t),i=e(r.objectStore(K));i.onsuccess=()=>n(i.result),i.onerror=()=>n(null),r.onabort=()=>n(null)}catch(r){n(null)}}))}var q="myop.d.";function ee(t,e,s){try{localStorage.setItem(q+t,JSON.stringify({t:e,e:s}))}catch(n){}}function ve(t){try{localStorage.removeItem(q+t)}catch(e){}}var _=new Map,h={key(t,e,s,n,r){return"".concat(t,"|").concat(e,"|").concat(s,"|").concat(n?"preview":"live","|").concat(r||"raw")},async get(t){let e=_.get(t);if(e)return e;let s=await L("readonly",n=>n.get(t));return s&&(_.set(t,s),ee(t,s.tag,s.storedAt+s.windowMs)),s},async put(t){_.set(t.key,t),ee(t.key,t.tag,t.storedAt+t.windowMs),await L("readwrite",e=>e.put(t))},async drop(t){_.delete(t),ve(t),await L("readwrite",e=>e.delete(t))},fresh(t){return!!t&&Date.now()-t.storedAt<t.windowMs},windowFrom(t){let e=t.get("cache-control")||"";if(/no-store|no-cache/i.test(e))return 0;let s=/s-maxage\s*=\s*(\d+)/i.exec(e)||/max-age\s*=\s*(\d+)/i.exec(e);if(!s)return 0;let n=Number(s[1]),r=Number(t.get("age")||0);return Math.max(0,n-(isNaN(r)?0:r))*1e3},async clear(){_.clear();try{for(let t=localStorage.length-1;t>=0;t--){let e=localStorage.key(t);e&&e.startsWith(q)&&localStorage.removeItem(e)}}catch(t){}await L("readwrite",t=>t.clear())}};var te=t=>({instance:{id:"auto",componentId:t.componentId,componentName:t.name,skinSelector:{type:"Dedicated",skin:{id:"skin_auto_v2_converted"}}},type:{id:t.id,name:t.name,description:t.description,props:[{id:"in_auto_v2_converted",name:"myop_init_interface",type:"any",behavior:{type:z.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:z.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:t.consume_variant[0].loader}],defaultSkin:0,uiTags:Array.isArray(t.uiTags)?t.uiTags:[]},name:t.name}),H="__MYOP_CLOUD_REPOSITORY_MAIN__",Ie=()=>{if(typeof window<"u")return window[H];if(typeof globalThis<"u")return globalThis[H]},Ce=t=>{typeof window<"u"&&(window[H]=t),typeof globalThis<"u"&&(globalThis[H]=t)},M=class M{constructor(e="https://cloud.myop.dev"){this._baseUrl=e;o(this,"variants",{});o(this,"preloadedComponents",{});o(this,"userFlows",{});o(this,"_defaultEnv","production");o(this,"_envExplicitlySet",!1);o(this,"_staticMode",!1);o(this,"_queryParams",{});o(this,"_delivery",{minify:!1,host:null,cache:!1,flow:!1});o(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});o(this,"_localServes",new Map);o(this,"_flushBound",!1);o(this,"_hydratedV1",new Set)}static get Main(){let e=Ie();return e||(M._main||(M._main=new M,Ce(M._main)),M._main)}static sizeOfHeld(e){var s,n,r,i,a;try{return(((a=(i=(r=(n=(s=e==null?void 0:e.config)==null?void 0:s.type)==null?void 0:n.skins)==null?void 0:r[0])==null?void 0:i.loader)==null?void 0:a.HTML)||"").length}catch(g){return 0}}setDelivery(e={}){e.minify!==void 0&&(this._delivery.minify=!!e.minify),e.host!==void 0&&(this._delivery.host=e.host),e.cache!==void 0&&(this._delivery.cache=!!e.cache),e.flow!==void 0&&(this._delivery.flow=!!e.flow)}deliveryStats(){var e;return w(C({},this._deliveryStats),{host:(e=this._delivery.host)!=null?e:M.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache,flow:this._delivery.flow})}async refreshDelivery(){await h.clear()}noteLocalServe(e,s,n){let r=n?"".concat(e,":").concat(n):e,i=this._localServes.get(r);i?i.count++:this._localServes.set(r,{id:e,env:s,count:1,source:n}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let e=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",e),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let e=[...this._localServes.entries()].map(([,s])=>"".concat(s.id,":").concat(s.env,":").concat(s.count).concat(s.source?":"+s.source:"")).join(",");this._localServes.clear();try{let s="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(e));fetch(s,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(s){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(e){var i;this._localServes.size&&this.flushLocalServes();let s=this.deliveryHost(),n="".concat(s).concat(e);this._deliveryStats.requests++;let r=s!==this._baseUrl;try{let a=await fetch(n);if(a.ok||a.status<500||!r)return r&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(s)}catch(a){if(!r)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(e))}enableStaticMode(){this._staticMode=!0}setQueryParams(e){this._queryParams=e}setEnvironment(e){this._defaultEnv=e,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(e,s,n){return s!==void 0||n!==void 0?"".concat(e,":").concat(s||this._defaultEnv,":").concat(n?"preview":"live")in this.variants:e in this.preloadedComponents}getPreloadedParams(e){return this.preloadedComponents[e]}async resolveComponent(e,s,n){return this.fetchComponentV2(e,s,n)}async fetchComponentV2(e,s,n){let{env:r,usePreview:i,cacheKey:a}=this.resolveParams(e,s,n);return console.log("[CloudRepository] fetchComponentV2",{componentId:e.slice(0,8)+"...",env:r,usePreview:i,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[e]||(this.preloadedComponents[e]={env:r,preview:i}),this.variants[a]=new Promise(async(g,l)=>{try{let c;if(this._staticMode){let O=i?"preview":r;c="".concat(this._baseUrl,"/components/").concat(e,"/").concat(O,".json");let v=new URLSearchParams(this._queryParams).toString();v&&(c+="?".concat(v))}else c="/consume?id=".concat(e,"&env=").concat(r),i&&(c+="&preview=true"),this._delivery.minify&&!i&&(c+="&opt=min");let I=this._delivery.cache&&!this._staticMode&&!i,S=I?h.key(this.deliveryHost(),e,r,i,this._delivery.minify?"min":"raw"):"",d=I?await h.get(S):null;if(d&&h.fresh(d)){this._deliveryStats.fromStorage++,this.noteLocalServe(e,r),this.variants[a].resolved=d.config,g(d.config);return}if(d&&d.tag){let O="/consume?ids=".concat(e,"&env=").concat(r)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(d.tag));this._deliveryStats.revalidations++;try{let v=await this.deliveryFetch(O);if(v.ok){let W=await v.json();if((W.unchanged||[]).includes(e)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=M.sizeOfHeld(d),d.storedAt=Date.now(),d.windowMs=h.windowFrom(v.headers)||d.windowMs,await h.put(d),this.variants[a].resolved=d.config,g(d.config);return}let A=(W.items||[])[0];if(A){let U=te(A);this._deliveryStats.fromNetwork++,await h.put({key:S,config:U,tag:A.tag||null,storedAt:Date.now(),windowMs:h.windowFrom(v.headers),host:this.deliveryHost()}),this.variants[a].resolved=U,g(U);return}}}catch(v){}}let E=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!E.ok){l(new Error('Failed to load component "'.concat(e,'" (').concat(E.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let T=(await E.json()).item;if(!T){l(new Error('Component "'.concat(e,'" not found')));return}if(!T.consume_variant||!T.consume_variant.length){l(new Error('Component "'.concat(e,'" has no implementation for environment "').concat(r,'"')));return}let F=te(T);this._deliveryStats.fromNetwork++,I&&await h.put({key:S,config:F,tag:T.tag||null,storedAt:Date.now(),windowMs:h.windowFrom(E.headers),host:this.deliveryHost()}),this.variants[a].resolved=F,g(F)}catch(c){delete this.variants[a],l(c)}})),await this.variants[a]}getResolvedConfig(e,s,n){var i;let{cacheKey:r}=this.resolveParams(e,s,n);return((i=this.variants[r])==null?void 0:i.resolved)||null}getComponentTags(e,s,n){var r,i;return((i=(r=this.getResolvedConfig(e,s,n))==null?void 0:r.type)==null?void 0:i.uiTags)||[]}resolveParams(e,s,n){let r=this.preloadedComponents[e],i=s!==void 0||n!==void 0,a,g;if(!i&&r)a=r.env,g=r.preview;else{a=s||this._defaultEnv;let l=s||this._envExplicitlySet;g=n===!0?!0:n===!1?!1:!l}return{env:a,usePreview:g,cacheKey:"".concat(e,":").concat(a,":").concat(g?"preview":"live")}}hydrateComponent(e,s,n,r){let{env:i,usePreview:a,cacheKey:g}=this.resolveParams(e,n,r),l=Promise.resolve(s);l.resolved=s,this.variants[g]=l,this.preloadedComponents[e]={env:i,preview:a}}hydrateV1Component(e,s){var r,i;let n=(r=s==null?void 0:s.item)!=null?r:s;if(!((i=n==null?void 0:n.components)!=null&&i.length))throw new Error("hydrateV1Component(".concat(e,"): not a /flow?auto=true response"));this.userFlows[e]=Promise.resolve(n),this._hydratedV1.add(e)}async fetchComponentV1(e,s){return s?(await this.fetchFlow(s)).components.find(r=>r.type.id===e):(await this.fetchAutoFlow(e)).components[0]}async fetchAutoFlow(e){return this._hydratedV1.delete(e)&&this.noteLocalServe(e,"v1_auto_flow","h"),this.userFlows[e]||(this.userFlows[e]=new Promise(async(s,n)=>{try{let r="/flow?id=".concat(e,"&auto=true"),a=await(this._delivery.flow&&this._delivery.host?await this.deliveryFetch(r):await fetch("".concat(this._baseUrl).concat(r))).json();s(a.item)}catch(r){delete this.userFlows[e],n(r)}})),await this.userFlows[e]}async fetchFlow(e){return this.userFlows[e]||(this.userFlows[e]=new Promise(async(s,n)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(e,"&resolve=components"))).json();s(i.item)}catch(r){delete this.userFlows[e],n(r)}})),await this.userFlows[e]}async fetchComponent(e,s){return this.fetchComponentV1(e,s)}};o(M,"_main",null),o(M,"DEFAULT_HOST","https://cloud.myop.dev");var x=M,be=x;var Se=async t=>await t();var p=x.Main,Te=()=>p,we=(t,e,s)=>p.isPreloaded(t,e,s),Re=t=>p.getPreloadedParams(t),_e=()=>{p=new x("http://localhost:9292")},Ee=t=>{p=new x(t)},ke=(t,e)=>{p=new x(t),p.enableStaticMode(),e&&p.setQueryParams(e)},se="https://delivery.myop.dev",Be=(t={})=>{var s,n,r;let e=t.minify!==!1||t.cache===!0||t.flow===!0;return p.setDelivery({minify:(s=t.minify)!=null?s:!1,cache:(n=t.cache)!=null?n:!1,flow:(r=t.flow)!=null?r:!1,host:t.host!==void 0?t.host:e?se:null}),$()},Pe=async()=>(await p.refreshDelivery(),$()),$=()=>p.deliveryStats(),De=()=>(p.setDelivery({minify:!1,cache:!1,flow:!1,host:null}),$()),Le=t=>{p=t},Ke=t=>{p.setEnvironment(t)},He=(t,e,s)=>p.getResolvedConfig(t,e,s),$e=(t,e,s)=>p.getComponentTags(t,e,s),Fe=async(t,e,s)=>Promise.allSettled(t.map(n=>p.fetchComponentV2(n,e,s))),Oe=(t,e,s)=>{for(let[n,r]of Object.entries(t))p.hydrateComponent(n,r,e,s)},Ae=t=>{for(let[e,s]of Object.entries(t))p.hydrateV1Component(e,s)};X("MyopHelpers",G);export{x as CloudRepository,j as ComponentConfig,se as DELIVERY_HOST,N as SkinConfig,ue as addClass,ge as applyStylesheet,me as applyStylesheetLink,fe as changeSkinUrlByTokenizer,Z as createIframeSkinByTokenizer,Be as delivery,De as deliveryOff,Pe as deliveryRefresh,$ as deliveryStats,_e as enableLocalDev,ke as enableSelfHosted,Se as exec,Te as getCloudRepository,$e as getComponentTags,Re as getPreloadedParams,He as getResolvedConfig,Oe as hydrateComponents,Ae as hydrateV1Components,we as isPreloaded,Fe as preloadComponents,he as removeClass,Le as setCloudRepository,Ee as setCloudRepositoryUrl,Ke as setEnvironment,be as v2_CloudRepository};
@@ -53,9 +53,11 @@ __export(helpers_exports, {
53
53
  enableSelfHosted: () => enableSelfHosted,
54
54
  exec: () => exec,
55
55
  getCloudRepository: () => getCloudRepository,
56
+ getComponentTags: () => getComponentTags,
56
57
  getPreloadedParams: () => getPreloadedParams,
57
58
  getResolvedConfig: () => getResolvedConfig,
58
59
  hydrateComponents: () => hydrateComponents,
60
+ hydrateV1Components: () => hydrateV1Components,
59
61
  isPreloaded: () => isPreloaded,
60
62
  preloadComponents: () => preloadComponents,
61
63
  removeClass: () => removeClass,
@@ -517,7 +519,10 @@ var convertV2VariantToComponentConfig = (config) => {
517
519
  loader: config.consume_variant[0].loader
518
520
  }
519
521
  ],
520
- defaultSkin: 0
522
+ defaultSkin: 0,
523
+ // Only `ui:` tags ever reach the client; the server filters, absent = none.
524
+ // @ts-ignore
525
+ uiTags: Array.isArray(config.uiTags) ? config.uiTags : []
521
526
  },
522
527
  name: config.name
523
528
  };
@@ -559,7 +564,7 @@ var _CloudRepository = class _CloudRepository {
559
564
  * Opt-in delivery settings, set by myop.delivery(). Off means: this file behaves
560
565
  * EXACTLY as it did before — same host, same URL, same everything.
561
566
  */
562
- __publicField(this, "_delivery", { minify: false, host: null, cache: false });
567
+ __publicField(this, "_delivery", { minify: false, host: null, cache: false, flow: false });
563
568
  /**
564
569
  * What actually happened, for myop.delivery.stats(). `fellBack` is the number that
565
570
  * matters: it is how you find out the lane is unhealthy without waiting for a
@@ -594,6 +599,9 @@ var _CloudRepository = class _CloudRepository {
594
599
  */
595
600
  __publicField(this, "_localServes", /* @__PURE__ */ new Map());
596
601
  __publicField(this, "_flushBound", false);
602
+ // ============ V1 Methods (Legacy) ============
603
+ /** ids seeded by hydrateV1Component whose first use has not been counted yet */
604
+ __publicField(this, "_hydratedV1", /* @__PURE__ */ new Set());
597
605
  }
598
606
  static get Main() {
599
607
  const globalMain = getGlobalMain();
@@ -629,32 +637,46 @@ var _CloudRepository = class _CloudRepository {
629
637
  * Deliberately mutates THIS instance rather than constructing a new repository:
630
638
  * CloudRepository.Main is a global singleton shared across bundles (see getGlobalMain),
631
639
  * so a second instance would be ignored by every component already using the first.
640
+ *
641
+ * @internal
632
642
  */
633
643
  setDelivery(opts = {}) {
634
644
  if (opts.minify !== void 0) this._delivery.minify = !!opts.minify;
635
645
  if (opts.host !== void 0) this._delivery.host = opts.host;
636
646
  if (opts.cache !== void 0) this._delivery.cache = !!opts.cache;
647
+ if (opts.flow !== void 0) this._delivery.flow = !!opts.flow;
637
648
  }
649
+ /** @internal */
638
650
  deliveryStats() {
639
651
  var _a;
640
652
  return __spreadProps(__spreadValues({}, this._deliveryStats), {
641
653
  host: (_a = this._delivery.host) != null ? _a : _CloudRepository.DEFAULT_HOST,
642
654
  minify: this._delivery.minify,
643
- cache: this._delivery.cache
655
+ cache: this._delivery.cache,
656
+ flow: this._delivery.flow
644
657
  });
645
658
  }
646
659
  /**
647
660
  * Forget what this browser holds, so the next load asks the server.
648
661
  * `refresh()` with no ids drops everything; the counterpart to the window for the case
649
662
  * where a change has to be visible on THIS load — right after someone publishes.
663
+ *
664
+ * @internal
650
665
  */
651
666
  async refreshDelivery() {
652
667
  await deliveryStore.clear();
653
668
  }
654
- noteLocalServe(componentId, env) {
655
- const cur = this._localServes.get(componentId);
669
+ /**
670
+ * `source: 'h'` = the view was served from a config the page's SERVER embedded
671
+ * (hydrateV1Component), not from this browser's cache window. Reported as a 4th batch
672
+ * field (`id:env:n:h`) so our usage data can tell server-rendered views apart; a server
673
+ * that predates it reads the first three fields and counts the view all the same.
674
+ */
675
+ noteLocalServe(componentId, env, source) {
676
+ const key = source ? "".concat(componentId, ":").concat(source) : componentId;
677
+ const cur = this._localServes.get(key);
656
678
  if (cur) cur.count++;
657
- else this._localServes.set(componentId, { env, count: 1 });
679
+ else this._localServes.set(key, { id: componentId, env, count: 1, source });
658
680
  this.bindFlush();
659
681
  }
660
682
  /** Report on page-hide, which is the only event that reliably fires on mobile. */
@@ -674,7 +696,7 @@ var _CloudRepository = class _CloudRepository {
674
696
  */
675
697
  flushLocalServes() {
676
698
  if (!this._localServes.size) return;
677
- const batch = [...this._localServes.entries()].map(([id, v]) => "".concat(id, ":").concat(v.env, ":").concat(v.count)).join(",");
699
+ const batch = [...this._localServes.entries()].map(([, v]) => "".concat(v.id, ":").concat(v.env, ":").concat(v.count).concat(v.source ? ":" + v.source : "")).join(",");
678
700
  this._localServes.clear();
679
701
  try {
680
702
  const url = "".concat(this.deliveryHost(), "/clientUsage?b=").concat(encodeURIComponent(batch));
@@ -723,7 +745,7 @@ var _CloudRepository = class _CloudRepository {
723
745
  /**
724
746
  * Enable static mode for self-hosted component registries.
725
747
  * In static mode, URLs are constructed as file paths instead of query params:
726
- * ${baseUrl}/components/${componentId}/${env}.json
748
+ * `${baseUrl}/components/${componentId}/${env}.json`
727
749
  */
728
750
  enableStaticMode() {
729
751
  this._staticMode = true;
@@ -932,6 +954,14 @@ var _CloudRepository = class _CloudRepository {
932
954
  const { cacheKey } = this.resolveParams(componentId, env, preview);
933
955
  return ((_a = this.variants[cacheKey]) == null ? void 0 : _a.resolved) || null;
934
956
  }
957
+ /**
958
+ * The `ui:` tags of an already-resolved component (`[]` if it has none or is not
959
+ * resolved yet). Synchronous, no request: tags arrive with the component itself.
960
+ */
961
+ getComponentTags(componentId, env, preview) {
962
+ var _a, _b;
963
+ return ((_b = (_a = this.getResolvedConfig(componentId, env, preview)) == null ? void 0 : _a.type) == null ? void 0 : _b.uiTags) || [];
964
+ }
935
965
  /**
936
966
  * Resolve which (env, preview) pair — and therefore which cache key — a call
937
967
  * for `componentId` refers to.
@@ -976,7 +1006,27 @@ var _CloudRepository = class _CloudRepository {
976
1006
  this.variants[cacheKey] = promise;
977
1007
  this.preloadedComponents[componentId] = { env: resolvedEnv, preview: usePreview };
978
1008
  }
979
- // ============ V1 Methods (Legacy) ============
1009
+ /**
1010
+ * Seed a v1 component's config, so `fetchComponentV1(componentId)` answers from memory
1011
+ * with no request. The v1 counterpart of {@link hydrateComponent}.
1012
+ *
1013
+ * `flow` is what `GET /flow?id=<componentId>&auto=true` returns: either the whole body
1014
+ * (`{item: {...}}`) or its `item`. Typical use is a server that fetched it (with
1015
+ * `&prefetch=1`, so the fetch is not counted as a view) and embedded it in the page.
1016
+ *
1017
+ * The view IS counted: the first time the seeded config is used, it is reported through
1018
+ * /clientUsage (flagged `:h`, recorded as deliveryPath 'hydrated'), so hydrating never makes
1019
+ * usage disappear and server-rendered views stay distinguishable.
1020
+ */
1021
+ hydrateV1Component(componentId, flow) {
1022
+ var _a, _b;
1023
+ const item = (_a = flow == null ? void 0 : flow.item) != null ? _a : flow;
1024
+ if (!((_b = item == null ? void 0 : item.components) == null ? void 0 : _b.length)) {
1025
+ throw new Error("hydrateV1Component(".concat(componentId, "): not a /flow?auto=true response"));
1026
+ }
1027
+ this.userFlows[componentId] = Promise.resolve(item);
1028
+ this._hydratedV1.add(componentId);
1029
+ }
980
1030
  /**
981
1031
  * Fetch a v1 component from a flow
982
1032
  */
@@ -990,13 +1040,15 @@ var _CloudRepository = class _CloudRepository {
990
1040
  }
991
1041
  }
992
1042
  async fetchAutoFlow(componentId) {
1043
+ if (this._hydratedV1.delete(componentId)) {
1044
+ this.noteLocalServe(componentId, "v1_auto_flow", "h");
1045
+ }
993
1046
  if (!this.userFlows[componentId]) {
994
1047
  this.userFlows[componentId] = new Promise(
995
1048
  async (resolve, reject) => {
996
1049
  try {
997
- const res = await fetch(
998
- "".concat(this._baseUrl, "/flow?id=").concat(componentId, "&auto=true")
999
- );
1050
+ const path = "/flow?id=".concat(componentId, "&auto=true");
1051
+ const res = this._delivery.flow && this._delivery.host ? await this.deliveryFetch(path) : await fetch("".concat(this._baseUrl).concat(path));
1000
1052
  const json = await res.json();
1001
1053
  resolve(json.item);
1002
1054
  } catch (e) {
@@ -1071,11 +1123,12 @@ var enableSelfHosted = (cdnUrl, queryParams) => {
1071
1123
  };
1072
1124
  var DELIVERY_HOST = "https://delivery.myop.dev";
1073
1125
  var delivery = (opts = {}) => {
1074
- var _a, _b;
1075
- const wantsLane = opts.minify !== false || opts.cache === true;
1126
+ var _a, _b, _c;
1127
+ const wantsLane = opts.minify !== false || opts.cache === true || opts.flow === true;
1076
1128
  _cloudRepository.setDelivery({
1077
1129
  minify: (_a = opts.minify) != null ? _a : false,
1078
1130
  cache: (_b = opts.cache) != null ? _b : false,
1131
+ flow: (_c = opts.flow) != null ? _c : false,
1079
1132
  host: opts.host !== void 0 ? opts.host : wantsLane ? DELIVERY_HOST : null
1080
1133
  });
1081
1134
  return deliveryStats();
@@ -1086,7 +1139,7 @@ var deliveryRefresh = async () => {
1086
1139
  };
1087
1140
  var deliveryStats = () => _cloudRepository.deliveryStats();
1088
1141
  var deliveryOff = () => {
1089
- _cloudRepository.setDelivery({ minify: false, cache: false, host: null });
1142
+ _cloudRepository.setDelivery({ minify: false, cache: false, flow: false, host: null });
1090
1143
  return deliveryStats();
1091
1144
  };
1092
1145
  var setCloudRepository = (repository) => {
@@ -1098,6 +1151,9 @@ var setEnvironment = (env) => {
1098
1151
  var getResolvedConfig = (componentId, env, preview) => {
1099
1152
  return _cloudRepository.getResolvedConfig(componentId, env, preview);
1100
1153
  };
1154
+ var getComponentTags = (componentId, env, preview) => {
1155
+ return _cloudRepository.getComponentTags(componentId, env, preview);
1156
+ };
1101
1157
  var preloadComponents = async (ids, env, preview) => {
1102
1158
  return Promise.allSettled(
1103
1159
  ids.map((id) => _cloudRepository.fetchComponentV2(id, env, preview))
@@ -1108,6 +1164,11 @@ var hydrateComponents = (configs, env, preview) => {
1108
1164
  _cloudRepository.hydrateComponent(id, config, env, preview);
1109
1165
  }
1110
1166
  };
1167
+ var hydrateV1Components = (flows) => {
1168
+ for (const [id, flow] of Object.entries(flows)) {
1169
+ _cloudRepository.hydrateV1Component(id, flow);
1170
+ }
1171
+ };
1111
1172
 
1112
1173
  // src/helpers/MyopHelpers.ts
1113
1174
  defineDynamicImport("MyopHelpers", helpers_exports);
@@ -1129,9 +1190,11 @@ export {
1129
1190
  enableSelfHosted,
1130
1191
  exec,
1131
1192
  getCloudRepository,
1193
+ getComponentTags,
1132
1194
  getPreloadedParams,
1133
1195
  getResolvedConfig,
1134
1196
  hydrateComponents,
1197
+ hydrateV1Components,
1135
1198
  isPreloaded,
1136
1199
  preloadComponents,
1137
1200
  removeClass,