"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[20],{191:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateCartPartialState=void 0;const o=r(388);e.generateCartPartialState=function({context:t}){const e=(0,o.cartLibSubState)({context:t});return function(t,r){return e(t,r)}}},166:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.cartLibSubState=void 0;const n=r(18),s=r(192),i=r(49),a=r(37);e.cartLibSubState=({context:t})=>(e,r)=>{const{itemsCount:c}=t;return{cart:Object.assign(Object.assign({},i.defaultCart),{itemsCount:c}),cartErrors:i.defaultCartErrors,isBusy:!0,isSync:!1,shouldGenerateNewCartByForce:!1,_initCart:function(){return o(this,void 0,void 0,(function*(){const t=(0,s.readCartIdFromLocalStorage)();try{const r=yield(0,n.initializeCart)(t);t!==(null==r?void 0:r.id)&&(0,s.saveCartIdToLocalStorage)(null==r?void 0:r.id);const o=(0,a.prepareCart)(r);e((()=>({cart:o,shouldGenerateNewCartByForce:!1})))}catch(t){console.error("Couldn't create a cart")}}))},addToCart:function(t){return o(this,void 0,void 0,(function*(){try{const{cart:o}=r();if(!o)return;const s=Object.assign(Object.assign({},t),{cartId:o.id}),i=o.id,c=yield(0,n.addToCartRequest)(s);if(void 0===c)throw new Error("Couldn't ADD item to the cart");const d=i!==c.id,u=(0,a.prepareCart)(c);e((()=>({cart:u,shouldGenerateNewCartByForce:d})))}catch(t){throw console.error(t),new Error}}))},removeFromCart:function(t){return o(this,void 0,void 0,(function*(){try{const{cart:o}=r();if(!o)return;const i=Object.assign(Object.assign({},t),{cartId:o.id}),c=o.id,d=yield(0,n.removeFromCartRequest)(i);if(void 0===d)throw new Error("Couldn't REMOVE item from the cart");const u=c!==d.id;u&&(0,s.saveCartIdToLocalStorage)(d.id);const l=(0,a.prepareCart)(d);e((()=>({cart:l,shouldGenerateNewCartByForce:u})))}catch(t){throw console.error(t),new Error}}))},updateCartItem:function(t){return o(this,void 0,void 0,(function*(){try{const{cart:o}=r();if(!o)return;const s=Object.assign(Object.assign({},t),{cartId:o.id}),i=o.id,c=yield(0,n.updateToCartRequest)(s);if(void 0===c)throw new Error("Couldn't UPDATE item in the cart");const d=i!==c.id,u=(0,a.prepareCart)(c);e((()=>({cart:u,shouldGenerateNewCartByForce:d})))}catch(t){throw console.log(t),new Error}}))},updateCartCustomer:function(){return o(this,void 0,void 0,(function*(){try{const{cart:t,customer:o}=r();if(!t)throw new Error;if(!o)throw new Error;const i={cartId:t.id,customerId:o.entityId},c=yield(0,n.updateCartByCustomerIdRequest)(i);if(void 0===c)throw new Error;const d=t.id!==c.id;d&&(0,s.saveCartIdToLocalStorage)(c.id);const u=(0,a.prepareCart)(c);e((()=>({cart:u,shouldGenerateNewCartByForce:d})))}catch(t){console.error("Couldn't assign Customer to the Cart")}}))},addDiscount:function(t){return o(this,void 0,void 0,(function*(){}))},setCartErrors:function(t){e((()=>({cartErrors:t})))}}}},388:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.cartLibSubState=void 0;var o=r(166);Object.defineProperty(e,"cartLibSubState",{enumerable:!0,get:function(){return o.cartLibSubState}})},193:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateCheckoutPartialState=void 0;const o=r(389);e.generateCheckoutPartialState=function({context:t}){const e=(0,o.checkoutSubState)({context:t});return function(t,r){return e(t,r)}}},167:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.checkoutSubState=void 0;const n=r(18),s=r(49),i=r(192);e.checkoutSubState=({context:t})=>(t,e)=>({checkout:s.defaultCheckout,_initCheckout:function(){return o(this,void 0,void 0,(function*(){const e=(0,i.readCartIdFromLocalStorage)();if(e)try{const r=yield(0,n.checkoutRequest)({cartId:e});if(!r)throw new Error;t((()=>({checkout:r})))}catch(t){console.error("Couldn't create a checkout")}}))},updateCheckout:function(){return o(this,void 0,void 0,(function*(){const e=(0,i.readCartIdFromLocalStorage)();if(e)try{const r=yield(0,n.updateCheckoutRequest)({cartId:e});if(!r)throw new Error;t((()=>({checkout:r})))}catch(t){console.error("Couldn't update a checkout")}}))}})},389:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.checkoutSubState=void 0;var o=r(167);Object.defineProperty(e,"checkoutSubState",{enumerable:!0,get:function(){return o.checkoutSubState}})},189:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateContextPartialState=void 0,e.generateContextPartialState=function({context:t}){return function(e,r){return{context:Object.assign({},t)}}}},195:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateCustomerPartialState=e.CustomerPartialState=void 0;const o=r(391),n=r(392);Object.defineProperty(e,"CustomerPartialState",{enumerable:!0,get:function(){return n.CustomerPartialState}}),e.generateCustomerPartialState=({context:t})=>{const e=(0,o.customerLibSubState)({context:t}),r=(0,o.customerOrdersLibSubState)({context:t});return function(t,o){const n=e(t,o),s=r(t,o);return Object.assign(Object.assign({},n),s)}}},392:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0})},169:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.customerLibSubState=void 0;const n=r(16),s=r(47),i=r(172),a="/graphql";e.customerLibSubState=()=>(t,e)=>({customer:void 0,isLoggedIn:!1,customerInfo:null,customerAddresses:[],getCurrentCustomer:function(){return o(this,void 0,void 0,(function*(){try{const r=e().customer;if(r)return void t((()=>({isLoggedIn:!0,customer:r})));const o=new n.GraphQLClient(a),s=yield o.request((0,i.currentlyLoggedInCustomer)());if(!(null==s?void 0:s.customer))return void t((()=>({isLoggedIn:!1,customer:void 0})));t((()=>({isLoggedIn:!0,customer:s.customer})))}catch(e){e&&console.error(e),t((()=>({isLoggedIn:!1,customer:void 0})))}}))},getCustomerAddresses:function(){return o(this,void 0,void 0,(function*(){t((()=>({customerInfo:null})));try{const r=e().customer;if(!r)return;const o="/v3/customers/addresses",n=yield fetch(o,{method:"GET",headers:{"content-type":"application/json",Accept:"application/json"}});if(200!==n.status)t((()=>({customerInfo:{status:n.status,method:"get",message:n.statusText}})));else{const e=(yield n.json()).data.map((t=>({firstName:t.first_name,lastName:t.last_name,address1:t.address1.replace(/\.$/,""),address2:t.address2,city:t.city,countryCode:t.country_code,stateOrProvince:t.state_or_province,postalCode:t.postal_code,phone:t.phone,company:t.company,country:t.country,addressType:t.address_type,customerId:r.entityId,id:t.id})));t((()=>({customerAddresses:[...e]})))}}catch(e){const r=e;if(r){const e=(0,i.prepareErrorMessage)(r,"get all addresses");t((()=>{var t;return{customerInfo:{status:(null===(t=r.response)||void 0===t?void 0:t.status)?r.response.status:400,method:"post",message:e}}}))}}}))},createCustomerAddress:function(r){return o(this,void 0,void 0,(function*(){try{const o=e().customer,n=e().customerAddresses;if(t((()=>({customerInfo:null}))),!o)return;const s="/v3/customers/addresses",i=r.map((t=>({customer_id:t.customerId,first_name:t.firstName,last_name:t.lastName,address1:t.address1,address2:t.address2,city:t.city,country_code:t.countryCode,state_or_province:t.stateOrProvince,postal_code:t.postalCode,phone:t.phone,address_type:t.addressType}))),a=yield fetch(s,{method:"POST",body:JSON.stringify(i)}),c=yield a.json();if(200===a.status){const e=c.data.map((t=>({firstName:t.first_name,lastName:t.last_name,address1:t.address1,address2:t.address2,city:t.city,countryCode:t.country_code,stateOrProvince:t.state_or_province,postalCode:t.postal_code,phone:t.phone,company:t.company,country:t.country,addressType:t.address_type,customerId:o.entityId,id:t.id}))),r=[...n,...e],s=[...new Map(r.map((t=>[t.id,t]))).values()];t((()=>({customerAddresses:[...s],customerInfo:null})))}if(200!==a.status)return void t((()=>({customerAddresses:[...n],customerInfo:{status:c.status,method:"post",message:`${c.title}`}})))}catch(e){const r=e;if(r){const e=(0,i.prepareErrorMessage)(r,"create an address");t((()=>{var t;return{customerInfo:{status:(null===(t=r.response)||void 0===t?void 0:t.status)?r.response.status:400,method:"post",message:e}}}))}}}))},updateCustomerAddress:function(r){return o(this,void 0,void 0,(function*(){try{const o=e().customer,n=e().customerAddresses;t((()=>({customerInfo:null})));const s="/v3/customers/addresses";if(!o)return;const i=yield fetch(s,{method:"PUT",body:JSON.stringify(r),headers:{"content-type":"application/json",Accept:"application/json"}}),a=yield i.json();if(200===i.status&&200===a.status||t((()=>({customerInfo:{status:a.status,method:"post",message:`${a.title}`}}))),200===i.status){const e=a.data.map((t=>({firstName:t.first_name,lastName:t.last_name,address1:t.address1,address2:t.address2,city:t.city,countryCode:t.country_code,stateOrProvince:t.state_or_province,postalCode:t.postal_code,phone:t.phone,company:t.company,country:t.country,addressType:t.address_type,customerId:o.entityId,id:t.id}))),r=[...n,...e],s=[...new Map(r.map((t=>[t.id,t]))).values()];t((()=>({customerAddresses:[...s],customerInfo:null})))}}catch(e){const r=e;if(r){const e=(0,i.prepareErrorMessage)(r,"update an address");t((()=>{var t;return{customerInfo:{status:(null===(t=r.response)||void 0===t?void 0:t.status)?r.response.status:400,method:"post",message:e}}}))}}}))},deleteCustomerAddress:function(e){return o(this,void 0,void 0,(function*(){try{const r=`/v3/customers/addresses?id:in=${e}`;t((()=>({customerInfo:null})));const o=yield fetch(r,{method:"DELETE",headers:{"content-type":"application/json",Accept:"application/json"}});204!==o.status&&t((()=>({customerInfo:{status:o.status,method:"delete",message:o.statusText}})))}catch(e){const r=e;if(r){const e=(0,i.prepareErrorMessage)(r,"delete an address");t((()=>{var t;return{customerInfo:{status:(null===(t=r.response)||void 0===t?void 0:t.status)?r.response.status:400,method:"post",message:e}}}))}}}))},validateCustomer:function(t,e){return o(this,void 0,void 0,(function*(){try{const r={email:t,password:e};yield fetch("/v3/customers/validate-credentials",{method:"POST",body:JSON.stringify(r)})}catch(t){console.error(t)}}))},login:function(e,r){return o(this,void 0,void 0,(function*(){const o={email:e,password:r};t((()=>({customerInfo:null})));try{const e=new n.GraphQLClient(a),r=yield e.request((0,i.loginMutation)(),o);t((()=>({isLoggedIn:!0,customer:r.login.customer})))}catch(e){const r=e;if(console.error("login error",null==r?void 0:r.response),r){const e=(0,i.prepareErrorMessage)(r,"log in");t((()=>({customerInfo:{status:r.response.status?r.response.status:400,method:"post",message:e}})))}}}))},logout:function(){return o(this,void 0,void 0,(function*(){t((()=>({customerInfo:null})));try{const e=new n.GraphQLClient(a);yield e.request((0,i.logoutMutation)()),t((()=>({isLoggedIn:!1,customer:void 0})))}catch(e){const r=e;if(r){const e=(0,i.prepareErrorMessage)(r,"log out");t((()=>{var t;return{customerInfo:{status:(null===(t=r.response)||void 0===t?void 0:t.status)?r.response.status:400,method:"post",message:e}}}))}}}))},register:t=>o(void 0,void 0,void 0,(function*(){try{const{customer:e,errors:r}=yield(0,s.registerCustomerRequest)(t);return e?{errors:r,customer:e}:{errors:r,customer:void 0}}catch(t){return{errors:{".otherReason":t.message},customer:void 0}}})),recoverPassword:t=>o(void 0,void 0,void 0,(function*(){try{const{errors:e}=yield(0,s.recoverPasswordRequest)(t);return{errors:e}}catch(t){const e=t;return console.error(t),{errors:{".unexpectedError":e.message}}}})),resetPassword:t=>o(void 0,void 0,void 0,(function*(){try{const{errors:e}=yield(0,s.resetPasswordRequest)(t);return{customer:void 0,errors:e}}catch(t){return{errors:{".unexpectedError":t.message},customer:void 0}}})),changeCustomerAccountSettings:t=>o(void 0,void 0,void 0,(function*(){const{customer:e,errors:r}=yield(0,s.changeCustomerAccountSettingsRequest)(t);return e?{errors:r,customer:e}:{errors:r,customer:void 0}}))})},391:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.customerOrdersLibSubState=e.customerLibSubState=void 0;var o=r(169);Object.defineProperty(e,"customerLibSubState",{enumerable:!0,get:function(){return o.customerLibSubState}});var n=r(170);Object.defineProperty(e,"customerOrdersLibSubState",{enumerable:!0,get:function(){return n.customerOrdersLibSubState}})},170:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.customerOrdersLibSubState=void 0;const n=r(47);e.customerOrdersLibSubState=()=>(t,e)=>({orderMessages:[],getAllOrders:()=>o(void 0,void 0,void 0,(function*(){const{customer:t}=e();if(!t)return;const r=yield(0,n.getAllOrdersRequest)();return r?(yield Promise.all(r.map((t=>o(void 0,void 0,void 0,(function*(){const e=yield(0,n.getOrderProductsRequest)({url:t.products.url,page:1,limit:1});return Object.assign(Object.assign({},t),{products:e||[]})})))))).map((t=>Object.assign(Object.assign({},t),{id:t.id,dateCreated:t.date_created,dateModified:t.date_modified,status:t.status,easyPayData:void 0,billingAddress:{firstName:t.billing_address.first_name,lastName:t.billing_address.last_name,street1:t.billing_address.address1,street2:t.billing_address.address2,city:t.billing_address.city,state:t.billing_address.state,zip:t.billing_address.zip,countryCode:t.billing_address.country_code,phone:t.billing_address.phone,country:t.billing_address.country,company:t.billing_address.company},totalIncTax:t.subtotal_inc_tax,subtotalExTax:t.subtotal_ex_tax,storeCreditAmount:t.store_credit_amount,shippingAddresses:[{firstName:t.shipping_addresses.first_name,lastName:t.shipping_addresses.last_name,street1:t.shipping_addresses.address1,street2:t.shipping_addresses.address2,city:t.shipping_addresses.city,stateOrProvince:t.shipping_addresses.state,state:t.shipping_addresses.zip,zip:t.shipping_addresses.country_code,phone:t.shipping_addresses.phone,country:t.shipping_addresses.country,company:t.shipping_addresses.company}],paymentMethod:t.payment_method,products:t.products.map((t=>({productId:t.product_id,name:t.name,basePrice:t.base_price,quantity:t.quantity,productOptions:t.product_options})))}))):void 0})),getOrderMessages:function(e){return o(this,void 0,void 0,(function*(){try{const r=`/v2/orders/${e}/messages`,o=yield fetch(r,{method:"GET"}),n=yield o.json();t((()=>({orderMessages:[...n.data]})))}catch(t){console.error(t)}}))}})},194:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.generateInventoryPartialState=void 0;const o=r(390);e.generateInventoryPartialState=function({context:t}){const e=(0,o.inventorySubState)({context:t});return function(t,r){return e(t,r)}}},390:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.inventorySubState=void 0;var o=r(168);Object.defineProperty(e,"inventorySubState",{enumerable:!0,get:function(){return o.inventorySubState}})},168:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.inventorySubState=void 0;const n=r(80);e.inventorySubState=({context:t})=>(t,e)=>({inventoryProducts:{},inventoryStatus:"loading",_initInventory:function(){return o(this,void 0,void 0,(function*(){try{const e={};t((()=>({inventoryProducts:e})))}catch(t){console.error("Couldn't create a inventory products")}}))},updateInventoryProducts:function(r){return o(this,void 0,void 0,(function*(){try{const{inventoryProducts:o}=e();if(!o)return;t((()=>({inventoryStatus:"loading"})));const s=new AbortController,{signal:i}=s,a=Object.assign(Object.assign({},r),{signal:i}),c=yield(0,n.getProductInventoryV2)(a);if(void 0===c)throw t((()=>({inventoryStatus:"error"}))),new Error("Couldn't UPDATE products in the inventory");const d=(0,n.prepareProducts)(r.ids,c,o);t((()=>({inventoryProducts:d,inventoryStatus:"loaded"})))}catch(t){console.error(t)}}))}})},80:function(t,e,r){var o=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.prepareProducts=e.getPrepareProduct=e.getProductInventoryV2=e.getProductInventory=void 0;const n=r(16);e.getProductInventory=function(t,e){var r,s,i,a,c,d;return o(this,void 0,void 0,(function*(){try{const o=n.gql` query productById($productId: Int!) { site { product(entityId: $productId) { entityId inventory { isInStock aggregated { availableToSell } } } } } `,u=new n.GraphQLClient("/graphql",{signal:e}),l=yield u.request(o,{productId:t});if(!l)throw new Error("No Data");const v=!!(null===(i=null===(s=null===(r=null==l?void 0:l.site)||void 0===r?void 0:r.product)||void 0===s?void 0:s.inventory)||void 0===i?void 0:i.isInStock),p=null===(d=null===(c=null===(a=null==l?void 0:l.site)||void 0===a?void 0:a.product)||void 0===c?void 0:c.inventory)||void 0===d?void 0:d.aggregated;return null!==p?{availableForSale:v,quantity:p.availableToSell}:{availableForSale:v}}catch(t){return void console.error(t)}}))},e.getProductInventoryV2=function(t){return o(this,void 0,void 0,(function*(){const{ids:e,signal:r}=t;try{const t=n.gql` query products($productsId: [Int!]) { site { products(entityIds: $productsId) { edges { node { entityId inventory { isInStock aggregated { availableToSell } } } } } } } `,o=new n.GraphQLClient("/graphql",{signal:r}),s=yield o.request(t,{productsId:e});if(!s)throw new Error("No Data");return s.site.products.edges}catch(t){return void console.error(t)}}))},e.getPrepareProduct=t=>{var e,r,o,n;const s=null===(r=null===(e=null==t?void 0:t.node)||void 0===e?void 0:e.inventory)||void 0===r?void 0:r.isInStock,i=null===(n=null===(o=null==t?void 0:t.node)||void 0===o?void 0:o.inventory)||void 0===n?void 0:n.aggregated;return null!==i?{availableForSale:s,quantity:i.availableToSell}:{availableForSale:s}},e.prepareProducts=(t,r,o)=>(t.forEach((t=>{if(!r)return;const n=r.find((e=>t===e.node.entityId));n&&(o[t]=(0,e.getPrepareProduct)(n))})),o)},190:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.initLogicOnClientSide=void 0;const o=r(376);e.initLogicOnClientSide=()=>{"undefined"!=typeof window&&(0,o.logPageView)()}},192:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.saveCartIdToLocalStorage=e.readCartIdFromLocalStorage=void 0;const o=r(20),n="cartId-6d2bfeda-a57c-4f6a-ba2d-7e10e90350df";e.readCartIdFromLocalStorage=function(){return(0,o.readFromLocalStorage)(n)||""},e.saveCartIdToLocalStorage=function(t){(0,o.saveToLocalStorage)(n,t)}},47:function(t,e){var r=this&&this.__awaiter||function(t,e,r,o){return new(r||(r=Promise))((function(n,s){function i(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(i,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.changeCustomerAccountSettingsRequest=e.getOrderProductsRequest=e.getAllOrdersRequest=e.resetPasswordRequest=e.recoverPasswordRequest=e.registerCustomerRequest=void 0;const o="/v3/customers";e.registerCustomerRequest=function(t){return r(this,void 0,void 0,(function*(){try{const e=yield fetch(o,{method:"POST",body:JSON.stringify([t.customer])}),r=yield e.json();return e.ok?{customer:r.data[0],errors:{}}:{customer:void 0,errors:r.errors}}catch(t){const e=t;return console.error("Error occured while registering customer."),{customer:void 0,errors:{".networkError":e.message}}}}))},e.recoverPasswordRequest=function(t){return r(this,void 0,void 0,(function*(){try{const e=new FormData;return e.append("email",t.email),(yield fetch("/login.php?action=send_password_email",{method:"POST",body:e})).ok,{errors:{}}}catch(t){return{errors:{".networkError":t.message}}}}))},e.resetPasswordRequest=function(t){return r(this,void 0,void 0,(function*(){if(!t.c||!t.t)return{errors:{}};try{const e=new FormData;return e.append("password",t.password),e.append("password_confirm",t.password_confirm),yield fetch(`/login.php?action=save_new_password&c=${t.c}&t=${t.t}`,{method:"POST",body:e}),{errors:{}}}catch(t){const e=t;return console.error(t),{errors:{networkError:e.message}}}}))},e.getAllOrdersRequest=function(){return r(this,void 0,void 0,(function*(){try{const t=yield fetch("/v2/orders",{headers:{Accept:"application/json","Content-Type":"application/json"}});return 204===t.status?[]:t.ok?yield t.json():void 0}catch(t){throw console.error(t),new Error("Error occured while fetching all orders")}}))},e.getOrderProductsRequest=function(t){return r(this,void 0,void 0,(function*(){const{page:e,limit:r,url:o}=t,n=o.indexOf("/v2");try{const t=yield fetch(`${o.substring(n)}?page=${e}&limit=${r}`,{});return t.ok?t.json():void 0}catch(t){throw console.error(t),new Error("Error occured while fetching all order products")}}))},e.changeCustomerAccountSettingsRequest=function(t){return r(this,void 0,void 0,(function*(){try{const e=yield fetch(o,{method:"PUT",body:JSON.stringify([t.customer])}),r=yield e.json();return e.ok?{customer:r.data[0],errors:{}}:{customer:void 0,errors:r.errors}}catch(t){return{customer:void 0,errors:{".networkError":t.message}}}}))}}}]);