"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[8],{27:(i,e,t)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.useLogCollection=e.setupLogViewCart=e.logViewedProduct=e.logPageView=void 0;const n=t(156),a=t(5),o=t(3);e.logPageView=()=>{if("undefined"!=typeof window)try{(0,n.initBentoAnalytics)({elevar:!0}).then((()=>{console.log("Success on initBentoAnalytics()")}))}catch(i){console.error("Error in initBentoAnalytics():",i)}},e.logViewedProduct=(i,e)=>{var t;if(!i||"undefined"==typeof window)return;const o=null!==(t=null==i?void 0:i.variants.find((i=>i.variantId===e)))&&void 0!==t?t:null==i?void 0:i.variants[0];(0,n.initBentoAnalytics)({elevar:!0}).then((()=>{var e,t,l,r,d,c,u,s,v,p,g;const _=`${window.location.origin}${null===(e=o.image)||void 0===e?void 0:e.src}`,f=null!==(l=(0,a.safeParseFloat)(null!==(t=o.price)&&void 0!==t?t:"0"))&&void 0!==l?l:0,w=null!==(c=(0,a.safeParseFloat)(null!==(d=null!==(r=o.compareAtPrice)&&void 0!==r?r:o.price)&&void 0!==d?d:"0"))&&void 0!==c?c:0;(0,n.logViewContent)({discounted_price:f,discounts:[],featured_image:{aspect_ratio:1,alt:null!==(s=null===(u=o.image)||void 0===u?void 0:u.altText)&&void 0!==s?s:"",width:0,height:0,url:_},final_line_price:f,final_price:f,gift_card:!1,grams:0,handle:i.handle,id:null!==(v=o.id)&&void 0!==v?v:i.id,image:_,inventory:o.quantityAvailable,key:o.sku,line_level_discount_allocations:[],line_level_total_discount:0,line_price:f,options_with_values:o.selectedOptions,original_line_price:w,original_price:w,price:f,product_description:i.description,product_has_only_default_variant:1===i.variants.length,product_id:null!==(p=(0,a.safeParseInt)(i.id))&&void 0!==p?p:0,product_title:i.title,product_type:i.productType,properties:{},quantity:1,requires_shipping:!0,sku:o.sku,taxable:!0,title:i.title,total_discount:0,url:window.location.href,variant_id:null!==(g=(0,a.safeParseInt)(o.variantId))&&void 0!==g?g:0,variant_options:o.selectedOptions.map((i=>i.value)),variant_title:o.title,vendor:i.vendor})}))},e.setupLogViewCart=()=>{if("undefined"==typeof window)return;const i=document.querySelector("input#cart-toggle"),e=()=>{(0,n.initBentoAnalytics)({elevar:!0}).then(n.logViewCart)};(null==i?void 0:i.checked)&&e(),null==i||i.addEventListener("change",e)},e.useLogCollection=i=>(0,o.useEffect)((()=>{"undefined"!=typeof window&&(0,n.initBentoAnalytics)({elevar:!0}).then((()=>{var e;const t={title:i.title,id:0,url:window.location.href};(0,n.logCollectionView)(Object.assign(Object.assign({},t),{title:null!==(e=t.title)&&void 0!==e?e:""}),i.products.map((i=>{var e,t,n,o,l,r,d,c,u,s,v,p;const g=null!==(e=i.variants.find((e=>i.defaultVariantId===e.variantId)))&&void 0!==e?e:i.variants[0],_={src:null===(t=g.image)||void 0===t?void 0:t.src,alt:null===(n=g.image)||void 0===n?void 0:n.altText,width:0,height:0,aspect_ratio:1},f=(0,a.safeParseFloat)(null!==(r=null!==(o=i.priceRange.minVariantPrice.amount)&&void 0!==o?o:null===(l=i.priceRange.maxVariantPrice)||void 0===l?void 0:l.amount)&&void 0!==r?r:"0"),w=(0,a.safeParseFloat)(null!==(p=null!==(v=null!==(u=null!==(c=null===(d=i.compareAtPriceRange.maxVariantPrice)||void 0===d?void 0:d.amount)&&void 0!==c?c:i.compareAtPriceRange.minVariantPrice.amount)&&void 0!==u?u:null===(s=i.priceRange.maxVariantPrice)||void 0===s?void 0:s.amount)&&void 0!==v?v:i.priceRange.minVariantPrice.amount)&&void 0!==p?p:"0");return{product:{compare_at_price:w,id:(0,a.safeParseInt)(i.id),selectedOptions:[],url:window.location.href,title:i.title,type:i.productType,image:_,price:f,vendor:i.vendor},selected_variant:{title:g.title,price:f,image:_,id:(0,a.safeParseInt)(g.id),compare_at_price:w,sku:g.sku,inventory_quantity:g.quantityAvailable,url:`${window.location.origin}/products/${i.handle}?variant=${g.id}`},quantity:1}})))}))}),[i])}}]);