PageSourceSearch

https://www.portlandleathergoods.com/cdn/shop/t/3246/assets/upsell…?v=64717774243611069181790187030

js portlandleathergoods.com collected 2026-09-25 08:27:49 UTC 5,722 bytes, 2 lines download raw bytes

1var b=Object.defineProperty;var C=(d,c,e)=>c in d?b(d,c,{enumerable:!0,configurable:!0,writable:!0,value:e}):d[c]=e;var i=(d,c,e)=>C(d,typeof c!="symbol"?c+"":c,e);import{i as a,a as h,g as E,f as m}from"main/custom-element-utils";import{c as p}from"main/cart";import{U as f}from"main/upsellBundle";import"main/cart-drawer-timer";class I extends HTMLElement{constructor(){super();i(this,"upsellId");i(this,"inputs");i(this,"variantImages");i(this,"bundleModal");i(this,"priceContainer");i(this,"beforePrice");i(this,"beforePriceElement");i(this,"afterPrice");i(this,"afterPriceElement");i(this,"couponRow");i(this,"discountCodeDict");i(this,"codePrefixSpan");i(this,"numActiveCoupons");i(this,"addToCartURL");i(this,"submitButtons");i(this,"cart");i(this,"cartItems");i(this,"handleUpsellToggled",e=>{const{beforeAdjustment:t,afterAdjustment:s,checked:o,itemId:r,discountCodeAction:n}=e.detail;this.updateDiscountCodeDict(r,n),this.beforePrice+=t,this.afterPrice+=s,this.calculateBundlePrice();const l=this.variantImages[r];l&&(o?delete l.dataset.disabled:l.dataset.disabled="true"),this.hideIfAllUnchecked()});i(this,"updateDiscountCodeDict",(e,t)=>{const{action:s,code:o}=t;if(!o)return;const r=this.discountCodeDict.get(o);if(r){const n=r.mainCode;switch(s){case"ADD":{r.bundleItems.set(e,!0),r.bundleItems.size===1&&(n.element.dataset.active="true",this.numActiveCoupons++);break}case"REMOVE":{r.bundleItems.delete(e),r.bundleItems.size===0&&(delete n.element.dataset.active,this.numActiveCoupons--);break}}switch(!0){case this.numActiveCoupons===0:{this.couponRow.classList.add("hidden");break}case(this.numActiveCoupons===1&&s==="ADD"):{this.couponRow.classList.remove("hidden");break}}this.codePrefixSpan&&(this.codePrefixSpan.dataset.count=this.numActiveCoupons.toString())}});i(this,"addItems",e=>{const t=[],s=this.getLineProperties().map(r=>{const n=r.split(":"),[l,u]=[n[0]?.trim(),n[1]?.trim()];if(!l||!u){console.warn("[DEBUG]: could not parse the line-item properties");return}else return[l,u]}).filter(r=>Array.isArray(r)),o=Object.fromEntries(s);this.inputs.forEach(r=>{if(r.checked){const n={id:r.value,quantity:1};o&&Object.keys(o).length>0&&(n.properties=o),t.push(n)}}),this.cartItems.addItem(0,t,!0).catch(r=>{console.error(r)}),this.bundleModal?.closeModal(e)});this.inputs=[...this.querySelectorAll("input[name='upsell[]']")],this.upsellId=a(this.dataset.upsellId),this.variantImages={},this.querySelectorAll("[data-thumb-for-item-id]").forEach(e=>{const t=e.dataset.thumbForItemId;t?this.variantImages[t]=e:console.warn("[DEBUG]: variantId is missing from the element",e)}),this.couponRow=a(this.querySelector("[data-coupon-row]")),this.numActiveCoupons=0,this.discountCodeDict=this.populateDiscountCodeDict(),this.priceContainer=a(this.querySelector("[data-price-container]")),this.codePrefixSpan=this.priceContainer.querySelector("pluralize-item[data-code-prefix-span]"),this.beforePriceElement=a(this.priceContainer.querySelector("[data-before-price-element]")),this.afterPriceElement=a(this.priceContainer.querySelector("[data-after-price-element]")),this.beforePrice=h(this.dataset.beforePrice,"[DEBUG]: expected data-before-price to be a number"),this.afterPrice=h(this.dataset.afterPrice,"[DEBUG]: expected data-before-price to be a number"),this.addToCartURL=a(window.routes.cart_add_url),this.cart=a(E(document,[...p],"down"),`[DEBUG]: Could not find cart container. Did you forget to add one of these elements? ${JSON.stringify(p)} following to the page?`),this.cartItems=a(document.querySelector("cart-items")),this.bundleModal=document.querySelector('[data-modal-selector="upsell-bundle"]')}connectedCallback(){this.assignSubmitButtons(),this.addEventListener(f.UPSELL_BUNDLE_ITEM_TOGGLED,this.handleUpsellToggled)}disconnectedCallback(){this.unassignSubmitButtons(),this.removeEventListener(f.UPSELL_BUNDLE_ITEM_TOGGLED,this.handleUpsellToggled)}unassignSubmitButtons(){this.submitButtons?.forEach(e=>{e.removeEventListener("click",this.addItems)})}assignSubmitButtons(){this.unassignSubmitButtons(),this.submitButtons=a(document.querySelectorAll(`button[data-bundle-submit=${this.upsellId}
1]`)),this.submitButtons.forEach(e=>{e.addEventListener("click",this.addItems)})}populateDiscountCodeDict(){const e=new Map;return this.querySelectorAll("[data-price-container] [data-coupon-code]").forEach(t=>{const s=t.dataset.couponCode;s&&!e.has(s)&&(e.set(s,{mainCode:{element:t},bundleItems:new Map}),this.numActiveCoupons++)}),this.querySelectorAll("upsell-bundle-item").forEach(t=>{const s=t.dataset.discountCode,o=t.dataset.itemId;s&&o&&e.get(s)?.bundleItems.set(o,!0)}),e}hideIfAllUnchecked(){this.inputs.find(t=>t.checked)?(this.priceContainer.classList.remove("hidden"),this.submitButtons?.forEach(t=>{t.removeAttribute("disabled")})):(this.priceContainer.classList.add("hidden"),this.submitButtons?.forEach(t=>{t.setAttribute("disabled","true")}))}calculateBundlePrice(){const e=this.dataset.currencyFormat??"${{amount}}";(()=>{const s=m(this.beforePrice,e),o=m(this.afterPrice,e);s.ok&&o.ok?(this.beforePriceElement.textContent=s.price,this.afterPriceElement.textContent=o.price,this.beforePrice===this.afterPrice?this.priceContainer.dataset.afterPriceOnly="true":delete this.priceContainer.dataset.afterPriceOnly):console.warn("[DEBUG]: Could not format the currency. Check before / after: ",s,o)})()}getLineProperties(){try{const e=this.querySelector('[type="application/json"]');return e?.textContent?JSON.parse(e.textContent).split(`
2`).filter(o=>o):(console.error("[DEBUG] Could not load line Item data!"),[])}catch(e){return console.error("[DEBUG] Upsell cound not load line properties data!",e),[]}}}window.customElements.define("upsell-bundle",I);export{I as UpsellBundle};

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.