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tD/C,SAAuBmB,GAC5B,IAAK,MAAM3G,KAASpF,OAAOgM,KAAKC,MAAO,CACrC,MAAMC,EAAWH,EAAc,MAAL3G,OAAK,EAALA,EAAOuD,MAC7BuD,GACFA,EAAS9G,EAEb,CAEA,IAAK,MAAM+G,KAAaJ,EACtBK,iBAAiBD,EAAWJ,EAASI,GAEzC,CDwDEE,CAV8D,CAC5D,mBAAoBpD,EACpB,mBAAoBqD,EACpB,oBAAqBA,EACrB,iBAAkBA,EAClB,iBAAkBA,EAClB,sBAAuBA,EACvB,cAAe5C,GAInB,E","sources":["webpack://lange/./scripts/common/liquid-global.ts","webpack://lange/./scripts/integrations/google/utils.ts","webpack://lange/./scripts/integrations/google/events/add-to-cart.ts","webpack://lange/./scripts/integrations/google/events/remove-from-cart.ts","webpack://lange/./scripts/integrations/google/events/view-cart.ts","webpack://lange/./scripts/integrations/google/events/view-item.ts","webpack://lange/./scripts/integrations/google/events/view-item-list.ts","webpack://lange/./scripts/integrations/google/index.ts","webpack://lange/./scripts/integrations/common.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/naming-convention */\n/**\n * Do not use this export. This is a hacky fix to a strange inlining optimization performed by\n * webpack where it removes this module and points identifiers directly to the global values.\n * Without this export, webpack fails to understand that `window.__ofir` must also be inlined.\n *\n * @type {unknown}\n */\nexport const __ofir: unknown = window.__ofir;\n\n/**\n * Cart should never be undefined\n */\nexport const Cart: OfirLiquidGlobals.Cart = window.__ofir?.Cart;\n\n/**\n * Checkout is undefined if user is not loading a checkout page.\n *\n * @type {OfirLiquidGlobals.Checkout}\n */\nexport const Checkout: OfirLiquidGlobals.Checkout = window.__ofir?.Checkout;\n\n/**\n * Collection is undefined if user is not loading a product or collection page.\n *\n * @type {OfirLiquidGlobals.Collection}\n */\nexport const Collection: OfirLiquidGlobals.Collection = window.__ofir?.Collection;\n\n/**\n * Customer is undefined if user is not logged in.\n *\n * @type {OfirLiquidGlobals.Customer}\n */\nexport const Customer: OfirLiquidGlobals.Customer = window.__ofir?.Customer;\n\n/**\n * GiftCard is undefined if user is not on gift card page.\n *\n * @type {OfirLiquidGlobals.GiftCard}\n */\nexport const GiftCard: OfirLiquidGlobals.GiftCard = window.__ofir?.GiftCard;\n\n/**\n * Order is undefined unless user is on thank_you page, order status page or account/order detail\n * page.\n *\n * @type {OfirLiquidGlobals.Order}\n */\nexport const Order: OfirLiquidGlobals.Order = window.__ofir?.Order;\n\n/** @type {OfirLiquidGlobals.Page} */\nexport const Page: OfirLiquidGlobals.Page = window.__ofir?.Page;\n\n/** @type {OfirLiquidGlobals.Pagination} */\nexport const Pagination: OfirLiquidGlobals.Pagination = window.__ofir?.Pagination;\n\n/**\n * Product is undefined if not accessing a product page template.\n *\n * @type {OfirLiquidGlobals.Product}\n */\nexport const Product: OfirLiquidGlobals.Product = window.__ofir?.Product;\n\n/** @type {OfirLiquidGlobals.Request} */\nexport const Request: OfirLiquidGlobals.Request = window.__ofir?.Request;\n\n/** @type {OfirLiquidGlobals.Scripts} */\nexport const Scripts: OfirLiquidGlobals.Scripts = window.__ofir?.Scripts;\n\n/** @type {OfirLiquidGlobals.Search} */\nexport const Search: OfirLiquidGlobals.Search = window.__ofir?.Search;\n\n/** @type {OfirLiquidGlobals.SearchEngineListing} */\nexport const SearchEngineListing: OfirLiquidGlobals.SearchEngineListing =\n  window.__ofir?.SearchEngineListing;\n\n/** @type {OfirLiquidGlobals.SectionSettings} */\nexport const SectionSettings: OfirLiquidGlobals.SectionSettings = window.__ofir?.SectionSettings;\n\n/** @type {OfirLiquidGlobals.Shop} */\nexport const Shop: OfirLiquidGlobals.Shop = window.__ofir?.Shop;\n\n/** @type {OfirLiquidGlobals.Template} */\nexport const Template: OfirLiquidGlobals.Template = window.__ofir?.Template;\n\n/** @type {OfirLiquidGlobals.Theme} */\nexport const Theme: OfirLiquidGlobals.Theme = window.__ofir?.Theme;\n\n/** @type {OfirLiquidGlobals.ThemeSettings} */\nexport const ThemeSettings: OfirLiquidGlobals.ThemeSettings = window.__ofir?.ThemeSettings;\n","import type * as GoogleTag from '@integrabeauty/google-tag';\nimport * as LiquidGlobal from '../../common/liquid-global';\n\nexport const GOOGLE_ANALYTICS_4_PROPERTY_ID = 'G-T4G3DP9D07';\nexport const GOOGLE_ADWORDS_PROPERTY_ID = 'AW-10932822801';\n\n/**\n * Convert a raw phone number (e.g. from user input) to the E.164 format, which means it must be 11\n * to 15 digits including a plus sign (+) prefix and country code with no dashes, parentheses, or\n * spaces.\n *\n * @see https://support.google.com/google-ads/answer/9888145\n */\nexport function phoneInputToE164(value: string) {\n  if (!value) {\n    return;\n  }\n\n  let phone = value.replace(/[^0-9]/g, '');\n  phone = phone.length === 10 ? `1${phone}` : phone;\n  phone = `+${phone}`;\n  return phone;\n}\n\nexport function getUserAddressProvince() {\n  if (LiquidGlobal.Order?.shipping_address?.province) {\n    return LiquidGlobal.Order?.shipping_address?.province;\n  }\n\n  if (LiquidGlobal.Order?.shipping_address?.province_code) {\n    return LiquidGlobal.Order?.shipping_address?.province_code;\n  }\n\n  if (LiquidGlobal.Customer?.default_address?.province) {\n    return LiquidGlobal.Customer?.default_address?.province;\n  }\n\n  if (LiquidGlobal.Customer?.default_address?.province_code) {\n    return LiquidGlobal.Customer?.default_address?.province_code;\n  }\n}\n\n/**\n * Per the docs, \"If your site doesn't collect one of the above fields, remove the field entirely\n * rather than leaving it blank.\" so we only set a field if it is not empty.\n *\n * @todo we can also use billing address and specify an array of addresses\n *\n * @see https://support.google.com/google-ads/answer/9888656\n * @see https://support.google.com/google-ads/answer/9888145\n */\nexport function buildUserData() {\n  const data: GoogleTag.UserData = {};\n  if (!LiquidGlobal.Customer && !LiquidGlobal.Order) {\n    return;\n  }\n\n  data.email = LiquidGlobal.Order?.email ?\n    LiquidGlobal.Order.email : LiquidGlobal.Customer.email;\n\n  data.phone_number = LiquidGlobal.Order?.shipping_address ?\n    phoneInputToE164(LiquidGlobal.Order.shipping_address.phone) :\n    phoneInputToE164(LiquidGlobal.Customer.phone);\n\n  const address: GoogleTag.MailingAddress = {};\n\n  address.first_name = LiquidGlobal.Order?.customer?.first_name ?? LiquidGlobal.Customer.first_name;\n  address.last_name = LiquidGlobal.Order?.customer?.last_name ?? LiquidGlobal.Customer.last_name;\n\n  if (LiquidGlobal.Order?.shipping_address) {\n    address.street = LiquidGlobal.Order.shipping_address.address1;\n    address.city = LiquidGlobal.Order.shipping_address.city;\n    address.postal_code = LiquidGlobal.Order.shipping_address.zip;\n    address.country = LiquidGlobal.Order.shipping_address.country_code;\n  } else if (LiquidGlobal.Customer?.default_address) {\n    address.street = LiquidGlobal.Customer.default_address.address1;\n    address.city = LiquidGlobal.Customer.default_address.city;\n    address.postal_code = LiquidGlobal.Customer.default_address.zip;\n    address.country = LiquidGlobal.Customer.default_address.country_code;\n  }\n\n  address.region = getUserAddressProvince();\n\n  // For address, first name, last name, postal code, and country are required. You can optionally\n  // provide street address, city, and region as additional match keys.\n  if (address.first_name && address.last_name && address.postal_code && address.country) {\n    data.address = address;\n  }\n\n  // According to https://support.google.com/google-ads/answer/9888145, At least one of the\n  // following fields must be provided:\n  //\n  // * Email\n  // * Address\n  // * Phone number (must be provided in conjunction with email, or full name and address)\n  //\n  // So what this basically means if that either email or address is required.\n  if (data.email || data.address) {\n    return data;\n  }\n\n  return null;\n}\n","import * as LiquidGlobal from '../../../common/liquid-global';\nimport * as utils from '../utils';\n\n/**\n * @todo also send events to universal analytics, google adwords?\n * @todo enhanced commerce\n *\n * @see https://developers.google.com/analytics/devguides/collection/ga4/reference/events#add_to_cart\n */\nexport function onAddToCart(event: OfirCustomEvents.AddToCartEvent) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  if (!event.detail.success) {\n    return;\n  }\n\n  if (!Array.isArray(event.detail.items)) {\n    return;\n  }\n\n  let totalValue = 0;\n  const ga4Items = [];\n  const awItems = [];\n  for (const item of event.detail.items) {\n    totalValue += item.quantity * item.line_price / 100;\n    ga4Items.push({\n      item_brand: 'ofir',\n      item_id: item.sku,\n      item_name: item.title,\n      item_category: item.product_type,\n      price: item.price / 100,\n      quantity: item.quantity\n    });\n\n    awItems.push({\n      brand: 'ofir',\n      id: item.sku,\n      name: item.title,\n      category: item.product_type,\n      price: item.price / 100,\n      quantity: item.quantity\n    });\n  }\n\n  /**\n   * TODO: specify item_variant, to do this we need variant title in the emitting event\n   *\n   * @see https://developers.google.com/analytics/devguides/collection/ga4/reference/events#add_to_cart\n   * @see https://developers.google.com/analytics/devguides/collection/ga4/reference/events#add_to_cart_item\n   */\n  gtag('event', 'add_to_cart', {\n    currency: LiquidGlobal.Shop.currency || 'USD',\n    items: ga4Items,\n    value: totalValue,\n    send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n  });\n\n  gtag('event', 'add_to_cart', {\n    currency: LiquidGlobal.Shop.currency || 'USD',\n    items: awItems,\n    value: totalValue,\n    send_to: utils.GOOGLE_ADWORDS_PROPERTY_ID\n  });\n}\n","import * as LiquidGlobal from '../../../common/liquid-global';\nimport * as utils from '../utils';\n\n/**\n * Responsible for emitting both GA4 and GoogleAds ecommerce event.\n *\n * @see https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#add_or_remove_an_item_from_a_shopping_cart\n */\nexport function onLineItemRemoved(event: WindowEventMap['line-item-removed']) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  const lineItem = event.detail.item;\n  const ga4Items = [];\n  ga4Items.push({\n    index: 1,\n    item_brand: 'ofir',\n    item_category: lineItem.product_type,\n    item_id: lineItem.sku,\n    item_name: lineItem.title,\n    price: lineItem.final_price / 100,\n    quantity: lineItem.quantity\n  });\n\n  gtag('event', 'remove_from_cart', {\n    currency: LiquidGlobal.Shop.currency || 'USD',\n    items: ga4Items,\n    value: lineItem.final_price / 100 * lineItem.quantity,\n    send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n  });\n\n  const awItems = [];\n  awItems.push({\n    brand: 'ofir',\n    category: lineItem.product_type,\n    id: lineItem.sku,\n    name: lineItem.title,\n    price: lineItem.final_price / 100,\n    quantity: lineItem.quantity\n  });\n\n  gtag('event', 'remove_from_cart', {\n    items: awItems,\n    send_to: utils.GOOGLE_ADWORDS_PROPERTY_ID\n  });\n}\n","import * as LiquidGlobal from '../../../common/liquid-global';\nimport * as utils from '../utils';\n\n/**\n * Responsible for emitting both GA4 and GoogleAds ecommerce event.\n *\n * TODO: Implement GoogleAds specific event or confirm GA4 events are being properly forwarded\n *\n * @see https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#add_or_remove_an_item_from_a_shopping_cart\n */\nexport function onViewCart(event: OfirCustomEvents.ViewCartEvent) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  if (!Array.isArray(event.detail.items)) {\n    return;\n  }\n\n  let totalValue = 0;\n  let index = 1;\n  const items = [];\n  for (const item of event.detail.items) {\n    totalValue += item.quantity * item.line_price / 100;\n    items.push({\n      item_id: `${item.sku}`,\n      item_name: item.product_title,\n      index,\n      item_brand: 'ofir',\n      item_category: item.product_type,\n      item_list_id: `${LiquidGlobal.Collection?.id}` || 'none',\n      item_list_name: LiquidGlobal.Collection?.handle || 'none',\n      item_variant: item.variant_title,\n      price: item.price / 100,\n      quantity: item.quantity\n    });\n    index = index + 1;\n  }\n\n  gtag('event', 'view_cart', {\n    currency: LiquidGlobal.Shop.currency || 'USD',\n    value: totalValue,\n    items,\n    send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n  });\n}\n","import * as LiquidGlobal from '../../../common/liquid-global';\nimport * as utils from '../utils';\n\n/**\n * Responsible for emitting both GA4 and GoogleAds ecommerce event.\n *\n * TODO: Implement GoogleAds specific event or confirm GA4 events are being properly forwarded\n *\n * @see https://developers.google.com/analytics/devguides/collection/ga4/reference/events#view_item\n * @see https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#view_item_details\n */\nexport function onViewItem(event: WindowEventMap['ofir-view-item']) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  if (LiquidGlobal.Template.name !== 'product') {\n    return;\n  }\n\n  gtag('event', 'view_item', {\n    currency: LiquidGlobal.Shop.currency || 'USD',\n    items: [\n      {\n        item_brand: 'ofir',\n        item_id: event.detail.sku,\n        item_category: event.detail.product_type,\n        item_name: event.detail.product_title,\n        item_variant: event.detail.variant_id.toString() ?? '',\n        price: event.detail.price / 100\n      }\n    ],\n    value: event.detail.price / 100,\n    send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n  });\n\n  // See https://developers.google.com/google-ads/api/docs/dynamic-remarketing/prerequisites. Per\n  // the docs, \"the event name you use can be a custom event name of your choosing or one of our\n  // recommended standard events. It doesn't need to match any specific value for the purpose of\n  // implementing dynamic remarketing, as long as the event data parameters (ecomm_pagetype,\n  // ecomm_prodid, and ecomm_totalvalue in this example) are correctly set.\"\n  //\n  //\n  // TODO: setup the dynamic properties too\n  gtag('event', 'view_item', {\n    currency: 'USD',\n    ecomm_pagetype: 'product',\n    ecomm_prodid: event.detail.sku,\n    ecomm_totalvalue: event.detail.price / 100,\n    items: [\n      {\n        category: event.detail.product_type,\n        google_business_vertical: 'retail',\n        id: event.detail.sku,\n        name: event.detail.product_title,\n        price: event.detail.price / 100\n      }\n    ],\n    value: event.detail.price / 100,\n    send_to: utils.GOOGLE_ADWORDS_PROPERTY_ID\n  });\n}\n","import * as LiquidGlobal from '../../../common/liquid-global';\nimport * as utils from '../utils';\n\n/**\n * Responsible for emitting both GA4 and GoogleAds ecommerce event.\n *\n * TODO: Implement GoogleAds specific event or confirm GA4 events are being properly forwarded\n *\n * @see https://developers.google.com/analytics/devguides/collection/ga4/reference/events#view_item_list\n * @see https://developers.google.com/analytics/devguides/collection/ga4/ecommerce?client_type=gtag#select_an_item_from_a_list\n */\nexport function onViewItemList(event: WindowEventMap['ofir-view-item-list']) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  if (LiquidGlobal.Template.name !== 'collection') {\n    return;\n  }\n\n  const ga4Items = [];\n  const awItems = [];\n  let position = 1;\n\n  for (const product of event.detail.products) {\n    ga4Items.push({\n      index: position,\n      item_brand: 'ofir',\n      item_category: product.type,\n      item_id: product.selected_or_first_available_variant.sku,\n      item_name: product.title,\n      item_variant: product.subtitle,\n      price: product.selected_or_first_available_variant.price / 100,\n      quantity: 1,\n      currency: LiquidGlobal.Shop.currency || 'USD'\n    });\n\n    awItems.push({\n      brand: 'ofir',\n      category: product.type,\n      id: product.selected_or_first_available_variant.sku,\n      index: position,\n      name: product.title,\n      list_name: event.detail.name,\n      price: product.variants?.length > 0 ? product.variants[0].price / 100 : 0,\n      quantity: 1,\n      variant: product.subtitle\n    });\n\n    position++;\n  }\n\n  // we do not set item list id/name per item because it is set at the \"event level\". same goes for\n  // currency. see the detailed docs in the reference link.\n  gtag('event', 'view_item_list', {\n    item_list_id: event.detail.id,\n    item_list_name: event.detail.name,\n    items: ga4Items,\n    send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n  });\n\n  gtag('event', 'view_item_list', {\n    items: awItems,\n    send_to: utils.GOOGLE_ADWORDS_PROPERTY_ID\n  });\n}\n","import '@integrabeauty/custom-events';\nimport type * as _GoogleTag from '@integrabeauty/google-tag';\nimport * as LiquidGlobal from '../../common/liquid-global';\nimport * as common from '../common';\nimport * as GoogleEvents from './events';\nimport * as utils from './utils';\n\nfunction onDOMContentLoaded() {\n  if (LiquidGlobal.Template.name !== 'product' && LiquidGlobal.Template.name !== 'collection' &&\n    LiquidGlobal.Template.name !== 'cart' && !location.href.includes('checkouts')) {\n    gtag('event', 'page_view', {\n      page_title: document.title,\n      page_location: location.href,\n      page_path: location.pathname,\n      send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID\n    });\n  }\n}\n\n/**\n * Handles form-submit events by sending a sign_up event to Google Analytics.\n */\nfunction onFormSubmit(event: WindowEventMap['form-submit']) {\n  const formType = event.detail.form_type;\n  if (formType) {\n    window.gtag('event', 'sign_up', {\n      method: formType,\n      send_to: utils.GOOGLE_ANALYTICS_4_PROPERTY_ID,\n      form_name: event.detail.form_name,\n      form_location: event.detail.form_location\n    });\n  }\n}\n\nfunction main() {\n// Enhanced conversions\n  const userData = utils.buildUserData();\n  if (userData) {\n    gtag('set', 'user_data', userData);\n  }\n\n  const config: Config = {\n    allow_ad_personalization_signals: true,\n    allow_enhanced_conversions: true,\n    allow_google_signals: true,\n    anonymize_ip: false,\n    conversion_linker: true\n  };\n\n  if (LiquidGlobal.Customer?.id) {\n    config.user_id = `${LiquidGlobal.Customer.id}`;\n  }\n\n  gtag('config', utils.GOOGLE_ANALYTICS_4_PROPERTY_ID, config);\n  gtag('config', utils.GOOGLE_ADWORDS_PROPERTY_ID, config);\n\n  // Gather and send custom dimensions. In GA4 we need to attach these to some event. We cannot\n  // use the implicit page view from config. We could disable page view from config and send an\n  // explicit page view but that seems to be detected as a history change instead of a page view.\n\n  const dimensions = <Record<string, string>>{};\n  const url = new URL(location.href);\n  const couponCode = url.searchParams.get('couponcode');\n  if (couponCode) {\n    dimensions.coupon_code_url_parameter = couponCode.toUpperCase();\n  }\n\n  const affiliate = url.searchParams.get('aff') || url.searchParams.get('affiliate');\n  if (affiliate && affiliate !== '{affiliate}') {\n    dimensions.affiliate_url_parameter = affiliate.toUpperCase();\n  }\n\n  const placement = url.searchParams.get('placement');\n  if (placement && placement !== '{placement}') {\n    dimensions.placement_url_parameter = placement.toUpperCase();\n  }\n\n  const adId = url.searchParams.get('ad.id');\n  if (adId && adId !== '{ad.id}') {\n    dimensions.ad_id_url_parameter = adId;\n  }\n\n  if (window.Shopify?.theme?.name) {\n    dimensions.shopify_theme = window.Shopify.theme.name;\n  }\n\n  if (Object.keys(dimensions).length > 0) {\n    window.gtag('event', 'capture_custom_dimensions', dimensions);\n  }\n\n  const registry = <Record<string, (...args: unknown[])=> void>>{\n    'DOMContentLoaded': onDOMContentLoaded,\n    'ofir-add-to-cart': GoogleEvents.onAddToCart,\n    'line-item-removed': GoogleEvents.onLineItemRemoved,\n    'ofir-view-cart': GoogleEvents.onViewCart,\n    'ofir-view-item': GoogleEvents.onViewItem,\n    'ofir-view-item-list': GoogleEvents.onViewItemList,\n    'form-submit': onFormSubmit\n  };\n\n  common.setupRegistry(registry);\n}\n\n/**\n * Shopify's Google Analytics app adds googletagmanager scripts later than this script is executed.\n * I don't think it has to be here and should be removed when we confirm that those events could be\n * removed and default Shopify events from the google-web-pixel app are enough.\n */\nfunction waitForGtag(callback: ()=> void) {\n  // eslint-disable-next-line @typescript-eslint/no-deprecated\n  if (typeof gtag !== 'undefined') {\n    callback();\n  } else {\n    setTimeout(() => waitForGtag(callback), 100);\n  }\n}\n\nwaitForGtag(main);\n","/**\n * Appends a script element in the head that loads its url async.\n *\n * @todo set crossorigin or other attributes?\n *\n * @param url The script url to load\n * @returns A promise that resolves to a load event or rejects with an error event\n */\nexport function loadScript(url: string) {\n  return new Promise<Event>((resolve, reject) => {\n    const script = document.createElement('script');\n    script.async = true;\n    script.addEventListener('load', resolve);\n    script.addEventListener('error', reject);\n    document.head.append(script);\n    script.src = url;\n  });\n}\n\n/**\n * Search the queue for events that have already fired. For each event, search for whether we have a\n * listener for the event. If found, directly dispatch the event to the listener. This fixes the\n * issue where the script that loads the registry does not add its event listeners until after the\n * event has fired.\n *\n * Then register event listeners for each key of the registry.\n *\n * We cannot restrict the type of parameters to the callback because we have some special callbacks\n * such as the callback for the global error event. However, most of the time the callback is just\n * one parameter, event of type Event.\n *\n * @param registry An event registry\n */\nexport function setupRegistry(registry: Record<string, (...args: unknown[])=> void>) {\n  for (const event of window.ofir.queue) {\n    const listener = registry[event?.type];\n    if (listener) {\n      listener(event);\n    }\n  }\n\n  for (const eventType in registry) {\n    addEventListener(eventType, registry[eventType]);\n  }\n}\n"],"names":["window","__ofir","_window$__ofir","Cart","_window$__ofir2","Checkout","Collection","_window$__ofir3","Customer","_window$__ofir4","Order","_window$__ofir5","GiftCard","_window$__ofir6","Shop","_window$__ofir7","Page","_window$__ofir8","Pagination","_window$__ofir9","Product","_window$__ofir0","Request","_window$__ofir1","Scripts","_window$__ofir10","Search","_window$__ofir11","SearchEngineListing","_window$__ofir12","SectionSettings","_window$__ofir13","Template","_window$__ofir14","_window$__ofir15","Theme","_window$__ofir16","ThemeSettings","GOOGLE_ANALYTICS_4_PROPERTY_ID","GOOGLE_ADWORDS_PROPERTY_ID","phoneInputToE164","value","phone","replace","length","concat","buildUserData","_LiquidGlobal$Order5","_LiquidGlobal$Order6","_LiquidGlobal$Order$c","_LiquidGlobal$Order7","_LiquidGlobal$Order$c2","_LiquidGlobal$Order8","_LiquidGlobal$Order9","_LiquidGlobal$Custome5","data","LiquidGlobal","email","phone_number","shipping_address","address","_LiquidGlobal$Order","_LiquidGlobal$Order3","_LiquidGlobal$Custome","_LiquidGlobal$Custome3","_LiquidGlobal$Order2","_LiquidGlobal$Order4","_LiquidGlobal$Custome2","_LiquidGlobal$Custome4","first_name","customer","last_name","street","address1","city","postal_code","zip","country","country_code","default_address","region","province","province_code","onAddToCart","event","detail","success","Array","isArray","items","totalValue","ga4Items","awItems","item","quantity","line_price","push","item_brand","item_id","sku","item_name","title","item_category","product_type","price","brand","id","name","category","gtag","currency","send_to","utils","onLineItemRemoved","lineItem","index","final_price","onViewCart","_LiquidGlobal$Collect","_LiquidGlobal$Collect2","product_title","item_list_id","item_list_name","handle","item_variant","variant_title","onViewItem","_event$detail$variant","variant_id","toString","ecomm_pagetype","ecomm_prodid","ecomm_totalvalue","google_business_vertical","onViewItemList","position","product","products","_product$variants","type","selected_or_first_available_variant","subtitle","list_name","variants","variant","onDOMContentLoaded","location","href","includes","page_title","document","page_location","page_path","pathname","onFormSubmit","formType","form_type","method","form_name","form_location","waitForGtag","callback","setTimeout","_window$Shopify","userData","config","allow_ad_personalization_signals","allow_enhanced_conversions","allow_google_signals","anonymize_ip","conversion_linker","user_id","dimensions","url","URL","couponCode","searchParams","get","coupon_code_url_parameter","toUpperCase","affiliate","affiliate_url_parameter","placement","placement_url_parameter","adId","ad_id_url_parameter","Shopify","theme","shopify_theme","Object","keys","registry","ofir","queue","listener","eventType","addEventListener","common","GoogleEvents"],"sourceRoot":""}