PageSourceSearch

https://unchartedsupplyco.com/cdn/shop/t/21/assets/product-form-handler.js?v=98438162550974437671786415285

js unchartedsupplyco.com collected 2026-09-25 14:23:06 UTC 10,667 bytes, 1 lines download raw bytes

1import{s as t}from"./chunk.lit-element-726bced0.js";import{E as e}from"./chunk.events-3f8ab4b2.js";import{f as i}from"./chunk.pricingUtils-2a16a1be.js";function a(t,e){const i=e.get(t.id);i&&(t.inventory_quantity=i.inventory_quantity,t.inventory_management=i.inventory_management,t.inventory_policy=i.inventory_policy)}function s(t,e,i,a){t.forEach((t=>{t.classList.toggle("u--isDisabled",!e),e?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled");const s=t.querySelector("span.text");s&&(s.textContent=i);let n=t.querySelector("[data-btn-price]");a?(n||(n=document.createElement("span"),n.setAttribute("data-btn-price",""),n.className="btn__price",t.insertBefore(n,t.querySelector(".checkmark"))),n.textContent=a):n&&n.remove()}))}function n(t,e,a={}){if(t.textContent="",!e)return r(t,"price__soldOut","Unavailable"),void t.classList.remove("isLoading","isSale");let s=!1;if(0===e.price){r(t,"price__free","Price TBD")}else if(e.available)if(s=e.compare_at_price&&e.compare_at_price>e.price,s){if(r(t,"price__compareAt",i(e.compare_at_price)),r(t,"price__main",i(e.price)),a.displaySavings){const a=e.compare_at_price-e.price;r(t,"price__savings",`You Save ${Math.round(a/e.compare_at_price*100)}% (${i(a)})`)}}else r(t,"price__main",i(e.price));else r(t,"price__main",i(e.price));t.classList.toggle("isSale",s),t.classList.remove("isLoading")}function r(t,e,i){const a=document.createElement("span");a.className=e,a.textContent=i,t.appendChild(a)}function l(t,e,i){t.className="badge"+(i?` badge--${i}`:""),t.textContent=e}function o(t){t.className="badge",t.textContent=""}const c="uc_ab_tests";class h extends t{createRenderRoot(){return this}static properties={enableHistoryState:{type:Boolean,attribute:"enable-history-state"},displaySavings:{type:Boolean,attribute:"display-savings"}};connectedCallback(){super.connectedCallback();const t=this.querySelector("[data-product-form]");if(!t)return;try{this._product=JSON.parse(t.dataset.product)}catch{return}this._inventoryMap=function(t){const e=new Map;for(const i of t)e.set(i.id,i);return e}(JSON.parse(t.dataset.variantInventory||"[]")),this._variantByOptions=new Map;for(const t of this._product.variants)this._variantByOptions.set(t.options.join("/"),t);if(this._details=this.closest(".product__details")||this,this._variantSelect=this.querySelector('select[name="id"]'),!this._variantSelect)return;this._priceUIEl=this._details.querySelector("[data-price-ui]"),this._badgeEl=this._details.querySelector("[data-badge]"),this._isPreorderCollection="true"===this._badgeEl?.dataset.isPreorderCollection,this._addToCartBtns=this._details.querySelectorAll("[data-ajax-submit]"),this._payBtn=this._details.querySelector(".shopify-payment-button"),this._purchaseDetails=this._details.querySelector(".productForm__buttons"),this._qtyInput=this._details.querySelector("[data-qty-input]"),this._qtyMinus=this._details.querySelector("[data-qty-minus]"),this._qtyPlus=this._details.querySelector("[data-qty-plus]"),this._variantBackInStockEls=this._details.querySelectorAll("[data-variant-back-in-stock]"),this._scarcityEl=this._details.querySelector("[data-scarcity]"),this._swatchesByGroup=new Map;this.querySelectorAll("[data-option-index]").forEach((t=>{const e=t.dataset.optionIndex;this._swatchesByGroup.has(e)||this._swatchesByGroup.set(e,[]),this._swatchesByGroup.get(e).push(t)})),this._selectedOptions=this._product.options.map((()=>"")),this._initSelectedOptions();for(const t of this._product.variants)a(t,this._inventoryMap);this._updateSwatchAvailability(),this._handleVariantChange=this._onVariantChange.bind(this),this._variantSelect.addEventListener("change",this._handleVariantChange),this._handleSwatchClick=this._onSwatchClick.bind(this),this._swatchesByGroup.forEach((t=>{t.forEach((t=>t.addEventListener("click",this._handleSwatchClick)))})),this._handleQtyMinus=this._onQtyMinus.bind(this),this._handleQtyPlus=this._onQtyPlus.bind(this),this._qtyMinus&&this._qtyMinus.addEventListener("click",this._handleQtyMinus),this._qtyPlus&&this._qtyPlus.addEventListener("click",this._handleQtyPlus),this._atcPriceVariant=function(t,e){let i={};try{i=JSON.parse(localStorage.getItem(c))||{}}catch{}if(i[t]&&e.includes(i[t]))return i[t];const a=e[Math.floor(Math.random()*e.length)];i[t]=a;try{localStorage.setItem(c,JSON.stringify(i))}catch{}return a}("atc_price_2026_04",["control","price_in_button"]),"function"==typeof gtag&&(gtag("set","user_properties",{hp_grid_variant:this._atcPriceVariant}),gtag("event","ab_test_assigned",{test_name:"atc_price_2026_04",test_variant:this._atcPriceVariant})),this._firstLoad=!0,this._onVariantChange()}disconnectedCallback(){super.disconnectedCallback(),this._variantSelect&&this._handleVariantChange&&this._variantSelect.removeEventListener("change",this._handleVariantChange),this._swatchesByGroup&&this._handleSwatchClick&&this._swatchesByGroup.forEach((t=>{t.forEach((t=>t.removeEventListener("click",this._handleSwatchClick)))})),this._qtyMinus&&this._handleQtyMinus&&this._qtyMinus.removeEventListener("click",this._handleQtyMinus),this._qtyPlus&&this._handleQtyPlus&&this._qtyPlus.removeEventListener("click",this._handleQtyPlus),this._handleVariantChange=null,this._handleSwatchClick=null,this._handleQtyMinus=null,this._handleQtyPlus=null,this._details=null,this._variantSelect=null,this._priceUIEl=null,this._badgeEl=null,this._addToCartBtns=null,this._payBtn=null,this._purchaseDetails=null,this._qtyInput
1=null,this._qtyMinus=null,this._qtyPlus=null,this._variantBackInStockEls=null,this._scarcityEl=null,this._isPreorderCollection=null,this._swatchesByGroup=null,this._variantByOptions=null,this._product=null,this._inventoryMap=null,this._selectedOptions=null}_initSelectedOptions(){const t=this._getSelectedVariant();t&&t.options.forEach(((t,e)=>{this._selectedOptions[e]=t;const i=this.querySelector(`[data-option-selected="${e}"]`);i&&(i.textContent=_(t))}))}_getSelectedVariant(){const t=Number(this._variantSelect.value);return this._product.variants.find((e=>e.id===t))||null}_findVariantByOptions(){return this._variantByOptions.get(this._selectedOptions.join("/"))||null}_onSwatchClick(t){const e=t.currentTarget;if(e.classList.contains("isUnavailable"))return;const i=e.dataset.optionIndex,a=e.dataset.optionValue;this._selectedOptions[Number(i)]=a;(this._swatchesByGroup.get(i)||[]).forEach((t=>{const e=t.dataset.optionValue===a;t.classList.toggle("isActive",e),t.setAttribute("aria-pressed",String(e))}));const s=this.querySelector(`[data-option-selected="${i}"]`);s&&(s.textContent=_(a));const n=this._findVariantByOptions();this._variantSelect.value=n?n.id:"",this._updateSwatchAvailability(),this._onVariantChange()}_updateSwatchAvailability(){this._swatchesByGroup.forEach(((t,e)=>{const i=Number(e);t.forEach((t=>{const e=[...this._selectedOptions];e[i]=t.dataset.optionValue;const a=this._product.variants.filter((t=>t.options.every(((t,a)=>a===i?t===e[i]:""===e[a]||t===e[a])))),s=a.length>0,n=s&&!a.some((t=>t.available));t.classList.toggle("isUnavailable",!s),t.classList.toggle("isSoldOut",n)}))}))}_onQtyMinus(){if(!this._qtyInput)return;const t=Number(this._qtyInput.value)||1;t>(Number(this._qtyInput.min)||1)&&(this._qtyInput.value=t-1)}_onQtyPlus(){if(!this._qtyInput)return;const t=Number(this._qtyInput.value)||1;t<(Number(this._qtyInput.max)||50)&&(this._qtyInput.value=t+1)}_onVariantChange(){const t=this._getSelectedVariant();if(this._firstLoad)this._priceUIEl&&(t&&n(this._priceUIEl,t,{displaySavings:this.displaySavings}),this._priceUIEl.classList.remove("isLoading"));else{if(this.enableHistoryState&&t){const e=new URL(window.location);e.searchParams.set("variant",t.id),window.history.replaceState({},"",e)}this._priceUIEl&&n(this._priceUIEl,t,{displaySavings:this.displaySavings})}this._updateBackInStockMessages(t);const a=!!t&&function(t,e){return!(!e||!t||!t.available||"continue"!==t.inventory_policy||t.inventory_quantity>0)}(t,this._isPreorderCollection);this._badgeEl&&!this._firstLoad&&function(t,e,{preorder:i=!1}={}){if(e)if(i)l(t,"Preorder","preOrder");else if(e.available)if(e.compare_at_price&&e.compare_at_price>e.price){const i=e.compare_at_price-e.price;l(t,`-${Math.round(i/e.compare_at_price*100)}%`,"sale")}else o(t);else l(t,"Sold Out","soldOut");else o(t)}(this._badgeEl,t,{preorder:a}),this._scarcityEl&&!this._firstLoad&&function(t,e,{preorder:i=!1}={}){const a=Number(t.dataset.scarcityUrgent)||10,s=Number(t.dataset.scarcityLow)||50;if(!e||i||!e.available||!e.inventory_management||"deny"!==e.inventory_policy||e.inventory_quantity<=0||e.inventory_quantity>s)return t.classList.remove("isVisible"),void(t.textContent="");const n=e.inventory_quantity<=a?"urgent":"low";t.textContent="urgent"===n?`Only ${e.inventory_quantity} left in stock`:"Low stock — order soon",t.classList.add("isVisible"),"function"==typeof gtag&&gtag("event","scarcity_message_viewed",{scarcity_tier:n,item_id:String(e.id)})}(this._scarcityEl,t,{preorder:a}),function({variant:t,addToCartBtns:e,payBtn:a,purchaseDetails:n,qtyInput:r,priceEl:l,preorder:o,showButtonPrice:c=!1}){l&&l.toggleAttribute("data-unavailable",!t),t&&(t.available||o)?(s(e,!0,o?"Preorder":function(t){for(const e of t)if(e.dataset.label)return e.dataset.label;return"Add to Cart"}(e),c&&t.price?i(t.price):null),a&&a.classList.remove("u--isDisabled"),n&&n.classList.remove("isUnavailable")):(s(e,!1,t?"Sold Out":"Unavailable",null),a&&a.classList.add("u--isDisabled"),n&&n.classList.add("isUnavailable"));r&&(t&&t.available&&t.inventory_management&&t.inventory_quantity>0&&"deny"===t.inventory_policy?(r.max=t.inventory_quantity,Number(r.value)>t.inventory_quantity&&(r.value=t.inventory_quantity)):r.max=50)}({variant:t,addToCartBtns:this._addToCartBtns,payBtn:this._payBtn,purchaseDetails:this._purchaseDetails,qtyInput:this._qtyInput,priceEl:this._priceUIEl,preorder:a,showButtonPrice:"price_in_button"===this._atcPriceVariant}),t&&t.featured_media&&null!==this.offsetParent&&window.dispatchEvent(new CustomEvent(e.VARIA
1NT_UPDATED,{detail:{featuredMediaId:t.featured_media.id,firstLoad:this._firstLoad}})),this._firstLoad||(this._variantSelect.removeEventListener("change",this._handleVariantChange),this._variantSelect.dispatchEvent(new Event("change",{cancelable:!0})),this._variantSelect.addEventListener("change",this._handleVariantChange)),this._firstLoad=!1}_updateBackInStockMessages(t){this._variantBackInStockEls&&this._variantBackInStockEls.length&&this._variantBackInStockEls.forEach((e=>{const i=Number(e.dataset.variantBackInStock);e.style.display=t&&i===t.id?"block":"none"}))}}function _(t){return t.replace(/-/g," ").replace(/\b\w/g,(t=>t.toUpperCase()))}customElements.define("product-form-handler",h);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.