import{r as t,h as i,H as e,g as s}from"./p-3f9529e5.js";import{p as n}from"./p-d40c026f.js";const h=":host{display:inline-block}:host([embedded]){width:var(--klevu-product-query-popup-width, 100%)}";var r=undefined&&undefined.__classPrivateFieldGet||function(t,i,e,s){if(e==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof i==="function"?t!==i||!s:!i.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e==="m"?s:e==="a"?s.call(t):s?s.value:i.get(t)};var d,o,u;const a=class{constructor(i){t(this,i);d.add(this);this.origin=undefined;this.isEnabled=false;this.removeAskloBranding=false;this.config=undefined;this.url="";this.additionaldata="";this.productId=undefined;this.pqaWidgetId=undefined;this.textFieldVariant="pill";this.textFieldPlaceholder="Enter your question here...";this.pqaWidgetLayout="popup";this.popupTitle=this.pqaWidgetLayout==="popup"?"Ask a Question":"Live FAQs";this.buttonText="Ask Product AI";this.finePrint="";this.askButtonText=undefined;this.useBackground=undefined;this.popupAnchor="bottom-start";this.popupOffset=5;this.disableCloseOutsideClick=undefined;this.settings=undefined;this.useNativeScrollbars=undefined;this.productInfoGenerator=undefined;this.itemId=undefined;this.itemGroupId=undefined;this.itemVariantId=undefined;this.channelId=undefined;this.locale=undefined;this.hideEmbeddedTitle=false}async connectedCallback(){var t;this.config=await((t=this.el.closest("klevu-init"))===null||t===void 0?void 0:t.getConfig());r(this,d,"m",o).call(this)}render(){if(!this.isEnabled){return null}return this.pqaWidgetLayout==="popup"?i(e,null,i("klevu-button",{ref:t=>this.origin=t,part:"klevu-query-open-button",exportparts:n("klevu-button")},i("slot",{name:"before-button-text"}),this.buttonText,i("slot",{name:"after-button-text"})),i("klevu-util-portal",null,r(this,d,"m",u).call(this))):i(e,{embedded:true},r(this,d,"m",u).call(this))}get el(){return s(this)}};d=new WeakSet,o=async function t(){var i;if(!this.pqaWidgetId){this.isEnabled=true;return}const e=await window.fetch(`${(i=this.config)===null||i===void 0?void 0:i.moiApiUrl}chat/status?pqaWidgetId=${this.pqaWidgetId}`);const s=await e.json();this.isEnabled=s.status==="UNKNOWN"||s.status==="ENABLED";this.removeAskloBranding=s.removeAskloBranding||false},u=function t(){return i("klevu-product-query-popup",{additionaldata:this.additionaldata||"",url:this.url,productId:this.productId||this.itemId,pqaWidgetId:this.pqaWidgetId,tFinePrint:this.finePrint,tPopupTitle:this.popupTitle,tTextFieldPlaceholder:this.textFieldPlaceholder,askButtonText:this.askButtonText,settings:this.settings,popupAnchor:this.popupAnchor,popupOffset:this.popupOffset,exportparts:n("klevu-product-query-popup"),useBackground:this.useBackground,originElement:this.origin,disableCloseOutsideClick:this.disableCloseOutsideClick,config:this.config,useNativeScrollbars:this.useNativeScrollbars,itemId:this.itemId,itemVariantId:this.itemVariantId,itemGroupId:this.itemGroupId,channelId:this.channelId,locale:this.locale,productInfoGenerator:this.productInfoGenerator,textFieldVariant:this.textFieldVariant,pqaWidgetLayout:this.pqaWidgetLayout,removeAskloBranding:this.removeAskloBranding,hideEmbeddedTitle:this.hideEmbeddedTitle},i("slot",{name:"after-fineprint",slot:"after-fineprint"}))};a.style=h;export{a as klevu_product_query};
//# sourceMappingURL=p-954c05ad.entry.js.map