import{r as t,h as e,H as i,g as s}from"./p-326e6826.js";import{p as n}from"./p-b650be7e.js";const o=":host{display:inline-block}";var r=undefined&&undefined.__classPrivateFieldGet||function(t,e,i,s){if(i==="a"&&!s)throw new TypeError("Private accessor was defined without a getter");if(typeof e==="function"?t!==e||!s:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return i==="m"?s:i==="a"?s.call(t):s?s.value:e.get(t)};var a,u;const h=class{constructor(e){t(this,e);a.add(this);this.origin=undefined;this.isEnabled=false;this.config=undefined;this.url="";this.productId=undefined;this.pqaWidgetId=undefined;this.textFieldVariant="pill";this.textFieldPlaceholder="Ask a questions";this.popupTitle="Ask a Question";this.buttonText="Ask a Question";this.finePrint="I'm an AI model. Sometimes, I may make mistakes. Please verify answers on the product page.";this.askButtonText=undefined;this.useBackground=undefined;this.popupAnchor="bottom-start";this.popupOffset=5;this.disableCloseOutsideClick=undefined;this.settings=undefined;this.useNativeScrollbars=undefined}async connectedCallback(){var t;this.config=await((t=this.el.closest("klevu-init"))===null||t===void 0?void 0:t.getConfig());r(this,a,"m",u).call(this)}render(){if(!this.isEnabled){return null}return e(i,null,e("klevu-button",{ref:t=>this.origin=t,part:"klevu-query-open-button",exportparts:n("klevu-button")},e("slot",{name:"before-button-text"}),this.buttonText,e("slot",{name:"after-button-text"})),this.origin&&e("klevu-util-portal",null,e("klevu-product-query-popup",{url:this.url,productId:this.productId,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},e("slot",{name:"after-fineprint",slot:"after-fineprint"}))))}get el(){return s(this)}};a=new WeakSet,u=async function t(){var e;if(!this.pqaWidgetId){this.isEnabled=true;return}const i=await window.fetch(`${(e=this.config)===null||e===void 0?void 0:e.moiApiUrl}chat/status?pqaWidgetId=${this.pqaWidgetId}`);const s=await i.json();this.isEnabled=s.status==="UNKNOWN"||s.status==="ENABLED"};h.style=o;export{h as klevu_product_query};
//# sourceMappingURL=p-7473ae06.entry.js.map