import{h as t,H as i,g as e,f as n}from"./p-5925f187.js";import{b as o}from"./p-1580513b.js";import{c as s}from"./p-4fb8ce4b.js";const r=()=>t(i,{class:"atomic-hidden"});const a="atomic/initializeComponent";const c=["atomic-recs-interface","atomic-search-interface","atomic-commerce-interface","atomic-commerce-recommendation-interface","atomic-relevance-inspector","atomic-insight-interface","atomic-external"];function l(t){return new Promise(((i,e)=>{const n=o(a,(t=>i(t)));t.dispatchEvent(n);if(!s(t,c.join(", "))){e(new d(t.nodeName.toLowerCase()))}}))}class d extends Error{constructor(t){super(`The "${t}" element must be the child of the following elements: ${c.join(", ")}`)}}function h(t){if(!t.shadowRoot){return}if(window.applyFocusVisiblePolyfill){window.applyFocusVisiblePolyfill(t.shadowRoot);return}window.addEventListener("focus-visible-polyfill-ready",(()=>{var i;return(i=window.applyFocusVisiblePolyfill)===null||i===void 0?void 0:i.call(window,t.shadowRoot)}),{once:true})}const f="data-atomic-rendered";const u="data-atomic-loaded";function m({forceUpdate:i}={}){return(l,m)=>{const{componentWillLoad:p,render:b,componentDidRender:w,componentDidLoad:g,disconnectedCallback:v}=l;let C=()=>{};if(m!=="bindings"){return console.error(`The InitializeBindings decorator should be used on a property called "bindings", and not "${m}"`,l)}l.componentWillLoad=function(){const t=e(this);t.setAttribute(f,"false");t.setAttribute(u,"false");const r=o(a,(t=>{this.bindings=t;const e=()=>n(this);this.bindings.i18n.on("languageChanged",e);C=()=>this.bindings.i18n.off("languageChanged",e);try{if(this.initialize){this.initialize();if(i){n(this)}}else{n(this)}}catch(t){this.error=t}}));t.dispatchEvent(r);if(!s(t,c.join(", "))){this.error=new d(t.nodeName.toLowerCase());return}return p&&p.call(this)};l.render=function(){if(this.error){return t("atomic-component-error",{element:e(this),error:this.error})}if(!this.bindings){return t(r,null)}e(this).setAttribute(f,"true");return b&&b.call(this)};l.disconnectedCallback=function(){const t=e(this);t.setAttribute(f,"false");t.setAttribute(u,"false");C();v&&v.call(this)};l.componentDidRender=function(){const t=e(this);if(t.getAttribute(f)==="false"){return}w&&w.call(this);if(t.getAttribute(u)==="false"){t.setAttribute(u,"true");h(e(this));g&&g.call(this)}};l.componentDidLoad=function(){}}}function p(t,i){return(n,o)=>{const{disconnectedCallback:s,initialize:r}=n;n.initialize=function(){r&&r.call(this);if(!r){return console.error(`ControllerState: The "initialize" method has to be defined and instantiate a controller for the property ${t}`,n)}if(!this[t]){return}if((i===null||i===void 0?void 0:i.onUpdateCallbackMethod)&&!this[i.onUpdateCallbackMethod]){return console.error(`ControllerState: The onUpdateCallbackMethod property "${i.onUpdateCallbackMethod}" is not defined`,n)}this.unsubscribeController=this[t].subscribe((()=>{this[o]=this[t].state;(i===null||i===void 0?void 0:i.onUpdateCallbackMethod)&&this[i.onUpdateCallbackMethod]()}))};n.disconnectedCallback=function(){var t;!e(this).isConnected&&((t=this.unsubscribeController)===null||t===void 0?void 0:t.call(this));s&&s.call(this)}}}export{p as B,r as H,m as I,d as M,a,h as b,l as i}; //# sourceMappingURL=p-1e3b01c2.js.map