LadiPageScriptV2.prototype.parseFormCheckoutProduct=function(e){var t={};try{t=JSON.parse(Base64.decode(e.getAttribute("data-product")))}catch(n){try{t=JSON.parse(e.getAttribute("data-product"))}catch(e){console.error(e)}}return t},LadiPageScriptV2.prototype.sendFormCheckout=function(e,t){var n=this,a=(e=n.findAncestor(e,"ladi-element")).getAttribute("data-payment");a=JSON.parse(a);var i,o=e.querySelectorAll('[data-form-checkout-item="product"] div[data-product]'),r=[];if(1===o.length){var c=n.findAncestor(o[0],"ladi-form-checkout-box");(W=n.parseFormCheckoutProduct(c)).quantity=1;var d=c.querySelector(".ladi-form-checkout-payment-quantity input");isEmptyLadiPage(d)||(W.quantity=parseInt(d.value)||W.quantity),r.push(W)}else r=Array.from(e.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-product-check.checked')).map(function(e){var t=n.findAncestor(e,"ladi-form-checkout-box"),a=n.parseFormCheckoutProduct(t);a.quantity=1;var i=t.querySelector(".ladi-form-checkout-payment-quantity input");return isEmptyLadiPage(i)||(a.quantity=parseInt(i.value)||a.quantity),a});(i=Array.from(e.querySelectorAll('[data-form-checkout-item="bump_offer"] .ladi-form-checkout-bump-offer-check.multiple.checked')).map(e=>{const t=e.closest(".ladi-form-checkout-bump-offer-product");return{...isEmptyLadiPage(t)?null:n.parseFormCheckoutProduct(t),quantity:1}})).length>0&&Array.prototype.push.apply(r,i);var s=isObjectLadiPage(n.runtime.payment_setting)?n.runtime.payment_setting:{},u=t.setFormData(e,!1),p=u.formDataObject,l=(u=t.setFormDataObjectThankyou()).formDataObjectThankyou,m=u.formDataObjectConvertThankyou,_=isEmptyLadiPage(p.name)?"":p.name,g=isEmptyLadiPage(p.email)?"":p.email,f=isEmptyLadiPage(p.phone)?"":p.phone,h=isEmptyLadiPage(p.message)?"":p.message,y=!isEmptyLadiPage(isEmptyLadiPage(p.i_agree_terms_and_conditions)?"":p.i_agree_terms_and_conditions),v=isEmptyLadiPage(p.country)?"":p.country.split(":")[0],E=isEmptyLadiPage(p.state)?"":p.state.split(":")[0],k=isEmptyLadiPage(p.ward)?"":p.ward.split(":")[0],L=isEmptyLadiPage(p.district)?"":p.district.split(":")[0],P=isEmptyLadiPage(p.address)?"":p.address.split(":")[0],b=!1,A=!1,w=!1,O=!0,T=0,S=isObjectLadiPage(n.runtime.tmp.form_data_value_all)?n.runtime.tmp.form_data_value_all:{},x=function(e,t){var a=Object.assign(n.copy(S),n.copy(l));return a=Object.assign(a,{qr_code:n.runtime.tmp.current_qr_code_link}),e=window.ladi(e).get_url(a,t,!1)},N=function(a){var i=s.thankyou_type,o=s.thankyou_value,r=!1;n.runtime.has_popupx&&n.runtime.tmp.popupx_is_inline&&(r=!0);var c=0,d=n.runtime.eventData[e.id]["option.form_auto_funnel"],u="";i==n.const.FORM_THANKYOU_TYPE.default&&(isEmptyLadiPage(o)||n.showMessage(o,m)),i==n.const.FORM_THANKYOU_TYPE.popup&&(d&&n.setDataReplaceElement(!1,!1,m,o),window.ladi(o).show(!1,{formThankyouPopupXInline:r})),i!=n.const.FORM_THANKYOU_TYPE.url&&i!=n.const.FORM_THANKYOU_TYPE.url_default||isEmptyLadiPage(a)||(o=window.ladi(a).encode_thankyou_url(),u=x(o,d),c+=1e3,n.runTimeout(function(){window.ladi(u).open_url()},c)),t.resetFormValue(e.querySelector(".ladi-form"))},C=function(e,t){"Success"==e&&N(t.thanks_url),"Canceled"==e&&n.showMessage(n.const.LANG.FORM_CHECKOUT_ORDER_CANCEL)};window.formCheckoutDownloadQRCode=function(){const e=document.getElementById("form-checkout-bank-qr").src;fetch(e).then(e=>e.blob()).then(e=>{const t=new FileReader;t.onloadend=function(){const e=t.result,n=document.createElement("a");n.href=e,n.download="qr_code.png",document.body.appendChild(n),n.click(),document.body.removeChild(n)},t.readAsDataURL(e)}).catch(e=>console.error("Error downloading image:",e))},window.formCheckoutCopyToClipboard=function(e){const t=e.closest(".info-row"),n=t?t.querySelector(".info-value"):null;if(n){const t=n.textContent.trim(),a=document.createElement("input");a.style.position="absolute",a.style.left="-9999px",document.body.appendChild(a),a.value=t,a.select(),document.execCommand("copy"),document.body.removeChild(a);const i=e.querySelector(".tooltiptext.right"),o=i.getAttribute("tooltiptext");i.setAttribute("tooltiptext","Copied to clipboard!"),i.style.visibility="visible",i.style.opacity="1",setTimeout(()=>{i.setAttribute("tooltiptext",o),i.style.visibility="hidden",i.style.opacity="0"},2e3)}else console.error("The .info-value element was not found.")},window.formCheckoutClosePopupQRCode=function(){b=!0;var e=document.querySelector(".ladipage-message");e&&e.remove();var t=document.querySelector("body .ladi-wraper");t&&(t.style.display="block"),n.removeTimeout(T),T=null},window.clickConfirmBankedCheckout=function(){console.log("clickConfirmBankedCheckout")};var R=function(e,t){t&&delete n.runtime.tmp.current_qr_code_link,b=!1;var a="form-checkout-bank-qr",i=e.bank_info.banks[0].autoConfirmPayment;const o=document.querySelector("body .ladi-wraper"),r=window.innerWidth<=768;if(o&&r?o.style.display="none":o&&(o.style.display=""),isEmptyLadiPage(document.getElementById(a))){LadiPageScript.showMessage(`\n \n
\n \n
Thanh toán chuyển khoản ngân hàng
\n ${i?'\n
\n
Đang chờ thanh toán
\n
\n
\n
\n Loading\n
\n\n \n\n ':""}\n ${function(){const t=e.bank_info.payment_guide.replace(/\n/g,"
");return htmlContent='
'+t+"
"}()}\n
\n\n
\n
\n
Quét mã QR thanh toán
\n ${function(){if(isObjectLadiPage(e.bank_info)){var t=e.bank_info.base_64_qrCode?"data:image/png;base64,"+e.bank_info.base_64_qrCode:e.bank_info.qr_url;return n.runtime.tmp.current_qr_code_link=t,`QRCode`}return""}()}\n \n
Mở app ngân hàng hoặc ví điện tử của bạn sau đó chọn quét mã QR để thực hiện thanh toán.
\n
\n ${function(){try{return`\n
\n
\n Chuyển khoản thủ công theo thông tin\n
\n \n
\n
\n
\n \n\n
\n
\n
Ngân hàng
\n
${e.bank_info.banks[0].bank.shortName}
\n
\n
\n
Thụ hưởng
\n
${e.bank_info.banks[0].accountName}
\n
\n
\n
Số tài khoản
\n
${e.bank_info.banks[0].accountNumber}
\n
\n Copy\n
\n
\n
\n
\n
Số tiền
\n
${n.formatCurrency(e.bank_info.amount,e.bank_info.currency_symbol,!0)}
\n
\n Copy\n
\n
\n
\n
\n
Nội dung CK
\n
\n ${i?`${e.bank_info.banks[0].transferContentPrefix}${e.bank_info.reference_no}`:`${function(e){const t=e.banks[0].transactionContent,n={"{{customer_full_name}}":e.customer_full_name||"","{{customer_phone}}":e.customer_phone||"","{{MaDonHang}}":e.reference_no||""};return t.replace(/{{(.*?)}}/g,(e,t)=>n[e]||"")}(e.bank_info)}`}\n
\n
\n Copy\n
\n
\n
\n ${i?`\n
\n Lưu ý: Vui lòng giữ nguyên nội dung ${e.bank_info.banks[0].transferContentPrefix}${e.bank_info.reference_no} để xác nhận thanh toán tự động\n
\n `:""}\n \n
\n
\n \n
\n `}catch(e){return""}}()}\n
\n `)}!A&&i&&(!function(e){const t=document.querySelector(".count-down"),a=document.getElementById("countdown-timer"),i=document.getElementById("countdown-message"),o=document.querySelector(".close-popup"),r=document.querySelector(".sub-title");let c=Date.now()+60*e*1e3;a.style.display="block",i.style.display="none",o.style.display="block",function e(){const d=Math.max(0,c-Date.now()),s=Math.floor(d/6e4),u=Math.floor(d%6e4/1e3);a.textContent=`${String(s).padStart(2,"0")} phút ${String(u).padStart(2,"0")} giây`,d>0?T=n.runTimeout(e,1e3):(i.style.textAlign="center",i.style.display="block",i.style.color="#E01A1A",i.style.maxWidth="632px",o.style.display="block",t.style.display="none",r.style.display="none",w=!0)}()}(5),A=!0);var c=new XMLHttpRequest;c.open("POST",n.const.API_LADISALE_CHECKOUT_GET_ORDER_STATUS),c.addEventListener("readystatechange",function(){if(4===this.readyState)try{var t=JSON.parse(this.responseText);if(200!=t.code)throw new TypeError("api error");if("Pending"==t.data.payment_status||"OnHold"==t.data.payment_status)throw new TypeError("fetch api");C(t.data.payment_status,e)}catch(t){setTimeout(function(){!b&&R(e,!1)},1e4)}}),c.setRequestHeader("content-type","application/json"),!O||b||w||(O=i,c.send(JSON.stringify({ls_data:e.ls_data})))},q="";s.thankyou_type==n.const.FORM_THANKYOU_TYPE.url&&(q=x(s.thankyou_value,!0)),isEmptyLadiPage(n.runtime.tmp.form_checkout_order_id)&&(n.runtime.tmp.form_checkout_order_id=n.randomString(10)),n.showLoadingBlur();var D=localStorage.getItem("previousSubmission");if(D)var F=JSON.parse(D);else F={customer_name:null,customer_email:null,customer_phone:null,variants:[],data_payment:{code:null,type:null,bank_code:null}};var I,M,j,U=r.map(function(e){return{product_id:e.product_id,product_variant_id:e.product_variant_id,quantity:e.quantity,store_id:e.store_id_product}});try{var Y={code:a.code||null,method_name:a.method_name||null},B=F.variants.length!==U.length;if(!B)for(var G=0;G!["name","email","phone","message","address","state","district","ward","country","i_agree_terms_and_conditions"].includes(e)).map(function(e){return{name:e[0],value:e[1]}}),customer_country_code:v,customer_state_id:E,customer_district_id:L,customer_ward_id:k,customer_address:P,shipping_country_code:v,shipping_state_id:E,shipping_district_id:L,shipping_ward_id:k,shipping_address:P,shipping_method_id:o?o.shipping_method_id:null,discount_shipping_code:i?i.code:null}),z=new XMLHttpRequest;z.addEventListener("readystatechange",function(){4===this.readyState&&(!function(e){try{var t=JSON.parse(e);if(200!=t.code||!isObjectLadiPage(t.data))return n.showMessage(t.message);if(window.ladi_fbq("track","InitiateCheckout",{value:r.reduce(function(e,t){return e+t.price*t.quantity},0),currency:n.runtime.currency,content_ids:r.map(function(e){return e.product_variant_id}),num_items:r.reduce(function(e,t){return e+t.quantity},0),products_name:r.map(function(e){return e.name})}),t.data,!isEmptyLadiPage(t.data.redirect_url)&&isEmptyLadiPage(t.data.vnptEPayData)&&(!isObjectLadiPage(t.data.bank_info)||isEmptyLadiPage(t.data.bank_info.base_64_qrCode)))return void n.runTimeout(function(){window.location.href=t.data.redirect_url},1e3);if(isObjectLadiPage(t.data.bank_info)&&!t.data.bank_info.qr_url&&!isEmptyLadiPage(t.data.bank_info.base_64_qrCode))return void R(t.data,!0);if(isObjectLadiPage(t.data.bank_info)&&!isEmptyLadiPage(t.data.bank_info.qr_url)&&!isEmptyLadiPage(t.data.ls_data)&&!b)return window.ladi("CART_TOKEN_FORM_CHECKOUT").set_cookie(t.data.cart_token,3),window.ladi("CHECKOUT_TOKEN_FORM_CHECKOUT").set_cookie(t.data.checkout_token,3),void(0!==t.data.bank_info.amount?R(t.data,!0):N(t.data.thanks_url));if(t.data.vnptEPayData){var a=document.createElement("div");a.style.display="none",a.appendChild(function(e={}){var t=document.createElement("form");return t.id="megapayForm",t.name="megapayForm",t.method="POST",[{name:"invoiceNo",value:e.invoice_no},{name:"amount",value:e.amount},{name:"currency",value:e.currency||"VND"},{name:"goodsNm",value:e.product_name},{name:"buyerPhone",value:e.buyer_phone},{name:"buyerAddr",value:""},{name:"buyerCity",value:""},{name:"buyerState",value:""},{name:"buyerPostCd",value:""},{name:"buyerCountry",value:""},{name:"fee",value:""},{name:"receiverFirstNm",value:""},{name:"receiverLastNm",value:""},{name:"receiverPhone",value:""},{name:"receiverAddr",value:""},{name:"receiverCity",value:""},{name:"receiverState",value:""},{name:"receiverPostCd",value:""},{name:"receiverCountry",value:"VN"},{name:"description",value:e.description},{name:"callBackUrl",value:e.redirect_url},{name:"notiUrl",value:e.notify_url},{name:"merId",value:e.mer_id},{name:"reqDomain",value:e.url},{name:"userLanguage",value:e.user_language},{name:"merchantToken",value:e.token},{name:"payToken",value:""},{name:"timeStamp",value:e.time_stamp},{name:"merTrxId",value:e.mer_trx_id},{name:"windowType",value:"1"},{name:"windowColor",value:"#0B3B39"},{name:"userFee",value:""},{name:"vaCondition",value:"03"},{name:"payType",value:e.type},{name:"payOption",value:""},{name:"bankCode",value:e.bank_code},{name:"goodsAmount",value:""},{name:"buyerLastNm",value:""},{name:"buyerFirstNm",value:""},{name:"buyerEmail",value:e.buyer_email},{name:"vaStartDt",value:e.va_start_date},{name:"vaEndDt",value:e.va_end_date}].forEach(function(e){var n=document.createElement("input");n.type="hidden",n.name=e.name,n.value=e.value,t.appendChild(n)}),t}(t.data.vnptEPayData)),document.body.appendChild(a),window.openPayment(1,t.data.vnptEPayData.domain)}N(t.data.thanks_url)}catch(e){return console.log(e),n.showMessage(n.const.LANG.REQUEST_SEND_ERROR)}}(this.responseText),n.hideLoadingBlur())}),z.open("POST",n.const.API_LADISALE_CHECKOUT_PAYMENT),z.setRequestHeader("Content-Type","application/json"),z.send(W),F={customer_name:_,customer_email:g,customer_phone:f,variants:U,data_payment:Y},localStorage.setItem("previousSubmission",JSON.stringify(F))}catch(e){n.hideLoadingBlur()}},LadiPageScriptV2.prototype.eventFormCheckoutSelectPaymentType=function(e){var t=this;t instanceof LadiPageScriptV2||(t=LadiPageScript),e.stopPropagation();var n=t.findAncestor(e.target,"ladi-form-checkout-box"),a=t.findAncestor(e.target,["ladi-form","ladi-element"]);isObjectLadiPage(LadiPageScript.runtime.tmp.isObjectCheck)||(LadiPageScript.runtime.tmp.isObjectCheck={});var i=LadiPageScript.runtime.tmp.isObjectCheck[a.id];if(delete LadiPageScript.runtime.tmp.isObjectCheck[a.id],!document.querySelector('script[src="https://pg.megapay.vn/pg_was/js/payment/layer/paymentClient.js"]')){var o=document.createElement("script");o.type="text/javascript",o.rel="preload",o.src="https://pg.megapay.vn/pg_was/js/payment/layer/paymentClient.js",o.async=!0,document.head.appendChild(o)}if(!document.querySelector('script[src="https://code.jquery.com/jquery-1.11.1.min.js"]')){var r=document.createElement("script");r.type="text/javascript",r.rel="preload",r.src="https://code.jquery.com/jquery-1.11.1.min.js",r.async=!0,document.head.appendChild(r)}t.showMessage("\n \n \n ");var c=function(){document.querySelector(".ladipage-message-close").click(),isEmptyLadiPage(a.getAttribute("data-payment"))&&a.setAttribute("data-payment",JSON.stringify({}))},d=function(e){var t=a.querySelector('.ladi-element[data-form-checkout-item="payment"] .ladi-form-checkout-box[data-payment-code="'+e.code+'"] .ladi-form-checkout-payment-content span:last-child');t.hasAttribute("data-old")||t.setAttribute("data-old",t.textContent),isEmptyLadiPage(e.code)?t.textContent=t.getAttribute("data-old"):t.textContent=e.method_title||t.getAttribute("data-old"),isEmptyLadiPage(e.code)||(Array.from(a.querySelectorAll('[data-form-checkout-item="payment"] .ladi-form-checkout-payment-check.checked')).forEach(function(e){e.classList.remove("checked")}),Array.from(a.querySelectorAll('[data-form-checkout-item="payment"] [data-payment-code="'+e.code+'"] .ladi-form-checkout-payment-check')).forEach(function(e){e.classList.add("checked")})),a.setAttribute("data-payment",JSON.stringify(e)),c()},s=document.querySelector(".ladipage-message-text iframe"),u=function(){if(isEmptyLadiPage(s))return;var e=isObjectLadiPage(t.runtime.payment_setting)?t.runtime.payment_setting:{},o=a.hasAttribute("data-payment")?JSON.parse(a.getAttribute("data-payment")):{};o.code=n.getAttribute("data-payment-code");var r=t.runtime.tmp.html_payment_str;const u=a.id;var p=null;document.querySelectorAll(`#${u} .ladi-form-checkout-product-check.multiple.checked`).forEach(e=>{const n=e.closest(".ladi-form-checkout-box");n&&(p=t.parseFormCheckoutProduct(n))}),s.contentWindow.isFirstClickMethodPayment=i,s.contentWindow.payment_continue=d,s.contentWindow.payment_cancel=c,s.contentWindow.payment_setting=e,s.contentWindow.current_select=o,s.contentWindow.ladi_uid=t.runtime.store_ladiuid,s.contentWindow.end_point_api=t.const.API_LADISALE_LIST_GATEWAY,s.contentWindow.objDataProduct=p,s.contentDocument.open(),s.contentDocument.write(r),s.contentDocument.close()};isEmptyLadiPage(t.runtime.tmp.html_payment_str)?fetch(t.const.URL_LADI_PAYMENT()).then(e=>e.text()).then(e=>{t.runtime.tmp.html_payment_str=e,u()}).catch(e=>{}):u()},LadiPageScriptV2.prototype.checkValidateSendFormCheckout=function(e){try{if(0==e.querySelectorAll('[data-form-checkout-item="product"] div[data-product]').length)throw new TypeError("no product")}catch(e){return this.showMessage(this.const.LANG.FORM_VALIDATE_CHECKOUT_PRODUCT),!1}try{var t=JSON.parse(e.getAttribute("data-payment"));if(0==Object.keys(t).length)throw new TypeError("no payment")}catch(t){if(e.querySelectorAll('[data-form-checkout-item="payment"] div[data-payment-code]').length>1)return this.showMessage(this.const.LANG.FORM_VALIDATE_CHECKOUT_PAYMENT);isObjectLadiPage(LadiPageScript.runtime.tmp.isObjectCheck)||(LadiPageScript.runtime.tmp.isObjectCheck={}),delete LadiPageScript.runtime.tmp.isObjectCheck[e.id];var n=e.querySelector('[data-form-checkout-item="payment"] .ladi-form-checkout-payment-content');return n&&n.click(),!1}return!0},LadiPageScriptV2.prototype.runOptionFormCheckout=function(){var e=this,t={state:"",district:"",ward:""},n=function(t){try{var n=e.findAncestor(t,"ladi-form-checkout-box"),a=e.parseFormCheckoutProduct(n);if(isEmptyLadiPage(a.min))throw new TypeError("no min");return parseInt(a.min)||1}catch(e){return 1}},a=function(t){try{var n=e.findAncestor(t,"ladi-form-checkout-box"),a=e.parseFormCheckoutProduct(n);if(isEmptyLadiPage(a.max))throw new TypeError("no max");return parseInt(a.max)||1}catch(e){return 1e6}},i=function(e){var t=parseInt(e.target.value);ta(e.target)&&(t=a(e.target)),e.target.value=t,c(e)},o=function(e){var t=e.target.parentElement.querySelector("input");t.value=(parseInt(t.value)||0)+1,t.value>a(e.target)&&(t.value=a(e.target)),c(e)},r=function(e){var t=e.target.parentElement.querySelector("input");t.value=(parseInt(t.value)||0)-1,t.value span.checked'),c=document.querySelectorAll("#"+a+" .ladi-form-checkout-bump-offer-check.checked");const d=Array.from(r).concat(Array.from(c));if(1==i.length&&(r=document.querySelectorAll("#"+a+" .ladi-form-checkout-product-check, #"+a+' [data-form-checkout-item="product"] [data-product] .ladi-form-checkout-payment-item > span')),0==r.length){var s=e.findAncestor(n.target,"ladi-form");s.querySelectorAll('[data-form-checkout-item="bump_offer"]').length>0&&(Array.from(s.querySelectorAll('[data-form-checkout-item="bump_offer"] .ladi-form-checkout-bump-offer-check.checked')).forEach(function(e){e.classList.remove("checked")}),c=[])}let u=[];if(1===i.length){const t=i[0].closest(".ladi-form-checkout-box"),n=t.querySelector('.ladi-form-checkout-payment-quantity input[type="number"]');if(t){const a=e.parseFormCheckoutProduct(t),i=isEmptyLadiPage(n)?1:parseInt(n.value);u.push({product_variant_id:a.product_variant_id,quantity:i})}o.forEach(t=>{const n=t.closest(".ladi-form-checkout-bump-offer-product"),a=e.parseFormCheckoutProduct(n);u.push({product_variant_id:a.product_variant_id,quantity:1})})}else d.forEach(t=>{const n=t.closest(".ladi-form-checkout-box, .ladi-form-checkout-bump-offer-product"),a=isEmptyLadiPage(n)?null:n.querySelector('.ladi-form-checkout-payment-quantity input[type="number"]');if(n){const t=e.parseFormCheckoutProduct(n),i=isEmptyLadiPage(a)?1:parseInt(a.value);u.push({product_variant_id:isObjectLadiPage(t)?t.product_variant_id:null,quantity:i})}});0==r.length&&0==c.length&&(u=[]),l(a,{variants:u}),L(n,t)},d=function(n){n.stopPropagation();var a=e.findAncestor(n.target,"ladi-element");if("product"==a.getAttribute("data-form-checkout-item")){var i=e.findAncestor(n.target,"ladi-form-checkout-box"),o=i.querySelector(".ladi-form-checkout-payment-check, .ladi-form-checkout-product-check");if(o){var r=a.querySelectorAll(".ladi-form-item [data-product]");if(o.classList.contains("checked")&&1==r.length)return;o.classList.contains("multiple")?o.classList.toggle("checked"):(Array.from(i.parentElement.querySelectorAll(".ladi-form-checkout-payment-check.checked, .ladi-form-checkout-product-check.checked")).forEach(function(e){e.classList.remove("checked")}),o.classList.add("checked"))}c(n),L(n,t)}},s=function(t){"payment"==e.findAncestor(t.target,"ladi-element").getAttribute("data-form-checkout-item")&&e.eventFormCheckoutSelectPaymentType(t)},u=function(t){if(t.stopPropagation(),"bump_offer"==e.findAncestor(t.target,"ladi-element").getAttribute("data-form-checkout-item")){var n=e.findAncestor(t.target,"ladi-form"),a=n.querySelectorAll('[data-form-checkout-item="product"]');let d=n.querySelectorAll('[data-form-checkout-item="product"] div[data-product]');if(a.length>0){var i,o,r=n.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-product-check.checked, [data-form-checkout-item="product"] [data-product] .ladi-form-checkout-payment-item > span.checked');if(1==d.length)(o=(i=e.findAncestor(t.target,"ladi-form-checkout-bump-offer-checkbox")).querySelector(".ladi-form-checkout-bump-offer-check"))&&(o.classList.contains("multiple")?o.classList.toggle("checked"):(Array.from(i.parentElement.querySelectorAll(".ladi-form-checkout-bump-offer-check.checked")).forEach(function(e){e.classList.remove("checked")}),o.classList.add("checked"))),c(t);else if(r.length>0)(o=(i=e.findAncestor(t.target,"ladi-form-checkout-bump-offer-checkbox")).querySelector(".ladi-form-checkout-bump-offer-check"))&&(o.classList.contains("multiple")?o.classList.toggle("checked"):(Array.from(i.parentElement.querySelectorAll(".ladi-form-checkout-bump-offer-check.checked")).forEach(function(e){e.classList.remove("checked")}),o.classList.add("checked"))),c(t);else LadiPageScript.showMessage(e.const.LANG.MESSAGE_WARNING_SELECT_PRODUCT_BUMP_OFFER)}}},p=function(t,n,a,i,o,r,c){isEmptyLadiPage(n)||window.ladi(t+"_cart_price").set_data(e.formatCurrency(n,e.runtime.currency,!0)),isEmptyLadiPage(a)||window.ladi(t+"_cart_discount").set_data("-"+e.formatCurrency(a,e.runtime.currency,!0)),isEmptyLadiPage(i)||window.ladi(t+"_cart_coupon_discount").set_data("-"+e.formatCurrency(i,e.runtime.currency,!0)),isEmptyLadiPage(o)||window.ladi(t+"_cart_checkout_price").set_data(e.formatCurrency(o,e.runtime.currency,!0)),isEmptyLadiPage(r)||window.ladi(t+"_cart_fee_shipping").set_data(e.formatCurrency(r,e.runtime.currency,!0)),isEmptyLadiPage(c)||window.ladi(t+"_cart_fee_shipping_discount").set_data("-"+e.formatCurrency(c,e.runtime.currency,!0))},l=function(t,n){isObjectLadiPage(e.runtime.tmp.timeout_form_checkout_get_price)||(e.runtime.tmp.timeout_form_checkout_get_price={}),e.removeTimeout(e.runtime.tmp.timeout_form_checkout_get_price),e.runtime.tmp.timeout_form_checkout_get_price[t]=e.runTimeout(function(){try{const o=document.querySelector("#"+t+' [data-form-checkout-item="total_price"]');if("none"!=window.getComputedStyle(o).display&&n.variants.length>0){var a=window.ladi("_cart_token").get_cookie(),i={"Content-Type":"application/json"};isEmptyLadiPage(a)||(i["cart-token"]=a),e.sendRequest("POST",e.const.API_LADISALE_PROMOTION,JSON.stringify(n),!0,i,function(n,a,i){if(i.readyState==XMLHttpRequest.DONE)try{var r=JSON.parse(n);if(200==a&&200==r.code&&isObjectLadiPage(r.data)&&isArrayLadiPage(r.data.variants)){e.runtime.tmp[t+"_data_cart_promotions"]=r.data.variants;let n=e.runtime.tmp[t+"_data_discount_coupon_selected"];return n&&isObjectLadiPage(n)?void m(t,n.discount_code):void g(t)}200==a&&201==a||e.showMessage(r.message)}catch(r){p(o.id,null,0,0,null,0,0)}})}else p(o.id,null,0,0,null,0,0)}catch(e){console.error(e)}},500)},m=function(n,a,i){try{let o=window.ladi("_cart_token").get_cookie(),r={"Content-Type":"application/json"};isEmptyLadiPage(o)||(r["cart-token"]=o);let c=_(n)||[],d={domain:"",path:"",path_type:"product",discount_code:a,discount_shipping_code:i?i.code:"",shipping_state_id:t.state.split(":")[0],shipping_district_id:t.district.split(":")[0],shipping_method_id:i?i.shipping_method_id:"",variants:c};e.sendRequest("POST",e.const.API_LADISALE_VALIDATE_COUPON_CODE,JSON.stringify(d),!0,r,function(t,a,i){if(i.readyState==XMLHttpRequest.DONE)try{var o=JSON.parse(t);if(200==a){if(200==o.code){let t=document.getElementById(n),a=null,i=null,r=null,c=null;t&&(a=t.querySelector(".checkout-block-discount-coupon"),i=t.querySelector("#value-coupon-code"),r=t.querySelector("#shipping-coupon"),c=t.querySelector("#value-coupon-shipping-code")),isObjectLadiPage(o.data)&&(a&&a.setAttribute("data-coupon-code",o.data.discount_code),a&&isObjectLadiPage(o.data.discount_shipping)&&a.setAttribute("data-coupon-shipping-code",o.data.discount_shipping.code),i&&(i.textContent="-"+e.formatCurrency(o.data.discount_price,e.runtime.currency,!0)),i&&0!=o.data.discount_price?(i.style.border="1px solid #EF9300",i.style.borderRadius="2px",i.style.color="EF9300",i.style.padding="2px 4px"):(i.textContent="",i.style.border="",i.style.borderRadius="",i.style.padding=""),c&&r&&isObjectLadiPage(o.data.discount_shipping)&&0!=o.data.discount_shipping.fee?(c.textContent="-"+e.formatCurrency(o.data.discount_shipping.fee,e.runtime.currency,!0),c.style.color="#4AC000",r.style.display="flex",r.style.alignItems="center",r.style.gap="4px",r.style.border="1px solid #4AC000",r.style.borderRadius="2px",r.style.padding="2px 4px"):(r.style.display="none",r.style.border="",r.style.borderRadius="",r.style.padding="")),e.runtime.tmp[n+"_data_discount_coupon_selected"]=o.data,e.runtime.tmp[n+"_data_discount_shipping_selected"]=isObjectLadiPage(o.data.discount_shipping)&&o.data.discount_shipping,g(n);let d=document.querySelectorAll(".ladipage-message-close");return void(d&&(d.forEach(function(e){e.click()}),document.body.style.overflow=""))}e.showMessage(o.message)}200==a&&201==a||e.showMessage(o.message)}catch(o){}})}catch(e){console.log("err validateCouponCode",e)}},_=function(t){let n=[],a=document.querySelectorAll("#"+t+' [data-form-checkout-item="product"] div[data-product]'),i=document.querySelectorAll("#"+t+' [data-form-checkout-item="bump_offer"] .ladi-form-checkout-bump-offer-check.checked'),o=document.querySelectorAll("#"+t+" .ladi-form-checkout-product-check.checked, #"+t+' [data-form-checkout-item="product"] [data-product] .ladi-form-checkout-payment-item > span.checked'),r=document.querySelectorAll("#"+t+" .ladi-form-checkout-bump-offer-check.checked");const c=Array.from(o).concat(Array.from(r));if(1===a.length){const t=a[0].closest(".ladi-form-checkout-box"),o=t.querySelector('.ladi-form-checkout-payment-quantity input[type="number"]');if(t){const a=e.parseFormCheckoutProduct(t),i=isEmptyLadiPage(o)?1:parseInt(o.value);n.push({product_name:a.name,price:a.price,product_variant_id:a.product_variant_id,product_id:a.product_id,quantity:i})}i.forEach(t=>{const a=t.closest(".ladi-form-checkout-bump-offer-product"),i=e.parseFormCheckoutProduct(a);n.push({product_name:i.name,price:i.price,product_id:i.product_id,product_variant_id:i.product_variant_id,quantity:1})})}else c.forEach(t=>{const a=t.closest(".ladi-form-checkout-box, .ladi-form-checkout-bump-offer-product"),i=isEmptyLadiPage(a)?null:a.querySelector('.ladi-form-checkout-payment-quantity input[type="number"]');if(a){const t=e.parseFormCheckoutProduct(a),o=isEmptyLadiPage(i)?1:parseInt(i.value);n.push({product_name:isObjectLadiPage(t)?t.name:"",price:isObjectLadiPage(t)?t.price:"",product_id:isObjectLadiPage(t)?t.product_id:null,product_variant_id:isObjectLadiPage(t)?t.product_variant_id:null,quantity:o})}});return n},g=function(t){let n=e.runtime.tmp[t+"_data_discount_coupon_selected"]||null,a=e.runtime.tmp[t+"_data_discount_shipping_selected"]||null,i=e.runtime.tmp[t+"_data_cart_promotions"]||null,o=0,r=0,c=0,d=0,s=0,u=0;try{const e=document.querySelector("#"+t+' [data-form-checkout-item="total_price"]');if(isEmptyLadiPage(e))return;let l=_(t)||[];if("none"!=window.getComputedStyle(e).display&&l.length>0){l.forEach(e=>{o+=e.price*e.quantity}),n&&n.discount_price?(d=o-n.discount_price,c=n.discount_price):d=o,i&&i.length>0&&(d-=r=n&&0==n.allow_promotion?0:i.reduce((e,t)=>t.discount?1==t.discount.type?t.price<=t.discount.value?e:e+t.price*(t.discount.value/100)*t.quantity:t.price<=t.discount.value?e:e+t.discount.value*t.quantity:e,0));const m=document.querySelector("#"+t+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(m)){const e=document.querySelector(".ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(e)){const t=e.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");if(!isEmptyLadiPage(t)){const e=JSON.parse(Base64.decode(t));isEmptyLadiPage(e)||(s=e.value,d+=e.value)}}}a&&(u=a.fee,d-=a.fee),d<0&&(d=0),p(e.id,o,r,c,d,s,u)}}catch(e){console.log("err.........",e)}},f=function(t){t.stopPropagation();var n=e.findAncestor(t.target,["ladi-form","ladi-element"]),a=e.findAncestor(t.target,"ladi-element"),i=n.id;if("fee_shipping"==a.getAttribute("data-form-checkout-item")){var o=e.findAncestor(t.target,"ladi-form-checkout-box"),r=o.querySelector(".ladi-form-checkout-payment-check, .ladi-form-checkout-method-shipping-check");if(r){var c=a.querySelectorAll(".ladi-form-item [data-shipping-method]");if(r.classList.contains("checked")&&1==c.length)return;r.classList.contains("multiple")?r.classList.toggle("checked"):(Array.from(o.parentElement.querySelectorAll(".ladi-form-checkout-payment-check.checked, .ladi-form-checkout-method-shipping-check.checked")).forEach(function(e){e.classList.remove("checked")}),r.classList.add("checked"))}const n=document.querySelector("#"+i+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(n)){const t=document.querySelector("#"+i+" .ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(t)){const n=t.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");if(!isEmptyLadiPage(n)){const t=JSON.parse(Base64.decode(n));isEmptyLadiPage(t)||(e.runtime.tmp[i+"_data_method_shipping_selected"]=t)}}}g(i)}},h=function(t){var n=window.ladi("_cart_token").get_cookie(),a={"Content-Type":"application/json"};isEmptyLadiPage(n)||(a["cart-token"]=n);let i={ladi_uid:e.runtime.store_ladiuid,show_all:!0,lang:"vi",is_ladipage:!0};e.sendRequest("POST",e.const.API_LADISALE_LIST_GATEWAY,JSON.stringify(i),!0,a,function(e,n,a){if(a.readyState==XMLHttpRequest.DONE)try{var i=JSON.parse(e);if(200==n)if(200!=i.code||isEmptyLadiPage(i.data))console.log("Response error: ",i.message);else{i.data.filter(e=>0==e.status).map(e=>e.code).forEach(e=>{const t=document.querySelector(`[data-payment-code="${e}"]`);t&&t.remove()});const e=document.querySelectorAll("#"+t+' [data-form-checkout-item="payment"] .ladi-form-checkout-box');if(1==e.length){e[0].style.borderBottom="none";const t=e[0].querySelector(".ladi-form-checkout-payment-check");t&&t.remove()}U()}}catch(i){console.log("err list gateway by ldp",i)}})},y=!0,v=function(t=null){const n=document.createElement("div");if(n.classList.add("ladi-form-checkout-box"),t){const e=JSON.stringify({shipping_method_name:t.name,shipping_method_id:t.shipping_method_id,value:t.fee});n.setAttribute("data-shipping-method",Base64.encode(e))}const a=document.createElement("div");a.classList.add("ladi-form-checkout-payment-item");const i=document.createElement("span");i.classList.add("ladi-form-checkout-payment-check","ladi-form-checkout-method-shipping-check"),i.style.cursor="pointer";const o=document.createElement("div");o.classList.add("ladi-form-checkout-payment-content","ladi-form-checkout-shipping-content"),o.style.justifyContent="space-between",o.style.flex="1 1 0%",o.style.cursor="pointer";const r=document.createElement("span");r.textContent=t?t.name:"";const c=document.createElement("span");return c.textContent=t?e.formatCurrency(t.fee,e.runtime.currency,!0):"",o.appendChild(r),o.appendChild(c),a.appendChild(i),a.appendChild(o),n.appendChild(a),n.addEventListener("click",f),n},E=function(t){const n=document.querySelector("#"+t+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(n)){const n=document.querySelector("#"+t+" .ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(n)){const a=n.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");if(!isEmptyLadiPage(a)){const n=JSON.parse(Base64.decode(a));isEmptyLadiPage(n)||(e.runtime.tmp[t+"_data_method_shipping_selected"]=n)}}}},k=function(t){const n=document.querySelector("#"+t+' [data-form-checkout-item="fee_shipping"]');isEmptyLadiPage(n)||(n.style.height="30px");const a=document.querySelector("#"+t+' [data-form-checkout-item="fee_shipping"] .ladi-form-item');a&&(a.innerHTML="");const i=[];i.forEach(function(){const e=v();a.appendChild(e)});var o=e.findAncestor(a,"ladi-element");o&&(0==i.length?o.style.setProperty("display","none","important"):o.style.removeProperty("display")),g(t)},L=function(t,n){var a=e.findAncestor(t.target,["ladi-form","ladi-element"]).id;let i=_(a)||[],o={store_id:e.runtime.store_id_int||null,state_id:n.state.split(":")[0],district_id:n.district.split(":")[0],discount_code:"",lang:"vi",variants:i};var r=window.ladi("_cart_token").get_cookie(),c={"Content-Type":"application/json"};isEmptyLadiPage(r)||(c["cart-token"]=r);const d=document.querySelector("#"+a+' [data-form-checkout-item="fee_shipping"]');isEmptyLadiPage(n.state)||isEmptyLadiPage(n.state)||!d||e.sendRequest("POST",e.const.API_LADISALE_GET_SHIPPING_METHODS,JSON.stringify(o),!0,c,function(t,n,i){if(i.readyState==XMLHttpRequest.DONE)try{var o=JSON.parse(t);200==n&&(200==o.code&&isObjectLadiPage(o.data)?(y=!1,function(t,n){const a=document.querySelector("#"+n+' [data-form-checkout-item="fee_shipping"]');isEmptyLadiPage(a)||(a.style.height=48*t.length+28+"px");const i=document.querySelector("#"+n+' [data-form-checkout-item="fee_shipping"] .ladi-form-item');i&&(i.innerHTML=""),t.forEach(function(e,t){const n=v(e);if(0==t){let e=n.querySelector(".ladi-form-checkout-payment-item .ladi-form-checkout-method-shipping-check");e&&e.classList.add("checked")}i.appendChild(n)});var o=e.findAncestor(i,"ladi-element");0==t.length?o.style.setProperty("display","none","important"):o.style.removeProperty("display"),g(n),E(n)}(o.data.shipping_methods,a)):y||k(a))}catch(o){console.log("err response.........",o)}})},P=async function(n){let a=e.runtime.store_id_int,i=window.ladi("_cart_token").get_cookie(),o={"Content-Type":"application/json"};isEmptyLadiPage(i)||(o["cart-token"]=i);let r={store_id:a},c=[],d=[];var s=e.findAncestor(n.target,["ladi-form","ladi-element"]),u=s.id;document.getElementById(u);var p=function(t){return 1==t.type?e.formatCurrency(t.value,"%",!0):e.formatCurrency(t.value,e.runtime.currency,!0)},l=function(e,t){return e.map(e=>{let n="shipping"===t?"data-coupon-shipping-code":"data-coupon-code",a="";return a="shipping"===t?`

${LadiPageScript.const.LANG.DISCOUNT_VALUE_SHIPPING_FEE.format(p(e))}

`:e.apply_to[1]?`

${LadiPageScript.const.LANG.DISCOUNT_TYPE_ORDER_PRODUCT_IN_CART.format(p(e))}

`:e.apply_to[2]?`

${LadiPageScript.const.LANG.DISCOUNT_TYPE_TAG_PRODUCT_IN_CART.format(p(e))}

`:`

${LadiPageScript.const.LANG.DISCOUNT_TYPE_PRODUCT_IN_CART.format(p(e))}

`,`\n
\n
\n

${e.code}

\n ${a}\n
\n
\n
\n
\n
\n `}).join("")};e.sendRequest("POST",e.const.API_LADISALE_LIST_COUPON_CODE,JSON.stringify(r),!0,o,function(a,i,o){try{if(o.readyState==XMLHttpRequest.DONE&&200==i){var r=JSON.parse(a);if(200==r.code&&isObjectLadiPage(r.data)){c=r.data.discounts||[],d=r.data.discountsShipping||[],LadiPageScript.showMessage(`\n \n
\n

${LadiPageScript.const.LANG.APPLY_COUPON_DISCOUNT}

\n
\n \n
\n
\n
\n
\n \n \n
\n
\n ${function(){let e=null;const n=document.querySelector("#"+u+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(n)){const t=document.querySelector(".ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(t)){const n=t.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");isEmptyLadiPage(n)||(e=JSON.parse(Base64.decode(n)))}}return!(isEmptyLadiPage(t.state)||isEmptyLadiPage(t.district)||isEmptyLadiPage(e))}()?`\n
\n
\n ${LadiPageScript.const.LANG.SHIPPING_DISCOUNT_FEE}

${LadiPageScript.const.LANG.YOU_CAN_CHOOSE_ONLY_ONE_DISCOUNT_CODE}

\n
\n ${l(d,"shipping")}\n
\n `:""}\n
\n
${LadiPageScript.const.LANG.COUPON_DISCOUNT_CODE}

${LadiPageScript.const.LANG.YOU_CAN_CHOOSE_ONLY_ONE_DISCOUNT_CODE}

\n ${l(c,"regular")}\n
\n
\n
\n \n `),document.body.style.overflow="hidden";let a=document.getElementById("action-close-modal-coupon-code");a&&a.addEventListener("click",function(){let e=document.querySelectorAll(".ladipage-message-close");e&&(e.forEach(function(e){e.click()}),document.body.style.overflow="")});let i=s.querySelector(".checkout-block-discount-coupon");const o=document.querySelectorAll(".coupon-item[data-coupon-shipping-code]");let g=i?i.getAttribute("data-coupon-shipping-code"):null;o.forEach(function(e){g&&o.forEach(function(e){let t=e.getAttribute("data-coupon-shipping-code");t&&t==g&&e.classList.add("checked")}),e.addEventListener("click",function(){o.forEach(function(e){e.classList.remove("checked")}),this.classList.add("checked")})});const f=document.querySelectorAll(".coupon-item[data-coupon-code]");let h=i?i.getAttribute("data-coupon-code"):null;f.forEach(function(e){h&&f.forEach(function(e){let t=e.getAttribute("data-coupon-code");t&&t==h&&e.classList.add("checked")}),e.addEventListener("click",function(e){f.forEach(function(e){e.classList.remove("checked")}),this.classList.add("checked")})});const y=document.getElementById("btn-cancel-coupon-code");y&&y.addEventListener("click",function(){let e=document.querySelectorAll(".ladipage-message-close");e&&(e.forEach(function(e){e.click()}),document.body.style.overflow="")});_(u);const v=document.getElementById("btn-confirm-coupon-code-form-checkout");v&&v.addEventListener("click",function(){let e=null,t="",n=document.querySelector(".order-coupon-code .coupon-item.checked"),a=document.querySelector(".shipping-code .coupon-item.checked");if(n&&(t=n.getAttribute("data-coupon-code")),a){const t=a.getAttribute("data-coupon-shipping-code"),n=document.querySelector("#"+u+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(n)){const n=document.querySelector(".ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(n)){const a=n.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");if(!isEmptyLadiPage(a)){e={code:t,shipping_method_id:JSON.parse(Base64.decode(a)).shipping_method_id}}}}}m(u,t,e)});const E=document.getElementById("button-apply-coupon-code-input");E&&E.addEventListener("click",e=>{let t=document.getElementById("input-enter-coupon-code").value,n=null,a=document.querySelector(".shipping-code .coupon-item.checked");if(a){const e=a.getAttribute("data-coupon-shipping-code"),t=document.querySelector("#"+u+' [data-form-checkout-item="fee_shipping"]');if(!isEmptyLadiPage(t)){const t=document.querySelector(".ladi-form-checkout-method-shipping-check.checked");if(!isEmptyLadiPage(t)){const a=t.closest(".ladi-form-checkout-box").getAttribute("data-shipping-method");if(!isEmptyLadiPage(a)){n={code:e,shipping_method_id:JSON.parse(Base64.decode(a)).shipping_method_id}}}}}m(u,t,n)})}}throw new TypeError("error")}catch(e){}var p})};Array.from(document.querySelectorAll("#action-show-popup-coupon-code")).forEach(function(e){e.addEventListener("click",P)});const b=window.location.search,A=new URLSearchParams(b).get("discount_code");if(A){let t=e.runtime.store_id_int,n=document.querySelectorAll(".ladi-form"),a=[];n&&n.length>0&&n.forEach(function(e){let t=e.closest("[id]");t&&t.id&&a.push(t.id)});let i=window.ladi("_cart_token").get_cookie(),o={"Content-Type":"application/json"};isEmptyLadiPage(i)||(o["cart-token"]=i);let r={store_id:t};e.sendRequest("POST",e.const.API_LADISALE_LIST_COUPON_CODE,JSON.stringify(r),!0,o,function(e,t,n){try{if(n.readyState==XMLHttpRequest.DONE&&200==t){var i=JSON.parse(e);if(200==i.code&&isObjectLadiPage(i.data)){let e=(i.data.discounts||[]).find(e=>e.code==A);e&&a&&a.length>0&&a.forEach(t=>{m(t,e.code)})}}}catch(e){console.log("Error api coupon")}})}for(var w=function(e){const t=document.querySelector("#"+e+" .overlay-checkout");t&&t.remove()},O=document.getElementsByClassName("ladi-form"),T=0;T0)if(0==t.querySelectorAll('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check.checked, [data-form-checkout-item="product"] .ladi-form-checkout-product-check.checked').length){var n=t.querySelector('[data-form-checkout-item="product"] .ladi-form-checkout-payment-check');n&&n.click()}}catch(e){}};for(T=0;T0)return t||i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,function(){var t=e.querySelector('[name="'+_[0]+'"]');isEmptyLadiPage(t)||t.focus()}),!1;var g=!0,f=0,h=function(){var t=e.querySelector('[name="'+O[f].name+'"]');isEmptyLadiPage(t)||t.focus()};for(f=0;ft)||(g=!1)}function d(e){if(isEmptyLadiPage(e))return;const t=e.value.replace(/\s/g,"").replace(/\./g,""),n=t.length<=r,a=e.getAttribute("pattern");if(a)try{const e=new RegExp(a);return n&&e.test(t)}catch(e){console.error("Invalid regular expression:",e)}return!isNaN(t)&&n}function s(e,t){if(!isEmptyLadiPage(e)){if(t)try{const n=t.replace(/^\/|\/$/g,"");return new RegExp(n).test(e)}catch(e){console.error("Invalid regular expression:",e)}return!0}}var u=Array.from(a).find(e=>"tel"===e.type);if(n.phone&&u){if(!d(u)||!c(n.phone.replace(/\s/g,"").replace(/\./g,""),r))return t||i.showMessage(i.const.LANG.FORM_INPUT_PHONE_ERROR,null,m),g=!1;o.push("phone")}if(n.email&&!c(n.email||"",50))return o.push("email"),t||i.showMessage(i.const.LANG.FORM_INPUT_EMAIL_ERROR,null,m),g=!1;if(!t&&n.name&&!c(n.name||"",500))return o.push("name"),i.showMessage(i.const.LANG.FORM_INPUT_NAME_ERROR,{max_length:500}),g=!1;if(!t&&n.message&&!c(n.message||"",2e3))return o.push("message"),i.showMessage(i.const.LANG.FORM_INPUT_MESSAGE_ERROR,{max_length:2e3}),g=!1;const p=["ward","district","state","country"];for(let e of p){const a=n[e];if(void 0===a||null===a)continue;const r=a.split(":")[1];if(!isEmptyLadiPage(r)&&!t&&r&&r.length>500){i.showMessage(i.const.LANG.FORM_INPUT_LOCATE_ERROR,{max_length:500}),o.push(e),g=!1;break}}for(let e of a){const n=e.name,a=e.value,u=e.placeholder;if(!o.includes(n)&&n){switch(e.type){case"text":if(!t){if(e.required&&isEmptyLadiPage(a))return i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,m),g=!1;if(a.length>500){const e={field_name:u||n,max_length:500};return i.showMessage(i.const.LANG.FORM_INPUT_TYPE_TEXT_ERROR,e),g=!1}}break;case"number":if(!t){if(e.required&&isEmptyLadiPage(a))return i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,m),g=!1;if(a&&(isNaN(a)||a.length>500))return i.showMessage(i.const.LANG.FORM_INPUT_TYPE_NUMBER_ERROR,{field_name:u||n,max_length:500}),g=!1}break;case"password":if(!t){if(e.required&&isEmptyLadiPage(a))return i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,m),g=!1;if(a&&a.length>500)return i.showMessage(i.const.LANG.FORM_INPUT_TYPE_TEXT_ERROR,{field_name:u||n,max_length:500}),g=!1}break;case"email":const o=e.getAttribute("pattern");if(e.required&&isEmptyLadiPage(a))return t||i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,m),g=!1;if(a&&(!c(a,50)||!s(a,o)))return t||i.showMessage(i.const.LANG.FORM_INPUT_EMAIL_ERROR,null,m),g=!1;break;case"tel":const p=a.replace(/\s/g,"").replace(/\./g,"");if(e.required&&isEmptyLadiPage(a))return t||i.showMessage(i.const.LANG.FORM_INPUT_REQUIRED_ERROR,null,m),g=!1;if(a&&(!d(e)||!c(p,r)))return t||i.showMessage(i.const.LANG.FORM_INPUT_PHONE_ERROR,null,m),g=!1}o.push(n)}}}(u),g},F=function(e,t){u={},p={},l={},m={};for(var n=e.querySelectorAll(".ladi-element .ladi-form-item-container [name]"),a={},o=null,r=0;r()\\[\\]\\\\.,;:\\s@"]+(\\.[^<>()\\[\\]\\\\.,;:\\s@"]+)*)|(".+"))@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\])|(([a-zA-Z\\-0-9]+\\.)+[a-zA-Z]{2,}))',pattern_flag:"gi",title:i.const.LANG.FORM_INPUT_EMAIL_REGEX}):isEmptyLadiPage(v)||O.push({name:o,pattern:v,title:isEmptyLadiPage(E)?i.const.LANG.FORM_INPUT_TEXT_REGEX:E}),"checkbox"==y){isArrayLadiPage(u[o])||(u[o]=[]),n[h].checked&&u[o].push(n[h].value);continue}if("radio"==y){n[h].checked&&(u[o]=n[h].value);continue}}if(u[o]=n[h].value,n[h].classList.contains("ladi-form-control-file")&&(u[o]=JSON.parse(n[h].getAttribute("data-path-file")||"[]"),m[o]=!0),"coupon"==o&&"INPUT"==n[h].tagName&&"text"==y&&"true"==n[h].getAttribute("data-replace-coupon")&&(u[o]=i.runtime.tmp.current_use_coupon||""),"INPUT"==n[h].tagName&&"date"==y&&!isEmptyLadiPage(u[o])){var k=n[h].getAttribute("date-format")||"dd-mm-yyyy",L=new Date(u[o]),P=k;P=(P=(P=(P=P.replaceAll("dd",(L.getDate()<10?"0":"")+L.getDate())).replaceAll("mm",(L.getMonth()+1<10?"0":"")+(L.getMonth()+1))).replaceAll("yyyy",L.getFullYear())).replaceAll("yy",L.getFullYear()-2e3),u[o]=P,p[o]=k}}return t||N.forEach(function(e){isNullLadiPage(u[e])||i.setCookieDomains("_ladipage_"+e,Base64.encode(u[e]),365)}),_=i.runtime.tmp.convertFormDataObjectCountry(u),{formDataObject:u}},I=function(e,t,a,c,l){var _=i.runtime.website_id,g={form_config_id:h,ladi_form_id:v,ladipage_id:i.runtime.ladipage_id,tracking_form:[],form_data:[],data_key:c};if(isEmptyLadiPage(_)||(g.website_id=_),a)g.status_send=i.const.STATUS_SEND.capture;else if(g.status_send=i.const.STATUS_SEND.sendform,T){var w=window.ladi("_checkout_token").get_cookie();isEmptyLadiPage(w)||(g.checkout_token=w)}try{Array.from(document.querySelectorAll("#"+v+' .ladi-element[data-form-checkout-item="product"] .ladi-form-checkout-payment-check.checked')).forEach(function(e){var t=i.findAncestor(e,"ladi-form-checkout-box"),n=i.parseFormCheckoutProduct(t);n.quantity=1;var a=t.querySelector(".ladi-form-checkout-payment-quantity input");isEmptyLadiPage(a)||(n.quantity=parseInt(a.value)||n.quantity),isArrayLadiPage(g.product_checkout)||(g.product_checkout=[]),g.product_checkout.push(`${n.product_variant_id}:${n.quantity}:${n.price}::|${n.name}`)});const e=document.getElementById(`${v}`).querySelector("[data-shipping-fee][data-shipping-name]");if(e){const t=e.getAttribute("data-shipping-fee"),n=e.getAttribute("data-shipping-name");g.shipping_lines=[{title:n,price:t}]}}catch(e){}var O=document.querySelector("#"+v+' div[data-is-merge-address="true"]'),N=!!O&&"true"==O.getAttribute("value");if(isEmptyLadiPage(N)||(g.merge_address=N),isEmptyLadiPage(t.voucher_id)||(g.voucher_id=t.voucher_id),isEmptyLadiPage(t.voucher_code)||(g.voucher_code=t.voucher_code),!isEmptyLadiPage(E)){var C=E.getElementsByClassName("ladiflow-widget")[0];isEmptyLadiPage(C)||(isObjectLadiPage(g.options)||(g.options={}),g.options.ladiflow_trigger_id=C.getAttribute("ladiflow-trigger-id"),g.options.ladiflow_ref=C.getAttribute("ladiflow-ref"),g.options.ladiflow_page_id=C.getAttribute("page_id"),g.options.ladiflow_checkbox_user_ref=C.getAttribute("user_ref"),g.options.ladiflow_store_id=C.getAttribute("ladiflow-store-id"),d=1e3,s=function(){isObjectLadiPage(window.LadiFlow)&&isFunctionLadiPage(window.LadiFlow.resetWidgetCheckbox)&&window.LadiFlow.resetWidgetCheckbox(C.id)})}isEmptyLadiPage(k)||["option.sync_ladisales_form_account_id","option.sync_ladiflow_form_account_id","option.sync_ladishare_form_account_id","option.sync_ladichat_form_account_id"].forEach(function(e){isEmptyLadiPage(k[e])||(isObjectLadiPage(g.options)||(g.options={}),isArrayLadiPage(g.options.external_form_config_ids)||(g.options.external_form_config_ids=[]),g.options.external_form_config_ids.push(k[e]))}),t.isFormOtp&&!isEmptyLadiPage(y)&&(isObjectLadiPage(g.options)||(g.options={}),isObjectLadiPage(g.options.external_otp_config)||(g.options.external_otp_config={}),g.options.external_otp_config.otp_config_id=y),isObjectLadiPage(g.options)&&(g.options=JSON.stringify(g.options)),isEmptyLadiPage(L)||(g.total_revenue=L),isEmptyLadiPage(i.runtime.time_zone)||(g.time_zone=i.runtime.time_zone);var R=Object.keys(LadiFormApi);if((f=function(e){var t=[],n=0,a=["state","district","ward"];for(n=0;n0&&t.push("country"),isEmptyLadiPage(o)||t.except(["ward"]),n=t.length;n'+l[m].getAttribute("data-placeholder")+""),l[m].setAttribute("data-selected","");for(var _=document.querySelectorAll(".ladi-google-recaptcha-checkbox[data-widget-id]"),g=0;g<_.length;g++){var f=_[g].getAttribute("data-widget-id");isEmptyLadiPage(f)||window.grecaptcha&&isObjectLadiPage(i.runtime.tmp.google_captcha)&&i.runtime.tmp.google_captcha.checkbox&&isFunctionLadiPage(window.grecaptcha.reset)&&window.grecaptcha.reset(f)}var h=document.querySelectorAll(".ladi-form .ladi-form-checkbox-box-item");for(g=0;g0){var t=!1;-1!=[i.const.FORM_CONFIG_TYPE.haravan,i.const.FORM_CONFIG_TYPE.wordpress].indexOf(i.runtime.shopping_product_type)&&(t=!0);var n=i.runtime.tmp.cart[0];return n=JSON.stringify(n),n=encodeURIComponent(n),void i.removeAddToCartProduct(n,!1,t,function(t){t?he(e):isFunctionLadiPage(e)&&e()})}-1!=[i.const.FORM_CONFIG_TYPE.ladisales].indexOf(i.runtime.shopping_product_type)&&(window.ladi("_cart_token").delete_cookie(),window.ladi("_checkout_token").delete_cookie(),i.createCartData()),isFunctionLadiPage(e)&&e()},ye=function(e,n,a,o){if(a.readyState==XMLHttpRequest.DONE){var r={};try{r=JSON.parse(e)}catch(e){}r=isObjectLadiPage(r)?r:{},o==i.const.API_FORM_DATA?(200==r.code?ce++:(1!=r.code||isEmptyLadiPage(r.message)||(se=r.message),de++,ge=!1),r.code||(navigator.onLine?(se=i.convertDataReplaceStr(i.const.LANG.MESSEAGE_NETWORK_HAS_CONNECT_BUT_NO_CODE_DATA,!1,null,!1,{status:n}),ue=!0):se=i.const.LANG.MESSEAGE_NETWORK_ERROR)):200==n||201==n?ce++:i.getElementAHref(o).host==i.const.DOMAIN_GOOGLE_DOCS?ce++:de++,ce+de==le.length&&(ge&&!me&&ce>=1?(me=!0,c.isResendOtp||(i.runtime.tmp.form_data_current=u),isFunctionLadiPage(c.callbackOtp)&&c.callbackOtp(!0),isObjectLadiPage(c)&&isFunctionLadiPage(c.callbackThankyou)?(V(),c.callbackThankyou(c,function(){he(function(){fe(!0),i.runtime.tmp.current_use_coupon=null})})):(G(),function(e,t,n){var a=null,o=!1,r=function(e,t){o||(isFunctionLadiPage(n)&&n(e,t),i.removeTimeout(a),o=!0)};a=i.runTimeout(r,3e3),i.runtime.tmp.runTrackingAnalytics("FormSubmit",{ladi_form_id:e,total_revenue:t},r)}(t.id,L,function(e,n){i.runEventTracking(t.id,{is_return_string:c.isSendFormCheckout,is_form:!0,event:{target:$}},u),window.ladi("_capture_"+t.id).delete_cookie(),isObjectLadiPage(c)&&isFunctionLadiPage(c.callbackOtpDone)&&c.callbackOtpDone(),he(function(){i.runTimeout(function(){i.runtime.tmp.current_use_coupon=null,ie(),fe(!0)},500)})}))):!_e&&de>=1&&(isFunctionLadiPage(c.callbackOtp)&&c.callbackOtp(!1),_e=!0,i.showMessage(se||i.const.LANG.REQUEST_SEND_ERROR),ue&&!isEmptyLadiPage(pe)&&(pe=JSON.parse(pe),i.sendRequest("POST",i.const.API_FORM_DATA_ERROR_RESPONSE,pe.data,pe.async,pe.headers),pe=null),fe(!1)))}},ve=function(e){le.push({url:i.const.API_FORM_DATA,data:JSON.stringify(e),async:!0,headers:{"Content-Type":"application/json"},callback:ye}),pe=JSON.stringify(le[le.length-1])};W&&I(0,c,a,o,ve),isArrayLadiPage(z)&&z.forEach(function(e){if(!isEmptyLadiPage(e.api_url)&&isArrayLadiPage(e.custom_fields)){var t=i.getElementAHref(e.api_url).host==i.const.DOMAIN_GOOGLE_DOCS,n={},a=null,o=null,r=null,c=null;e.custom_fields.forEach(function(e){if(T&&("cart_products"==e.ladi_name&&(a=e.name),"cart_revenue"==e.ladi_name&&(o=e.name),"cart_shipping"==e.ladi_name&&(r=e.name),"cart_coupon_amount"==e.ladi_name&&(c=e.name)),!m[e.ladi_name]){var t=_[e.ladi_name];isNullLadiPage(t)||(isArrayLadiPage(t)?0==t.length?n[e.name]="":n[e.name]=JSON.stringify(t):n[e.name]=t)}}),isEmptyLadiPage(a)||isNullLadiPage(P)||(n[a]=JSON.stringify(P)),isEmptyLadiPage(o)||isNullLadiPage(L)||(n[o]=L),isEmptyLadiPage(r)||isNullLadiPage(i.runtime.tmp.add_to_cart_shipping_method_id)||(n[r]=i.runtime.tmp.add_to_cart_shipping_method_id+"|"+(i.runtime.tmp.add_to_cart_fee_shipping||0)),isEmptyLadiPage(c)||isEmptyLadiPage(i.runtime.tmp.current_use_coupon)||(n[c]=i.runtime.tmp.add_to_cart_discount||0);var d={};if(!isEmptyLadiPage(e.api_request_header))try{var s=JSON.parse(e.api_request_header);Object.keys(s).forEach(function(e){d[e]=s[e]})}catch(e){}if(!t)n.link=window.location.href,i.runtime.has_popupx&&(n.origin_link=i.runtime.tmp.popupx_origin_url),Object.keys(LadiFormApi).forEach(function(e){n[e]=LadiFormApi[e]}),x.forEach(function(e){var t=S[e];isNullLadiPage(t)||(n[e]=t)});var u=null,p=e.content_type||i.const.CONTENT_TYPE.form_urlencoded;if(p==i.const.CONTENT_TYPE.form_urlencoded&&(d["Content-Type"]="application/x-www-form-urlencoded",u=Object.keys(n).reduce(function(e,t){return e.push(t+"="+encodeURIComponent(n[t])),e},[]).join("&")),p==i.const.CONTENT_TYPE.json&&(d["Content-Type"]="application/json",u=JSON.stringify(n)),p==i.const.CONTENT_TYPE.form_data)u=new FormData,Object.keys(n).forEach(function(e){u.append(e,n[e])});le.push({url:e.api_url,data:u,async:!0,headers:d,callback:ye})}});(le.length>0||!W)&&K(),i.runTimeout(function(){0==le.length&&(W?j(0,c,N,o):I(0,c,a,o,ve)),le.forEach(function(e){i.sendRequest("POST",e.url,e.data,e.async,e.headers,e.callback)})},d)}}}}}},J=function(e){var t=i.findAncestor(e.target,"ladi-element");if(!isEmptyLadiPage(t))for(var n=t.querySelectorAll('[type="checkbox"]'),a=0;a0){y[0].setAttribute("required","required");for(var v=0;v0}))i.showMessage(i.const.LANG.ADD_TO_CART_PRODUCT_ONLY_ONE,{name:i.getMessageNameProduct(o.product.variants[s])});else{var v=i.runtime.tmp.cart.findIndex(function(e){return e.product_variant_id==u}),E=!1;if(-1==v){E=!0;var k={store_id:o.store_info.id,product_id:l,product_variant_id:u,name:m,title:_,price:g,image:y,quantity:0,min_buy:o.product.variants[s].min_buy,max_buy:o.product.variants[s].max_buy,inventory_checked:o.product.variants[s].inventory_checked,available_quantity:f,currency:o.store_info.currency,product_type:o.product.variants[s].product_type,package_quantity:o.product.variants[s].package_quantity};isObjectLadiPage(k.currency)&&!isEmptyLadiPage(k.currency.code)&&(k.currency.symbol=i.formatCurrency(null,k.currency.code,!1,!0)),i.runtime.tmp.cart.push(k),v=i.runtime.tmp.cart.length-1}var L=c.querySelector('input[name="quantity"]');if(isEmptyLadiPage(L)||isEmptyLadiPage(L.value))i.showMessage(i.const.LANG.ADD_TO_CART_QUANTITY_REQUIRED);else{var P=parseInt(L.value)||0;if(P<=0)return void i.showMessage(i.const.LANG.ADD_TO_CART_QUANTITY_REQUIRED);var b=null,A=1;A=o.product.variants[s].min_buy||A;var w=o.product.variants[s].max_buy;A>i.runtime.tmp.cart[v].quantity+P&&(P=A-i.runtime.tmp.cart[v].quantity);var O=!1;if(!isEmptyLadiPage(w)&&i.runtime.tmp.cart[v].quantity+P>w&&(P=w-i.runtime.tmp.cart[v].quantity)<=0&&(O=!0,b=w),1==o.product.variants[s].inventory_checked){if(A>f)return void i.showMessage(i.const.LANG.ADD_TO_CART_NO_QUANTITY,{name:i.getMessageNameProduct(o.product.variants[s],!0)});i.runtime.tmp.cart[v].quantity+P>f&&(P=f-i.runtime.tmp.cart[v].quantity,f>0&&(O=!0,(isEmptyLadiPage(b)||b>f)&&(b=f)))}if(O||P<=0&&f>0)i.showMessage(i.const.LANG.ADD_TO_CART_MAX_QUANTITY,{max:b,name:i.getMessageNameProduct(o.product.variants[s])},function(){var t=e.target;t=i.findAncestor(t,"ladi-button"),isEmptyLadiPage(t)||(t=i.findAncestor(t,"ladi-element"));var n=i.runtime.eventData[t.id];if(!isEmptyLadiPage(n)){var a=n["option.data_event"];if(!isArrayLadiPage(a)&&(a=[],isObjectLadiPage(n["option.data_action"]))){var o=i.copy(n["option.data_action"]);o.action_type=i.const.ACTION_TYPE.action,a.push(o)}a.forEach(function(e){e.action_type==i.const.ACTION_TYPE.action&&(e.type==i.const.DATA_ACTION_TYPE.popup_cart&&window.ladi("POPUP_CART").show(),e.type==i.const.DATA_ACTION_TYPE.popup_checkout&&(i.runtime.shopping_third_party?i.getThirdPartyCheckoutUrl(!0,null,{event:{target:r}}):window.ladi("POPUP_CHECKOUT").show(!1,{event:{target:r}})))})}});else if(P>0){var T=!isEmptyLadiPage(o.product.variants[s].start_date)&&new Date(o.product.variants[s].start_date).getTime()>Date.now(),S=!isEmptyLadiPage(o.product.variants[s].end_date)&&new Date(o.product.variants[s].end_date).getTime()0&&(t[o].value=r,Z&&i.fireEvent(t[o],"change"));else{if("country"==e&&"true"==t[o].getAttribute("data-is-select-country"))continue;"INPUT"==t[o].tagName&&"true"==t[o].getAttribute("data-is-select-country")&&2==(n=r.split(":")).length&&(r=n[1]),t[o].value=r,Z&&i.fireEvent(t[o],"change")}}},te=function(e){e.target.type="date",e.target.focus()},ne=function(e){isEmptyLadiPage(e.target.value)&&(e.target.type="text")};for(X=0;Xme&&(me=_e),le[pe].setAttribute("tabindex",i.runtime.tabindexForm+_e);for(le=c[X].querySelectorAll("[data-tabindex]"),pe=0;peme&&(me=_e),le[pe].setAttribute("data-tabindex",i.runtime.tabindexForm+_e);i.runtime.tabindexForm+=me;for(var ge=0;gea?1:-1},d=function(n){var a=window.LadiLocation[t];if(isObjectLadiPage(a)){var i=a.data[n];isEmptyLadiPage(i)||(e+='")}},s=function(e){var t=window.LadiLocation[e.target.getAttribute("data-country")];if(isObjectLadiPage(t)){var a=t.data[e.target.value.split(":")[0]];if(n="",!isEmptyLadiPage(a)&&isObjectLadiPage(a.data)){var c=Object.keys(a.data);o=a.data,c.sort(r),c.forEach(function(e){var t=a.data[e];n+='"})}var d=i.findAncestor(e.target,"ladi-element");if(!isEmptyLadiPage(d)){var s=d.querySelector('[name="district"]');isEmptyLadiPage(s)||"SELECT"==s.tagName&&(s.setAttribute("data-selected",""),s.innerHTML=s.querySelector("option").outerHTML+n);var u=d.querySelector('[name="ward"]');isEmptyLadiPage(u)||"SELECT"==u.tagName&&(u.setAttribute("data-selected",""),u.innerHTML=u.querySelector("option").outerHTML),LadiPageShopping.push(function(){i.reloadFeeShipping({target:u})})}}},u=function(e){var t=i.findAncestor(e.target,"ladi-element");if(!isEmptyLadiPage(t)){var n=t.querySelector('[name="ward"]');if(!isEmptyLadiPage(n)){a="";var c=t.querySelector('select[name="state"]');if(!isEmptyLadiPage(c)){var d=c.getAttribute("data-selected");if(!isEmptyLadiPage(d)){d=d.split(":")[0];var s=window.LadiLocation[c.getAttribute("data-country")];if(isObjectLadiPage(s)){var u=s.data[d];if(!isEmptyLadiPage(u)&&isObjectLadiPage(u.data)){var p=u.data[e.target.value.split(":")[0]];if(!isEmptyLadiPage(p)){var l=Object.keys(p.data);o=p.data,l.sort(r),l.forEach(function(e){var t=p.data[e];a+='"})}}}}}"SELECT"==n.tagName&&(n.setAttribute("data-selected",""),n.innerHTML=n.querySelector("option").outerHTML+a);var m=t.querySelector('[name="district"]');isEmptyLadiPage(m)||"SELECT"!=m.tagName||LadiPageShopping.push(function(){i.reloadFeeShipping({target:n})})}}},p=function(e){var t=i.findAncestor(e.target,"ladi-element");if(!isEmptyLadiPage(t)){var n=t.querySelector('[name="ward"]');isEmptyLadiPage(n)||"SELECT"!=n.tagName||LadiPageShopping.push(function(){i.reloadFeeShipping()})}};for(X=0;X .ladi-element [name="'+e+'"]');isEmptyLadiPage(t)||(t=i.findAncestor(t,"ladi-element"),window.ladi(t.id).value(n[e]))})}Object.keys(n).forEach(function(e){i.setDataReplaceStr(e,n[e])});var s=null,u=i.findAncestor(r,["ladi-popup","ladi-element"]);isEmptyLadiPage(u)||(s=u.id),i.setDataReplaceElement(!1,!1,null,s)}},LadiPageScriptV2.prototype.setFrequencyFormSubmit=function(e){this.frequencyFormDataByKey({addValue:1,expires:365,key:"submit_form",form_id:e}),this.frequencyFormDataByKey({addValue:1,key:"view",form_id:e}),this.frequencyFormDataByKey({addValue:1,expires:365,key:"guest",form_id:e}),this.frequencyFormDataByKey({addValue:1,key:"session",form_id:e}),this.frequencyFormDataByKey({addValue:1,expires:1/24,key:"hour",form_id:e}),this.frequencyFormDataByKey({addValue:1,expires:1,key:"day",form_id:e}),this.frequencyFormDataByKey({addValue:1,expires:7,key:"week",form_id:e}),this.frequencyFormDataByKey({addValue:1,expires:30,key:"month",form_id:e})},LadiPageScriptV2.prototype.setEventDataFormDynamic=function(e){var t,n,a,i,o,r=this;if(isObjectLadiPage(r.runtime.eventData[e])&&!isEmptyLadiPage(r.runtime.eventData[e]["option.dynamic_form_config"]))try{var c=JSON.parse(r.runtime.eventData[e]["option.dynamic_form_config"]);c.configs=isArrayLadiPage(c.configs)?c.configs:[],c.default_actions=isArrayLadiPage(c.default_actions)?c.default_actions:[];for(var d=r.copy(r.runtime.eventData[e]),s=function(e,t,n){var a=!1;"NOT_CONTAINS"!=t&&"NOT_STARTS_WITH"!=t&&"NOT_ENDS_WITH"!=t&&"!="!=t&&"NOT_IN"!=t||(a=!0);var i=isEmptyLadiPage(n)?"":n;i=(i=isStringLadiPage(i)?i:String(i)).toLowerCase();for(var o=0==n?0:parseFloatLadiPage(n)||null,r=0;r"==t&&o>d){a=!0;break}if(">="==t&&o>=d){a=!0;break}if("<"==t&&o=c&&n<=d){a=!0;break}if("NOT_FROM_TO"==t&&n>=c&&n<=d){a=!1;break}}return a},_=function(e,t,n){var a=new Date(n);return s(e,t,a.getDay())},g=function(e,t,n){var a=Math.floor((Date.now()-r.runtime.timerefresh)/1e3),i=Math.round((window.scrollY+r.getHeightDevice())/document.body.clientHeight*100);i=i>100?100:i;var o=r.frequencyFormDataByKey({getValue:!0,key:"submit_form"}),c=r.frequencyFormDataByKey({getValue:!0,key:"page_view"});return"form_submit"==n?s(e,t,o):"page_view"==n?s(e,t,c):"time_on_page"==n?s(e,t,a):"scroll_page"==n?s(e,t,i):void 0},f=0;fe.const.FORM_UPLOAD_FILE_LENGTH)e.showMessage(e.const.LANG.FORM_UPLOAD_FILE_MAX_LENGTH_ERROR,{max_length:e.const.FORM_UPLOAD_FILE_LENGTH});else{for(var i=new FormData,o=0,r=0;r1024*e.const.FORM_UPLOAD_FILE_SIZE*1024)e.showMessage(e.const.LANG.FORM_UPLOAD_FILE_MAX_SIZE_ERROR,{max_size:e.const.FORM_UPLOAD_FILE_SIZE});else{var c={ladipage_id:e.runtime.ladipage_id,lang:e.runtime.lang};i.append("json_data",JSON.stringify(c)),e.showLoadingBlur(),e.sendRequest("POST",e.const.API_FILE_UPLOAD,i,!0,null,function(n,a,i){if(i.readyState==XMLHttpRequest.DONE){if(e.hideLoadingBlur(),200==a)try{var o=JSON.parse(n);if(200==o.code){var r=[],c=[];return o.data.success.forEach(function(e){r.push(e.name),c.push({id:e._id,path:e.path,name:e.name})}),t.value=r.length>0?"["+r.join(", ")+"]":"",void t.setAttribute("data-path-file",JSON.stringify(c))}if(!isEmptyLadiPage(o.message))return void e.showMessage(o.message)}catch(e){}e.showMessage(e.const.LANG.REQUEST_SEND_ERROR)}}),isFunctionLadiPage(a)&&a()}}}(n=document.querySelector('[data-click-id="'+t.target.getAttribute("data-file-click-id")+'"]'),t.target.files,function(){t.target.value=null})})),i.click()},a=0;a