!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define("@pidelo/models",["exports"],t):t(((e=e||self).pidelo=e.pidelo||{},e.pidelo.models={}))}(this,(function(e){"use strict";
/*! *****************************************************************************
    Copyright (c) Microsoft Corporation. All rights reserved.
    Licensed under the Apache License, Version 2.0 (the "License"); you may not use
    this file except in compliance with the License. You may obtain a copy of the
    License at http://www.apache.org/licenses/LICENSE-2.0

    THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
    WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
    MERCHANTABLITY OR NON-INFRINGEMENT.

    See the Apache Version 2.0 License for specific language governing permissions
    and limitations under the License.
    ***************************************************************************** */var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,n)};function n(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r;function i(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function u(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){e.done?i(e.value):new n((function(t){t(e.value)})).then(a,u)}s((r=r.apply(e,t||[])).next())}))}function o(e,t){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function u(o){return function(u){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,u])}}}!function(e){e.None="none",e.Primary="primary",e.Secondary="secondary",e.Tertiary="tertiary",e.Success="success",e.Warning="warning",e.Danger="danger",e.Light="light",e.Medium="medium",e.Dark="dark"}(r||(r={}));var a,u=r;!function(e){e[e.Rejected=-1]="Rejected",e[e.Undefined=0]="Undefined",e[e.Received=1]="Received",e[e.Confirmed=2]="Confirmed",e[e.Delivering=3]="Delivering",e[e.Delivered=4]="Delivered",e[e.Rated=5]="Rated"}(a||(a={}));var s,c=a;!function(e){e[e.None=0]="None",e[e.Awful=1]="Awful",e[e.Bad=2]="Bad",e[e.Neutral=3]="Neutral",e[e.Good=4]="Good",e[e.Great=5]="Great"}(s||(s={}));var l,d=s;!function(e){e[e.None=0]="None",e[e.Cash=1]="Cash",e[e.Visa=2]="Visa",e[e.MasterCard=4]="MasterCard",e[e.All=7]="All"}(l||(l={}));var f=l,p=function(e){for(var t in e)e[t]&&(this[t]=e[t])},h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),v=function(){function e(e,t){this.id=t,this.rawData=e}return e.prototype.serialize=function(){return this.rawData},e}(),b=function(e){function t(n,r){void 0===n&&(n=t.EMPTY);var i=this;if(!(n instanceof t))return i=e.call(this,n,r)||this,n.owner||(i.rawData.owner=null),n.ownerRef||(i.rawData.ownerRef=null),i.data.enabled=!0===n.enabled||!0===n.active,i.rawData.defaultPrice=n.defaultPrice||n.default_price||0,i.rawData.priceZones=n.priceZones||n.price_zones||null,i.rawData.polygonArea=n.polygonArea||n.polygon_area||null,i.rawData.radius=n.radius||n.radio||0,i;i=e.call(this,n.rawData,r)||this}return n(t,e),Object.defineProperty(t.prototype,"data",{get:function(){return this.rawData},enumerable:!0,configurable:!0}),t.EMPTY={name:"",enabled:!1,defaultPrice:0,owner:null,ownerRef:null,radius:0,geolocation:null,priceZones:null,polygonArea:null},t}(v),m=function(e){function t(t){void 0===t&&(t={});var n=e.call(this,t)||this;return n.minOrder=0,n.payment_methods=[],n.paymentMethods=f.None,n.deliveryMethodsRefs=[],n.costByDeliveryMethod={},n.canDeferOrders=!1,n.deliveryMethodsRefs=t.deliveryMethodsRefs||[],n.costByDeliveryMethod=t.costByDeliveryMethod||{},n}return n(t,e),t.prototype.fetchDeliveryMethods=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return e=[],this.deliveryMethodsRefs.forEach((function(e){e.get()})),[4,Promise.all(e)];case 1:return[2,t.sent().map((function(e){return new b(e.data(),e.id)}))]}}))}))},t}(p),g=function(e){function t(t,n){var r=e.call(this,t,n)||this;return void 0===r.rawData.enabled&&(r.rawData.enabled=!1),void 0===r.rawData.sortIndex&&(r.rawData.enabled=!1,r.rawData.sortIndex=-1),r}return n(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return this.rawData.name},set:function(e){this.rawData.name=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"enabled",{get:function(){return this.rawData.enabled},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sortIndex",{get:function(){return this.rawData.sortIndex},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"image",{get:function(){return this.rawData.image},set:function(e){this.rawData.image=e},enumerable:!0,configurable:!0}),t}(v),w=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.products_count=0,t.sortIndex=0,t.subCategories=[],t}return n(t,e),t.prototype.categoryGroup=function(){return i(this,void 0,void 0,(function(){var e;return o(this,(function(t){switch(t.label){case 0:return this.categoryGroupRef?[4,this.categoryGroupRef.get()]:[3,2];case 1:if((e=t.sent()).exists)return[2,new g(e.data(),e.id)];t.label=2;case 2:return[2,void 0]}}))}))},t}(p),D=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),O=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),R=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.acceptTerms=!1,t.paymentMethod=f.None,t.accepted=!1,t.rejected=!1,t.delivered=!1,t.items=[],t.rate=0,t}return n(t,e),t.prototype.getSubTotalOrder=function(){var e=0;return this.items.forEach((function(t){e+=t.getTotal()})),e},t.prototype.getTotalOrder=function(){return this.getSubTotalOrder()+(this.deliveryCost||0)},t.prototype.packOrder=function(e,t,n,r,i){this.createdAt=e,this.customer=t,this.status=c.Received,this.customerData={name:n||"NO_NAME",phone:r},this.deliveryAddress||(this.deliveryAddress=i)},t.prototype.deliverOrder=function(e){this.deliveredAt=e,this.delivered=!0},t.prototype.acceptOrder=function(e){this.acceptedAt=e,this.accepted=!0},Object.defineProperty(t.prototype,"status",{get:function(){if(void 0===this._status){var e=c.Undefined;this.rejected?e=c.Rejected:null!=this.ratedAt?e=c.Rated:this.delivered?e=c.Delivered:null!=this.deliveryStartedAt?e=c.Delivering:this.accepted?e=c.Confirmed:this.createdAt&&(e=c.Received),this.status=e}return this._status},set:function(e){this._status=e},enumerable:!0,configurable:!0}),t}(p),A=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t.prototype.getTotal=function(){return this.price*this.qty},t}(p),M=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.owner=null,t.options=[],t}return n(t,e),t.prototype.addChild=function(e){return this.children.push(e),this},t.prototype.setForRequest=function(){this.accepted=!1,this.pending=!0,this.enabled=!0,this.rejected=!1,this.exclusive=!0,this.createdAt=new Date,this.order=1},t.prototype.initializeForImport=function(){this.accepted=!0,this.pending=!1,this.enabled=!0,this.rejected=!1,this.exclusive=!1},t}(p),P=function(){this.name="",this.multiple=!1,this.required=!1,this.values=[]},_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p),x=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return n(t,e),t}(p);e.Account=h,e.Address=y,e.Business=m,e.Category=w,e.CategoryGroup=g,e.Color=u,e.Commerce=D,e.DeliveryMethod=b,e.Item=O,e.Order=R,e.OrderItem=A,e.OrderStatus=c,e.PaymentMethod=f,e.Product=M,e.ProductOption=P,e.Rate=d,e.Schedule=_,e.SerializableModel=v,e.Stock=j,e.SubCategory=x,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=pidelo-models.umd.min.js.map