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AAHI,OAAcZ,EAAMS,OAAOC,WAAU,KAAAE,OAAIZ,EAAMS,OAAOE,YACtDX,EAAMS,OAAOC,aACtBF,EAAY,WAAHI,OAAcZ,EAAMS,OAAOC,aAGtCjD,OAAOoD,IAAI,QAAS,cAAe,CACjCC,iBAAkBd,EAAMS,OAAOM,aAC/BC,aAAchB,EAAMS,OAAOQ,cAC3BC,YAAaV,EAAY,CAACA,QAAaW,EACvCC,aAAc,UACdC,SAAU,MACVC,MAAOtB,EAAMS,OAAOc,OAExB,EA8CE,qCA5CF,SAAsCvB,GACR,iBAAjBA,EAAMS,QAAwC,OAAjBT,EAAMS,SAIzCT,EAAMS,OAAOe,SAAYxB,EAAMS,OAAOgB,kBAI3ChE,OAAOoD,IAAI,QAAS,uBAAwB,CAC1CG,aAAchB,EAAMS,OAAOgB,gBAC3BC,kBAAmB1B,EAAMS,OAAOgB,gBAChCE,QAAQ,GAEZ,EA+BE,mBA7BF,SAAqB3B,GACnB,GAA4B,iBAAjBA,EAAMS,QAAwC,OAAjBT,EAAMS,QAKzCT,EAAMS,OAAOe,QAIlB,IAAK,MAAMI,KAAQ5B,EAAMS,OAAOoB,MAAO,CACrC,MAAMC,EAAmD,CACvDhB,iBAAkBc,EAAKb,aACvBC,aAAcY,EAAKG,MACnBX,aAAc,UACdF,YAAiD,kBAApCU,EAAKb,aAAaiB,cAC7B,CAAC,WAADpB,OAAYgB,EAAKlB,aACjB,CAAC,WAADE,OAAYgB,EAAKlB,WAAU,KAAAE,OAAIgB,EAAKjB,aACtCU,SAAUY,EAAmBZ,UAAY,MACzCC,MAAOM,EAAKM,WAAaN,EAAKM,WAAa,IAAM,GAGnDzE,OAAOoD,IAAI,QAAS,YAAaiB,EACnC,CACF,G","sources":["webpack://lange/./scripts/common/liquid-global.ts","webpack://lange/./scripts/integrations/common.ts","webpack://lange/./scripts/integrations/facebook/index.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","/**\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","import * as LiquidGlobals from '../../common/liquid-global';\nimport * as common from '../common';\n\n/**\n * @see https://developers.facebook.com/docs/meta-pixel/reference#object-properties\n */\nfunction onViewItem(event: WindowEventMap['ofir-view-item']) {\n  // relevant fields are content_ids, content_category, content_name, content_type, contents,\n  // currency, and value. if using dynamic ads then content_type and contents or content_ids are\n  // required.\n\n  // The producer of the content viewed event is not yet giving us currency so we have to assume it\n  // is USD.\n\n  // price is already in dollars here, we do not divide by 100\n\n  // This used to incorrectly specify content type as product_group but it is always product, we\n  // are viewing a single product.\n\n  // TODO: this is missing contents, it was not even in the legacy GTM implementation\n\n  // the legacy implementation was passing the property content_sku but this is not a real property\n\n  let contentId;\n  if (event.detail.product_id && event.detail.variant_id) {\n    contentId = `shopify_${event.detail.product_id}_${event.detail.variant_id}`;\n  } else if (event.detail.product_id) {\n    contentId = `shopify_${event.detail.product_id}`;\n  }\n\n  window.fbq('track', 'ViewContent', {\n    content_category: event.detail.product_type,\n    content_name: event.detail.product_title,\n    content_ids: contentId ? [contentId] : undefined,\n    content_type: 'product',\n    currency: 'USD',\n    value: event.detail.price\n  });\n}\n\nfunction onStayConnectedFormSubmitted(event: OfirCustomEvents.StayConnectedFormSubmittedEvent) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  if (!event.detail.success && !event.detail.subscribed_from) {\n    return;\n  }\n\n  window.fbq('track', 'CompleteRegistration', {\n    content_name: event.detail.subscribed_from,\n    registration_type: event.detail.subscribed_from,\n    status: true\n  });\n}\n\nfunction onAddToCart(event: OfirCustomEvents.AddToCartEvent) {\n  if (typeof event.detail !== 'object' || event.detail === null) {\n    return;\n  }\n\n  // Ignore failed adds\n  if (!event.detail.success) {\n    return;\n  }\n\n  for (const item of event.detail.items) {\n    const properties: Partial<Facebook.StandardProperties> = {\n      content_category: item.product_type,\n      content_name: item.title,\n      content_type: 'product',\n      content_ids: item.product_type.toLowerCase() === 'simple-bundle' ?\n        [`shopify_${item.product_id}`] :\n        [`shopify_${item.product_id}_${item.variant_id}`],\n      currency: LiquidGlobals.Shop.currency || 'USD',\n      value: item.line_price ? item.line_price / 100 : 0\n    };\n\n    window.fbq('track', 'AddToCart', properties);\n  }\n}\n\nconst registry = <Record<string, (...args: unknown[])=> void>>{\n  'ofir-view-item': onViewItem,\n  'ofir-stay-connected-form-submitted': onStayConnectedFormSubmitted,\n  'ofir-add-to-cart': onAddToCart\n};\n\ncommon.setupRegistry(registry);\n"],"names":["window","__ofir","_window$__ofir","Cart","_window$__ofir2","Checkout","_window$__ofir3","Collection","_window$__ofir4","Customer","_window$__ofir5","GiftCard","_window$__ofir6","Order","_window$__ofir7","Page","_window$__ofir8","Pagination","_window$__ofir9","Product","_window$__ofir0","Request","_window$__ofir1","Scripts","_window$__ofir10","Search","_window$__ofir11","SearchEngineListing","_window$__ofir12","SectionSettings","Shop","_window$__ofir13","_window$__ofir14","Template","_window$__ofir15","Theme","_window$__ofir16","ThemeSettings","registry","event","ofir","queue","listener","type","eventType","addEventListener","common","contentId","detail","product_id","variant_id","concat","fbq","content_category","product_type","content_name","product_title","content_ids","undefined","content_type","currency","value","price","success","subscribed_from","registration_type","status","item","items","properties","title","toLowerCase","LiquidGlobals","line_price"],"sourceRoot":""}