var f=Object.defineProperty;var _=(i,t,e)=>t in i?f(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e;var o=(i,t,e)=>(_(i,typeof t!="symbol"?t+"":t,e),e);import{t as g,d,s as p,U as y,l as S,m as C,o as v}from"./conversionBooster-index.js";import{g as b}from"./conversionBooster-chunk-theme.js";import{r as I}from"./conversionBooster-chunk-store.js";import"./conversionBooster-chunk-_commonjsHelpers.js";var A=(i=>(i[i.DISABLE=0]="DISABLE",i[i.ICON=1]="ICON",i[i.CUSTOM=2]="CUSTOM",i))(A||{}),P=(i=>(i.PDP="PRODUCT_DETAIL",i.CART="CART",i))(P||{});const w=()=>(Math.random()+Date.now()).toString(36).replace(/\./g,"");class u{constructor(t){o(this,"name");o(this,"dom");o(this,"data");o(this,"type");o(this,"isAdmin");o(this,"initCallback");o(this,"resetCallback");this.name=t.name||"PaymentSecurity"+w(),this.dom=t.dom,this.data=t.data,this.isAdmin=t.isAdmin,this.type=t.type,this.initCallback=t.initCallback}init(){if(!this.isAdmin&&(!this.data||!this.data.isOpen)||this.checkExitDom())return;this.stop();let t="",e=!1;if(this.dom.length>0&&this.data){let a=null;this.dom.forEach(s=>{if(!t&&(a=$(s),a.length>0&&a.css("display")!=="none"&&a.css("display"))){if(t=this.assembleHtml(),!t)return;a.after(t),e=!0,$(`.j-shopline-${this.name}`).attr("style",b().join("")),this.initCallback&&(this.resetCallback=this.initCallback($(`.j-shopline-${this.name}`))),this.initPayIconCollapse()}})}e&&g($(`.j-shopline-${this.name}`),`${this.name}-${this.dom.join(",")}-node-empty`)}checkExitDom(){const t=$(".trade-cart-safety-logo"),e=$(".productSecurityPayment");return!!($(`.j-shopline-${this.name}`).length>0||t.length>0&&t.css("display")&&t.css("display")!=="none"||e.length>0&&e.css("display")&&e.css("display")!=="none")}assembleHtml(){return this.type==="CART"||this.type==="MINI_CART"?this._cartAssembleHtml():this.type==="PDP"?this._pdpAssembleHtml():""}_pdpAssembleHtml(){var r,c;if(!this.data)return"";const{paymentSecurity:t,afterSaleGuarantee:e}=this.data;let a="",s="",n="";if(t.displayPosition&&t.displayPosition.includes("PRODUCT_DETAIL")&&(n=(r=t.desc)!=null&&r.trim()?`

${t.desc}

`:"",n&&d({component:111,page:105,event_id:6215,action_type:101,event_name:"payment_security_information_pdp"}),t.imageType>0&&(t.pcImages.length>0||t.mobileImages.length>0))){const l=t.imageType===2,m=h=>``;s=`
${t.pcImages.map(m).join("")}
`,s+=`
${t.mobileImages.map(m).join("")}
`,s&&d({component:111,page:105,event_id:6217,action_type:101,event_name:"payment_security_icon_pdp"})}return e.displayPosition&&e.displayPosition.includes("PRODUCT_DETAIL")&&(a=(c=e.desc)!=null&&c.trim()?`
${e.desc}
`:"",a&&d({component:111,page:105,event_id:6219,action_type:101,event_name:"after_sales_guarantee_information_pdp"})),!n&&!s&&!a?"":`
${n} ${s} ${a}
`}_cartAssembleHtml(){var n,r;if(!this.data)return"";const t=this.data;let e="",a="",s="";if(!t)return"";if(t.paymentSecurity.displayPosition&&t.paymentSecurity.displayPosition.includes("CART")&&(s=(n=t.paymentSecurity.desc)!=null&&n.trim()?`
${t.paymentSecurity.desc}
`:"",s&&d({component:111,page:106,event_id:6216,action_type:101,event_name:"payment_security_information_cart"}),t.paymentSecurity.imageType>0&&(t.paymentSecurity.pcImages.length>0||t.paymentSecurity.mobileImages.length>0))){const c=t.paymentSecurity.imageType===2,l=m=>``;a=`
${t.paymentSecurity.pcImages.map(l).join("")}
`,a+=`
${t.paymentSecurity.mobileImages.map(l).join("")}
`,t.paymentSecurity.imageType===1&&(a+=`
launch Pack up
`),a+="
",a&&d({component:111,page:106,event_id:6218,action_type:101,event_name:"payment_security_icon_cart"})}return t.afterSaleGuarantee.displayPosition&&t.afterSaleGuarantee.displayPosition.includes("CART")&&(e=(r=t.afterSaleGuarantee.desc)!=null&&r.trim()?`
${t.afterSaleGuarantee.desc}
`:"",e&&d({component:111,page:106,event_id:6220,action_type:101,event_name:"after_sales_guarantee_information_cart"})),!s&&!a&&!e?"":``}initPayIconCollapse(){$(`.j-shopline-${this.name} .tradeCartSafetyLogo-list-mobile`).each((t,e)=>{this._isPayIconOver(e)&&(e.dataset.open="0",$(e).find(".tradeCartSafetyLogo-collapse").on("click",this._collapsePayIconClick))})}_collapsePayIconClick(t){const{target:e}=t,a=$(e).parents(".tradeCartSafetyLogo-list-mobile");a.length>0&&(a[0].dataset.open=a[0].dataset.open==="0"?"1":"0")}_isPayIconOver(t){var n;if(((n=this.data)==null?void 0:n.paymentSecurity.imageType)===1){const r=$(t).find(".tradeCartSafetyLogo-list-mobile-content").height();if(r&&r>64)return $(t).css("--plugin-isv-conversionBooster-collapse_over_height--",64+"px"),!0}return!1}reset(t){I(this.name),this.data=Object.assign({},this.data,t.data),$(`.j-shopline-${this.name} .tradeCartSafetyLogo-list-mobile`).each((e,a)=>{this._isPayIconOver(a)&&$(a).find(".tradeCartSafetyLogo-collapse").off("click",this._collapsePayIconClick)}),$(`.j-shopline-${this.name}`).remove(),this.resetCallback&&this.resetCallback(),this.init()}stop(){return!1}}const H=async i=>{var t,e,a;if([p.CART,p.PDP].includes(y)){const s=[".auto-coupon-add-to-cart-plugin",".products-button-wrap",".sticky-main-view",".product-form",".product__info-description",".product-button-list"],n=[".main_cart [data-slot-cart-checkout-end]",".cart__taxes__desc",".cart__checkout"];new u({data:i,dom:y===p.CART?[...n,...s]:[...s,...n],type:y===p.CART?"CART":"PDP"}).init()}if(S()){const s=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,n=document.querySelector("cart-drawer-entry .cart-drawer");if(!n){C("seed-cart-drawer-dom-not-found-in-paymentSecurity",void 0,!0);return}let r=null;const c=()=>{n.classList.contains("active")&&(r||(r=new u({data:i,dom:["cart-drawer .cart-drawer__checkout-wrapper"],type:"MINI_CART",name:"PaymentSecurityCartDrawer"})),r.init())},l=new s(c);n&&l.observe(n,{subtree:!0,attributes:!0}),c()}else if((t=window==null?void 0:window.Shopline)!=null&&t.event){let s=null;(a=(e=window==null?void 0:window.Shopline)==null?void 0:e.event)==null||a.on(v.CART_SIDER_RENDER,()=>{s||(s=new u({data:i,dom:["[data-slot-mini-cart-checkout-end]","#payment_button_mini-cart-spb","#payment_button_mini-cart-spb-fixed",".sidebar__trade-cart-checkout"],type:"MINI_CART",name:"PaymentSecurityCartDrawer"})),s.init()})}};export{u as PaymentSecurity,P as PaymentSecurityDisposition,A as PaymentSecurityImageType,H as startPaymentSecurity};