@myop/sdk 0.3.36 → 0.4.0-beta.1

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 (46) hide show
  1. package/dist/bundled-declarations.d.ts +406 -166
  2. package/dist/cjs/{_IframeSDK.3283252f.js → _IframeSDK.158994c9.js} +1325 -915
  3. package/dist/cjs/_IframeSDK.158994c9.js.map +7 -0
  4. package/dist/cjs/_IframeSDK.941e9a62.min.js +1 -0
  5. package/dist/cjs/_MyopHelpers.91004b19.min.js +1 -0
  6. package/dist/cjs/{_MyopHelpers.08d1cf5d.js → _MyopHelpers.efed13e4.js} +362 -2
  7. package/dist/cjs/_MyopHelpers.efed13e4.js.map +7 -0
  8. package/dist/cjs/_WebComponentSDK.5f41b3b7.min.js +1 -0
  9. package/dist/cjs/{_WebComponentSDK.e84be6ea.js → _WebComponentSDK.ca9d238e.js} +893 -486
  10. package/dist/cjs/_WebComponentSDK.ca9d238e.js.map +7 -0
  11. package/dist/cjs/_hostSDK.23c64e1b.min.js +1 -0
  12. package/dist/cjs/{_hostSDK.fa5b3ccf.js → _hostSDK.3c04ba71.js} +1348 -941
  13. package/dist/cjs/_hostSDK.3c04ba71.js.map +7 -0
  14. package/dist/cjs/myop_sdk.js +35 -24
  15. package/dist/cjs/myop_sdk.js.map +2 -2
  16. package/dist/cjs/myop_sdk.min.js +1 -1
  17. package/dist/cjs-bundled/myop_sdk.bundled.js +1820 -1379
  18. package/dist/cjs-bundled/myop_sdk.bundled.js.map +4 -4
  19. package/dist/cjs-bundled/myop_sdk.bundled.min.js +1 -1
  20. package/dist/module/Iframe/index.js +1501 -1079
  21. package/dist/module/Iframe/index.js.map +4 -4
  22. package/dist/module/SDK.d.ts +5 -1
  23. package/dist/module/SDK.js +1974 -1523
  24. package/dist/module/SDK.js.map +4 -4
  25. package/dist/module/embeddedSDK.js +1 -1
  26. package/dist/module/helpers/CloudRepository.d.ts +96 -0
  27. package/dist/module/helpers/cloudRepositoryHelpers.d.ts +99 -0
  28. package/dist/module/helpers/deliveryStore.d.ts +51 -0
  29. package/dist/module/helpers/index.js +370 -3
  30. package/dist/module/helpers/index.js.map +4 -4
  31. package/dist/module/host/components/myopIframeComponent.d.ts +6 -0
  32. package/dist/module/host/embeddedSDK.js +1 -1
  33. package/dist/module/host/hostSDK.d.ts +2 -0
  34. package/dist/module/host/index.js +1516 -1097
  35. package/dist/module/host/index.js.map +4 -4
  36. package/dist/module/webcomponent/index.js +1202 -783
  37. package/dist/module/webcomponent/index.js.map +4 -4
  38. package/package.json +1 -1
  39. package/dist/cjs/_IframeSDK.3283252f.js.map +0 -7
  40. package/dist/cjs/_IframeSDK.652f4774.min.js +0 -1
  41. package/dist/cjs/_MyopHelpers.08d1cf5d.js.map +0 -7
  42. package/dist/cjs/_MyopHelpers.59521d8f.min.js +0 -1
  43. package/dist/cjs/_WebComponentSDK.8fe7c9bf.min.js +0 -1
  44. package/dist/cjs/_WebComponentSDK.e84be6ea.js.map +0 -7
  45. package/dist/cjs/_hostSDK.de2d767e.min.js +0 -1
  46. package/dist/cjs/_hostSDK.fa5b3ccf.js.map +0 -7
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/dynamicImport/defineDynamicImport.ts", "../../src/helpers/index.ts", "../../src/utils/uuid.ts", "../../src/messages/BaseMessage.ts", "../../src/messages/ExecuteScriptMessage.ts", "../../src/messages/CustomRefMessage.ts", "../../src/helpers/applyStylesheet.ts", "../../src/helpers/iframeSkinUrlTokenizer.ts", "../../src/helpers/classList.ts", "../../src/helpers/configBuilder.ts", "../../src/common/index.ts", "../../src/helpers/deliveryStore.ts", "../../src/helpers/CloudRepository.ts", "../../src/helpers/exec.ts", "../../src/helpers/cloudRepositoryHelpers.ts", "../../src/helpers/MyopHelpers.ts"],
4
+ "sourcesContent": ["export const __federation__ = \"__federation__\"\nexport const onLoadKey = \"onLoad\"\nexport const moduleInstanceKey = \"moduleInstance\"\n\nexport const defineDynamicImport = (globalName: string, module: any) => {\n // @ts-ignore\n if (window[__federation__] && window[__federation__][globalName] && window[__federation__][globalName][onLoadKey]) {\n // @ts-ignore\n window[__federation__][globalName][onLoadKey]({[globalName]: module})\n } else {\n //console.log('__federation__ loader not defined for module', module);\n }\n}", "export * from \"./applyStylesheet\";\nexport * from \"./iframeSkinUrlTokenizer\";\nexport * from \"./classList\";\nexport * from \"./configBuilder\";\nexport * from \"./CloudRepository\";\nexport * from \"./exec\";\nexport * from \"./cloudRepositoryHelpers\";", "//TODO : reuse from one place.\n// needs to be used in myop-sdk, myop-dashbaord, myop-server, myop-cli ..\n\nexport const uuidv4 = () => {\n return \"10000000-1000-4000-8000-100000000000\".replace(/[018]/g, c =>\n (+c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +c / 4).toString(16)\n );\n}\n\n// Convert UUID string to bytes\nexport const uuidToBytes = (uuid: string): Uint8Array => {\n return Uint8Array.from(\n uuid.replace(/-/g, '').match(/.{1,2}/g)!.map(byte => parseInt(byte, 16))\n );\n};\n\n// Convert bytes to UUID string\nexport const bytesToUuid = (bytes: Uint8Array): string => {\n const hex = [...bytes].map(b => b.toString(16).padStart(2, '0')).join('');\n return [\n hex.slice(0, 8),\n hex.slice(8, 12),\n hex.slice(12, 16),\n hex.slice(16, 20),\n hex.slice(20)\n ].join('-');\n};\n\n// Base64 URL-safe encode\nexport const base64UrlEncode = (bytes: Uint8Array): string => {\n const base64 = btoa(String.fromCharCode(...bytes));\n return base64.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n};\n\n// Base64 URL-safe decode\nexport const base64UrlDecode = (str: string): Uint8Array => {\n let base64 = str.replace(/-/g, '+').replace(/_/g, '/');\n while (base64.length % 4) base64 += '=';\n const binary = atob(base64);\n return Uint8Array.from(binary, char => char.charCodeAt(0));\n};\n\n// Compress an array of UUIDs into a short URL-safe string\nexport const compressUUIDs = (uuids: string[]): string => {\n const allBytes = uuids.flatMap(uuid => Array.from(uuidToBytes(uuid)));\n return base64UrlEncode(new Uint8Array(allBytes));\n};\n\n// Decompress from URL-safe string back to an array of UUIDs\nexport const decompressUUIDs = (encoded: string): string[] => {\n const bytes = base64UrlDecode(encoded);\n if (bytes.length % 16 !== 0) throw new Error('Invalid input length');\n\n const uuids: string[] = [];\n for (let i = 0; i < bytes.length; i += 16) {\n uuids.push(bytesToUuid(bytes.slice(i, i + 16)));\n }\n return uuids;\n};\n", "import {MyopMessageKey} from \"../common/MyopMessages\";\nimport {uuidv4} from \"../utils/utils\";\nimport {IMyopComponent} from \"../host\";\nimport {IRefConfig} from \"../common\";\n\nexport class MessageDirection {\n static down = 'down' as const\n static up = 'up' as const\n}\n\nexport type MessageDirectionOption = 'up' | 'down';\n\nexport abstract class BaseMyopMessage<T = any> {\n id = uuidv4()\n\n static create<T, U extends new (...args: ConstructorParameters<U>) => T = typeof this>(\n this: U,\n ...args: ConstructorParameters<U>\n ): InstanceType<typeof this> {\n // @ts-ignore\n return new this(...args);\n }\n\n constructor() {\n //console.log('meesage id created', this.id, document.location.href);\n }\n\n myop = true\n\n abstract messageType: MyopMessageKey | string;\n\n content?: T\n\n // TODO : cant be optional \n source?: string\n destination?: string\n\n route?: string[]\n\n ref?: Ref\n\n direction?: MessageDirectionOption\n\n cleanable: boolean = false\n\n isTypeof(msg: BaseMyopMessage): boolean {\n return msg.messageType === this.messageType\n }\n}\n\nexport abstract class MyopElementMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public ref: Ref) {\n super()\n }\n}\n\nexport abstract class MyopBindReplayMessage<T = any> extends BaseMyopMessage<T> {\n constructor(public replayToHandler?: string) {\n super();\n }\n}\n\nexport abstract class MyopBindMessage<T = any, R extends MyopBindReplayMessage = any> extends BaseMyopMessage<T> {\n\n public abstract replyMessageKey: MyopMessageKey;\n\n public handlerUniqueId = uuidv4()\n\n constructor(public handler: (message: R) => void) {\n super()\n }\n}\n\nexport class Ref {\n public myop = true;\n\n public __nonProxied?: Ref;\n\n static create(selector: string, refConfig?: IRefConfig, component?: IMyopComponent) {\n let _refConfig = refConfig;\n if (!_refConfig) {\n _refConfig = {\n id: '',\n name: '',\n description: '',\n selectorType: 'id-attribute',\n selector: selector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n }\n return new Ref(_refConfig, component);\n }\n\n constructor(public refConfig: IRefConfig, public component?: IMyopComponent) {\n this.__nonProxied = {\n ...this,\n component: null // in order to be serializable\n }\n }\n}\n", "import {MyopBindMessage, MyopBindReplayMessage} from \"./BaseMessage\";\nimport {MyopMessageKey} from \"../common/MyopMessages\";\nimport {RootRef} from \"../common\";\nimport {makeSerializable} from \"../common/utils/serialization.ts\";\n\nconst ReplayMessageKey = 'ExecuteScriptReplyMessage'\n\nconst functionBodyRegex = /(?:function\\s*\\w*\\s*\\([^)]*\\)\\s*\\{([\\s\\S]*?)\\}|(\\([^)]*\\)\\s*=>\\s*\\{([\\s\\S]*?)\\}))\\s*$/;\nconst expressionBodyRegex = /\\(\\s*[^)]+\\s*\\)\\s*=>\\s*(.+)/;\n\nexport const stripFunction = (content: string) => {\n let match = content.match(functionBodyRegex);\n if (match) {\n return match[1] || match[3];\n } else {\n let match = content.match(expressionBodyRegex);\n if (match)\n return match[1].trim();\n }\n}\n\nexport type scriptInputs = {\n [key: string]: string | number | boolean\n} | {};\n\nexport type scriptVars<T> = {\n send: (data: T) => void;\n // completeStream: () => void;\n rootRef: RootRef;\n makeSerializable: typeof makeSerializable\n}\n\nexport type extendedScriptVars<T, I> = {\n [K in keyof I]: I[K];\n} & scriptVars<T>\n\nexport class ExecuteScriptMessage<T = any, I extends scriptInputs = any> extends MyopBindMessage<string, ExecuteScriptReplyMessage<T>> {\n\n replyMessageKey: MyopMessageKey = ReplayMessageKey;\n messageType = 'ExecuteScriptMessage';\n script: string = ''\n\n static replierKey = 'send';\n static completeStreamKey = 'completeStream';\n\n constructor(script: (vars: extendedScriptVars<T, I>) => T, handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }, public scriptInputs?: I) {\n super(handler);\n this.script = script.toString();\n\n //TODO: can be remove\n this.content = script.toString()\n this.content = stripFunction(this.content);\n }\n}\n\nexport class ExecuteScriptReplyMessage<T = any> extends MyopBindReplayMessage<T> {\n\n messageType = ReplayMessageKey;\n\n constructor(public replayToHandler: string, public content: T) {\n super(replayToHandler);\n }\n}\n", "import {\n ExecuteScriptMessage,\n ExecuteScriptReplyMessage,\n extendedScriptVars,\n scriptInputs, stripFunction\n} from \"./ExecuteScriptMessage.ts\";\n\nexport type customRefScriptInputs = {\n elementId: string,\n ref?: HTMLElement,\n _script?: string,\n __scriptInputs?: Object\n};\n\nexport class CustomRefMessage<T = any, I extends scriptInputs = customRefScriptInputs> extends ExecuteScriptMessage<T, I & customRefScriptInputs> {\n\n constructor(script: (vars: extendedScriptVars<T, I & customRefScriptInputs>) => T,\n public scriptInputs: I & customRefScriptInputs,\n handler: (message: ExecuteScriptReplyMessage<T>) => void = () => {\n }) {\n\n //mock vars\n // let rootRef, elementId, _script, __scriptInputs;\n super(({rootRef, elementId, _script, __scriptInputs}) => {\n const refs = (rootRef.shadowRoot || rootRef.container).querySelectorAll(`[${'myop-id'}='${elementId}']`);\n if (refs.length) {\n // const ref = refs[0];\n\n //TODO : think about exposing \"refs\" and not only \"ref\"\n //for cases where the Ref has multiplate implementations\n\n // @ts-ignore\n __scriptInputs.ref = refs[0];\n\n const dynamicFunction = new Function(`return (${_script})(...arguments)`);\n return dynamicFunction(__scriptInputs);\n\n // @ts-ignore\n //return Function('ref', 'rootRef', ...Object.keys(__scriptInputs), _script!)(ref, rootRef, ...Object.values(__scriptInputs))\n }\n return null as T;\n }, handler);\n\n this.scriptInputs = {\n ...scriptInputs,\n //_script: stripFunction(script.toString()),\n _script: script.toString()\n };\n }\n}\n", "import type * as CSS from \"csstype\";\nimport {IMyopComponent} from \"../host\";\nimport {uuidv4} from \"../utils/utils.ts\";\nimport {ExecuteScriptMessage} from \"../messages\";\n\n// ignoring documentation\n/** @ignore */\nexport interface CSSProperties extends CSS.Properties<string | number> {\n}\n\nexport type StylesheetDefinition = { [key: string]: CSSProperties };\n\nexport const applyStylesheet = (component: IMyopComponent, stylesheet: StylesheetDefinition, css?: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _stylesheet, _tagId, _css}) => {\n const styleTag = document.createElement('style');\n styleTag.type = 'text/css';\n\n // Build the CSS string from the styles object\n let cssString = _css;\n\n for (const selector in _stylesheet) {\n cssString += `${selector} { `;\n const properties = _stylesheet[selector];\n for (const property in properties) {\n cssString += `${property}: ${properties[property]}; `;\n }\n cssString += '} ';\n }\n\n // Set the CSS string as the content of the <style> element\n styleTag.appendChild(document.createTextNode(cssString));\n styleTag.id = _tagId;\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(styleTag);\n\n }, () => {\n }, {\n _stylesheet: stylesheet,\n _css : css ? css : '',\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n\nexport const applyStylesheetLink = (component: IMyopComponent, link: string) => {\n const tagId = `myop-css-${uuidv4()}`;\n component.send(new ExecuteScriptMessage(({rootRef, _tagId, _link}) => {\n const linkElement = document.createElement('link');\n linkElement.id = _tagId;\n linkElement.rel = 'stylesheet';\n linkElement.href = _link;\n document.head.appendChild(linkElement);\n\n // Append the <style> element\n (rootRef.shadowRoot || rootRef.container).appendChild(linkElement);\n }, () => {\n }, {\n _link : link,\n _tagId: tagId\n }));\n\n return () => {\n component.send(new ExecuteScriptMessage(({rootRef, _tagId}) => {\n const element = (rootRef.shadowRoot || document).getElementById(_tagId);\n if (element) {\n element.remove();\n }\n }, () => {\n }, {\n _tagId: tagId\n }))\n }\n}\n", "import {IIframeLoaderConfig, ISkinConfig} from \"../common\";\n\nexport type TokenMap = Record<string, string| number>\n\nconst replaceTokens = (input: string, tokenMap: TokenMap): string => {\n // Create a regex pattern from the keys of the tokenMap\n const pattern = new RegExp(Object.keys(tokenMap).join('|'), 'g');\n\n // Replace tokens in the input string using the regex\n return input.replace(pattern, (matched) => {\n // Return the replacement value from the tokenMap\n return (tokenMap[matched] || matched).toString();\n });\n}\n\nexport const createIframeSkinByTokenizer = (selectedSkin: ISkinConfig, tokenMap: TokenMap) => {\n const typedSkinConfig = (selectedSkin.loader as IIframeLoaderConfig)\n if (typedSkinConfig.type !== 'IframeLoader') {\n throw new Error(`iframeSkinUrlTokenizer received skin with loader type \"${typedSkinConfig.type}\", currently only \"IframeLoader\" is supported`)\n }\n\n selectedSkin.loader = {\n ...selectedSkin.loader\n }\n\n selectedSkin.loader.url = replaceTokens(selectedSkin.loader.url, tokenMap);\n\n return selectedSkin;\n}\n\nexport const changeSkinUrlByTokenizer = (tokenMap: TokenMap) => {\n return async (selectedSkin: ISkinConfig) => {\n return createIframeSkinByTokenizer(selectedSkin, tokenMap);\n }\n}", "import {CustomRefMessage} from \"../messages\";\nimport {IMyopComponent} from \"../host\";\n\n// const space = ' ';\n// export const getClasses = async (connectedRef: Ref): Promise<string[]> => (await exec(actAs<HTMLDivElement>(connectedRef).classList)).value.split(space);\n// export const addClass = async (connectedRef: Ref, className: string) => {\n// const classes = await getClasses(connectedRef);\n// classes.includes(className) || classes.push(className);\n// // @ts-ignore\n// connectedRef.classList = classes.join(space);\n// }\n// export const removeClass = async (connectedRef: Ref, className: string,) => {\n// let classes = await getClasses(connectedRef);\n// // @ts-ignore\n// connectedRef.classList = classes.filter(c => c !== className).join(space);\n// }\n//\n//\n\nexport const addClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.add(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}\n\nexport const removeClass = (component: IMyopComponent, className: string, myopId: string) => {\n component.send(new CustomRefMessage(({ref, _className}) => {\n ref?.classList.remove(_className);\n }, {\n elementId: myopId,\n _className: className\n }));\n}", "import {\n IComponentConfig,\n IComponentDefinitionConfig,\n IComponentInstanceConfig, IHTMLLoaderConfig, IRefConfig,\n ISkinLoaderConfig,\n ISkinSelectorConfig,\n IDedicatedSkinConfig, ISkinConfig\n} from \"../common\";\nimport {uuidv4} from \"../utils/utils.ts\";\n\nexport class SkinConfig implements ISkinConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new SkinConfig();\n }\n\n id = this._runTimeId;\n name = this._runTimeName;\n description = '';\n loader = null as unknown as ISkinLoaderConfig;\n\n withLoader = (loader: ISkinLoaderConfig) => {\n this.loader = loader;\n return this;\n }\n\n withHTMLLoader = (loader: Omit<IHTMLLoaderConfig, 'type'>) => {\n loader.type = 'HTMLLoader';\n this.loader = loader as IHTMLLoaderConfig;\n return this;\n }\n\n build = () => {\n return this;\n }\n}\n\nexport class ComponentConfig implements IComponentConfig {\n _runTimeInstanceId = 'runtime-instance-id-' + uuidv4();\n _runTimeId = 'runtime-id-' + uuidv4();\n _runTimeName = 'runtime-name-' + uuidv4();\n\n static create = () => {\n return new ComponentConfig();\n }\n\n instance = {\n id: this._runTimeInstanceId,\n componentId: this._runTimeId,\n componentName: this._runTimeName,\n skinSelector: null as unknown as ISkinSelectorConfig\n } as IComponentInstanceConfig;\n\n name = this._runTimeName\n type = {\n id: this._runTimeId,\n name: this._runTimeName,\n description: '',\n props: [],\n refs: [],\n skins: [],\n defaultSkin: 0\n } as IComponentDefinitionConfig\n\n withInstance = (instance: IComponentInstanceConfig) => {\n this.instance = instance;\n return this;\n }\n\n withType = (type: IComponentDefinitionConfig) => {\n this.type = type;\n return this;\n }\n\n withName = (name: string) => {\n this.name = name;\n return this;\n }\n\n withDefaultSkin = (defaultSkin: ISkinConfig) => {\n this.type.skins.push(defaultSkin);\n this.type.defaultSkin = this.type.skins.length - 1;\n this.instance.skinSelector = {\n type: 'Dedicated',\n skin: {\n id: defaultSkin.id\n }\n } as IDedicatedSkinConfig\n\n return this;\n }\n\n withRef = (ref: IRefConfig) => {\n this.type.refs.push(ref);\n return this;\n }\n\n withBasicRef = (refSelector: string) => {\n const newBasicRef = {\n id: '',\n name: refSelector,\n description: '',\n selectorType: 'id-attribute',\n selector: refSelector,\n behavior: {\n type: 'code'\n }\n } as IRefConfig\n\n this.type.refs.push(newBasicRef);\n return this;\n }\n\n build = () => {\n return JSON.parse(JSON.stringify(this))\n }\n}\n", "import {MyopMessageKey} from \"./MyopMessages\";\n\nexport * from './MyopElementRef';\nexport * from './baseMessageHandler';\nexport * from './BaseMyopSDK';\n\nexport type CleanupHandler = () => void\n\nexport type Dictionary<T> = { [key: string]: T; };\n\n//export type SkinLoaderType = 'IframeLoader' | 'WebComponentLoader' | 'HTMLLoader' | string;\n\nexport const SkinLoaders = {\n \"IframeLoader\": \"IframeLoader\",\n \"WebComponentLoader\": \"WebComponentLoader\",\n \"HTMLLoader\": \"HTMLLoader\",\n \"MinimizedLoader\": \"MinimizedLoader\"\n} as const;\nexport type SkinLoaderType = keyof typeof SkinLoaders;\n\nexport type PropType = 'any' | 'string' | 'number' | string; // TODO : <\nexport type RefSelectorType = 'id-attribute' | 'css-selector' | 'xpath' | string;\n\nexport const LoaderFrameworks = {\n \"react\": \"react\",\n \"vue\": \"vue\",\n \"angular\": \"angular\",\n} as const\nexport type LoaderFrameworkType = keyof typeof LoaderFrameworks;\n\nexport interface IWebComponentLoaderConfig extends ISkinLoaderConfig {\n type: \"WebComponentLoader\";\n url: string,\n tag: string,\n framework?: LoaderFrameworkType\n}\n\nexport interface IIframeLoaderConfig extends ISkinLoaderConfig {\n type: \"IframeLoader\";\n url: string\n autoHeight: boolean\n height?: string\n width?: string\n}\n\nexport const ShadowRootModeType = {\n \"open\": \"open\",\n \"closed\": \"closed\",\n \"none\": \"none\",\n \"localFrame\": \"localFrame\"\n} as const;\n\n\nexport interface IHTMLLoaderConfig extends ISkinLoaderConfig {\n type: \"HTMLLoader\";\n HTML: string;\n //TODO: rename(rootMode/customElementMode) + db migration\n shadowRootMode?: keyof typeof ShadowRootModeType;\n autoHeight?: boolean;\n height?: string;\n width?: string;\n /**\n * When true, an inline-HTML (localFrame) component is rendered in a sandboxed,\n * cross-origin iframe with NO access to the host document (untrusted code).\n * The host render policy can also force this regardless of the config value.\n */\n isolation?: boolean;\n}\n\n/**\n * How a component is rendered on the host page, in ascending isolation:\n * - 'webComponent' \u2014 custom element on the host document (most privileged)\n * - 'iframe' \u2014 same-origin inline-HTML iframe (today's default)\n * - 'isolatedIframe' \u2014 sandboxed, cross-origin iframe (untrusted code)\n */\nexport type RenderMode = 'webComponent' | 'iframe' | 'isolatedIframe';\n\nexport interface RenderPolicyContext {\n componentDefinition: IComponentDefinitionConfig;\n skin: ISkinConfig;\n /** What the component asked for (marker \u21D2 'webComponent', config.isolation \u21D2 'isolatedIframe'). */\n requestedMode: RenderMode;\n /** Whether the HTML carries the `<!-- myop-web-component -->` marker. */\n isWebComponent: boolean;\n}\n\n/**\n * Host-supplied gate deciding how (or whether) a component renders. Return a\n * RenderMode to use, or `false` to block rendering entirely.\n */\nexport type RenderPolicy =\n (ctx: RenderPolicyContext) => RenderMode | false | Promise<RenderMode | false>;\n\n//for internal dashboard usage\nexport interface IMinimizedLoaderConfig extends ISkinLoaderConfig {\n type: \"MinimizedLoader\";\n}\n\ninterface DashboardObject {\n _temp_client_id?: string,\n}\n\ntype Extend<T, U> = T & U;\n\ntype ExtendRecursively<T, E> = {\n [K in keyof E]: E[K];\n} & {\n [K in keyof T]: T[K] extends object\n ? ExtendRecursively<T[K], E>\n : T[K];\n};\n\nexport type IDashboard<T> = ExtendRecursively<T, DashboardObject>;\n\nexport interface ISkinLoaderConfig {\n type: SkinLoaderType\n\n [key: string]: any; // Allows any additional properties\n}\n\nexport interface v2_IReleaseMetadata {\n environmentId: string;\n environmentIdentifier: string;\n releasedOn?: string;\n releasedBy?: string;\n}\n\nexport interface v2_IVariantConfig extends v2_IMyopStoredObject {\n loader: ISkinLoaderConfig\n componentId: string;\n\n releases?: v2_IReleaseMetadata[]\n}\n\nexport interface ISkinConfig {\n id: string\n name: string\n description: string\n loader: ISkinLoaderConfig\n createdBy?: string\n createdOn?: string\n}\n\nexport interface v2_ISkinConfig extends ISkinConfig {\n componentId: string\n}\n\nexport interface IMessagePropConfig extends IPropConfig {\n type: PropType\n messageType: MyopMessageKey\n}\n\nexport interface IBindMessagePropConfig extends IPropConfig {\n type: PropType\n messageType: MyopMessageKey\n}\n\nexport const PropMessageModes = {\n \"input\": \"input\",\n \"output\": \"output\"\n} as const;\n\nexport const PropConfigBehaviorTypes = {\n \"message\": \"message\",\n \"code\": \"code\"\n} as const;\n\nexport interface IPropMessageBehaviorParam {\n value: string\n}\n\nexport interface IPropBehavior {\n type: keyof typeof PropConfigBehaviorTypes\n}\n\nexport interface IPropCodeBehavior extends IPropBehavior {\n type: \"code\"\n remap?: string\n}\n\nexport interface IPropMessageBehavior extends IPropBehavior {\n type: \"message\"\n message: MyopMessageKey\n ref: string, //TODO make it id\n params: IPropMessageBehaviorParam[]\n mode: keyof typeof PropMessageModes\n}\n\nexport interface IPropConfig {\n id: string\n name: string\n description: string\n type: PropType\n behavior: IPropBehavior\n}\n\n\nexport class RefBehaviorType {\n static code = 'code' as const\n static component = 'component' as const\n}\n\nexport type IRefBehaviorType = 'code' | 'component';\n\nexport interface IRefBehavior {\n type: IRefBehaviorType\n}\n\nexport interface IComponentRefBehavior extends IRefBehavior {\n type: 'component'\n componentId: string\n\n /**\n * @deprecated\n * Property instance is deprecated and will be removed in future versions.\n */\n instance: IComponentInstanceConfig\n}\n\nexport interface ICodeRefBehavior extends IRefBehavior {\n type: 'code'\n}\n\nexport interface IRefConfig {\n id: string\n name: string\n description: string\n selectorType: RefSelectorType\n selector: string\n behavior: IRefBehavior\n}\n\n/**\n * Experience segment rule\n */\nexport interface IExperienceSegmentRule {\n property: string;\n operator: string;\n value: string;\n}\n\n/**\n * Experience A/B split version\n */\nexport interface IExperienceABSplitVersion {\n id: string;\n percentage: number;\n}\n\n/**\n * Experience A/B split configuration\n */\nexport interface IExperienceABSplit {\n versions: IExperienceABSplitVersion[];\n}\n\n/**\n * Experience segment configuration\n */\nexport interface IExperienceSegment {\n id: string;\n name: string;\n description: string;\n rules: IExperienceSegmentRule[];\n useAb: boolean;\n componentVariants: Record<string, string | Record<string, string>>;\n abSplit?: IExperienceABSplit;\n stickyProperties?: string[];\n}\n\n/**\n * Experience definition config (v2)\n */\nexport interface IExperienceDefinitionConfig extends v2_IMyopStoredObject {\n /** Selected component IDs */\n components: string[];\n /** Segment configurations */\n segments: IExperienceSegment[];\n /** Fallback variant per component */\n fallback: Record<string, string>;\n /** Tags */\n tags: string[];\n}\n\nexport interface IComponentDefinitionConfig {\n id: string;\n name: string,\n description: string,\n // props: Record<string, IPropConfig> //id - type\n // refs: Record<string, IRefConfig>,\n // skins: Record<string, ISkinConfig>\n props: IPropConfig[],\n refs: IRefConfig[],\n skins: ISkinConfig[],\n defaultSkin: number;\n\n //TODO : think about that\n //resolvedDefinitions?: IComponentDefinitionConfig[]\n //TODO : move to base class ( IStorableItem or so...)\n\n createdOn?: string\n createdBy?: string\n updatedBy?: string\n}\n\n\nexport interface v2_IBaseMyopObject {\n id: string,\n name: string,\n description: string,\n}\n\nexport interface v2_IMyopStoredObject extends v2_IBaseMyopObject {\n updatedOn?: string\n updatedBy?: string\n}\n\nexport interface ComponentAccess {\n visibility: 'private' | 'unlisted' | 'public';\n unlisted?: {\n slug: string;\n };\n marketplace?: {\n status: 'draft' | 'submitted' | 'claimed' | 'closed';\n description: string;\n contactEmail: string;\n deadline: string;\n };\n}\n\nexport interface v2_IComponentDefinitionConfig extends v2_IMyopStoredObject {\n variants_ids: string[],\n DTOs: v2_IDTO[],\n tags: string[],\n access?: ComponentAccess,\n\n //\n variants_names: string[],\n variants_data: {\n name: string;\n id: string\n description?: string\n updatedOn?: string\n updatedBy?: string\n has_releases?: boolean\n }[],\n\n preview_variant: v2_IVariantConfig;\n extra?: {\n firstVariant: v2_IVariantConfig; //when new component creates at the client\n }\n}\n\nexport interface v2_IDTO extends v2_IMyopStoredObject {\n data: object\n methodName: string\n}\n\nexport interface ISkinInstanceConfig {\n id: string\n}\n\nexport interface ISkinSelectorConfig {\n type: keyof typeof SkinSelectorTypes,\n //skins: ISkinInstanceConfig[]\n}\n\nexport const SegmentType = {\n \"FunctionResult\": \"FunctionResult\",\n} as const;\n\nexport interface ISegmentInstance {\n segmentId: string;\n skinSelector: ISkinSelectorConfig\n}\n\nexport interface ISegmentDefinition {\n id: string;\n type: keyof typeof SegmentType\n}\n\nexport interface IFunctionResultsSegment extends ISegmentDefinition {\n id: string;\n type: typeof SegmentType.FunctionResult\n name: string\n description: string\n function: string\n}\n\nexport const SkinSelectorTypes = {\n \"Segmented\": \"Segmented\",\n \"Dedicated\": \"Dedicated\",\n\n /**\n * This Selector Type is not yet supported but will be added in a future release.\n * Please check the documentation for updates.\n *\n * @type {string}\n */\n \"Default\": \"Default\"\n} as const;\n\n\n/**\n * This Skin Config Type is not yet supported but will be added in a future release.\n * Please check the documentation for updates.\n *\n * @type {IDefaultSkinConfig}\n */\nexport interface IDefaultSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Default,\n}\n\nexport interface ISegmentedSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Segmented,\n segments: ISegmentInstance[]\n}\n\nexport interface IDedicatedSkinConfig extends ISkinSelectorConfig {\n type: typeof SkinSelectorTypes.Dedicated,\n\n /**\n * @deprecated Use {@link skin} instead.\n * Property skins is deprecated and will be removed in future versions.\n * Please update your code to use {@link skin} for better compatibility.\n *\n * @type {string}\n */\n skins?: ISkinInstanceConfig[] // deprecated\n skin: ISkinInstanceConfig\n}\n\nexport interface IComponentInstanceConfig {\n id: string;\n componentId: string;\n\n //TODO :\n // RefID ? to support more than 1 component from the same type in composites ?\n\n //TODO : remove\n componentName: string; // << check\n\n skinSelector: ISkinSelectorConfig\n\n // storing the nested config for ref components\n nestedComponents?: IComponentInstanceConfig[]\n\n //only on GET?\n //TODO : think about that\n resolvedExperiences?: IExperience[]\n // will include instance and def config in order to render in production\n resolvedNestedComponents?: IComponentConfig[]\n}\n\nexport const ExperienceTypes = {\n \"Segment\": \"Segment\",\n \"Promo\": \"Promo\",\n \"AB\": \"AB\"\n} as const;\n\nexport interface IExperience {\n id: string\n name: string\n description: string\n type: keyof typeof ExperienceTypes\n experiences: IExperience[]\n //stickinessFactor\n //EndDate\n}\n\n// export interface IABExperienceGroup {\n// id: string\n// name: string\n// percentage: number\n// }\n\nexport interface IABExperience extends IExperience {\n type: typeof ExperienceTypes.AB\n // groups: IABExperienceGroup[]\n experiences: IExperience[]\n percentage: number\n}\n\nexport interface IDateRange {\n id: string\n start: Date\n end: Date\n timezone: string\n}\n\nexport interface ISegmentExperience extends IExperience {\n type: keyof typeof ExperienceTypes\n segment: ISegmentDefinition\n dateRange?: IDateRange\n}\n\nexport interface IUserFlowDefinition {\n id: string;\n name: string;\n description: string;\n components: IComponentInstanceConfig[];\n origins: string[],\n experiences: IExperience[]\n branch?: string\n}\n\nexport interface IComponentConfig {\n instance: IComponentInstanceConfig\n type: IComponentDefinitionConfig\n\n // TODO : verify uniqueness (dashboard & server)\n name: string\n}\n\ninterface IBranchable {\n branch?: string\n}\n\nexport interface IUserFlow extends Omit<IUserFlowDefinition, 'components'>, IBranchable {\n components: IComponentConfig[]\n}\n\nexport class RootRef {\n constructor(public container: HTMLElement, public shadowRoot?: ShadowRoot) {\n\n }\n\n getRootDiv = () => {\n return (this.shadowRoot || this.container).querySelector('div')\n }\n\n getRoot = () => {\n return (this.shadowRoot || this.container);\n }\n}\n", "/**\n * The client window: what a returning visitor does NOT ask for.\n *\n * A component the browser already holds, still inside its freshness window, is rendered\n * with no network at all. Once the window ends the browser does not re-download it either\n * \u2014 it sends back the version it holds and is usually told \"unchanged\" in a few hundred\n * bytes.\n *\n * THE WINDOW IS THE SERVER'S, NOT OURS. It comes from the response: `s-maxage` is the\n * freshness the server promised, and `Age` is how much of it a CDN already spent before\n * the bytes reached us. The window we may keep is therefore `s-maxage - Age`, never\n * `s-maxage` \u2014 otherwise a copy that sat at the edge for 55 of its 60 seconds would be\n * held for another 60 here, and a publish would take twice as long to be seen as promised.\n * This is the single easiest thing to get wrong in a client cache, and it is invisible in\n * testing because it only shows up as \"sometimes stale\".\n *\n * IndexedDB, not localStorage: components run to hundreds of KB, localStorage caps around\n * 5 MB and blocks the main thread. Every path degrades to the network \u2014 a browser in\n * private mode, with storage disabled or over quota, must render the page, not fail it.\n */\n\nconst DB_NAME = 'myop-delivery';\nconst STORE = 'components';\nconst DB_VERSION = 1;\n\nexport interface StoredEntry {\n key: string;\n /** the resolved component config, exactly as the network path produces it */\n config: any;\n /** the server's version token for these bytes: `<rev>~<opt>` */\n tag: string | null;\n /** when this browser stored it */\n storedAt: number;\n /** how long it may be used without asking, in ms (already Age-adjusted) */\n windowMs: number;\n /** which host produced it \u2014 a key from another host is never reused */\n host: string;\n /** wire size of the response it came from, so stats can say what the window saved */\n bytes?: number;\n}\n\nlet dbPromise: Promise<IDBDatabase | null> | null = null;\n\nfunction openDb(): Promise<IDBDatabase | null> {\n if (dbPromise) return dbPromise;\n dbPromise = new Promise((resolve) => {\n try {\n if (typeof indexedDB === 'undefined') return resolve(null);\n const req = indexedDB.open(DB_NAME, DB_VERSION);\n req.onupgradeneeded = () => {\n const db = req.result;\n if (!db.objectStoreNames.contains(STORE)) db.createObjectStore(STORE, { keyPath: 'key' });\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => resolve(null);\n // A blocked upgrade must not hang the page load.\n req.onblocked = () => resolve(null);\n } catch {\n resolve(null);\n }\n });\n return dbPromise;\n}\n\nfunction tx<T>(mode: IDBTransactionMode, fn: (store: IDBObjectStore) => IDBRequest): Promise<T | null> {\n return openDb().then(db => new Promise<T | null>((resolve) => {\n if (!db) return resolve(null);\n try {\n const t = db.transaction(STORE, mode);\n const req = fn(t.objectStore(STORE));\n req.onsuccess = () => resolve(req.result as T);\n req.onerror = () => resolve(null);\n t.onabort = () => resolve(null);\n } catch {\n resolve(null);\n }\n }));\n}\n\n/**\n * A SYNCHRONOUS shadow of what we hold, for code that runs before IndexedDB can answer.\n *\n * The page's HTML can start the component request while the JS bundle is still downloading\n * \u2014 but only if it knows, at parse time, whether a request is needed at all and which one.\n * IndexedDB is async, so an inline script cannot ask it. localStorage can be read\n * synchronously, so each entry mirrors two tiny facts here: the version tag and when the\n * window ends. Nothing else \u2014 the component itself stays in IndexedDB where it belongs.\n *\n * Without this the preload hint is actively harmful: it downloads the whole component\n * every time, including on the visits where the stored copy was going to answer for free.\n * Measured on myop.dev before it existed \u2014 98 KB fetched, then discarded, on every reload.\n */\nconst HINT_PREFIX = 'myop.d.';\n\nfunction writeHint(key: string, tag: string | null, expiresAt: number) {\n try { localStorage.setItem(HINT_PREFIX + key, JSON.stringify({ t: tag, e: expiresAt })); }\n catch { /* private mode, quota, disabled \u2014 the hint is an optimisation, never a requirement */ }\n}\n\nfunction clearHint(key: string) {\n try { localStorage.removeItem(HINT_PREFIX + key); } catch { /* as above */ }\n}\n\n/** A memory layer in front of storage: a second component on the same page must not wait on IO. */\nconst memory = new Map<string, StoredEntry>();\n\nexport const deliveryStore = {\n key(host: string, componentId: string, env: string, preview: boolean, opt: string) {\n // The HOST is part of the key. Two stacks can serve the same component with\n // different freshness, and entries from one must never be read as the other's.\n return `${host}|${componentId}|${env}|${preview ? 'preview' : 'live'}|${opt || 'raw'}`;\n },\n\n async get(key: string): Promise<StoredEntry | null> {\n const m = memory.get(key);\n if (m) return m;\n const e = await tx<StoredEntry>('readonly', s => s.get(key));\n if (e) {\n memory.set(key, e);\n // SELF-HEAL. The two stores can disagree: an entry written before the hint\n // existed, a browser that evicted localStorage but not IndexedDB, a user who\n // cleared one. A missing hint makes the preload fall back to the FULL component\n // while the SDK, which can see IndexedDB, only wants the version check -- two\n // requests where there should be one. Seen in the wild on the first load after\n // the hint shipped. Rewriting it here costs nothing and closes the gap for good.\n writeHint(key, e.tag, e.storedAt + e.windowMs);\n }\n return e;\n },\n\n async put(entry: StoredEntry): Promise<void> {\n memory.set(entry.key, entry);\n writeHint(entry.key, entry.tag, entry.storedAt + entry.windowMs);\n await tx('readwrite', s => s.put(entry));\n },\n\n async drop(key: string): Promise<void> {\n memory.delete(key);\n clearHint(key);\n await tx('readwrite', s => s.delete(key));\n },\n\n /** Still usable without asking the server? */\n fresh(e: StoredEntry | null): boolean {\n return !!e && (Date.now() - e.storedAt) < e.windowMs;\n },\n\n /**\n * The window this response licenses: the server's freshness minus what a CDN already\n * spent. Returns 0 when the server said nothing about caching, which means \"do not\n * hold this\" \u2014 the safe reading, and what production sends today.\n */\n windowFrom(headers: Headers): number {\n const cc = headers.get('cache-control') || '';\n if (/no-store|no-cache/i.test(cc)) return 0;\n const m = /s-maxage\\s*=\\s*(\\d+)/i.exec(cc) || /max-age\\s*=\\s*(\\d+)/i.exec(cc);\n if (!m) return 0;\n const total = Number(m[1]);\n const age = Number(headers.get('age') || 0);\n return Math.max(0, (total - (isNaN(age) ? 0 : age))) * 1000;\n },\n\n /** For tests and for `refresh()`: forget everything this browser holds. */\n async clear(): Promise<void> {\n memory.clear();\n try {\n for (let i = localStorage.length - 1; i >= 0; i--) {\n const k = localStorage.key(i);\n if (k && k.startsWith(HINT_PREFIX)) localStorage.removeItem(k);\n }\n } catch { /* nothing to clean up if it was never writable */ }\n await tx('readwrite', s => s.clear());\n },\n};\n", "import {\n IComponentConfig,\n IComponentDefinitionConfig,\n IComponentInstanceConfig,\n IDedicatedSkinConfig,\n IPropConfig,\n ISkinConfig,\n IUserFlow,\n PropConfigBehaviorTypes,\n v2_IVariantConfig\n} from \"../common\";\nimport { deliveryStore } from \"./deliveryStore\";\n\nconst convertV2VariantToComponentConfig = (config: v2_IVariantConfig): IComponentConfig => {\n return {\n instance: {\n id: 'auto',\n componentId: config.componentId,\n componentName: config.name,\n\n skinSelector: {\n type: 'Dedicated',\n skin: {\n id: 'skin_auto_v2_converted'\n }\n } as IDedicatedSkinConfig\n\n } as IComponentInstanceConfig,\n type: {\n id: config.id,\n name: config.name,\n description: config.description,\n props: [\n {\n id: 'in_auto_v2_converted',\n name: 'myop_init_interface',\n type: 'any',\n behavior: {\n type: PropConfigBehaviorTypes.code\n }\n } as IPropConfig,\n\n {\n id: 'out_auto_v2_converted',\n name: 'myop_cta_handler',\n type: 'any',\n behavior: {\n type: PropConfigBehaviorTypes.code\n }\n } as IPropConfig\n ],\n refs: [],\n skins: [\n {\n id: 'skin_auto_v2_converted',\n name: 'auto_v2_converted',\n description: '',\n //TODO : handle empty :\n // @ts-ignore\n loader: config.consume_variant[0].loader\n } as ISkinConfig\n ],\n defaultSkin: 0\n } as IComponentDefinitionConfig,\n name: config.name\n } as IComponentConfig;\n};\n\n/**\n * CloudRepository - Unified cloud data access layer for Myop components\n *\n * Supports both v2 (default) and v1 modes:\n * - v2: Uses /consume endpoint for fetching variants\n * - v1: Uses /flow endpoint for fetching user flows\n */\n// Use a global singleton to ensure only one CloudRepository.Main exists\n// even when the module is loaded multiple times by different bundlers\nconst GLOBAL_KEY = '__MYOP_CLOUD_REPOSITORY_MAIN__';\n\nconst getGlobalMain = (): CloudRepository | undefined => {\n if (typeof window !== 'undefined') {\n return (window as any)[GLOBAL_KEY];\n }\n if (typeof globalThis !== 'undefined') {\n return (globalThis as any)[GLOBAL_KEY];\n }\n return undefined;\n};\n\nconst setGlobalMain = (instance: CloudRepository) => {\n if (typeof window !== 'undefined') {\n (window as any)[GLOBAL_KEY] = instance;\n }\n if (typeof globalThis !== 'undefined') {\n (globalThis as any)[GLOBAL_KEY] = instance;\n }\n};\n\nexport class CloudRepository {\n private static _main: CloudRepository | null = null;\n\n static get Main(): CloudRepository {\n // Check if a global instance already exists (from another bundle)\n const globalMain = getGlobalMain();\n if (globalMain) {\n return globalMain;\n }\n\n // Create new instance if needed\n if (!CloudRepository._main) {\n CloudRepository._main = new CloudRepository();\n setGlobalMain(CloudRepository._main);\n }\n return CloudRepository._main;\n }\n\n // v2 cache - keyed by componentId:env:preview|live\n // Each Promise is tagged with a `resolved` property after settling (see fetchComponentV2).\n private variants: Record<string, Promise<IComponentConfig> & { resolved?: IComponentConfig }> = {};\n\n // Track which components were preloaded and with what params\n // Key: componentId, Value: { env, preview }\n private preloadedComponents: Record<string, { env: string; preview: boolean }> = {};\n\n // v1 cache\n private userFlows: Record<string, Promise<IUserFlow>> = {};\n\n private _defaultEnv = 'production';\n private _envExplicitlySet = false;\n private _staticMode = false;\n private _queryParams: Record<string, string> = {};\n\n constructor(private _baseUrl = 'https://cloud.myop.dev') {\n }\n\n /**\n * How big the component we are NOT re-downloading is. Deliberately measured from what\n * we hold rather than from Content-Length: once a response is compressed the header is\n * not readable cross-origin, so reading it there reported 0 every single time.\n */\n private static sizeOfHeld(e: any): number {\n try { return (e?.config?.type?.skins?.[0]?.loader?.HTML || '').length; } catch { return 0; }\n }\n\n /** The host every request goes to unless delivery() moved it. Never changes. */\n private static readonly DEFAULT_HOST = 'https://cloud.myop.dev';\n\n /**\n * Opt-in delivery settings, set by myop.delivery(). Off means: this file behaves\n * EXACTLY as it did before \u2014 same host, same URL, same everything.\n */\n private _delivery: { minify: boolean; host: string | null; cache: boolean } =\n { minify: false, host: null, cache: false };\n\n /**\n * What actually happened, for myop.delivery.stats(). `fellBack` is the number that\n * matters: it is how you find out the lane is unhealthy without waiting for a\n * bug report, because a fallback is INVISIBLE to the page (it still renders).\n */\n private _deliveryStats = {\n requests: 0, viaDelivery: 0, fellBack: 0, lastError: null as string | null,\n /** where the last loads were answered from \u2014 the number the client window exists to move */\n fromMemory: 0, fromStorage: 0, fromNetwork: 0,\n /** re-checks after the window ended, and how many were answered \"nothing changed\" */\n revalidations: 0, unchanged: 0, bytesSaved: 0,\n };\n\n /**\n * Turn on the opt-in delivery path.\n *\n * Opting in IS choosing the delivery stack: this points /consume at `host` (a second,\n * complete stack reading the same data) and asks for the minified artifact. Leave this\n * uncalled and nothing about the SDK changes.\n *\n * Deliberately mutates THIS instance rather than constructing a new repository:\n * CloudRepository.Main is a global singleton shared across bundles (see getGlobalMain),\n * so a second instance would be ignored by every component already using the first.\n */\n setDelivery(opts: { minify?: boolean; host?: string | null; cache?: boolean } = {}) {\n if (opts.minify !== undefined) this._delivery.minify = !!opts.minify;\n if (opts.host !== undefined) this._delivery.host = opts.host;\n if (opts.cache !== undefined) this._delivery.cache = !!opts.cache;\n }\n\n deliveryStats() {\n return { ...this._deliveryStats, host: this._delivery.host ?? CloudRepository.DEFAULT_HOST,\n minify: this._delivery.minify, cache: this._delivery.cache };\n }\n\n /**\n * Forget what this browser holds, so the next load asks the server.\n * `refresh()` with no ids drops everything; the counterpart to the window for the case\n * where a change has to be visible on THIS load \u2014 right after someone publishes.\n */\n async refreshDelivery(): Promise<void> {\n await deliveryStore.clear();\n }\n\n /**\n * Local serves waiting to be reported: componentId -> {env, count}.\n *\n * THE MEASUREMENT PROBLEM THIS SOLVES. The better this cache works, the more usage\n * vanishes: a visitor inside their freshness window renders the page with no request,\n * so neither the server nor the CDN can see them. Left alone, a successful rollout\n * looks in the ledger exactly like customers leaving.\n *\n * So local serves are counted here and reported afterwards, batched, on a path that\n * never blocks rendering: flushed when the page is hidden (keepalive, so it survives\n * the tab closing) and opportunistically whenever the SDK is talking to the server\n * anyway. Nothing is sent while the page is loading, which is the point of the window.\n */\n private _localServes = new Map<string, {env: string; count: number}>();\n private _flushBound = false;\n\n private noteLocalServe(componentId: string, env: string) {\n const cur = this._localServes.get(componentId);\n if (cur) cur.count++;\n else this._localServes.set(componentId, {env, count: 1});\n this.bindFlush();\n }\n\n /** Report on page-hide, which is the only event that reliably fires on mobile. */\n private bindFlush() {\n if (this._flushBound || typeof document === 'undefined') return;\n this._flushBound = true;\n const onHide = () => { if (document.visibilityState === 'hidden') this.flushLocalServes(); };\n document.addEventListener('visibilitychange', onHide);\n window.addEventListener('pagehide', () => this.flushLocalServes());\n }\n\n /**\n * Send what we have. `keepalive` is what makes this work at page-hide: the request\n * outlives the document. Failure is ignored \u2014 a lost usage report must never be\n * visible to a visitor, and the next page load will report its own.\n */\n flushLocalServes(): void {\n if (!this._localServes.size) return;\n const batch = [...this._localServes.entries()]\n .map(([id, v]) => `${id}:${v.env}:${v.count}`).join(',');\n this._localServes.clear();\n try {\n const url = `${this.deliveryHost()}/clientUsage?b=${encodeURIComponent(batch)}`;\n fetch(url, {keepalive: true, mode: 'cors', credentials: 'omit'}).catch(() => {});\n } catch { /* never the visitor's problem */ }\n }\n\n /** Where /consume should be fetched from right now. */\n private deliveryHost(): string {\n return this._delivery.host || this._baseUrl;\n }\n\n /**\n * Fetch a delivery URL with ONE fallback to the default host.\n *\n * The fallback is the kill switch: break or disable the lane and every client drifts\n * back to cloud.myop.dev on its own, with no customer deploy. It must therefore be\n * genuinely silent to the page and genuinely LOUD in stats() \u2014 a fallback that nobody\n * counts is an outage nobody notices.\n *\n * Only transport failures and 5xx fall back. A 404 is an answer: the component really\n * is missing, and retrying elsewhere would only hide it.\n */\n private async deliveryFetch(path: string): Promise<Response> {\n // We are about to use the network anyway: a good moment to hand over whatever the\n // window served offline, rather than waiting for the page to be closed.\n if (this._localServes.size) this.flushLocalServes();\n const host = this.deliveryHost();\n const primary = `${host}${path}`;\n this._deliveryStats.requests++;\n const usingLane = host !== this._baseUrl;\n try {\n const res = await fetch(primary);\n if (res.ok || res.status < 500 || !usingLane) {\n if (usingLane && res.ok) this._deliveryStats.viaDelivery++;\n return res;\n }\n this._deliveryStats.lastError = `HTTP ${res.status} from ${host}`;\n } catch (e: any) {\n if (!usingLane) throw e;\n this._deliveryStats.lastError = String(e?.message ?? e);\n }\n this._deliveryStats.fellBack++;\n console.warn(`[myop] delivery host failed (${this._deliveryStats.lastError}) \u2014 falling back to ${this._baseUrl}`);\n return await fetch(`${this._baseUrl}${path}`);\n }\n\n /**\n * Enable static mode for self-hosted component registries.\n * In static mode, URLs are constructed as file paths instead of query params:\n * ${baseUrl}/components/${componentId}/${env}.json\n */\n enableStaticMode() {\n this._staticMode = true;\n }\n\n /**\n * Set query parameters to append to all fetch URLs (e.g. for CDN cache busting).\n * Example: `setQueryParams({ lastupdate: '11112026' })`\n */\n setQueryParams(params: Record<string, string>) {\n this._queryParams = params;\n }\n\n /**\n * Set the default environment for this CloudRepository instance\n */\n setEnvironment(env: string) {\n this._defaultEnv = env;\n this._envExplicitlySet = true;\n }\n\n /**\n * Get the current default environment\n */\n getDefaultEnvironment(): string {\n return this._defaultEnv;\n }\n\n // ============ V2 Methods (Default) ============\n\n /**\n * Check if a component is already cached/preloaded (v2)\n * If env and preview are not provided, checks if ANY version is preloaded\n */\n isPreloaded(componentId: string, env?: string, preview?: boolean): boolean {\n // If specific env/preview requested, check exact match\n if (env !== undefined || preview !== undefined) {\n const cacheKey = `${componentId}:${env || this._defaultEnv}:${preview ? 'preview' : 'live'}`;\n return cacheKey in this.variants;\n }\n // Otherwise check if any version was preloaded\n return componentId in this.preloadedComponents;\n }\n\n /**\n * Get the preloaded params for a component (if preloaded)\n * Returns undefined if not preloaded\n */\n getPreloadedParams(componentId: string): { env: string; preview: boolean } | undefined {\n return this.preloadedComponents[componentId];\n }\n\n /**\n * Resolve a component config: fetch it once, then serve it from this\n * repository's cache.\n *\n * This is the name to use. `fetchComponentV2` is the same method under its\n * versioned name and stays for backward compatibility \u2014 note that the\n * unversioned `fetchComponent` is a *deprecated v1* API and is NOT this.\n *\n * Completes the trio with {@link getResolvedConfig} (synchronous read of an\n * already-resolved config) and {@link hydrateComponent} (seed one you\n * already hold).\n *\n * Prefer the module-level `preloadComponents([id])` in app code; reach for\n * this when you need an isolated repository instance whose cache lifetime\n * you control \u2014 a server with its own TTL, for example.\n */\n async resolveComponent(componentId: string, env?: string, preview?: boolean): Promise<IComponentConfig> {\n return this.fetchComponentV2(componentId, env, preview);\n }\n\n /**\n * Fetch a v2 component config\n * If env/preview not specified and component was preloaded, uses preloaded params\n *\n * @see resolveComponent \u2014 the unversioned name for this method\n */\n async fetchComponentV2(componentId: string, environmentIdentifier?: string, preview?: boolean): Promise<IComponentConfig> {\n const { env, usePreview, cacheKey } = this.resolveParams(componentId, environmentIdentifier, preview);\n\n console.log('[CloudRepository] fetchComponentV2', {\n componentId: componentId.slice(0, 8) + '...',\n env,\n usePreview,\n cacheKey,\n cached: cacheKey in this.variants\n });\n\n if (!this.variants[cacheKey]) {\n // Track this as preloaded (first fetch counts as preload)\n if (!this.preloadedComponents[componentId]) {\n this.preloadedComponents[componentId] = { env, preview: usePreview };\n }\n\n // eslint-disable-next-line no-async-promise-executor\n this.variants[cacheKey] = new Promise(\n async (resolve, reject) => {\n try {\n let url: string;\n if (this._staticMode) {\n const file = usePreview ? 'preview' : env;\n url = `${this._baseUrl}/components/${componentId}/${file}.json`;\n const qs = new URLSearchParams(this._queryParams).toString();\n if (qs) url += `?${qs}`;\n } else {\n url = `/consume?id=${componentId}&env=${env}`;\n if (usePreview) {\n url += '&preview=true';\n }\n // A preview is never minified: the artifact is built from the\n // released variant, and an author must see their own edit.\n if (this._delivery.minify && !usePreview) {\n url += '&opt=min';\n }\n }\n\n // ---- the client window -------------------------------------\n // A preview is never held: an author has to see their own edit.\n const cacheable = this._delivery.cache && !this._staticMode && !usePreview;\n const storeKey = cacheable ? deliveryStore.key(\n this.deliveryHost(), componentId, env,\n usePreview, this._delivery.minify ? 'min' : 'raw') : '';\n let held = cacheable ? await deliveryStore.get(storeKey) : null;\n\n if (held && deliveryStore.fresh(held)) {\n // Inside the window: no request at all. Counted locally and\n // reported later, or this visit is invisible to the ledger.\n this._deliveryStats.fromStorage++;\n this.noteLocalServe(componentId, env);\n (this.variants[cacheKey] as any).resolved = held.config;\n resolve(held.config);\n return;\n }\n\n if (held && held.tag) {\n // The window ended. Send back the version we hold rather than\n // re-downloading: the answer is usually a few hundred bytes.\n //\n // Deliberately the `ids=`/`have=` route and NOT If-None-Match:\n // a request header triggers a CORS preflight, there is no OPTIONS\n // route, and it fails in a browser while working perfectly in curl.\n // The validator travels in the query string, so it is a plain GET.\n const checkUrl = `/consume?ids=${componentId}&env=${env}` +\n (this._delivery.minify ? '&opt=min' : '') +\n `&have=${encodeURIComponent(held.tag)}`;\n this._deliveryStats.revalidations++;\n try {\n const check = await this.deliveryFetch(checkUrl);\n if (check.ok) {\n const body = await check.json();\n if ((body.unchanged || []).includes(componentId)) {\n this._deliveryStats.unchanged++;\n this._deliveryStats.bytesSaved += CloudRepository.sizeOfHeld(held);\n held.storedAt = Date.now();\n held.windowMs = deliveryStore.windowFrom(check.headers) || held.windowMs;\n await deliveryStore.put(held);\n (this.variants[cacheKey] as any).resolved = held.config;\n resolve(held.config);\n return;\n }\n // It changed. The answer already carries the new bytes.\n const item = (body.items || [])[0];\n if (item) {\n const cfg = convertV2VariantToComponentConfig(item);\n this._deliveryStats.fromNetwork++;\n await deliveryStore.put({\n key: storeKey, config: cfg, tag: item.tag || null,\n storedAt: Date.now(),\n windowMs: deliveryStore.windowFrom(check.headers),\n host: this.deliveryHost(),\n } as any);\n (this.variants[cacheKey] as any).resolved = cfg;\n resolve(cfg);\n return;\n }\n }\n } catch {\n // A failed re-check must not fail the page: fall through to\n // the ordinary fetch below.\n }\n }\n\n const res = this._staticMode\n ? await fetch(url)\n : await this.deliveryFetch(url);\n if (!res.ok) {\n reject(new Error(`Failed to load component \"${componentId}\" (${res.status}${this._staticMode ? ` from ${url}` : ''})`));\n return;\n }\n const json = await res.json();\n const variant = json.item;\n\n if (!variant) {\n reject(new Error(`Component \"${componentId}\" not found`));\n return;\n }\n\n if (!variant.consume_variant || !variant.consume_variant.length) {\n reject(new Error(`Component \"${componentId}\" has no implementation for environment \"${env}\"`));\n return;\n }\n\n const componentConfig = convertV2VariantToComponentConfig(variant);\n this._deliveryStats.fromNetwork++;\n if (cacheable) {\n // Hold it for exactly as long as the server said, minus what a\n // CDN already spent (deliveryStore.windowFrom).\n await deliveryStore.put({\n key: storeKey, config: componentConfig,\n tag: (variant as any).tag || null,\n storedAt: Date.now(),\n windowMs: deliveryStore.windowFrom(res.headers),\n host: this.deliveryHost(),\n } as any);\n }\n // Tag the Promise so getResolvedConfig can read it synchronously\n (this.variants[cacheKey] as any).resolved = componentConfig;\n resolve(componentConfig);\n } catch (e) {\n // Clear the cached rejected promise so the next call\n // makes a fresh request (e.g. after network recovery)\n delete this.variants[cacheKey];\n reject(e);\n }\n }\n );\n }\n\n return await this.variants[cacheKey];\n }\n\n /**\n * Synchronous version of fetchComponentV2 \u2014 returns the config only if\n * the fetch already completed, null otherwise.\n *\n * Uses the same `this.variants` cache that fetchComponentV2/preloadComponents\n * populate. Each cached Promise is tagged with a `.resolved` property when\n * it settles \u2014 this method just reads that property. No separate cache.\n *\n * Why this exists: React Native needs the config at render time to embed it\n * in the WebView HTML (can't await in useState). If preloadComponents ran\n * earlier and the fetch completed, this returns the result synchronously,\n * skipping the WEBVIEW_READY \u2192 fetch \u2192 inject round trip entirely.\n */\n getResolvedConfig(componentId: string, env?: string, preview?: boolean): IComponentConfig | null {\n const { cacheKey } = this.resolveParams(componentId, env, preview);\n return this.variants[cacheKey]?.resolved || null;\n }\n\n /**\n * Resolve which (env, preview) pair \u2014 and therefore which cache key \u2014 a call\n * for `componentId` refers to.\n *\n * Single source of truth for fetchComponentV2, getResolvedConfig and\n * hydrateComponent, so a hydrated config always lands on the key a later\n * fetch will look under.\n */\n private resolveParams(componentId: string, environmentIdentifier?: string, preview?: boolean) {\n // If no explicit env/preview and component was preloaded, use preloaded params\n const preloaded = this.preloadedComponents[componentId];\n const hasExplicitParams = environmentIdentifier !== undefined || preview !== undefined;\n\n let env: string;\n let usePreview: boolean;\n\n if (!hasExplicitParams && preloaded) {\n // Use preloaded params\n env = preloaded.env;\n usePreview = preloaded.preview;\n } else {\n // Use provided params or defaults\n env = environmentIdentifier || this._defaultEnv;\n // If preview explicitly true \u2192 true\n // If preview explicitly false \u2192 false\n // If preview undefined: env was specified (via param or setEnvironment) \u2192 false, otherwise \u2192 true\n const hasEffectiveEnv = environmentIdentifier || this._envExplicitlySet;\n usePreview = preview === true ? true : (preview === false ? false : !hasEffectiveEnv);\n }\n\n return { env, usePreview, cacheKey: `${componentId}:${env}:${usePreview ? 'preview' : 'live'}` };\n }\n\n /**\n * Seed an already-resolved component config into the cache, without any\n * network request.\n *\n * The counterpart to {@link fetchComponentV2}: use it when the config was\n * resolved somewhere else \u2014 most often on a server, then embedded in the\n * page \u2014 so the browser can render the component with no round trip.\n *\n * After hydrating, `fetchComponentV2`, `getResolvedConfig` and `isPreloaded`\n * all answer for this component from memory.\n *\n * Pass the same `env` / `preview` the config was resolved with; the defaults\n * match what a plain `fetchComponentV2(componentId)` would have used.\n */\n hydrateComponent(componentId: string, config: IComponentConfig, env?: string, preview?: boolean): void {\n const { env: resolvedEnv, usePreview, cacheKey } = this.resolveParams(componentId, env, preview);\n\n const promise = Promise.resolve(config) as Promise<IComponentConfig> & { resolved?: IComponentConfig };\n // Tag it the same way fetchComponentV2 does, so getResolvedConfig can\n // read it synchronously.\n promise.resolved = config;\n\n this.variants[cacheKey] = promise;\n this.preloadedComponents[componentId] = { env: resolvedEnv, preview: usePreview };\n }\n\n // ============ V1 Methods (Legacy) ============\n\n /**\n * Fetch a v1 component from a flow\n */\n async fetchComponentV1(componentId: string, flowId?: string) {\n if (flowId) {\n const flow = await this.fetchFlow(flowId);\n return flow.components.find(c => c.type.id === componentId);\n } else {\n const flow = await this.fetchAutoFlow(componentId);\n return flow.components[0];\n }\n }\n\n async fetchAutoFlow(componentId: string) {\n if (!this.userFlows[componentId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[componentId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${componentId}&auto=true`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n delete this.userFlows[componentId];\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[componentId];\n }\n\n async fetchFlow(flowId: string) {\n if (!this.userFlows[flowId]) {\n // eslint-disable-next-line no-async-promise-executor\n this.userFlows[flowId] = new Promise(\n async (resolve, reject) => {\n try {\n const res = await fetch(\n `${this._baseUrl}/flow?id=${flowId}&resolve=components`\n );\n const json = await res.json();\n resolve(json.item);\n } catch (e) {\n delete this.userFlows[flowId];\n reject(e);\n }\n }\n );\n }\n\n return await this.userFlows[flowId];\n }\n\n // ============ Backward Compatibility ============\n\n /**\n * @deprecated Use fetchComponentV2 or fetchComponentV1 explicitly\n * Defaults to v1 behavior for backward compatibility with existing code\n */\n async fetchComponent(componentId: string, flowId?: string) {\n return this.fetchComponentV1(componentId, flowId);\n }\n}\n\n/**\n * @deprecated Use CloudRepository instead\n */\nexport const v2_CloudRepository = CloudRepository;\n", "export const exec = async (getter: any) => {\n return await getter()\n}\n", "import { CloudRepository } from \"./CloudRepository\";\nimport { IComponentConfig } from \"../common\";\n\nlet _cloudRepository = CloudRepository.Main;\n\nexport const getCloudRepository = () => _cloudRepository;\n\nexport const isPreloaded = (componentId: string, env?: string, preview?: boolean): boolean => {\n return _cloudRepository.isPreloaded(componentId, env, preview);\n};\n\nexport const getPreloadedParams = (componentId: string) => {\n return _cloudRepository.getPreloadedParams(componentId);\n};\n\nexport const enableLocalDev = () => {\n _cloudRepository = new CloudRepository(\"http://localhost:9292\");\n};\n\nexport const setCloudRepositoryUrl = (url: string) => {\n _cloudRepository = new CloudRepository(url);\n};\n\n/**\n * Configure the SDK to fetch components from a self-hosted static registry (S3, CDN, etc.)\n * instead of the Myop cloud. Components are served as static JSON files:\n * `${cdnUrl}/components/${componentId}/${environment}.json`\n */\nexport const enableSelfHosted = (cdnUrl: string, queryParams?: Record<string, string>) => {\n _cloudRepository = new CloudRepository(cdnUrl);\n _cloudRepository.enableStaticMode();\n if (queryParams) {\n _cloudRepository.setQueryParams(queryParams);\n }\n};\n\n/**\n * THE OPT-IN. One call, and nothing changes for anyone who does not make it.\n *\n * myop.delivery({ minify: true });\n *\n * Opting in IS choosing the delivery lane: a second, complete Myop stack (its own server\n * and CDN) reading the same component data. So this call does two things at once \u2014 it\n * points `/consume` at that stack and asks it for the minified artifact \u2014 which is why\n * turning the feature off is a config value on our side or one line on yours, and never\n * a DNS change.\n *\n * Safety properties, all deliberate:\n * - If the lane fails (transport error or 5xx), the SDK retries ONCE against\n * cloud.myop.dev and the page renders anyway. `delivery.stats().fellBack` counts it.\n * - `cache: true` adds the client window: a component this browser already holds, still\n * inside the freshness the server promised, is rendered with NO request. Once the\n * window ends the browser sends back the version it holds instead of re-downloading.\n * - A preview is never minified and never cached.\n * - Only /consume moves. Everything else keeps the host it has today.\n * - Asking for `minify` does not force it: the server decides per component, and a\n * component that is not enabled is served raw, which is not an error.\n *\n * `host` is for us (a staging lane, a local server); leave it out.\n */\nexport const DELIVERY_HOST = 'https://delivery.myop.dev';\n\nexport const delivery = (opts: { minify?: boolean; cache?: boolean; host?: string | null } = {}) => {\n const wantsLane = opts.minify !== false || opts.cache === true;\n _cloudRepository.setDelivery({\n minify: opts.minify ?? false,\n cache: opts.cache ?? false,\n host: opts.host !== undefined ? opts.host : (wantsLane ? DELIVERY_HOST : null),\n });\n return deliveryStats();\n};\n\n/**\n * Forget what this browser holds, so the next load asks the server. Use it when a change\n * has to be visible on THIS load \u2014 right after someone publishes \u2014 rather than within the\n * freshness window.\n */\nexport const deliveryRefresh = async () => {\n await _cloudRepository.refreshDelivery();\n return deliveryStats();\n};\n\n/**\n * What answered the last requests, and \u2014 the number worth watching \u2014 how many times the\n * SDK had to fall back to the default host because the lane did not answer.\n */\nexport const deliveryStats = () => _cloudRepository.deliveryStats();\n\n/** Undo delivery(): back to the default host and raw bytes, with no reload. */\nexport const deliveryOff = () => {\n _cloudRepository.setDelivery({ minify: false, cache: false, host: null });\n return deliveryStats();\n};\n\nexport const setCloudRepository = (repository: CloudRepository) => {\n _cloudRepository = repository;\n};\n\nexport const setEnvironment = (env: string) => {\n _cloudRepository.setEnvironment(env);\n};\n\nexport const getResolvedConfig = (componentId: string, env?: string, preview?: boolean) => {\n return _cloudRepository.getResolvedConfig(componentId, env, preview);\n};\n\nexport const preloadComponents = async (ids: string[], env?: string, preview?: boolean) => {\n return Promise.allSettled(\n ids.map((id) => _cloudRepository.fetchComponentV2(id, env, preview)),\n );\n};\n\n/**\n * Seed already-resolved component configs into the SDK cache, with no network\n * request. The counterpart to {@link preloadComponents}.\n *\n * Use it when the configs were resolved somewhere else \u2014 typically on a server\n * and embedded in the page \u2014 so the component renders with zero round trips:\n *\n * ```ts\n * // server: const configs = { [id]: await new CloudRepository().fetchComponentV2(id) }\n * // client:\n * hydrateComponents(configs);\n * // <MyopComponent componentId={id} /> now renders without fetching\n * ```\n *\n * Pass the same `env` / `preview` the configs were resolved with; the defaults\n * match what a plain `preloadComponents([id])` would have used.\n */\nexport const hydrateComponents = (\n configs: Record<string, IComponentConfig>,\n env?: string,\n preview?: boolean,\n) => {\n for (const [id, config] of Object.entries(configs)) {\n _cloudRepository.hydrateComponent(id, config, env, preview);\n }\n};\n", "import {defineDynamicImport} from \"../dynamicImport/defineDynamicImport.ts\";\nimport * as MyopHelpers from \"./index.ts\";\n\nexport * from \"./index.ts\";\n\ndefineDynamicImport('MyopHelpers', MyopHelpers);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;AAAO,IAAM,iBAAiB;AACvB,IAAM,YAAY;AAGlB,IAAM,sBAAsB,CAAC,YAAoB,WAAgB;AAEpE,MAAI,OAAO,cAAc,KAAK,OAAO,cAAc,EAAE,UAAU,KAAK,OAAO,cAAc,EAAE,UAAU,EAAE,SAAS,GAAG;AAE/G,WAAO,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,EAAC,CAAC,UAAU,GAAG,OAAM,CAAC;AAAA,EACxE,OAAO;AAAA,EAEP;AACJ;;;ACZA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,eAAW;",
6
+ "names": ["match", "scriptInputs", "scriptInputs", "e"]
7
+ }
@@ -0,0 +1 @@
1
+ var jt=Object.defineProperty,On=Object.defineProperties;var zn=Object.getOwnPropertyDescriptors;var Vt=Object.getOwnPropertySymbols;var $n=Object.prototype.hasOwnProperty,An=Object.prototype.propertyIsEnumerable;var at=(o,n,e)=>n in o?jt(o,n,{enumerable:!0,configurable:!0,writable:!0,value:e}):o[n]=e,h=(o,n)=>{for(var e in n||(n={}))$n.call(n,e)&&at(o,e,n[e]);if(Vt)for(var e of Vt(n))An.call(n,e)&&at(o,e,n[e]);return o},L=(o,n)=>On(o,zn(n));var Fn=(o,n)=>{for(var e in n)jt(o,e,{get:n[e],enumerable:!0})};var r=(o,n,e)=>at(o,typeof n!="symbol"?n+"":n,e);var De=class{constructor(n,e,t,s,i){this.myopId=n;this.htmlTagName=e;this.BoundingRect=t;this.offsetTop=s;this.offsetLeft=i;r(this,"type","MyopElementRef")}};var Gt=async o=>{if(typeof o=="function")o();else if(o instanceof Promise){let n=await o;typeof n=="function"&&n()}},pt=class{constructor(n){this.messageToHost=n}},Be=class extends pt{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 Le={};Fn(Le,{AddEventListenerMessage:()=>ft,BaseMyopMessage:()=>M,BindClickMessage:()=>lt,ChangeTextMessage:()=>mt,CleanupMessage:()=>Ie,CleanupReplayMessage:()=>we,ClickReplayMessage:()=>me,CreateRefComponentMessage:()=>Me,CustomRefMessage:()=>G,DetectMyopRefsMessage:()=>ht,DetectedMyopRefsMessage:()=>be,DisposeMessage:()=>xe,ElementValueReplayMessage:()=>ge,EnvelopedMessage:()=>Ce,EventListenerCallbackMessage:()=>ue,ExecuteComponentMethod:()=>D,ExecuteScriptMessage:()=>k,ExecuteScriptReplyMessage:()=>fe,GetAttributeMessage:()=>Mt,GetAttributeReplayMessage:()=>Ct,GetElementValueMessage:()=>gt,InitMessage:()=>se,InitRequest:()=>he,InitResponse:()=>ye,MessageDirection:()=>E,MutationObserverMessage:()=>It,MyopBindMessage:()=>x,MyopBindReplayMessage:()=>w,MyopElementMessage:()=>ct,Ref:()=>U,RefComponentCreatedMessage:()=>ie,ResizeObserverMessage:()=>wt,SetAttributeMessage:()=>ut,SetInnerHtml:()=>yt,SetMutationObserverMessage:()=>bt,SetResizeObserverMessage:()=>ve,stripFunction:()=>Xt});var R=()=>"10000000-1000-4000-8000-100000000000".replace(/[018]/g,o=>(+o^crypto.getRandomValues(new Uint8Array(1))[0]&15>>+o/4).toString(16));var Kn=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 Wn=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 dt=o=>{let n=Wn(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(Kn(n.slice(t,t+16)));return e};var Yt=o=>new Promise(n=>setTimeout(n,o));var E=class{};r(E,"down","down"),r(E,"up","up");var M=class{constructor(){r(this,"id",R());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}},ct=class extends M{constructor(e){super();this.ref=e}},w=class extends M{constructor(e){super();this.replayToHandler=e}},x=class extends M{constructor(e){super();this.handler=e;r(this,"handlerUniqueId",R())}},U=class o{constructor(n,e){this.refConfig=n;this.component=e;r(this,"myop",!0);r(this,"__nonProxied");this.__nonProxied=L(h({},this),{component:null})}static create(n,e,t){let s=e;return s||(s={id:"",name:"",description:"",selectorType:"id-attribute",selector:n,behavior:{type:"code"}}),new o(s,t)}};var Qt="ClickReplayMessage",lt=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",Qt);r(this,"messageType","BindClickMessage");r(this,"cleanable",!0)}},me=class extends w{constructor(){super(...arguments);r(this,"messageType",Qt)}};var mt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","ChangeTextMessage");this.content=t}};var Jt="ExecuteScriptReplyMessage",Nn=/(?:function\s*\w*\s*\([^)]*\)\s*\{([\s\S]*?)\}|(\([^)]*\)\s*=>\s*\{([\s\S]*?)\}))\s*$/,Un=/\(\s*[^)]+\s*\)\s*=>\s*(.+)/,Xt=o=>{let n=o.match(Nn);if(n)return n[1]||n[3];{let e=o.match(Un);if(e)return e[1].trim()}},k=class extends x{constructor(e,t=()=>{},s){super(t);this.scriptInputs=s;r(this,"replyMessageKey",Jt);r(this,"messageType","ExecuteScriptMessage");r(this,"script","");this.script=e.toString(),this.content=e.toString(),this.content=Xt(this.content)}};r(k,"replierKey","send"),r(k,"completeStreamKey","completeStream");var fe=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.content=t;r(this,"messageType",Jt)}};var G=class extends k{constructor(e,t,s=()=>{}){super(({rootRef:i,elementId:a,_script:p,__scriptInputs:d})=>{let c=(i.shadowRoot||i.container).querySelectorAll("[myop-id='".concat(a,"']"));return c.length?(d.ref=c[0],new Function("return (".concat(p,")(...arguments)"))(d)):null},s);this.scriptInputs=t;this.scriptInputs=L(h({},t),{_script:e.toString()})}};var Zt="EventListenerCallbackMessage",ft=class extends x{constructor(e,t,s){super(s);this.ref=e;this.type=t;this.handler=s;r(this,"replyMessageKey",Zt);r(this,"messageType","AddEventListenerMessage");r(this,"cleanable",!0);r(this,"serializableSkeleton",!1)}withSerializableSkeleton(e){return this.serializableSkeleton=e,this}},ue=class extends w{constructor(e,t){super(e);this.replayToHandler=e;this.e=t;r(this,"messageType",Zt);this.content={e:t}}};var ut=class extends M{constructor(e,t,s){super();this.ref=e;this.name=t;this.value=s;r(this,"messageType","SetAttributeMessage")}};var en="ElementValueReplayMessage",gt=class extends x{constructor(e,t){super(t);this.ref=e;r(this,"replyMessageKey",en);r(this,"messageType","GetElementValueMessage")}},ge=class extends w{constructor(e){super();this.content=e;r(this,"messageType",en)}};var yt=class extends M{constructor(e,t){super();this.ref=e;r(this,"messageType","SetInnerHtml");this.content=t}};var se=class extends M{constructor(e){super();r(this,"messageType","InitMessage");this.content={id:e}}isTypeof(e){return e.messageType===this.messageType}},ye=class extends se{constructor(){super(...arguments);r(this,"messageType","InitResponse")}},he=class extends M{constructor(){super(...arguments);r(this,"messageType","InitRequest")}};var tn="RefComponentCreatedMessage",Me=class extends x{constructor(e,t,s,i){super(i);this.refConfig=e;this.nestedComponentConfig=t;this.options=s;r(this,"replyMessageKey",tn);r(this,"messageType","CreateRefComponentMessage")}},ie=class extends w{constructor(e,t,s){super(e);this.replayToHandler=e;this.nestedRefs=t;this.failed=s;r(this,"messageType",tn)}};var Ce=class extends M{constructor(e,t){super();this.destination=e;this.message=t;r(this,"messageType","EnvelopedMessage");let s=t;this.route=[e,...s.route?s.route:[]]}};var nn="DetectedMyopRefsMessage",ht=class extends x{constructor(){super(...arguments);r(this,"messageType","DetectMyopRefsMessage");r(this,"replyMessageKey",nn)}},be=class extends w{constructor(e,t){super(e);this.replayToHandler=e;r(this,"messageType",nn);this.content=t}isTypeof(e){return e.messageType===this.messageType}};var on="GetAttributeReplayMessage",Mt=class extends x{constructor(e,t,s){super(s);this.ref=e;this.name=t;r(this,"replyMessageKey",on);r(this,"messageType","GetAttributeMessage")}},Ct=class extends w{constructor(e){super();this.content=e;r(this,"messageType",on)}};var D=class extends M{constructor(e){super();this.method=e;r(this,"messageType","ExecuteComponentMethod")}};var bt=class extends M{constructor(){super(...arguments);r(this,"messageType","SetMutationObserverMessage")}},It=class extends M{constructor(){super(...arguments);r(this,"messageType","MutationObserverMessage")}};var sn="CleanupReplayMessage",Ie=class extends x{constructor(e,t){super(t);this.cleanupForMessageId=e;r(this,"replyMessageKey",sn);r(this,"messageType","CleanupMessage")}},we=class extends w{constructor(e){super();this.customCleanup=e;r(this,"messageType",sn)}};var xe=class extends M{constructor(){super(...arguments);r(this,"messageType","DisposeMessage")}};var ve=class extends M{constructor(){super(...arguments);r(this,"cleanable",!0);r(this,"messageType","SetResizeObserverMessage")}},wt=class extends M{constructor(){super(...arguments);r(this,"messageType","ResizeObserverMessage")}};var xt=class{constructor(n,e){this.id=n;this.context=e;r(this,"send",n=>{})}},Pe=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!==E.down)return;if(t.messageType===y.DisposeMessage){t.destination&&delete this.components[t.destination];return}if(t.messageType===y.InitMessage){let s=t.content.id;if(this.components[s])return;this.components[s]=new xt(s),this.messageToHost(new ye(s));return}if(t.messageType===y.EnvelopedMessage){let s=t,i=s.message;if(t=i,this.alwaysPassEnvelopesToHost||this.components[t.destination]){let a=myop.hostSDK.components.find(d=>d.id===i.destination);if(a){a.send(i);return}let p=myop.hostSDK.components.find(d=>d.id===s.destination);if(p){p.send(i);return}}else return}if(t.messageType){if(t.messageType===y.CleanupMessage){let i=t,a=this.messageCleanupCache[i.cleanupForMessageId],p=new we(!!a);p.destination=t.destination,a?(delete this.messageCleanupCache[i.cleanupForMessageId],Gt(a).then(()=>{this.messageToHost(p,i)}).catch(()=>{})):this.messageToHost(p,i);return}let s=!1;this.supportedHandlers.forEach(i=>{if(i.messageType===t.messageType){s=!0;let a=i.executor(t);if(t.cleanable&&a&&(this.messageCleanupCache[t.id]=a),a&&!t.cleanable)throw new Error("Cleanup handler generated for non-cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."));if(!a&&t.cleanable)throw new Error("No cleanup handler generated for a cleanable message. \nmessageType - ".concat(t.messageType,", handler executor was - ").concat(i.executor,"\n\nPlease review the message definition object & message handler.\nTo ensure cleanup properly set 'cleanable' true at message definition and return IMessageExecutorCleanup from your handlers."))}})}else console.log("unsupported message type")}}};var A={IframeLoader:"IframeLoader",WebComponentLoader:"WebComponentLoader",HTMLLoader:"HTMLLoader",MinimizedLoader:"MinimizedLoader"};var Y={open:"open",closed:"closed",none:"none",localFrame:"localFrame"};var ae={message:"message",code:"code"},re=class{};r(re,"code","code"),r(re,"component","component");var Q={Segmented:"Segmented",Dedicated:"Dedicated",Default:"Default"},ze={Segment:"Segment",Promo:"Promo",AB:"AB"},Oe=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 $e={webcomponent_message_key:"myop_webcomponent_message"};var I=class extends Be{constructor(e,t){super(e);this.context=t;r(this,"executor",e=>{if(e.destination){let t=e.destination;if(this.context[t].context){let s=(i,a)=>{this.messageToHost(L(h({},i),{source:e.destination?e.destination:e.source,destination:e.source?e.source:e.destination}),a)};return this.innerExecutor(e,this.context[t].context,s)}else debugger}else debugger})}};var F={id:"myop-id"};var B=(o,n)=>n.querySelectorAll("[".concat(F.id,"='").concat(o.refConfig.selector,"']"));var Ae=class extends I{constructor(){super(...arguments);r(this,"messageType",y.BindClickMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=()=>{s(new me(e.handlerUniqueId))};p.addEventListener("click",d),a.push(()=>{p.removeEventListener("click",d)})}),()=>{a.forEach(p=>p())}})}};var Fe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ChangeTextMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.textContent=e.content})})}};var Ke=class extends Oe{constructor(e,t){super(e,t);this.container=e;this.shadowRoot=t}};var We=class extends I{constructor(){super(...arguments);r(this,"innerExecutor",(e,t)=>{let s=t.shadowRoot.querySelectorAll("[".concat(F.id,"]")),i=[];s.forEach(a=>{let p=a.getAttribute(F.id);p&&i.push(new De(p,a.tagName,a.getBoundingClientRect(),a.offsetTop,a.offsetLeft))}),this.messageToHost(new be(e.handlerUniqueId,i))});r(this,"messageType",y.DetectMyopRefsMessage)}};var Ne="__federation__",rn="onLoad";var Ue=(o,n)=>{window[Ne]&&window[Ne][o]&&window[Ne][o][rn]&&window[Ne][o][rn]({[o]:n})};var qe=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetAttributeMessage);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.setAttribute(e.name,e.value)})})}};var vt=o=>o!==Object(o),qn=o=>typeof o=="function",St=o=>{if(vt(o))return!0;if(qn(o)||Object.getPrototypeOf(o))return!1;for(let n in o){let e=o[n];if(typeof e=="object"){if(!St(e))return!1}else{if(vt(e))continue;return!1}}return!0},K=(o,n={},e=!0,t=new WeakMap)=>{if(vt(o))return o;if(Array.isArray(o)){if(t.has(o))return t.get(o);let s=[];t.set(o,s);for(let i=0;i<o.length;i++){let a=o[i];s[i]=K(a,n,e,t)}return s}if(o!==null&&typeof o=="object"){if(t.has(o))return t.get(o);let s={};t.set(o,s);for(let i in o){let a=typeof n=="boolean"?n:n[i];a&&(a===!0?(e?o[i]!==void 0:o[i])&&(s[i]=K(o[i],!0,e,t)):typeof a=="object"&&(s[i]=K(o[i],a,e,t)))}return s}return{}};var Ve=class extends I{constructor(){super(...arguments);r(this,"messageType",y.AddEventListenerMessage);r(this,"innerExecutor",(e,t,s)=>{let i=B(e.ref,t.shadowRoot),a=[];return i.forEach(p=>{let d=c=>{s(new ue(e.handlerUniqueId,K(c,e.serializableSkeleton)))};p.addEventListener(e.type,d),a.push(()=>{p.removeEventListener(e.type,d)})}),()=>{a.forEach(p=>p())}})}};var z=class{constructor(n,e,t){this.componentDefinition=n;this.container=e;r(this,"id","");r(this,"messageHandlers",{});r(this,"element");r(this,"_markedForDisposed",!1);r(this,"bind",(n,e)=>{this.messageHandlers[n]||(this.messageHandlers[n]=[]),this.messageHandlers[n].includes(e)||this.messageHandlers[n].push(e)});r(this,"bindWhen",(n,e,t)=>{if(!t)throw new Error("can't use component.bindWhen without an handler");this.messageHandlers[n]||(this.messageHandlers[n]=[]);let s=this.messageHandlers[n],i=a=>e(a)?(t(a),!0):!1;return s.push(i),()=>{let a=s.indexOf(i);a>-1&&s.splice(a,1)}});r(this,"setInitiated",()=>{this.isInitiated=!0,this._whenInitiatedResolve&&this._whenInitiatedResolve()});r(this,"isInitiated",!1);r(this,"_whenInitiatedResolve");r(this,"_whenInitiatedReject");r(this,"_whenInitiated",new Promise((n,e)=>{this._whenInitiatedResolve=n,this._whenInitiatedReject=e}));r(this,"initiated",()=>this._whenInitiated);r(this,"props",{});r(this,"refs",{});this.id=(t==null?void 0:t.id)||q.Instance().assignId(n);let s=t!=null&&t.timeout?t==null?void 0:t.timeout:5*1e3;setTimeout(()=>{!this.isInitiated&&this._whenInitiatedReject&&!this._markedForDisposed&&this._whenInitiatedReject("timeout_".concat(s," ").concat(this.id))},s),this.initiated().then(()=>{window.myop.hostSDK.inspected&&this.inspect()})}get markedForDisposed(){return this._markedForDisposed}set markedForDisposed(n){if(this._markedForDisposed)throw new Error("InvalidOperationException: The component is already in the process of being disposed. Dispose operation cannot be performed again until the current disposal process is complete.");this._markedForDisposed=n}onMessageReceived(n){if(n.messageType===y.ExecuteComponentMethod){let t=n;return this[t.method]?this[t.method](t.content):console.log("method not found ".concat(t.method," on component"),this),!0}let e=this.messageHandlers[n.messageType];if(e&&e.length){let t=!1;return e.forEach(s=>{t=t||s(n)}),t}return!1}sendCleanupMessage(n){n.source=this.id,n.destination=this.id,n.direction=E.down;let e=this.bindWhen(n.replyMessageKey,s=>s.replayToHandler===n.handlerUniqueId,s=>{n.handler(s),e()}),t=n.handler;delete n.handler,this.send(n),n.handler=t}send(n){n.source||(n.source=this.id),n.destination||(n.destination=this.id),n.direction=E.down;let e;if(n.handler){let t=n;e=this.bindWhen(t.replyMessageKey,s=>s.replayToHandler===t.handlerUniqueId,t.handler),delete n.handler}return n.ref&&(n.ref=n.ref.__nonProxied||n.ref),n.cleanable?()=>{this.sendCleanupMessage(new Ie(n.id,t=>{})),e&&e()}:()=>{}}dispose(){if(this.markedForDisposed=!0,!this.isInitiated)return;console.log("disposing component",this.id),this.send(new xe);let n=this.messageHandlers.onDispose;n&&n.forEach(e=>{e(null)}),this.messageHandlers={},this.id+="_disposed",this.isInitiated=!1}};var an={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 Se=class extends z{constructor(e,t,s){super(e,t.container,s);this.componentDefinition=e;this.parent=t;r(this,"send",e=>{let t=e.handler,s=super.send(e);return this.parent.send(new Ce(this.id,e)),e.handler=t,s});r(this,"dispose",()=>{this.isInitiated&&this.send(new D("dispose")),super.dispose()})}hide(){this.send(new D("hide"))}show(){this.send(new D("show"))}inspect(){return this.send(new D("inspect"))}setHeightBasedOnDocumentElement(){this.send(new D("setHeightBasedOnDocumentElement"))}setHeightBasedOnScrollHeight(){this.send(new D("setHeightBasedOnScrollHeight"))}onMessageReceived(e){return super.onMessageReceived(e)}};var J=class extends z{constructor(e,t,s,i,a,p){super(e,s,p);this.container=s;this.customElement=i;this.tagName=a;r(this,"ctaCleanup");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_ctaListener",e=>{let t=e.detail;t!=null&&t.action&&(this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}))});r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=super.send(e);return console.debug("[MyopExtractedWebComponent] send() called - web components use direct API instead",e),t});r(this,"dispose",()=>{var e;this.ctaCleanup&&this.ctaCleanup(),super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i,this.customElement.addEventListener("myop-cta",this._ctaListener),this.ctaCleanup=()=>this.customElement.removeEventListener("myop-cta",this._ctaListener),this.setInitiated()}inspect(){return this.cleanupInspect=pe(this.id,"MyopExtractedWebComponent",0,this.container,this.customElement,this.componentDefinition),this.cleanupInspect}hide(){this.customElement.style.opacity="0",this.customElement.style.position="absolute",this.customElement.style.pointerEvents="none",this.customElement.style.visibility="hidden",this.customElement.style.height="0",this.customElement.style.width="0"}show(){this.customElement.style.opacity="1",this.customElement.style.position="unset",this.customElement.style.pointerEvents="all",this.customElement.style.visibility="visible",this.customElement.style.height="",this.customElement.style.width=""}initWithData(e){typeof this.customElement.myop_init_interface=="function"&&this.customElement.myop_init_interface(e)}getData(){if(typeof this.customElement.myop_init_interface=="function")return this.customElement.myop_init_interface()}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}};var Vn=(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},pe=(o,n,e,t,s,i)=>{let a=Vn("".concat(i.name," : ").concat(n),e,i);return t.insertBefore(a,s),s.style.border="1px solid #007BFF",s.style.display="block",()=>{s.style.border="unset",t.removeChild(a)}},pn=(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),dn=(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."))},cn=(o,n,e)=>{let t=n.reduce((i,a)=>L(h({},i),{[a.name]:h({},a)}),{}),s={get:(i,a)=>{let p=t[a];if(pn(p,a,o))return!1;if(p.behavior.type===ae.code){if(o instanceof J)return(p.behavior.remap||a)==="myop_init_interface"?u=>{if(u===void 0)return o.getData();o.initWithData(u)}:void 0;if(o instanceof W&&o.isolated)return(p.behavior.remap||a)==="myop_init_interface"?u=>{if(u===void 0)return o.getData();o.initWithData(u)}:void 0;if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let c=p.behavior;return o.element.contentWindow[c.remap||a]}return dn(p,a,o),!1}return p.mode==="output"?new Promise(d=>{let c=[];p.behavior.ref&&c.push(U.create(p.behavior.ref)),c.push(m=>{d(m)}),p.behavior.params&&c.push(...p.behavior.params);let u=Le[p.behavior.message];o.send(new u(...c))}):null},set:(i,a,p)=>{let d=t[a];if(pn(d,a,o))return!1;if(d.behavior.type===ae.code){if(o instanceof J){let u=d.behavior.remap||a;if(u==="myop_cta_handler")return o.setCtaHandler(p),!0;if(u==="myop_init_interface")return o.initWithData(p),!0}if(o instanceof W&&o.isolated){let u=d.behavior.remap||a;if(u==="myop_cta_handler")return o.setCtaHandler(p),!0;if(u==="myop_init_interface")return o.initWithData(p),!0}if(e.loader.type===A.HTMLLoader&&e.loader.shadowRootMode===Y.localFrame){let u=d.behavior,m=o.element.contentWindow,g=u.remap||a;if(m[g]=p,g==="myop_cta_handler"&&m.__myop_cta_queue){let f=m.__myop_cta_queue;m.__myop_cta_queue=null,f.forEach(l=>{o.markedForDisposed||p(l.action,l.payload)})}return!0}return dn(d,a,o),!1}else if(d.mode==="input")if(d.behavior.type==="message"){let c=[];d.behavior.ref&&c.push(U.create(d.behavior.ref)),c.push(p),d.behavior.params&&c.push(...d.behavior.params);let u=Le[d.behavior.message];return o.send(new u(...c)),!0}else throw new Error("Error: Unsupported Behavior\n\nThe 'behavior' field provided is not supported.\n"+"Component: ".concat(o.componentDefinition.name,", ID: ").concat(o.componentDefinition.id,"\n\n")+"Prop Name: ".concat(a,"\n")+"Behavior Field: ".concat(d.behavior.type,"\n\n")+"Check the documentation for valid behavior options.");return!1}};return o.props={},o.props=new Proxy(o.props,s),o},jn=(o,n)=>new Proxy(o,{get(e,t){return e[t]?e[t]:(...i)=>new Promise(a=>{i.forEach(p=>{St(p)||an.notSerializableRefCall(t,p)}),n.send(new G(({ref:p,propName:d,functionArgs:c,makeSerializable:u})=>{if(p){let m=p[d];return u(typeof m=="function"?p[d](...c):m,!0)}return null},{elementId:e.refConfig.selector,propName:t,functionArgs:i},p=>{a(p.content)}))})},set(e,t,s){return n.send(new G(({ref:i,propName:a,propValue:p})=>{i&&(i[a]=p)},{elementId:e.refConfig.selector,propValue:s,propName:t},i=>{})),!0}}),Et=async(o,n,e,t)=>{let s=o.component;if(!s)throw new Error("cant createRefComponent with detached ref");return new Promise(async(i,a)=>{let p=new Se(n.type,s,t);e.push(p),await s.initiated();let d=setTimeout(()=>{a("timeout")},5e3);s.send(new Me(o.refConfig,n,L(h({},t||{}),{id:p.id,_hasParent:!0}),async c=>{if(clearTimeout(d),c.failed){a("CreateRefComponentMessage failed");return}let u=e.find(m=>m.id==p.id);if(u!==p){s.refs[o.refConfig.name]=u,i(u);return}else p.setInitiated(),s.refs[o.refConfig.name]=p;c.nestedRefs.forEach(m=>{let g=n.instance.resolvedNestedComponents.find(l=>l.type.id===m.componentDefinitionId).type,f=new Se(g,p);f.setInitiated(),p.refs[m.refName]=f,e.push(f)});try{await _t(p,n,e,!0),s.setHeightBasedOnScrollHeight&&s.setHeightBasedOnScrollHeight(),i(p)}catch(m){a(m)}}))})},_t=async(o,n,e,t=!1)=>{o.refs||(o.refs={});let s=Object.values(o.componentDefinition.refs).map(i=>new Promise(async(a,p)=>{var d;if(i.behavior.type==re.component){if(t){a();return}let c=i.behavior.componentId;c||(c=i.behavior.instance.componentId);let u=(d=n.instance.resolvedNestedComponents)==null?void 0:d.find(g=>g.type.id===c);if(!u)throw new Error("componentConfig provided without nestedComponentConfig check the config object");let m=U.create("",i,o);try{let g=await Et(m,u,e);o.refs[i.name]=g,a()}catch(g){p(g)}}else try{let c=U.create("",i,o);o.refs[i.name]=jn(c,o),a()}catch(c){}}));try{await Promise.all(s)}catch(i){throw i}};var W=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.componentConfig=e;this.container=s;this.IframeElement=i;r(this,"_autoSizeCleanup");r(this,"_autoSizeOptions");r(this,"_autoSizeUpdate");r(this,"isolated",!1);r(this,"_lastData");r(this,"_ctaHandler");r(this,"_ctaQueue",[]);r(this,"_isoMsgHandler");r(this,"_isoSizeOpts");r(this,"_isoAutoSize",!1);r(this,"_isoLastSize");r(this,"sizeMeta");r(this,"cleanupInspect");r(this,"setHeightBasedOnDocumentElement",()=>{let e=this.send(new k(()=>window.document.documentElement.scrollHeight,t=>{this.IframeElement.style.height="".concat(t.content,"px"),e()}))});r(this,"observeSizeBasedOnDocumentElement",()=>this.send(new k(({send:t})=>{let{height:s,width:i}=document.documentElement.getBoundingClientRect(),a=new ResizeObserver(()=>{let{height:p,width:d}=document.documentElement.getBoundingClientRect();t({height:p,width:d})});return a.observe(document.documentElement),a.observe(document.body),{height:s,width:i}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px")})));r(this,"observeAutoSize",e=>{if(this._autoSizeOptions=e,this.isolated)return this._isoSizeOpts=e,this._isoAutoSize=!0,this._isoLastSize&&this._applyIsoSize(this._isoLastSize.height,this._isoLastSize.width),()=>{this._isoAutoSize=!1,this._isoSizeOpts=void 0};if(this._autoSizeCleanup&&this._autoSizeUpdate)return this._autoSizeUpdate(),this._autoSizeCleanup;let t=this.IframeElement,s=t.contentDocument;if(!s)return this.observeHeightViaBridge();let i=(f,l,_)=>l!==void 0&&f<l?l:_!==void 0&&f>_?_:f,a=f=>{if(f===void 0)return;if(typeof f=="number")return f;let l=parseFloat(f);return isNaN(l)?void 0:l},p=()=>{var Ot,zt,$t,At,Ft,Kt,Wt,Nt;let f=t.contentDocument;if(!f)return;let l=this._autoSizeOptions,_=a(l==null?void 0:l.minWidth),T=a(l==null?void 0:l.maxWidth),N=a(l==null?void 0:l.minHeight),v=a(l==null?void 0:l.maxHeight),Z=(Ot=l==null?void 0:l.loaderMinHeight)!=null?Ot:50,j=((zt=this.sizeMeta)==null?void 0:zt.width)==="100%"?"100%":void 0,H=(($t=this.sizeMeta)==null?void 0:$t.height)==="100%"?"100%":void 0,b=(Ft=(At=l==null?void 0:l.explicitWidth)!=null?At:j)!=null?Ft:"100%",C=(Kt=l==null?void 0:l.explicitHeight)!=null?Kt:H,S=b!==void 0,ee=C!==void 0,te=this.container.getBoundingClientRect(),En=te.width===0,_n=te.height===0||te.height===Z,ne=(l!=null&&l.forceAutoSize||En)&&!S,oe=(l!=null&&l.forceAutoSize||_n)&&!ee;if(!ne&&!oe){t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",(Wt=l==null?void 0:l.onSizeChange)==null||Wt.call(l,{width:typeof b=="number"?b:void 0,height:typeof C=="number"?C:void 0,autoSizingWidth:!1,autoSizingHeight:!1});return}let Tn=t.style.transition,$=this.container,Rn=$.style.transition;t.style.transition="none",$.style.transition="none";let kt=t.getBoundingClientRect().height,Ht=t.getBoundingClientRect().width,Dt=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height)),Bt=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),ce=Bt,le=Dt,kn=oe&&Dt>kt+1,Hn=ne&&Bt>Ht+1,Re=oe&&!kn,ke=ne&&!Hn;if(Re||ke){let Ln=$.style.minHeight,Pn=$.style.minWidth;Re&&($.style.minHeight="".concat(kt,"px")),ke&&($.style.minWidth="".concat(Ht,"px")),Re&&(t.style.height="0px"),ke&&(t.style.width="0px"),ce=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height));let Ut=Re&&le<2,qt=ke&&ce<2;if(Ut||qt){let He=f.createElement("style");He.id="__myop_measure";let rt=[];Ut&&rt.push("height: auto !important","min-height: 0 !important","max-height: none !important"),qt&&rt.push("width: auto !important","min-width: 0 !important","max-width: none !important"),He.textContent="*, *::before, *::after { ".concat(rt.join("; "),"; flex-basis: auto !important; flex-grow: 0 !important; }"),f.head.appendChild(He),ce=Math.ceil(Math.max(f.documentElement.scrollWidth,f.body.scrollWidth,f.body.getBoundingClientRect().width)),le=Math.ceil(Math.max(f.documentElement.scrollHeight,f.body.scrollHeight,f.body.getBoundingClientRect().height)),He.remove()}$.style.minHeight=Ln,$.style.minWidth=Pn}let Lt=i(ce,_,T),Pt=i(le,N,v);ne?t.style.width="".concat(Lt,"px"):t.style.width=typeof b=="number"?"".concat(b,"px"):"100%",oe?t.style.height="".concat(Pt,"px"):t.style.height=typeof C=="number"?"".concat(C,"px"):"100%",t.offsetHeight,t.style.transition=Tn,$.style.transition=Rn;let Dn=ne&&T!==void 0&&ce>T,Bn=oe&&v!==void 0&&le>v;f.documentElement.style.overflowX=Dn?"auto":"",f.documentElement.style.overflowY=Bn?"auto":"",(Nt=l==null?void 0:l.onSizeChange)==null||Nt.call(l,{width:Lt,height:Pt,autoSizingWidth:ne,autoSizingHeight:oe})};p(),this._autoSizeUpdate=p;let d,c=()=>{d===void 0&&(d=requestAnimationFrame(()=>{d=void 0,p()}))},u=new ResizeObserver(()=>c());u.observe(s.body),u.observe(s.documentElement);let m=new MutationObserver(()=>c());m.observe(s.body,{childList:!0,subtree:!0,characterData:!0,attributes:!0});let g=()=>{u.disconnect(),m.disconnect(),d!==void 0&&(cancelAnimationFrame(d),d=void 0),this._autoSizeUpdate=void 0,this._autoSizeCleanup=void 0};return this._autoSizeCleanup=g,g});r(this,"_bridgeSizeCleanup");r(this,"observeHeightViaBridge",()=>{if(this._bridgeSizeCleanup)return this._bridgeSizeCleanup;let e,t=!1,s=()=>{t=!0,e==null||e(),this._bridgeSizeCleanup=void 0};return this._bridgeSizeCleanup=s,this.initiated().then(()=>{t||this.markedForDisposed||(this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.width="100%",this.setHeightBasedOnScrollHeight(),e=this.send(new ve))}).catch(()=>{}),s});r(this,"setSizeBasedOnDocumentElement",()=>{let e=this.send(new k(()=>{let{height:t,width:s}=document.documentElement.getBoundingClientRect();return{height:t,width:s}},t=>{this.IframeElement.style.width="".concat(t.content.width,"px"),this.IframeElement.style.height="".concat(t.content.height,"px"),e()}))});r(this,"setHeightBasedOnScrollHeight",()=>{let e=this.send(new k(()=>{let s=0;return s++,s--,Math.max(Math.max(window.document.body.clientHeight,window.document.body.scrollHeight),window.document.body.offsetHeight)+s+"px"},t=>{this.IframeElement.style.height=t.content,e()}))});r(this,"send",e=>{var i,a;let t=h({},e);if(t.messageType===y.ExecuteComponentMethod)return this[t.method](),()=>{};t.direction=E.down;let s=super.send(t);return(a=(i=this.IframeElement)==null?void 0:i.contentWindow)==null||a.postMessage(t,"*"),s});r(this,"dispose",()=>{var e;(e=this._bridgeSizeCleanup)==null||e.call(this),this._autoSizeCleanup&&(this._autoSizeCleanup(),this._autoSizeCleanup=void 0),this._isoMsgHandler&&(window.removeEventListener("message",this._isoMsgHandler),this._isoMsgHandler=void 0),this.cleanupInspect&&this.cleanupInspect(),super.dispose(),this.IframeElement.parentNode.removeChild(this.IframeElement)});this.element=this.IframeElement,this._lastData=a==null?void 0:a.data}enableIsolation(){this.isolated=!0,this.setInitiated(),this._isoMsgHandler=e=>{if(e.source!==this.IframeElement.contentWindow)return;let t=e.data;!t||t.__myop!==!0||(t.type==="myop:cta"?this._ctaHandler&&!this.markedForDisposed?this._ctaHandler(t.action,t.payload):this._ctaHandler||this._ctaQueue.push({action:t.action,payload:t.payload}):t.type==="myop:size"&&this._applyIsoSize(t.height,t.width))},window.addEventListener("message",this._isoMsgHandler)}initWithData(e){var t,s;this._lastData=e,(s=(t=this.IframeElement)==null?void 0:t.contentWindow)==null||s.postMessage({__myop:!0,type:"myop:init",data:e},"*")}getData(){return this._lastData}setCtaHandler(e){if(this._ctaHandler=e,this._ctaQueue.length>0){let t=[...this._ctaQueue];this._ctaQueue=[],t.forEach(s=>{this.markedForDisposed||e(s.action,s.payload)})}}_applyIsoSize(e,t){var c;if(!e||Number.isNaN(e)||(this._isoLastSize={height:e,width:t},!this._isoAutoSize))return;let s=this._isoSizeOpts,i=u=>u===void 0?void 0:typeof u=="number"?u:isNaN(parseFloat(u))?void 0:parseFloat(u),a=i(s==null?void 0:s.minHeight),p=i(s==null?void 0:s.maxHeight),d=e;a!==void 0&&d<a&&(d=a),p!==void 0&&d>p&&(d=p),this.IframeElement.style.position="relative",this.IframeElement.style.inset="auto",this.IframeElement.style.height=d+"px",this.IframeElement.style.width="100%",(c=s==null?void 0:s.onSizeChange)==null||c.call(s,{width:t!=null?t:this.IframeElement.clientWidth,height:d,autoSizingWidth:!1,autoSizingHeight:!0})}inspect(){return this.cleanupInspect?this.cleanupInspect:(this.cleanupInspect=pe(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 V=class{constructor(){r(this,"appendChild",(n,e,t)=>{var s;if(t!=null&&t.relative){if(t.relative.direction==="before")return n.insertBefore(e,t.relative.child);if(t.relative.direction==="after"){let i=(s=t.relative.child)==null?void 0:s.nextSibling;return n.insertBefore(e,i||null)}}else return n.appendChild(e)})}};var Gn=(o,n,e)=>{let t=new URL(o);return t.searchParams.append(n,e),t.toString()},je=class extends V{constructor(){super(...arguments);r(this,"type",A.IframeLoader);r(this,"load",async(e,t,s,i)=>{let a,p=t.loader;if((s==null?void 0:s.nodeName)==="IFRAME")console.log("needs to load into an exsisting Iframe...",p.url,s),a=s,a.src=p.url;else{let c=R(),u="myop-comp-".concat(c);a=document.createElement("iframe"),a.id=u;let m="\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n height: ".concat(p.autoHeight||!p.height?"100%":p.height,";\n width: 100%;\n overflow: hidden;\n border: none;\n opacity: ").concat(i!=null&&i.hidden?"0":"1",";\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n ");a.style.cssText=m,i!=null&&i.elementAttributes&&Object.entries(i.elementAttributes).forEach(([f,l])=>{l===""||l===null||l===void 0?a.setAttribute(f,""):a.setAttribute(f,String(l))});let g=t.loader.url;i!=null&&i._hasParent&&(g=Gn(g,"_myop-comp",c)),a.src=g,s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),a=this.appendChild(s,a,i)}let d=new W(e,t,s,a,i);return p.autoHeight&&(i==null?void 0:i.autoSize)!==!1&&d.observeHeightViaBridge(),d})}};var de=class extends z{constructor(e,t,s,i,a){super(e,s,a);this.container=s;this.customElement=i;r(this,"cleanupInspect",()=>{});r(this,"send",e=>{let t=h({},e),s=super.send(t),i=new CustomEvent($e.webcomponent_message_key,{detail:t});try{this.customElement.dispatchEvent(i)}catch(a){console.log("error while trying to dispatchEvent",a)}return s});r(this,"dispose",()=>{var e;super.dispose(),(e=this.customElement.parentNode)==null||e.removeChild(this.customElement)});this.element=i}inspect(){return this.cleanupInspect=pe(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 Tt={},Ge=class extends V{constructor(){super(...arguments);r(this,"type",A.WebComponentLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader;Tt[a.url]?console.log("Module alreday loaded or in loading process"):Tt[a.url]=new Promise((c,u)=>{let m=a.url,g=document.createElement("script");g.type="module",g.src=m,g.onload=()=>{c()},g.onerror=()=>{u()},document.head.appendChild(g)}),await Tt[a.url],await Yt(1);let p="myop-comp-".concat(R()),d=document.createElement(a.tag);return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),d.id=p,i!=null&&i.hidden&&(d.style.opacity="0",d.style.position="absolute",d.style.height="0",d.style.width="0",d.style.pointerEvents="none",d.style.visibility="hidden"),i!=null&&i._environment&&(d._myopEnvironment=i==null?void 0:i._environment),this.appendChild(s,d,i),new de(e,t,s,d,i)})}};var ln="0.4.0-beta.1";var Yn="myop-delivery",Je="components";var Ye=null;function Qn(){return Ye||(Ye=new Promise(o=>{try{if(typeof indexedDB>"u")return o(null);let n=indexedDB.open(Yn,1);n.onupgradeneeded=()=>{let e=n.result;e.objectStoreNames.contains(Je)||e.createObjectStore(Je,{keyPath:"key"})},n.onsuccess=()=>o(n.result),n.onerror=()=>o(null),n.onblocked=()=>o(null)}catch(n){o(null)}}),Ye)}function Qe(o,n){return Qn().then(e=>new Promise(t=>{if(!e)return t(null);try{let s=e.transaction(Je,o),i=n(s.objectStore(Je));i.onsuccess=()=>t(i.result),i.onerror=()=>t(null),s.onabort=()=>t(null)}catch(s){t(null)}}))}var Rt="myop.d.";function mn(o,n,e){try{localStorage.setItem(Rt+o,JSON.stringify({t:n,e}))}catch(t){}}function Jn(o){try{localStorage.removeItem(Rt+o)}catch(n){}}var Ee=new Map,P={key(o,n,e,t,s){return"".concat(o,"|").concat(n,"|").concat(e,"|").concat(t?"preview":"live","|").concat(s||"raw")},async get(o){let n=Ee.get(o);if(n)return n;let e=await Qe("readonly",t=>t.get(o));return e&&(Ee.set(o,e),mn(o,e.tag,e.storedAt+e.windowMs)),e},async put(o){Ee.set(o.key,o),mn(o.key,o.tag,o.storedAt+o.windowMs),await Qe("readwrite",n=>n.put(o))},async drop(o){Ee.delete(o),Jn(o),await Qe("readwrite",n=>n.delete(o))},fresh(o){return!!o&&Date.now()-o.storedAt<o.windowMs},windowFrom(o){let n=o.get("cache-control")||"";if(/no-store|no-cache/i.test(n))return 0;let e=/s-maxage\s*=\s*(\d+)/i.exec(n)||/max-age\s*=\s*(\d+)/i.exec(n);if(!e)return 0;let t=Number(e[1]),s=Number(o.get("age")||0);return Math.max(0,t-(isNaN(s)?0:s))*1e3},async clear(){Ee.clear();try{for(let o=localStorage.length-1;o>=0;o--){let n=localStorage.key(o);n&&n.startsWith(Rt)&&localStorage.removeItem(n)}}catch(o){}await Qe("readwrite",o=>o.clear())}};var fn=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:ae.code}},{id:"out_auto_v2_converted",name:"myop_cta_handler",type:"any",behavior:{type:ae.code}}],refs:[],skins:[{id:"skin_auto_v2_converted",name:"auto_v2_converted",description:"",loader:o.consume_variant[0].loader}],defaultSkin:0},name:o.name}),Xe="__MYOP_CLOUD_REPOSITORY_MAIN__",Xn=()=>{if(typeof window<"u")return window[Xe];if(typeof globalThis<"u")return globalThis[Xe]},Zn=o=>{typeof window<"u"&&(window[Xe]=o),typeof globalThis<"u"&&(globalThis[Xe]=o)},O=class O{constructor(n="https://cloud.myop.dev"){this._baseUrl=n;r(this,"variants",{});r(this,"preloadedComponents",{});r(this,"userFlows",{});r(this,"_defaultEnv","production");r(this,"_envExplicitlySet",!1);r(this,"_staticMode",!1);r(this,"_queryParams",{});r(this,"_delivery",{minify:!1,host:null,cache:!1});r(this,"_deliveryStats",{requests:0,viaDelivery:0,fellBack:0,lastError:null,fromMemory:0,fromStorage:0,fromNetwork:0,revalidations:0,unchanged:0,bytesSaved:0});r(this,"_localServes",new Map);r(this,"_flushBound",!1)}static get Main(){let n=Xn();return n||(O._main||(O._main=new O,Zn(O._main)),O._main)}static sizeOfHeld(n){var e,t,s,i,a;try{return(((a=(i=(s=(t=(e=n==null?void 0:n.config)==null?void 0:e.type)==null?void 0:t.skins)==null?void 0:s[0])==null?void 0:i.loader)==null?void 0:a.HTML)||"").length}catch(p){return 0}}setDelivery(n={}){n.minify!==void 0&&(this._delivery.minify=!!n.minify),n.host!==void 0&&(this._delivery.host=n.host),n.cache!==void 0&&(this._delivery.cache=!!n.cache)}deliveryStats(){var n;return L(h({},this._deliveryStats),{host:(n=this._delivery.host)!=null?n:O.DEFAULT_HOST,minify:this._delivery.minify,cache:this._delivery.cache})}async refreshDelivery(){await P.clear()}noteLocalServe(n,e){let t=this._localServes.get(n);t?t.count++:this._localServes.set(n,{env:e,count:1}),this.bindFlush()}bindFlush(){if(this._flushBound||typeof document>"u")return;this._flushBound=!0;let n=()=>{document.visibilityState==="hidden"&&this.flushLocalServes()};document.addEventListener("visibilitychange",n),window.addEventListener("pagehide",()=>this.flushLocalServes())}flushLocalServes(){if(!this._localServes.size)return;let n=[...this._localServes.entries()].map(([e,t])=>"".concat(e,":").concat(t.env,":").concat(t.count)).join(",");this._localServes.clear();try{let e="".concat(this.deliveryHost(),"/clientUsage?b=").concat(encodeURIComponent(n));fetch(e,{keepalive:!0,mode:"cors",credentials:"omit"}).catch(()=>{})}catch(e){}}deliveryHost(){return this._delivery.host||this._baseUrl}async deliveryFetch(n){var i;this._localServes.size&&this.flushLocalServes();let e=this.deliveryHost(),t="".concat(e).concat(n);this._deliveryStats.requests++;let s=e!==this._baseUrl;try{let a=await fetch(t);if(a.ok||a.status<500||!s)return s&&a.ok&&this._deliveryStats.viaDelivery++,a;this._deliveryStats.lastError="HTTP ".concat(a.status," from ").concat(e)}catch(a){if(!s)throw a;this._deliveryStats.lastError=String((i=a==null?void 0:a.message)!=null?i:a)}return this._deliveryStats.fellBack++,console.warn("[myop] delivery host failed (".concat(this._deliveryStats.lastError,") \u2014 falling back to ").concat(this._baseUrl)),await fetch("".concat(this._baseUrl).concat(n))}enableStaticMode(){this._staticMode=!0}setQueryParams(n){this._queryParams=n}setEnvironment(n){this._defaultEnv=n,this._envExplicitlySet=!0}getDefaultEnvironment(){return this._defaultEnv}isPreloaded(n,e,t){return e!==void 0||t!==void 0?"".concat(n,":").concat(e||this._defaultEnv,":").concat(t?"preview":"live")in this.variants:n in this.preloadedComponents}getPreloadedParams(n){return this.preloadedComponents[n]}async resolveComponent(n,e,t){return this.fetchComponentV2(n,e,t)}async fetchComponentV2(n,e,t){let{env:s,usePreview:i,cacheKey:a}=this.resolveParams(n,e,t);return console.log("[CloudRepository] fetchComponentV2",{componentId:n.slice(0,8)+"...",env:s,usePreview:i,cacheKey:a,cached:a in this.variants}),this.variants[a]||(this.preloadedComponents[n]||(this.preloadedComponents[n]={env:s,preview:i}),this.variants[a]=new Promise(async(p,d)=>{try{let c;if(this._staticMode){let N=i?"preview":s;c="".concat(this._baseUrl,"/components/").concat(n,"/").concat(N,".json");let v=new URLSearchParams(this._queryParams).toString();v&&(c+="?".concat(v))}else c="/consume?id=".concat(n,"&env=").concat(s),i&&(c+="&preview=true"),this._delivery.minify&&!i&&(c+="&opt=min");let u=this._delivery.cache&&!this._staticMode&&!i,m=u?P.key(this.deliveryHost(),n,s,i,this._delivery.minify?"min":"raw"):"",g=u?await P.get(m):null;if(g&&P.fresh(g)){this._deliveryStats.fromStorage++,this.noteLocalServe(n,s),this.variants[a].resolved=g.config,p(g.config);return}if(g&&g.tag){let N="/consume?ids=".concat(n,"&env=").concat(s)+(this._delivery.minify?"&opt=min":"")+"&have=".concat(encodeURIComponent(g.tag));this._deliveryStats.revalidations++;try{let v=await this.deliveryFetch(N);if(v.ok){let Z=await v.json();if((Z.unchanged||[]).includes(n)){this._deliveryStats.unchanged++,this._deliveryStats.bytesSaved+=O.sizeOfHeld(g),g.storedAt=Date.now(),g.windowMs=P.windowFrom(v.headers)||g.windowMs,await P.put(g),this.variants[a].resolved=g.config,p(g.config);return}let j=(Z.items||[])[0];if(j){let H=fn(j);this._deliveryStats.fromNetwork++,await P.put({key:m,config:H,tag:j.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(v.headers),host:this.deliveryHost()}),this.variants[a].resolved=H,p(H);return}}}catch(v){}}let f=this._staticMode?await fetch(c):await this.deliveryFetch(c);if(!f.ok){d(new Error('Failed to load component "'.concat(n,'" (').concat(f.status).concat(this._staticMode?" from ".concat(c):"",")")));return}let _=(await f.json()).item;if(!_){d(new Error('Component "'.concat(n,'" not found')));return}if(!_.consume_variant||!_.consume_variant.length){d(new Error('Component "'.concat(n,'" has no implementation for environment "').concat(s,'"')));return}let T=fn(_);this._deliveryStats.fromNetwork++,u&&await P.put({key:m,config:T,tag:_.tag||null,storedAt:Date.now(),windowMs:P.windowFrom(f.headers),host:this.deliveryHost()}),this.variants[a].resolved=T,p(T)}catch(c){delete this.variants[a],d(c)}})),await this.variants[a]}getResolvedConfig(n,e,t){var i;let{cacheKey:s}=this.resolveParams(n,e,t);return((i=this.variants[s])==null?void 0:i.resolved)||null}resolveParams(n,e,t){let s=this.preloadedComponents[n],i=e!==void 0||t!==void 0,a,p;if(!i&&s)a=s.env,p=s.preview;else{a=e||this._defaultEnv;let d=e||this._envExplicitlySet;p=t===!0?!0:t===!1?!1:!d}return{env:a,usePreview:p,cacheKey:"".concat(n,":").concat(a,":").concat(p?"preview":"live")}}hydrateComponent(n,e,t,s){let{env:i,usePreview:a,cacheKey:p}=this.resolveParams(n,t,s),d=Promise.resolve(e);d.resolved=e,this.variants[p]=d,this.preloadedComponents[n]={env:i,preview:a}}async fetchComponentV1(n,e){return e?(await this.fetchFlow(e)).components.find(s=>s.type.id===n):(await this.fetchAutoFlow(n)).components[0]}async fetchAutoFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&auto=true"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchFlow(n){return this.userFlows[n]||(this.userFlows[n]=new Promise(async(e,t)=>{try{let i=await(await fetch("".concat(this._baseUrl,"/flow?id=").concat(n,"&resolve=components"))).json();e(i.item)}catch(s){delete this.userFlows[n],t(s)}})),await this.userFlows[n]}async fetchComponent(n,e){return this.fetchComponentV1(n,e)}};r(O,"_main",null),r(O,"DEFAULT_HOST","https://cloud.myop.dev");var X=O;var Ze=X.Main;var eo="https://delivery.myop.dev",un=(o={})=>{var e,t;let n=o.minify!==!1||o.cache===!0;return Ze.setDelivery({minify:(e=o.minify)!=null?e:!1,cache:(t=o.cache)!=null?t:!1,host:o.host!==void 0?o.host:n?eo:null}),_e()},gn=async()=>(await Ze.refreshDelivery(),_e()),_e=()=>Ze.deliveryStats(),yn=()=>(Ze.setDelivery({minify:!1,cache:!1,host:null}),_e());var hn="";var to="<!-- myop-web-component -->",no="myop-web-component",Cn=new Map,bn=[],et,In=async()=>(et||(et=new Te,et.init()),et);function oo(o,n){return class extends HTMLElement{connectedCallback(){let e=n===Y.open?"open":"closed",t=this.attachShadow({mode:e});In().then(s=>{s.connectedCallback(this,t),t.innerHTML=o})}}}var so=(o,n,e)=>{customElements.define(o,oo(n,e)),console.log("define('".concat(o,"') was called, web component ready to use"))},io=o=>o.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/(\d+)/g,"-$1").toLowerCase(),ro=o=>(o=io(o),o.replace(/_/g,"-"));var tt=class extends V{constructor(){super(...arguments);r(this,"type",A.HTMLLoader);r(this,"load",async(e,t,s,i)=>{let a=t.loader,p=this.isMyopWebComponent(a.HTML),{mode:d,isolate:c}=await this.resolveRenderMode(e,t,a,p,i);if(d===!1)throw new Error('[Myop] Rendering blocked by render policy for component "'.concat(e.id,'"'));if(p){if(d!=="webComponent")throw new Error('[Myop] Web-component rendering denied by render policy for component "'.concat(e.id,'"'));return this.loadExtractedWebComponent(e,t,s,a.HTML,i)}let u="myop-comp-".concat(R()),m;if(a.shadowRootMode===Y.localFrame){let g=R(),f="myop-comp-".concat(g),l=document.createElement("iframe");l.id=f,c&&l.setAttribute("sandbox","allow-scripts allow-forms allow-popups"),l.style.cssText="\n display: block;\n padding: 0;\n margin: 0;\n position: absolute;\n inset: 0;\n overflow: hidden;\n border: none;\n opacity: ".concat(i!=null&&i.hidden?"0":"1",";\n width: 100%;\n height: 100%;\n pointer-events: ").concat(i!=null&&i.hidden?"none":"all",";\n "),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),l=this.appendChild(s,l,i);let _=[],T=c?{open(){},writeln(b){_.push(b)},close(){l.srcdoc=_.join("\n")}}:(()=>{let b=l.contentDocument||l.contentWindow.document;return b.open(),b})(),N=null;{let S=new DOMParser().parseFromString(a.HTML,"text/html").querySelector('meta[name="myop:size"]');if(S)try{N=JSON.parse(S.getAttribute("content")||"{}")}catch(ee){}}let v=a.HTML;if(i!=null&&i._inspection){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S==null||S.removeAttribute("type");let ee=C.implementation.createHTMLDocument();ee.body.innerHTML="<script>\n const beforeKeysWindow = new Set(Object.keys(window));\n window.myopState = {\n beforeKeysWindow,\n };\n <\/script>";let te=ee.body.firstChild;te&&C.head&&C.head.insertBefore(C.importNode(te,!0),C.head.firstChild),v="<!DOCTYPE html>"+C.documentElement.outerHTML}else if((i==null?void 0:i.data)!==void 0){let C=new DOMParser().parseFromString(a.HTML,"text/html"),S=C.getElementById("myop_preview");S&&(S.remove(),v="<!DOCTYPE html>"+C.documentElement.outerHTML)}if(i!=null&&i.injectCss){let C=new DOMParser().parseFromString(v,"text/html"),S=C.createElement("style");S.setAttribute("data-myop-injected","true"),S.textContent=i.injectCss.replace(/<\s*\/\s*style/gi,"<\\/style"),(C.head||C.documentElement).appendChild(S),v="<!DOCTYPE html>"+C.documentElement.outerHTML}T.writeln(v);let Z='<script src="'.concat(window.myop.__ROOT_SDK_PUBLIC_URL__,'"><\/script>'),j="<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||T.writeln("".concat(Z).concat(j)),!c&&(i==null?void 0:i.data)!==void 0){let b="<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(i.data).replace(/<\/script/gi,"\\u003c/script"),S='<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>");T.writeln(b+S)}if(c){let b=(i==null?void 0:i.data)!==void 0?JSON.stringify(i.data).replace(/<\/script/gi,"\\u003c/script"):"undefined";T.writeln(this.buildIsolationBridge(b))}T.close();let H=new W(e,t,s,l,i);return c&&H.enableIsolation(),H.sizeMeta=N,H.initiated().then(()=>{if((i==null?void 0:i.autoSize)===!1)return;let b=!1;H.observeAutoSize({forceAutoSize:!0,onSizeChange:()=>{!b&&!(i!=null&&i.hidden)&&(b=!0,H.show())}})}),H}if(a.shadowRootMode===Y.none){let g=document.createElement("template");g.innerHTML=a.HTML,m=g.content.firstElementChild,In().then(f=>{f.connectedCallback(m,m)})}else{let g=ro(e.name+t.id);bn.includes(g)||(so(g,a.HTML,a.shadowRootMode),bn.push(g)),m=document.createElement(g)}return s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),m.id=u,i!=null&&i.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),this.appendChild(s,m,i),new de(e,t,s,m,i)})}isMyopWebComponent(e){return e.trimStart().startsWith(to)}async resolveRenderMode(e,t,s,i,a){var u,m,g,f;let p=i?"webComponent":s.isolation||a!=null&&a.isolation?"isolatedIframe":"iframe",d=(f=a==null?void 0:a.renderPolicy)!=null?f:(g=(m=(u=window==null?void 0:window.myop)==null?void 0:u.hostSDK)==null?void 0:m.getRenderPolicy)==null?void 0:g.call(m),c=d?await d({componentDefinition:e,skin:t,requestedMode:p,isWebComponent:i}):p;return{mode:c,isolate:c==="isolatedIframe"}}buildIsolationBridge(e){return"<script>\n (function () {\n var __initial = ".concat(e,";\n var __pending;\n // data-out (cta)\n window.myop_cta_handler = function (action, payload) {\n try { parent.postMessage({ __myop: true, type: 'myop:cta', action: action, payload: payload }, '*'); } catch (e) {}\n };\n function callInit(data) {\n if (typeof window.myop_init_interface === 'function') { window.myop_init_interface(data); return true; }\n return false;\n }\n // data-in (init updates)\n window.addEventListener('message', function (e) {\n var d = e.data;\n if (!d || d.__myop !== true) return;\n if (d.type === 'myop:init') { if (!callInit(d.data)) __pending = d.data; }\n });\n // first render: use a pending update if one arrived, else the baked initial data\n (function flushInitial() {\n var data = (__pending !== undefined) ? __pending : __initial;\n if (data === undefined) return;\n if (callInit(data)) { __pending = undefined; __initial = undefined; }\n else requestAnimationFrame(flushInitial);\n })();\n // resize (report content size)\n function contentHeight() {\n // Measure the BODY (content box). documentElement.scrollHeight includes\n // the iframe viewport \u2014 which we're driving \u2014 so it would report the\n // current frame height, not the content, and never shrink.\n var b = document.body;\n if (b) return Math.max(b.scrollHeight, b.offsetHeight);\n return document.documentElement.scrollHeight;\n }\n function postSize() {\n try {\n parent.postMessage({\n __myop: true, type: 'myop:size',\n height: contentHeight(),\n width: document.documentElement.scrollWidth\n }, '*');\n } catch (e) {}\n }\n // Observe the BODY (reflows with content) \u2014 not documentElement, whose box is\n // the iframe viewport and would feed back into a resize loop. A MutationObserver\n // catches content swaps (e.g. innerHTML re-render) that don't change body's box.\n if (window.ResizeObserver) {\n try { var __ro = new ResizeObserver(postSize); if (document.body) __ro.observe(document.body); } catch (e) {}\n }\n if (window.MutationObserver && document.body) {\n try { new MutationObserver(postSize).observe(document.body, { childList: true, subtree: true, attributes: true, characterData: true }); } catch (e) {}\n }\n window.addEventListener('load', postSize);\n postSize();\n })();\n <\/script>")}extractWebComponentScript(e){let i=new DOMParser().parseFromString(e,"text/html").getElementById(no);return(i==null?void 0:i.textContent)||null}executeWebComponentScript(e,t){let s=Cn.get(t);if(s)return console.log("[MyopWebComponent] Script already executed for ".concat(t,", reusing <").concat(s,">")),s;let i=document.createElement("script");i.textContent=e,i.id="myop-extracted-".concat(t),document.head.appendChild(i);let a=window.__MYOP_TAG_NAME__;return a&&Cn.set(t,a),console.log("[MyopWebComponent] Executed web component script: ".concat(t," -> <").concat(a,">")),a}async loadExtractedWebComponent(e,t,s,i,a){let p=this.extractWebComponentScript(i);if(!p)throw new Error('[MyopWebComponent] No <script id="myop-web-component"> found in HTML');let d="".concat(e.id,"-").concat(t.id),c=this.executeWebComponentScript(p,d);if(!c)throw new Error("[MyopWebComponent] Script did not set window.__MYOP_TAG_NAME__");let u="myop-comp-".concat(R()),m=document.createElement(c);m.id=u,a!=null&&a.hidden&&(m.style.opacity="0",m.style.position="absolute",m.style.height="0",m.style.width="0",m.style.pointerEvents="none",m.style.visibility="hidden"),s.querySelector('[id^="myop-comp-"]')||(s.innerHTML=""),this.appendChild(s,m,a);let g=new J(e,t,s,m,c,a);return(a==null?void 0:a.data)!==void 0&&g.initWithData(a.data),console.log("[MyopWebComponent] Loaded <".concat(c,"> into container")),g}};var wn=async o=>{try{let n=new URL(window.location.href),t=new URLSearchParams(n.search).get("myopOverride");if(t){let[s,...i]=dt(t);switch(s){case"component":{let[a,p]=i,d=await X.Main.fetchComponent(a);if(d&&d.type.skins.find(u=>u.id===p))return d.instance.skinSelector={type:Q.Dedicated,skin:{id:p}},d}break;default:{let[a,p]=dt(t),c=(await X.Main.fetchFlow(a)).components.find(u=>u.type.id===o.type.id);if(c&&c.instance.skinSelector.type===Q.Segmented&&c.instance.resolvedExperiences){let u=c.instance.resolvedExperiences.find(m=>m.id===p);if((u==null?void 0:u.type)===ze.Segment){let m=u,f=c.instance.skinSelector.segments.find(l=>l.segmentId===m.segment.id);if(f)return c.instance.skinSelector=f==null?void 0:f.skinSelector,c}}}break}}}finally{return null}};var xn="https://cdn.myop.dev/sdk/next/myop_sdk.min.js",q=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",ln);r(this,"type2InstanceCount",{});r(this,"assignId",n=>(this.type2InstanceCount[n.id]||(this.type2InstanceCount[n.id]=0),"".concat(n.id,"_").concat(++this.type2InstanceCount[n.id])));r(this,"inspected",!1);r(this,"inspect",()=>{this.inspected||(this.inspected=!0,this.components.forEach(n=>{n.inspect&&n.inspect()}))});r(this,"isTrustedSource",n=>{if(!n||n===window)return!0;let e=t=>{let s=t.element;return(s==null?void 0:s.nodeName)==="IFRAME"&&s.contentWindow===n};return this.components.some(e)||this.components2init.some(e)});r(this,"incomingMessageHandler",n=>{var e;if((e=n.data)!=null&&e.myop&&this.isTrustedSource(n.source)&&n.data.myop){if(n.data.direction!==E.up&&n.data.messageType!==y.EnvelopedMessage)return;let t=n.data;if(t.messageType===y.InitRequest){this.components2init.forEach(i=>{i.send(new se(i.id))});return}if(t.messageType===y.InitResponse){this.components2init=this.components2init.filter(a=>a.id!==t.content.id);let i=this.components.find(a=>{var p;return a.id===((p=t.content)==null?void 0:p.id)});i==null||i.setInitiated();return}if(t.messageType===y.EnvelopedMessage){let i=t,a=this.components.find(p=>p.id===i.destination);if(a){if(i.direction===E.down){i.message.messageType===D.name?a.onMessageReceived(i.message):(i.message.route=i.route,a.send(i.message));return}}else{let p=this.components.find(d=>d.id===i.message.destination);p&&p.send(i.message)}return}let s=this.components.find(i=>i.id===t.destination);if(!s){window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t);return}if(s){if(s.onMessageReceived(t))return;window.myop.IframeSDK&&window.myop.IframeSDK.messageToHost(t)}}});r(this,"send",n=>{let e=new MessageEvent("",{data:n});this.incomingMessageHandler(e)});r(this,"init",n=>{if(this.initiated){n!=null&&n.length&&this._registerLoaders(n);return}let e=[new je,new Ge,new tt];this.componentsLoaders=[...e],n&&this._registerLoaders(n),window.addEventListener("message",this.incomingMessageHandler,!1),console.log("myop hostSDK initiated",document.location.href),this.initiated=!0});r(this,"_registerLoaders",n=>{let e={};n.forEach(t=>{let s=new t(this.componentsLoaders);e[s.type]=s}),this.componentsLoaders.forEach(t=>{e[t.type]||(e[t.type]=t)}),this.componentsLoaders=Object.values(e)});r(this,"_getSkinIdBySkinSelector",async(n,e=[],t)=>{var i;async function s(a,p){for(let d of a)if(await p(d))return d}switch(n.type){case"DedicatedSkin":case Q.Dedicated:return((i=n.skin)==null?void 0:i.id)||n.skins[0].id;case Q.Segmented:{let p=await s(n.segments,async d=>{if(d.segmentId==="Default")return!0;let c=e.find(f=>f.type===ze.Segment?f.segment.id===d.segmentId:!1);if(!c)throw new Error("experience not found");let m=c.segment,g=(t||{})[m.function];return g?await g():(console.warn("segmentId:".concat(d.segmentId,", ").concat(m.function," function not provided !")),!1)});if(p)return this._getSkinIdBySkinSelector(p.skinSelector,e);debugger}break;default:debugger}return""});r(this,"runSkinSelector",async(n,e)=>{let t=await this._getSkinIdBySkinSelector(n.instance.skinSelector,n.instance.resolvedExperiences,e);return n.type.skins.find(s=>s.id===t)});r(this,"loaderHooks");r(this,"loadComponent",async(n,e,t)=>{var u,m,g,f;if(!e){debugger;throw new Error("no container was found for this component")}let s=await wn(n);s&&(n=s);let i=h(h({},(u=this.loaderHooks)!=null?u:{}),(m=t==null?void 0:t.hooks)!=null?m:{}),a=e;if(a.myop)if(a.component){n=h({},n),n.instance=h({},n.instance);let l=await this.runSkinSelector(n,i);if(!l)throw new Error("runSkinSelector failed to choose skin, check the provided config");return(g=t==null?void 0:t.hooks)!=null&&g.afterSkinSelected&&(l=await t.hooks.afterSkinSelected(h({},l))),n.instance.skinSelector={type:Q.Dedicated,skin:l},t&&(t=h({},t),delete t.hooks),await Et(a,n,this.components,t)}else throw new Error("load component got a detached ref.");e=e;let p=await this.runSkinSelector(n,i);if(!p)throw new Error("runSkinSelector failed to choose skin, check the provided config");(f=t==null?void 0:t.hooks)!=null&&f.afterSkinSelected&&(p=await t.hooks.afterSkinSelected(h({},p)));let d=this.componentsLoaders.find(l=>l.type===p.loader.type);if(!d){debugger;throw new Error('no loader "'.concat(p.loader.type,'" was found for component'))}let c=await d.load(n.type,p,e,t);c.isInitiated||this.components2init.push(c),c.bind("onDispose",()=>(this.components=this.components.filter(l=>l!==c),this.components2init=this.components2init.filter(l=>l!==c),!0)),this.components.push(c),(!t||t.connectProps!==!1)&&(c=cn(c,n.type.props,p));try{await _t(c,n,this.components)}catch(l){throw l}return t!=null&&t.skipInit||await c.initiated(),c});r(this,"navigate",async(n,e,t)=>{if(n.parent)throw new Error("Navigating on remote ref components is not implemented yet");if(t!=null&&t.staged){let s=await this.loadComponent(e,n.container,h({hidden:!0,relative:{direction:"after",child:n.element}},t));return t.init&&await t.init(s),s.show(),n.dispose(),s}else{let s=n.element.nextSibling;return n.dispose(),this.loadComponent(e,n.container,h({relative:{direction:"before",child:s}},t))}})}};r(q,"Instance",()=>window.myop.hostSDK);window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xn});if(!window.myop.hostSDK){let o=new q;o.init(),window.myop||(window.myop={__ROOT_SDK_PUBLIC_URL__:xn}),window.myop.hostSDK=o}if(window.myop&&!window.myop.delivery){let o=n=>un(n);o.stats=_e,o.off=yn,o.refresh=gn,window.myop.delivery=o}var ao=window.myop.hostSDK;Ue("hostSDK",ao);var nt=class extends I{constructor(){super(...arguments);r(this,"messageType",y.CreateRefComponentMessage);r(this,"innerExecutor",(e,t,s)=>{(async()=>{let a=t.shadowRoot.querySelectorAll("[".concat(F.id,"='").concat(e.refConfig.selector,"']"));if(a.length===1){let p=q.Instance(),d=p.components.find(g=>g.id===e.options.id);d&&d.dispose();let c=p.components.indexOf(d);c!==-1&&p.components.splice(c,1);let u=await p.loadComponent(e.nestedComponentConfig,a.item(0),e.options),m=[];Object.keys(u.refs).forEach(g=>{let f=u.refs[g];f=f.__nonProxied||f,f.componentDefinition&&m.push({refName:g,componentDefinitionId:f.componentDefinition.id})}),s(new ie(e.handlerUniqueId,m))}else{console.error("CreateRefComponentMessageHandler - DOM element not found"),this.messageToHost(new ie(e.handlerUniqueId,[],!0));debugger}})().then()})}};var vn=(o,n,e)=>{let t=o.scriptInputs?o.scriptInputs:{};t.makeSerializable=K,t.send=n,t.rootRef=e,t.__scriptInputs=t;let i=new Function("return (".concat(o.script,")(...arguments)"))(t);n(i)};var ot=class extends I{constructor(){super(...arguments);r(this,"messageType",y.ExecuteScriptMessage);r(this,"innerExecutor",(e,t,s)=>{vn(e,a=>{s(new fe(e.handlerUniqueId,a))},t)})}};var Sn=o=>{if(!o)return null;if(o.tagName==="FORM"){let n=new FormData(o),e={formData:{},unmappedData:[]},t=o.querySelectorAll("input, select, textarea"),s=-1;return t.forEach(i=>{if(typeof i.value=="string"){let a=i.getAttribute(F.id),p=i.getAttribute("name"),d={id:i.id,name:p,value:Sn(i),required:i.required,validity:K(i.validity,!0),myopId:a};p?e.formData[p]?e.formData[p].value?e.unmappedData.push(d):(e.unmappedData.push(e.formData[p]),e.formData[p]=d):e.formData[p]=d:e.unmappedData.push(d)}}),e}return o.type==="checkbox"||o.type==="radio"?o.checked?o.value:null:o.tagName==="INPUT"||o.tagName==="TEXTAREA"||o.tagName==="SELECT"?o.value:o.isContentEditable?o.innerText||o.textContent:null},st=class extends I{constructor(){super(...arguments);r(this,"messageType",y.GetElementValueMessage);r(this,"innerExecutor",(e,t,s)=>{B(e.ref,t.shadowRoot).forEach(a=>{s(new ge(Sn(a)),e)})})}};var it=class extends I{constructor(){super(...arguments);r(this,"messageType",y.SetInnerHtml);r(this,"innerExecutor",(e,t)=>{B(e.ref,t.shadowRoot).forEach(i=>{i.innerHTML=e.content})})}};var Te=class extends Pe{constructor(){super(...arguments);r(this,"alwaysPassEnvelopesToHost",!0);r(this,"connectedCallback",(e,t)=>{e.addEventListener($e.webcomponent_message_key,s=>{let i=s.data?s.data:s.detail;if(!i||!i.myop){debugger;throw new Error("recvied webcomponent_message with wrong type")}else{let a=i;if(this.handleIncomeMessages(s),a.messageType===y.InitMessage){let p=a.content.id;this.components[p].context=new Ke(e,t)}}}),setTimeout(()=>{this.messageToHost(new he)},1)});r(this,"messageToHost",(e,t)=>{e.direction=E.up,!e.replayToHandler&&(t!=null&&t.handlerUniqueId)&&(e.replayToHandler=t.handlerUniqueId),window.myop.hostSDK.send(e)});r(this,"supportedHandlers",[new Fe(this.messageToHost,this.components),new it(this.messageToHost,this.components),new Ae(this.messageToHost,this.components),new We(this.messageToHost,this.components),new qe(this.messageToHost,this.components),new Ve(this.messageToHost,this.components),new ot(this.messageToHost,this.components),new st(this.messageToHost,this.components),new nt(this.messageToHost,this.components)]);r(this,"init",()=>{})}};Ue("WebComponentSDK",Te);export{Te as WebComponentSDK};