@widgetic/embed-sdk 2.0.14 → 2.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -9
- package/dist/browser/chunks/ABTestManager.js +1 -1
- package/dist/browser/chunks/advanced.js +1 -1
- package/dist/browser/chunks/api.js +1 -1
- package/dist/browser/chunks/core.js +1 -1
- package/dist/browser/chunks/display.js +1 -1
- package/dist/browser/chunks/media.js +1 -1
- package/dist/browser/chunks/messaging.js +1 -1
- package/dist/browser/chunks/renderers.js +1 -1
- package/dist/browser/chunks/scanner.js +1 -1
- package/dist/browser/chunks/security.js +1 -1
- package/dist/browser/embed-bootstrap.js +1 -1
- package/dist/browser/embed-sdk.js +1 -1
- package/dist/esm/chunks/ABTestManager.js +1 -1
- package/dist/esm/chunks/advanced.js +1 -1
- package/dist/esm/chunks/api.js +1 -1
- package/dist/esm/chunks/core.js +1 -1
- package/dist/esm/chunks/display.js +1 -1
- package/dist/esm/chunks/media.js +1 -1
- package/dist/esm/chunks/messaging.js +1 -1
- package/dist/esm/chunks/renderers.js +1 -1
- package/dist/esm/chunks/scanner.js +1 -1
- package/dist/esm/chunks/security.js +1 -1
- package/dist/esm/embed-bootstrap.js +1 -1
- package/dist/esm/embed-sdk.js +1 -1
- package/dist/esm/types/abTesting/ABTestElement.d.ts +10 -0
- package/dist/esm/types/abTesting/ABTestManager.d.ts +54 -12
- package/dist/esm/types/abTesting/abVisitor.d.ts +31 -0
- package/dist/esm/types/core/advanced-security-manager.d.ts +3 -0
- package/dist/esm/types/core/widget-manager.d.ts +8 -43
- package/dist/esm/types/utils/declarative-embed-parser.d.ts +14 -0
- package/dist/esm/types/utils/hydrate-published-host.d.ts +7 -4
- package/dist/esm/types/utils/image-delivery.d.ts +54 -0
- package/dist/esm/types/utils/lookup-cache.d.ts +34 -0
- package/dist/esm/types/utils/preload-content-images.d.ts +21 -0
- package/dist/esm/types/utils/public-embed-lookup.d.ts +3 -0
- package/dist/esm/types/utils/published-host-bridge.d.ts +16 -0
- package/dist/umd/embed-bootstrap.js +1 -1
- package/dist/umd/embed-sdk.js +1 -1
- package/package.json +1 -1
- package/dist/esm/types/core/realtime-manager.d.ts +0 -286
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e}from"./vendor.js";import{r as t,a as i,b as n,E as o,d as s,g as a,e as d,c as r}from"./api.js";import{l as c,a as l,b as u,d as g}from"./core.js";import{b as h,c as m,m as p}from"./scanner.js";import{a as b,g as f}from"./media.js";import{getMessenger as w}from"./messaging.js";import{R as v}from"./display.js";const y="undefined"!=typeof HTMLElement?HTMLElement:class{};class I extends y{static get observedAttributes(){return["composition-id","width","height","resize","autoscale","adaptive","theme"]}constructor(){super(),this.svelteComponent=null,this.compositionData=null,this.widgetData=null,this.loadedModule=null,this.isInitialized=!1,this.isWidgetConnected=!1,this.resizeObserver=null,this.eventListeners=new Map,this.widgetState={ready:!1,error:null,loading:!1,data:{}},this.instanceId=this.generateInstanceId(),this.cssNamespace=`widgetic-${this.instanceId}`,this.initializeCSSIsolation(),c.debug("WidgeticWidget created",{instanceId:this.instanceId})}connectedCallback(){return e(this,void 0,void 0,(function*(){var e;if(!this.isWidgetConnected){this.isWidgetConnected=!0,c.debug("WidgeticWidget connected",{instanceId:this.instanceId});try{this.setLoadingState(!0);const a=h(this),d=null!==(e=null==a?void 0:a.id)&&void 0!==e?e:this.getAttribute("composition-id");if(!d)throw new Error("composition-id attribute is required");m(this);const r="widget"===(null==a?void 0:a.kind)?yield t(d):yield i(d);if("refused"===r.status)throw n(d,r.refusal),new Error(o);const c="found"===r.status?r.payload:null;if(null==c?void 0:c.embedUrl){const e=p(this,c);return this.innerHTML="",this.appendChild(s(c.embedUrl,this.getAttribute("width")||"400",this.getAttribute("height")||"300",d,e)),void this.setWidgetReady()}yield this.loadWidgetData(d),this.widgetData&&(yield this.loadWidgetModule()),yield this.initializeWidget(),this.setupResponsiveBehavior(),this.setupEventHandling(),this.setWidgetReady()}catch(e){c.error("WidgeticWidget initialization failed",{instanceId:this.instanceId,error:e}),this.setErrorState(e)}}}))}disconnectedCallback(){this.isWidgetConnected&&(c.debug("WidgeticWidget disconnected",{instanceId:this.instanceId}),this.cleanup(),this.isWidgetConnected=!1)}attributeChangedCallback(e,t,i){if(this.isInitialized&&t!==i){switch(c.debug("WidgeticWidget attribute changed",{instanceId:this.instanceId,attribute:e,oldValue:t,newValue:i}),e){case"width":case"height":this.updateDimensions();break;case"resize":this.updateResizeMode();break;case"autoscale":this.updateAutoscale();break;case"adaptive":this.updateAdaptive();break;case"theme":this.updateTheme()}this.notifyWidgetPropsChanged()}}initializeCSSIsolation(){this.setAttribute("data-widgetic-instance",this.instanceId),this.addBaseStyles(),this.initializeCSSCustomProperties()}addBaseStyles(){const e=`widgetic-base-styles-${this.instanceId}`;if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent=`\n /* Widget base styles with namespace isolation */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"] {\n /* CSS Reset for widget container */\n all: initial;\n \n /* Widget container properties */\n display: block;\n box-sizing: border-box;\n position: relative;\n \n /* CSS custom properties with namespacing */\n --widgetic-instance: ${this.instanceId};\n --widgetic-primary: var(--widgetic-${this.instanceId}-primary, #007bff);\n --widgetic-secondary: var(--widgetic-${this.instanceId}-secondary, #6c757d);\n --widgetic-background: var(--widgetic-${this.instanceId}-background, #ffffff);\n --widgetic-text: var(--widgetic-${this.instanceId}-text, #333333);\n --widgetic-border: var(--widgetic-${this.instanceId}-border, #dee2e6);\n \n /* Widget content isolation */\n contain: layout style paint;\n isolation: isolate;\n }\n\n /* Prevent external CSS interference */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"] * {\n box-sizing: border-box;\n }\n\n /* Loading state styles */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"][data-loading="true"] {\n min-height: 120px;\n background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);\n background-size: 400% 100%;\n animation: widgetic-loading-${this.instanceId} 1.5s ease-in-out infinite;\n }\n\n @keyframes widgetic-loading-${this.instanceId} {\n 0% { background-position: 100% 50%; }\n 100% { background-position: 0% 50%; }\n }\n\n /* Error state styles */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"][data-error="true"] {\n border: 2px dashed #dc3545;\n background-color: #f8d7da;\n color: #721c24;\n padding: 16px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n }\n `,document.head.appendChild(t)}initializeCSSCustomProperties(){const e=this.getAttribute("theme");if(e)try{const t=JSON.parse(e);Object.entries(t).forEach((([e,t])=>{this.style.setProperty(`--widgetic-${this.instanceId}-${e}`,String(t))}))}catch(t){c.warn("Invalid theme attribute",{instanceId:this.instanceId,theme:e})}}loadWidgetData(t){return e(this,void 0,void 0,(function*(){const e=a();this.compositionData=yield e.getComposition(t),this.widgetData=yield e.getWidget(this.compositionData.widgetId),c.debug("Widget data loaded",{instanceId:this.instanceId,compositionId:t,widgetId:this.compositionData.widgetId})}))}loadWidgetModule(){return e(this,void 0,void 0,(function*(){if(!this.widgetData)return;const e=d();this.loadedModule=yield e.loadModule(this.widgetData),c.debug("Widget module loaded",{instanceId:this.instanceId,moduleUrl:this.widgetData.moduleUrl,loadTime:this.loadedModule.loadTime})}))}initializeWidget(){return e(this,void 0,void 0,(function*(){if(!this.loadedModule||!this.compositionData)throw new Error("Widget module or composition data not loaded");try{const{component:e}=this.loadedModule.module,t=document.createElement("div");if(t.className=`widgetic-content-${this.instanceId}`,this.applyWidgetProperties(t),e.$$typeof)yield this.initializeReactComponent(t,e);else if(e._isVue||e.__isVue)yield this.initializeVueComponent(t,e);else{if("function"!=typeof e)throw new Error("Unsupported component type");yield this.initializeSvelteOrVanillaComponent(t,e)}this.innerHTML="",this.appendChild(t),this.isInitialized=!0,c.debug("Widget initialized successfully",{instanceId:this.instanceId})}catch(e){throw c.error("Widget initialization failed",{instanceId:this.instanceId,error:e}),e}}))}initializeReactComponent(t,i){return e(this,void 0,void 0,(function*(){if("undefined"==typeof window||!window.React||!window.ReactDOM)throw new Error("React not available globally");{const e=window.React,n=window.ReactDOM,o=this.getWidgetProps(),s=e.createElement(i,o);n.render(s,t)}}))}initializeVueComponent(t,i){return e(this,void 0,void 0,(function*(){if("undefined"==typeof window||!window.Vue)throw new Error("Vue not available globally");{const e=window.Vue,n=this.getWidgetProps();new e({el:t,render:e=>e(i,{props:n})})}}))}initializeSvelteOrVanillaComponent(t,i){return e(this,void 0,void 0,(function*(){var e;const n=this.getWidgetProps();if(i.$$prop_def||(null===(e=i.prototype)||void 0===e?void 0:e.$$prop_def))this.svelteComponent=new i({target:t,props:n});else if(i.prototype&&i.prototype.constructor===i){const e=new i(t,n);"function"==typeof e.render&&(yield e.render())}else if("function"==typeof i)yield i(t,n);else{if(!i||"function"!=typeof i.init)throw new Error("Unknown component type");yield i.init(t,n)}}))}getWidgetProps(){var e,t;return{config:(null===(e=this.compositionData)||void 0===e?void 0:e.config)||{},metadata:(null===(t=this.compositionData)||void 0===t?void 0:t.metadata)||{},instance:this.instanceId,element:this,dimensions:{width:this.getAttribute("width")||"100%",height:this.getAttribute("height")||"400"},resize:this.getAttribute("resize")||"responsive",autoscale:"true"===this.getAttribute("autoscale"),adaptive:parseInt(this.getAttribute("adaptive")||"768"),state:this.widgetState,onStateChange:this.handleStateChange.bind(this),onResize:this.handleResize.bind(this),onError:this.handleError.bind(this)}}applyWidgetProperties(e){var t;const i=this.getAttribute("width")||"100%",n=this.getAttribute("height")||"400",o=this.getAttribute("resize")||"responsive";switch(e.style.width="number"==typeof i?`${i}px`:i,e.style.height="number"==typeof n?`${n}px`:n,o){case"fill-width":e.style.width="100%";break;case"responsive":e.style.maxWidth="100%",e.style.height="auto"}e.classList.add(`widgetic-widget-${(null===(t=this.widgetData)||void 0===t?void 0:t.type)||"unknown"}`)}setupResponsiveBehavior(){const e=parseInt(this.getAttribute("adaptive")||"768"),t="true"===this.getAttribute("autoscale"),i=this.getAttribute("resize")||"responsive";t&&"ResizeObserver"in window&&(this.resizeObserver=new ResizeObserver((e=>{for(const t of e)this.handleAutoscale(t)})),this.resizeObserver.observe(this)),"responsive"!==i&&"fill-width"!==i||this.setupAdaptiveBehavior(e)}setupAdaptiveBehavior(e){const t=window.matchMedia(`(max-width: ${e}px)`),i=t=>{this.setAttribute("data-mobile",t.matches?"true":"false"),this.dispatchEvent(new CustomEvent("widgetic:adaptive",{detail:{isMobile:t.matches,breakpoint:e}}))};i(t),t.addEventListener("change",i),this.eventListeners.set("adaptive",(()=>{t.removeEventListener("change",i)}))}handleAutoscale(e){const{width:t,height:i}=e.contentRect;this.dispatchEvent(new CustomEvent("widgetic:resize",{detail:{width:t,height:i}})),this.widgetState.data.dimensions={width:t,height:i}}setupEventHandling(){const e=e=>{this.dispatchEvent(new CustomEvent("widgetic:interaction",{detail:{type:"click",originalEvent:e},bubbles:!0}))};this.addEventListener("click",e),this.eventListeners.set("click",(()=>{this.removeEventListener("click",e)}));const t=e=>{e.target instanceof HTMLFormElement&&this.handleFormSubmission(e)};this.addEventListener("submit",t),this.eventListeners.set("submit",(()=>{this.removeEventListener("submit",t)}))}handleFormSubmission(e){e.preventDefault();const t=e.target,i=new FormData(t),n={};i.forEach(((e,t)=>{n[t]=e})),this.widgetState.data.formData=n,this.dispatchEvent(new CustomEvent("widgetic:form-submit",{detail:{data:n,form:t},bubbles:!0})),c.debug("Form submitted",{instanceId:this.instanceId,data:n})}handleStateChange(e){this.widgetState.data=Object.assign(Object.assign({},this.widgetState.data),e),this.dispatchEvent(new CustomEvent("widgetic:state-change",{detail:{state:this.widgetState.data},bubbles:!0}))}handleResize(e){this.dispatchEvent(new CustomEvent("widgetic:resize",{detail:e,bubbles:!0}))}handleError(e){this.setErrorState(e)}updateDimensions(){const e=this.querySelector(`.widgetic-content-${this.instanceId}`);e&&this.applyWidgetProperties(e)}updateResizeMode(){this.updateDimensions(),this.setupResponsiveBehavior()}updateAutoscale(){this.setupResponsiveBehavior()}updateAdaptive(){const e=parseInt(this.getAttribute("adaptive")||"768");this.setupAdaptiveBehavior(e)}updateTheme(){this.initializeCSSCustomProperties()}notifyWidgetPropsChanged(){this.svelteComponent&&"function"==typeof this.svelteComponent.$set&&this.svelteComponent.$set(this.getWidgetProps()),this.dispatchEvent(new CustomEvent("widgetic:props-changed",{detail:{props:this.getWidgetProps()}}))}setLoadingState(e){this.widgetState.loading=e,this.setAttribute("data-loading",e?"true":"false"),e&&(this.innerHTML=`\n <div class="widgetic-loading-${this.instanceId}">\n <div>Loading widget...</div>\n </div>\n `)}setWidgetReady(){this.widgetState.ready=!0,this.widgetState.loading=!1,this.widgetState.error=null,this.setAttribute("data-ready","true"),this.removeAttribute("data-loading"),this.removeAttribute("data-error"),this.dispatchEvent(new CustomEvent("widgetic:ready",{detail:{instanceId:this.instanceId},bubbles:!0})),c.info("Widget ready",{instanceId:this.instanceId})}setErrorState(e){this.widgetState.error=e,this.widgetState.loading=!1,this.widgetState.ready=!1,this.setAttribute("data-error","true"),this.removeAttribute("data-loading"),this.removeAttribute("data-ready"),this.innerHTML=`\n <div class="widgetic-error-${this.instanceId}">\n <strong>Widget Error</strong><br>\n <small>${e.message}</small>\n </div>\n `,this.dispatchEvent(new CustomEvent("widgetic:error",{detail:{error:e.message,instanceId:this.instanceId},bubbles:!0})),c.error("Widget error",{instanceId:this.instanceId,error:e})}getState(){return Object.assign({},this.widgetState.data)}setState(e){this.handleStateChange(e)}refresh(){return e(this,void 0,void 0,(function*(){this.cleanup(),this.isInitialized=!1,this.isWidgetConnected=!1,yield this.connectedCallback()}))}cleanup(){this.svelteComponent&&"function"==typeof this.svelteComponent.$destroy&&(this.svelteComponent.$destroy(),this.svelteComponent=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.eventListeners.forEach((e=>{if("function"==typeof e)try{e()}catch(e){c.warn("Failed to cleanup event listener",{instanceId:this.instanceId,error:e})}})),this.eventListeners.clear();const e=document.getElementById(`widgetic-base-styles-${this.instanceId}`);e&&e.remove(),c.debug("Widget cleanup complete",{instanceId:this.instanceId})}generateInstanceId(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}}function E(){"undefined"!=typeof window&&"undefined"!=typeof customElements&&(customElements.get("widgetic-widget")||(customElements.define("widgetic-widget",I),c.info("WidgeticWidget custom element registered")))}class x{constructor(){this.observers=new Map,this.mutationObservers=new Map,this.timeouts=new Map,this.animationIds=new Map,this.storageKey="widgetic_autoscale_heights"}static getInstance(){return x.instance||(x.instance=new x),x.instance}enableAutoScale(e,t,i={enabled:!0}){if(!i.enabled)return;const n=Object.assign({minHeight:i.minHeight||50,maxHeight:i.maxHeight||2e3,debounceDelay:i.debounceDelay||150,threshold:i.threshold||5,animate:!1!==i.animate,animationDuration:i.animationDuration||300},i),o=e.offsetHeight,s=this.getStoredHeight(t);s&&s!==o&&this.setElementHeight(e,s,n.animate,n.animationDuration),this.setupContentMonitoring(e,t,n,o)}disableAutoScale(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e));const i=this.mutationObservers.get(e);i&&(i.disconnect(),this.mutationObservers.delete(e));const n=this.timeouts.get(e);n&&(clearTimeout(n),this.timeouts.delete(e));const o=this.animationIds.get(e);o&&(cancelAnimationFrame(o),this.animationIds.delete(e));const s=document.querySelector(`iframe[data-widgetic-id="${e}"], iframe[data-composition-id="${e}"]`);s&&s._autoscaleMessageCleanup&&(s._autoscaleMessageCleanup(),delete s._autoscaleMessageCleanup)}getStoredHeight(e){try{const t=localStorage.getItem(this.storageKey);if(!t)return null;const i=JSON.parse(t),n=i[e];if(!n)return null;const o=864e5;return Date.now()-n.lastUpdated>o?(delete i[e],localStorage.setItem(this.storageKey,JSON.stringify(i)),null):n.height}catch(e){return null}}storeHeight(e,t,i){try{const n=localStorage.getItem(this.storageKey),o=n?JSON.parse(n):{};o[e]={compositionId:e,height:t,originalHeight:i,lastUpdated:Date.now()},localStorage.setItem(this.storageKey,JSON.stringify(o))}catch(e){}}setupContentMonitoring(e,t,i,n){const o=this.findContentElement(e);if(!o)return void e.tagName.toLowerCase();const s=this.createDebouncedHeightUpdate(e,t,i,n);if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver((e=>{for(const t of e){const e=t.target.scrollHeight;s(e)}}));e.observe(o),this.observers.set(t,e)}const a=new MutationObserver((()=>{const e=o.scrollHeight;s(e)}));a.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","height"]}),this.mutationObservers.set(t,a);const d=o.scrollHeight;s(d)}findContentElement(e){var t;if("iframe"===e.tagName.toLowerCase())try{const i=e,n=i.contentDocument||(null===(t=i.contentWindow)||void 0===t?void 0:t.document);if(null==n?void 0:n.body)return n.body}catch(t){return this.setupIframePostMessageListener(e),null}const i=e.tagName.toLowerCase();if("widgetic"===i||"widgetic-widget"===i||e.classList.contains("widgetic-widget")){return e.querySelector(".widget-content, .widgetic-content, [data-content]")||e}return e}setupIframePostMessageListener(e){const t=e.getAttribute("data-widgetic-id")||e.getAttribute("data-composition-id")||"unknown",i=i=>{var n,o;if(i.source===e.contentWindow&&("widgetic:autoscale"===(null===(n=i.data)||void 0===n?void 0:n.type)||"autoscale"===(null===(o=i.data)||void 0===o?void 0:o.type))){const{height:n,contentHeight:o}=i.data.payload||i.data;if("number"==typeof n&&n>0){const i=this.getConfigForWidget(t),s=Math.max(i.minHeight||50,Math.min(i.maxHeight||2e3,n));this.setElementHeight(e,s,i.animate,i.animationDuration),this.storeHeight(t,s,e.offsetHeight),e.dispatchEvent(new CustomEvent("widgetic:autoscale",{detail:{compositionId:t,oldHeight:e.offsetHeight,newHeight:s,contentHeight:o||n}}))}}};window.addEventListener("message",i),e._autoscaleMessageCleanup=()=>{window.removeEventListener("message",i)}}getConfigForWidget(e){return{enabled:!0,minHeight:50,maxHeight:2e3,animate:!0,animationDuration:300,debounceDelay:150,threshold:5}}createDebouncedHeightUpdate(e,t,i,n){let o=e.offsetHeight;return s=>{const a=this.timeouts.get(t);a&&clearTimeout(a);const d=setTimeout((()=>{const a=Math.max(i.minHeight,Math.min(i.maxHeight,s));Math.abs(a-o)>=i.threshold&&(this.setElementHeight(e,a,i.animate,i.animationDuration),this.storeHeight(t,a,n),o=a,e.dispatchEvent(new CustomEvent("widgetic:autoscale",{detail:{compositionId:t,oldHeight:o,newHeight:a,contentHeight:s}}))),this.timeouts.delete(t)}),i.debounceDelay);this.timeouts.set(t,d)}}setElementHeight(e,t,i=!0,n=300){if(!i)return void(e.style.height=`${t}px`);const o=e.offsetHeight,s=t-o;if(Math.abs(s)<1)return;const a=this.animationIds.get(e.id||e.tagName);a&&cancelAnimationFrame(a);const d=performance.now(),r=o,c=i=>{const o=i-d,a=Math.min(o/n,1),l=1-Math.pow(1-a,3),u=r+s*l;if(e.style.height=`${u}px`,a<1){const t=requestAnimationFrame(c);this.animationIds.set(e.id||e.tagName,t)}else e.style.height=`${t}px`,this.animationIds.delete(e.id||e.tagName)},l=requestAnimationFrame(c);this.animationIds.set(e.id||e.tagName,l)}clearStoredHeights(){try{localStorage.removeItem(this.storageKey)}catch(e){}}getStoredHeights(){try{const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return{}}}destroy(){this.observers.forEach((e=>e.disconnect())),this.observers.clear(),this.mutationObservers.forEach((e=>e.disconnect())),this.mutationObservers.clear(),this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts.clear(),this.animationIds.forEach((e=>cancelAnimationFrame(e))),this.animationIds.clear()}}class k{constructor(){this.autoScaleManager=x.getInstance(),E()}render(t){return e(this,void 0,void 0,(function*(){const{compositionId:e,width:i="100%",height:n="400",resize:o="responsive",autoscale:s=!0,adaptive:a=768,media:d,content:r}=t,c=document.createElement("widgetic-widget");if(c.setAttribute("composition-id",e),c.setAttribute("width",String(i)),c.setAttribute("height",String(n)),c.setAttribute("resize",o),"boolean"==typeof s?c.setAttribute("autoscale",s?"true":"false"):s&&"object"==typeof s?(c.setAttribute("autoscale","true"),void 0!==s.minHeight&&c.setAttribute("autoscale-min-height",String(s.minHeight)),void 0!==s.maxHeight&&c.setAttribute("autoscale-max-height",String(s.maxHeight)),void 0!==s.debounceDelay&&c.setAttribute("autoscale-debounce",String(s.debounceDelay)),void 0!==s.threshold&&c.setAttribute("autoscale-threshold",String(s.threshold)),void 0!==s.animate&&c.setAttribute("autoscale-animate",String(s.animate)),void 0!==s.animationDuration&&c.setAttribute("autoscale-animation-duration",String(s.animationDuration))):c.setAttribute("autoscale","false"),c.setAttribute("adaptive",String(a)),d&&Object.keys(d).length>0){b().registerWidget(e,d),this.setupCustomElementMediaListener(c,e)}if(r&&Object.keys(r).length>0){f().registerWidget(e,r),this.setupCustomElementContentListener(c,e)}return{id:`custom-${e}-${Date.now()}`,element:c,compositionData:{id:e,name:`Composition ${e}`,widgetId:`widget-${e}`,config:{}},widgetData:{id:`widget-${e}`,name:`Widget ${e}`,type:"custom-element",version:"1.0",moduleUrl:"",dependencies:[]},renderMode:"custom-element",cleanup:()=>{c._mediaCommandCleanup&&c._mediaCommandCleanup(),c._mediaObserverCleanup&&c._mediaObserverCleanup(),c._contentPositionCleanup&&c._contentPositionCleanup()}}}))}initializeWidget(t,i,n){return e(this,void 0,void 0,(function*(){}))}renderFrameworkComponent(t,i,n){return e(this,void 0,void 0,(function*(){if(i.$$typeof&&"undefined"!=typeof window&&window.React&&window.ReactDOM){const e=window.React,o=window.ReactDOM,s=e.createElement(i,{config:n.config,metadata:n.metadata});o.render(s,t)}else{if(!i._isVue&&!i.__isVue||"undefined"==typeof window||!window.Vue)throw new Error("Framework component detected but framework not available");new(0,window.Vue)({el:t,render:e=>e(i,{props:{config:n.config,metadata:n.metadata}})})}}))}applyElementStyling(e,t,i){const{width:n,height:o,resize:s,autoscale:a,adaptive:d}=i;switch(e.style.width="number"==typeof n?`${n}px`:n,e.style.height="number"==typeof o?`${o}px`:o,e.style.display="block",e.style.overflow="hidden",s){case"fill-width":e.style.width="100%";break;case"responsive":this.makeResponsive(e,d||768)}if(a){("boolean"==typeof a?a:a&&"object"==typeof a&&a.enabled)&&this.enableAutoscale(e,t,a)}e.classList.add("widgetic-widget","widgetic-custom-element")}makeResponsive(e,t){const i=window.matchMedia(`(max-width: ${t}px)`),n=()=>{i.matches?(e.style.width="100%",e.style.height="auto",e.style.minHeight="200px",e.classList.add("widgetic-mobile")):e.classList.remove("widgetic-mobile")};n(),i.addEventListener?i.addEventListener("change",n):i.addListener(n),e._responsiveCleanup=()=>{i.removeEventListener?i.removeEventListener("change",n):i.removeListener(n)}}enableAutoscale(e,t,i){const n="boolean"==typeof i?{enabled:i}:i;n.enabled&&(this.autoScaleManager.enableAutoScale(e,t,n),e._autoscaleCleanup=()=>{this.autoScaleManager.disableAutoScale(t)})}showLoadingState(e){e.innerHTML='\n <div class="widgetic-loading" style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n ">\n <div style="text-align: center; color: #6c757d;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #dee2e6;\n border-top: 2px solid #007bff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <small>Loading widget...</small>\n </div>\n </div>\n <style>\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n '}showErrorState(e,t){const i=t instanceof Error?t.message:"Unknown error";e.innerHTML=`\n <div class="widgetic-error" style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #fff5f5;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n color: #c53030;\n ">\n <div style="text-align: center; padding: 20px;">\n <div style="font-size: 24px; margin-bottom: 8px;">⚠️</div>\n <div style="font-weight: 500; margin-bottom: 4px;">Widget Error</div>\n <small style="color: #718096;">${i}</small>\n </div>\n </div>\n `,e.setAttribute("data-error","true"),e.dispatchEvent(new CustomEvent("widgetic:error",{detail:{error:i}}))}setupCustomElementMediaListener(e,t){const i=b(),n=t=>{const{command:i}=t.detail;if("pause"===i){const t=e.querySelectorAll("audio"),i=e.querySelectorAll("video");t.forEach((e=>{e.paused||e.pause()})),i.forEach((e=>{e.paused||e.pause()}))}else if("play"===i){const t=e.querySelectorAll("audio"),i=e.querySelectorAll("video"),n=Array.from(t).concat(Array.from(i)).find((e=>e.currentTime>0&&!e.ended));n&&n.play().catch((()=>{}))}};e.addEventListener("widgetic:media:command",n),e._mediaCommandCleanup=()=>{e.removeEventListener("widgetic:media:command",n)};const o=(n,o)=>s=>{const a=(e.__widgetConfig||{}).media||{},d="audio"===n.tagName.toLowerCase()?"audio":"video";i.handleMediaEvent({type:o,compositionId:t,config:a,data:{position:n.currentTime,duration:n.duration,volume:n.volume,mediaType:d,title:n.title||n.getAttribute("data-title")||void 0}})},s=()=>{const t=e.querySelectorAll("audio"),i=e.querySelectorAll("video");Array.from(t).concat(Array.from(i)).forEach((e=>{e.addEventListener("play",o(e,"play")),e.addEventListener("pause",o(e,"pause")),e.addEventListener("ended",o(e,"ended")),e.addEventListener("seeked",o(e,"seeking")),e.addEventListener("volumechange",o(e,"volumechange"))}))};s();const a=new MutationObserver((()=>{s()}));a.observe(e,{childList:!0,subtree:!0}),e._mediaObserverCleanup=()=>{a.disconnect()}}setupCustomElementContentListener(e,t){const i=f(),n=n=>{if(n.detail&&n.detail.type){const o=n.detail.type,s=n.detail.data||n.detail;let a={};try{const t=e.getAttribute("data-content-config");t&&(a=JSON.parse(t))}catch(e){a={contentType:"custom",persistState:!0}}i.handleContentPositionEvent({type:o,compositionId:t,config:a,data:s})}};e.addEventListener("widgetic:content:position",n),e.addEventListener("widgetic:content:navigate",n),e.addEventListener("widgetic:content:complete",n),e.addEventListener("widgetic:content:reset",n),e.addEventListener("widgetic:content:metadata",n),e._contentPositionCleanup=()=>{e.removeEventListener("widgetic:content:position",n),e.removeEventListener("widgetic:content:navigate",n),e.removeEventListener("widgetic:content:complete",n),e.removeEventListener("widgetic:content:reset",n),e.removeEventListener("widgetic:content:metadata",n)}}}var C=Object.freeze({__proto__:null,CustomElementRenderer:k});class S{constructor(){this.observers=new Map,this.callbacks=new Map,this.currentStates=new Map,this.debounceTimers=new Map,"undefined"==typeof ResizeObserver&&c.warn("ResizeObserver not available, responsive breakpoints will not work")}registerWidget(e,t,i,n){if("undefined"==typeof ResizeObserver)return void c.warn("ResizeObserver not available, skipping responsive registration",{widgetId:e});this.unregisterWidget(e);const o=t.getBoundingClientRect().width,s=i.initialMode||(o<i.breakpoint?"mobile":"desktop"),a={mode:s,breakpoint:i.breakpoint,width:o,timestamp:Date.now()};this.currentStates.set(e,a),this.callbacks.set(e,n);const d=new ResizeObserver((t=>{this.handleResize(e,t,i)}));d.observe(t),this.observers.set(e,d),n(a),c.debug("Widget registered for responsive monitoring",{widgetId:e,breakpoint:i.breakpoint,initialMode:s,containerWidth:o})}unregisterWidget(e){const t=this.debounceTimers.get(e);t&&(clearTimeout(t),this.debounceTimers.delete(e));const i=this.observers.get(e);i&&(i.disconnect(),this.observers.delete(e)),this.callbacks.delete(e),this.currentStates.delete(e),c.debug("Widget unregistered from responsive monitoring",{widgetId:e})}getCurrentState(e){return this.currentStates.get(e)||null}checkResponsiveState(e,t){const i=this.currentStates.get(e),n=this.callbacks.get(e);if(!i||!n)return void c.warn("Widget not registered for responsive monitoring",{widgetId:e});const o=t<i.breakpoint?"mobile":"desktop";if(o!==i.mode){const s={mode:o,breakpoint:i.breakpoint,width:t,timestamp:Date.now()};this.currentStates.set(e,s),n(s),c.info("Responsive state changed manually",{widgetId:e,from:i.mode,to:o,width:t,breakpoint:i.breakpoint})}}handleResize(e,t,i){const n=this.debounceTimers.get(e);n&&clearTimeout(n);const o=setTimeout((()=>{this.processResize(e,t,i),this.debounceTimers.delete(e)}),i.debounceDelay||150);this.debounceTimers.set(e,o)}processResize(e,t,i){const n=this.currentStates.get(e),o=this.callbacks.get(e);if(!n||!o)return;const s=t[t.length-1];if(!s)return;const a=s.contentRect.width,d=a<i.breakpoint?"mobile":"desktop";if(d!==n.mode){const t={mode:d,breakpoint:i.breakpoint,width:a,timestamp:Date.now()};this.currentStates.set(e,t),o(t),c.info("Responsive breakpoint crossed",{widgetId:e,from:n.mode,to:d,width:a,breakpoint:i.breakpoint})}else if(Math.abs(a-n.width)>10){const t=Object.assign(Object.assign({},n),{width:a,timestamp:Date.now()});this.currentStates.set(e,t),c.debug("Container width updated",{widgetId:e,width:a,mode:n.mode,breakpoint:i.breakpoint})}}getRegisteredWidgets(){return Array.from(this.observers.keys())}cleanup(){const e=this.getRegisteredWidgets();for(const t of e)this.unregisterWidget(t);c.debug("ResponsiveManager cleanup complete")}}let W=null;function M(){return W||(W=new S),W}class L{constructor(){this.messageQueue=new Map,this.iframeRegistry=new Map,this.loadingTimeouts=new Map,this.autoScaleManager=x.getInstance()}renderWidget(t){return e(this,void 0,void 0,(function*(){const{compositionId:e,width:i,height:n,resize:o="fixed",autoscale:s=!1,adaptive:a,responsive:d,container:l,allowFullscreen:u=!0,sandbox:g=this.getDefaultSandboxPermissions(),allowedFeatures:h=this.getDefaultAllowedFeatures(),loading:m="lazy",enableResize:p=!0,compositionData:w,widgetData:y,security:I={},fallback:E={enabled:!0,timeout:1e4,retryCount:3},media:x}=t;if(!i||!n||!l)throw new Error("Missing required parameters: width, height, and container are required");const k=w||{id:e,name:`Composition ${e}`,widgetId:`widget-${e}`,config:{}},C=y||{id:k.widgetId,name:`Widget ${e}`,type:"iframe",version:"1.0",moduleUrl:"",dependencies:[]};try{const w=this.createSecureIframe(e,t);w.src=yield this.buildSecureIframeUrl(e,t),w.title=`Widgetic Widget: ${k.name||e}`,w.loading=m,this.applySandboxSecurity(w,g,h),w.width=i.toString(),w.height=n.toString(),w.frameBorder="0",w.scrolling="no",u&&(w.allowFullscreen=!0,w.setAttribute("allowfullscreen","")),w.title=`Widgetic Widget ${e}`,w.setAttribute("aria-label",`${r("interactiveWidget")}: ${e}`);const y={compositionId:e,renderMode:"iframe",displayMode:"inline",resize:o,width:"number"==typeof i?i:parseInt(i.toString()),height:"number"==typeof n?n:parseInt(n.toString()),autoscale:s,adaptive:a,responsive:d,media:x},S=v.generateIframeCSS(y);S&&(w.style.cssText+=S),this.applyIframeStyling(w,e,{width:i,height:n,resize:o,autoscale:s,adaptive:a}),w.style.visibility="hidden",w.style.opacity="0",w.style.transition="opacity 0.3s ease",this.addLoadingIndicator(l,y),this.setupEnhancedIframeMessaging(w,e,I),this.setupLoadingOptimization(w,e,E);const W="lazy"===m,M=new Promise(((t,i)=>{let n=null;W||(n=setTimeout((()=>{i(new Error(`Iframe load timeout for composition: ${e}`))}),E.timeout||1e4)),w.onload=()=>{n&&clearTimeout(n),this.removeLoadingIndicator(l),w.style.visibility="visible",w.style.opacity="1",t()},w.onerror=()=>{n&&clearTimeout(n),this.removeLoadingIndicator(l),i(new Error(`Failed to load iframe for composition: ${e}`))}}));if(l.appendChild(w),p&&"undefined"!=typeof ResizeObserver){const t=new v({observeResize:!0}),i=`iframe-${e}-${Date.now()}`;w.setAttribute("data-widget-id",i),t.registerWidget(i,w,l,y),w.__resizeHandler=t,w.__widgetId=i}d&&"number"==typeof d&&d>0&&this.setupResponsiveMonitoring(w,l,e,d),this.iframeRegistry.set(e,w),w.classList.add("widgetic-widget","widgetic-iframe","widgetic-enhanced"),W||(yield M);const L=`iframe-${e}-${Date.now()}`;if(c.info("Enhanced iframe widget rendered successfully",{compositionId:e,size:{width:i,height:n},resize:o,autoscale:s,responsive:d,sandbox:g.join(" "),features:h.join("; ")}),y.media&&Object.keys(y.media).length>0){b().registerWidget(e,y.media),this.setupIframeMediaListener(w,e)}if(t.content&&Object.keys(t.content).length>0){f().registerWidget(e,t.content),this.setupIframeContentListener(w,e)}return{id:L,element:w,compositionData:k,widgetData:C,renderMode:"iframe",cleanup:()=>this.cleanupWidget(w)}}catch(t){throw c.error("Enhanced iframe widget rendering failed",{compositionId:e,error:t}),this.removeLoadingIndicator(l),t}}))}renderWidgets(t){return e(this,void 0,void 0,(function*(){c.debug("Rendering multiple iframe widgets",{count:t.length});const e=t.map((e=>this.renderWidget(e))),i=yield Promise.allSettled(e),n=[];for(let e=0;e<i.length;e++){const o=i[e],s=t[e];if("fulfilled"===o.status)n.push(o.value);else{c.error("Iframe widget rendering failed in batch",{compositionId:s.compositionId,error:o.reason});const e=`error-${s.compositionId}-${Date.now()}`;n.push({id:e,element:this.createErrorElement(s,o.reason),compositionData:{id:s.compositionId,name:`Composition ${s.compositionId}`,widgetId:`widget-${s.compositionId}`,config:{}},widgetData:{id:`widget-${s.compositionId}`,name:`Widget ${s.compositionId}`,type:"iframe",version:"1.0",moduleUrl:"",dependencies:[]},renderMode:"iframe",cleanup:()=>{}})}}return c.info("Iframe batch rendering complete",{total:t.length,successful:n.filter((e=>"IFRAME"===e.element.tagName)).length,failed:n.filter((e=>"IFRAME"!==e.element.tagName)).length}),n}))}createSecureIframe(e,t){var i;const n=document.createElement("iframe");return n.style.border="none",n.style.display="block",n.style.overflow="hidden",n.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),n.setAttribute("crossorigin","anonymous"),(null===(i=t.security)||void 0===i?void 0:i.enableCSP)&&n.setAttribute("csp",this.generateCSP(t.security.allowedOrigins)),n.setAttribute("data-widgetic-id",e),n.setAttribute("data-enhanced","true"),n}getDefaultSandboxPermissions(){return["allow-scripts","allow-same-origin","allow-forms","allow-popups","allow-presentation","allow-downloads"]}getDefaultAllowedFeatures(){return["autoplay","encrypted-media","picture-in-picture","fullscreen","clipboard-read","clipboard-write"]}applySandboxSecurity(e,t,i){e.setAttribute("sandbox",t.join(" ")),e.setAttribute("allow",i.join("; ")),e.setAttribute("fetchpriority","high")}generateCSP(e){const t=e||[l.CLIENT_URL];return[`default-src 'self' ${t.join(" ")}`,`script-src 'self' 'unsafe-inline' ${t.join(" ")}`,`style-src 'self' 'unsafe-inline' ${t.join(" ")}`,`img-src 'self' data: blob: ${t.join(" ")}`,`media-src 'self' blob: ${t.join(" ")}`,"object-src 'none'","base-uri 'self'","form-action 'self'"].join("; ")}buildSecureIframeUrl(t,i){return e(this,void 0,void 0,(function*(){var e;const n=`${l.CLIENT_URL}/embed/${t}`,o=new URLSearchParams;i.width&&o.set("width","number"==typeof i.width?i.width.toString():i.width),i.height&&o.set("height","number"==typeof i.height?i.height.toString():i.height),i.resize&&o.set("resize",i.resize),i.autoscale&&o.set("autoscale","true"),i.adaptive&&o.set("adaptive",i.adaptive.toString()),i.responsive&&"number"==typeof i.responsive&&o.set("responsive",i.responsive.toString()),(null===(e=i.security)||void 0===e?void 0:e.signatureValidation)&&o.set("validateSignature","true"),o.set("sdkVersion","1.0"),o.set("mode","iframe");try{const e=yield g();o.set("apiKey",e)}catch(e){c.warn("Failed to get auth token for iframe",e),l.API_KEY&&o.set("apiKey",l.API_KEY)}const s=`${n}?${o.toString()}`;return c.debug("Built secure iframe URL",{compositionId:t,url:s}),s}))}applyIframeStyling(e,t,i){const{width:n,height:o,resize:s,autoscale:a,adaptive:d}=i;if(e.style.width="number"==typeof n?`${n}px`:n,e.style.height="number"==typeof o?`${o}px`:o,"fill-width"===s)e.style.width="100%",e.style.height="auto",e.style.minHeight="number"==typeof o?`${o}px`:o;a&&this.enableIframeAutoscale(e,t,a),d&&this.makeIframeResponsive(e,d)}makeIframeResponsive(e,t){const i=window.matchMedia(`(max-width: ${t}px)`),n=()=>{i.matches?(e.style.width="100%",e.style.height="auto",e.style.minHeight="200px",e.classList.add("widgetic-mobile")):e.classList.remove("widgetic-mobile")};n(),i.addEventListener?i.addEventListener("change",n):i.addListener(n),e._responsiveCleanup=()=>{i.removeEventListener?i.removeEventListener("change",n):i.removeListener(n)}}enableIframeAutoscale(e,t,i){const n="boolean"==typeof i?{enabled:i}:i;n.enabled&&(this.autoScaleManager.enableAutoScale(e,t,n),e._autoscaleCleanup=()=>{this.autoScaleManager.disableAutoScale(t)},c.debug("AutoScale enabled for iframe",{compositionId:t,config:n}))}setupLoadingOptimization(e,t,i){if(!i.enabled)return;const n=i.timeout||1e4,o=i.retryCount||3;let s=0;const a=()=>{s<o?(s++,c.warn(`Iframe loading failed, retrying (${s}/${o})`,{compositionId:t}),setTimeout((()=>{e.src=e.src+"&retry="+s}),1e3*s)):(c.error("Iframe loading failed after retries",{compositionId:t,retryCount:o}),this.handleIframeFallback(e,t))},d=setTimeout((()=>{c.warn("Iframe loading timeout",{compositionId:t,timeout:n}),a()}),n);this.loadingTimeouts.set(t,d),e.addEventListener("load",(()=>{const e=this.loadingTimeouts.get(t);e&&(clearTimeout(e),this.loadingTimeouts.delete(t)),c.debug("Iframe loaded successfully",{compositionId:t})})),e.addEventListener("error",(()=>{c.error("Iframe error occurred",{compositionId:t}),a()}))}handleIframeFallback(e,t){const i=document.createElement("div");i.className="widgetic-iframe-fallback",i.innerHTML='\n <div style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n color: #6c757d;\n text-align: center;\n padding: 20px;\n ">\n <div>\n <div style="font-size: 24px; margin-bottom: 8px;">⚠️</div>\n <div style="font-weight: 500; margin-bottom: 4px;">Widget Unavailable</div>\n <small>The widget could not be loaded. Please try refreshing the page.</small>\n </div>\n </div>\n ',e.parentNode&&(e.parentNode.insertBefore(i,e),e.parentNode.removeChild(e)),i.dispatchEvent(new CustomEvent("widgetic:fallback",{detail:{compositionId:t,reason:"loading_failed"},bubbles:!0}))}setupEnhancedIframeMessaging(e,t,i={}){const n=w({enableSignatureValidation:i.signatureValidation||!1,allowedOrigins:i.allowedOrigins,enableHeartbeat:!0,heartbeatInterval:3e4});n.registerHandler(t,(t=>{this.handleEnhancedIframeMessage(e,t)})),e.addEventListener("load",(()=>{n.sendMessage(t,{type:"config",instanceId:t,payload:{compositionId:t,apiUrl:u(),timestamp:Date.now(),sdkVersion:"2.0",mode:"iframe"},timestamp:Date.now(),version:"1.0"}),c.debug("Initial config sent to iframe",{compositionId:t})})),e.__messenger=n,e.__messagingCompositionId=t,c.debug("Enhanced iframe messaging setup complete",{compositionId:t})}handleEnhancedIframeMessage(e,t){switch(c.debug("Enhanced iframe message received",{type:t.type,instanceId:t.instanceId,sequence:t.sequence}),t.type){case"resize":this.handleResizeMessage(e,t);break;case"ready":this.handleReadyMessage(e,t);break;case"error":this.handleErrorMessage(e,t);break;case"data":this.handleDataMessage(e,t);break;case"event":this.handleEventMessage(e,t);break;default:c.debug("Unknown enhanced message type",{type:t.type,instanceId:t.instanceId})}}handleResizeMessage(e,t){const{width:i,height:n}=t.payload;i&&n&&(e.style.width=`${i}px`,e.style.height=`${n}px`,e.dispatchEvent(new CustomEvent("widgetic:resize",{detail:{width:i,height:n,instanceId:t.instanceId},bubbles:!0})),c.debug("Iframe resized",{width:i,height:n,instanceId:t.instanceId}))}handleReadyMessage(e,t){e.setAttribute("data-ready","true"),e.dispatchEvent(new CustomEvent("widgetic:ready",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,payload:t.payload},bubbles:!0})),c.info("Iframe widget ready",{instanceId:t.instanceId})}handleErrorMessage(e,t){e.setAttribute("data-error","true"),e.dispatchEvent(new CustomEvent("widgetic:error",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,error:t.payload.error,code:t.payload.code},bubbles:!0})),c.error("Iframe widget error",{instanceId:t.instanceId,error:t.payload.error})}handleDataMessage(e,t){e.dispatchEvent(new CustomEvent("widgetic:data",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,data:t.payload},bubbles:!0})),c.debug("Iframe data received",{instanceId:t.instanceId,dataType:t.payload.type})}handleEventMessage(e,t){e.dispatchEvent(new CustomEvent("widgetic:interaction",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,eventType:t.payload.type,eventData:t.payload.data},bubbles:!0})),c.debug("Iframe interaction event",{instanceId:t.instanceId,eventType:t.payload.type})}sendMessageToIframe(e,t,i){w().sendMessage(e,{type:t,instanceId:e,payload:i,timestamp:Date.now(),version:"1.0"})}addLoadingIndicator(e,t){const i=document.createElement("div");i.className="widgetic-loading-indicator",i.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: center;\n width: ${t.width}px;\n height: ${t.height}px;\n background: #f5f5f5;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n position: relative;\n `,i.innerHTML='\n <div style="text-align: center;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #e0e0e0;\n border-top: 2px solid #666;\n border-radius: 50%;\n animation: widgetic-spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <div>Loading widget...</div>\n </div>\n ';const n=document.createElement("style");n.textContent="\n @keyframes widgetic-spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(n),e.appendChild(i)}removeLoadingIndicator(e){const t=e.querySelector(".widgetic-loading-indicator");t&&t.parentNode&&t.parentNode.removeChild(t)}createErrorElement(e,t){const i=document.createElement("div");return i.className="widgetic-error",i.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: center;\n width: ${e.width}px;\n height: ${e.height}px;\n background: #fff5f5;\n color: #e53e3e;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n text-align: center;\n padding: 16px;\n box-sizing: border-box;\n `,i.innerHTML=`\n <div>\n <div style="font-weight: 600; margin-bottom: 4px;">Widget Error</div>\n <div style="font-size: 12px; opacity: 0.8;">Failed to load composition: ${e.compositionId}</div>\n </div>\n `,i}cleanupWidget(e){const t=e.__resizeHandler,i=e.__widgetId;t&&i&&t.unregisterWidget(i);const n=e.__responsiveManager,o=e.__responsiveId;n&&o&&n.unregisterWidget(o);const s=e.__messenger,a=e.__messagingCompositionId;s&&a&&s.unregisterHandler(a);const d=this.loadingTimeouts.get(a);d&&(clearTimeout(d),this.loadingTimeouts.delete(a)),a&&this.iframeRegistry.delete(a),e._responsiveCleanup&&e._responsiveCleanup(),e._autoscaleCleanup&&e._autoscaleCleanup(),e.parentNode&&e.parentNode.removeChild(e),c.debug("Iframe cleanup complete",{compositionId:a})}cleanupIframe(e){const t=this.iframeRegistry.get(e);t&&this.cleanupWidget(t)}setupResponsiveMonitoring(e,t,i,n){const o=M(),s=w(),a={breakpoint:n,debounceDelay:150},d=`responsive-${i}`;o.registerWidget(d,t,a,(t=>{c.debug("Responsive state changed, notifying iframe",{compositionId:i,mode:t.mode,breakpoint:t.breakpoint,width:t.width}),s.sendMessage(i,{type:"responsive",instanceId:i,compositionId:i,payload:{mode:t.mode,breakpoint:t.breakpoint,width:t.width,timestamp:t.timestamp},timestamp:Date.now(),version:"1.0"}),e.dispatchEvent(new CustomEvent("widgetic:responsive",{detail:{instanceId:i,compositionId:i,mode:t.mode,breakpoint:t.breakpoint,width:t.width},bubbles:!0}))})),e.__responsiveId=d,e.__responsiveManager=o,c.info("Responsive monitoring enabled for iframe",{compositionId:i,breakpoint:n,containerId:d})}setupIframeMediaListener(e,t){const i=b(),n=n=>{var o,s;if(n.source===e.contentWindow&&(null===(s=null===(o=n.data)||void 0===o?void 0:o.type)||void 0===s?void 0:s.startsWith("widgetic:media:"))){const o=n.data.type.replace("widgetic:media:","");if(["play","pause","stop","ended","seeking","seeked","timeupdate","progress","volumechange","trackchange","playlistchange"].includes(o)){const s=e.getAttribute("data-widget-config"),a=s?JSON.parse(s):{};i.handleMediaEvent({type:o,compositionId:t,config:a.media||{},data:n.data.detail||n.data.payload||n.data.data||{}})}}};window.addEventListener("message",n),e._mediaListenerCleanup=()=>{window.removeEventListener("message",n)}}setupIframeContentListener(e,t){const i=f(),n=n=>{var o,s;if(n.source===e.contentWindow&&(null===(s=null===(o=n.data)||void 0===o?void 0:o.type)||void 0===s?void 0:s.startsWith("widgetic:content:"))){const o=n.data.type.replace("widgetic:content:","");if(["position","navigate","complete","reset","metadata"].includes(o)){const s=e.getAttribute("data-widgetic-config");let a={};if(s)try{a=JSON.parse(s).content||{}}catch(e){a={contentType:"custom",persistState:!0}}i.handleContentPositionEvent({type:o,compositionId:t,config:a,data:n.data.payload||n.data.data||{}})}}};window.addEventListener("message",n),e._contentListenerCleanup=()=>{window.removeEventListener("message",n)}}}let $=null;var A=Object.freeze({__proto__:null,IframeRenderer:L,getIframeRenderer:function(){return $||($=new L),$}});class z{constructor(){this.batchClient=a(),this.moduleLoader=d(),this.customElementRenderer=new k,this.iframeRenderer=new L,this.renderedWidgets=new Map}renderWidget(t){return e(this,void 0,void 0,(function*(){const e=this.generateWidgetId(t.compositionId),i=this.createLoadingElement(t.container);t.container&&i&&t.container.appendChild(i);try{const n=yield this.batchClient.getComposition(t.compositionId),o=yield this.batchClient.getWidget(n.widgetId),s=this.determineRenderMode(t.renderMode,o);let a;if("custom-element"===s)try{a=yield this.moduleLoader.loadModule(o)}catch(s){const a=yield this.renderWithIframe(e,t,n,o);return this.removeLoadingElement(i),a}const d="iframe"===s?yield this.renderWithIframe(e,t,n,o):yield this.renderWithCustomElement(e,t,n,o,a);return this.removeLoadingElement(i),this.renderedWidgets.set(e,d),this.emitWidgetEvent("ready",{widgetId:e,compositionId:t.compositionId,renderMode:d.renderMode,loadTime:(null==a?void 0:a.loadTime)||0,cached:(null==a?void 0:a.cached)||!1}),d}catch(n){if(this.removeLoadingElement(i),this.emitWidgetEvent("error",{widgetId:e,compositionId:t.compositionId,error:n instanceof Error?n.message:String(n),fallback:"iframe"}),t.container){const e=this.createErrorElement(t.compositionId,n);t.container.appendChild(e)}try{const i=yield this.renderFallback(e,t);if(t.container){const e=t.container.querySelector(".widgetic-error");e&&e.remove()}return i}catch(e){throw new Error(`Widget rendering failed: ${n}. Fallback also failed: ${e}`)}}}))}renderWidgets(t){return e(this,void 0,void 0,(function*(){const i=t.map((e=>e.compositionId)),n=yield this.batchClient.getCompositions(i),o=new Map(n.map((e=>[e.id,e]))),s=new Set;for(const e of t)if("iframe"!==e.renderMode){const t=o.get(e.compositionId);t&&t.widgetId&&s.add(t.widgetId)}const a=s.size>0?yield this.batchClient.getWidgets(Array.from(s)):[],d=new Map(a.map((e=>[e.id,e]))),r=a.filter((e=>"custom-element"===this.determineRenderMode("auto",e)));r.length>0&&(yield this.moduleLoader.preloadModules(r));const c=t.map((t=>e(this,void 0,void 0,(function*(){const e=o.get(t.compositionId)||{id:t.compositionId,widgetId:"default",name:"Composition",settings:{},config:{},version:"1.0.0"},i=d.get(e.widgetId)||{id:e.widgetId||"default",name:"Widget",type:"iframe",version:"1.0.0",moduleUrl:"",dependencies:[]};return this.renderSingleWidgetWithData(t,e,i)}))));return(yield Promise.allSettled(c)).filter((e=>"rejected"!==e.status)).map((e=>e.value))}))}getWidget(e){return this.renderedWidgets.get(e)||null}getAllWidgets(){return Array.from(this.renderedWidgets.values())}refreshWidget(t){return e(this,void 0,void 0,(function*(){const e=this.renderedWidgets.get(t);if(!e)return null;e.cleanup(),this.renderedWidgets.delete(t);const i={compositionId:e.compositionData.id,renderMode:e.renderMode,container:e.element.parentElement||void 0};return this.batchClient.clearCache(),this.moduleLoader.invalidateModule(e.widgetData.id),this.renderWidget(i)}))}cleanupWidget(e){const t=this.renderedWidgets.get(e);t&&(t.cleanup(),this.renderedWidgets.delete(e))}cleanupAll(){const e=Array.from(this.renderedWidgets.values());for(const t of e)t.cleanup();this.renderedWidgets.clear()}getStats(){return{renderedWidgets:this.renderedWidgets.size,batchCache:this.batchClient.getCacheStats(),moduleCache:this.moduleLoader.getCacheStats(),widgets:Array.from(this.renderedWidgets.entries()).map((([e,t])=>({id:e,compositionId:t.compositionData.id,widgetType:t.widgetData.type,renderMode:t.renderMode,hasModule:!!t.loadedModule})))}}renderSingleWidgetWithData(t,i,n){return e(this,void 0,void 0,(function*(){const e=this.generateWidgetId(t.compositionId);if("custom-element"===this.determineRenderMode(t.renderMode,n))try{const o=yield this.moduleLoader.loadModule(n);return this.renderWithCustomElement(e,t,i,n,o)}catch(e){}return this.renderWithIframe(e,t,i,n)}))}renderWithCustomElement(t,i,n,o,s){return e(this,void 0,void 0,(function*(){const e=yield this.customElementRenderer.render({compositionId:i.compositionId,compositionData:n,widgetData:o,loadedModule:s,width:i.width,height:i.height,resize:i.resize,autoscale:i.autoscale,adaptive:i.adaptive});return i.container&&i.container.appendChild(e.element),{id:t,element:e.element,compositionData:n,widgetData:o,loadedModule:s,renderMode:"custom-element",cleanup:()=>{e.element.remove()}}}))}renderWithIframe(t,i,n,o){return e(this,void 0,void 0,(function*(){return yield this.iframeRenderer.renderWidget({compositionId:i.compositionId,compositionData:n,widgetData:o,width:i.width,height:i.height,resize:i.resize,autoscale:i.autoscale,adaptive:i.adaptive,container:i.container})}))}renderFallback(t,i){return e(this,void 0,void 0,(function*(){const e=document.createElement("div");return e.className="widgetic-fallback",e.innerHTML=`\n <div style="\n padding: 20px; \n text-align: center; \n background: #f5f5f5; \n border: 1px solid #ddd; \n border-radius: 4px;\n color: #666;\n ">\n <p>Widget temporarily unavailable</p>\n <small>Composition ID: ${i.compositionId}</small>\n </div>\n `,i.container&&i.container.appendChild(e),{id:t,element:e,compositionData:{id:i.compositionId,name:"Fallback",widgetId:"fallback",config:{}},widgetData:{id:"fallback",name:"Fallback Widget",type:"fallback",version:"1.0.0",moduleUrl:""},renderMode:"iframe",cleanup:()=>{e.remove()}}}))}determineRenderMode(e="auto",t){var i;if("auto"!==e)return e;const n="undefined"!=typeof customElements&&"function"==typeof customElements.define,o=(null==t?void 0:t.moduleUrl)||(null===(i=null==t?void 0:t.metadata)||void 0===i?void 0:i.supportsCustomElements);return n&&o?"custom-element":"iframe"}generateWidgetId(e){return`widget-${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}emitWidgetEvent(e,t){const i=new CustomEvent(`widgetic:${e}`,{detail:t,bubbles:!0});document.dispatchEvent(i)}createLoadingElement(e){if(!e)return null;const t=document.createElement("div");return t.className="widgetic-loading",t.style.cssText="\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100px;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n color: #6c757d;\n ",t.innerHTML='\n <div style="text-align: center;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #f3f3f3;\n border-top: 2px solid #007bff;\n border-radius: 50%;\n animation: widgetic-spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <div style="font-size: 14px;">Loading widget...</div>\n </div>\n ',this.addLoadingStyles(),t}removeLoadingElement(e){e&&e.parentNode&&e.parentNode.removeChild(e)}createErrorElement(e,t){const i=document.createElement("div");i.className="widgetic-error",i.style.cssText="\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100px;\n padding: 20px;\n text-align: center;\n background: #fff5f5;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n color: #742a2a;\n ";const n=t instanceof Error?t.message:"Unknown error occurred",o=this.analyzeError(n,t);return i.innerHTML=`\n <div>\n <div style="font-size: 24px; margin-bottom: 8px;">${o.icon}</div>\n <div style="font-weight: 500; margin-bottom: 8px;">${o.title}</div>\n <div style="font-size: 14px; margin-bottom: 12px; color: #666;">\n ${o.description}\n </div>\n <div style="font-size: 12px; margin-bottom: 16px; color: #888;">\n Widget ID: ${e}\n </div>\n ${o.actionHtml}\n </div>\n `,i}analyzeError(e,t){const i=e.toLowerCase();return i.includes("composition not found")||i.includes("404")?{icon:"🔍",title:"Widget Not Found",description:"This widget may have been removed or the ID is incorrect.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Not%20Found%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AThe%20widget%20could%20not%20be%20found.%20Please%20check%20if%20it%20was%20deleted%20or%20if%20the%20ID%20is%20correct.', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:i.includes("unauthorized")||i.includes("forbidden")||i.includes("401")||i.includes("403")||i.includes("permission")||i.includes("access denied")?{icon:"🔒",title:"Access Restricted",description:"This widget requires an active subscription or has been restricted.",actionHtml:`\n <div style="margin-bottom: 12px;">\n <a \n href="https://widgetic.com/pricing" \n target="_blank"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n ⭐ Upgrade Plan\n </a>\n </div>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Access%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AI%20am%20having%20trouble%20accessing%20this%20widget.%20Please%20check%20my%20account%20status%20and%20permissions.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:i.includes("deleted")||i.includes("expired")||i.includes("no longer available")?{icon:"🗑️",title:"Widget Deleted",description:"This widget has been permanently removed.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Deleted%20Widget%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AThis%20widget%20appears%20to%20have%20been%20deleted.%20Can%20you%20help%20me%20restore%20it%20or%20find%20an%20alternative?', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:i.includes("subscription")||i.includes("billing")||i.includes("payment")||i.includes("plan")||i.includes("downgrade")?{icon:"💳",title:"Subscription Required",description:"This widget requires an active subscription to display.",actionHtml:`\n <div style="margin-bottom: 12px;">\n <a \n href="https://widgetic.com/pricing" \n target="_blank"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n margin-right: 8px;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n ⭐ View Plans\n </a>\n <a \n href="https://widgetic.com/dashboard/billing" \n target="_blank"\n style="\n background: #6c757d;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#5a6268'"\n onmouseout="this.style.background='#6c757d'"\n >\n 💳 Billing\n </a>\n </div>\n <div style="font-size: 12px; color: #888; margin-top: 8px;">\n Need help? Contact support below\n </div>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Subscription%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AI%20need%20help%20with%20my%20subscription%20to%20access%20this%20widget.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 4px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n margin-top: 4px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:i.includes("timeout")||i.includes("network")||i.includes("connection")||i.includes("fetch")?{icon:"🌐",title:"Connection Issue",description:"Unable to load widget due to network connectivity.",actionHtml:`\n <button \n onclick="window.location.reload()"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n margin-right: 8px;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n 🔄 Retry\n </button>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Connection%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AError:%20${encodeURIComponent(e)}%0A%0AI%20am%20experiencing%20connection%20issues%20loading%20this%20widget.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:{icon:"⚠️",title:"Widget Unavailable",description:e||"An unknown error occurred while loading this widget.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Error%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AError:%20${encodeURIComponent(e)}', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n <div style="margin-top: 8px;">\n <button \n onclick="window.location.reload()"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n margin-left: 8px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 🔄 Refresh Page\n </button>\n </div>\n `}}addLoadingStyles(){const e="widgetic-loading-styles";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes widgetic-spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(t)}}let R=null;function D(){return R||(R=new z),R}function _(){R&&R.cleanupAll(),R=null}var H=Object.freeze({__proto__:null,WidgetRenderer:z,getWidgetRenderer:D,resetWidgetRenderer:_});export{k as C,L as I,I as W,z as a,_ as b,C as c,D as g,A as i,E as r,H as w};
|
|
1
|
+
import{_ as e}from"./vendor.js";import{g as t,a as n}from"./api.js";import{n as i,m as o,l as s,d as r,g as a}from"./core.js";import{b as d,c,m as l}from"./scanner.js";import{a as u,g}from"./media.js";import{getMessenger as m}from"./messaging.js";import{R as p}from"./display.js";const h=["DOMAIN_NOT_ALLOWED","UNPUBLISHED","SUSPENDED","NOT_FOUND","RATE_LIMITED"],f={DOMAIN_NOT_ALLOWED:"domain_not_allowed",UNPUBLISHED:"unpublished",SUSPENDED:"suspended",NOT_FOUND:"not_found",RATE_LIMITED:"rate_limited"};function b(e){return h.includes(e)?f[e]:null}const w=/^https:\/\/[^\s"'<>]+\.(?:png|jpe?g|webp|gif|avif)(?:\?[^\s"'<>]*)?$/i,v=new Set;function y(e,t,n=e=>e){if("undefined"!=typeof document&&document.head)try{for(const i of function(e,t,n=2){const i=[];let o=0;const s=(e,t)=>{if(i.length>=n||o>=400)return;if(o+=1,"string"==typeof e)return void(w.test(e)&&!i.includes(e)&&i.push(e));if(t>=4||null===e||"object"!=typeof e)return;const r=Array.isArray(e)?e:Object.values(e);for(const e of r)s(e,t+1)};return s(e,0),s(t,0),i}(e,t)){const e=n(i);if(v.has(e))continue;v.add(e);const t=document.createElement("link");t.setAttribute("rel","preload"),t.setAttribute("as","image"),t.setAttribute("href",e),document.head.appendChild(t)}}catch(e){}}const I=[480,960,1600],k=["static.widgetic.com","cdn.widgetic.com"],E=/^https:\/\/[^\s"'<>]+\.(?:png|jpe?g|webp|avif)(?:\?[^\s"'<>]*)?$/i;function C(){var e;if("undefined"==typeof window)return I[I.length-1];return function(e){var t;const n=I,i=Number.isFinite(e)&&e>0?e:n[n.length-1];return null!==(t=n.find((e=>e>=i)))&&void 0!==t?t:n[n.length-1]}((window.innerWidth||(null===(e=document.documentElement)||void 0===e?void 0:e.clientWidth)||0)*Math.min(window.devicePixelRatio||1,2))}function x(e,t){let n=0;const i=(e,o)=>{if(n+=1,n>5e3)return e;if("string"==typeof e)return function(e,t){if(!E.test(e))return e;let n;try{n=new URL(e)}catch(t){return e}if(!k.includes(n.hostname.toLowerCase()))return e;if(n.pathname.startsWith("/cdn-cgi/"))return e;const i=`width=${t},fit=scale-down,quality=80,format=auto`;return`${n.origin}/cdn-cgi/image/${i}/${e}`}(e,t);if(o>=8||null===e||"object"!=typeof e)return e;if(Array.isArray(e))return e.map((e=>i(e,o+1)));const s={};for(const[t,n]of Object.entries(e))s[t]=i(n,o+1);return s};return i(e,0)}function S(e,t,n){try{if(!function(e){if(!e||!0!==e.optimize)return!1;if("undefined"==typeof window||"undefined"==typeof document)return!1;if(!1===window.WIDGETIC_IMAGE_OPTIMIZE)return!1;const t=document.querySelectorAll("script[src*='embed-sdk'][data-image-optimize]");for(const e of Array.from(t))if("off"===(e.getAttribute("data-image-optimize")||"").trim().toLowerCase())return!1;return!0}(e))return{content:t,contentItems:n};const i=C();return{content:x(t,i),contentItems:x(n,i)}}catch(e){return{content:t,contentItems:n}}}const W="lookups",A=864e5;function $(){if("undefined"==typeof window||"undefined"==typeof document)return!1;const e=window;if(!e.indexedDB)return!1;if(!1===e.WIDGETIC_EMBED_LOOKUP_CACHE)return!1;const t=document.querySelectorAll("script[src*='embed-sdk'][data-lookup-cache]");for(const e of Array.from(t))if("off"===(e.getAttribute("data-lookup-cache")||"").trim().toLowerCase())return!1;return!0}let M=null;function L(){return M||(M=new Promise((t=>{try{const n=window.indexedDB.open("widgetic-embed-lookup",1);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(W)||n.result.createObjectStore(W)},n.onsuccess=()=>{t(n.result),function(t){e(this,void 0,void 0,(function*(){try{const e=t.transaction(W,"readwrite"),n=e.objectStore(W).openCursor(),i=Date.now()-A;n.onsuccess=()=>{const e=n.result;if(!e)return;const t=e.value;(!t||"number"!=typeof t.storedAtMs||t.storedAtMs<i)&&e.delete(),e.continue()}}catch(e){}}))}(n.result)},n.onerror=()=>t(null),n.onblocked=()=>t(null)}catch(e){t(null)}})),M)}const D="https://cdn.widgetic.com",_="DOMAIN_NOT_ALLOWED";function z(){if("undefined"==typeof document)return[];const e=[],t=document.querySelectorAll("script[src*='embed-sdk']");for(const n of Array.from(t)){const t=n.getAttribute("data-api-url");t&&t.trim()&&e.push(t.trim().replace(/\/+$/,""))}const n=window.WIDGETIC_EMBED_API;return n&&String(n).trim()&&e.push(String(n).trim().replace(/\/+$/,"")),e}function R(e){var t;if("undefined"==typeof window)return null;const n=window.__WIDGETIC_EMBED_LOOKUP__;return(null===(t=null==n?void 0:n[e])||void 0===t?void 0:t.embedUrl)||null}function O(e,t){if(!e||"object"!=typeof e)return null;let n="string"==typeof e.embedUrl?e.embedUrl:"";if(!n&&"string"==typeof e.js_path&&e.js_path.trim()){const t=e.js_path.trim();n=/^https?:\/\//i.test(t)?t:`${D}${t.startsWith("/")?"":"/"}${t}`}else!n&&"string"==typeof e.embed_url&&e.embed_url.trim()&&(n=e.embed_url.trim());if(!n)return null;const i=function(e){if(!e||"object"!=typeof e)return;const t=e;return"string"!=typeof t.moduleUrl||"number"!=typeof t.contractVersion?void 0:{moduleUrl:t.moduleUrl,contractVersion:t.contractVersion,moduleHash:"string"==typeof t.moduleHash?t.moduleHash:null}}(e.direct),o="string"==typeof e.compositionId?e.compositionId:void 0,s="string"==typeof e.widgetId?e.widgetId:"string"==typeof e.id?e.id:void 0,r="string"==typeof e.entryWriteToken?e.entryWriteToken:void 0;let a;if(e.entries&&"object"==typeof e.entries){const t=e.entries;"string"==typeof t.url&&(a=Object.assign({url:t.url},"string"==typeof t.writeToken?{writeToken:t.writeToken}:r?{writeToken:r}:{}))}else r&&o&&t&&(a={url:`${t.replace(/\/+$/,"")}/embed/compositions/${o}/entries`,writeToken:r});const d=e.media,c=d&&"object"==typeof d&&"boolean"==typeof d.optimize?{optimize:d.optimize}:void 0,l=S(c,e.content&&"object"==typeof e.content?e.content:{},Array.isArray(e.contentItems)?e.contentItems:[]);return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({embedUrl:n,compositionId:o},s?{widgetId:s}:{}),{design:e.design&&"object"==typeof e.design?e.design:{},content:l.content,contentItems:l.contentItems}),c?{media:c}:{}),i?{direct:i}:{}),r?{entryWriteToken:r}:{}),a?{entries:a}:{})}function j(t){return e(this,void 0,void 0,(function*(){let e=null;try{e=yield t.json()}catch(t){e=null}const n=function(e){if(!e||"object"!=typeof e||Array.isArray(e))return null;const t=e.code;return"string"==typeof t&&t.length>0&&t.length<=64?t:null}(e),i=(n&&b(n)?n:null)||(429===(o=t.status)?"RATE_LIMITED":404===o?"NOT_FOUND":null);var o;if(!i)return null;const s=b(i);return s?{gatewayCode:i,stateCode:s}:null}))}const T=new Map;function U(e){try{return new URL(e).origin}catch(e){return""}}function H(t){return e(this,void 0,void 0,(function*(){try{const n=yield fetch(t,{method:"GET",mode:"cors"});if(!n.ok){const t=yield function(t){return e(this,void 0,void 0,(function*(){if(403!==t.status)return null;try{const e=yield t.json();if(!e||"object"!=typeof e||e.code!==_)return null;const n=e.details&&"object"==typeof e.details?e.details:null,i="string"==typeof(null==n?void 0:n.reason)?n.reason.slice(0,80):void 0;return{code:_,reason:i}}catch(e){return null}}))}(n);if(t)return{kind:"refused",refusal:t};const i=yield j(n);return i?{kind:"failed",failure:i}:{kind:"unavailable"}}return{kind:"json",json:yield n.json()}}catch(e){return{kind:"unavailable"}}}))}function N(t){const n=T.get(t);if(n)return n;const i=H(t).then((n=>("json"===n.kind&&O(n.json,U(t))&&function(t,n){e(this,void 0,void 0,(function*(){if(!$())return;const e=yield L();if(e)try{const i={json:n,storedAtMs:Date.now()};e.transaction(W,"readwrite").objectStore(W).put(i,t)}catch(e){}}))}(t,n.json),n)));return T.set(t,i),i.finally((()=>{T.get(t)===i&&T.delete(t)})),i}function P(e){return JSON.parse(JSON.stringify(e))}function F(t){return e(this,void 0,void 0,(function*(){const n=U(t),i=yield function(t){return e(this,void 0,void 0,(function*(){if(!$())return null;const e=yield L();return e?new Promise((n=>{try{const i=e.transaction(W,"readonly").objectStore(W).get(t);i.onsuccess=()=>{const e=i.result,t=e&&"number"==typeof e.storedAtMs&&e.json&&"object"==typeof e.json;n(t?e:null)},i.onerror=()=>n(null)}catch(e){n(null)}})):null}))}(t);if(i&&function(e,t=Date.now()){const n=t-e.storedAtMs;return n>=0&&n<=3e4}(i)){const e=O(P(i.json),n);if(e)return N(t),y(e.content,e.contentItems),{kind:"payload",payload:e,gatewayOrigin:n}}const o=yield N(t);if("json"!==o.kind)return o;const s=O(P(o.json),n);return s?(y(s.content,s.contentItems),{kind:"payload",payload:s,gatewayOrigin:n}):{kind:"unavailable"}}))}function B(e){return"refused"===e.kind?{status:"refused",refusal:e.refusal}:"failed"===e.kind?{status:"failed",failure:e.failure}:{status:"found",payload:e.payload,gatewayOrigin:e.gatewayOrigin||void 0}}function q(e){const t=`/embed/compositions/${e}`,n=[];for(const e of z())n.push(`${e}${t}`);const s=o().replace(/\/+$/,"");n.push(`${s}${t}`);const r=String(i.PROD_API_URL).replace(/\/+$/,"");return r&&n.push(`${r}${t}`),[...new Set(n)]}function V(t){return e(this,void 0,void 0,(function*(){const e=z();for(const n of e){const e=yield F(`${n}/embed/compositions/${t}`);if("unavailable"!==e.kind)return B(e)}const n=yield function(e){const t=R(e);return t?Promise.resolve(t):"undefined"==typeof document?Promise.resolve(null):new Promise((t=>{const n=document.createElement("script");n.src=`${D}/embed/compositions/${e}.js`,n.async=!0,n.onload=()=>t(R(e)),n.onerror=()=>t(null),document.head.appendChild(n)}))}(t);if(n){for(const e of q(t)){const t=yield F(e);if("refused"===t.kind)return B(t);if("failed"!==t.kind&&"payload"===t.kind){const e=t.payload;return{status:"found",payload:Object.assign(Object.assign({},e),{embedUrl:e.embedUrl||n}),gatewayOrigin:t.gatewayOrigin||void 0}}}return{status:"found",payload:{embedUrl:n,compositionId:t}}}let i=null;for(const e of q(t)){const t=yield F(e);if("refused"===t.kind)return B(t);if("failed"!==t.kind){if("payload"===t.kind)return B(t)}else i=t.failure}return i?{status:"failed",failure:i}:{status:"not-found"}}))}function K(t){return e(this,void 0,void 0,(function*(){const e=z();for(const n of e){const e=yield F(`${n}/widgets/${encodeURIComponent(t)}`);if("unavailable"!==e.kind)return B(e)}const n=R(t);let s=null;for(const e of function(e){const t=`/widgets/${encodeURIComponent(e)}`,n=[];for(const e of z())n.push(`${e}${t}`);const s=o().replace(/\/+$/,"");n.push(`${s}${t}`);const r=String(i.PROD_API_URL).replace(/\/+$/,"");return r&&n.push(`${r}${t}`),[...new Set(n)]}(t)){const t=yield F(e);if("refused"===t.kind)return B(t);if("failed"!==t.kind){if("payload"===t.kind)return B(t)}else s=t.failure}return n?{status:"found",payload:{embedUrl:n,widgetId:t}}:s?{status:"failed",failure:s}:{status:"not-found"}}))}const J=new Set;function G(e,t){var n;if(J.has(e))return;J.add(e);"undefined"!=typeof window&&(null===(n=window.location)||void 0===n?void 0:n.hostname)&&window.location.hostname,t.reason&&t.reason}function Y(e,t,n,i,o){const s=document.createElement("iframe");return s.src=e,s.width=t,s.height=n,s.setAttribute("frameborder","0"),s.setAttribute("allowfullscreen",""),s.style.border="0",s.style.display="block",s.style.maxWidth="100%",i&&s.setAttribute("data-composition-id",i),function(e,t){if(!t)return;const n=t.design&&Object.keys(t.design).length>0?t.design:null,i=t.content&&Object.keys(t.content).length>0?t.content:null,o=t.contentItems&&t.contentItems.length>0?t.contentItems:null;if(!n&&!i&&!o)return;const s=()=>{const t=e.contentWindow;if(!t)return;const s={type:"widgetic:update"};n&&(s.design=n),i&&(s.content=i),o&&(s.contentItems=o),t.postMessage(s,"*")};window.addEventListener("message",(t=>{t.source===e.contentWindow&&"widgetic:ready"===(t.data&&t.data.type||"")&&s()})),e.addEventListener("load",(()=>{s(),window.setTimeout(s,80),window.setTimeout(s,400)}))}(s,o),s}const Q="undefined"!=typeof HTMLElement?HTMLElement:class{};class Z extends Q{static get observedAttributes(){return["composition-id","width","height","resize","autoscale","adaptive","theme"]}constructor(){super(),this.svelteComponent=null,this.compositionData=null,this.widgetData=null,this.loadedModule=null,this.isInitialized=!1,this.isWidgetConnected=!1,this.resizeObserver=null,this.eventListeners=new Map,this.widgetState={ready:!1,error:null,loading:!1,data:{}},this.instanceId=this.generateInstanceId(),this.cssNamespace=`widgetic-${this.instanceId}`,this.initializeCSSIsolation(),s.debug("WidgeticWidget created",{instanceId:this.instanceId})}connectedCallback(){return e(this,void 0,void 0,(function*(){var e;if(!this.isWidgetConnected){this.isWidgetConnected=!0,s.debug("WidgeticWidget connected",{instanceId:this.instanceId});try{this.setLoadingState(!0);const t=d(this),n=null!==(e=null==t?void 0:t.id)&&void 0!==e?e:this.getAttribute("composition-id");if(!n)throw new Error("composition-id attribute is required");c(this);const i="widget"===(null==t?void 0:t.kind)?yield K(n):yield V(n);if("refused"===i.status)throw G(n,i.refusal),new Error("This embed is not authorized to be shown on this website.");const o="found"===i.status?i.payload:null;if(null==o?void 0:o.embedUrl){const e=l(this,o);return this.innerHTML="",this.appendChild(Y(o.embedUrl,this.getAttribute("width")||"400",this.getAttribute("height")||"300",n,e)),void this.setWidgetReady()}yield this.loadWidgetData(n),this.widgetData&&(yield this.loadWidgetModule()),yield this.initializeWidget(),this.setupResponsiveBehavior(),this.setupEventHandling(),this.setWidgetReady()}catch(e){s.error("WidgeticWidget initialization failed",{instanceId:this.instanceId,error:e}),this.setErrorState(e)}}}))}disconnectedCallback(){this.isWidgetConnected&&(s.debug("WidgeticWidget disconnected",{instanceId:this.instanceId}),this.cleanup(),this.isWidgetConnected=!1)}attributeChangedCallback(e,t,n){if(this.isInitialized&&t!==n){switch(s.debug("WidgeticWidget attribute changed",{instanceId:this.instanceId,attribute:e,oldValue:t,newValue:n}),e){case"width":case"height":this.updateDimensions();break;case"resize":this.updateResizeMode();break;case"autoscale":this.updateAutoscale();break;case"adaptive":this.updateAdaptive();break;case"theme":this.updateTheme()}this.notifyWidgetPropsChanged()}}initializeCSSIsolation(){this.setAttribute("data-widgetic-instance",this.instanceId),this.addBaseStyles(),this.initializeCSSCustomProperties()}addBaseStyles(){const e=`widgetic-base-styles-${this.instanceId}`;if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent=`\n /* Widget base styles with namespace isolation */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"] {\n /* CSS Reset for widget container */\n all: initial;\n \n /* Widget container properties */\n display: block;\n box-sizing: border-box;\n position: relative;\n \n /* CSS custom properties with namespacing */\n --widgetic-instance: ${this.instanceId};\n --widgetic-primary: var(--widgetic-${this.instanceId}-primary, #007bff);\n --widgetic-secondary: var(--widgetic-${this.instanceId}-secondary, #6c757d);\n --widgetic-background: var(--widgetic-${this.instanceId}-background, #ffffff);\n --widgetic-text: var(--widgetic-${this.instanceId}-text, #333333);\n --widgetic-border: var(--widgetic-${this.instanceId}-border, #dee2e6);\n \n /* Widget content isolation */\n contain: layout style paint;\n isolation: isolate;\n }\n\n /* Prevent external CSS interference */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"] * {\n box-sizing: border-box;\n }\n\n /* Loading state styles */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"][data-loading="true"] {\n min-height: 120px;\n background: linear-gradient(90deg, #f0f0f0 25%, transparent 37%, #f0f0f0 63%);\n background-size: 400% 100%;\n animation: widgetic-loading-${this.instanceId} 1.5s ease-in-out infinite;\n }\n\n @keyframes widgetic-loading-${this.instanceId} {\n 0% { background-position: 100% 50%; }\n 100% { background-position: 0% 50%; }\n }\n\n /* Error state styles */\n widgetic-widget[data-widgetic-instance="${this.instanceId}"][data-error="true"] {\n border: 2px dashed #dc3545;\n background-color: #f8d7da;\n color: #721c24;\n padding: 16px;\n text-align: center;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;\n }\n `,document.head.appendChild(t)}initializeCSSCustomProperties(){const e=this.getAttribute("theme");if(e)try{const t=JSON.parse(e);Object.entries(t).forEach((([e,t])=>{this.style.setProperty(`--widgetic-${this.instanceId}-${e}`,String(t))}))}catch(t){s.warn("Invalid theme attribute",{instanceId:this.instanceId,theme:e})}}loadWidgetData(n){return e(this,void 0,void 0,(function*(){const e=t();this.compositionData=yield e.getComposition(n),this.widgetData=yield e.getWidget(this.compositionData.widgetId),s.debug("Widget data loaded",{instanceId:this.instanceId,compositionId:n,widgetId:this.compositionData.widgetId})}))}loadWidgetModule(){return e(this,void 0,void 0,(function*(){if(!this.widgetData)return;const e=n();this.loadedModule=yield e.loadModule(this.widgetData),s.debug("Widget module loaded",{instanceId:this.instanceId,moduleUrl:this.widgetData.moduleUrl,loadTime:this.loadedModule.loadTime})}))}initializeWidget(){return e(this,void 0,void 0,(function*(){if(!this.loadedModule||!this.compositionData)throw new Error("Widget module or composition data not loaded");try{const{component:e}=this.loadedModule.module,t=document.createElement("div");if(t.className=`widgetic-content-${this.instanceId}`,this.applyWidgetProperties(t),e.$$typeof)yield this.initializeReactComponent(t,e);else if(e._isVue||e.__isVue)yield this.initializeVueComponent(t,e);else{if("function"!=typeof e)throw new Error("Unsupported component type");yield this.initializeSvelteOrVanillaComponent(t,e)}this.innerHTML="",this.appendChild(t),this.isInitialized=!0,s.debug("Widget initialized successfully",{instanceId:this.instanceId})}catch(e){throw s.error("Widget initialization failed",{instanceId:this.instanceId,error:e}),e}}))}initializeReactComponent(t,n){return e(this,void 0,void 0,(function*(){if("undefined"==typeof window||!window.React||!window.ReactDOM)throw new Error("React not available globally");{const e=window.React,i=window.ReactDOM,o=this.getWidgetProps(),s=e.createElement(n,o);i.render(s,t)}}))}initializeVueComponent(t,n){return e(this,void 0,void 0,(function*(){if("undefined"==typeof window||!window.Vue)throw new Error("Vue not available globally");{const e=window.Vue,i=this.getWidgetProps();new e({el:t,render:e=>e(n,{props:i})})}}))}initializeSvelteOrVanillaComponent(t,n){return e(this,void 0,void 0,(function*(){var e;const i=this.getWidgetProps();if(n.$$prop_def||(null===(e=n.prototype)||void 0===e?void 0:e.$$prop_def))this.svelteComponent=new n({target:t,props:i});else if(n.prototype&&n.prototype.constructor===n){const e=new n(t,i);"function"==typeof e.render&&(yield e.render())}else if("function"==typeof n)yield n(t,i);else{if(!n||"function"!=typeof n.init)throw new Error("Unknown component type");yield n.init(t,i)}}))}getWidgetProps(){var e,t;return{config:(null===(e=this.compositionData)||void 0===e?void 0:e.config)||{},metadata:(null===(t=this.compositionData)||void 0===t?void 0:t.metadata)||{},instance:this.instanceId,element:this,dimensions:{width:this.getAttribute("width")||"100%",height:this.getAttribute("height")||"400"},resize:this.getAttribute("resize")||"responsive",autoscale:"true"===this.getAttribute("autoscale"),adaptive:parseInt(this.getAttribute("adaptive")||"768"),state:this.widgetState,onStateChange:this.handleStateChange.bind(this),onResize:this.handleResize.bind(this),onError:this.handleError.bind(this)}}applyWidgetProperties(e){var t;const n=this.getAttribute("width")||"100%",i=this.getAttribute("height")||"400",o=this.getAttribute("resize")||"responsive";switch(e.style.width="number"==typeof n?`${n}px`:n,e.style.height="number"==typeof i?`${i}px`:i,o){case"fill-width":e.style.width="100%";break;case"responsive":e.style.maxWidth="100%",e.style.height="auto"}e.classList.add(`widgetic-widget-${(null===(t=this.widgetData)||void 0===t?void 0:t.type)||"unknown"}`)}setupResponsiveBehavior(){const e=parseInt(this.getAttribute("adaptive")||"768"),t="true"===this.getAttribute("autoscale"),n=this.getAttribute("resize")||"responsive";t&&"ResizeObserver"in window&&(this.resizeObserver=new ResizeObserver((e=>{for(const t of e)this.handleAutoscale(t)})),this.resizeObserver.observe(this)),"responsive"!==n&&"fill-width"!==n||this.setupAdaptiveBehavior(e)}setupAdaptiveBehavior(e){const t=window.matchMedia(`(max-width: ${e}px)`),n=t=>{this.setAttribute("data-mobile",t.matches?"true":"false"),this.dispatchEvent(new CustomEvent("widgetic:adaptive",{detail:{isMobile:t.matches,breakpoint:e}}))};n(t),t.addEventListener("change",n),this.eventListeners.set("adaptive",(()=>{t.removeEventListener("change",n)}))}handleAutoscale(e){const{width:t,height:n}=e.contentRect;this.dispatchEvent(new CustomEvent("widgetic:resize",{detail:{width:t,height:n}})),this.widgetState.data.dimensions={width:t,height:n}}setupEventHandling(){const e=e=>{this.dispatchEvent(new CustomEvent("widgetic:interaction",{detail:{type:"click",originalEvent:e},bubbles:!0}))};this.addEventListener("click",e),this.eventListeners.set("click",(()=>{this.removeEventListener("click",e)}));const t=e=>{e.target instanceof HTMLFormElement&&this.handleFormSubmission(e)};this.addEventListener("submit",t),this.eventListeners.set("submit",(()=>{this.removeEventListener("submit",t)}))}handleFormSubmission(e){e.preventDefault();const t=e.target,n=new FormData(t),i={};n.forEach(((e,t)=>{i[t]=e})),this.widgetState.data.formData=i,this.dispatchEvent(new CustomEvent("widgetic:form-submit",{detail:{data:i,form:t},bubbles:!0})),s.debug("Form submitted",{instanceId:this.instanceId,data:i})}handleStateChange(e){this.widgetState.data=Object.assign(Object.assign({},this.widgetState.data),e),this.dispatchEvent(new CustomEvent("widgetic:state-change",{detail:{state:this.widgetState.data},bubbles:!0}))}handleResize(e){this.dispatchEvent(new CustomEvent("widgetic:resize",{detail:e,bubbles:!0}))}handleError(e){this.setErrorState(e)}updateDimensions(){const e=this.querySelector(`.widgetic-content-${this.instanceId}`);e&&this.applyWidgetProperties(e)}updateResizeMode(){this.updateDimensions(),this.setupResponsiveBehavior()}updateAutoscale(){this.setupResponsiveBehavior()}updateAdaptive(){const e=parseInt(this.getAttribute("adaptive")||"768");this.setupAdaptiveBehavior(e)}updateTheme(){this.initializeCSSCustomProperties()}notifyWidgetPropsChanged(){this.svelteComponent&&"function"==typeof this.svelteComponent.$set&&this.svelteComponent.$set(this.getWidgetProps()),this.dispatchEvent(new CustomEvent("widgetic:props-changed",{detail:{props:this.getWidgetProps()}}))}setLoadingState(e){this.widgetState.loading=e,this.setAttribute("data-loading",e?"true":"false"),e&&(this.innerHTML=`\n <div class="widgetic-loading-${this.instanceId}">\n <div>Loading widget...</div>\n </div>\n `)}setWidgetReady(){this.widgetState.ready=!0,this.widgetState.loading=!1,this.widgetState.error=null,this.setAttribute("data-ready","true"),this.removeAttribute("data-loading"),this.removeAttribute("data-error"),this.dispatchEvent(new CustomEvent("widgetic:ready",{detail:{instanceId:this.instanceId},bubbles:!0})),s.info("Widget ready",{instanceId:this.instanceId})}setErrorState(e){this.widgetState.error=e,this.widgetState.loading=!1,this.widgetState.ready=!1,this.setAttribute("data-error","true"),this.removeAttribute("data-loading"),this.removeAttribute("data-ready"),this.innerHTML=`\n <div class="widgetic-error-${this.instanceId}">\n <strong>Widget Error</strong><br>\n <small>${e.message}</small>\n </div>\n `,this.dispatchEvent(new CustomEvent("widgetic:error",{detail:{error:e.message,instanceId:this.instanceId},bubbles:!0})),s.error("Widget error",{instanceId:this.instanceId,error:e})}getState(){return Object.assign({},this.widgetState.data)}setState(e){this.handleStateChange(e)}refresh(){return e(this,void 0,void 0,(function*(){this.cleanup(),this.isInitialized=!1,this.isWidgetConnected=!1,yield this.connectedCallback()}))}cleanup(){this.svelteComponent&&"function"==typeof this.svelteComponent.$destroy&&(this.svelteComponent.$destroy(),this.svelteComponent=null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),this.eventListeners.forEach((e=>{if("function"==typeof e)try{e()}catch(e){s.warn("Failed to cleanup event listener",{instanceId:this.instanceId,error:e})}})),this.eventListeners.clear();const e=document.getElementById(`widgetic-base-styles-${this.instanceId}`);e&&e.remove(),s.debug("Widget cleanup complete",{instanceId:this.instanceId})}generateInstanceId(){return`${Date.now()}-${Math.random().toString(36).substring(2,11)}`}}function X(){"undefined"!=typeof window&&"undefined"!=typeof customElements&&(customElements.get("widgetic-widget")||(customElements.define("widgetic-widget",Z),s.info("WidgeticWidget custom element registered")))}class ee{constructor(){this.observers=new Map,this.mutationObservers=new Map,this.timeouts=new Map,this.animationIds=new Map,this.storageKey="widgetic_autoscale_heights"}static getInstance(){return ee.instance||(ee.instance=new ee),ee.instance}enableAutoScale(e,t,n={enabled:!0}){if(!n.enabled)return;const i=Object.assign({minHeight:n.minHeight||50,maxHeight:n.maxHeight||2e3,debounceDelay:n.debounceDelay||150,threshold:n.threshold||5,animate:!1!==n.animate,animationDuration:n.animationDuration||300},n),o=e.offsetHeight,s=this.getStoredHeight(t);s&&s!==o&&this.setElementHeight(e,s,i.animate,i.animationDuration),this.setupContentMonitoring(e,t,i,o)}disableAutoScale(e){const t=this.observers.get(e);t&&(t.disconnect(),this.observers.delete(e));const n=this.mutationObservers.get(e);n&&(n.disconnect(),this.mutationObservers.delete(e));const i=this.timeouts.get(e);i&&(clearTimeout(i),this.timeouts.delete(e));const o=this.animationIds.get(e);o&&(cancelAnimationFrame(o),this.animationIds.delete(e));const s=document.querySelector(`iframe[data-widgetic-id="${e}"], iframe[data-composition-id="${e}"]`);s&&s._autoscaleMessageCleanup&&(s._autoscaleMessageCleanup(),delete s._autoscaleMessageCleanup)}getStoredHeight(e){try{const t=localStorage.getItem(this.storageKey);if(!t)return null;const n=JSON.parse(t),i=n[e];if(!i)return null;const o=864e5;return Date.now()-i.lastUpdated>o?(delete n[e],localStorage.setItem(this.storageKey,JSON.stringify(n)),null):i.height}catch(e){return null}}storeHeight(e,t,n){try{const i=localStorage.getItem(this.storageKey),o=i?JSON.parse(i):{};o[e]={compositionId:e,height:t,originalHeight:n,lastUpdated:Date.now()},localStorage.setItem(this.storageKey,JSON.stringify(o))}catch(e){}}setupContentMonitoring(e,t,n,i){const o=this.findContentElement(e);if(!o)return void e.tagName.toLowerCase();const s=this.createDebouncedHeightUpdate(e,t,n,i);if("undefined"!=typeof ResizeObserver){const e=new ResizeObserver((e=>{for(const t of e){const e=t.target.scrollHeight;s(e)}}));e.observe(o),this.observers.set(t,e)}const r=new MutationObserver((()=>{const e=o.scrollHeight;s(e)}));r.observe(o,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","height"]}),this.mutationObservers.set(t,r);const a=o.scrollHeight;s(a)}findContentElement(e){var t;if("iframe"===e.tagName.toLowerCase())try{const n=e,i=n.contentDocument||(null===(t=n.contentWindow)||void 0===t?void 0:t.document);if(null==i?void 0:i.body)return i.body}catch(t){return this.setupIframePostMessageListener(e),null}const n=e.tagName.toLowerCase();if("widgetic"===n||"widgetic-widget"===n||e.classList.contains("widgetic-widget")){return e.querySelector(".widget-content, .widgetic-content, [data-content]")||e}return e}setupIframePostMessageListener(e){const t=e.getAttribute("data-widgetic-id")||e.getAttribute("data-composition-id")||"unknown",n=n=>{var i,o;if(n.source===e.contentWindow&&("widgetic:autoscale"===(null===(i=n.data)||void 0===i?void 0:i.type)||"autoscale"===(null===(o=n.data)||void 0===o?void 0:o.type))){const{height:i,contentHeight:o}=n.data.payload||n.data;if("number"==typeof i&&i>0){const n=this.getConfigForWidget(t),s=Math.max(n.minHeight||50,Math.min(n.maxHeight||2e3,i));this.setElementHeight(e,s,n.animate,n.animationDuration),this.storeHeight(t,s,e.offsetHeight),e.dispatchEvent(new CustomEvent("widgetic:autoscale",{detail:{compositionId:t,oldHeight:e.offsetHeight,newHeight:s,contentHeight:o||i}}))}}};window.addEventListener("message",n),e._autoscaleMessageCleanup=()=>{window.removeEventListener("message",n)}}getConfigForWidget(e){return{enabled:!0,minHeight:50,maxHeight:2e3,animate:!0,animationDuration:300,debounceDelay:150,threshold:5}}createDebouncedHeightUpdate(e,t,n,i){let o=e.offsetHeight;return s=>{const r=this.timeouts.get(t);r&&clearTimeout(r);const a=setTimeout((()=>{const r=Math.max(n.minHeight,Math.min(n.maxHeight,s));Math.abs(r-o)>=n.threshold&&(this.setElementHeight(e,r,n.animate,n.animationDuration),this.storeHeight(t,r,i),o=r,e.dispatchEvent(new CustomEvent("widgetic:autoscale",{detail:{compositionId:t,oldHeight:o,newHeight:r,contentHeight:s}}))),this.timeouts.delete(t)}),n.debounceDelay);this.timeouts.set(t,a)}}setElementHeight(e,t,n=!0,i=300){if(!n)return void(e.style.height=`${t}px`);const o=e.offsetHeight,s=t-o;if(Math.abs(s)<1)return;const r=this.animationIds.get(e.id||e.tagName);r&&cancelAnimationFrame(r);const a=performance.now(),d=o,c=n=>{const o=n-a,r=Math.min(o/i,1),l=1-Math.pow(1-r,3),u=d+s*l;if(e.style.height=`${u}px`,r<1){const t=requestAnimationFrame(c);this.animationIds.set(e.id||e.tagName,t)}else e.style.height=`${t}px`,this.animationIds.delete(e.id||e.tagName)},l=requestAnimationFrame(c);this.animationIds.set(e.id||e.tagName,l)}clearStoredHeights(){try{localStorage.removeItem(this.storageKey)}catch(e){}}getStoredHeights(){try{const e=localStorage.getItem(this.storageKey);return e?JSON.parse(e):{}}catch(e){return{}}}destroy(){this.observers.forEach((e=>e.disconnect())),this.observers.clear(),this.mutationObservers.forEach((e=>e.disconnect())),this.mutationObservers.clear(),this.timeouts.forEach((e=>clearTimeout(e))),this.timeouts.clear(),this.animationIds.forEach((e=>cancelAnimationFrame(e))),this.animationIds.clear()}}class te{constructor(){this.autoScaleManager=ee.getInstance(),X()}render(t){return e(this,void 0,void 0,(function*(){const{compositionId:e,width:n="100%",height:i="400",resize:o="responsive",autoscale:s=!0,adaptive:r=768,media:a,content:d}=t,c=document.createElement("widgetic-widget");if(c.setAttribute("composition-id",e),c.setAttribute("width",String(n)),c.setAttribute("height",String(i)),c.setAttribute("resize",o),"boolean"==typeof s?c.setAttribute("autoscale",s?"true":"false"):s&&"object"==typeof s?(c.setAttribute("autoscale","true"),void 0!==s.minHeight&&c.setAttribute("autoscale-min-height",String(s.minHeight)),void 0!==s.maxHeight&&c.setAttribute("autoscale-max-height",String(s.maxHeight)),void 0!==s.debounceDelay&&c.setAttribute("autoscale-debounce",String(s.debounceDelay)),void 0!==s.threshold&&c.setAttribute("autoscale-threshold",String(s.threshold)),void 0!==s.animate&&c.setAttribute("autoscale-animate",String(s.animate)),void 0!==s.animationDuration&&c.setAttribute("autoscale-animation-duration",String(s.animationDuration))):c.setAttribute("autoscale","false"),c.setAttribute("adaptive",String(r)),a&&Object.keys(a).length>0){u().registerWidget(e,a),this.setupCustomElementMediaListener(c,e)}if(d&&Object.keys(d).length>0){g().registerWidget(e,d),this.setupCustomElementContentListener(c,e)}return{id:`custom-${e}-${Date.now()}`,element:c,compositionData:{id:e,name:`Composition ${e}`,widgetId:`widget-${e}`,config:{}},widgetData:{id:`widget-${e}`,name:`Widget ${e}`,type:"custom-element",version:"1.0",moduleUrl:"",dependencies:[]},renderMode:"custom-element",cleanup:()=>{c._mediaCommandCleanup&&c._mediaCommandCleanup(),c._mediaObserverCleanup&&c._mediaObserverCleanup(),c._contentPositionCleanup&&c._contentPositionCleanup()}}}))}initializeWidget(t,n,i){return e(this,void 0,void 0,(function*(){}))}renderFrameworkComponent(t,n,i){return e(this,void 0,void 0,(function*(){if(n.$$typeof&&"undefined"!=typeof window&&window.React&&window.ReactDOM){const e=window.React,o=window.ReactDOM,s=e.createElement(n,{config:i.config,metadata:i.metadata});o.render(s,t)}else{if(!n._isVue&&!n.__isVue||"undefined"==typeof window||!window.Vue)throw new Error("Framework component detected but framework not available");new(0,window.Vue)({el:t,render:e=>e(n,{props:{config:i.config,metadata:i.metadata}})})}}))}applyElementStyling(e,t,n){const{width:i,height:o,resize:s,autoscale:r,adaptive:a}=n;switch(e.style.width="number"==typeof i?`${i}px`:i,e.style.height="number"==typeof o?`${o}px`:o,e.style.display="block",e.style.overflow="hidden",s){case"fill-width":e.style.width="100%";break;case"responsive":this.makeResponsive(e,a||768)}if(r){("boolean"==typeof r?r:r&&"object"==typeof r&&r.enabled)&&this.enableAutoscale(e,t,r)}e.classList.add("widgetic-widget","widgetic-custom-element")}makeResponsive(e,t){const n=window.matchMedia(`(max-width: ${t}px)`),i=()=>{n.matches?(e.style.width="100%",e.style.height="auto",e.style.minHeight="200px",e.classList.add("widgetic-mobile")):e.classList.remove("widgetic-mobile")};i(),n.addEventListener?n.addEventListener("change",i):n.addListener(i),e._responsiveCleanup=()=>{n.removeEventListener?n.removeEventListener("change",i):n.removeListener(i)}}enableAutoscale(e,t,n){const i="boolean"==typeof n?{enabled:n}:n;i.enabled&&(this.autoScaleManager.enableAutoScale(e,t,i),e._autoscaleCleanup=()=>{this.autoScaleManager.disableAutoScale(t)})}showLoadingState(e){e.innerHTML='\n <div class="widgetic-loading" style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n ">\n <div style="text-align: center; color: #6c757d;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #dee2e6;\n border-top: 2px solid #007bff;\n border-radius: 50%;\n animation: spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <small>Loading widget...</small>\n </div>\n </div>\n <style>\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n </style>\n '}showErrorState(e,t){const n=t instanceof Error?t.message:"Unknown error";e.innerHTML=`\n <div class="widgetic-error" style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #fff5f5;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n color: #c53030;\n ">\n <div style="text-align: center; padding: 20px;">\n <div style="font-size: 24px; margin-bottom: 8px;">⚠️</div>\n <div style="font-weight: 500; margin-bottom: 4px;">Widget Error</div>\n <small style="color: #718096;">${n}</small>\n </div>\n </div>\n `,e.setAttribute("data-error","true"),e.dispatchEvent(new CustomEvent("widgetic:error",{detail:{error:n}}))}setupCustomElementMediaListener(e,t){const n=u(),i=t=>{const{command:n}=t.detail;if("pause"===n){const t=e.querySelectorAll("audio"),n=e.querySelectorAll("video");t.forEach((e=>{e.paused||e.pause()})),n.forEach((e=>{e.paused||e.pause()}))}else if("play"===n){const t=e.querySelectorAll("audio"),n=e.querySelectorAll("video"),i=Array.from(t).concat(Array.from(n)).find((e=>e.currentTime>0&&!e.ended));i&&i.play().catch((()=>{}))}};e.addEventListener("widgetic:media:command",i),e._mediaCommandCleanup=()=>{e.removeEventListener("widgetic:media:command",i)};const o=(i,o)=>s=>{const r=(e.__widgetConfig||{}).media||{},a="audio"===i.tagName.toLowerCase()?"audio":"video";n.handleMediaEvent({type:o,compositionId:t,config:r,data:{position:i.currentTime,duration:i.duration,volume:i.volume,mediaType:a,title:i.title||i.getAttribute("data-title")||void 0}})},s=()=>{const t=e.querySelectorAll("audio"),n=e.querySelectorAll("video");Array.from(t).concat(Array.from(n)).forEach((e=>{e.addEventListener("play",o(e,"play")),e.addEventListener("pause",o(e,"pause")),e.addEventListener("ended",o(e,"ended")),e.addEventListener("seeked",o(e,"seeking")),e.addEventListener("volumechange",o(e,"volumechange"))}))};s();const r=new MutationObserver((()=>{s()}));r.observe(e,{childList:!0,subtree:!0}),e._mediaObserverCleanup=()=>{r.disconnect()}}setupCustomElementContentListener(e,t){const n=g(),i=i=>{if(i.detail&&i.detail.type){const o=i.detail.type,s=i.detail.data||i.detail;let r={};try{const t=e.getAttribute("data-content-config");t&&(r=JSON.parse(t))}catch(e){r={contentType:"custom",persistState:!0}}n.handleContentPositionEvent({type:o,compositionId:t,config:r,data:s})}};e.addEventListener("widgetic:content:position",i),e.addEventListener("widgetic:content:navigate",i),e.addEventListener("widgetic:content:complete",i),e.addEventListener("widgetic:content:reset",i),e.addEventListener("widgetic:content:metadata",i),e._contentPositionCleanup=()=>{e.removeEventListener("widgetic:content:position",i),e.removeEventListener("widgetic:content:navigate",i),e.removeEventListener("widgetic:content:complete",i),e.removeEventListener("widgetic:content:reset",i),e.removeEventListener("widgetic:content:metadata",i)}}}var ne=Object.freeze({__proto__:null,CustomElementRenderer:te});const ie={close:"Close",closeOverlay:"Close overlay",interactiveWidget:"Interactive widget"},oe=new Map([["fr",{close:"Fermer",closeOverlay:"Fermer la fenêtre",interactiveWidget:"Widget interactif"}],["de",{close:"Schließen",closeOverlay:"Fenster schließen",interactiveWidget:"Interaktives Widget"}],["es",{close:"Cerrar",closeOverlay:"Cerrar ventana",interactiveWidget:"Widget interactivo"}],["pt",{close:"Fechar",closeOverlay:"Fechar janela",interactiveWidget:"Widget interativo"}],["nl",{close:"Sluiten",closeOverlay:"Venster sluiten",interactiveWidget:"Interactieve widget"}],["da",{close:"Luk",closeOverlay:"Luk vinduet",interactiveWidget:"Interaktiv widget"}],["sv",{close:"Stäng",closeOverlay:"Stäng fönstret",interactiveWidget:"Interaktiv widget"}],["zh",{close:"关闭",closeOverlay:"关闭窗口",interactiveWidget:"交互式小组件"}],["ar",{close:"إغلاق",closeOverlay:"إغلاق النافذة",interactiveWidget:"ويجت تفاعلي"}],["he",{close:"סגירה",closeOverlay:"סגירת החלון",interactiveWidget:"וידג'ט אינטראקטיבי"}],["fa",{close:"بستن",closeOverlay:"بستن پنجره",interactiveWidget:"ویجت تعاملی"}],["ur",{close:"بند کریں",closeOverlay:"ونڈو بند کریں",interactiveWidget:"انٹرایکٹو ویجٹ"}]]);function se(e,t=function(){var e,t;return"undefined"==typeof document?"":(null===(e=document.body)||void 0===e?void 0:e.getAttribute("lang"))||(null===(t=document.documentElement)||void 0===t?void 0:t.getAttribute("lang"))||""}()){const n=function(e){var t,n;const i=(null!=e?e:"").trim().replace(/_/g,"-").toLowerCase().split("-"),o="iw"===i[0]?"he":null!==(t=i[0])&&void 0!==t?t:"",s=null!==(n=i[1])&&void 0!==n?n:"";return("zh"!==o||"tw"!==s&&"hk"!==s&&"hant"!==s)&&oe.has(o)?o:null}(t),i=null===n?void 0:oe.get(n);return(null!=i?i:ie)[e]}oe.keys();class re{constructor(){this.observers=new Map,this.callbacks=new Map,this.currentStates=new Map,this.debounceTimers=new Map,"undefined"==typeof ResizeObserver&&s.warn("ResizeObserver not available, responsive breakpoints will not work")}registerWidget(e,t,n,i){if("undefined"==typeof ResizeObserver)return void s.warn("ResizeObserver not available, skipping responsive registration",{widgetId:e});this.unregisterWidget(e);const o=t.getBoundingClientRect().width,r=n.initialMode||(o<n.breakpoint?"mobile":"desktop"),a={mode:r,breakpoint:n.breakpoint,width:o,timestamp:Date.now()};this.currentStates.set(e,a),this.callbacks.set(e,i);const d=new ResizeObserver((t=>{this.handleResize(e,t,n)}));d.observe(t),this.observers.set(e,d),i(a),s.debug("Widget registered for responsive monitoring",{widgetId:e,breakpoint:n.breakpoint,initialMode:r,containerWidth:o})}unregisterWidget(e){const t=this.debounceTimers.get(e);t&&(clearTimeout(t),this.debounceTimers.delete(e));const n=this.observers.get(e);n&&(n.disconnect(),this.observers.delete(e)),this.callbacks.delete(e),this.currentStates.delete(e),s.debug("Widget unregistered from responsive monitoring",{widgetId:e})}getCurrentState(e){return this.currentStates.get(e)||null}checkResponsiveState(e,t){const n=this.currentStates.get(e),i=this.callbacks.get(e);if(!n||!i)return void s.warn("Widget not registered for responsive monitoring",{widgetId:e});const o=t<n.breakpoint?"mobile":"desktop";if(o!==n.mode){const r={mode:o,breakpoint:n.breakpoint,width:t,timestamp:Date.now()};this.currentStates.set(e,r),i(r),s.info("Responsive state changed manually",{widgetId:e,from:n.mode,to:o,width:t,breakpoint:n.breakpoint})}}handleResize(e,t,n){const i=this.debounceTimers.get(e);i&&clearTimeout(i);const o=setTimeout((()=>{this.processResize(e,t,n),this.debounceTimers.delete(e)}),n.debounceDelay||150);this.debounceTimers.set(e,o)}processResize(e,t,n){const i=this.currentStates.get(e),o=this.callbacks.get(e);if(!i||!o)return;const r=t[t.length-1];if(!r)return;const a=r.contentRect.width,d=a<n.breakpoint?"mobile":"desktop";if(d!==i.mode){const t={mode:d,breakpoint:n.breakpoint,width:a,timestamp:Date.now()};this.currentStates.set(e,t),o(t),s.info("Responsive breakpoint crossed",{widgetId:e,from:i.mode,to:d,width:a,breakpoint:n.breakpoint})}else if(Math.abs(a-i.width)>10){const t=Object.assign(Object.assign({},i),{width:a,timestamp:Date.now()});this.currentStates.set(e,t),s.debug("Container width updated",{widgetId:e,width:a,mode:i.mode,breakpoint:n.breakpoint})}}getRegisteredWidgets(){return Array.from(this.observers.keys())}cleanup(){const e=this.getRegisteredWidgets();for(const t of e)this.unregisterWidget(t);s.debug("ResponsiveManager cleanup complete")}}let ae=null;function de(){return ae||(ae=new re),ae}class ce{constructor(){this.messageQueue=new Map,this.iframeRegistry=new Map,this.loadingTimeouts=new Map,this.autoScaleManager=ee.getInstance()}renderWidget(t){return e(this,void 0,void 0,(function*(){const{compositionId:e,width:n,height:i,resize:o="fixed",autoscale:r=!1,adaptive:a,responsive:d,container:c,allowFullscreen:l=!0,sandbox:m=this.getDefaultSandboxPermissions(),allowedFeatures:h=this.getDefaultAllowedFeatures(),loading:f="lazy",enableResize:b=!0,compositionData:w,widgetData:v,security:y={},fallback:I={enabled:!0,timeout:1e4,retryCount:3},media:k}=t;if(!n||!i||!c)throw new Error("Missing required parameters: width, height, and container are required");const E=w||{id:e,name:`Composition ${e}`,widgetId:`widget-${e}`,config:{}},C=v||{id:E.widgetId,name:`Widget ${e}`,type:"iframe",version:"1.0",moduleUrl:"",dependencies:[]};try{const w=this.createSecureIframe(e,t);w.src=yield this.buildSecureIframeUrl(e,t),w.title=`Widgetic Widget: ${E.name||e}`,w.loading=f,this.applySandboxSecurity(w,m,h),w.width=n.toString(),w.height=i.toString(),w.frameBorder="0",w.scrolling="no",l&&(w.allowFullscreen=!0,w.setAttribute("allowfullscreen","")),w.title=`Widgetic Widget ${e}`,w.setAttribute("aria-label",`${se("interactiveWidget")}: ${e}`);const v={compositionId:e,renderMode:"iframe",displayMode:"inline",resize:o,width:"number"==typeof n?n:parseInt(n.toString()),height:"number"==typeof i?i:parseInt(i.toString()),autoscale:r,adaptive:a,responsive:d,media:k},x=p.generateIframeCSS(v);x&&(w.style.cssText+=x),this.applyIframeStyling(w,e,{width:n,height:i,resize:o,autoscale:r,adaptive:a}),w.style.visibility="hidden",w.style.opacity="0",w.style.transition="opacity 0.3s ease",this.addLoadingIndicator(c,v),this.setupEnhancedIframeMessaging(w,e,y),this.setupLoadingOptimization(w,e,I);const S="lazy"===f,W=new Promise(((t,n)=>{let i=null;S||(i=setTimeout((()=>{n(new Error(`Iframe load timeout for composition: ${e}`))}),I.timeout||1e4)),w.onload=()=>{i&&clearTimeout(i),this.removeLoadingIndicator(c),w.style.visibility="visible",w.style.opacity="1",t()},w.onerror=()=>{i&&clearTimeout(i),this.removeLoadingIndicator(c),n(new Error(`Failed to load iframe for composition: ${e}`))}}));if(c.appendChild(w),b&&"undefined"!=typeof ResizeObserver){const t=new p({observeResize:!0}),n=`iframe-${e}-${Date.now()}`;w.setAttribute("data-widget-id",n),t.registerWidget(n,w,c,v),w.__resizeHandler=t,w.__widgetId=n}d&&"number"==typeof d&&d>0&&this.setupResponsiveMonitoring(w,c,e,d),this.iframeRegistry.set(e,w),w.classList.add("widgetic-widget","widgetic-iframe","widgetic-enhanced"),S||(yield W);const A=`iframe-${e}-${Date.now()}`;if(s.info("Enhanced iframe widget rendered successfully",{compositionId:e,size:{width:n,height:i},resize:o,autoscale:r,responsive:d,sandbox:m.join(" "),features:h.join("; ")}),v.media&&Object.keys(v.media).length>0){u().registerWidget(e,v.media),this.setupIframeMediaListener(w,e)}if(t.content&&Object.keys(t.content).length>0){g().registerWidget(e,t.content),this.setupIframeContentListener(w,e)}return{id:A,element:w,compositionData:E,widgetData:C,renderMode:"iframe",cleanup:()=>this.cleanupWidget(w)}}catch(t){throw s.error("Enhanced iframe widget rendering failed",{compositionId:e,error:t}),this.removeLoadingIndicator(c),t}}))}renderWidgets(t){return e(this,void 0,void 0,(function*(){s.debug("Rendering multiple iframe widgets",{count:t.length});const e=t.map((e=>this.renderWidget(e))),n=yield Promise.allSettled(e),i=[];for(let e=0;e<n.length;e++){const o=n[e],r=t[e];if("fulfilled"===o.status)i.push(o.value);else{s.error("Iframe widget rendering failed in batch",{compositionId:r.compositionId,error:o.reason});const e=`error-${r.compositionId}-${Date.now()}`;i.push({id:e,element:this.createErrorElement(r,o.reason),compositionData:{id:r.compositionId,name:`Composition ${r.compositionId}`,widgetId:`widget-${r.compositionId}`,config:{}},widgetData:{id:`widget-${r.compositionId}`,name:`Widget ${r.compositionId}`,type:"iframe",version:"1.0",moduleUrl:"",dependencies:[]},renderMode:"iframe",cleanup:()=>{}})}}return s.info("Iframe batch rendering complete",{total:t.length,successful:i.filter((e=>"IFRAME"===e.element.tagName)).length,failed:i.filter((e=>"IFRAME"!==e.element.tagName)).length}),i}))}createSecureIframe(e,t){var n;const i=document.createElement("iframe");return i.style.border="none",i.style.display="block",i.style.overflow="hidden",i.setAttribute("referrerpolicy","strict-origin-when-cross-origin"),i.setAttribute("crossorigin","anonymous"),(null===(n=t.security)||void 0===n?void 0:n.enableCSP)&&i.setAttribute("csp",this.generateCSP(t.security.allowedOrigins)),i.setAttribute("data-widgetic-id",e),i.setAttribute("data-enhanced","true"),i}getDefaultSandboxPermissions(){return["allow-scripts","allow-same-origin","allow-forms","allow-popups","allow-presentation","allow-downloads"]}getDefaultAllowedFeatures(){return["autoplay","encrypted-media","picture-in-picture","fullscreen","clipboard-read","clipboard-write"]}applySandboxSecurity(e,t,n){e.setAttribute("sandbox",t.join(" ")),e.setAttribute("allow",n.join("; ")),e.setAttribute("fetchpriority","high")}generateCSP(e){const t=e||[r.CLIENT_URL];return[`default-src 'self' ${t.join(" ")}`,`script-src 'self' 'unsafe-inline' ${t.join(" ")}`,`style-src 'self' 'unsafe-inline' ${t.join(" ")}`,`img-src 'self' data: blob: ${t.join(" ")}`,`media-src 'self' blob: ${t.join(" ")}`,"object-src 'none'","base-uri 'self'","form-action 'self'"].join("; ")}buildSecureIframeUrl(t,n){return e(this,void 0,void 0,(function*(){var e;const i=`${r.CLIENT_URL}/embed/${t}`,o=new URLSearchParams;n.width&&o.set("width","number"==typeof n.width?n.width.toString():n.width),n.height&&o.set("height","number"==typeof n.height?n.height.toString():n.height),n.resize&&o.set("resize",n.resize),n.autoscale&&o.set("autoscale","true"),n.adaptive&&o.set("adaptive",n.adaptive.toString()),n.responsive&&"number"==typeof n.responsive&&o.set("responsive",n.responsive.toString()),(null===(e=n.security)||void 0===e?void 0:e.signatureValidation)&&o.set("validateSignature","true"),o.set("sdkVersion","1.0"),o.set("mode","iframe");try{const e=yield a();o.set("apiKey",e)}catch(e){s.warn("Failed to get auth token for iframe",e),r.API_KEY&&o.set("apiKey",r.API_KEY)}const d=`${i}?${o.toString()}`;return s.debug("Built secure iframe URL",{compositionId:t,url:d}),d}))}applyIframeStyling(e,t,n){const{width:i,height:o,resize:s,autoscale:r,adaptive:a}=n;if(e.style.width="number"==typeof i?`${i}px`:i,e.style.height="number"==typeof o?`${o}px`:o,"fill-width"===s)e.style.width="100%",e.style.height="auto",e.style.minHeight="number"==typeof o?`${o}px`:o;r&&this.enableIframeAutoscale(e,t,r),a&&this.makeIframeResponsive(e,a)}makeIframeResponsive(e,t){const n=window.matchMedia(`(max-width: ${t}px)`),i=()=>{n.matches?(e.style.width="100%",e.style.height="auto",e.style.minHeight="200px",e.classList.add("widgetic-mobile")):e.classList.remove("widgetic-mobile")};i(),n.addEventListener?n.addEventListener("change",i):n.addListener(i),e._responsiveCleanup=()=>{n.removeEventListener?n.removeEventListener("change",i):n.removeListener(i)}}enableIframeAutoscale(e,t,n){const i="boolean"==typeof n?{enabled:n}:n;i.enabled&&(this.autoScaleManager.enableAutoScale(e,t,i),e._autoscaleCleanup=()=>{this.autoScaleManager.disableAutoScale(t)},s.debug("AutoScale enabled for iframe",{compositionId:t,config:i}))}setupLoadingOptimization(e,t,n){if(!n.enabled)return;const i=n.timeout||1e4,o=n.retryCount||3;let r=0;const a=()=>{r<o?(r++,s.warn(`Iframe loading failed, retrying (${r}/${o})`,{compositionId:t}),setTimeout((()=>{e.src=e.src+"&retry="+r}),1e3*r)):(s.error("Iframe loading failed after retries",{compositionId:t,retryCount:o}),this.handleIframeFallback(e,t))},d=setTimeout((()=>{s.warn("Iframe loading timeout",{compositionId:t,timeout:i}),a()}),i);this.loadingTimeouts.set(t,d),e.addEventListener("load",(()=>{const e=this.loadingTimeouts.get(t);e&&(clearTimeout(e),this.loadingTimeouts.delete(t)),s.debug("Iframe loaded successfully",{compositionId:t})})),e.addEventListener("error",(()=>{s.error("Iframe error occurred",{compositionId:t}),a()}))}handleIframeFallback(e,t){const n=document.createElement("div");n.className="widgetic-iframe-fallback",n.innerHTML='\n <div style="\n display: flex;\n align-items: center;\n justify-content: center;\n height: 100%;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n color: #6c757d;\n text-align: center;\n padding: 20px;\n ">\n <div>\n <div style="font-size: 24px; margin-bottom: 8px;">⚠️</div>\n <div style="font-weight: 500; margin-bottom: 4px;">Widget Unavailable</div>\n <small>The widget could not be loaded. Please try refreshing the page.</small>\n </div>\n </div>\n ',e.parentNode&&(e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e)),n.dispatchEvent(new CustomEvent("widgetic:fallback",{detail:{compositionId:t,reason:"loading_failed"},bubbles:!0}))}setupEnhancedIframeMessaging(e,t,n={}){const i=m({enableSignatureValidation:n.signatureValidation||!1,allowedOrigins:n.allowedOrigins,enableHeartbeat:!0,heartbeatInterval:3e4});i.registerHandler(t,(t=>{this.handleEnhancedIframeMessage(e,t)})),e.addEventListener("load",(()=>{i.sendMessage(t,{type:"config",instanceId:t,payload:{compositionId:t,apiUrl:o(),timestamp:Date.now(),sdkVersion:"2.0",mode:"iframe"},timestamp:Date.now(),version:"1.0"}),s.debug("Initial config sent to iframe",{compositionId:t})})),e.__messenger=i,e.__messagingCompositionId=t,s.debug("Enhanced iframe messaging setup complete",{compositionId:t})}handleEnhancedIframeMessage(e,t){switch(s.debug("Enhanced iframe message received",{type:t.type,instanceId:t.instanceId,sequence:t.sequence}),t.type){case"resize":this.handleResizeMessage(e,t);break;case"ready":this.handleReadyMessage(e,t);break;case"error":this.handleErrorMessage(e,t);break;case"data":this.handleDataMessage(e,t);break;case"event":this.handleEventMessage(e,t);break;default:s.debug("Unknown enhanced message type",{type:t.type,instanceId:t.instanceId})}}handleResizeMessage(e,t){const{width:n,height:i}=t.payload;n&&i&&(e.style.width=`${n}px`,e.style.height=`${i}px`,e.dispatchEvent(new CustomEvent("widgetic:resize",{detail:{width:n,height:i,instanceId:t.instanceId},bubbles:!0})),s.debug("Iframe resized",{width:n,height:i,instanceId:t.instanceId}))}handleReadyMessage(e,t){e.setAttribute("data-ready","true"),e.dispatchEvent(new CustomEvent("widgetic:ready",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,payload:t.payload},bubbles:!0})),s.info("Iframe widget ready",{instanceId:t.instanceId})}handleErrorMessage(e,t){e.setAttribute("data-error","true"),e.dispatchEvent(new CustomEvent("widgetic:error",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,error:t.payload.error,code:t.payload.code},bubbles:!0})),s.error("Iframe widget error",{instanceId:t.instanceId,error:t.payload.error})}handleDataMessage(e,t){e.dispatchEvent(new CustomEvent("widgetic:data",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,data:t.payload},bubbles:!0})),s.debug("Iframe data received",{instanceId:t.instanceId,dataType:t.payload.type})}handleEventMessage(e,t){e.dispatchEvent(new CustomEvent("widgetic:interaction",{detail:{instanceId:t.instanceId,compositionId:t.compositionId,eventType:t.payload.type,eventData:t.payload.data},bubbles:!0})),s.debug("Iframe interaction event",{instanceId:t.instanceId,eventType:t.payload.type})}sendMessageToIframe(e,t,n){m().sendMessage(e,{type:t,instanceId:e,payload:n,timestamp:Date.now(),version:"1.0"})}addLoadingIndicator(e,t){const n=document.createElement("div");n.className="widgetic-loading-indicator",n.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: center;\n width: ${t.width}px;\n height: ${t.height}px;\n background: #f5f5f5;\n color: #666;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n border: 1px solid #e0e0e0;\n border-radius: 4px;\n position: relative;\n `,n.innerHTML='\n <div style="text-align: center;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #e0e0e0;\n border-top: 2px solid #666;\n border-radius: 50%;\n animation: widgetic-spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <div>Loading widget...</div>\n </div>\n ';const i=document.createElement("style");i.textContent="\n @keyframes widgetic-spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(i),e.appendChild(n)}removeLoadingIndicator(e){const t=e.querySelector(".widgetic-loading-indicator");t&&t.parentNode&&t.parentNode.removeChild(t)}createErrorElement(e,t){const n=document.createElement("div");return n.className="widgetic-error",n.style.cssText=`\n display: flex;\n align-items: center;\n justify-content: center;\n width: ${e.width}px;\n height: ${e.height}px;\n background: #fff5f5;\n color: #e53e3e;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;\n font-size: 14px;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n text-align: center;\n padding: 16px;\n box-sizing: border-box;\n `,n.innerHTML=`\n <div>\n <div style="font-weight: 600; margin-bottom: 4px;">Widget Error</div>\n <div style="font-size: 12px; opacity: 0.8;">Failed to load composition: ${e.compositionId}</div>\n </div>\n `,n}cleanupWidget(e){const t=e.__resizeHandler,n=e.__widgetId;t&&n&&t.unregisterWidget(n);const i=e.__responsiveManager,o=e.__responsiveId;i&&o&&i.unregisterWidget(o);const r=e.__messenger,a=e.__messagingCompositionId;r&&a&&r.unregisterHandler(a);const d=this.loadingTimeouts.get(a);d&&(clearTimeout(d),this.loadingTimeouts.delete(a)),a&&this.iframeRegistry.delete(a),e._responsiveCleanup&&e._responsiveCleanup(),e._autoscaleCleanup&&e._autoscaleCleanup(),e.parentNode&&e.parentNode.removeChild(e),s.debug("Iframe cleanup complete",{compositionId:a})}cleanupIframe(e){const t=this.iframeRegistry.get(e);t&&this.cleanupWidget(t)}setupResponsiveMonitoring(e,t,n,i){const o=de(),r=m(),a={breakpoint:i,debounceDelay:150},d=`responsive-${n}`;o.registerWidget(d,t,a,(t=>{s.debug("Responsive state changed, notifying iframe",{compositionId:n,mode:t.mode,breakpoint:t.breakpoint,width:t.width}),r.sendMessage(n,{type:"responsive",instanceId:n,compositionId:n,payload:{mode:t.mode,breakpoint:t.breakpoint,width:t.width,timestamp:t.timestamp},timestamp:Date.now(),version:"1.0"}),e.dispatchEvent(new CustomEvent("widgetic:responsive",{detail:{instanceId:n,compositionId:n,mode:t.mode,breakpoint:t.breakpoint,width:t.width},bubbles:!0}))})),e.__responsiveId=d,e.__responsiveManager=o,s.info("Responsive monitoring enabled for iframe",{compositionId:n,breakpoint:i,containerId:d})}setupIframeMediaListener(e,t){const n=u(),i=i=>{var o,s;if(i.source===e.contentWindow&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.type)||void 0===s?void 0:s.startsWith("widgetic:media:"))){const o=i.data.type.replace("widgetic:media:","");if(["play","pause","stop","ended","seeking","seeked","timeupdate","progress","volumechange","trackchange","playlistchange"].includes(o)){const s=e.getAttribute("data-widget-config"),r=s?JSON.parse(s):{};n.handleMediaEvent({type:o,compositionId:t,config:r.media||{},data:i.data.detail||i.data.payload||i.data.data||{}})}}};window.addEventListener("message",i),e._mediaListenerCleanup=()=>{window.removeEventListener("message",i)}}setupIframeContentListener(e,t){const n=g(),i=i=>{var o,s;if(i.source===e.contentWindow&&(null===(s=null===(o=i.data)||void 0===o?void 0:o.type)||void 0===s?void 0:s.startsWith("widgetic:content:"))){const o=i.data.type.replace("widgetic:content:","");if(["position","navigate","complete","reset","metadata"].includes(o)){const s=e.getAttribute("data-widgetic-config");let r={};if(s)try{r=JSON.parse(s).content||{}}catch(e){r={contentType:"custom",persistState:!0}}n.handleContentPositionEvent({type:o,compositionId:t,config:r,data:i.data.payload||i.data.data||{}})}}};window.addEventListener("message",i),e._contentListenerCleanup=()=>{window.removeEventListener("message",i)}}}let le=null;var ue=Object.freeze({__proto__:null,IframeRenderer:ce,getIframeRenderer:function(){return le||(le=new ce),le}});class ge{constructor(){this.batchClient=t(),this.moduleLoader=n(),this.customElementRenderer=new te,this.iframeRenderer=new ce,this.renderedWidgets=new Map}renderWidget(t){return e(this,void 0,void 0,(function*(){const e=this.generateWidgetId(t.compositionId),n=this.createLoadingElement(t.container);t.container&&n&&t.container.appendChild(n);try{const i=yield this.batchClient.getComposition(t.compositionId),o=yield this.batchClient.getWidget(i.widgetId),s=this.determineRenderMode(t.renderMode,o);let r;if("custom-element"===s)try{r=yield this.moduleLoader.loadModule(o)}catch(s){const r=yield this.renderWithIframe(e,t,i,o);return this.removeLoadingElement(n),r}const a="iframe"===s?yield this.renderWithIframe(e,t,i,o):yield this.renderWithCustomElement(e,t,i,o,r);return this.removeLoadingElement(n),this.renderedWidgets.set(e,a),this.emitWidgetEvent("ready",{widgetId:e,compositionId:t.compositionId,renderMode:a.renderMode,loadTime:(null==r?void 0:r.loadTime)||0,cached:(null==r?void 0:r.cached)||!1}),a}catch(i){if(this.removeLoadingElement(n),this.emitWidgetEvent("error",{widgetId:e,compositionId:t.compositionId,error:i instanceof Error?i.message:String(i),fallback:"iframe"}),t.container){const e=this.createErrorElement(t.compositionId,i);t.container.appendChild(e)}try{const n=yield this.renderFallback(e,t);if(t.container){const e=t.container.querySelector(".widgetic-error");e&&e.remove()}return n}catch(e){throw new Error(`Widget rendering failed: ${i}. Fallback also failed: ${e}`)}}}))}renderWidgets(t){return e(this,void 0,void 0,(function*(){const n=t.map((e=>e.compositionId)),i=yield this.batchClient.getCompositions(n),o=new Map(i.map((e=>[e.id,e]))),s=new Set;for(const e of t)if("iframe"!==e.renderMode){const t=o.get(e.compositionId);t&&t.widgetId&&s.add(t.widgetId)}const r=s.size>0?yield this.batchClient.getWidgets(Array.from(s)):[],a=new Map(r.map((e=>[e.id,e]))),d=r.filter((e=>"custom-element"===this.determineRenderMode("auto",e)));d.length>0&&(yield this.moduleLoader.preloadModules(d));const c=t.map((t=>e(this,void 0,void 0,(function*(){const e=o.get(t.compositionId)||{id:t.compositionId,widgetId:"default",name:"Composition",settings:{},config:{},version:"1.0.0"},n=a.get(e.widgetId)||{id:e.widgetId||"default",name:"Widget",type:"iframe",version:"1.0.0",moduleUrl:"",dependencies:[]};return this.renderSingleWidgetWithData(t,e,n)}))));return(yield Promise.allSettled(c)).filter((e=>"rejected"!==e.status)).map((e=>e.value))}))}getWidget(e){return this.renderedWidgets.get(e)||null}getAllWidgets(){return Array.from(this.renderedWidgets.values())}refreshWidget(t){return e(this,void 0,void 0,(function*(){const e=this.renderedWidgets.get(t);if(!e)return null;e.cleanup(),this.renderedWidgets.delete(t);const n={compositionId:e.compositionData.id,renderMode:e.renderMode,container:e.element.parentElement||void 0};return this.batchClient.clearCache(),this.moduleLoader.invalidateModule(e.widgetData.id),this.renderWidget(n)}))}cleanupWidget(e){const t=this.renderedWidgets.get(e);t&&(t.cleanup(),this.renderedWidgets.delete(e))}cleanupAll(){const e=Array.from(this.renderedWidgets.values());for(const t of e)t.cleanup();this.renderedWidgets.clear()}getStats(){return{renderedWidgets:this.renderedWidgets.size,batchCache:this.batchClient.getCacheStats(),moduleCache:this.moduleLoader.getCacheStats(),widgets:Array.from(this.renderedWidgets.entries()).map((([e,t])=>({id:e,compositionId:t.compositionData.id,widgetType:t.widgetData.type,renderMode:t.renderMode,hasModule:!!t.loadedModule})))}}renderSingleWidgetWithData(t,n,i){return e(this,void 0,void 0,(function*(){const e=this.generateWidgetId(t.compositionId);if("custom-element"===this.determineRenderMode(t.renderMode,i))try{const o=yield this.moduleLoader.loadModule(i);return this.renderWithCustomElement(e,t,n,i,o)}catch(e){}return this.renderWithIframe(e,t,n,i)}))}renderWithCustomElement(t,n,i,o,s){return e(this,void 0,void 0,(function*(){const e=yield this.customElementRenderer.render({compositionId:n.compositionId,compositionData:i,widgetData:o,loadedModule:s,width:n.width,height:n.height,resize:n.resize,autoscale:n.autoscale,adaptive:n.adaptive});return n.container&&n.container.appendChild(e.element),{id:t,element:e.element,compositionData:i,widgetData:o,loadedModule:s,renderMode:"custom-element",cleanup:()=>{e.element.remove()}}}))}renderWithIframe(t,n,i,o){return e(this,void 0,void 0,(function*(){return yield this.iframeRenderer.renderWidget({compositionId:n.compositionId,compositionData:i,widgetData:o,width:n.width,height:n.height,resize:n.resize,autoscale:n.autoscale,adaptive:n.adaptive,container:n.container})}))}renderFallback(t,n){return e(this,void 0,void 0,(function*(){const e=document.createElement("div");return e.className="widgetic-fallback",e.innerHTML=`\n <div style="\n padding: 20px; \n text-align: center; \n background: #f5f5f5; \n border: 1px solid #ddd; \n border-radius: 4px;\n color: #666;\n ">\n <p>Widget temporarily unavailable</p>\n <small>Composition ID: ${n.compositionId}</small>\n </div>\n `,n.container&&n.container.appendChild(e),{id:t,element:e,compositionData:{id:n.compositionId,name:"Fallback",widgetId:"fallback",config:{}},widgetData:{id:"fallback",name:"Fallback Widget",type:"fallback",version:"1.0.0",moduleUrl:""},renderMode:"iframe",cleanup:()=>{e.remove()}}}))}determineRenderMode(e="auto",t){var n;if("auto"!==e)return e;const i="undefined"!=typeof customElements&&"function"==typeof customElements.define,o=(null==t?void 0:t.moduleUrl)||(null===(n=null==t?void 0:t.metadata)||void 0===n?void 0:n.supportsCustomElements);return i&&o?"custom-element":"iframe"}generateWidgetId(e){return`widget-${e}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}emitWidgetEvent(e,t){const n=new CustomEvent(`widgetic:${e}`,{detail:t,bubbles:!0});document.dispatchEvent(n)}createLoadingElement(e){if(!e)return null;const t=document.createElement("div");return t.className="widgetic-loading",t.style.cssText="\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100px;\n background: #f8f9fa;\n border: 1px solid #e9ecef;\n border-radius: 4px;\n color: #6c757d;\n ",t.innerHTML='\n <div style="text-align: center;">\n <div style="\n width: 20px;\n height: 20px;\n border: 2px solid #f3f3f3;\n border-top: 2px solid #007bff;\n border-radius: 50%;\n animation: widgetic-spin 1s linear infinite;\n margin: 0 auto 8px;\n "></div>\n <div style="font-size: 14px;">Loading widget...</div>\n </div>\n ',this.addLoadingStyles(),t}removeLoadingElement(e){e&&e.parentNode&&e.parentNode.removeChild(e)}createErrorElement(e,t){const n=document.createElement("div");n.className="widgetic-error",n.style.cssText="\n display: flex;\n align-items: center;\n justify-content: center;\n min-height: 100px;\n padding: 20px;\n text-align: center;\n background: #fff5f5;\n border: 1px solid #fed7d7;\n border-radius: 4px;\n color: #742a2a;\n ";const i=t instanceof Error?t.message:"Unknown error occurred",o=this.analyzeError(i,t);return n.innerHTML=`\n <div>\n <div style="font-size: 24px; margin-bottom: 8px;">${o.icon}</div>\n <div style="font-weight: 500; margin-bottom: 8px;">${o.title}</div>\n <div style="font-size: 14px; margin-bottom: 12px; color: #666;">\n ${o.description}\n </div>\n <div style="font-size: 12px; margin-bottom: 16px; color: #888;">\n Widget ID: ${e}\n </div>\n ${o.actionHtml}\n </div>\n `,n}analyzeError(e,t){const n=e.toLowerCase();return n.includes("composition not found")||n.includes("404")?{icon:"🔍",title:"Widget Not Found",description:"This widget may have been removed or the ID is incorrect.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Not%20Found%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AThe%20widget%20could%20not%20be%20found.%20Please%20check%20if%20it%20was%20deleted%20or%20if%20the%20ID%20is%20correct.', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:n.includes("unauthorized")||n.includes("forbidden")||n.includes("401")||n.includes("403")||n.includes("permission")||n.includes("access denied")?{icon:"🔒",title:"Access Restricted",description:"This widget requires an active subscription or has been restricted.",actionHtml:`\n <div style="margin-bottom: 12px;">\n <a \n href="https://widgetic.com/pricing" \n target="_blank"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n ⭐ Upgrade Plan\n </a>\n </div>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Access%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AI%20am%20having%20trouble%20accessing%20this%20widget.%20Please%20check%20my%20account%20status%20and%20permissions.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:n.includes("deleted")||n.includes("expired")||n.includes("no longer available")?{icon:"🗑️",title:"Widget Deleted",description:"This widget has been permanently removed.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Deleted%20Widget%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AThis%20widget%20appears%20to%20have%20been%20deleted.%20Can%20you%20help%20me%20restore%20it%20or%20find%20an%20alternative?', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:n.includes("subscription")||n.includes("billing")||n.includes("payment")||n.includes("plan")||n.includes("downgrade")?{icon:"💳",title:"Subscription Required",description:"This widget requires an active subscription to display.",actionHtml:`\n <div style="margin-bottom: 12px;">\n <a \n href="https://widgetic.com/pricing" \n target="_blank"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n margin-right: 8px;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n ⭐ View Plans\n </a>\n <a \n href="https://widgetic.com/dashboard/billing" \n target="_blank"\n style="\n background: #6c757d;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#5a6268'"\n onmouseout="this.style.background='#6c757d'"\n >\n 💳 Billing\n </a>\n </div>\n <div style="font-size: 12px; color: #888; margin-top: 8px;">\n Need help? Contact support below\n </div>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Subscription%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AI%20need%20help%20with%20my%20subscription%20to%20access%20this%20widget.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 4px 8px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 11px;\n margin-top: 4px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:n.includes("timeout")||n.includes("network")||n.includes("connection")||n.includes("fetch")?{icon:"🌐",title:"Connection Issue",description:"Unable to load widget due to network connectivity.",actionHtml:`\n <button \n onclick="window.location.reload()"\n style="\n background: #28a745;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n margin-right: 8px;\n "\n onmouseover="this.style.background='#218838'"\n onmouseout="this.style.background='#28a745'"\n >\n 🔄 Retry\n </button>\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Connection%20Issue%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AError:%20${encodeURIComponent(e)}%0A%0AI%20am%20experiencing%20connection%20issues%20loading%20this%20widget.', '_blank')"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 📧 Contact Support\n </button>\n `}:{icon:"⚠️",title:"Widget Unavailable",description:e||"An unknown error occurred while loading this widget.",actionHtml:`\n <button \n onclick="window.open('mailto:support@widgetic.com?subject=Widget%20Error%20-%20${encodeURIComponent(t.compositionId||"Unknown")}&body=Widget%20ID:%20${encodeURIComponent(t.compositionId||"Unknown")}%0AError:%20${encodeURIComponent(e)}', '_blank')"\n style="\n background: #007bff;\n color: white;\n border: none;\n padding: 8px 16px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 14px;\n text-decoration: none;\n display: inline-block;\n "\n onmouseover="this.style.background='#0056b3'"\n onmouseout="this.style.background='#007bff'"\n >\n 📧 Contact Support\n </button>\n <div style="margin-top: 8px;">\n <button \n onclick="window.location.reload()"\n style="\n background: transparent;\n color: #007bff;\n border: 1px solid #007bff;\n padding: 6px 12px;\n border-radius: 4px;\n cursor: pointer;\n font-size: 12px;\n margin-left: 8px;\n "\n onmouseover="this.style.background='#007bff'; this.style.color='white'"\n onmouseout="this.style.background='transparent'; this.style.color='#007bff'"\n >\n 🔄 Refresh Page\n </button>\n </div>\n `}}addLoadingStyles(){const e="widgetic-loading-styles";if(document.getElementById(e))return;const t=document.createElement("style");t.id=e,t.textContent="\n @keyframes widgetic-spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n ",document.head.appendChild(t)}}let me=null;function pe(){return me||(me=new ge),me}function he(){me&&me.cleanupAll(),me=null}var fe=Object.freeze({__proto__:null,WidgetRenderer:ge,getWidgetRenderer:pe,resetWidgetRenderer:he});export{te as C,ce as I,Z as W,V as a,G as b,Y as c,se as d,X as e,ge as f,pe as g,he as h,ne as i,ue as j,K as r,b as s,fe as w};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as t}from"./core.js";import{M as e,f as i,h as r,i as n}from"./api.js";function a(e){const i=e.getAttribute("composition-id");if(!i)throw new Error("Missing required composition-id attribute");return{compositionId:i,renderMode:o(e.getAttribute("render-mode")),displayMode:s(e.getAttribute("display-mode")),resize:u(e.getAttribute("resize")),width:parseInt(e.getAttribute("width")||"")||t.width,height:parseInt(e.getAttribute("height")||"")||t.height,autoscale:S(e),adaptive:c(e.getAttribute("adaptive")),responsive:l(e.getAttribute("responsive")),device:L(e),fullscreen:d(e),triggers:j(e),overlay:g(e),popup:w(e),media:z(e),content:I(e)}}function o(t){switch(t){case"iframe":case"custom-element":return t;default:return"auto"}}function s(t){switch(t){case"overlay":case"popup":case"fullscreen":case"modal":return t;default:return"inline"}}function u(t){switch(t){case"fill-width":case"fill-height":case"fixed":case"fixed-height":case"fixed-width":case"allow-scale-down":case"fill":return t;default:return"fixed"}}function c(t){if(!t)return;const e=parseInt(t);return isNaN(e)?void 0:e}function l(t){if(!t)return;const e=parseInt(t);return isNaN(e)?void 0:e}function d(t){if("enabled"===t.getAttribute("fullscreen")||"true"===t.getAttribute("fullscreen-enabled"))return{enabled:!0,trigger:p(t.getAttribute("fullscreen-trigger")),showControls:"false"!==t.getAttribute("fullscreen-controls"),exitOnEscape:"false"!==t.getAttribute("fullscreen-exit-on-escape"),allowAutoEnter:"true"===t.getAttribute("fullscreen-auto-enter")}}function p(t){switch(t){case"click":case"double-click":case"hover":case"auto":case"manual":return t;default:return"click"}}function g(t){if("enabled"===t.getAttribute("overlay")||"true"===t.getAttribute("overlay-enabled"))return{enabled:!0,position:y(t.getAttribute("overlay-position")),backdrop:m(t),background:f(t,m(t)),closeOnBackdropClick:"false"!==t.getAttribute("overlay-close-on-backdrop"),closeOnEscape:"false"!==t.getAttribute("overlay-close-on-escape"),showCloseButton:"false"!==t.getAttribute("overlay-close-button"),trigger:h(t.getAttribute("overlay-trigger")),width:t.getAttribute("overlay-width")||void 0,height:t.getAttribute("overlay-height")||void 0,maxWidth:t.getAttribute("overlay-max-width")||void 0,maxHeight:t.getAttribute("overlay-max-height")||void 0,zIndex:parseInt(t.getAttribute("overlay-z-index")||"")||void 0,animation:v(t.getAttribute("overlay-animation")),overlayWidth:t.getAttribute("overlay-width")||void 0,overlayHeight:t.getAttribute("overlay-height")||void 0,overlayResize:A(t.getAttribute("overlay-resize-mode")),keepDimensions:"false"!==t.getAttribute("keep-dimensions"),embedTarget:t.getAttribute("embed-target")||void 0}}function b(t){return"true"===t.getAttribute("overlay-backdrop")}function m(t){return"false"!==t.getAttribute("overlay-backdrop")}function f(t,e){if(!e)return;const i=t.getAttribute("overlay-background-color")||void 0,r=t.getAttribute("overlay-background-opacity"),n=null===r?Number.NaN:Number(r);return{enabled:!0,color:i,opacity:Number.isFinite(n)?n:void 0}}function h(t){switch(t){case"click":case"hover":case"manual":case"auto":return t;default:return"click"}}function v(t){switch(t){case"fade":case"slide-up":case"slide-down":case"slide-left":case"slide-right":case"zoom":case"bounce":case"none":return t;case"scale":return"zoom";case"slide":return"slide-up";default:return"fade"}}function y(t){switch(t){case"top":case"bottom":case"left":case"right":case"top-left":case"top-right":case"bottom-left":case"bottom-right":return t;case"top-center":return"top";case"center-left":return"left";case"center-right":return"right";case"bottom-center":return"bottom";default:return"center"}}function A(t){switch(t){case"fillWidth":return"fill-width";case"fillHeight":return"fill-height";case"fixedSize":return"fixed";case"fixedHeight":return"fixed-height";case"fixedWidth":return"fixed-width";case"allowScaleDown":return"allow-scale-down";case"fill":return"fill";default:return}}function w(t){if("enabled"===t.getAttribute("popup")||"true"===t.getAttribute("popup-enabled"))return{enabled:!0,trigger:k(t.getAttribute("popup-trigger")),width:parseInt(t.getAttribute("popup-width")||"")||void 0,height:parseInt(t.getAttribute("popup-height")||"")||void 0,centerScreen:"false"!==t.getAttribute("popup-center"),allowResize:"true"===t.getAttribute("popup-resizable"),showToolbar:"true"===t.getAttribute("popup-toolbar"),target:t.getAttribute("popup-target")||void 0}}function k(t){switch(t){case"click":case"manual":return t;default:return"click"}}function S(t){const e=t.getAttribute("autoscale");return!!e&&(("true"===e||""===e||"false"!==e)&&(C(t)||!0))}function C(t){return t.getAttribute("autoscale-min-height")||t.getAttribute("autoscale-max-height")||t.getAttribute("autoscale-debounce")||t.getAttribute("autoscale-threshold")||t.getAttribute("autoscale-animate")||t.getAttribute("autoscale-animation-duration")?{enabled:!0,minHeight:parseInt(t.getAttribute("autoscale-min-height")||"")||void 0,maxHeight:parseInt(t.getAttribute("autoscale-max-height")||"")||void 0,debounceDelay:parseInt(t.getAttribute("autoscale-debounce")||"")||void 0,threshold:parseInt(t.getAttribute("autoscale-threshold")||"")||void 0,animate:"false"!==t.getAttribute("autoscale-animate"),animationDuration:parseInt(t.getAttribute("autoscale-animation-duration")||"")||void 0}:null}function O(t){return`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function x(t){return"widgetic"===t.tagName.toLowerCase()&&t.hasAttribute("composition-id")}function z(t){const e={},i=t.getAttribute("media-auto-pause")||t.getAttribute("data-media-auto-pause");null!==i&&(e.autoPause="true"===i||""===i);const r=t.getAttribute("media-type")||t.getAttribute("data-media-type");r&&["audio","video","both"].includes(r)&&(e.mediaType=r);const n=t.getAttribute("media-priority")||t.getAttribute("data-media-priority");if(n){const t=parseInt(n,10);!isNaN(t)&&t>=0&&t<=10&&(e.priority=t)}const a=t.getAttribute("media-persist-state")||t.getAttribute("data-media-persist-state");null!==a&&(e.persistState="true"===a||""===a);const o=t.getAttribute("media-allow-simultaneous")||t.getAttribute("data-media-allow-simultaneous");if(o){const t=o.split(",").map((t=>t.trim())).filter((t=>["audio","video"].includes(t)));t.length>0&&(e.allowSimultaneous=t)}const s=t.getAttribute("media-auto-resume")||t.getAttribute("data-media-auto-resume");null!==s&&(e.autoResume="true"===s||""===s);const u=t.getAttribute("media-auto-resume-timeout")||t.getAttribute("data-media-auto-resume-timeout");if(u){const t=parseInt(u,10);!isNaN(t)&&t>0&&(e.autoResumeTimeout=t)}const c=t.getAttribute("media-global-volume")||t.getAttribute("data-media-global-volume");return null!==c&&(e.globalVolume="true"===c||""===c),e}function I(t){const e={},i=t.getAttribute("content-type")||t.getAttribute("data-content-type");i&&["gallery","carousel","slider","stepper","tabs","list","custom"].includes(i)&&(e.contentType=i);const r=t.getAttribute("content-persist-state")||t.getAttribute("data-content-persist-state");null!==r&&(e.persistState="true"===r||""===r);const n=t.getAttribute("content-auto-resume")||t.getAttribute("data-content-auto-resume");null!==n&&(e.autoResume="true"===n||""===n);const a=t.getAttribute("content-auto-resume-timeout")||t.getAttribute("data-content-auto-resume-timeout");if(a){const t=parseInt(a,10);!isNaN(t)&&t>0&&(e.autoResumeTimeout=t)}const o=t.getAttribute("content-track-metadata")||t.getAttribute("data-content-track-metadata");return null!==o&&(e.trackMetadata="true"===o||""===o),Object.keys(e).length>0?e:void 0}function j(t){const e=t.getAttribute("embed-target");if("overlay"!==e&&"mixed"!==e)return;const i=function(t){switch(t){case"page-load":return"pageLoad";case"exit-intent":return"exitIntent";case"delay":return"delay";case"scroll":return"scroll";default:return}}(t.getAttribute("event-trigger")),r=parseInt(t.getAttribute("max-views")||""),n=parseInt(t.getAttribute("time-period")||""),a=Number.isFinite(r)&&r>0||Number.isFinite(n)&&n>0;return Object.assign(Object.assign(Object.assign({mode:e,eventTrigger:i},"overlay"===e&&"delay"===i?{delay:{enabled:!0,delayMs:N(t)}}:{}),"overlay"===e&&"scroll"===i?{scroll:{enabled:!0,threshold:.1,distance:T(t),direction:"down"}}:{}),{overlay:{position:t.getAttribute("overlay-position")||void 0,keepDimensions:"false"!==t.getAttribute("keep-dimensions"),zIndex:E(t),fullWidth:"true"===t.getAttribute("overlay-full-width")||void 0,overlayWidth:t.getAttribute("overlay-width")||void 0,overlayHeight:t.getAttribute("overlay-height")||void 0,overlayResize:A(t.getAttribute("overlay-resize-mode")),backdrop:b(t),background:f(t,b(t)),closeButton:!0},recurrence:a?{enabled:!0,maxViews:Number.isFinite(r)&&r>0?r:Number.MAX_SAFE_INTEGER,timePeriodHours:Number.isFinite(n)&&n>0?n:24}:void 0})}function E(t){const i=parseInt(t.getAttribute("overlay-z-index")||"");if(Number.isFinite(i)&&!(i<=0))return Math.min(i,e)}function N(t){const e=parseInt(t.getAttribute("trigger-delay")||"");return!Number.isFinite(e)||e<0?i:Math.min(e,r)}function T(t){const e=parseInt(t.getAttribute("trigger-scroll-distance")||"");return Number.isFinite(e)&&e>0?e:n}function L(t){const e=t.getAttribute("device-mobile-enabled")||t.getAttribute("data-device-mobile-enabled"),i=t.getAttribute("device-desktop-enabled")||t.getAttribute("data-device-desktop-enabled");if(e||i)return{mobileEnabled:"false"!==e,desktopEnabled:"false"!==i}}var q=Object.freeze({__proto__:null,generateInstanceId:O,isValidWidgetElement:x,parseTriggerConfig:j,parseWidgetConfig:a});const M=new Set(["id","class","style","title","lang","dir","hidden","tabindex","role","slot","part","draggable","contenteditable","spellcheck","translate","composition-id","compositionid","composition","widget","widget-id","widgetid","src","width","height","resize","resize-mode","render-mode","display-mode","autoscale","adaptive","responsive","theme","mode","colors","context","values","media-resolver","mediaresolver","sandbox","autoload","use-iframe","embed-target","event-trigger","trigger-delay","trigger-scroll-distance","overlay-position","overlay-full-width","overlay-backdrop","max-views","time-period","device-mobile-enabled","device-desktop-enabled","display-on-mobile","display-on-desktop","use-breakpoints","mobile-breakpoint","tablet-breakpoint","desktop-breakpoint","design","content","items","content-items","contentitems"]),R={backgroundcolor:"backgroundColor",textcolor:"textColor",primarycolor:"primaryColor",secondarycolor:"secondaryColor",accentcolor:"accentColor",bordercolor:"borderColor",borderradius:"borderRadius",borderwidth:"borderWidth",fontsize:"fontSize",fontfamily:"fontFamily",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing"},W=new WeakMap;function F(t){const e=t.trim().replace(/^data-/,"").replace(/-([a-zA-Z0-9])/g,((t,e)=>e.toUpperCase())),i=e.toLowerCase();return e===i&&R[i]?R[i]:e}function P(t){var e,i,r,n,a,o,s,u;const c=(null===(e=t.getAttribute("composition-id"))||void 0===e?void 0:e.trim())||(null===(i=t.getAttribute("compositionid"))||void 0===i?void 0:i.trim())||(null===(r=t.getAttribute("data-composition-id"))||void 0===r?void 0:r.trim())||(null===(n=t.getAttribute("composition"))||void 0===n?void 0:n.trim());if(c)return{kind:"composition",id:c};const l=(null===(a=t.getAttribute("widget"))||void 0===a?void 0:a.trim())||(null===(o=t.getAttribute("widget-id"))||void 0===o?void 0:o.trim())||(null===(s=t.getAttribute("widgetid"))||void 0===s?void 0:s.trim())||(null===(u=t.getAttribute("data-widget-id"))||void 0===u?void 0:u.trim());return l?{kind:"widget",id:l}:null}const _=new WeakSet;function H(t){if(!t||_.has(t))return;_.add(t);const e=[{prop:"values",attr:"values"},{prop:"context",attr:"context"},{prop:"design",attr:"design"},{prop:"content",attr:"content"},{prop:"contentItems",attr:"content-items"}];for(const{prop:i,attr:r}of e){const e=Object.prototype.hasOwnProperty.call(t,i),n=e?t[i]:void 0;e&&delete t[i];const a=e=>{if(null==e||""===e)t.removeAttribute(r);else if("string"==typeof e)t.getAttribute(r)!==e&&t.setAttribute(r,e);else if("object"==typeof e)try{const i=JSON.stringify(e);t.getAttribute(r)!==i&&t.setAttribute(r,i)}catch(t){}};try{Object.defineProperty(t,i,{configurable:!0,enumerable:!1,get:()=>t.getAttribute(r),set(t){a(t)}}),e&&void 0!==n&&a(n)}catch(t){}}const i=[{prop:"mediaResolver",attr:"media-resolver"},{prop:"compositionId",attr:"composition-id"},{prop:"widgetId",attr:"widget-id"}];for(const{prop:e,attr:r}of i){const i=Object.prototype.hasOwnProperty.call(t,e),n=i?t[e]:void 0;i&&delete t[e];const a=e=>{if(null==e||""===e)t.removeAttribute(r);else{const i=String(e);t.getAttribute(r)!==i&&t.setAttribute(r,i)}};try{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get:()=>t.getAttribute(r),set(t){a(t)}}),i&&void 0!==n&&a(n)}catch(t){}}}function B(t){const e=P(t);return e?e.id:null}function D(t){const e=t.tagName.toUpperCase();return"IFRAME"===e||"SCRIPT"===e||"STYLE"===e||"TEMPLATE"===e||!!(t.hasAttribute("data-widgetic-direct")||t.hasAttribute("data-widgetic-internal")||t.classList.contains("widgetic-direct-target"))}function J(t){const e=t.toLowerCase();return!!M.has(e)||(!!e.startsWith("data-widgetic-")||(!!e.startsWith("aria-")||!!e.startsWith("on")))}function V(t){const e=t.trim();if("true"===e)return!0;if("false"===e)return!1;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(e){return t}return t}function $(t){if(!t||!t.trim())return null;try{const e=JSON.parse(t);if(e&&"object"==typeof e&&!Array.isArray(e))return e}catch(t){}return null}function G(t){if(!t||!t.trim())return null;try{const e=JSON.parse(t);if(Array.isArray(e))return e.filter((t=>Boolean(t&&"object"==typeof t&&!Array.isArray(t)))).map(((t,e)=>Object.assign(Object.assign({id:"string"==typeof t.id&&t.id.trim()?t.id:`item-${e+1}`,order:e+1},t),{metadata:Object.assign({service:"declarative"},t)})))}catch(t){}return null}function U(t){var e;const i=Array.from(t.children).filter((t=>!D(t)));if(0===i.length)return null!==(e=W.get(t))&&void 0!==e?e:[];const r=i.map(((t,e)=>{var i;t.hasAttribute("data-widgetic-item")||(t.setAttribute("data-widgetic-item","1"),t instanceof HTMLElement&&(t.hidden=!0,t.style.display="none"));const r={};for(const e of Array.from(t.attributes)){const t=e.name.toLowerCase();if("data-widgetic-item"===t||"hidden"===t)continue;if("style"===t&&"display:none;"===e.value.replace(/\s+/g,""))continue;const i=F(e.name);i&&!(i in Object.prototype)&&(r[i]=V(e.value))}if(0===t.children.length){const e=null===(i=t.textContent)||void 0===i?void 0:i.trim();e&&(void 0===r.content&&(r.content=e),void 0===r.text&&(r.text=e))}const n="string"==typeof r.id&&r.id.trim()?r.id:`item-${e+1}`;return Object.assign(Object.assign({id:n,order:e+1},r),{metadata:Object.assign({service:"declarative"},r)})}));return W.set(t,r),r}function X(t,e){if(!t)return null;if(e in t)return e;const i=e.toLowerCase();for(const e of Object.keys(t))if(e.toLowerCase()===i)return e;return null}function Y(t,e){const i={},r={},n=$(t.getAttribute("design"));if(n)for(const[t,e]of Object.entries(n))t in Object.prototype||null==e||(i[t]="string"==typeof e?e:JSON.stringify(e));const a=$(t.getAttribute("content"));if(a)for(const[t,e]of Object.entries(a))t in Object.prototype||void 0===e||(r[t]=e);const o=$(t.getAttribute("values"));if(o)for(const[t,e]of Object.entries(o))t in Object.prototype||void 0===e||(r[t]=e);for(const n of Array.from(t.attributes)){const t=n.name,a=t.toLowerCase();if(a.startsWith("design-")&&a.length>7){const r=F(t.slice(7));if(r&&!(r in Object.prototype)){i[X(null==e?void 0:e.design,r)||r]=n.value}continue}if(a.startsWith("content-")&&"content-items"!==a&&a.length>8){const i=F(t.slice(8));if(i&&!(i in Object.prototype)){r[X(null==e?void 0:e.content,i)||i]=V(n.value)}continue}if(J(t))continue;const o=F(t);if(!o||o in Object.prototype)continue;const s=X(null==e?void 0:e.content,o),u=X(null==e?void 0:e.design,o);if(s&&!u)r[s]=V(n.value);else if(u&&!s)i[u]=n.value;else{i[o]=n.value,r[o]=V(n.value);const e=t.replace(/^data-/,"");e===o||e in Object.prototype||(i[e]=n.value)}}let s=U(t);if(0===s.length){const e=G(t.getAttribute("content-items"))||G(t.getAttribute("contentitems"))||G(t.getAttribute("items"));e&&e.length>0&&(s=e)}return{design:i,content:r,contentItems:s,hasOverrides:Object.keys(i).length>0||Object.keys(r).length>0||s.length>0}}function Z(t,e){const i=null!=e?e:{},r=Y(t,i);return r.hasOverrides?Object.assign(Object.assign({},i),{design:Object.assign(Object.assign({},i.design||{}),r.design),content:Object.assign(Object.assign({},i.content||{}),r.content),contentItems:r.contentItems.length>0?r.contentItems:i.contentItems||[]}):i}function K(t){var e,i;if(0===t.length)return!0;for(const r of t){if("attributes"===r.type){const t=(null===(e=r.attributeName)||void 0===e?void 0:e.toLowerCase())||"";if(!t)continue;if("data-widgetic-mounted"===t||"data-widgetic-mounting"===t||"data-widgetic-refused"===t||"data-widgetic-context-invalid"===t||"data-widgetic-overlay"===t||"data-device-restricted"===t||"data-widgetic-item"===t||"hidden"===t)continue;if("style"===t&&r.target!==(null===(i=r.target.ownerDocument)||void 0===i?void 0:i.body)&&r.target instanceof Element&&r.target.hasAttribute("data-widgetic-item"))continue;if(r.target instanceof Element&&D(r.target))continue;return!0}if("childList"===r.type){if([...Array.from(r.addedNodes),...Array.from(r.removedNodes)].some((t=>!(t instanceof Element&&D(t)))))return!0}if("characterData"===r.type){const t=r.target.parentElement;if(t&&!D(t))return!0}}return!1}const Q=new WeakMap;function tt(t,e,i){const r=Q.get(t);r&&r();const n="undefined"!=typeof MutationObserver?MutationObserver:null;if(!n)return()=>{};let a,o=!1;try{a=new n((r=>{K(r)&&(o||(o=!0,queueMicrotask((()=>{o=!1;const r=Y(t,e);i(r)}))))}))}catch(t){return()=>{}}a.observe(t,{attributes:!0,childList:!0,subtree:!0,characterData:!0});const s=()=>{a.disconnect(),Q.delete(t)};return Q.set(t,s),s}function et(t){const e=Q.get(t);e&&e()}function it(){return"undefined"==typeof window?{customElements:!1,http3:!1,resizeObserver:!1,fullscreenApi:!1,popupBlocking:!1}:{customElements:"undefined"!=typeof customElements&&"function"==typeof customElements.define,http3:rt(),resizeObserver:"undefined"!=typeof ResizeObserver,fullscreenApi:nt(),popupBlocking:at()}}function rt(){if("undefined"==typeof performance||!performance.getEntriesByType)return!1;try{const t=performance.getEntriesByType("navigation");if(t.length>0){const e=t[0];return"h3"===e.nextHopProtocol||"h3-29"===e.nextHopProtocol}return!1}catch(t){return!1}}function nt(){return!("undefined"==typeof document||!document.documentElement)&&!!(document.documentElement.requestFullscreen||document.documentElement.webkitRequestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.msRequestFullscreen)}function at(){if("undefined"==typeof window||!window.open)return!1;try{const t=window.open("","widgetic-popup-test","width=1,height=1");return!t||(t.close(),!1)}catch(t){return!0}}function ot(t,e){switch(t){case"custom-element":case"auto":default:return e.customElements?"custom-element":"iframe";case"iframe":return"iframe"}}function st(){if("undefined"==typeof localStorage)return!1;try{const t="widgetic-test";return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch(t){return!1}}var ut=Object.freeze({__proto__:null,checkSdkInitialization:function(){if("undefined"==typeof window)return!1;const t="widgetic-sdk-initialized";return st()?!!localStorage.getItem(t)||(localStorage.setItem(t,Date.now().toString()),!1):!!window.__widgeticInitialized},clearSdkInitialization:function(){st()&&localStorage.removeItem("widgetic-sdk-initialized"),delete window.__widgeticInitialized},detectBrowserCapabilities:it,determineBestRenderMode:ot,hasIntersectionObserver:function(){return"undefined"!=typeof IntersectionObserver},isLocalStorageAvailable:st});class ct{static analyzeElement(t){try{const e=this.getExplicitMetadata(t);return e||this.analyzeHeuristically(t)}catch(t){return null}}static getExplicitMetadata(t){const e=t.getAttribute("data-widget-meta");if(e)try{return JSON.parse(e)}catch(t){}const i=t.getAttribute("data-capabilities");if(i)return this.parseCapabilitiesString(i);const r=t.querySelector('script[type="application/json"]');if(r&&r.textContent)try{const t=JSON.parse(r.textContent);return t.capabilities||t.metadata}catch(t){}return null}static analyzeHeuristically(t){const e={type:"custom",version:"1.0.0"},i=t.getAttribute("data-widget-type")||t.getAttribute("data-type")||this.inferTypeFromStructure(t);switch(i&&(e.type=i),e.type){case"media":e.mediaCapabilities=this.analyzeMediaCapabilities(t);break;case"gallery":e.contentCapabilities=this.analyzeContentCapabilities(t);break;case"form":e.textCapabilities=this.analyzeTextCapabilities(t);break;case"interactive":e.interactionCapabilities=this.analyzeInteractionCapabilities(t)}return e.supportsResponsive=this.checkResponsiveSupport(t),e.supportsAutoscale=this.checkAutoscaleSupport(t),e.supportsThemes=this.checkThemeSupport(t),e.displayCapabilities=this.analyzeDisplayCapabilities(t),e.abTestingCapabilities=this.analyzeABTestingCapabilities(t),e}static inferTypeFromStructure(t){var e;return t.querySelector("video, audio")||t.classList.contains("media-widget")||(null===(e=t.getAttribute("data-widget-id"))||void 0===e?void 0:e.includes("video"))?"media":t.querySelector("form, input, textarea")||t.classList.contains("form-widget")?"form":t.querySelector(".gallery, .carousel")||t.classList.contains("gallery-widget")||t.querySelectorAll("img").length>1?"gallery":t.querySelector("button, .interactive")||t.classList.contains("quiz-widget")||t.classList.contains("poll-widget")?"interactive":"custom"}static analyzeMediaCapabilities(t){const e=t.querySelectorAll("video"),i=t.querySelectorAll("audio"),r=null!==t.querySelector("[controls]"),n=null!==t.querySelector("[data-volume], .volume-control");let a="audio";return e.length>0&&i.length>0?a="mixed":e.length>0&&(a="video"),{supportsPlay:!0,supportsPause:!0,supportsVolumeControl:n||r,supportsSeek:r,supportsGlobalVolume:t.hasAttribute("data-global-volume"),mediaType:a}}static analyzeContentCapabilities(t){const e=t.querySelectorAll(".item, .slide, img, .content-item"),i=null!==t.querySelector(".nav, .navigation, button"),r=t.hasAttribute("data-position")||t.hasAttribute("data-track-position");let n="gallery";return t.classList.contains("carousel")&&(n="carousel"),t.classList.contains("list")&&(n="list"),t.classList.contains("grid")&&(n="grid"),{supportsPositionTracking:r,supportsNavigation:i,contentType:n,totalItems:e.length}}static analyzeTextCapabilities(t){const e=t.querySelectorAll("input, textarea, select"),i=Array.from(e).map((t=>t.getAttribute("name")||t.getAttribute("id")||"unknown"));return{supportsTextPersistence:t.hasAttribute("data-persist")||t.hasAttribute("data-autosave"),supportsSanitization:!0,fields:i}}static analyzeInteractionCapabilities(t){const e=t.querySelectorAll("button").length>0,i=t.querySelectorAll("form").length>0,r=t.hasAttribute("data-events")||t.hasAttribute("data-track-interactions"),n=[],a=t.getAttribute("data-events");return a&&n.push(...a.split(",").map((t=>t.trim()))),{supportsClicks:e||null!==t.querySelector("[onclick]"),supportsFormSubmission:i,supportsCustomEvents:r,customEventTypes:n.length>0?n:void 0}}static analyzeDisplayCapabilities(t){return{supportsFullscreen:t.hasAttribute("data-fullscreen")||t.classList.contains("fullscreen-capable"),supportsOverlay:t.hasAttribute("data-overlay")||t.classList.contains("overlay-capable"),supportsPopup:t.hasAttribute("data-popup")||t.classList.contains("popup-capable"),supportsInline:!0}}static analyzeABTestingCapabilities(t){if(!("widgetic-abtest"===t.tagName.toLowerCase()||t.hasAttribute("experiment-id")||t.hasAttribute("data-ab-test")))return;const e=[],i=[];return t.querySelector("button, a, [onclick]")&&(e.push("clicks"),i.push("clicks")),t.querySelector("form")&&(e.push("submissions"),i.push("conversions")),t.querySelector("video, audio")&&(e.push("plays"),i.push("plays")),e.push("impressions"),{supportsTracking:!0,trackableEvents:e,conversionGoals:i}}static checkResponsiveSupport(t){return t.hasAttribute("data-responsive")||t.hasAttribute("data-breakpoints")||t.classList.contains("responsive")}static checkAutoscaleSupport(t){return t.hasAttribute("data-autoscale")||t.hasAttribute("data-auto-height")||t.classList.contains("autoscale")}static checkThemeSupport(t){return t.hasAttribute("data-theme")||t.classList.contains("themeable")||null!==t.querySelector("[data-theme]")}static parseCapabilitiesString(t){const e=t.split(",").map((t=>t.trim()));return{type:"custom",version:"1.0.0",mediaCapabilities:e.includes("media")?{supportsPlay:!0,supportsPause:!0,supportsVolumeControl:e.includes("volume"),supportsSeek:e.includes("seek"),supportsGlobalVolume:e.includes("global-volume"),mediaType:"mixed"}:void 0,textCapabilities:e.includes("forms")?{supportsTextPersistence:e.includes("persist"),supportsSanitization:!0,fields:[]}:void 0,interactionCapabilities:e.includes("interactive")?{supportsClicks:!0,supportsFormSubmission:e.includes("forms"),supportsCustomEvents:e.includes("events")}:void 0,supportsResponsive:e.includes("responsive"),supportsAutoscale:e.includes("autoscale"),supportsThemes:e.includes("themes")}}}function lt(t){var e,i,r,n;const a=new Set;return a.add("rendering"),a.add("api"),t.mediaCapabilities&&a.add("media"),t.textCapabilities&&a.add("security"),t.interactionCapabilities&&a.add("messaging"),((null===(e=t.displayCapabilities)||void 0===e?void 0:e.supportsFullscreen)||(null===(i=t.displayCapabilities)||void 0===i?void 0:i.supportsOverlay)||(null===(r=t.displayCapabilities)||void 0===r?void 0:r.supportsPopup))&&a.add("display"),t.abTestingCapabilities&&(a.add("abTesting"),a.add("messaging")),(null===(n=t.performanceRequirements)||void 0===n?void 0:n.requiresLazyLoading)&&a.add("performance"),Array.from(a)}var dt=Object.freeze({__proto__:null,WidgetMetadataAnalyzer:ct,analyzeWidgetRequirementsEnhanced:function(t){const e=new Set;for(const i of t){const t=ct.analyzeElement(i);if(t){lt(t).forEach((t=>e.add(t)))}}return Array.from(e)},getRequiredChunks:lt});export{Y as a,P as b,U as c,it as d,x as e,ot as f,B as g,K as h,H as i,O as j,st as k,q as l,Z as m,ut as n,tt as o,a as p,et as s,dt as w};
|
|
1
|
+
import{D as t}from"./core.js";const e=3e3,i=99999999,r=2147483647;function n(e){const i=e.getAttribute("composition-id");if(!i)throw new Error("Missing required composition-id attribute");return{compositionId:i,renderMode:o(e.getAttribute("render-mode")),displayMode:a(e.getAttribute("display-mode")),resize:s(e.getAttribute("resize")),width:parseInt(e.getAttribute("width")||"")||t.width,height:parseInt(e.getAttribute("height")||"")||t.height,autoscale:S(e),adaptive:c(e.getAttribute("adaptive")),responsive:u(e.getAttribute("responsive")),device:T(e),fullscreen:l(e),triggers:x(e),overlay:p(e),popup:A(e),media:j(e),content:I(e)}}function o(t){switch(t){case"iframe":case"custom-element":return t;default:return"auto"}}function a(t){switch(t){case"overlay":case"popup":case"fullscreen":case"modal":return t;default:return"inline"}}function s(t){switch(t){case"fill-width":case"fill-height":case"fixed":case"fixed-height":case"fixed-width":case"allow-scale-down":case"fill":return t;default:return"fixed"}}function c(t){if(!t)return;const e=parseInt(t);return isNaN(e)?void 0:e}function u(t){if(!t)return;const e=parseInt(t);return isNaN(e)?void 0:e}function l(t){if("enabled"===t.getAttribute("fullscreen")||"true"===t.getAttribute("fullscreen-enabled"))return{enabled:!0,trigger:d(t.getAttribute("fullscreen-trigger")),showControls:"false"!==t.getAttribute("fullscreen-controls"),exitOnEscape:"false"!==t.getAttribute("fullscreen-exit-on-escape"),allowAutoEnter:"true"===t.getAttribute("fullscreen-auto-enter")}}function d(t){switch(t){case"click":case"double-click":case"hover":case"auto":case"manual":return t;default:return"click"}}function p(t){if("enabled"===t.getAttribute("overlay")||"true"===t.getAttribute("overlay-enabled"))return{enabled:!0,position:h(t.getAttribute("overlay-position")),backdrop:b(t),background:f(t,b(t)),closeOnBackdropClick:"false"!==t.getAttribute("overlay-close-on-backdrop"),closeOnEscape:"false"!==t.getAttribute("overlay-close-on-escape"),showCloseButton:"false"!==t.getAttribute("overlay-close-button"),trigger:m(t.getAttribute("overlay-trigger")),width:t.getAttribute("overlay-width")||void 0,height:t.getAttribute("overlay-height")||void 0,maxWidth:t.getAttribute("overlay-max-width")||void 0,maxHeight:t.getAttribute("overlay-max-height")||void 0,zIndex:parseInt(t.getAttribute("overlay-z-index")||"")||void 0,animation:y(t.getAttribute("overlay-animation")),overlayWidth:t.getAttribute("overlay-width")||void 0,overlayHeight:t.getAttribute("overlay-height")||void 0,overlayResize:v(t.getAttribute("overlay-resize-mode")),keepDimensions:"false"!==t.getAttribute("keep-dimensions"),embedTarget:t.getAttribute("embed-target")||void 0}}function g(t){return"true"===t.getAttribute("overlay-backdrop")}function b(t){return"false"!==t.getAttribute("overlay-backdrop")}function f(t,e){if(!e)return;const i=t.getAttribute("overlay-background-color")||void 0,r=t.getAttribute("overlay-background-opacity"),n=null===r?Number.NaN:Number(r);return{enabled:!0,color:i,opacity:Number.isFinite(n)?n:void 0}}function m(t){switch(t){case"click":case"hover":case"manual":case"auto":return t;default:return"click"}}function y(t){switch(t){case"fade":case"slide-up":case"slide-down":case"slide-left":case"slide-right":case"zoom":case"bounce":case"none":return t;case"scale":return"zoom";case"slide":return"slide-up";default:return"fade"}}function h(t){switch(t){case"top":case"bottom":case"left":case"right":case"top-left":case"top-right":case"bottom-left":case"bottom-right":return t;case"top-center":return"top";case"center-left":return"left";case"center-right":return"right";case"bottom-center":return"bottom";default:return"center"}}function v(t){switch(t){case"fillWidth":return"fill-width";case"fillHeight":return"fill-height";case"fixedSize":return"fixed";case"fixedHeight":return"fixed-height";case"fixedWidth":return"fixed-width";case"allowScaleDown":return"allow-scale-down";case"fill":return"fill";default:return}}function A(t){if("enabled"===t.getAttribute("popup")||"true"===t.getAttribute("popup-enabled"))return{enabled:!0,trigger:w(t.getAttribute("popup-trigger")),width:parseInt(t.getAttribute("popup-width")||"")||void 0,height:parseInt(t.getAttribute("popup-height")||"")||void 0,centerScreen:"false"!==t.getAttribute("popup-center"),allowResize:"true"===t.getAttribute("popup-resizable"),showToolbar:"true"===t.getAttribute("popup-toolbar"),target:t.getAttribute("popup-target")||void 0}}function w(t){switch(t){case"click":case"manual":return t;default:return"click"}}function S(t){const e=t.getAttribute("autoscale");return!!e&&(("true"===e||""===e||"false"!==e)&&(k(t)||!0))}function k(t){return t.getAttribute("autoscale-min-height")||t.getAttribute("autoscale-max-height")||t.getAttribute("autoscale-debounce")||t.getAttribute("autoscale-threshold")||t.getAttribute("autoscale-animate")||t.getAttribute("autoscale-animation-duration")?{enabled:!0,minHeight:parseInt(t.getAttribute("autoscale-min-height")||"")||void 0,maxHeight:parseInt(t.getAttribute("autoscale-max-height")||"")||void 0,debounceDelay:parseInt(t.getAttribute("autoscale-debounce")||"")||void 0,threshold:parseInt(t.getAttribute("autoscale-threshold")||"")||void 0,animate:"false"!==t.getAttribute("autoscale-animate"),animationDuration:parseInt(t.getAttribute("autoscale-animation-duration")||"")||void 0}:null}function C(t){return`${t}-${Date.now()}-${Math.random().toString(36).substr(2,9)}`}function O(t){return"widgetic"===t.tagName.toLowerCase()&&t.hasAttribute("composition-id")}function j(t){const e={},i=t.getAttribute("media-auto-pause")||t.getAttribute("data-media-auto-pause");null!==i&&(e.autoPause="true"===i||""===i);const r=t.getAttribute("media-type")||t.getAttribute("data-media-type");r&&["audio","video","both"].includes(r)&&(e.mediaType=r);const n=t.getAttribute("media-priority")||t.getAttribute("data-media-priority");if(n){const t=parseInt(n,10);!isNaN(t)&&t>=0&&t<=10&&(e.priority=t)}const o=t.getAttribute("media-persist-state")||t.getAttribute("data-media-persist-state");null!==o&&(e.persistState="true"===o||""===o);const a=t.getAttribute("media-allow-simultaneous")||t.getAttribute("data-media-allow-simultaneous");if(a){const t=a.split(",").map((t=>t.trim())).filter((t=>["audio","video"].includes(t)));t.length>0&&(e.allowSimultaneous=t)}const s=t.getAttribute("media-auto-resume")||t.getAttribute("data-media-auto-resume");null!==s&&(e.autoResume="true"===s||""===s);const c=t.getAttribute("media-auto-resume-timeout")||t.getAttribute("data-media-auto-resume-timeout");if(c){const t=parseInt(c,10);!isNaN(t)&&t>0&&(e.autoResumeTimeout=t)}const u=t.getAttribute("media-global-volume")||t.getAttribute("data-media-global-volume");return null!==u&&(e.globalVolume="true"===u||""===u),e}function I(t){const e={},i=t.getAttribute("content-type")||t.getAttribute("data-content-type");i&&["gallery","carousel","slider","stepper","tabs","list","custom"].includes(i)&&(e.contentType=i);const r=t.getAttribute("content-persist-state")||t.getAttribute("data-content-persist-state");null!==r&&(e.persistState="true"===r||""===r);const n=t.getAttribute("content-auto-resume")||t.getAttribute("data-content-auto-resume");null!==n&&(e.autoResume="true"===n||""===n);const o=t.getAttribute("content-auto-resume-timeout")||t.getAttribute("data-content-auto-resume-timeout");if(o){const t=parseInt(o,10);!isNaN(t)&&t>0&&(e.autoResumeTimeout=t)}const a=t.getAttribute("content-track-metadata")||t.getAttribute("data-content-track-metadata");return null!==a&&(e.trackMetadata="true"===a||""===a),Object.keys(e).length>0?e:void 0}function x(t){const e=t.getAttribute("embed-target");if("overlay"!==e&&"mixed"!==e)return;const i=function(t){switch(t){case"page-load":return"pageLoad";case"exit-intent":return"exitIntent";case"delay":return"delay";case"scroll":return"scroll";default:return}}(t.getAttribute("event-trigger")),r=parseInt(t.getAttribute("max-views")||""),n=parseInt(t.getAttribute("time-period")||""),o=Number.isFinite(r)&&r>0||Number.isFinite(n)&&n>0;return Object.assign(Object.assign(Object.assign({mode:e,eventTrigger:i},"overlay"===e&&"delay"===i?{delay:{enabled:!0,delayMs:E(t)}}:{}),"overlay"===e&&"scroll"===i?{scroll:{enabled:!0,threshold:.1,distance:N(t),direction:"down"}}:{}),{overlay:{position:t.getAttribute("overlay-position")||void 0,keepDimensions:"false"!==t.getAttribute("keep-dimensions"),zIndex:z(t),fullWidth:"true"===t.getAttribute("overlay-full-width")||void 0,overlayWidth:t.getAttribute("overlay-width")||void 0,overlayHeight:t.getAttribute("overlay-height")||void 0,overlayResize:v(t.getAttribute("overlay-resize-mode")),backdrop:g(t),background:f(t,g(t)),closeButton:!0},recurrence:o?{enabled:!0,maxViews:Number.isFinite(r)&&r>0?r:Number.MAX_SAFE_INTEGER,timePeriodHours:Number.isFinite(n)&&n>0?n:24}:void 0})}function z(t){const e=parseInt(t.getAttribute("overlay-z-index")||"");if(Number.isFinite(e)&&!(e<=0))return Math.min(e,r)}function E(t){const e=parseInt(t.getAttribute("trigger-delay")||"");return!Number.isFinite(e)||e<0?3e3:Math.min(e,864e5)}function N(t){const e=parseInt(t.getAttribute("trigger-scroll-distance")||"");return Number.isFinite(e)&&e>0?e:100}function T(t){const e=t.getAttribute("device-mobile-enabled")||t.getAttribute("data-device-mobile-enabled"),i=t.getAttribute("device-desktop-enabled")||t.getAttribute("data-device-desktop-enabled");if(e||i)return{mobileEnabled:"false"!==e,desktopEnabled:"false"!==i}}var L=Object.freeze({__proto__:null,generateInstanceId:C,isValidWidgetElement:O,parseTriggerConfig:x,parseWidgetConfig:n});const q=new Set(["id","class","style","title","lang","dir","hidden","tabindex","role","slot","part","draggable","contenteditable","spellcheck","translate","composition-id","compositionid","composition","widget","widget-id","widgetid","src","width","height","resize","resize-mode","render-mode","display-mode","autoscale","adaptive","responsive","theme","mode","colors","context","values","media-resolver","mediaresolver","sandbox","autoload","use-iframe","embed-target","event-trigger","trigger-delay","trigger-scroll-distance","overlay-position","overlay-full-width","overlay-backdrop","max-views","time-period","device-mobile-enabled","device-desktop-enabled","display-on-mobile","display-on-desktop","use-breakpoints","mobile-breakpoint","tablet-breakpoint","desktop-breakpoint","design","content","items","content-items","contentitems"]),R={backgroundcolor:"backgroundColor",textcolor:"textColor",primarycolor:"primaryColor",secondarycolor:"secondaryColor",accentcolor:"accentColor",bordercolor:"borderColor",borderradius:"borderRadius",borderwidth:"borderWidth",fontsize:"fontSize",fontfamily:"fontFamily",fontweight:"fontWeight",lineheight:"lineHeight",letterspacing:"letterSpacing"},M=new WeakMap;function W(t){const e=t.trim().replace(/^data-/,"").replace(/-([a-zA-Z0-9])/g,((t,e)=>e.toUpperCase())),i=e.toLowerCase();return e===i&&R[i]?R[i]:e}function F(t){var e,i,r,n,o,a,s,c;const u=(null===(e=t.getAttribute("composition-id"))||void 0===e?void 0:e.trim())||(null===(i=t.getAttribute("compositionid"))||void 0===i?void 0:i.trim())||(null===(r=t.getAttribute("data-composition-id"))||void 0===r?void 0:r.trim())||(null===(n=t.getAttribute("composition"))||void 0===n?void 0:n.trim());if(u)return{kind:"composition",id:u};const l=(null===(o=t.getAttribute("widget"))||void 0===o?void 0:o.trim())||(null===(a=t.getAttribute("widget-id"))||void 0===a?void 0:a.trim())||(null===(s=t.getAttribute("widgetid"))||void 0===s?void 0:s.trim())||(null===(c=t.getAttribute("data-widget-id"))||void 0===c?void 0:c.trim());return l?{kind:"widget",id:l}:null}const P=new WeakSet;function _(t){if(!t||P.has(t))return;P.add(t);const e=[{prop:"values",attr:"values"},{prop:"context",attr:"context"},{prop:"design",attr:"design"},{prop:"content",attr:"content"},{prop:"contentItems",attr:"content-items"}];for(const{prop:i,attr:r}of e){const e=Object.prototype.hasOwnProperty.call(t,i),n=e?t[i]:void 0;e&&delete t[i];const o=e=>{if(null==e||""===e)t.removeAttribute(r);else if("string"==typeof e)t.getAttribute(r)!==e&&t.setAttribute(r,e);else if("object"==typeof e)try{const i=JSON.stringify(e);t.getAttribute(r)!==i&&t.setAttribute(r,i)}catch(t){}};try{Object.defineProperty(t,i,{configurable:!0,enumerable:!1,get:()=>t.getAttribute(r),set(t){o(t)}}),e&&void 0!==n&&o(n)}catch(t){}}const i=[{prop:"mediaResolver",attr:"media-resolver"},{prop:"compositionId",attr:"composition-id"},{prop:"widgetId",attr:"widget-id"}];for(const{prop:e,attr:r}of i){const i=Object.prototype.hasOwnProperty.call(t,e),n=i?t[e]:void 0;i&&delete t[e];const o=e=>{if(null==e||""===e)t.removeAttribute(r);else{const i=String(e);t.getAttribute(r)!==i&&t.setAttribute(r,i)}};try{Object.defineProperty(t,e,{configurable:!0,enumerable:!1,get:()=>t.getAttribute(r),set(t){o(t)}}),i&&void 0!==n&&o(n)}catch(t){}}}function D(t){const e=F(t);return e?e.id:null}function G(t){if("SCRIPT"!==t.tagName.toUpperCase())return!1;const e=(t.getAttribute("type")||"").trim().toLowerCase();return"application/json"===e||"application/ld+json"===e||"application/widgetic+json"===e||(t.hasAttribute("data-widgetic-json")||t.hasAttribute("data-widgetic-config"))}function H(t){const e=t.tagName.toUpperCase();return"SCRIPT"===e?!G(t):"IFRAME"===e||"STYLE"===e||"TEMPLATE"===e||!!(t.hasAttribute("data-widgetic-direct")||t.hasAttribute("data-widgetic-internal")||t.classList.contains("widgetic-direct-target"))}function B(t){const e=t.toLowerCase();return!!q.has(e)||(!!e.startsWith("data-widgetic-")||(!!e.startsWith("aria-")||!!e.startsWith("on")))}function V(t){const e=t.trim();if("true"===e)return!0;if("false"===e)return!1;if(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch(e){return t}return t}function J(t){if(!t||!t.trim())return null;try{const e=JSON.parse(t);if(e&&"object"==typeof e&&!Array.isArray(e))return e}catch(t){}return null}function $(t){return t.filter((t=>Boolean(t&&"object"==typeof t&&!Array.isArray(t)))).map(((t,e)=>function(t,e){const i={};for(const[e,r]of Object.entries(t))"properties"===e||"inputController"===e||e in Object.prototype||(i[e]=r);if(Array.isArray(t.properties))for(const e of t.properties){if(!e||"object"!=typeof e||Array.isArray(e))continue;const t=e,r="string"==typeof t.name?t.name.trim():"";if(!r||r in Object.prototype)continue;const n=void 0!==t.value&&null!==t.value?t.value:t.defaultValue;void 0!==n&&(i[r]=n)}const r="string"==typeof i.id&&i.id.trim()?i.id:"string"==typeof t.id&&t.id.trim()?t.id:`item-${e+1}`;return Object.assign(Object.assign({id:r,order:e+1},i),{metadata:Object.assign({service:"declarative"},i)})}(t,e)))}function U(t){if(!t||!t.trim())return null;try{const e=JSON.parse(t);if(Array.isArray(e))return $(e)}catch(t){}return null}function X(t,e,i=!1){if(Array.isArray(t)){let r=!1;for(const n of t){if(!n||"object"!=typeof n||Array.isArray(n))continue;const t=n,o="string"==typeof t.name?t.name.trim():"";if(!o||o in Object.prototype)continue;const a=void 0!==t.value&&null!==t.value?t.value:t.defaultValue;null!=a&&(e[o]=i?"string"==typeof a?a:String(a):a,r=!0)}return r}if(t&&"object"==typeof t&&!Array.isArray(t)){let r=!1;for(const[n,o]of Object.entries(t))if(n&&!(n in Object.prototype)&&o&&"object"==typeof o&&!Array.isArray(o)){const t=o;if("defaultValue"in t||"value"in t||"inputController"in t){const o=void 0!==t.value&&null!==t.value?t.value:t.defaultValue;null!=o&&(e[n]=i?"string"==typeof o?o:String(o):o,r=!0);continue}}return r}return!1}function Y(t,e){const i={};let r=!1;if(Array.isArray(t.componentGroups)){r=!0;for(const e of t.componentGroups){if(!e||"object"!=typeof e)continue;const t=e.components;if(Array.isArray(t))for(const e of t){if(!e||"object"!=typeof e)continue;const t=e;if(Array.isArray(t.propertyGroups))for(const e of t.propertyGroups)e&&"object"==typeof e&&X(e.properties,i,!0);t.properties&&X(t.properties,i,!0)}}}if(Array.isArray(t.propertyGroups)){r=!0;for(const e of t.propertyGroups)e&&"object"==typeof e&&X(e.properties,i,!0)}if(t.properties&&X(t.properties,i,!0)&&(r=!0),r)for(const[t,r]of Object.entries(i))e[t]=String(r);else for(const[i,r]of Object.entries(t))i in Object.prototype||null==r||(e[i]="string"==typeof r?r:JSON.stringify(r))}const Z=new Set(["$schema","id","name","version","contentType","genericContent","contentItems","contentItemsSnapshot","items","options","componentGroups","propertyGroups"]);function K(t,e){let i=null,r=!1;if(t.genericContent&&"object"==typeof t.genericContent&&!Array.isArray(t.genericContent)){r=!0;const i=t.genericContent;if(!X(i.properties,e,!1))for(const[t,r]of Object.entries(i))"properties"===t||"inputController"===t||t in Object.prototype||void 0===r||(e[t]=r)}t.properties&&X(t.properties,e,!1)&&(r=!0);const n=Array.isArray(t.contentItems)?t.contentItems:Array.isArray(t.items)?t.items:Array.isArray(t.contentItemsSnapshot)?t.contentItemsSnapshot:null;n&&(i=$(n));for(const[i,o]of Object.entries(t))i in Object.prototype||void 0===o||"contentItems"!==i&&"items"!==i&&"contentItemsSnapshot"!==i&&"genericContent"!==i&&"design"!==i&&"content"!==i&&"values"!==i&&(r&&(Z.has(i)||"properties"===i)||(!n||"options"!==i&&"contentType"!==i&&"$schema"!==i)&&(e[i]=o));return i}function Q(t){var e;const i=Array.from(t.children).filter((t=>!H(t)&&!G(t)));if(0===i.length)return t.querySelector("[data-widgetic-direct], iframe")||Array.from(t.children).some(G)?(M.delete(t),[]):null!==(e=M.get(t))&&void 0!==e?e:[];const r=i.map(((t,e)=>{var i;t.hasAttribute("data-widgetic-item")||(t.setAttribute("data-widgetic-item","1"),t instanceof HTMLElement&&(t.hidden=!0,t.style.display="none"));const r={};for(const e of Array.from(t.attributes)){const t=e.name.toLowerCase();if("data-widgetic-item"===t||"hidden"===t)continue;if("style"===t&&"display:none;"===e.value.replace(/\s+/g,""))continue;const i=W(e.name);i&&!(i in Object.prototype)&&(r[i]=V(e.value))}if(0===t.children.length){const e=null===(i=t.textContent)||void 0===i?void 0:i.trim();e&&(void 0===r.content&&(r.content=e),void 0===r.text&&(r.text=e))}const n="string"==typeof r.id&&r.id.trim()?r.id:`item-${e+1}`;return Object.assign(Object.assign({id:n,order:e+1},r),{metadata:Object.assign({service:"declarative"},r)})}));return M.set(t,r),r}function tt(t,e){if(!t)return null;if(e in t)return e;const i=e.toLowerCase();for(const e of Object.keys(t))if(e.toLowerCase()===i)return e;return null}function et(t,e){const i=function(t,e){var i;const r={},n={};let o=[];const a=Array.from(t.children).filter(G);for(const t of a){const a=null===(i=t.textContent)||void 0===i?void 0:i.trim();if(!a)continue;let s;try{s=JSON.parse(a)}catch(t){continue}if(Array.isArray(s)){o=$(s);continue}if(!s||"object"!=typeof s)continue;const c=s,u=(t.getAttribute("data-schema")||t.getAttribute("data-widgetic-json")||t.getAttribute("data-widgetic-config")||"").trim().toLowerCase();if("design"===u){Y(c,r);continue}if("content"===u){const t=K(c,n);t&&t.length>0&&(o=t);continue}let l=!1;if(c.design&&"object"==typeof c.design&&!Array.isArray(c.design)&&(Y(c.design,r),l=!0),(Array.isArray(c.componentGroups)||Array.isArray(c.propertyGroups))&&(Y(c,r),l=!0),c.content&&"object"==typeof c.content&&!Array.isArray(c.content)){const t=K(c.content,n);t&&t.length>0&&(o=t),l=!0}if(c.values&&"object"==typeof c.values&&!Array.isArray(c.values)){const t=K(c.values,n);t&&t.length>0&&(o=t),l=!0}if(c.genericContent||Array.isArray(c.contentItems)||Array.isArray(c.items)||Array.isArray(c.contentItemsSnapshot)){const t=K(c,n);t&&t.length>0&&(o=t),l=!0}if(!l)for(const[t,i]of Object.entries(c)){if(t in Object.prototype||null==i)continue;const o=tt(null==e?void 0:e.content,t),a=tt(null==e?void 0:e.design,t);a&&!o?r[a]="string"==typeof i?i:JSON.stringify(i):o&&!a?n[o]=i:(n[t]=i,"string"!=typeof i&&"number"!=typeof i||(r[t]=String(i)))}}return{design:r,content:n,contentItems:o}}(t,e),r=Object.assign({},i.design),n=Object.assign({},i.content);let o=null;const a=J(t.getAttribute("design"));a&&Y(a,r);const s=J(t.getAttribute("content"));if(s){const t=K(s,n);t&&t.length>0&&(o=t)}const c=J(t.getAttribute("values"));if(c){const t=K(c,n);t&&t.length>0&&(o=t)}for(const i of Array.from(t.attributes)){const t=i.name,o=t.toLowerCase();if(o.startsWith("design-")&&o.length>7){const n=W(t.slice(7));if(n&&!(n in Object.prototype)){r[tt(null==e?void 0:e.design,n)||n]=i.value}continue}if(o.startsWith("content-")&&"content-items"!==o&&o.length>8){const r=W(t.slice(8));if(r&&!(r in Object.prototype)){n[tt(null==e?void 0:e.content,r)||r]=V(i.value)}continue}if(B(t))continue;const a=W(t);if(!a||a in Object.prototype)continue;const s=tt(null==e?void 0:e.content,a),c=tt(null==e?void 0:e.design,a);if(s&&!c)n[s]=V(i.value);else if(c&&!s)r[c]=i.value;else{r[a]=i.value,n[a]=V(i.value);const e=t.replace(/^data-/,"");e===a||e in Object.prototype||(r[e]=i.value)}}let u=Q(t);if(0===u.length){const e=U(t.getAttribute("content-items"))||U(t.getAttribute("contentitems"))||U(t.getAttribute("items"))||o;e&&e.length>0?u=e:i.contentItems.length>0&&(u=i.contentItems)}return{design:r,content:n,contentItems:u,hasOverrides:Object.keys(r).length>0||Object.keys(n).length>0||u.length>0}}function it(t,e){const i=null!=e?e:{},r=et(t,i);return r.hasOverrides?Object.assign(Object.assign({},i),{design:Object.assign(Object.assign({},i.design||{}),r.design),content:Object.assign(Object.assign({},i.content||{}),r.content),contentItems:r.contentItems.length>0?r.contentItems:i.contentItems||[]}):i}function rt(t){var e,i;if(0===t.length)return!0;for(const r of t){if("attributes"===r.type){const t=(null===(e=r.attributeName)||void 0===e?void 0:e.toLowerCase())||"";if(!t)continue;if("data-widgetic-mounted"===t||"data-widgetic-mounting"===t||"data-widgetic-refused"===t||"data-widgetic-context-invalid"===t||"data-widgetic-overlay"===t||"data-device-restricted"===t||"data-widgetic-item"===t||"hidden"===t)continue;if("style"===t&&r.target!==(null===(i=r.target.ownerDocument)||void 0===i?void 0:i.body)&&r.target instanceof Element&&r.target.hasAttribute("data-widgetic-item"))continue;if(r.target instanceof Element&&H(r.target))continue;return!0}if("childList"===r.type){if(r.target instanceof Element&&H(r.target))continue;if([...Array.from(r.addedNodes),...Array.from(r.removedNodes)].some((t=>!(t instanceof Element&&H(t)))))return!0}if("characterData"===r.type){const t=r.target.parentElement;if(t&&!H(t))return!0}}return!1}const nt=new WeakMap;function ot(t,e,i){const r=nt.get(t);r&&r();const n="undefined"!=typeof MutationObserver?MutationObserver:null;if(!n)return()=>{};let o,a=!1;try{o=new n((r=>{rt(r)&&(a||(a=!0,queueMicrotask((()=>{a=!1;const r=et(t,e);i(r)}))))}))}catch(t){return()=>{}}o.observe(t,{attributes:!0,childList:!0,subtree:!0,characterData:!0});const s=()=>{o.disconnect(),nt.delete(t)};return nt.set(t,s),s}function at(){return"undefined"==typeof window?{customElements:!1,http3:!1,resizeObserver:!1,fullscreenApi:!1,popupBlocking:!1}:{customElements:"undefined"!=typeof customElements&&"function"==typeof customElements.define,http3:st(),resizeObserver:"undefined"!=typeof ResizeObserver,fullscreenApi:ct(),popupBlocking:ut()}}function st(){if("undefined"==typeof performance||!performance.getEntriesByType)return!1;try{const t=performance.getEntriesByType("navigation");if(t.length>0){const e=t[0];return"h3"===e.nextHopProtocol||"h3-29"===e.nextHopProtocol}return!1}catch(t){return!1}}function ct(){return!("undefined"==typeof document||!document.documentElement)&&!!(document.documentElement.requestFullscreen||document.documentElement.webkitRequestFullscreen||document.documentElement.mozRequestFullScreen||document.documentElement.msRequestFullscreen)}function ut(){if("undefined"==typeof window||!window.open)return!1;try{const t=window.open("","widgetic-popup-test","width=1,height=1");return!t||(t.close(),!1)}catch(t){return!0}}function lt(t,e){switch(t){case"custom-element":case"auto":default:return e.customElements?"custom-element":"iframe";case"iframe":return"iframe"}}function dt(){if("undefined"==typeof localStorage)return!1;try{const t="widgetic-test";return localStorage.setItem(t,t),localStorage.removeItem(t),!0}catch(t){return!1}}var pt=Object.freeze({__proto__:null,checkSdkInitialization:function(){if("undefined"==typeof window)return!1;const t="widgetic-sdk-initialized";return dt()?!!localStorage.getItem(t)||(localStorage.setItem(t,Date.now().toString()),!1):!!window.__widgeticInitialized},clearSdkInitialization:function(){dt()&&localStorage.removeItem("widgetic-sdk-initialized"),delete window.__widgeticInitialized},detectBrowserCapabilities:at,determineBestRenderMode:lt,hasIntersectionObserver:function(){return"undefined"!=typeof IntersectionObserver},isLocalStorageAvailable:dt});class gt{static analyzeElement(t){try{const e=this.getExplicitMetadata(t);return e||this.analyzeHeuristically(t)}catch(t){return null}}static getExplicitMetadata(t){const e=t.getAttribute("data-widget-meta");if(e)try{return JSON.parse(e)}catch(t){}const i=t.getAttribute("data-capabilities");if(i)return this.parseCapabilitiesString(i);const r=t.querySelector('script[type="application/json"]');if(r&&r.textContent)try{const t=JSON.parse(r.textContent);return t.capabilities||t.metadata}catch(t){}return null}static analyzeHeuristically(t){const e={type:"custom",version:"1.0.0"},i=t.getAttribute("data-widget-type")||t.getAttribute("data-type")||this.inferTypeFromStructure(t);switch(i&&(e.type=i),e.type){case"media":e.mediaCapabilities=this.analyzeMediaCapabilities(t);break;case"gallery":e.contentCapabilities=this.analyzeContentCapabilities(t);break;case"form":e.textCapabilities=this.analyzeTextCapabilities(t);break;case"interactive":e.interactionCapabilities=this.analyzeInteractionCapabilities(t)}return e.supportsResponsive=this.checkResponsiveSupport(t),e.supportsAutoscale=this.checkAutoscaleSupport(t),e.supportsThemes=this.checkThemeSupport(t),e.displayCapabilities=this.analyzeDisplayCapabilities(t),e.abTestingCapabilities=this.analyzeABTestingCapabilities(t),e}static inferTypeFromStructure(t){var e;return t.querySelector("video, audio")||t.classList.contains("media-widget")||(null===(e=t.getAttribute("data-widget-id"))||void 0===e?void 0:e.includes("video"))?"media":t.querySelector("form, input, textarea")||t.classList.contains("form-widget")?"form":t.querySelector(".gallery, .carousel")||t.classList.contains("gallery-widget")||t.querySelectorAll("img").length>1?"gallery":t.querySelector("button, .interactive")||t.classList.contains("quiz-widget")||t.classList.contains("poll-widget")?"interactive":"custom"}static analyzeMediaCapabilities(t){const e=t.querySelectorAll("video"),i=t.querySelectorAll("audio"),r=null!==t.querySelector("[controls]"),n=null!==t.querySelector("[data-volume], .volume-control");let o="audio";return e.length>0&&i.length>0?o="mixed":e.length>0&&(o="video"),{supportsPlay:!0,supportsPause:!0,supportsVolumeControl:n||r,supportsSeek:r,supportsGlobalVolume:t.hasAttribute("data-global-volume"),mediaType:o}}static analyzeContentCapabilities(t){const e=t.querySelectorAll(".item, .slide, img, .content-item"),i=null!==t.querySelector(".nav, .navigation, button"),r=t.hasAttribute("data-position")||t.hasAttribute("data-track-position");let n="gallery";return t.classList.contains("carousel")&&(n="carousel"),t.classList.contains("list")&&(n="list"),t.classList.contains("grid")&&(n="grid"),{supportsPositionTracking:r,supportsNavigation:i,contentType:n,totalItems:e.length}}static analyzeTextCapabilities(t){const e=t.querySelectorAll("input, textarea, select"),i=Array.from(e).map((t=>t.getAttribute("name")||t.getAttribute("id")||"unknown"));return{supportsTextPersistence:t.hasAttribute("data-persist")||t.hasAttribute("data-autosave"),supportsSanitization:!0,fields:i}}static analyzeInteractionCapabilities(t){const e=t.querySelectorAll("button").length>0,i=t.querySelectorAll("form").length>0,r=t.hasAttribute("data-events")||t.hasAttribute("data-track-interactions"),n=[],o=t.getAttribute("data-events");return o&&n.push(...o.split(",").map((t=>t.trim()))),{supportsClicks:e||null!==t.querySelector("[onclick]"),supportsFormSubmission:i,supportsCustomEvents:r,customEventTypes:n.length>0?n:void 0}}static analyzeDisplayCapabilities(t){return{supportsFullscreen:t.hasAttribute("data-fullscreen")||t.classList.contains("fullscreen-capable"),supportsOverlay:t.hasAttribute("data-overlay")||t.classList.contains("overlay-capable"),supportsPopup:t.hasAttribute("data-popup")||t.classList.contains("popup-capable"),supportsInline:!0}}static analyzeABTestingCapabilities(t){if(!("widgetic-abtest"===t.tagName.toLowerCase()||t.hasAttribute("experiment-id")||t.hasAttribute("data-ab-test")))return;const e=[],i=[];return t.querySelector("button, a, [onclick]")&&(e.push("clicks"),i.push("clicks")),t.querySelector("form")&&(e.push("submissions"),i.push("conversions")),t.querySelector("video, audio")&&(e.push("plays"),i.push("plays")),e.push("impressions"),{supportsTracking:!0,trackableEvents:e,conversionGoals:i}}static checkResponsiveSupport(t){return t.hasAttribute("data-responsive")||t.hasAttribute("data-breakpoints")||t.classList.contains("responsive")}static checkAutoscaleSupport(t){return t.hasAttribute("data-autoscale")||t.hasAttribute("data-auto-height")||t.classList.contains("autoscale")}static checkThemeSupport(t){return t.hasAttribute("data-theme")||t.classList.contains("themeable")||null!==t.querySelector("[data-theme]")}static parseCapabilitiesString(t){const e=t.split(",").map((t=>t.trim()));return{type:"custom",version:"1.0.0",mediaCapabilities:e.includes("media")?{supportsPlay:!0,supportsPause:!0,supportsVolumeControl:e.includes("volume"),supportsSeek:e.includes("seek"),supportsGlobalVolume:e.includes("global-volume"),mediaType:"mixed"}:void 0,textCapabilities:e.includes("forms")?{supportsTextPersistence:e.includes("persist"),supportsSanitization:!0,fields:[]}:void 0,interactionCapabilities:e.includes("interactive")?{supportsClicks:!0,supportsFormSubmission:e.includes("forms"),supportsCustomEvents:e.includes("events")}:void 0,supportsResponsive:e.includes("responsive"),supportsAutoscale:e.includes("autoscale"),supportsThemes:e.includes("themes")}}}function bt(t){var e,i,r,n;const o=new Set;return o.add("rendering"),o.add("api"),t.mediaCapabilities&&o.add("media"),t.textCapabilities&&o.add("security"),t.interactionCapabilities&&o.add("messaging"),((null===(e=t.displayCapabilities)||void 0===e?void 0:e.supportsFullscreen)||(null===(i=t.displayCapabilities)||void 0===i?void 0:i.supportsOverlay)||(null===(r=t.displayCapabilities)||void 0===r?void 0:r.supportsPopup))&&o.add("display"),t.abTestingCapabilities&&(o.add("abTesting"),o.add("messaging")),(null===(n=t.performanceRequirements)||void 0===n?void 0:n.requiresLazyLoading)&&o.add("performance"),Array.from(o)}var ft=Object.freeze({__proto__:null,WidgetMetadataAnalyzer:gt,analyzeWidgetRequirementsEnhanced:function(t){const e=new Set;for(const i of t){const t=gt.analyzeElement(i);if(t){bt(t).forEach((t=>e.add(t)))}}return Array.from(e)},getRequiredChunks:bt});export{e as D,r as M,et as a,F as b,Q as c,i as d,at as e,O as f,D as g,rt as h,_ as i,lt as j,C as k,dt as l,it as m,L as n,ot as o,n as p,pt as q,ft as w};
|