PageSourceSearch

https://www.hillhousehome.com/cdn/shop/t/555/assets/bundled-add-to-cart.directive.js

js hillhousehome.com collected 2026-10-02 10:26:17 UTC 6,782 bytes, 14 lines download raw bytes

1import { D as Directive, O as Ohm, g as gsapWithCSS, j as getLastSeenPromo, k as SuperTracker, C as CartManager, M as ModalManager, H as HostAttr, a as autobind } from './bundled-app.js';
2import { Monogram } from './bundled-monogram.directive.js';
3import { B as BoostSearchService } from './bundled-BoostSearch.js';
4import { GiftCardRecipientForm } from './bundled-gift-card-recipient-form.directive.js';
5import { P as ProductManager } from './bundled-ProductManager.js';
6import './bundled-unsafe-html.js';
7import './bundled-ShopifyUtils.js';
8import './bundled-debounce.decorator.js';
9import './bundled-HostChild.js';
10import './bundled-AnnouncementManager.js';
11
12function t(t,e,i,o){var r,a=arguments.length,n=a<3?e:null===o?o=Object.getOwnPropertyDescriptor(e,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,i,o);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(n=(a<3?r(n):a>3?r(e,i,n):r(e,i))||n);return a>3&&n&&Object.defineProperty(e,i,n),n}function e(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}class AddToCart extends Directive{get pdpForm(){return this.host.closest(".pdpForm")||this.host.closest("[product-scope]")?.querySelector(".pdpForm")}onAppInit(){this.bindEvents(),this.isAutomatic&&(this.productManager=ProductManager.getInstance(this.host),this.productManager.stateChange$.subscribe({next:this.onProductChange}));}bindEvents(){this.host.addEventListener("click",this.onClick);}onProductChange(t){let{selectedVariant:e,product:i}=t;this.host.disabled=!e?.available||i.tags?.includes("coming-soon")&&!window.__isVipCustomer;}onClick(t){if(this.host.disabled||this.isAddingToCart)return;let e=this.pdpForm?.querySelector("gift-card-recipient-form");if(e){let t=Ohm.getDirectiveFromHostElement(e,GiftCardRecipientForm);if(t&&!t.validate())return}this.isAddingToCart=!0,this.host.disabled=!0,gsapWithCSS.set(this.host,{width:this.host.offsetWidth}),this.host.textContent=this.addingText;let o=[{id:this.id,quantity:this.quantity}],r=new Date().getTime(),a={},s=this.getMonogram();if(this.collectFormInputs().forEach(([t,e])=>{t.startsWith("properties[")&&(a[t]=`${e}`);}),Object.keys(a).forEach(t=>{a[t.replace(/\[/g,".").replace(/\]/g,"").split(".").pop()]=a[t],delete a[t];}),s&&s.properties){o.push({id:s.id,quantity:1,properties:{_monogram_id:r,_LPROP:"finalsale"}}),a._monogram_id=r,a._LPROP="finalsale";let t=s.properties;Object.keys(t).forEach(e=>{a[e]=t[e];});}let d=document.querySelector(".pdpForm .productSwatch--selected[bundle-color-option]"),c=d?.getAttribute("color");c&&(a._bundle_option=c),o[0].properties=a,document.dispatchEvent(new CustomEvent("theme:loading:start")),this.cartManager.addMany(o.reverse()).then(t=>this.onAddCallback(!0,t)).catch(()=>this.onAddCallback(!1,null));}collectFormInputs(){if(!this.pdpForm)return [];let t=[];return this.pdpForm.querySelectorAll('input[name^="properties["], textarea[name^="properties["], select[name^="properties["]').forEach(e=>{e.disabled||e instanceof HTMLInputElement&&("radio"===e.type||"checkbox"===e.type)&&!e.checked||t.push([e.name,e.value]);}),t}trackAdd(){let t=this.datalayerConfig,e=this.getProductId(),i=e?this.boostSearchService.getSearchContext(e,!1):null;t.view_type=this.host.closest('[product-scope="quickshop"]')?"quick view":"standard view";let o=getLastSeenPromo();o&&(t.promotion_id=o.promotion_id,t.promotion_name=o.promotion_name),i&&(t.view_type=i.view_type||"",t.item_list_name=i.item_list_name||"",t.item_list_id=i.item_list_id||"",t.module_type=i.module_type||""),SuperTracker.getInstance().trackGa({event:"add_to_cart",ecommerce:{currency:window.Shopify.currency.active,view_type:t.view_type,...i&&{item_list_name:i.item_list_name,item_list_id:i.item_list_id,module_type:i.module_type,view_type:i.view_type},items:[t]}});}trackBoostAddToCart(){let t=this.getProductId();if(!t)return;let e=this.boostSearchService.getSearchContext(t,!0);e&&this.boostSearchService.trackAddToCart(t,this.id,e.queryString,e.requestId);}getProductId(){if(this.productManager){let t=this.productManager.getState();return t?.product?.id||null}return null}buildNotificationData(){if(!this.productManager)return null;let t=this.productManager.getState();if(!t||!t.selectedVariant)return null;let{selectedVariant:e,product:i,options:o,rawData:r}=t,a=r.options.map((t,e)=>({name:this.formatOptionName(t),value:o[e]||""})).filter(t=>t.value),n=e.featured_image?.src||i.media?.[0]?.src||"",s=i.complete_the_look_handles||[];return {id:e.id,title:t.title,price:e.price,compare_at_price:e.compare_at_price||0,image:n,quantity:this.quantity,options_with_values:a,related_products:s}}onAddCallback(t,e){if(this.isAddingToCart=!1,document.dispatchEvent(new CustomEvent("theme:loading:end")),this.host.disabled=!1,t){let t=this.host.hasAttribute("context"),e=this.host.getAttribute("context");t&&"sidecart"===e||(this.trackAdd(),this.trackBoostAddToCart()),this.host.focus(),"modal-quickshop"===this.modalManager.getCurrentModalId()&&this.modalManager.close(),this.modalManager.open("modal-sidecart");}}formatOptionName(t){return t.split("-").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}getMonogram(){let t=document.querySelector(".pdpForm .monogram[data-values]");if(!t)return;let e=t.closest("[monogram]");if(e)return Ohm.getDirectiveFromHostElement(e,Monogram)||null}constructor(...t){super(...t),this.addingText="Adding...",this.quantity=1,this.isAutomatic=this.host.hasAttribute("automatic"),this.cartManager=CartManager.getInstance(),this.modalManager=ModalManager.getInstance(),this.boostSearchService=BoostSearchService.getInstance(),this.defaultText=this.host.textContent,this.isAddingToCart=!1;}}AddToCart.selector="[add-to-cart]",t([HostAttr("#add-to-cart"),e("design:type",Number)],AddToCart.prototype,"id",void 0),t([HostAttr("adding-text"),e("design:type",String)],AddToCart.prototype,"addingText",void 0),t([HostAttr("=datalayer-config",!1,t=>
12(Object.keys(t).forEach(e=>{"undefined"===t[e]&&(t[e]=void 0);}),t)),e("design:type","undefined"==typeof Record?Object:Record)],AddToCart.prototype,"datalayerConfig",void 0),t([HostAttr("#"),e("design:type",Number)],AddToCart.prototype,"quantity",void 0),t([autobind,e("design:type",Function),e("design:paramtypes",["undefined"==typeof ProductState?Object:ProductState]),e("design:returntype",void 0)],AddToCart.prototype,"onProductChange",null),t([autobind,e("design:type",Function),e("design:paramtypes",["undefined"==typeof MouseEvent?Object:MouseEvent]),e("design:returntype",void 0)],AddToCart.prototype,"onClick",null),t([autobind,e("design:type",Function),e("design:paramtypes",[Boolean,"undefined"==typeof ShopifyCart?Object:ShopifyCart]),e("design:returntype",void 0)],AddToCart.prototype,"onAddCallback",null);
13
14export { AddToCart };

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.