{
  "version": 3,
  "sources": ["/cdn/shop/t/5/assets/cart-functions.js?enable_js_minification=1"],
  "sourcesContent": ["function getDefaultRequestConfig() {\n  return JSON.parse(\n    JSON.stringify({\n      credentials: 'same-origin',\n      headers: {\n        'X-Requested-With': 'XMLHttpRequest',\n        'Content-Type': 'application/json;'\n      }\n    })\n  );\n}\n\nfunction fetchJSON(url, config) {\n  return fetch(url, config).then(function(response) {\n    if (!response.ok) {\n      throw response;\n    }\n    return response.json();\n  });\n}\n\n\nasync function fetchJSONPromise(url, config) {\n  const response = await fetch(url, config);\n  return response.json();\n}\n\nfunction cart() {\n  return fetchJSON('/cart.js', getDefaultRequestConfig());\n}\n\nasync function cartAdd(id, quantity, properties) {\n  var config = getDefaultRequestConfig();\n\n  config.method = 'POST';\n  config.body = JSON.stringify({\n    id: id,\n    quantity: quantity,\n    properties: properties\n  });\n\n  return await fetchJSONPromise('/cart/add.js', config);\n\n}\n\nfunction cartAddFromForm(formData) {\n  var config = getDefaultRequestConfig();\n  delete config.headers['Content-Type'];\n\n  config.method = 'POST';\n  config.body = formData;\n\n  return fetchJSON('/cart/add.js', config);\n}\n\nasync function cartChange(line, quantity) {\n  var config = getDefaultRequestConfig();\n\n  options = options || {};\n\n  config.method = 'POST';\n  config.body = JSON.stringify({\n    id: line,\n    quantity: quantity\n  });\n\n  return await fetchJSONPromise('/cart/change.js', config);\n}\n\nfunction cartClear() {\n  var config = getDefaultRequestConfig();\n  config.method = 'POST';\n\n  return fetchJSON('/cart/clear.js', config);\n}\n\nfunction cartUpdate(body) {\n  var config = getDefaultRequestConfig();\n\n  config.method = 'POST';\n  config.body = JSON.stringify(body);\n\n  return fetchJSON('/cart/update.js', config);\n}\n\nfunction cartShippingRates() {\n  return fetchJSON('/cart/shipping_rates.json', getDefaultRequestConfig());\n}\n\nfunction key(key) {\n  if (typeof key !== 'string' || key.split(':').length !== 2) {\n    throw new TypeError(\n      'Theme Cart: Provided key value is not a string with the format xxx:xxx'\n    );\n  }\n}\n\nfunction quantity(quantity) {\n  if (typeof quantity !== 'number' || isNaN(quantity)) {\n    throw new TypeError(\n      'Theme Cart: An object which specifies a quantity or properties value is required'\n    );\n  }\n}\n\nfunction id(id) {\n  if (typeof id !== 'number' || isNaN(id)) {\n    throw new TypeError('Theme Cart: Variant ID must be a number');\n  }\n}\n\nfunction properties(properties) {\n  if (typeof properties !== 'object') {\n    throw new TypeError('Theme Cart: Properties must be an object');\n  }\n}\n\nfunction form(form) {\n  if (!(form instanceof HTMLFormElement)) {\n    throw new TypeError('Theme Cart: Form must be an instance of HTMLFormElement');\n  }\n}\n\nfunction options(options) {\n  if (typeof options !== 'object') {\n    throw new TypeError('Theme Cart: Options must be an object');\n  }\n\n  if (\n    typeof options.quantity === 'undefined' &&\n    typeof options.properties === 'undefined'\n  ) {\n    throw new Error(\n      'Theme Cart: You muse define a value for quantity or properties'\n    );\n  }\n\n  if (typeof options.quantity !== 'undefined') {\n    quantity(options.quantity);\n  }\n\n  if (typeof options.properties !== 'undefined') {\n    properties(options.properties);\n  }\n}\n\n/**\n * Cart Template Script\n * ------------------------------------------------------------------------------\n * A file that contains scripts highly couple code to the Cart template.\n *\n * @namespace cart\n */\n\n/**\n * Returns the state object of the cart\n * @returns {Promise} Resolves with the state object of the cart (https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#get-cart)\n */\nfunction getState() {\n  return cart();\n}\n\n/**\n * Returns the index of the cart line item\n * @param {string} key The unique key of the line item\n * @returns {Promise} Resolves with the index number of the line item\n */\nfunction getItemIndex(key$$1) {\n  key(key$$1);\n\n  return cart().then(function(state) {\n    var index = -1;\n\n    state.items.forEach(function(item, i) {\n      index = item.key === key$$1 ? i + 1 : index;\n    });\n\n    if (index === -1) {\n      return Promise.reject(\n        new Error('Theme Cart: Unable to match line item with provided key')\n      );\n    }\n\n    return index;\n  });\n}\n\n/**\n * Fetches the line item object\n * @param {string} key The unique key of the line item\n * @returns {Promise} Resolves with the line item object (See response of cart/add.js https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#add-to-cart)\n */\nfunction getItem(key$$1) {\n  key(key$$1);\n\n  return cart().then(function(state) {\n    var lineItem = null;\n\n    state.items.forEach(function(item) {\n      lineItem = item.key === key$$1 ? item : lineItem;\n    });\n\n    if (lineItem === null) {\n      return Promise.reject(\n        new Error('Theme Cart: Unable to match line item with provided key')\n      );\n    }\n\n    return lineItem;\n  });\n}\n\n/**\n * Add a new line item to the cart\n * @param {number} id The variant's unique ID\n * @param {object} options Optional values to pass to /cart/add.js\n * @param {number} options.quantity The quantity of items to be added to the cart\n * @param {object} options.properties Line item property key/values (https://help.shopify.com/en/themes/liquid/objects/line_item#line_item-properties)\n * @returns {Promise} Resolves with the line item object (See response of cart/add.js https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#add-to-cart)\n */\nfunction addItem(id$$1, options$$1) {\n  options$$1 = options$$1 || {};\n\n  id(id$$1);\n\n  return cartAdd(id$$1, options$$1.quantity, options$$1.properties);\n}\n\n/**\n * Add a new line item to the cart from a product form\n * @param {object} form DOM element which is equal to the <form> node\n * @returns {Promise} Resolves with the line item object (See response of cart/add.js https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#add-to-cart)\n */\nfunction addItemFromForm(form$$1) {\n  form(form$$1);\n\n  var formData = new FormData(form$$1);\n  id(parseInt(formData.get('id'), 10));\n\n  return cartAddFromForm(formData);\n}\n\n/**\n * Changes the quantity and/or properties of an existing line item.\n * @param {string} key The unique key of the line item (https://help.shopify.com/en/themes/liquid/objects/line_item#line_item-key)\n * @param {object} options Optional values to pass to /cart/add.js\n * @param {number} options.quantity The quantity of items to be added to the cart\n * @param {object} options.properties Line item property key/values (https://help.shopify.com/en/themes/liquid/objects/line_item#line_item-properties)\n * @returns {Promise} Resolves with the state object of the cart (https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#get-cart)\n */\nfunction updateItem(key$$1, options$$1) {\n  key(key$$1);\n  options(options$$1);\n\n  return getItemIndex(key$$1).then(function(line) {\n    return cartChange(line, options$$1);\n  });\n}\n\n/**\n * Removes a line item from the cart\n * @param {string} key The unique key of the line item (https://help.shopify.com/en/themes/liquid/objects/line_item#line_item-key)\n * @returns {Promise} Resolves with the state object of the cart (https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#get-cart)\n */\nfunction removeItem(key$$1) {\n  key(key$$1);\n\n  return getItemIndex(key$$1).then(function(line) {\n    return cartChange(line, { quantity: 0 });\n  });\n}\n\n/**\n * Sets all quantities of all line items in the cart to zero. This does not remove cart attributes nor the cart note.\n * @returns {Promise} Resolves with the state object of the cart (https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#get-cart)\n */\nfunction clearItems() {\n  return cartClear();\n}\n\n/**\n * Gets all cart attributes\n * @returns {Promise} Resolves with the cart attributes object\n */\nfunction getAttributes() {\n  return cart().then(function(state) {\n    return state.attributes;\n  });\n}\n\n/**\n * Sets all cart attributes\n * @returns {Promise} Resolves with the cart state object\n */\nfunction updateAttributes(attributes) {\n  return cartUpdate({ attributes: attributes });\n}\n\n/**\n * Clears all cart attributes\n * @returns {Promise} Resolves with the cart state object\n */\nfunction clearAttributes() {\n  return getAttributes().then(function(attributes) {\n    for (var key$$1 in attributes) {\n      attributes[key$$1] = '';\n    }\n    return updateAttributes(attributes);\n  });\n}\n\n/**\n * Gets cart note\n * @returns {Promise} Resolves with the cart note string\n */\nfunction getNote() {\n  return cart().then(function(state) {\n    return state.note;\n  });\n}\n\n/**\n * Sets cart note\n * @returns {Promise} Resolves with the cart state object\n */\nfunction updateNote(note) {\n  return cartUpdate({ note: note });\n}\n\n/**\n * Clears cart note\n * @returns {Promise} Resolves with the cart state object\n */\nfunction clearNote() {\n  return cartUpdate({ note: '' });\n}\n\n/**\n * Get estimated shipping rates.\n * @returns {Promise} Resolves with response of /cart/shipping_rates.json (https://help.shopify.com/en/themes/development/getting-started/using-ajax-api#get-shipping-rates)\n */\nfunction getShippingRates() {\n  return cartShippingRates();\n}\n"],
  "mappings": "AAAA,SAAS,yBAA0B,CACjC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