(function(c){const b=()=>{var e;try{const t=document.getElementById("es-script").getAttribute("src");c.ES_EX_VERSION=(e=t.split("/assets")[0].split("/")[t.split("/assets")[0].split("/").length-1])==null?void 0:e.replace("easysell-cod-form-upsells-",""),console.log("production",c.ES_EX_VERSION)}catch{console.log("production")}console.log("%c EasySell COD Form & Upsells","font-weight: bold; font-size: 14px;color: rgb(2,135,206); text-shadow: 3px 3px 0 rgb(2,135,206) 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)"),console.log("%c https://apps.shopify.com/easy-order-form","font-weight: bold; font-size: 14px;color: rgb(2,135,206); text-shadow: 3px 3px 0 rgb(2,135,206) 15px 15px 0 rgb(2,135,206) , 18px 18px 0 rgb(4,77,145) , 21px 21px 0 rgb(42,21,113)")},O=(e,t)=>{const n=t.find(a=>a.value==="email"),r=t.find(a=>a.value==="phone"),o=t.find(a=>a.value==="discount");let s=`${c.location.origin}/cart/`;e.itemCount>0&&e.items.forEach(a=>s+=`${a.variant_id}:${a.quantity},`),s+="?",o&&o.valid===!0&&(s+=`discount=${o.model}&`),n&&!n.hasError&&n.model?s+=`checkout[email]=${n.model}&`:r&&!r.hasError&&r.model&&!c.ONLY_USE_EMAIL_FOR_CHECKOUT&&(s+=`checkout[email]=${r.model}&`);const i=["first_name","last_name","phone","address","address2","city","province","country","zip","company"],u=t.filter(a=>i.includes(a.value));return u.forEach(a=>{let l=a.model;!a.hasError&&l&&(typeof l=="object"&&(l=l.value),s+=`checkout[shipping_address][${a.value}]=${l}&`)}),u.forEach(a=>{let l=a.model;!a.hasError&&l&&(typeof l=="object"&&(l=l.value),s+=`checkout[billing_address][${a.value}]=${l}&`)}),s=s.replace("[address]","[address1]"),s};function C(e,t,n,r){var i,u;const o=e==null?void 0:e.filter(a=>["select","text","textarea","radio","checkbox","date"].includes(a.type)&&a.model).map(a=>{if(a.title&&a.model!==a.prefix){let l=null;return typeof a.model=="object"?l=a.model.label??null:l=a.model??null,l?`*${a.title??""}*: ${l}`:""}else return""}).join("%0a");let s=(i=t.items)==null?void 0:i.map(a=>`${a.title??""}`).join(" - ");return c.location.href.indexOf("/products")!==-1&&(s+=` ${"https://"+location.host+location.pathname}`),n=(u=n==null?void 0:n.replace("+",""))==null?void 0:u.replace(/\s/g,""),r=(r??"").replace("{url}",s).replace("{total}",c.ES_TOTAL),`https://wa.me/${n}?text=${encodeURIComponent(r)}%0a${o}`}function T(e,t,n){var r;return n=n.replace("{{variant:quantity}}",((r=t.items)==null?void 0:r.map(o=>`${o.variant_id}:${o.quantity}`).join(","))??""),e==null||e.forEach(o=>{const s=o.model?typeof o.model=="object"?o.model.value:o.model:"";n=n.replace(`{{${o.value}}}`,s)}),n.indexOf("/")===0&&(n=c.Shopify.routes.root+n.substring(1)),n}const R=()=>{let e=!1;try{e=!!JSON.parse(document.querySelector("gp-product").getAttribute("gp-context")).productId||c.__gemStoreData!==void 0}catch{}return c.__pageflyProducts!==void 0||e||c.ES_IS_PAGEBUILDER===!0},v=()=>{const e=document.querySelector('[data-pf-type="ProductATC"]');if(e)return e;const t=document.querySelectorAll('form[method="post"][action*="/cart/add"]');for(let n=0;n1&&!s||i)return r}return document.getElementById("new-form")||(t==null?void 0:t[0])||null},A=()=>{let t=document.querySelectorAll('form[method="post"][action$="/cart"], form[method="post"][action$="/checkout"], form[method="post"][action*="/cart?"], form[method="post"][action*="/checkout?"]');c.ES_CART_SELECTORS_EMBD_OVERWRITE!==void 0&&(t=document.querySelectorAll(c.ES_CART_SELECTORS_EMBD_OVERWRITE));let n=null;for(let r=0;r{document.body.insertAdjacentHTML("beforeend",`
×
${e}
`),document.getElementById("es-thanks-modal").style.display="block"},I=()=>{document.querySelectorAll(`.${c.EPBS}`).forEach(t=>{var n;return(n=t.parentNode)==null?void 0:n.removeChild(t)}),document.getElementById("easysell").style.display="none",document.querySelector("#easysell-modal").style.display="none";const e=document.getElementById("es-not-eligible-modal");e&&(e.style.display="block")},L=(e,t,n="click")=>{document.querySelectorAll(e).forEach(r=>{r.removeEventListener(n,t),r.addEventListener(n,t)})},$=e=>{document.querySelectorAll(e).forEach(t=>{t.parentNode.removeChild(t)})},F=e=>{if(S(e.globalCSS),e.formStyle){const{iconColor:t,iconBackground:n}=e.formStyle,r=[t&&`.es-input-group-text{color:${t} !important;}`,n&&`.es-input-group-text{background-color:${n} !important;}`].filter(Boolean);r.length&&S(r.join(` `))}},S=e=>{const t=document.createElement("style");t.innerHTML=e,document.head.appendChild(t)},x=e=>{const t=document.createElement("script");t.innerHTML=e,document.body.appendChild(t)},D=e=>{const t=document.getElementById("es-css");t&&(t.disabled=!e,e?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled"))},E=(e=null)=>{var r,o,s,i;const t=u=>{const a=new FormData(u),l=new URLSearchParams;for(const[m,d]of a)l.append(m,d);return l},n=document.querySelector('[name="es-quantity-picker"]');if(n!=null&&n.value)return parseInt(n.value);if(e){if(c.ES_QUANTITY_SELECTOR_OVERRIDE){const a=document.querySelector(c.ES_QUANTITY_SELECTOR_OVERRIDE);if(!isNaN(a==null?void 0:a.value))return parseInt(a.value)}try{if(c.ES_CLOSEST_FORM){const a=t(c.ES_CLOSEST_FORM);if(a.get("id")===e&&a.get("quantity")&&!isNaN(a.get("quantity")))return parseInt(a.get("quantity"))}}catch(a){console.error(a)}let u=(r=document.querySelector(`input[name="updates[]"][data-id^="${e}"]`))==null?void 0:r.getAttribute("value");if(u||(u=(o=document.querySelector(`input[name="updates[]"][data-quantity-variant-id^="${e}"]`))==null?void 0:o.getAttribute("value")),u&&!isNaN(u)&&`${u}`!=`${e}`)return parseInt(u);if(!u){const a=document.querySelectorAll("#CartDrawer-Form .drawer__cart-item__quantity");if(a.length)for(let l=0;l{var n,r,o,s,i,u,a;if(c.ES_VARIANT_SELECTOR_OVERRIDE){const l=document.querySelector(c.ES_VARIANT_SELECTOR_OVERRIDE);if(l&&((n=l.value)!=null&&n.trim()))return l.value.trim()}if(c.ES_CLOSEST_FORM){const l=c.ES_CLOSEST_FORM,m=l.querySelector("[name='id']");if(m){const d=m.getAttribute("value");if(d)return d;const y=m.value;if(y)return y;const h=(r=l.querySelector("[name='id'] option:not([disabled])"))==null?void 0:r.getAttribute("value");if(h)return h}}let e=g("variant");if(e&&e===c.ShopifyAnalytics.meta.selectedVariantId)return e;let t=(o=document.querySelector('[action$="/cart/add"]'))==null?void 0:o.querySelector("[name='id']");if((s=t==null?void 0:t.value)!=null&&s.trim()||(t=((u=(i=document.querySelector('form[method="post"] [name="add"]'))==null?void 0:i.closest("form"))==null?void 0:u.querySelector("[name='id']"))??document.querySelector("[name='id']")),(a=t==null?void 0:t.value)!=null&&a.trim())return t.value.trim();if(c.ES_SECTION_PRODUCT_HANDLE){const l=c.ES_SECTION_PRODUCT.variants.map(m=>`${m.id}`);return e&&l.includes(e)?e:c.ES_SECTION_PRODUCT.variants[0].id}return e||null},g=function(e){return new URL(c.location.href).searchParams.get(e)};function M(){var r;const e=document.getElementById("es-sticky");document.body.appendChild(e);const t=o=>{e.style.display=o?"flex":"none"},n=o=>{const s=o.getBoundingClientRect();return s.top>=0&&s.top<=c.innerHeight||s.bottom>=0&&s.bottom<=c.innerHeight};if(c.EASYSELL_CONFIG.settings.form_type==="popup"){const o=(r=document.querySelectorAll(".es-popup-button-product, .es-popup-button-cart"))==null?void 0:r[0];if(!o)return;const s=o.getBoundingClientRect().top+c.scrollY;document.addEventListener("scroll",()=>{t(s{t(!n(o))})}}function N(){var e;try{let t={};if(document.querySelector("#prvw__bundle_container")&&(t=(r=>Object.fromEntries([...r.querySelectorAll('input[name$="[id]"], input[name="id"]')].map(o=>{const s=o.name==="id"?r.querySelector('input[name="quantity"]'):r.querySelector(`input[name="items[${o.name.match(/\[(\d+)\]/)[1]}][quantity]"]`);return[o.value,parseInt((s==null?void 0:s.value)||1)]})))(document.querySelector(".es-popup-button-product").closest("form"))),((e=c.wideBundle)==null?void 0:e.isAutomaticDiscount)===!0&&(t=wideBundle.getSelectedVariantId().reduce((r,o)=>(r[o]=(r[o]||0)+1,r),{})),Object.keys(t).length>0)return t}catch{}}const k=()=>{var e,t;if(c.ES_CLOSEST_FORM||c.ES_PROPERTIES_FORM_SELECTOR){const n=c.ES_PROPERTIES_FORM_SELECTOR?document.querySelector(c.ES_PROPERTIES_FORM_SELECTOR):c.ES_CLOSEST_FORM;try{const r={};if((n?new FormData(n):(t=(e=c.ymq_option)==null?void 0:e.productInstance)==null?void 0:t.formData).forEach(function(s,i){i.startsWith("properties[")&&s&&(r[i.replace(/(^.*\[|\].*$)/g,"")]=s)}),Object.keys(r).length!==0)return r}catch(r){console.log(r)}}return null};function B(){try{let e=c.location.search.substring(1);if(sessionStorage!=null&&sessionStorage.getItem(`${c.Shopify.shop}_landing_page`)&&(e+="&"+new URL(sessionStorage.getItem(`${c.Shopify.shop}_landing_page`)).search.substring(1)),e.indexOf("utm_")===-1){const o=p("_shopify_sa_p");o&&(e+="&"+o)}const t=e.split("&"),n=c.ES_ALL_QUERY?t:t.filter(function(o){return o.substring(0,4)==="utm_"}),r={};return n.forEach(function(o){o.split("=")[1]&&(r[o.split("=")[0]]=o.split("=")[1])}),r.full_url=c.location.href,c.ES_ALL_QUERY&&(r.useragent=navigator.userAgent,r.referrer=document.referrer),r}catch{return{}}}const p=e=>{const t=`; ${document.cookie}`.split(`; ${e}=`);return t.length===2?t.pop().split(";").shift():""};function P(e){if(!e)return"";e!=null&&e.backgroundColor&&(e!=null&&e.background)&&delete e.backgroundColor;let t="";const n=r=>r.replace(/[A-Z]/g,o=>`-${o.toLowerCase()}`);return Object.keys(e).forEach(r=>{if(r==="animation")return;let o=e[r];r!="fontWeight"&&(isNaN(o)||(o=o+"px")),t+=`${n(r)}: ${o} !important;`}),t+=`box-shadow: 0 2px 7px 0 rgba(0, 0, 0, ${e.boxShadowOpacity/100}) !important;`,c.ES_NO_CSS_IMPORTANT&&(t=t.replace(/!important/g,"")),t}function U(e,t,n=100,r=2e3){function o(i){const u=new Date().getTime();e()?t(!0):u-i>=r?t(!1):setTimeout(()=>{o(i)},n)}const s=new Date().getTime();o(s)}function f(e,...t){const n=r=>r&&typeof r=="object"&&!Array.isArray(r);try{if(!t.length)return e;const r=t.shift();if(n(e)&&n(r))for(const o in r)n(r[o])?(e[o]||Object.assign(e,{[o]:{}}),f(e[o],r[o])):Object.assign(e,{[o]:r[o]});return f(e,...t)}catch{return e}}function V(){try{const e=new Date().getTime(),t=Math.floor(Math.random()*1e9),n=navigator.userAgent;let r=0;for(let o=0;o{try{if(c.ES_CUSTOMER_ADDRESSES&&c.ES_CUSTOMER_ADDRESSES.length>0){const e=c.ES_CUSTOMER_ADDRESSES.find(t=>t.default===!0)??c.ES_CUSTOMER_ADDRESSES[0];e&&(e.address=e.address1,c.ES_CUSTOMER_EMAIL&&(e.email=c.ES_CUSTOMER_EMAIL),Object.entries(e).forEach(([t,n])=>{c.changeESFieldValue(t,n)}))}}catch(e){console.log(e)}};function Y(e){const t=n=>n.offsetParent!==null;return new Promise(n=>{const r=document.querySelector(e);if(r&&t(r)){n();return}const o=new MutationObserver(s=>{const i=document.querySelector(e);i&&t(i)&&(o.disconnect(),n())});o.observe(document,{attributes:!0,childList:!0,subtree:!0})})}const G=()=>{try{const e=new URLSearchParams(location.search).get("fbclid")||"",t=p("_fbc");let n=null;if(t&&t.split(".").pop().length>10)n=t;else if(e&&e.length>10){const r=location.hostname.split(".").length-1,o=Math.round(Date.now());n=`fb.${r}.${o}.${e}`}return{fbp:p("_fbp"),fbc:n}}catch{return{}}};function H(){const e=document.createElement("script");e.src="https://challenges.cloudflare.com/turnstile/v0/api.js?onload=onloadTurnstileCallback",e.async=!0,e.defer=!0,document.head.appendChild(e),c.onloadTurnstileCallback=()=>{turnstile.render("#es-cf-turnstile",{sitekey:c.EASYSELL_CONFIG.settings.botModeSitekey,appearance:c.EASYSELL_CONFIG.settings.botModeAppearance??"interaction-only",callback:function(t){c.ES_TOKEN=t}})}}const Q=()=>{try{sessionStorage!=null&&sessionStorage.getItem(`${c.Shopify.shop}_landing_page`)||sessionStorage.setItem(`${c.Shopify.shop}_landing_page`,c.location.href),typeof c.es_after_init_completed=="function"&&setTimeout(()=>{try{c.es_after_init_completed()}catch(e){console.log(e)}},500),c.EASYSELL_CONFIG.settings.bot_mode===!0&&H()}catch(e){console.log(e)}};c.ES_GET_VARIANT_QUANTITY=E,c.ES_GET_VARIANT_ID=_,c.EasySellHelpers=c.EasySellHelpers||{logAppInfo:b,buildCheckoutLink:O,buildWhatsAppLink:C,buildButtonLink:T,isPageBuilder:R,getProductForm:v,getCartForm:A,showThanksModal:q,returnNodesToPreviousState:I,addListenerToSelector:L,removeElementBySelector:$,injectGlobalCSS:F,injectCss:S,injectCustomJS:x,toggleCSSConfig:D,getVariantQuantity:E,getVariantId:_,toggleStickyButtonOnScroll:M,getBundlesAppUpdates:N,getProperties:k,getUtms:B,styleToStringStyle:P,waitForCondition:U,mergeDeep:f,generateUniqueId:V,checkLoggedInCustomer:j,waitForSelectorToBeVisible:Y,getPixelCookies:G,afterInitCompleted:Q,getCookie:p,getUrlParam:g}})(window);